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