[pve-devel] r5830 - in pve-manager/pve2/www/new: . panel tree

svn-commits at proxmox.com svn-commits at proxmox.com
Wed Apr 20 08:26:53 CEST 2011


Author: dietmar
Date: 2011-04-20 08:26:52 +0200 (Wed, 20 Apr 2011)
New Revision: 5830

Modified:
   pve-manager/pve2/www/new/StateProvider.js
   pve-manager/pve2/www/new/Workspace.js
   pve-manager/pve2/www/new/panel/NodeConfig.js
   pve-manager/pve2/www/new/panel/StatusPanel.js
   pve-manager/pve2/www/new/tree/ResourceTree.js
Log:
fix history handling


Modified: pve-manager/pve2/www/new/StateProvider.js
===================================================================
--- pve-manager/pve2/www/new/StateProvider.js	2011-04-20 04:47:30 UTC (rev 5829)
+++ pve-manager/pve2/www/new/StateProvider.js	2011-04-20 06:26:52 UTC (rev 5830)
@@ -15,6 +15,24 @@
 Ext.define('PVE.StateProvider', {
     extend: 'Ext.state.Provider',
 
+    // private
+    setHV: function(name, newvalue, fireEvents) {
+	var self = this;
+
+	var changes = false;
+ 	var oldtext = Ext.encode(self.UIState[name]);
+ 	var newtext = Ext.encode(newvalue);
+	if (newtext != oldtext) {
+	    changes = true;
+ 	    self.UIState[name] = newvalue;
+	    //console.log("changed old " + name + " " + oldtext);
+	    //console.log("changed new " + name + " " + newtext);
+	    if (fireEvents)
+		self.fireEvent("statechange", self, name, { value: newvalue });
+	}
+	return changes;
+    },
+
     constructor: function(config){
 	var self = this;
 
@@ -33,11 +51,13 @@
 	var defaults = {
 	    view: 'server',
 	    ltab: 'clog',
-	    ctab: 'search'
+	    ctab: 'search',
+	    rid: ''
 	};
 
 	Ext.Array.each(list, function(name) {
-	    self.UIState[name] = defaults[name] || null;
+	    self.UIState[name] = Ext.isDefined(defaults[name]) ?
+		defaults[name] : null;
 	});
 
 	var history_change_cb = function(token) {
@@ -45,6 +65,7 @@
 	    if (!token) {
 		PVE.StopPageUnload = true;
 		Ext.History.back();
+		Ext.History.forward();
 		return;
 	    }
 	    PVE.StopPageUnload = false;
@@ -52,17 +73,7 @@
 	    Ext.Array.each(list, function(name) {
 		if (typeof newstate[name] == "undefined")
 		    return;
-
-		var oldvalue = { value: self.UIState[name] };
- 		var newvalue = { value: newstate[name] };
- 		var newtext = Ext.encode(newvalue);
-		var oldtext = Ext.encode(oldvalue);
-		if (newtext != oldtext) {
- 		    self.UIState[name] = newstate[name];
-		    //console.log("changed old " + name + " " + oldtext);
-		    //console.log("changed new " + name + " " + newtext);
-		    self.fireEvent("statechange", self, name, newvalue);
-		}
+		self.setHV(name, newstate[name], true);
 	    });
 	};
 
@@ -88,7 +99,7 @@
 	    }
 	}
 
-	// console.log("GET " + name + " " + Ext.encode(data));
+	//console.log("GET " + name + " " + Ext.encode(data));
 
 	return data;
     },
@@ -110,12 +121,11 @@
 
 	//console.log("SET " + name + " " + Ext.encode(value));
 	if (typeof self.UIState[name] != "undefined") {
-	    if (name !== 'rid' && !self.UIState.rid)
-		return;
-	    var cstate = Ext.clone(self.UIState);
-	    cstate[name] = value ? value.value : null;
-	    var htext = Ext.urlEncode(cstate);
-	    Ext.History.add(htext);
+	    var newvalue = value ? value.value : null;
+	    if (self.setHV(name, newvalue, false)) {
+		var htext = Ext.urlEncode(self.UIState);
+		Ext.History.add(htext);
+	    }
 	} else {
   	    window.localStorage.setItem(name, Ext.encode(value));
 	    self.fireEvent("statechange", self, name, value);

Modified: pve-manager/pve2/www/new/Workspace.js
===================================================================
--- pve-manager/pve2/www/new/Workspace.js	2011-04-20 04:47:30 UTC (rev 5829)
+++ pve-manager/pve2/www/new/Workspace.js	2011-04-20 06:26:52 UTC (rev 5830)
@@ -143,21 +143,24 @@
 		    split: true,
 		    selModel: new Ext.selection.TreeModel({
 			listeners: {
-			    select: function(sm, n) {
+			    selectionchange: function(sm, selected) {
+				var comp;
 				var tlckup = {
 				    node: 'pveNodeConfig'
 				};
 
-				var comp = { 
-				    xtype: tlckup[n.data.type] || 'pveConfigPanel',
-				    layout: 'fit',
-				    border: false,
-				    showSearch: (n.data.id === 'root') ||
-					Ext.isDefined(n.data.groupbyid),
-				    pveSelNode: n 
-				};
+				if (selected.length > 0) {
+				    var n = selected[0];
+				    comp = { 
+					xtype: tlckup[n.data.type] || 'pveConfigPanel',
+					layout: 'fit',
+					border: false,
+					showSearch: (n.data.id === 'root') ||
+					    Ext.isDefined(n.data.groupbyid),
+					pveSelNode: n 
+				    };
+				}
 
-
 				self.setView(comp);
 			    }
 			}

Modified: pve-manager/pve2/www/new/panel/NodeConfig.js
===================================================================
--- pve-manager/pve2/www/new/panel/NodeConfig.js	2011-04-20 04:47:30 UTC (rev 5829)
+++ pve-manager/pve2/www/new/panel/NodeConfig.js	2011-04-20 06:26:52 UTC (rev 5830)
@@ -11,6 +11,7 @@
 
 	Ext.apply(me, {
 	    title: "Node '" + nodename + "'",
+
 	    items: [
 		{
 		    title: 'Summary',

Modified: pve-manager/pve2/www/new/panel/StatusPanel.js
===================================================================
--- pve-manager/pve2/www/new/panel/StatusPanel.js	2011-04-20 04:47:30 UTC (rev 5829)
+++ pve-manager/pve2/www/new/panel/StatusPanel.js	2011-04-20 06:26:52 UTC (rev 5830)
@@ -12,6 +12,11 @@
 	var stateid = 'ltab';
 	var sp = Ext.state.Manager.getProvider();
 
+	var state = sp.get(stateid);
+	if (state && state.value) {
+	    me.activeTab = state.value;
+	}
+
 	Ext.apply(me, {
 	    listeners: {
 		tabchange: function() {
@@ -32,11 +37,6 @@
 	    ]
 	});
 
-	var state = sp.get(stateid);
-	if (state && state.value) {
-	    me.activeTab = state.value;
-	}
-
 	me.callParent();
 
 	var statechange = function(sp, key, state) {

Modified: pve-manager/pve2/www/new/tree/ResourceTree.js
===================================================================
--- pve-manager/pve2/www/new/tree/ResourceTree.js	2011-04-20 04:47:30 UTC (rev 5829)
+++ pve-manager/pve2/www/new/tree/ResourceTree.js	2011-04-20 06:26:52 UTC (rev 5830)
@@ -299,6 +299,7 @@
 		self.getSelectionModel().deselectAll();
 	    },
 	    applyState : function(state) {
+		var sm = self.getSelectionModel();
 		if (state && state.value) {
 		    var rootnode = self.store.getRootNode();
 		    var node;
@@ -308,7 +309,6 @@
 			node = rootnode.findChild('id', state.value, true);
 
 		    if (node) {
-			var sm = self.getSelectionModel();
 			if (!sm.isSelected(node)) {
 			    sm.select(node);
 			    var cn = node;
@@ -318,6 +318,8 @@
 			    }
 			}
 		    }
+		} else {
+		    sm.deselectAll();
 		}
 	    }
 	});




More information about the pve-devel mailing list