From baed2b7c417dffbc907decc07b15c6a4632f8224 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Sun, 24 May 2020 02:10:47 +0200 Subject: [PATCH] fix #2574: ui: permission-path selector: push each unique path only once 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 --- www/manager6/data/PermPathStore.js | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/www/manager6/data/PermPathStore.js b/www/manager6/data/PermPathStore.js index fc14d504..051da3cf 100644 --- a/www/manager6/data/PermPathStore.js +++ b/www/manager6/data/PermPathStore.js @@ -19,28 +19,26 @@ Ext.define('PVE.data.PermPathStore', { me.callParent([config]); + let donePaths = {}; me.suspendEvents(); PVE.data.ResourceStore.each(function(record) { + let path; switch (record.get('type')) { - case 'node': - me.add({value: '/nodes/' + record.get('text')}); + case 'node': path = '/nodes/' + record.get('text'); break; - - case 'qemu': - me.add({value: '/vms/' + record.get('vmid')}); + case 'qemu': path = '/vms/' + record.get('vmid'); break; - - case 'lxc': - me.add({value: '/vms/' + record.get('vmid')}); + case 'lxc': path = '/vms/' + record.get('vmid'); break; - - case 'storage': - me.add({value: '/storage/' + record.get('storage')}); + case 'storage': path = '/storage/' + record.get('storage'); break; - case 'pool': - me.add({value: '/pool/' + record.get('pool')}); + case 'pool': path = '/pool/' + record.get('pool'); break; } + if (path !== undefined && !donePaths[path]) { + me.add({ value: path }); + donePaths[path] = 1; + } }); me.resumeEvents();