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 <[email protected]>
---
changes from v2:
* do not autogenerate checkboxes
* remove now unecessary initComponent
* indentation fix

 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 68b5227b..cc2f7203 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 00000000..02ce0a1d
--- /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 3a9959fe..e4a8d86b 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
            }
        };
 
-- 
2.11.0


_______________________________________________
pve-devel mailing list
[email protected]
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to