Skip to content

Commit 28ad009

Browse files
logout
1 parent 6627db5 commit 28ad009

File tree

12 files changed

+272
-377
lines changed

12 files changed

+272
-377
lines changed

src/components/HelloWorld.vue

Lines changed: 0 additions & 153 deletions
This file was deleted.

src/components/KLAvatar.vue

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<template>
2+
<v-avatar
3+
:color="user.avatar !== null ? 'white' : backgroundColor"
4+
v-bind="$attrs"
5+
>
6+
<v-img
7+
v-if="user.avatar !== null"
8+
:src="user.avatar"
9+
:alt="user.name"
10+
>
11+
<template #placeholder>
12+
<v-row
13+
class="fill-height ma-0"
14+
justify="center"
15+
align="center"
16+
>
17+
<v-progress-circular
18+
indeterminate
19+
color="primary"
20+
></v-progress-circular>
21+
</v-row>
22+
</template>
23+
</v-img>
24+
<span
25+
v-else
26+
class="white--text"
27+
:style="{ fontSize }"
28+
>
29+
{{ user.name.charAt(0) }}
30+
</span>
31+
</v-avatar>
32+
</template>
33+
34+
<script lang="ts">
35+
import { User } from '@/interfaces/user'
36+
import { Vue, Component, Prop } from 'vue-property-decorator'
37+
import { mapGetters } from 'vuex'
38+
39+
@Component({
40+
computed: {
41+
...mapGetters({
42+
user: 'account/loggedInUser'
43+
})
44+
}
45+
})
46+
export default class KLAvatar extends Vue {
47+
@Prop({ type: String, default: 'secondary' }) readonly backgroundColor!: string
48+
49+
user!: User
50+
51+
get fontSize (): string {
52+
let imgSize: number | string = this.$attrs.size || '48'
53+
imgSize = parseInt(imgSize) * 0.5
54+
return imgSize.toString() + 'px'
55+
}
56+
}
57+
</script>
58+
59+
<style scoped lang="scss">
60+
61+
</style>

src/components/KLDialogConfirm.vue

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<template>
2+
<v-dialog
3+
v-model="localValue"
4+
width="500"
5+
>
6+
<v-card>
7+
<v-card-title>
8+
Please confirm
9+
</v-card-title>
10+
<v-card-text>
11+
<slot></slot>
12+
</v-card-text>
13+
<v-card-actions>
14+
<v-spacer></v-spacer>
15+
<v-btn
16+
text
17+
@click="$emit('cancel')"
18+
>
19+
Cancel
20+
</v-btn>
21+
<v-btn
22+
color="primary"
23+
depressed
24+
:loading="loading"
25+
@click="$emit('confirm')"
26+
>
27+
Confirm
28+
</v-btn>
29+
</v-card-actions>
30+
</v-card>
31+
</v-dialog>
32+
</template>
33+
34+
<script lang="ts">
35+
import { Vue, Component, Prop } from 'vue-property-decorator'
36+
37+
@Component
38+
export default class KLDialogConfirm extends Vue {
39+
@Prop(Boolean) readonly value!: boolean
40+
@Prop(Boolean) readonly loading!: boolean
41+
42+
get localValue (): boolean {
43+
return this.value
44+
}
45+
46+
set localValue (value: boolean) {
47+
this.$emit('input', value)
48+
}
49+
}
50+
</script>
51+
52+
<style scoped lang="scss">
53+
54+
</style>

src/layouts/LayoutClassroomTeacher.vue

Lines changed: 22 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -75,47 +75,27 @@
7575
</v-tabs>
7676

7777
<router-view v-if="classroomFound" class="mt-5"></router-view>
78-
</div>
79-
</v-container>
8078

81-
<v-dialog
82-
v-model="confirmDelete"
83-
width="500"
84-
>
85-
<v-card>
86-
<v-card-title>
87-
Please confirm
88-
</v-card-title>
89-
<v-card-text>
90-
<p>
91-
You are deleting classroom <strong>{{ classroom.name }}</strong>.
92-
</p>
93-
<div class="error--text">
94-
<v-icon color="error">
95-
mdi-alert-outline
96-
</v-icon>
97-
This cannot be undone!
79+
<KLDialogConfirm
80+
v-model="confirmDelete"
81+
:loading="deleting"
82+
@confirm="deleteClassroom"
83+
@cancel="confirmDelete = false"
84+
>
85+
<div>
86+
<p>
87+
You are deleting classroom <strong>{{ classroom.name }}</strong>.
88+
</p>
89+
<div class="error--text">
90+
<v-icon color="error">
91+
mdi-alert-outline
92+
</v-icon>
93+
This cannot be undone!
94+
</div>
9895
</div>
99-
</v-card-text>
100-
<v-card-actions>
101-
<v-spacer></v-spacer>
102-
<v-btn
103-
text
104-
@click="confirmDelete = false"
105-
>
106-
Cancel
107-
</v-btn>
108-
<v-btn
109-
color="primary"
110-
depressed
111-
:loading="deleting"
112-
@click="deleteClassroom"
113-
>
114-
Confirm
115-
</v-btn>
116-
</v-card-actions>
117-
</v-card>
118-
</v-dialog>
96+
</KLDialogConfirm>
97+
</div>
98+
</v-container>
11999
</LayoutDefault>
120100
</template>
121101

@@ -125,10 +105,12 @@ import { unexpectedExc } from '@/utils'
125105
import { Vue, Component } from 'vue-property-decorator'
126106
import { mapMutations, mapState } from 'vuex'
127107
import LayoutDefault from './LayoutDefault.vue'
108+
import KLDialogConfirm from '@/components/KLDialogConfirm.vue'
128109
129110
@Component({
130111
components: {
131-
LayoutDefault
112+
LayoutDefault,
113+
KLDialogConfirm
132114
},
133115
computed: {
134116
...mapState('classroom', {

src/layouts/LayoutDefault.vue

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,17 @@
2424
<router-link
2525
v-else
2626
:to="{ name: 'MyInfo' }"
27-
class="white--text"
27+
class="white--text user-info"
2828
>
29-
{{ user.name }}
29+
<v-btn
30+
large
31+
text
32+
>
33+
<KLAvatar size="40"></KLAvatar>
34+
<span class="ml-3">
35+
{{ user.name }}
36+
</span>
37+
</v-btn>
3038
</router-link>
3139
</div>
3240
</v-app-bar>
@@ -57,15 +65,25 @@
5765
import { User } from '@/interfaces/user'
5866
import { Vue, Component } from 'vue-property-decorator'
5967
import { mapGetters } from 'vuex'
68+
import KLAvatar from '@/components/KLAvatar.vue'
6069
6170
@Component({
6271
computed: {
6372
...mapGetters({
6473
user: 'account/loggedInUser'
6574
})
75+
},
76+
components: {
77+
KLAvatar
6678
}
6779
})
6880
export default class LayoutDefault extends Vue {
6981
user!: User
7082
}
7183
</script>
84+
85+
<style lang="scss" scoped>
86+
.user-info {
87+
text-decoration: none;
88+
}
89+
</style>

0 commit comments

Comments
 (0)