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