[pve-devel] r6233 - in pve-manager/pve2: . www/manager/qemu www/manager/window

svn-commits at proxmox.com svn-commits at proxmox.com
Tue Jul 5 09:47:55 CEST 2011


Author: dietmar
Date: 2011-07-05 09:47:55 +0200 (Tue, 05 Jul 2011)
New Revision: 6233

Modified:
   pve-manager/pve2/ChangeLog
   pve-manager/pve2/www/manager/qemu/HardwareView.js
   pve-manager/pve2/www/manager/window/Edit.js
Log:

	* 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)

	* www/manager/qemu/HardwareView.js: use new getParams() function



Modified: pve-manager/pve2/ChangeLog
===================================================================
--- pve-manager/pve2/ChangeLog	2011-07-05 07:09:35 UTC (rev 6232)
+++ pve-manager/pve2/ChangeLog	2011-07-05 07:47:55 UTC (rev 6233)
@@ -1,3 +1,11 @@
+2011-07-05  Proxmox Support Team  <support at proxmox.com>
+
+	* 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)
+
+	* www/manager/qemu/HardwareView.js: use new getParams() function
+
 2011-07-04  Proxmox Support Team  <support at proxmox.com>
 
 	* www/manager/form/BusTypeSelector.js: add noVirtIO, noScsi options.

Modified: pve-manager/pve2/www/manager/qemu/HardwareView.js
===================================================================
--- pve-manager/pve2/www/manager/qemu/HardwareView.js	2011-07-05 07:09:35 UTC (rev 6232)
+++ pve-manager/pve2/www/manager/qemu/HardwareView.js	2011-07-05 07:47:55 UTC (rev 6233)
@@ -1,11 +1,9 @@
 Ext.define('PVE.qemu.HDEdit', {
     extend: 'PVE.window.Edit',
 
-    submit: function(formpanel) {
+    getParams: function(values) {
 	var me = this;
 
-	var values = formpanel.getValues();
-
 	me.drive.cache = values.cache ? values.cache : undefined;	
 	me.drive.backup = values.nobackup ? 'no' : undefined;
 
@@ -13,18 +11,7 @@
 
 	params[me.confid] = PVE.Parser.printQemuDrive(me.drive);
 
-	PVE.Utils.API2Request({
-	    url: me.url,
-	    method: 'PUT',
-	    params: params,
-	    failure: function(response, opts) {
-		Ext.Msg.alert('Error', response.htmlStatus);
-	    },
-	    success: function(response, opts) {
-		me.close();
-	    }
-	});
-	
+	return params;
     },
 
     initComponent : function() {
@@ -103,11 +90,9 @@
 
     cdrom: false,
 
-    submit: function(formpanel) {
+    getParams: function(values) {
 	var me = this;
 
-	var values = formpanel.getValues();
-
 	var drive = {};
 
 	var confid = '' + values.controller + values.deviceid;
@@ -136,18 +121,7 @@
 
 	params[confid] = PVE.Parser.printQemuDrive(drive);
 
-	PVE.Utils.API2Request({
-	    url: me.url,
-	    method: 'PUT',
-	    params: params,
-	    failure: function(response, opts) {
-		Ext.Msg.alert('Error', response.htmlStatus);
-	    },
-	    success: function(response, opts) {
-		me.close();
-	    }
-	});
-	
+	return params;	
     },
 
     initComponent : function() {

Modified: pve-manager/pve2/www/manager/window/Edit.js
===================================================================
--- pve-manager/pve2/www/manager/window/Edit.js	2011-07-05 07:09:35 UTC (rev 6232)
+++ pve-manager/pve2/www/manager/window/Edit.js	2011-07-05 07:47:55 UTC (rev 6233)
@@ -7,17 +7,41 @@
     // OK and RESET) 
     create: false, 
 
+    // getParams: function(values): Object
+    // a way to modify parameters and use PVE.Utils.API2Request()
+    // to submit data
+
     submit: function(formpanel) {
 	var me = this;
 
-	formpanel.submit({
-	    success: function() { 
-		me.close();
-	    },
-	    failure: function(form, action) {
-		Ext.Msg.alert('Error', PVE.Utils.extractFormActionError(action));
-	    }
-	});
+	if (Ext.isFunction(me.getParams)) {
+
+	    var values = formpanel.getValues();
+
+	    var params = me.getParams(values);
+
+	    PVE.Utils.API2Request({
+		url: me.url,
+		method: me.method || 'PUT',
+		params: params,
+		failure: function(response, opts) {
+		    Ext.Msg.alert('Error', response.htmlStatus);
+		},
+		success: function(response, opts) {
+		    me.close();
+		}
+	    });
+
+	} else {
+	    formpanel.submit({
+		success: function() { 
+		    me.close();
+		},
+		failure: function(form, action) {
+		    Ext.Msg.alert('Error', PVE.Utils.extractFormActionError(action));
+		}
+	    });
+	}
     },
 
     load: function(options) {




More information about the pve-devel mailing list