[pve-devel] r5500 - pve-manager/pve2/www/manager

svn-commits at proxmox.com svn-commits at proxmox.com
Thu Feb 10 10:35:53 CET 2011


Author: dietmar
Date: 2011-02-10 10:35:53 +0100 (Thu, 10 Feb 2011)
New Revision: 5500

Modified:
   pve-manager/pve2/www/manager/NodeConfig.js
Log:
improve usability


Modified: pve-manager/pve2/www/manager/NodeConfig.js
===================================================================
--- pve-manager/pve2/www/manager/NodeConfig.js	2011-02-10 08:51:02 UTC (rev 5499)
+++ pve-manager/pve2/www/manager/NodeConfig.js	2011-02-10 09:35:53 UTC (rev 5500)
@@ -794,6 +794,7 @@
 	    root: 'data',
 	    restful: true, // use GET, not POST
 	    fields: [ 'service', 'name', 'desc', 'state' ],
+	    idProperty: 'service',
 	    sortInfo: { field: 'name', order: 'DESC' }
 	});
 
@@ -801,7 +802,7 @@
 	    store.load();
 	};
 
-	var sm;
+	var sm = new Ext.grid.RowSelectionModel({singleSelect: true});
 
 	var service_cmd = function(cmd) {
 	    var rec = sm.getSelected();
@@ -842,45 +843,52 @@
 	    }
 	});
 
-	sm = new Ext.grid.RowSelectionModel({
-	    singleSelect: true,
-	    listeners: {
-		rowselect: function(selm, row, record) {
-		    var service = record.data.service;
-		    var state = record.data.state;
-		    if (service == 'apache' || service == 'pvedaemon') {
-			if (state == 'running') {
-			    start_btn.disable();
-			    restart_btn.enable();
-			} else {
-			    start_btn.enable();
-			    restart_btn.disable();
-			}
-			stop_btn.disable();
-		    } else {
-			if (state == 'running') {
-			    start_btn.disable();
-			    restart_btn.enable();
-			    stop_btn.enable();
-			} else {
-			    start_btn.enable();
-			    restart_btn.disable();
-			    stop_btn.disable();
-			}
-		    }
-		},
-		rowdeselect: function(selm, row, record) {
+	sm.on('rowselect', function(selm, row, record) {
+	    var service = record.data.service;
+	    var state = record.data.state;
+	    if (service == 'apache' || service == 'pvedaemon') {
+		if (state == 'running') {
 		    start_btn.disable();
-		    stop_btn.disable();
+		    restart_btn.enable();
+		} else {
+		    start_btn.enable();
 		    restart_btn.disable();
 		}
+		stop_btn.disable();
+	    } else {
+		if (state == 'running') {
+		    start_btn.disable();
+		    restart_btn.enable();
+		    stop_btn.enable();
+		} else {
+		    start_btn.enable();
+		    restart_btn.disable();
+		    stop_btn.disable();
+		}
 	    }
 	});
 
+	sm.on('rowdeselect', function(selm, row, record) {
+	    start_btn.disable();
+	    stop_btn.disable();
+	    restart_btn.disable();
+	});
+
+	var prev_selection;
+	store.on('beforeload', function() {
+	    prev_selection = sm.getSelected();
+	});
+
 	store.on("load", function() {
 	    start_btn.disable();
 	    stop_btn.disable();
 	    restart_btn.disable();
+	    console.log("test1 " + prev_selection);
+	    if (prev_selection) {
+		var recid = store.indexOfId(prev_selection.data.service);
+		if (recid >= 0)
+		    sm.selectRow(recid);
+	    }
 	}); 
 
 	Ext.apply(self, {




More information about the pve-devel mailing list