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

svn-commits at proxmox.com svn-commits at proxmox.com
Thu Jul 28 11:24:52 CEST 2011


Author: dietmar
Date: 2011-07-28 11:24:52 +0200 (Thu, 28 Jul 2011)
New Revision: 6376

Modified:
   pve-manager/pve2/ChangeLog
   pve-manager/pve2/www/manager/form/ComboGrid.js
   pve-manager/pve2/www/manager/form/NodeSelector.js
   pve-manager/pve2/www/manager/qemu/CreateWizard.js
   pve-manager/pve2/www/manager/storage/DirEdit.js
Log:
	* www/manager/form/ComboGrid.js: bug fix: sync selected after
	creating the grid, make it work with multiSelect

	* www/manager/form/NodeSelector.js (validator): make it work with
	multiSelect

	* www/manager/form/NodeSelector.js: new property 'onlineValidator'
	- invalidate nodes which are offline



Modified: pve-manager/pve2/ChangeLog
===================================================================
--- pve-manager/pve2/ChangeLog	2011-07-28 09:05:25 UTC (rev 6375)
+++ pve-manager/pve2/ChangeLog	2011-07-28 09:24:52 UTC (rev 6376)
@@ -1,3 +1,14 @@
+2011-07-28  Proxmox Support Team  <support at proxmox.com>
+
+	* www/manager/form/ComboGrid.js: bug fix: sync selected after
+	creating the grid, make it work with multiSelect
+
+	* www/manager/form/NodeSelector.js (validator): make it work with
+	multiSelect
+
+	* www/manager/form/NodeSelector.js: new property 'onlineValidator'
+	- invalidate nodes which are offline
+
 2011-07-27  Proxmox Support Team  <support at proxmox.com>
 
 	* www/manager/storage/LVMEdit.js: impl.

Modified: pve-manager/pve2/www/manager/form/ComboGrid.js
===================================================================
--- pve-manager/pve2/www/manager/form/ComboGrid.js	2011-07-28 09:05:25 UTC (rev 6375)
+++ pve-manager/pve2/www/manager/form/ComboGrid.js	2011-07-28 09:24:52 UTC (rev 6376)
@@ -48,14 +48,12 @@
             refresh: me.onListRefresh,
 	    show: function() {
 		picker.setHeight(me.computeHeight());
+		me.syncSelection();
 	    },
             scope: me
         });
 
-        me.mon(picker.getSelectionModel(), {
-            selectionChange: me.onListSelectionChange,
-            scope: me
-        });
+        me.mon(picker.getSelectionModel(), 'selectionchange', me.onListSelectionChange, me);
 
         return picker;
     },
@@ -85,12 +83,29 @@
 	// hack: autoSelect does not work
 	me.store.on('load', function(store, r, success, o) {
 	    var form = me.up('form');
+	    if (form) {
+		form.setLoading(false);
+	    }
 	    if (success) {
 		var def = me.getValue();
 		if (def) {
 		    me.setValue(def, true); // sync with grid
 		}
-		if (!def || !store.findRecord(me.valueField, def)) {
+		var found = false;
+		if (def) {
+		    if (Ext.isArray(def)) {
+			Ext.Array.each(def, function(v) {
+			    if (store.findRecord(me.valueField, v)) {
+				found = true;
+				return false; // break
+			    }
+			});
+		    } else {
+			found = store.findRecord(me.valueField, def);
+		    }
+		}
+
+		if (!found) {
 		    var rec = me.store.first();
 		    if (me.autoSelect && rec && rec.data) {
 			def = rec.data[me.valueField];
@@ -100,9 +115,6 @@
 		    }
 		}
 	    }
-	    if (form) {
-		form.setLoading(false);
-	    }
 	});
     }
-});
\ No newline at end of file
+});

Modified: pve-manager/pve2/www/manager/form/NodeSelector.js
===================================================================
--- pve-manager/pve2/www/manager/form/NodeSelector.js	2011-07-28 09:05:25 UTC (rev 6375)
+++ pve-manager/pve2/www/manager/form/NodeSelector.js	2011-07-28 09:24:52 UTC (rev 6376)
@@ -6,6 +6,9 @@
     ],
     alias: ['widget.PVE.form.NodeSelector'],
 
+    // invalidate nodes which are offline
+    onlineValidator: false,
+
     initComponent: function() {
 	var me = this;
 
@@ -31,7 +34,6 @@
 
 	Ext.apply(me, {
 	    store: store,
-	    allowBlank: false,
 	    valueField: 'name',
 	    displayField: 'name',
             listConfig: {
@@ -59,12 +61,23 @@
 	    },
 	    validator: function(value) {
 		/*jslint confusion: true */
-		var rec = me.store.findRecord(me.valueField, value);
-		if (rec && rec.data && Ext.isNumeric(rec.data.mem)) {
+		if (!me.onlineValidator || (me.allowBlank && !value)) {
 		    return true;
 		}
+		
+		var offline = [];
+		Ext.Array.each(value.split(/\s*,\s*/), function(node) {
+		    var rec = me.store.findRecord(me.valueField, node);
+		    if (!(rec && rec.data) || !Ext.isNumeric(rec.data.mem)) {
+			offline.push(node);
+		    } 
+		});
 
-		return "Node " + value + " seems to be offline!";
+		if (offline.length == 0) {
+		    return true;
+		}
+
+		return "Node " + offline.join(', ') + " seems to be offline!";
 	    }
 	});
 

Modified: pve-manager/pve2/www/manager/qemu/CreateWizard.js
===================================================================
--- pve-manager/pve2/www/manager/qemu/CreateWizard.js	2011-07-28 09:05:25 UTC (rev 6375)
+++ pve-manager/pve2/www/manager/qemu/CreateWizard.js	2011-07-28 09:24:52 UTC (rev 6376)
@@ -51,6 +51,7 @@
 			    name: 'nodename',
 			    fieldLabel: 'Node',
 			    allowBlank: false,
+			    onlineValidator: true,
 			    listeners: {
 				change: function(f, value) {
 				    networkpanel.setNodename(value);

Modified: pve-manager/pve2/www/manager/storage/DirEdit.js
===================================================================
--- pve-manager/pve2/www/manager/storage/DirEdit.js	2011-07-28 09:05:25 UTC (rev 6375)
+++ pve-manager/pve2/www/manager/storage/DirEdit.js	2011-07-28 09:24:52 UTC (rev 6376)
@@ -64,6 +64,17 @@
 	    }
 	];
 
+	if (me.create || me.storageId !== 'local') {
+	    me.column2.unshift({
+		xtype: 'PVE.form.NodeSelector',
+		name: 'nodes',
+		fieldLabel: 'Nodes',
+		emptyText: 'All (no restrictions)',
+		multiSelect: true,
+		autoSelect: false
+	    });
+	}
+
 	me.callParent();
     }
 });
@@ -106,6 +117,10 @@
 		    if (values.storage === 'local') {
 			values.content = ctypes.split(',');
 		    }
+		    if (values.nodes) {
+			console.dir(values.nodes);
+			values.nodes = values.nodes.split(',');
+		    }
 		    values.enable = values.disable ? 0 : 1;
 
 		    ipanel.setValues(values);




More information about the pve-devel mailing list