[pve-devel] r6228 - pve-manager/pve2/www/manager/qemu

svn-commits at proxmox.com svn-commits at proxmox.com
Mon Jul 4 10:50:44 CEST 2011


Author: dietmar
Date: 2011-07-04 10:50:44 +0200 (Mon, 04 Jul 2011)
New Revision: 6228

Modified:
   pve-manager/pve2/www/manager/qemu/HardwareView.js
Log:
better Bus/Device selector


Modified: pve-manager/pve2/www/manager/qemu/HardwareView.js
===================================================================
--- pve-manager/pve2/www/manager/qemu/HardwareView.js	2011-07-04 06:40:23 UTC (rev 6227)
+++ pve-manager/pve2/www/manager/qemu/HardwareView.js	2011-07-04 08:50:44 UTC (rev 6228)
@@ -109,7 +109,10 @@
 
 	var drive = {};
 
-	var confid = me.down('field[name=_confid]').getValue();
+	var controller = me.down('field[name=_controller]').getValue();
+	var deviceid = me.down('field[name=_deviceid]').getValue();
+
+	var confid = '' + controller + deviceid;
 	
 	var field = me.down('field[name=_disksize]');
 	var hdsize = field.getValue();
@@ -164,6 +167,12 @@
 	    allowBlank: false
 	});
 
+	var maxIds = {
+	    ide: 3,
+	    virtio: 15,
+	    scsi: 15
+	};
+
 	me.column1 = [
 	    hdstoragesel,
 	    {
@@ -176,12 +185,44 @@
 		allowBlank: false
 	    },
 	    {
-		// fixme: we need a selector for all unused disk ids
-		xtype: 'displayfield',
-		name: '_confid',
-		value: 'virtio5',
+		xtype: 'fieldcontainer',
 		fieldLabel: 'Bus/Device',
-		allowBlank: false
+		layout: 'hbox',
+		defaults: {
+                    flex: 1,
+                    hideLabel: true
+		},
+		items: [
+		    {
+			xtype: 'PVE.form.BusTypeSelector',
+			name: '_controller',
+			value: 'ide',
+			allowBlank: false,
+			listeners: {
+			    change: function(t, value) {
+				if (!value)
+				    return;
+				var field = me.down('field[name=_deviceid]');
+				field.setMaxValue(maxIds[value]);
+				field.validate();
+			    }
+			}
+		    },
+		    {
+			xtype: 'numberfield',
+			name: '_deviceid',
+			minValue: 0,
+			maxValue: maxIds['ide'],
+			value: 0,
+			validator: function(value) {
+			    var controller = me.down('field[name=_controller]').getValue();
+			    var confid = '' + controller + value;
+			    if (Ext.isDefined(me.vmconfig[confid]))
+				return "This device is already in use.";
+			    return true;
+			}
+		    }
+		]
 	    }
 	];
 
@@ -214,7 +255,21 @@
 
 	me.load({
 	    success: function(form, action) {
+		var confid;
 		me.vmconfig = action.result.data;
+		var controller = 'ide';
+		if (me.vmconfig.ostype === 'l26') {
+		    controller = 'virtio';
+		}
+		me.down('field[name=_controller]').setValue(controller);
+		var i;
+		for (i = 0; i <= maxIds[controller]; i++) {
+		    confid = '' + controller + i;
+		    if (!Ext.isDefined(me.vmconfig[confid])) {
+			me.down('field[name=_deviceid]').setValue(i);
+			break;
+		    }
+		}
 	    }
 	});
     }




More information about the pve-devel mailing list