forked from genieacs/genieacs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin-menu.ts
104 lines (93 loc) · 2.74 KB
/
admin-menu.ts
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
/**
* Copyright 2013-2019 GenieACS Inc.
*
* This file is part of GenieACS.
*
* GenieACS is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* GenieACS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with GenieACS. If not, see <http://www.gnu.org/licenses/>.
*/
import m from "mithril";
import { ClosureComponent, Component } from "mithril";
const component: ClosureComponent = (): Component => {
return {
view: (vnode) => {
const active = { [vnode.attrs["page"]]: "active" };
const tabs = [];
if (window.authorizer.hasAccess("presets", 1)) {
tabs.push(
m(
"li",
{ class: active["presets"] },
m("a", { href: "#!/admin/presets" }, "Presets")
)
);
}
if (window.authorizer.hasAccess("provisions", 1)) {
tabs.push(
m(
"li",
{ class: active["provisions"] },
m("a", { href: "#!/admin/provisions" }, "Provisions")
)
);
}
if (window.authorizer.hasAccess("virtualParameters", 1)) {
tabs.push(
m(
"li",
{ class: active["virtualParameters"] },
m("a", { href: "#!/admin/virtualParameters" }, "Virtual Parameters")
)
);
}
if (window.authorizer.hasAccess("files", 1)) {
tabs.push(
m(
"li",
{ class: active["files"] },
m("a", { href: "#!/admin/files" }, "Files")
)
);
}
if (window.authorizer.hasAccess("config", 1)) {
tabs.push(
m(
"li",
{ class: active["config"] },
m("a", { href: "#!/admin/config" }, "Config")
)
);
}
if (window.authorizer.hasAccess("permissions", 1)) {
tabs.push(
m(
"li",
{ class: active["permissions"] },
m("a", { href: "#!/admin/permissions" }, "Permissions")
)
);
}
if (window.authorizer.hasAccess("users", 1)) {
tabs.push(
m(
"li",
{ class: active["users"] },
m("a", { href: "#!/admin/users" }, "Users")
)
);
}
return m("nav#side-menu", m("ul", tabs));
},
};
};
export default component;