]> git.proxmox.com Git - proxmox-backup.git/blob - www/NavigationTree.js
ui: replace DataStoreStatus with DataStoreConfig
[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 leaf: true
58 },
59 {
60 text: gettext('Data Store'),
61 iconCls: 'fa fa-archive',
62 path: 'pbsDataStoreConfig',
63 expanded: true,
64 leaf: false
65 },
66 ]
67 }
68 });
69
70 Ext.define('PBS.view.main.NavigationTree', {
71 extend: 'Ext.list.Tree',
72 xtype: 'navigationtree',
73
74 controller: {
75 xclass: 'Ext.app.ViewController',
76
77 init: function(view) {
78
79 view.rstore = Ext.create('Proxmox.data.UpdateStore', {
80 autoStart: true,
81 interval: 15 * 1000,
82 storeid: 'pbs-datastore-list',
83 model: 'pbs-datastore-list'
84 });
85
86 view.rstore.on('load', this.onLoad, this);
87 view.on('destroy', view.rstore.stopUpdate);
88 },
89
90 onLoad: function(store, records, success) {
91 if (!success) return;
92 var view = this.getView();
93
94 let root = view.getStore().getRoot();
95
96 // FIXME: newly added always get appended to the end..
97 records.sort((a, b) => {
98 if (a.id > b.id) return 1;
99 if (a.id < b.id) return -1;
100 return 0;
101 });
102
103 var list = root.findChild('path', 'pbsDataStoreConfig', false);
104 var length = records.length;
105 var lookup_hash = {};
106 for (var i = 0; i < length; i++) {
107 var name = records[i].id;
108 lookup_hash[name] = true;
109 if (!list.findChild('text', name, false)) {
110 list.appendChild({
111 text: name,
112 path: `DataStore-${name}`,
113 iconCls: 'fa fa-database',
114 leaf: true
115 });
116 }
117 }
118
119 var erase_list = [];
120 list.eachChild(function(node) {
121 var name = node.data.text;
122 if (!lookup_hash[name]) {
123 erase_list.push(node);
124 }
125 });
126
127 Ext.Array.forEach(erase_list, function(node) { node.erase(); });
128
129 }
130 },
131
132 select: function(path) {
133 var me = this;
134 var item = me.getStore().findRecord('path', path, 0, false, true, true);
135 me.setSelection(item);
136 },
137
138 animation: false,
139 expanderOnly: true,
140 expanderFirst: false,
141 store: 'NavigationStore',
142 ui: 'nav'
143 });