[pve-devel] [PATCH manager v2 5/6] ui: merge CPUOptions into ProcessorEdit

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Oct 5 15:17:40 CEST 2017


It seemed a bit weird that those options were in a seprate edit
window as they affect the same backend variable and may cause
confusion, an user may not be sure in what way they are related to
each other, if at all.

This allows us to share the help button, the docs must be updated so
that the moved fields are represented there.

Further we reduce the count of non common buttons from the Hardware
View.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---

changes since v1:
* use the ViewController's init call back for enforcing what fields are
  hidden if not in Wizard, instead of an afterrender listener on the view,
  not only shorter it also gets called just once.
* use 'vCPUs at start' for the vcpus field, as vCPUs is to general and would
  suggest that this is also involved in the total core count... Another
  option was 'Plugged vCPUs' but that sounded a bit weird, IMO.

 www/manager6/Makefile              |  1 -
 www/manager6/qemu/CPUOptions.js    | 76 --------------------------------------
 www/manager6/qemu/CreateWizard.js  |  1 +
 www/manager6/qemu/HardwareView.js  | 22 -----------
 www/manager6/qemu/ProcessorEdit.js | 39 +++++++++++++++++++
 5 files changed, 40 insertions(+), 99 deletions(-)
 delete mode 100644 www/manager6/qemu/CPUOptions.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 0c057f1d..81a46e23 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -148,7 +148,6 @@ JSSRC= 				                 	\
 	qemu/HDMove.js					\
 	qemu/HDThrottle.js				\
 	qemu/HDEfi.js					\
-	qemu/CPUOptions.js				\
 	qemu/DisplayEdit.js				\
 	qemu/KeyboardEdit.js				\
 	qemu/HardwareView.js				\
diff --git a/www/manager6/qemu/CPUOptions.js b/www/manager6/qemu/CPUOptions.js
deleted file mode 100644
index 4ea8c35f..00000000
--- a/www/manager6/qemu/CPUOptions.js
+++ /dev/null
@@ -1,76 +0,0 @@
-Ext.define('PVE.qemu.CPUOptionsInputPanel', {
-    extend: 'PVE.panel.InputPanel',
-    alias: 'widget.PVE.qemu.CPUOptionsInputPanel',
-
-    onGetValues: function(values) {
-	var me = this;
-
-	PVE.Utils.delete_if_default(values, 'vcpus', '', 0);
-	PVE.Utils.delete_if_default(values, 'cpulimit', '0', 0);
-	PVE.Utils.delete_if_default(values, 'cpuunits', '1024', 0);
-
-	return values;
-    },
-
-    initComponent : function() {
-	var me = this;
-
-        var items = [
-            {
-                xtype: 'pveIntegerField',
-                name: 'vcpus',
-                minValue: 1,
-                maxValue: me.maxvcpus,
-                value: '',
-                fieldLabel: gettext('VCPUs'),
-                allowBlank: true,
-                emptyText: me.maxvcpus
-            },
-            {
-                xtype: 'numberfield',
-                name: 'cpulimit',
-                minValue: 0,
-                maxValue: 128,
-                value: '',
-                step: 1,
-                fieldLabel: gettext('Host CPU time'),
-                allowBlank: true,
-                emptyText: gettext('unlimited')
-            },
-	    {
-                xtype: 'pveIntegerField',
-                name: 'cpuunits',
-                fieldLabel: gettext('CPU shares'),
-                minValue: 2,
-                maxValue: 262144,
-                value: '1024',
-                allowBlank: true
-            }
-	];
-
-	me.items = items;
-
-	me.callParent();
-    }
-});
-
-Ext.define('PVE.qemu.CPUOptions', {
-    extend: 'PVE.window.Edit',
-
-    initComponent : function() {
-	var me = this;
-
-        var ipanel = Ext.create('PVE.qemu.CPUOptionsInputPanel', {
-            maxvcpus: me.maxvcpus
-        });
-	
-	Ext.apply(me, {
-	    subject: gettext('CPU options'),
-	    items: [ ipanel ]
-	});
-
-	me.callParent();
-
-	me.load();
-    }
-});
diff --git a/www/manager6/qemu/CreateWizard.js b/www/manager6/qemu/CreateWizard.js
index 954b8ef0..3d778c27 100644
--- a/www/manager6/qemu/CreateWizard.js
+++ b/www/manager6/qemu/CreateWizard.js
@@ -115,6 +115,7 @@ Ext.define('PVE.qemu.CreateWizard', {
 		},
 		{
 		    xtype: 'pveQemuProcessorPanel',
+		    insideWizard: true,
 		    title: gettext('CPU')
 		},
 		{
diff --git a/www/manager6/qemu/HardwareView.js b/www/manager6/qemu/HardwareView.js
index cbec59d2..5affc2b6 100644
--- a/www/manager6/qemu/HardwareView.js
+++ b/www/manager6/qemu/HardwareView.js
@@ -329,22 +329,6 @@ Ext.define('PVE.qemu.HardwareView', {
 	    win.on('destroy', reload);
 	};
 
-	var run_cpuoptions = function() {
-	    var sockets = me.getObjectValue('sockets', 1);
-	    var cores = me.getObjectValue('cores', 1);
-
-	    var win = Ext.create('PVE.qemu.CPUOptions', {
-		maxvcpus: sockets * cores,
-		vmid: vmid,
-		pveSelNode: me.pveSelNode,
-		url: '/api2/extjs/' + baseurl
-	    });
-
-	    win.show();
-
-	    win.on('destroy', reload);
-	};
-
 	var run_move = function() {
 	    var rec = sm.getSelection()[0];
 	    if (!rec) {
@@ -390,11 +374,6 @@ Ext.define('PVE.qemu.HardwareView', {
 	    handler: run_diskthrottle
 	});
 
-	var cpuoptions_btn = new Ext.Button({
-	    text: gettext('CPU options'),
-	    handler: run_cpuoptions
-	});
-
 	var remove_btn = new PVE.button.Button({
 	    text: gettext('Remove'),
 	    selModel: sm,
@@ -597,7 +576,6 @@ Ext.define('PVE.qemu.HardwareView', {
 		resize_btn,
 		move_btn,
 		diskthrottle_btn,
-		cpuoptions_btn,
 		revert_btn
 	    ],
 	    rows: rows,
diff --git a/www/manager6/qemu/ProcessorEdit.js b/www/manager6/qemu/ProcessorEdit.js
index 627d0c93..04f1b90f 100644
--- a/www/manager6/qemu/ProcessorEdit.js
+++ b/www/manager6/qemu/ProcessorEdit.js
@@ -2,6 +2,7 @@ Ext.define('PVE.qemu.ProcessorInputPanel', {
     extend: 'PVE.panel.InputPanel',
     alias: 'widget.pveQemuProcessorPanel',
     onlineHelp: 'qm_cpu',
+    insideWizard: false,
 
     controller: {
 	xclass: 'Ext.app.ViewController',
@@ -13,9 +14,18 @@ Ext.define('PVE.qemu.ProcessorInputPanel', {
 		change: 'setTotalCores'
 	    }
 	},
+	wizardOnlyFields: [ 'vcpus', 'cpulimit', 'cpuunits' ],
+	init: function(view) {
+	    Ext.Array.each(this.wizardOnlyFields, function (field_ref) {
+		view.lookup(field_ref).setHidden(view.insideWizard);
+	    });
+	},
 	setTotalCores: function() {
 	    var sockets = this.lookup('sockets').getValue();
 	    var cores = this.lookup('cores').getValue();
+	    var vcpus_field = this.lookup('vcpus');
+	    vcpus_field.setMaxValue(sockets * cores);
+	    vcpus_field.validate();
 	}
     },
 
@@ -48,6 +58,10 @@ Ext.define('PVE.qemu.ProcessorInputPanel', {
 	    values['delete'] = delarr;
 	}
 
+	PVE.Utils.delete_if_default(values, 'vcpus', '', 0);
+	PVE.Utils.delete_if_default(values, 'cpulimit', '0', 0);
+	PVE.Utils.delete_if_default(values, 'cpuunits', '1024', 0);
+
 	return values;
     },
 
@@ -86,6 +100,31 @@ Ext.define('PVE.qemu.ProcessorInputPanel', {
 	    name: 'cputype',
 	    value: '__default__',
 	    fieldLabel: gettext('Type')
+	},
+	{
+	    xtype: 'pveIntegerField',
+	    name: 'vcpus',
+	    reference: 'vcpus',
+	    minValue: 1,
+	    fieldLabel: gettext('vCPUs at start'),
+	    emptyText: gettext('all')
+	},
+	{
+	    xtype: 'numberfield',
+	    name: 'cpulimit',
+	    reference: 'cpulimit',
+	    minValue: 0,
+	    fieldLabel: gettext('Host CPU time'),
+	    emptyText: gettext('unlimited')
+	},
+	{
+	    xtype: 'pveIntegerField',
+	    name: 'cpuunits',
+	    reference: 'cpuunits',
+	    fieldLabel: gettext('CPU shares'),
+	    minValue: 2,
+	    maxValue: 262144,
+	    value: '1024'
 	}
     ],
 
-- 
2.11.0





More information about the pve-devel mailing list