]> git.proxmox.com Git - proxmox-backup.git/blob - www/NavigationTree.js
ui: acl: add improved permission selector
[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('Remotes'),
35 iconCls: 'fa fa-server',
36 path: 'pbsRemoteView',
37 leaf: true,
38 },
39 {
40 text: gettext('Sync Jobs'),
41 iconCls: 'fa fa-refresh',
42 path: 'pbsSyncJobView',
43 leaf: true,
44 },
45 {
46 text: gettext('Subscription'),
47 iconCls: 'fa fa-support',
48 path: 'pbsSubscription',
49 leaf: true
50 }
51 ]
52 },
53 {
54 text: gettext('Administration'),
55 iconCls: 'fa fa-wrench',
56 path: 'pbsServerAdministration',
57 expanded: true,
58 leaf: false,
59 children: [
60 {
61 text: gettext('Disks'),
62 iconCls: 'fa fa-hdd-o',
63 path: 'pmxDiskList',
64 leaf: false,
65 children: [
66 {
67 text: Proxmox.Utils.directoryText,
68 iconCls: 'fa fa-folder',
69 path: 'pbsDirectoryList',
70 leaf: true,
71 },
72 {
73 text: "ZFS",
74 iconCls: 'fa fa-th-large',
75 path: 'pbsZFSList',
76 leaf: true,
77 },
78 ]
79 }
80 ]
81 },
82 {
83 text: gettext('Datastore'),
84 iconCls: 'fa fa-archive',
85 path: 'pbsDataStoreConfig',
86 expanded: true,
87 leaf: false
88 },
89 ]
90 }
91 });
92
93 Ext.define('PBS.view.main.NavigationTree', {
94 extend: 'Ext.list.Tree',
95 xtype: 'navigationtree',
96
97 controller: {
98 xclass: 'Ext.app.ViewController',
99
100 init: function(view) {
101
102 view.rstore = Ext.create('Proxmox.data.UpdateStore', {
103 autoStart: true,
104 interval: 15 * 1000,
105 storeId: 'pbs-datastore-list',
106 storeid: 'pbs-datastore-list',
107 model: 'pbs-datastore-list'
108 });
109
110 view.rstore.on('load', this.onLoad, this);
111 view.on('destroy', view.rstore.stopUpdate);
112 },
113
114 onLoad: function(store, records, success) {
115 if (!success) return;
116 var view = this.getView();
117
118 let root = view.getStore().getRoot();
119
120 // FIXME: newly added always get appended to the end..
121 records.sort((a, b) => {
122 if (a.id > b.id) return 1;
123 if (a.id < b.id) return -1;
124 return 0;
125 });
126
127 var list = root.findChild('path', 'pbsDataStoreConfig', false);
128 var length = records.length;
129 var lookup_hash = {};
130 for (var i = 0; i < length; i++) {
131 var name = records[i].id;
132 lookup_hash[name] = true;
133 if (!list.findChild('text', name, false)) {
134 list.appendChild({
135 text: name,
136 path: `DataStore-${name}`,
137 iconCls: 'fa fa-database',
138 leaf: true
139 });
140 }
141 }
142
143 var erase_list = [];
144 list.eachChild(function(node) {
145 var name = node.data.text;
146 if (!lookup_hash[name]) {
147 erase_list.push(node);
148 }
149 });
150
151 Ext.Array.forEach(erase_list, function(node) { node.erase(); });
152
153 }
154 },
155
156 select: function(path) {
157 var me = this;
158 var item = me.getStore().findRecord('path', path, 0, false, true, true);
159 me.setSelection(item);
160 },
161
162 animation: false,
163 expanderOnly: true,
164 expanderFirst: false,
165 store: 'NavigationStore',
166 ui: 'nav'
167 });