mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-08 02:02:47 +00:00
ui: lxc/Mountpoints: eslint fixes and code cleanup/refactoring/modernize
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
c57ff36d38
commit
7aaa492bbd
@ -1,17 +1,12 @@
|
|||||||
/* hidden: boolean and string
|
|
||||||
* bind: function and object
|
|
||||||
* disabled: boolean and string
|
|
||||||
*/
|
|
||||||
Ext.define('PVE.lxc.MountPointInputPanel', {
|
Ext.define('PVE.lxc.MountPointInputPanel', {
|
||||||
extend: 'Proxmox.panel.InputPanel',
|
extend: 'Proxmox.panel.InputPanel',
|
||||||
xtype: 'pveLxcMountPointInputPanel',
|
xtype: 'pveLxcMountPointInputPanel',
|
||||||
|
|
||||||
insideWizard: false,
|
|
||||||
|
|
||||||
onlineHelp: 'pct_container_storage',
|
onlineHelp: 'pct_container_storage',
|
||||||
|
|
||||||
unused: false, // add unused disk imaged
|
insideWizard: false,
|
||||||
|
|
||||||
|
unused: false, // add unused disk imaged
|
||||||
unprivileged: false,
|
unprivileged: false,
|
||||||
|
|
||||||
vmconfig: {}, // used to select unused disks
|
vmconfig: {}, // used to select unused disks
|
||||||
@ -41,58 +36,64 @@ Ext.define('PVE.lxc.MountPointInputPanel', {
|
|||||||
delete values.disksize;
|
delete values.disksize;
|
||||||
delete values.diskformat;
|
delete values.diskformat;
|
||||||
|
|
||||||
let mountopts = (values.mountoptions || []).join(';');
|
let setMPOpt = (k, src, v) => PVE.Utils.propertyStringSet(me.mp, src, k, v);
|
||||||
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 = {};
|
setMPOpt('mp', values.mp);
|
||||||
|
let mountOpts = (values.mountoptions || []).join(';');
|
||||||
|
setMPOpt('mountoptions', values.mountoptions, mountOpts);
|
||||||
|
setMPOpt('mp', values.mp);
|
||||||
|
setMPOpt('backup', values.backup);
|
||||||
|
setMPOpt('quota', values.quota);
|
||||||
|
setMPOpt('ro', values.ro);
|
||||||
|
setMPOpt('acl', values.acl);
|
||||||
|
setMPOpt('replicate', values.replicate);
|
||||||
|
|
||||||
|
let res = {};
|
||||||
res[confid] = PVE.Parser.printLxcMountPoint(me.mp);
|
res[confid] = PVE.Parser.printLxcMountPoint(me.mp);
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
setMountPoint: function(mp) {
|
setMountPoint: function(mp) {
|
||||||
var me = this;
|
let me = this;
|
||||||
var vm = this.getViewModel();
|
let vm = me.getViewModel();
|
||||||
vm.set('mptype', mp.type);
|
vm.set('mptype', mp.type);
|
||||||
if (mp.mountoptions) {
|
if (mp.mountoptions) {
|
||||||
mp.mountoptions = mp.mountoptions.split(';');
|
mp.mountoptions = mp.mountoptions.split(';');
|
||||||
}
|
}
|
||||||
me.mp = mp;
|
me.mp = mp;
|
||||||
|
me.filterMountOptions();
|
||||||
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);
|
me.setValues(mp);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
filterMountOptions: function() {
|
||||||
|
let me = this;
|
||||||
|
if (me.confid === 'rootfs') {
|
||||||
|
let field = me.down('field[name=mountoptions]');
|
||||||
|
let exclude = ['nodev', 'noexec'];
|
||||||
|
let filtered = field.comboItems.filter(v => !exclude.includes(v[0]));
|
||||||
|
field.setComboItems(filtered);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
setVMConfig: function(vmconfig) {
|
setVMConfig: function(vmconfig) {
|
||||||
var me = this;
|
let me = this;
|
||||||
var vm = me.getViewModel();
|
let vm = me.getViewModel();
|
||||||
me.vmconfig = vmconfig;
|
me.vmconfig = vmconfig;
|
||||||
vm.set('unpriv', vmconfig.unprivileged);
|
vm.set('unpriv', vmconfig.unprivileged);
|
||||||
|
|
||||||
PVE.Utils.forEachMP(function(bus, i) {
|
PVE.Utils.forEachMP((bus, i) => {
|
||||||
var name = "mp" + i.toString();
|
let name = "mp" + i.toString();
|
||||||
if (!Ext.isDefined(vmconfig[name])) {
|
if (!Ext.isDefined(vmconfig[name])) {
|
||||||
me.down('field[name=mpid]').setValue(i);
|
me.down('field[name=mpid]').setValue(i);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
return undefined;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
setNodename: function(nodename) {
|
setNodename: function(nodename) {
|
||||||
var me = this;
|
let me = this;
|
||||||
var vm = me.getViewModel();
|
let vm = me.getViewModel();
|
||||||
vm.set('node', nodename);
|
vm.set('node', nodename);
|
||||||
me.down('#diskstorage').setNodename(nodename);
|
me.down('#diskstorage').setNodename(nodename);
|
||||||
},
|
},
|
||||||
@ -108,25 +109,22 @@ Ext.define('PVE.lxc.MountPointInputPanel', {
|
|||||||
},
|
},
|
||||||
'#hdstorage': {
|
'#hdstorage': {
|
||||||
change: function(field, newValue) {
|
change: function(field, newValue) {
|
||||||
var me = this;
|
let me = this;
|
||||||
if (!newValue) {
|
if (!newValue) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var rec = field.store.getById(newValue);
|
let rec = field.store.getById(newValue);
|
||||||
if (!rec) {
|
if (!rec) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
me.getViewModel().set('type', rec.data.type);
|
||||||
var vm = me.getViewModel();
|
|
||||||
vm.set('type', rec.data.type);
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
init: function(view) {
|
init: function(view) {
|
||||||
var me = this;
|
let me = this;
|
||||||
var vm = this.getViewModel();
|
let vm = this.getViewModel();
|
||||||
view.mp = {};
|
view.mp = {};
|
||||||
vm.set('confid', view.confid);
|
vm.set('confid', view.confid);
|
||||||
vm.set('unused', view.unused);
|
vm.set('unused', view.unused);
|
||||||
@ -134,9 +132,11 @@ Ext.define('PVE.lxc.MountPointInputPanel', {
|
|||||||
vm.set('unpriv', view.unprivileged);
|
vm.set('unpriv', view.unprivileged);
|
||||||
vm.set('hideStorSelector', view.unused || !view.isCreate);
|
vm.set('hideStorSelector', view.unused || !view.isCreate);
|
||||||
|
|
||||||
// can be array if created from unused disk
|
if (view.isCreate) { // can be array if created from unused disk
|
||||||
if (view.isCreate) {
|
|
||||||
vm.set('isIncludedInBackup', true);
|
vm.set('isIncludedInBackup', true);
|
||||||
|
if (view.insideWizard) {
|
||||||
|
view.filterMountOptions();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -191,12 +191,11 @@ Ext.define('PVE.lxc.MountPointInputPanel', {
|
|||||||
validator: function(value) {
|
validator: function(value) {
|
||||||
let view = this.up('inputpanel');
|
let view = this.up('inputpanel');
|
||||||
if (!view.rendered) {
|
if (!view.rendered) {
|
||||||
return;
|
return undefined;
|
||||||
}
|
}
|
||||||
if (Ext.isDefined(view.vmconfig["mp"+value])) {
|
if (Ext.isDefined(view.vmconfig["mp"+value])) {
|
||||||
return "Mount point is already in use.";
|
return "Mount point is already in use.";
|
||||||
}
|
}
|
||||||
/* returns a string above */
|
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -330,18 +329,18 @@ Ext.define('PVE.lxc.MountPointEdit', {
|
|||||||
unprivileged: false,
|
unprivileged: false,
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
var me = this;
|
let me = this;
|
||||||
|
|
||||||
var nodename = me.pveSelNode.data.node;
|
let nodename = me.pveSelNode.data.node;
|
||||||
if (!nodename) {
|
if (!nodename) {
|
||||||
throw "no node name specified";
|
throw "no node name specified";
|
||||||
}
|
}
|
||||||
|
|
||||||
var unused = me.confid && me.confid.match(/^unused\d+$/);
|
let unused = me.confid && me.confid.match(/^unused\d+$/);
|
||||||
|
|
||||||
me.isCreate = me.confid ? unused : true;
|
me.isCreate = me.confid ? unused : true;
|
||||||
|
|
||||||
var ipanel = Ext.create('PVE.lxc.MountPointInputPanel', {
|
let ipanel = Ext.create('PVE.lxc.MountPointInputPanel', {
|
||||||
confid: me.confid,
|
confid: me.confid,
|
||||||
nodename: nodename,
|
nodename: nodename,
|
||||||
unused: unused,
|
unused: unused,
|
||||||
@ -349,7 +348,7 @@ Ext.define('PVE.lxc.MountPointEdit', {
|
|||||||
isCreate: me.isCreate,
|
isCreate: me.isCreate,
|
||||||
});
|
});
|
||||||
|
|
||||||
var subject;
|
let subject;
|
||||||
if (unused) {
|
if (unused) {
|
||||||
subject = gettext('Unused Disk');
|
subject = gettext('Unused Disk');
|
||||||
} else if (me.isCreate) {
|
} else if (me.isCreate) {
|
||||||
@ -369,17 +368,15 @@ Ext.define('PVE.lxc.MountPointEdit', {
|
|||||||
me.load({
|
me.load({
|
||||||
success: function(response, options) {
|
success: function(response, options) {
|
||||||
ipanel.setVMConfig(response.result.data);
|
ipanel.setVMConfig(response.result.data);
|
||||||
if (me.confid) {
|
|
||||||
/*data is defined as array above*/
|
|
||||||
var value = response.result.data[me.confid];
|
|
||||||
var mp = PVE.Parser.parseLxcMountPoint(value);
|
|
||||||
|
|
||||||
|
if (me.confid) {
|
||||||
|
let value = response.result.data[me.confid];
|
||||||
|
let mp = PVE.Parser.parseLxcMountPoint(value);
|
||||||
if (!mp) {
|
if (!mp) {
|
||||||
Ext.Msg.alert(gettext('Error'), 'Unable to parse mount point options');
|
Ext.Msg.alert(gettext('Error'), 'Unable to parse mount point options');
|
||||||
me.close();
|
me.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ipanel.setMountPoint(mp);
|
ipanel.setMountPoint(mp);
|
||||||
me.isValid(); // trigger validation
|
me.isValid(); // trigger validation
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user