]> git.proxmox.com Git - pve-manager.git/blobdiff - www/manager6/lxc/MPEdit.js
fix #2810: reset state of mounts array in initComponent
[pve-manager.git] / www / manager6 / lxc / MPEdit.js
index 37f725eaea6197d4e6b503842a488e7b4b639f8f..f0a9233b5359111fd010d0fe2b9029071af4a365 100644 (file)
@@ -1,4 +1,3 @@
-/*jslint confusion: true*/
 /* hidden: boolean and string
  * bind: function and object
  * disabled: boolean and string
@@ -27,23 +26,32 @@ Ext.define('PVE.lxc.MountPointInputPanel', {
     onGetValues: function(values) {
        var me = this;
 
-       var confid = me.confid || values.mpsel;
-       values.file = me.down('field[name=file]').getValue();
+       var confid = me.confid || "mp"+values.mpid;
+       me.mp.file = me.down('field[name=file]').getValue();
 
        if (me.unused) {
-           confid = values.mpsel;
+           confid = "mp"+values.mpid;
        } else if (me.isCreate) {
-           values.file = values.hdstorage + ':' + values.disksize;
+           me.mp.file = values.hdstorage + ':' + values.disksize;
        }
 
        // delete unnecessary fields
-       delete values.mpsel;
+       delete values.mpid;
        delete values.hdstorage;
        delete values.disksize;
        delete values.diskformat;
 
+       let mountopts = (values.mountoptions || []).join(';');
+       PVE.Utils.propertyStringSet(me.mp, values.mp, 'mp');
+       PVE.Utils.propertyStringSet(me.mp, values.mountoptions, 'mountoptions', mountopts);
+       PVE.Utils.propertyStringSet(me.mp, values.backup, 'backup');
+       PVE.Utils.propertyStringSet(me.mp, values.quota, 'quota');
+       PVE.Utils.propertyStringSet(me.mp, values.ro, 'ro');
+       PVE.Utils.propertyStringSet(me.mp, values.acl, 'acl');
+       PVE.Utils.propertyStringSet(me.mp, values.replicate, 'replicate');
+
        var res = {};
-       res[confid] = PVE.Parser.printLxcMountPoint(values);
+       res[confid] = PVE.Parser.printLxcMountPoint(me.mp);
        return res;
     },
 
@@ -52,6 +60,18 @@ Ext.define('PVE.lxc.MountPointInputPanel', {
        var me = this;
        var vm = this.getViewModel();
        vm.set('mptype', mp.type);
+       if (mp.mountoptions) {
+           mp.mountoptions = mp.mountoptions.split(';');
+       }
+       me.mp = mp;
+
+       if (this.confid === 'rootfs') {
+           var field = me.down('field[name=mountoptions]');
+           var forbidden = ['nodev', 'noexec'];
+           var filtered = field.comboItems.filter(e => !forbidden.includes(e[0]));
+           field.setComboItems(filtered);
+       }
+
        me.setValues(mp);
     },
 
@@ -60,12 +80,11 @@ Ext.define('PVE.lxc.MountPointInputPanel', {
        var vm = me.getViewModel();
        me.vmconfig = vmconfig;
        vm.set('unpriv', vmconfig.unprivileged);
-       vm.notify();
 
        PVE.Utils.forEachMP(function(bus, i) {
            var name = "mp" + i.toString();
            if (!Ext.isDefined(vmconfig[name])) {
-               me.down('field[name=mpsel]').setValue(name);
+               me.down('field[name=mpid]').setValue(i);
                return false;
            }
        });
@@ -75,7 +94,6 @@ Ext.define('PVE.lxc.MountPointInputPanel', {
        var me = this;
        var vm = me.getViewModel();
        vm.set('node', nodename);
-       vm.notify();
        me.down('#diskstorage').setNodename(nodename);
     },
 
@@ -83,7 +101,7 @@ Ext.define('PVE.lxc.MountPointInputPanel', {
        xclass: 'Ext.app.ViewController',
 
        control: {
-           'field[name=mpsel]': {
+           'field[name=mpid]': {
                change: function(field, value) {
                    field.validate();
                }
@@ -102,7 +120,6 @@ Ext.define('PVE.lxc.MountPointInputPanel', {
 
                    var vm = me.getViewModel();
                    vm.set('type', rec.data.type);
-                   vm.notify();
                }
            }
        },
@@ -110,12 +127,17 @@ Ext.define('PVE.lxc.MountPointInputPanel', {
        init: function(view) {
            var me = this;
            var vm = this.getViewModel();
+           view.mp = {};
            vm.set('confid', view.confid);
            vm.set('unused', view.unused);
            vm.set('node', view.nodename);
            vm.set('unpriv', view.unprivileged);
            vm.set('hideStorSelector', view.unused || !view.isCreate);
-           vm.notify();
+
+           // can be array if created from unused disk
+           if (view.isCreate) {
+               vm.set('isIncludedInBackup', true);
+           }
        }
     },
 
@@ -154,33 +176,26 @@ Ext.define('PVE.lxc.MountPointInputPanel', {
 
     column1: [
        {
-           xtype: 'proxmoxKVComboBox',
-           name: 'mpsel',
-           fieldLabel: gettext('Mount Point'),
-           matchFieldWidth: false,
+           xtype: 'proxmoxintegerfield',
+           name: 'mpid',
+           fieldLabel: gettext('Mount Point ID'),
+           minValue: 0,
+           maxValue: PVE.Utils.mp_counts.mps - 1,
            hidden: true,
            allowBlank: false,
+           disabled: true,
            bind: {
                hidden: '{hasMP}',
                disabled: '{hasMP}'
            },
-           comboItems: (function(){
-               var mps = [];
-               PVE.Utils.forEachMP(function(bus,i) {
-                   var name = 'mp' + i.toString();
-                   mps.push([name,name]);
-               });
-               return mps;
-           }()),
            validator: function(value) {
                var me = this.up('inputpanel');
                if (!me.rendered) {
                    return;
                }
-               if (Ext.isDefined(me.vmconfig[value])) {
+               if (Ext.isDefined(me.vmconfig["mp"+value])) {
                    return "Mount point is already in use.";
                }
-               /*jslint confusion: true*/
                /* returns a string above */
                return true;
            }
@@ -218,6 +233,7 @@ Ext.define('PVE.lxc.MountPointInputPanel', {
            value: '',
            emptyText:  gettext('/some/path'),
            allowBlank: false,
+           disabled: true,
            fieldLabel: gettext('Path'),
            bind: {
                hidden: '{isRoot}',
@@ -228,9 +244,14 @@ Ext.define('PVE.lxc.MountPointInputPanel', {
            xtype: 'proxmoxcheckbox',
            name: 'backup',
            fieldLabel: gettext('Backup'),
+           autoEl: {
+               tag: 'div',
+               'data-qtip': gettext('Include volume in backup job'),
+           },
            bind: {
                hidden: '{isRoot}',
-               disabled: '{isBindOrRoot}'
+               disabled: '{isBindOrRoot}',
+               value: '{isIncludedInBackup}'
            }
        }
     ],
@@ -259,7 +280,22 @@ Ext.define('PVE.lxc.MountPointInputPanel', {
                disabled: '{isRoot}'
            },
            fieldLabel: gettext('Read-only')
-       }
+       },
+       {
+           xtype: 'proxmoxKVComboBox',
+           name: 'mountoptions',
+           fieldLabel: gettext('Mount options'),
+           deleteEmpty: false,
+           comboItems: [
+               ['noatime', 'noatime'],
+               ['nodev', 'nodev'],
+               ['noexec', 'noexec'],
+               ['nosuid', 'nosuid']
+           ],
+           multiSelect: true,
+           value: [],
+           allowBlank: true
+       },
     ],
 
     advancedColumn2: [
@@ -324,6 +360,7 @@ Ext.define('PVE.lxc.MountPointEdit', {
 
        Ext.apply(me, {
            subject: subject,
+           defaultFocus: me.confid !== 'rootfs' ? 'textfield[name=mp]' : 'tool',
            items: ipanel
        });
 
@@ -333,10 +370,8 @@ Ext.define('PVE.lxc.MountPointEdit', {
            success: function(response, options) {
                ipanel.setVMConfig(response.result.data);
                if (me.confid) {
-                   /*jslint confusion: true*/
                    /*data is defined as array above*/
                    var value = response.result.data[me.confid];
-                   /*jslint confusion: false*/
                    var mp = PVE.Parser.parseLxcMountPoint(value);
 
                    if (!mp) {