This repository was archived by the owner on Apr 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 71
/
Copy pathleft-menu.js
83 lines (78 loc) · 2.38 KB
/
left-menu.js
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
import { RawCMS } from '../../../../config/raw-cms.js';
import { vuexStore } from '../../../../config/vuex.js';
import { evtToggleDrawer } from '../../events.js';
import { loginService } from '../../services/login.service.js';
import { UserAvatarDef } from '../user-avatar/user-avatar.js';
const _LeftMenu = async (resolve, reject) => {
const tpl = await RawCMS.loadComponentTpl(
'/modules/core/components/left-menu/left-menu.tpl.html'
);
const avatarDef = await UserAvatarDef();
resolve({
components: {
UserAvatar: avatarDef,
},
computed: {
userinfo: function() {
return vuexStore.state.core.userInfo || {};
},
},
data: function() {
return {
isVisible: false,
isUserMenuVisible: false,
items: [
{ icon: 'mdi-home', text: 'Home', route: 'home' },
{ icon: 'mdi-account', text: 'Users', route: 'users' },
{ icon: 'mdi-cube', text: 'Entities', route: 'entities' },
{ icon: 'mdi-book-open', text: 'Collections', route: 'collections' },
{ icon: 'mdi-circle', text: 'Lambdas', route: 'lambdas' },
{ icon: 'mdi-settings', text: 'Configuration', route: 'plugins' },
{
icon: 'mdi-file-document-outline',
text: 'Dev portal',
extLink: RawCMS.env.api.baseUrl,
},
],
bottomItem: { icon: 'mdi-information', text: 'About', route: 'about' },
};
},
methods: {
toggleVisibility: function() {
this.isVisible = !this.isVisible;
},
toggleUserMenuVisibility: function() {
this.isUserMenuVisible = !this.isUserMenuVisible;
},
goTo: function(item) {
if (item === null || item === undefined) {
return;
}
// Ext link
if (item.extLink) {
window.open(item.extLink);
return;
}
// Internal route
if (this.isActive(item)) {
return;
}
this.$router.push({ name: item.route });
},
isActive: function(item) {
return item.route === this.$route.name;
},
logout: async function() {
loginService.logout();
},
},
mounted: function() {
RawCMS.eventBus.$on(evtToggleDrawer, () => {
this.toggleVisibility();
});
},
template: tpl,
});
};
export const LeftMenu = _LeftMenu;
export default _LeftMenu;