]>
Commit | Line | Data |
---|---|---|
b0ee976f DM |
1 | Ext.define('PBS.store.NavigationStore', { |
2 | extend: 'Ext.data.TreeStore', | |
3 | ||
4 | storeId: 'NavigationStore', | |
5 | ||
6 | root: { | |
7 | expanded: true, | |
8 | children: [ | |
84b9eced TL |
9 | { |
10 | text: gettext('Dashboard'), | |
11 | iconCls: 'fa fa-tachometer', | |
12 | path: 'pbsDashboard', | |
264c1958 | 13 | leaf: true, |
84b9eced | 14 | }, |
b0ee976f DM |
15 | { |
16 | text: gettext('Configuration'), | |
17 | iconCls: 'fa fa-gears', | |
18 | path: 'pbsSystemConfiguration', | |
19 | expanded: true, | |
20 | children: [ | |
88acc861 DC |
21 | { |
22 | text: gettext('User Management'), | |
23 | iconCls: 'fa fa-user', | |
24 | path: 'pbsUserView', | |
264c1958 | 25 | leaf: true, |
88acc861 | 26 | }, |
0542cfdf DC |
27 | { |
28 | text: gettext('Permissions'), | |
29 | iconCls: 'fa fa-unlock', | |
30 | path: 'pbsACLView', | |
264c1958 | 31 | leaf: true, |
0542cfdf | 32 | }, |
9e2a4653 DC |
33 | { |
34 | text: gettext('Remotes'), | |
35 | iconCls: 'fa fa-server', | |
36 | path: 'pbsRemoteView', | |
37 | leaf: true, | |
38 | }, | |
86e432b0 DC |
39 | { |
40 | text: gettext('Sync Jobs'), | |
41 | iconCls: 'fa fa-refresh', | |
42 | path: 'pbsSyncJobView', | |
43 | leaf: true, | |
44 | }, | |
b0ee976f DM |
45 | { |
46 | text: gettext('Subscription'), | |
47 | iconCls: 'fa fa-support', | |
48 | path: 'pbsSubscription', | |
264c1958 TL |
49 | leaf: true, |
50 | }, | |
51 | ], | |
b0ee976f DM |
52 | }, |
53 | { | |
54 | text: gettext('Administration'), | |
55 | iconCls: 'fa fa-wrench', | |
56 | path: 'pbsServerAdministration', | |
7f17f744 DC |
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 | }, | |
2ea501ff DC |
72 | { |
73 | text: "ZFS", | |
74 | iconCls: 'fa fa-th-large', | |
75 | path: 'pbsZFSList', | |
76 | leaf: true, | |
77 | }, | |
264c1958 TL |
78 | ], |
79 | }, | |
80 | ], | |
98bb3b90 DC |
81 | }, |
82 | { | |
58f950c5 | 83 | text: gettext('Datastore'), |
98bb3b90 DC |
84 | iconCls: 'fa fa-archive', |
85 | path: 'pbsDataStoreConfig', | |
86 | expanded: true, | |
264c1958 | 87 | leaf: false, |
98bb3b90 | 88 | }, |
264c1958 TL |
89 | ], |
90 | }, | |
b0ee976f DM |
91 | }); |
92 | ||
93 | Ext.define('PBS.view.main.NavigationTree', { | |
94 | extend: 'Ext.list.Tree', | |
95 | xtype: 'navigationtree', | |
96 | ||
ca23a97f DM |
97 | controller: { |
98 | xclass: 'Ext.app.ViewController', | |
99 | ||
100 | init: function(view) { | |
ca23a97f DM |
101 | view.rstore = Ext.create('Proxmox.data.UpdateStore', { |
102 | autoStart: true, | |
103 | interval: 15 * 1000, | |
d757021f | 104 | storeId: 'pbs-datastore-list', |
ca23a97f | 105 | storeid: 'pbs-datastore-list', |
264c1958 | 106 | model: 'pbs-datastore-list', |
ca23a97f DM |
107 | }); |
108 | ||
109 | view.rstore.on('load', this.onLoad, this); | |
110 | view.on('destroy', view.rstore.stopUpdate); | |
111 | }, | |
112 | ||
113 | onLoad: function(store, records, success) { | |
98bb3b90 | 114 | if (!success) return; |
ca23a97f DM |
115 | var view = this.getView(); |
116 | ||
117 | let root = view.getStore().getRoot(); | |
118 | ||
8277f4ac TL |
119 | // FIXME: newly added always get appended to the end.. |
120 | records.sort((a, b) => { | |
264c1958 | 121 | if (a.id > b.id) return 1; |
8277f4ac TL |
122 | if (a.id < b.id) return -1; |
123 | return 0; | |
124 | }); | |
125 | ||
98bb3b90 | 126 | var list = root.findChild('path', 'pbsDataStoreConfig', false); |
ca23a97f DM |
127 | var length = records.length; |
128 | var lookup_hash = {}; | |
129 | for (var i = 0; i < length; i++) { | |
264c1958 | 130 | let name = records[i].id; |
ca23a97f DM |
131 | lookup_hash[name] = true; |
132 | if (!list.findChild('text', name, false)) { | |
133 | list.appendChild({ | |
134 | text: name, | |
c0ac2074 | 135 | path: `DataStore-${name}`, |
bc9c306c | 136 | iconCls: 'fa fa-database', |
264c1958 | 137 | leaf: true, |
ca23a97f DM |
138 | }); |
139 | } | |
140 | } | |
141 | ||
142 | var erase_list = []; | |
143 | list.eachChild(function(node) { | |
264c1958 | 144 | let name = node.data.text; |
ca23a97f DM |
145 | if (!lookup_hash[name]) { |
146 | erase_list.push(node); | |
147 | } | |
148 | }); | |
149 | ||
150 | Ext.Array.forEach(erase_list, function(node) { node.erase(); }); | |
264c1958 | 151 | }, |
ca23a97f DM |
152 | }, |
153 | ||
b0ee976f DM |
154 | select: function(path) { |
155 | var me = this; | |
156 | var item = me.getStore().findRecord('path', path, 0, false, true, true); | |
157 | me.setSelection(item); | |
158 | }, | |
159 | ||
160 | animation: false, | |
161 | expanderOnly: true, | |
162 | expanderFirst: false, | |
163 | store: 'NavigationStore', | |
264c1958 | 164 | ui: 'nav', |
b0ee976f | 165 | }); |