]>
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('User Management'),
33 iconCls
: 'fa fa-user',
38 text
: gettext('Permissions'),
39 iconCls
: 'fa fa-unlock',
44 text
: gettext('Remotes'),
45 iconCls
: 'fa fa-server',
46 path
: 'pbsRemoteView',
50 text
: gettext('Subscription'),
51 iconCls
: 'fa fa-support',
52 path
: 'pbsSubscription',
58 text
: gettext('Administration'),
59 iconCls
: 'fa fa-wrench',
60 path
: 'pbsServerAdministration',
65 text
: gettext('Disks'),
66 iconCls
: 'fa fa-hdd-o',
71 text
: Proxmox
.Utils
.directoryText
,
72 iconCls
: 'fa fa-folder',
73 path
: 'pbsDirectoryList',
78 iconCls
: 'fa fa-th-large',
87 text
: gettext('Datastore'),
88 iconCls
: 'fa fa-archive',
95 text
: gettext('Add Datastore'),
96 iconCls
: 'fa fa-plus-circle',
106 Ext
.define('PBS.view.main.NavigationTree', {
107 extend
: 'Ext.list.Tree',
108 xtype
: 'navigationtree',
111 xclass
: 'Ext.app.ViewController',
113 init: function(view
) {
114 view
.rstore
= Ext
.create('Proxmox.data.UpdateStore', {
117 storeId
: 'pbs-datastore-list',
118 storeid
: 'pbs-datastore-list',
119 model
: 'pbs-datastore-list',
122 view
.rstore
.on('load', this.onLoad
, this);
123 view
.on('destroy', view
.rstore
.stopUpdate
);
126 onLoad: function(store
, records
, success
) {
127 if (!success
) return;
128 var view
= this.getView();
130 let root
= view
.getStore().getRoot();
132 records
.sort((a
, b
) => a
.id
.localeCompare(b
.id
));
134 var list
= root
.findChild('id', 'datastores', false);
135 var length
= records
.length
;
136 var lookup_hash
= {};
138 for (let i
= 0; i
< length
; i
++) {
139 let name
= records
[i
].id
;
140 lookup_hash
[name
] = true;
142 while (name
.localeCompare(list
.getChildAt(j
).data
.text
) > 0 &&
143 (j
+ 1) < list
.childNodes
.length
) {
147 if (list
.getChildAt(j
).data
.text
.localeCompare(name
) !== 0) {
148 list
.insertChild(j
, {
150 path
: `DataStore-${name}`,
151 iconCls
: 'fa fa-database',
158 list
.eachChild(function(node
) {
159 let name
= node
.data
.text
;
160 if (!lookup_hash
[name
] && node
.data
.id
!== 'addbutton') {
161 erase_list
.push(node
);
165 Ext
.Array
.forEach(erase_list
, function(node
) { list
.removeChild(node
, true); });
167 if (view
.pathToSelect
!== undefined) {
168 let path
= view
.pathToSelect
;
169 delete view
.pathToSelect
;
170 view
.select(path
, true);
176 itemclick: function(tl
, info
) {
177 if (info
.node
.data
.id
=== 'datastores') {
180 if (info
.node
.data
.id
=== 'addbutton') {
182 Ext
.create('PBS.DataStoreEdit', {
184 destroy: function() {
195 select: function(path
, silent
) {
197 if (me
.rstore
.isLoaded()) {
199 me
.suspendEvents(false);
201 var item
= me
.getStore().findRecord('path', path
, 0, false, true, true);
202 me
.setSelection(item
);
204 me
.resumeEvents(true);
207 me
.pathToSelect
= path
;
213 expanderFirst
: false,
214 store
: 'NavigationStore',