]>
git.proxmox.com Git - proxmox-backup.git/blob - www/NavigationTree.js
1 Ext
.define('pbs-datastore-list', {
2 extend
: 'Ext.data.Model',
3 fields
: ['name', 'comment'],
6 url
: "/api2/json/admin/datastore",
11 Ext
.define('PBS.store.NavigationStore', {
12 extend
: 'Ext.data.TreeStore',
14 storeId
: 'NavigationStore',
20 text
: gettext('Dashboard'),
21 iconCls
: 'fa fa-tachometer',
26 text
: gettext('Configuration'),
27 iconCls
: 'fa fa-gears',
28 path
: 'pbsSystemConfiguration',
32 text
: gettext('Access Control'),
34 path
: 'pbsAccessControlPanel',
38 text
: gettext('Remotes'),
39 iconCls
: 'fa fa-server',
40 path
: 'pbsRemoteView',
44 text
: gettext('Subscription'),
45 iconCls
: 'fa fa-support',
46 path
: 'pbsSubscription',
52 text
: gettext('Administration'),
53 iconCls
: 'fa fa-wrench',
54 path
: 'pbsServerAdministration',
59 text
: gettext('Disks'),
60 iconCls
: 'fa fa-hdd-o',
65 text
: Proxmox
.Utils
.directoryText
,
66 iconCls
: 'fa fa-folder',
67 path
: 'pbsDirectoryList',
72 iconCls
: 'fa fa-th-large',
81 text
: gettext('Datastore'),
82 iconCls
: 'fa fa-archive',
89 text
: gettext('Add Datastore'),
90 iconCls
: 'fa fa-plus-circle',
100 Ext
.define('PBS.view.main.NavigationTree', {
101 extend
: 'Ext.list.Tree',
102 xtype
: 'navigationtree',
105 xclass
: 'Ext.app.ViewController',
107 init: function(view
) {
108 view
.rstore
= Ext
.create('Proxmox.data.UpdateStore', {
111 storeId
: 'pbs-datastore-list',
112 storeid
: 'pbs-datastore-list',
113 model
: 'pbs-datastore-list',
116 view
.rstore
.on('load', this.onLoad
, this);
117 view
.on('destroy', view
.rstore
.stopUpdate
);
120 onLoad: function(store
, records
, success
) {
121 if (!success
) return;
122 var view
= this.getView();
124 let root
= view
.getStore().getRoot();
126 records
.sort((a
, b
) => a
.id
.localeCompare(b
.id
));
128 var list
= root
.findChild('id', 'datastores', false);
129 var length
= records
.length
;
130 var lookup_hash
= {};
132 for (let i
= 0; i
< length
; i
++) {
133 let name
= records
[i
].id
;
134 lookup_hash
[name
] = true;
136 while (name
.localeCompare(list
.getChildAt(j
).data
.text
) > 0 &&
137 (j
+ 1) < list
.childNodes
.length
) {
141 if (list
.getChildAt(j
).data
.text
.localeCompare(name
) !== 0) {
142 list
.insertChild(j
, {
144 path
: `DataStore-${name}`,
145 iconCls
: 'fa fa-database',
152 list
.eachChild(function(node
) {
153 let name
= node
.data
.text
;
154 if (!lookup_hash
[name
] && node
.data
.id
!== 'addbutton') {
155 erase_list
.push(node
);
159 Ext
.Array
.forEach(erase_list
, function(node
) { list
.removeChild(node
, true); });
161 if (view
.pathToSelect
!== undefined) {
162 let path
= view
.pathToSelect
;
163 delete view
.pathToSelect
;
164 view
.select(path
, true);
170 itemclick: function(tl
, info
) {
171 if (info
.node
.data
.id
=== 'datastores') {
174 if (info
.node
.data
.id
=== 'addbutton') {
176 Ext
.create('PBS.DataStoreEdit', {
178 destroy: function() {
189 select: function(path
, silent
) {
191 if (me
.rstore
.isLoaded()) {
193 me
.suspendEvents(false);
195 var item
= me
.getStore().findRecord('path', path
, 0, false, true, true);
196 me
.setSelection(item
);
198 me
.resumeEvents(true);
201 me
.pathToSelect
= path
;
207 expanderFirst
: false,
208 store
: 'NavigationStore',