add datastore content panel

This commit is contained in:
Dietmar Maurer
2019-12-20 12:46:09 +01:00
parent 5e62d19cfb
commit ca23a97f0e
4 changed files with 156 additions and 17 deletions

View File

@ -46,6 +46,66 @@ Ext.define('PBS.view.main.NavigationTree', {
extend: 'Ext.list.Tree',
xtype: 'navigationtree',
controller: {
xclass: 'Ext.app.ViewController',
init: function(view) {
view.rstore = Ext.create('Proxmox.data.UpdateStore', {
autoStart: true,
interval: 15 * 1000,
storeid: 'pbs-datastore-list',
model: 'pbs-data-store-config'
});
view.rstore.on('load', this.onLoad, this);
view.on('destroy', view.rstore.stopUpdate);
},
onLoad: function(store, records, success) {
var view = this.getView();
let root = view.getStore().getRoot();
if (!root.findChild('path', 'pbsDataStoreList', false)) {
root.appendChild({
text: gettext('Data Store'),
expanded: true,
iconCls: 'fa fa-archive',
path: 'pbsDataStoreList',
leaf: false
});
}
var list = root.findChild('path', 'pbsDataStoreList', false);
var length = records.length;
var lookup_hash = {};
for (var i = 0; i < length; i++) {
var name = records[i].id;
lookup_hash[name] = true;
if (!list.findChild('text', name, false)) {
list.appendChild({
text: name,
path: 'pbsDataStoreContent:' + name,
iconCls: 'fa fa-hdd-o',
leaf: true
});
}
}
var erase_list = [];
list.eachChild(function(node) {
var name = node.data.text;
if (!lookup_hash[name]) {
erase_list.push(node);
}
});
Ext.Array.forEach(erase_list, function(node) { node.erase(); });
}
},
select: function(path) {
var me = this;
var item = me.getStore().findRecord('path', path, 0, false, true, true);