[pve-devel] r6234 - in pve-manager/pve2: . www/manager/form www/manager/qemu

svn-commits at proxmox.com svn-commits at proxmox.com
Tue Jul 5 12:59:30 CEST 2011


Author: dietmar
Date: 2011-07-05 12:59:30 +0200 (Tue, 05 Jul 2011)
New Revision: 6234

Modified:
   pve-manager/pve2/ChangeLog
   pve-manager/pve2/www/manager/form/ComboGrid.js
   pve-manager/pve2/www/manager/form/FileSelector.js
   pve-manager/pve2/www/manager/qemu/HardwareView.js
Log:
impl. PVE.qemu.CDEdit


Modified: pve-manager/pve2/ChangeLog
===================================================================
--- pve-manager/pve2/ChangeLog	2011-07-05 07:47:55 UTC (rev 6233)
+++ pve-manager/pve2/ChangeLog	2011-07-05 10:59:30 UTC (rev 6234)
@@ -1,5 +1,10 @@
 2011-07-05  Proxmox Support Team  <support at proxmox.com>
 
+	* www/manager/qemu/HardwareView.js: impl. PVE.qemu.CDEdit
+
+	* www/manager/form/ComboGrid.js: sync value with picker (make it
+	work when we call setValue before load is finished).
+
 	* www/manager/window/Edit.js: new getParams() function, used to
 	modify field values before submit (I found no clean way to do that
 	with ExtJS)

Modified: pve-manager/pve2/www/manager/form/ComboGrid.js
===================================================================
--- pve-manager/pve2/www/manager/form/ComboGrid.js	2011-07-05 07:47:55 UTC (rev 6233)
+++ pve-manager/pve2/www/manager/form/ComboGrid.js	2011-07-05 10:59:30 UTC (rev 6234)
@@ -84,13 +84,15 @@
 	    var form = me.up('form');
 	    if (success) {
 		var def = me.getValue();
+		if (def)
+		    me.setValue(def, true); // sync with grid
 		if (!def || !store.findRecord(me.valueField, def)) {
 		    var rec = me.store.first();
 		    if (me.autoSelect && rec && rec.data) {
 			def = rec.data[me.valueField];
-			me.setValue(def);
+			me.setValue(def, true);
 		    } else {
-			me.setValue('');
+			me.setValue('', true);
 		    }
 		}
 	    }

Modified: pve-manager/pve2/www/manager/form/FileSelector.js
===================================================================
--- pve-manager/pve2/www/manager/form/FileSelector.js	2011-07-05 07:47:55 UTC (rev 6233)
+++ pve-manager/pve2/www/manager/form/FileSelector.js	2011-07-05 10:59:30 UTC (rev 6234)
@@ -39,14 +39,17 @@
 	var me = this;
 
 	var store = Ext.create('Ext.data.Store', {
-	    fields: [ 'volid', 'format', 'size', 'used', 'vmid',
-		      {	name: 'text', 
-			convert: function(value, record) {
-			    if (value)
-				return value;
-			    return record.data.volid.replace(/^.*:.*\//,'');;
-			}
-		      }],
+	    fields: [ 
+		'volid', 'format', 'size', 'used', 'vmid',
+		{	
+		    name: 'text', 
+		    convert: function(value, record) {
+			if (value)
+			    return value;
+			return record.data.volid.replace(/^.*:.*\//,'');;
+		    }
+		}
+	    ]
 	});
 
 	Ext.apply(me, {

Modified: pve-manager/pve2/www/manager/qemu/HardwareView.js
===================================================================
--- pve-manager/pve2/www/manager/qemu/HardwareView.js	2011-07-05 07:47:55 UTC (rev 6233)
+++ pve-manager/pve2/www/manager/qemu/HardwareView.js	2011-07-05 10:59:30 UTC (rev 6234)
@@ -1,3 +1,129 @@
+Ext.define('PVE.qemu.CDEdit', {
+    extend: 'PVE.window.Edit',
+
+    getParams: function(values) {
+	var me = this;
+
+	var params = {};
+
+	if (values.mediaType  === 'iso') {
+	    me.drive.file = values.cdimage;
+	} else if (values.mediaType === 'cdrom') {
+	    me.drive.file = 'cdrom';
+	} else {
+	    me.drive.file = 'none';
+	}
+
+	params[me.confid] = PVE.Parser.printQemuDrive(me.drive);
+
+	return params;
+    },
+
+    initComponent : function() {
+	var me = this;
+
+	var nodename = me.pveSelNode.data.node;
+	if (!nodename) 
+	    throw "no node name specified";
+
+	if (!me.confid)
+	    throw "create not implemented";
+	    
+	var cdfilesel = Ext.create('PVE.form.FileSelector', {
+	    name: 'cdimage',
+	    nodename: nodename,
+	    storageContent: 'iso',
+	    fieldLabel: 'ISO Image',
+	    labelAlign: 'right',
+	    allowBlank: false
+	});
+
+	var cdstoragesel = Ext.create('PVE.form.StorageSelector', {
+	    name: 'storage',
+	    nodename: nodename,
+	    fieldLabel: 'Storage',
+	    labelAlign: 'right',
+	    storageContent: 'iso',
+	    allowBlank: false,
+	    autoSelect: false,
+	    listeners: {
+		change: function(f, value) {
+		    if (!value)
+			return;
+		    cdfilesel.setStorage(value);
+		}
+	    }
+	});
+
+	me.items = [ 
+	    {
+		xtype: 'radiofield',
+		name: 'mediaType',
+		inputValue: 'iso',
+		boxLabel: 'Use CD/DVD disc image file (iso)',
+		checked: true,
+		listeners: {
+		    change: function(f, value) {
+			if (!me.rendered)
+			    return;
+			me.down('field[name=storage]').setDisabled(!value);
+			me.down('field[name=cdimage]').setDisabled(!value);
+			me.down('field[name=cdimage]').validate();
+		    }
+		}
+	    },
+	    cdstoragesel, 
+	    cdfilesel,
+	    {
+		xtype: 'radiofield',
+		name: 'mediaType',
+		inputValue: 'cdrom',
+		boxLabel: 'Use physical CD/DVD Drive'
+	    },
+	    {
+		xtype: 'radiofield',
+		name: 'mediaType',
+		inputValue: 'none',
+		boxLabel: 'Eject (no media).'
+	    }
+	];
+
+	Ext.applyIf(me, {
+	    title: "Change CD/DVD settings (" + me.confid + ")"
+ 	});
+
+	me.callParent();
+
+	me.load({
+	    success: function(form, action) {
+		var value = action.result.data[me.confid];
+		me.drive = PVE.Parser.parseQemuDrive(me.confid, value);
+		if (!me.drive) {
+		    Ext.Msg.alert('Error', 'Unable to parse drive options');
+		    me.close();
+		    return;
+		}
+
+		var values = {};
+		if (me.drive.file === 'cdrom') {
+		    values.mediaType = 'cdrom';
+		} else if (me.drive.file === 'none') {
+		    values.mediaType = 'none';
+	        } else {
+		    values.mediaType = 'iso';
+		    var match = me.drive.file.match(/^([^:]+):/);
+		    if (match) {
+			values.storage = match[1];
+			values.cdimage = me.drive.file;
+		    };
+		}
+
+		form.setValues(values);
+	    }
+	});
+    }
+});
+
 Ext.define('PVE.qemu.HDEdit', {
     extend: 'PVE.window.Edit',
 
@@ -599,7 +725,14 @@
 	    if (!rowdef.editor)
 		return;
 
-	    var win = Ext.create(rowdef.editor, {
+	    var editor = rowdef.editor;
+	    if (rowdef.tdCls == 'pve-itype-icon-storage') { 
+		if (rec.data.value.match(/media=cdrom/)) {
+		    editor = 'PVE.qemu.CDEdit';
+		}
+	    }
+
+	    var win = Ext.create(editor, {
 		pveSelNode: me.pveSelNode,
 		confid: rec.data.key,
 		url: '/api2/extjs/' + baseurl




More information about the pve-devel mailing list