]> git.proxmox.com Git - proxmox-backup.git/blob - www/NavigationTree.js
ui: add ACL panel to Configuration
[proxmox-backup.git] / www / NavigationTree.js
1 Ext.define('PBS.store.NavigationStore', {
2 extend: 'Ext.data.TreeStore',
3
4 storeId: 'NavigationStore',
5
6 root: {
7 expanded: true,
8 children: [
9 {
10 text: gettext('Dashboard'),
11 iconCls: 'fa fa-tachometer',
12 path: 'pbsDashboard',
13 leaf: true
14 },
15 {
16 text: gettext('Configuration'),
17 iconCls: 'fa fa-gears',
18 path: 'pbsSystemConfiguration',
19 expanded: true,
20 children: [
21 {
22 text: gettext('User Management'),
23 iconCls: 'fa fa-user',
24 path: 'pbsUserView',
25 leaf: true
26 },
27 {
28 text: gettext('Permissions'),
29 iconCls: 'fa fa-unlock',
30 path: 'pbsACLView',
31 leaf: true
32 },
33 {
34 text: gettext('Data Store'),
35 iconCls: 'fa fa-archive',
36 path: 'pbsDataStoreConfig',
37 leaf: true
38 },
39 {
40 text: gettext('Subscription'),
41 iconCls: 'fa fa-support',
42 path: 'pbsSubscription',
43 leaf: true
44 }
45 ]
46 },
47 {
48 text: gettext('Administration'),
49 iconCls: 'fa fa-wrench',
50 path: 'pbsServerAdministration',
51 leaf: true
52 }
53 ]
54 }
55 });
56
57 Ext.define('PBS.view.main.NavigationTree', {
58 extend: 'Ext.list.Tree',
59 xtype: 'navigationtree',
60
61 controller: {
62 xclass: 'Ext.app.ViewController',
63
64 init: function(view) {
65
66 view.rstore = Ext.create('Proxmox.data.UpdateStore', {
67 autoStart: true,
68 interval: 15 * 1000,
69 storeid: 'pbs-datastore-list',
70 model: 'pbs-datastore-list'
71 });
72
73 view.rstore.on('load', this.onLoad, this);
74 view.on('destroy', view.rstore.stopUpdate);
75 },
76
77 onLoad: function(store, records, success) {
78 var view = this.getView();
79
80 let root = view.getStore().getRoot();
81
82 if (!root.findChild('path', 'pbsDataStoreStatus', false)) {
83 root.appendChild({
84 text: gettext('Data Store'),
85 expanded: true,
86 iconCls: 'fa fa-archive',
87 path: 'pbsDataStoreStatus',
88 leaf: false
89 });
90 }
91
92 var list = root.findChild('path', 'pbsDataStoreStatus', false);
93 var length = records.length;
94 var lookup_hash = {};
95 for (var i = 0; i < length; i++) {
96 var name = records[i].id;
97 lookup_hash[name] = true;
98 if (!list.findChild('text', name, false)) {
99 list.appendChild({
100 text: name,
101 path: 'pbsDataStoreContent:' + name,
102 iconCls: 'fa fa-database',
103 leaf: true
104 });
105 }
106 }
107
108 var erase_list = [];
109 list.eachChild(function(node) {
110 var name = node.data.text;
111 if (!lookup_hash[name]) {
112 erase_list.push(node);
113 }
114 });
115
116 Ext.Array.forEach(erase_list, function(node) { node.erase(); });
117
118 }
119 },
120
121 select: function(path) {
122 var me = this;
123 var item = me.getStore().findRecord('path', path, 0, false, true, true);
124 me.setSelection(item);
125 },
126
127 animation: false,
128 expanderOnly: true,
129 expanderFirst: false,
130 store: 'NavigationStore',
131 ui: 'nav'
132 });