[pve-devel] [PATCH manager] ui: qemu: make DisplayEdit declarative and drop DisplaySelector

Thomas Lamprecht t.lamprecht at proxmox.com
Fri Feb 9 11:52:38 CET 2018


DisplayEdit did not get a cleanup during our ExtJS 4 to ExtJS 6
cleanup, in fact it was really touched in the last 5 years.

So refactor it to a declarative syntax, at least almost, we keep the
me.load in initComponent, just to much hassle to adress this for now.

Also purge DisplaySelector. It was a component inheriting from
KVComboBox with the possible VGA values as items only used here.
So just use a KVComboBox directly and set comboboxItems directly.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 www/manager6/Makefile                |  1 -
 www/manager6/form/DisplaySelector.js |  5 ---
 www/manager6/qemu/DisplayEdit.js     | 59 +++++++++++++++---------------------
 3 files changed, 24 insertions(+), 41 deletions(-)
 delete mode 100644 www/manager6/form/DisplaySelector.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index e2145085..6e0af248 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -43,7 +43,6 @@ JSSRC= 				                 	\
 	form/IPProtocolSelector.js			\
 	form/CPUModelSelector.js			\
 	form/VNCKeyboardSelector.js			\
-	form/DisplaySelector.js				\
 	form/CacheTypeSelector.js			\
 	form/SnapshotSelector.js			\
 	form/ContentTypeSelector.js			\
diff --git a/www/manager6/form/DisplaySelector.js b/www/manager6/form/DisplaySelector.js
deleted file mode 100644
index 4b753e45..00000000
--- a/www/manager6/form/DisplaySelector.js
+++ /dev/null
@@ -1,5 +0,0 @@
-Ext.define('PVE.form.DisplaySelector', {
-    extend: 'Proxmox.form.KVComboBox',
-    alias: ['widget.DisplaySelector'],
-    comboItems: PVE.Utils.kvm_vga_driver_array()
-});
diff --git a/www/manager6/qemu/DisplayEdit.js b/www/manager6/qemu/DisplayEdit.js
index 00df0036..56d352d5 100644
--- a/www/manager6/qemu/DisplayEdit.js
+++ b/www/manager6/qemu/DisplayEdit.js
@@ -3,47 +3,36 @@ Ext.define('PVE.qemu.DisplayEdit', {
 
     vmconfig: undefined,
 
+    subject: gettext('Display'),
+    width: 350,
+
+    items: [{
+	name: 'vga',
+	xtype: 'proxmoxKVComboBox',
+	value: '__default__',
+	fieldLabel: gettext('Graphic card'),
+	comboItems: PVE.Utils.kvm_vga_driver_array(),
+	validator: function() {
+	    var v = this.getValue();
+	    var cfg = this.up('proxmoxWindowEdit').vmconfig || {};
+
+	    if (v.match(/^serial\d+$/) && (!cfg[v] || cfg[v] !== 'socket')) {
+		return Ext.String.format(gettext("Serial interface '{0}' is " +
+		    "not correctly configured."), v);
+	    }
+	    return true;
+	}
+    }],
+
     initComponent : function() {
 	var me = this;
 
-	var displayField;
-
-	var validateDisplay = function() {
-	    /*jslint confusion: true */
-	    var val = displayField.getValue();
-
-	    if (me.vmconfig && val.match(/^serial\d+$/)) {
-		if (me.vmconfig[val] && me.vmconfig[val] === 'socket') {
-		    return true;
-		}
-		return "Serial interface '" + val + "' is not correctly configured.";
-	    }
-	    
-	    return true;
-	};
-
-	displayField = Ext.createWidget('DisplaySelector', {  
-	    name: 'vga',
-	    value: '__default__',
-	    fieldLabel: gettext('Graphic card'),
-	    validator: validateDisplay
-	});
-
-	Ext.apply(me, {
-	    subject: gettext('Display'),
-	    width: 350,
-	    items: displayField
-	});
-
 	me.callParent();
 
 	me.load({
-	    success: function(response, options) {
-		var values = response.result.data;
-
-		me.vmconfig = values;
-
-		me.setValues(values);
+	    success: function(response) {
+		me.vmconfig = response.result.data;
+		me.setValues(me.vmconfig);
 	    }
 	});
     }
-- 
2.14.2





More information about the pve-devel mailing list