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