From 725128bbff3d0de56d1cade1828a9427a514918d Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Mon, 5 Nov 2018 10:07:56 +0100 Subject: [PATCH] gui: expose lxc features but constrain editing to root@pam give a checkbox (for now) for nfs and cifs, but keep all that are manually set Signed-off-by: Dominik Csapak --- www/manager6/Makefile | 1 + www/manager6/lxc/FeaturesEdit.js | 93 ++++++++++++++++++++++++++++++++ www/manager6/lxc/Options.js | 6 +++ 3 files changed, 100 insertions(+) create mode 100644 www/manager6/lxc/FeaturesEdit.js diff --git a/www/manager6/Makefile b/www/manager6/Makefile index 68b5227b0..cc2f72037 100644 --- a/www/manager6/Makefile +++ b/www/manager6/Makefile @@ -146,6 +146,7 @@ JSSRC= \ lxc/Summary.js \ lxc/Network.js \ lxc/Resources.js \ + lxc/FeaturesEdit.js \ lxc/Options.js \ lxc/DNS.js \ lxc/Config.js \ diff --git a/www/manager6/lxc/FeaturesEdit.js b/www/manager6/lxc/FeaturesEdit.js new file mode 100644 index 000000000..02ce0a1d3 --- /dev/null +++ b/www/manager6/lxc/FeaturesEdit.js @@ -0,0 +1,93 @@ +Ext.define('PVE.lxc.FeaturesInputPanel', { + extend: 'Proxmox.panel.InputPanel', + xtype: 'pveLxcFeaturesInputPanel', + + // used to save the mounts fstypes until sending + mounts: [], + + fstypes: ['nfs', 'cifs'], + + items: [ + { + xtype: 'proxmoxcheckbox', + fieldLabel: gettext('keyctl'), + name: 'keyctl' + }, + { + xtype: 'proxmoxcheckbox', + fieldLabel: gettext('Nesting'), + name: 'nesting' + }, + { + xtype: 'proxmoxcheckbox', + name: 'nfs', + fieldLabel: 'NFS' + }, + { + xtype: 'proxmoxcheckbox', + name: 'cifs', + fieldLabel: 'CIFS' + } + ], + + onGetValues: function(values) { + var me = this; + var mounts = me.mounts; + me.fstypes.forEach(function(fs) { + if (values[fs]) { + mounts.push(fs); + } + delete values[fs]; + }); + + if (mounts.length) { + values.mount = mounts.join(';'); + } + + var featuresstring = PVE.Parser.printPropertyString(values, undefined); + if (featuresstring == '') { + return { 'delete': 'features' }; + } + return { features: featuresstring }; + }, + + setValues: function(values) { + var me = this; + + me.down('field[name=keyctl]').setDisabled(!values.unprivileged); + + if (values.features) { + var res = PVE.Parser.parsePropertyString(values.features); + me.mounts = []; + if (res.mount) { + res.mount.split(/[; ]/).forEach(function(item) { + if (me.fstypes.indexOf(item) === -1) { + me.mounts.push(item); + } else { + res[item] = 1; + } + }); + } + this.callParent([res]); + } + } +}); + +Ext.define('PVE.lxc.FeaturesEdit', { + extend: 'Proxmox.window.Edit', + xtype: 'pveLxcFeaturesEdit', + + subject: gettext('Features'), + + items: [{ + xtype: 'pveLxcFeaturesInputPanel' + }], + + initComponent : function() { + var me = this; + + me.callParent(); + + me.load(); + } +}); diff --git a/www/manager6/lxc/Options.js b/www/manager6/lxc/Options.js index 3a9959fed..e4a8d86be 100644 --- a/www/manager6/lxc/Options.js +++ b/www/manager6/lxc/Options.js @@ -134,6 +134,12 @@ Ext.define('PVE.lxc.Options', { header: gettext('Unprivileged container'), renderer: Proxmox.Utils.format_boolean, defaultValue: 0 + }, + features: { + header: gettext('Features'), + defaultValue: Proxmox.Utils.noneText, + editor: Proxmox.UserName === 'root@pam' ? + 'PVE.lxc.FeaturesEdit' : undefined } };