mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-05-03 08:38:31 +00:00

In clusters a storage was pushed as many times as there are nodes using it. Ensure we only push a path once, do this with a memory oriented solution, i.e., build a extra object to remember what we already pushed. This is preferred over a me.findExact call as it's a o(n) vs o(n^2) solution compute wise and we make the user wait if this would need long, so reducing compute time over memory use is here a good choice - even if we will seldom run into situations where this actually will make a difference with such small data counts. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
54 lines
1.1 KiB
JavaScript
54 lines
1.1 KiB
JavaScript
Ext.define('PVE.data.PermPathStore', {
|
|
extend: 'Ext.data.Store',
|
|
alias: 'store.pvePermPath',
|
|
fields: ['value'],
|
|
autoLoad: false,
|
|
data: [
|
|
{ 'value': '/' },
|
|
{ 'value': '/access' },
|
|
{ 'value': '/nodes' },
|
|
{ 'value': '/pool' },
|
|
{ 'value': '/storage' },
|
|
{ 'value': '/vms' },
|
|
],
|
|
|
|
constructor: function(config) {
|
|
var me = this;
|
|
|
|
config = config || {};
|
|
|
|
me.callParent([config]);
|
|
|
|
let donePaths = {};
|
|
me.suspendEvents();
|
|
PVE.data.ResourceStore.each(function(record) {
|
|
let path;
|
|
switch (record.get('type')) {
|
|
case 'node': path = '/nodes/' + record.get('text');
|
|
break;
|
|
case 'qemu': path = '/vms/' + record.get('vmid');
|
|
break;
|
|
case 'lxc': path = '/vms/' + record.get('vmid');
|
|
break;
|
|
case 'storage': path = '/storage/' + record.get('storage');
|
|
break;
|
|
case 'pool': path = '/pool/' + record.get('pool');
|
|
break;
|
|
}
|
|
if (path !== undefined && !donePaths[path]) {
|
|
me.add({ value: path });
|
|
donePaths[path] = 1;
|
|
}
|
|
});
|
|
me.resumeEvents();
|
|
|
|
me.fireEvent('refresh', me);
|
|
me.fireEvent('datachanged', me);
|
|
|
|
me.sort({
|
|
property: 'value',
|
|
direction: 'ASC',
|
|
});
|
|
},
|
|
});
|