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