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