forked from apache/cloudstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserMenu.vue
More file actions
134 lines (125 loc) · 4.01 KB
/
Copy pathUserMenu.vue
File metadata and controls
134 lines (125 loc) · 4.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
<template>
<div class="user-menu">
<translation-menu class="action"/>
<header-notice class="action"/>
<label class="user-menu-server-info action">
<a-icon
slot="prefix"
type="database"
:style="[{
color: $config.theme['@primary-color']
}]"></a-icon>
{{ server.name || server.apiBase || 'Local-Server' }}
</label>
<a-dropdown>
<span class="user-menu-dropdown action">
<a-avatar class="user-menu-avatar avatar" size="small" :src="avatar()"/>
<span>{{ nickname() }}</span>
</span>
<a-menu slot="overlay" class="user-menu-wrapper">
<a-menu-item class="user-menu-item" key="0">
<router-link :to="{ path: '/accountuser/' + $store.getters.userInfo.id }">
<a-icon class="user-menu-item-icon" type="user"/>
<span class="user-menu-item-name">{{ $t('label.profilename') }}</span>
</router-link>
</a-menu-item>
<a-menu-item class="user-menu-item" key="1">
<a @click="toggleUseBrowserTimezone">
<a-icon class="user-menu-item-icon" type="clock-circle"/>
<span class="user-menu-item-name" style="margin-right: 5px">{{ $t('label.use.local.timezone') }}</span>
<a-switch
:checked="$store.getters.usebrowsertimezone" />
</a>
</a-menu-item>
<a-menu-item class="user-menu-item" key="2" disabled>
<a :href="$config.docBase" target="_blank">
<a-icon class="user-menu-item-icon" type="question-circle-o"></a-icon>
<span class="user-menu-item-name">{{ $t('label.help') }}</span>
</a>
</a-menu-item>
<a-menu-divider/>
<a-menu-item class="user-menu-item" key="3">
<a href="javascript:;" @click="handleLogout">
<a-icon class="user-menu-item-icon" type="logout"/>
<span class="user-menu-item-name">{{ $t('label.logout') }}</span>
</a>
</a-menu-item>
</a-menu>
</a-dropdown>
</div>
</template>
<script>
import Vue from 'vue'
import HeaderNotice from './HeaderNotice'
import TranslationMenu from './TranslationMenu'
import { mapActions, mapGetters } from 'vuex'
import { SERVER_MANAGER } from '@/store/mutation-types'
export default {
name: 'UserMenu',
components: {
TranslationMenu,
HeaderNotice
},
computed: {
server () {
return Vue.ls.get(SERVER_MANAGER) || this.$config.servers[0]
}
},
methods: {
...mapActions(['Logout']),
...mapGetters(['nickname', 'avatar']),
toggleUseBrowserTimezone () {
this.$store.dispatch('SetUseBrowserTimezone', !this.$store.getters.usebrowsertimezone)
},
handleLogout () {
return this.Logout({}).then(() => {
this.$router.push('/user/login')
}).catch(err => {
this.$message.error({
title: 'Failed to Logout',
description: err.message
})
})
}
}
}
</script>
<style lang="less" scoped>
.user-menu {
&-wrapper {
padding: 4px 0;
}
&-item {
width: auto;
}
&-item-name {
user-select: none;
margin-left: 8px;
}
&-item-icon i {
min-width: 12px;
margin-right: 8px;
}
&-server-info {
.anticon {
margin-right: 5px;
}
}
}
</style>