[pve-devel] [PATCH manager 1/1 v2] gui: let users edit the vga memory

Dominik Csapak d.csapak at proxmox.com
Fri Nov 9 13:31:10 CET 2018


and show the default for each type of virtual gpu

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/manager6/Utils.js            |  6 ++-
 www/manager6/qemu/DisplayEdit.js | 89 ++++++++++++++++++++++++++++++++++++----
 2 files changed, 86 insertions(+), 9 deletions(-)

diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index 568ceb7b..a659b093 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -350,7 +350,11 @@ Ext.define('PVE.Utils', { utilities: {
 	if (!value) {
 	    return Proxmox.Utils.defaultText;
 	}
-	var text = PVE.Utils.kvm_vga_drivers[value];
+	var vga = PVE.Parser.parsePropertyString(value, 'type');
+	var text = PVE.Utils.kvm_vga_drivers[vga.type];
+	if (!vga.type) {
+	    text = Proxmox.Utils.defaultText;
+	}
 	if (text) {
 	    return text + ' (' + value + ')';
 	}
diff --git a/www/manager6/qemu/DisplayEdit.js b/www/manager6/qemu/DisplayEdit.js
index 936521ae..c31c69ad 100644
--- a/www/manager6/qemu/DisplayEdit.js
+++ b/www/manager6/qemu/DisplayEdit.js
@@ -1,15 +1,24 @@
-Ext.define('PVE.qemu.DisplayEdit', {
-    extend: 'Proxmox.window.Edit',
+Ext.define('PVE.qemu.DisplayInputPanel', {
+    extend: 'Proxmox.panel.InputPanel',
+    xtype: 'pveDisplayInputPanel',
 
-    vmconfig: undefined,
-
-    subject: gettext('Display'),
-    width: 350,
+    onGetValues: function(values) {
+	var ret = PVE.Parser.printPropertyString(values, 'type');
+	if (ret === '') {
+	    return {
+		'delete': 'vga'
+	    };
+	}
+	return {
+	    vga: ret
+	};
+    },
 
     items: [{
-	name: 'vga',
+	name: 'type',
 	xtype: 'proxmoxKVComboBox',
 	value: '__default__',
+	deleteEmpty: false,
 	fieldLabel: gettext('Graphic card'),
 	comboItems: PVE.Utils.kvm_vga_driver_array(),
 	validator: function() {
@@ -21,7 +30,70 @@ Ext.define('PVE.qemu.DisplayEdit', {
 		return Ext.String.format(fmt, v);
 	    }
 	    return true;
+	},
+	listeners: {
+	    change: function(cb, val) {
+		var me = this.up('panel');
+		if (!val) {
+		    return;
+		}
+		var disable = false;
+		var emptyText = Proxmox.Utils.defaultText;
+		switch (val) {
+		    case "cirrus":
+			emptyText = "4";
+			break;
+		    case "std":
+			emptyText = "16";
+			break;
+		    case "qxl":
+		    case "qxl2":
+		    case "qxl3":
+		    case "qxl4":
+			emptyText = "16";
+			break;
+		    case "vmware":
+			emptyText = "16";
+			break;
+		    case "serial0":
+		    case "serial1":
+		    case "serial2":
+		    case "serial3":
+			emptyText = 'N/A';
+			disable = true;
+			break;
+		    case "virtio":
+			emptyText = "256";
+			break;
+		    default:
+			break;
+		}
+		var memoryfield = me.down('field[name=memory]');
+		memoryfield.setEmptyText(emptyText);
+		memoryfield.setDisabled(disable);
+	    }
 	}
+    },{
+	xtype: 'proxmoxintegerfield',
+	emptyText: Proxmox.Utils.defaultText,
+	fieldLabel: gettext('Memory') + ' (MiB)',
+	minValue: 4,
+	maxValue: 512,
+	step: 4,
+	name: 'memory'
+    }]
+});
+
+Ext.define('PVE.qemu.DisplayEdit', {
+    extend: 'Proxmox.window.Edit',
+
+    vmconfig: undefined,
+
+    subject: gettext('Display'),
+    width: 350,
+
+    items: [{
+	xtype: 'pveDisplayInputPanel'
     }],
 
     initComponent : function() {
@@ -32,7 +104,8 @@ Ext.define('PVE.qemu.DisplayEdit', {
 	me.load({
 	    success: function(response) {
 		me.vmconfig = response.result.data;
-		me.setValues(me.vmconfig);
+		var vga = me.vmconfig.vga || '__default__';
+		me.setValues(PVE.Parser.parsePropertyString(vga, 'type'));
 	    }
 	});
     }
-- 
2.11.0





More information about the pve-devel mailing list