From cd84df4c6e9a689a6a3cc936283c146bebbc721b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Jochum?= Date: Tue, 8 May 2018 15:15:38 +0200 Subject: [PATCH] fix #1499 Implement a combobox for Permissions paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: René Jochum --- www/manager6/Makefile | 2 + www/manager6/data/PermPathStore.js | 54 +++++++++++++++++++++++++++ www/manager6/dc/ACLView.js | 2 +- www/manager6/form/PermPathSelector.js | 12 ++++++ 4 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 www/manager6/data/PermPathStore.js create mode 100644 www/manager6/form/PermPathSelector.js diff --git a/www/manager6/Makefile b/www/manager6/Makefile index a2bd4576c..3cc6990f0 100644 --- a/www/manager6/Makefile +++ b/www/manager6/Makefile @@ -14,6 +14,7 @@ JSSRC= \ lxc/CmdMenu.js \ node/CmdMenu.js \ VNCConsole.js \ + data/PermPathStore.js \ data/ResourceStore.js \ data/model/Realm.js \ data/model/RRDModels.js \ @@ -59,6 +60,7 @@ JSSRC= \ form/USBSelector.js \ form/CalendarEvent.js \ form/CephPoolSelector.js \ + form/PermPathSelector.js \ dc/Tasks.js \ dc/Log.js \ panel/StatusPanel.js \ diff --git a/www/manager6/data/PermPathStore.js b/www/manager6/data/PermPathStore.js new file mode 100644 index 000000000..c88f4cee1 --- /dev/null +++ b/www/manager6/data/PermPathStore.js @@ -0,0 +1,54 @@ +Ext.define('PVE.data.PermPathStore', { + extend: 'Ext.data.Store', + alias: 'store.pvePermPath', + fields: [ 'value' ], + autoLoad: false, + data: [ + {'value': '/access'}, + {'value': '/nodes'}, + {'value': '/pool'}, + {'value': '/storage'}, + {'value': '/vms'} + ], + + constructor: function(config) { + var me = this; + + config = config || {}; + + me.callParent([config]); + + me.suspendEvents(); + PVE.data.ResourceStore.each(function(record) { + switch (record.get('type')) { + case 'node': + me.add({value: '/nodes/' + record.get('text')}); + break; + + case 'qemu': + me.add({value: '/vms/' + record.get('vmid')}); + break; + + case 'lxc': + me.add({value: '/vms/' + record.get('vmid')}); + break; + + case 'storage': + me.add({value: '/storage/' + record.get('storage')}); + break; + case 'pool': + me.add({value: '/pool/' + record.get('pool')}); + break; + } + }); + me.resumeEvents(); + + me.fireEvent('refresh', me); + me.fireEvent('datachanged', me); + + me.sort({ + property: 'value', + direction: 'ASC' + }); + } +}); \ No newline at end of file diff --git a/www/manager6/dc/ACLView.js b/www/manager6/dc/ACLView.js index e12c83f20..1322f9528 100644 --- a/www/manager6/dc/ACLView.js +++ b/www/manager6/dc/ACLView.js @@ -12,7 +12,7 @@ Ext.define('PVE.dc.ACLAdd', { var items = [ { - xtype: me.path ? 'hiddenfield' : 'textfield', + xtype: me.path ? 'hiddenfield' : 'pvePermPathSelector', name: 'path', value: me.path, allowBlank: false, diff --git a/www/manager6/form/PermPathSelector.js b/www/manager6/form/PermPathSelector.js new file mode 100644 index 000000000..928a9621d --- /dev/null +++ b/www/manager6/form/PermPathSelector.js @@ -0,0 +1,12 @@ +Ext.define('PVE.form.PermPathSelector', { + extend: 'Ext.form.field.ComboBox', + xtype: 'pvePermPathSelector', + + valueField: 'value', + displayField: 'value', + typeAhead: true, + queryMode: 'local', + store: { + type: 'pvePermPath' + } +});