[pve-devel] r5834 - in pve-manager/pve2/www/new: . form grid panel tree

svn-commits at proxmox.com svn-commits at proxmox.com
Wed Apr 20 11:34:35 CEST 2011


Author: dietmar
Date: 2011-04-20 11:34:35 +0200 (Wed, 20 Apr 2011)
New Revision: 5834

Modified:
   pve-manager/pve2/www/new/Workspace.js
   pve-manager/pve2/www/new/form/ViewSelector.js
   pve-manager/pve2/www/new/grid/ResourceGrid.js
   pve-manager/pve2/www/new/panel/ConfigPanel.js
   pve-manager/pve2/www/new/tree/ResourceTree.js
Log:
fix filter handling


Modified: pve-manager/pve2/www/new/Workspace.js
===================================================================
--- pve-manager/pve2/www/new/Workspace.js	2011-04-20 07:20:13 UTC (rev 5833)
+++ pve-manager/pve2/www/new/Workspace.js	2011-04-20 09:34:35 UTC (rev 5834)
@@ -4,21 +4,22 @@
 	'Ext.selection.*',
 	'PVE.window.LoginWindow', 
 	'PVE.Utils', 
+	'PVE.form.ViewSelector', 
 	'PVE.data.ResourceStore',
 	'PVE.tree.ResourceTree'],
 
     // private
-    defaultView: {
+    defaultContent: {
 	title: 'Nothing selected',
 	border: false,
 	region:'center'
     },
 
-    setView: function(comp) {
+    setContent: function(comp) {
 	var self = this;
 	
 	if (!comp) 
-	    comp = self.defaultView;
+	    comp = self.defaultContent;
 
 	var cont = self.child('#content');
 	cont.removeAll(true);
@@ -73,6 +74,51 @@
 	    }
 	});
 
+	var selview = new PVE.form.ViewSelector({
+	    listeners: {
+		select: function(combo, records) { 
+		    if (records && records.length) {
+			var view = combo.getViewFilter();
+			combo.up('pveResourceTree').setViewFilter(view);
+		    }
+		}
+	    }
+	});
+
+	var rtree = Ext.createWidget('pveResourceTree', {
+	    width: 200,
+	    region: 'west',
+	    margins: '0 0 0 5',
+	    split: true,
+	    viewFilter: selview.getViewFilter(),
+	    tbar: [ ' ', selview ],
+	    selModel: new Ext.selection.TreeModel({
+		listeners: {
+		    selectionchange: function(sm, selected) {
+			var comp;
+			var tlckup = {
+			    node: 'pveNodeConfig'
+			};
+			
+			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,
+				viewFilter: selview.getViewFilter()
+			    };
+			}
+
+			self.setContent(comp);
+		    }
+		}
+	    })
+	});
+
 	Ext.apply(self, {
  	    layout: 'border',
 	    border: false,
@@ -117,7 +163,7 @@
 			    handler: function() { 
 				PVE.data.ResourceStore.stopUpdate();
 				self.showLogin(); 
-				self.setView(); 
+				self.setContent(); 
 				var rt = self.down('pveResourceTree');
 				rt.clearTree();
 			    }
@@ -135,38 +181,8 @@
 		    margins:'0 5 0 0',
 		    items: self.defaultView
 		},
+		rtree,
 		{
-		    xtype: 'pveResourceTree',
-		    width: 200,
-		    region: 'west',
-		    margins: '0 0 0 5',
-		    split: true,
-		    selModel: new Ext.selection.TreeModel({
-			listeners: {
-			    selectionchange: function(sm, selected) {
-				var comp;
-				var tlckup = {
-				    node: 'pveNodeConfig'
-				};
-
-				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);
-			    }
-			}
-		    })
-		},
-		{
 		    xtype: 'pveStatusPanel',
 		    region: 'south',
 		    margins:'0 5 5 5',

Modified: pve-manager/pve2/www/new/form/ViewSelector.js
===================================================================
--- pve-manager/pve2/www/new/form/ViewSelector.js	2011-04-20 07:20:13 UTC (rev 5833)
+++ pve-manager/pve2/www/new/form/ViewSelector.js	2011-04-20 09:34:35 UTC (rev 5834)
@@ -51,7 +51,7 @@
 	    valueField: 'key',
 	    displayField: 'value',
 
-	    getViewSettings: function() {
+	    getViewFilter: function() {
 		var view = self.getValue();
 		return Ext.apply({ id: view }, default_views[view] || default_views.server);
 	    },

Modified: pve-manager/pve2/www/new/grid/ResourceGrid.js
===================================================================
--- pve-manager/pve2/www/new/grid/ResourceGrid.js	2011-04-20 07:20:13 UTC (rev 5833)
+++ pve-manager/pve2/www/new/grid/ResourceGrid.js	2011-04-20 09:34:35 UTC (rev 5834)
@@ -57,11 +57,11 @@
 	    return match;
 	};
 
-	var updateGrid = function(removeAll) {
+	var updateGrid = function() {
 
-	    var filterfn = null;
+	    var filterfn = me.viewFilter ? me.viewFilter.filterfn : null;
 	    
-	    //console.log("START GRID UPDATE " + removeAll);
+	    //console.log("START GRID UPDATE " +  me.viewFilter);
 
 	    store.suspendEvents();
 
@@ -73,7 +73,8 @@
 
 		var orgnode = rstore.data.get(cn.data.id);
 		if (orgnode) {
-		    if (!textfilter || textfilter_match(cn))
+		    if ((!filterfn || filterfn(cn)) &&
+			(!textfilter || textfilter_match(cn)))
 			nodeidx[cn.data.id] = orgnode;
 		}
 	    
@@ -147,11 +148,11 @@
 	var filter_task = new Ext.util.DelayedTask(function(){
 	    console.log("run filter " + textfilter);
 	    //store.filterBy(textfilter_match, store);
-	    updateGrid(true);
+	    updateGrid();
 	});
 
 
-	var load_cb = function() { updateGrid(false); };
+	var load_cb = function() { updateGrid(); };
 
 	Ext.apply(me, {
 	    title: 'Search',

Modified: pve-manager/pve2/www/new/panel/ConfigPanel.js
===================================================================
--- pve-manager/pve2/www/new/panel/ConfigPanel.js	2011-04-20 07:20:13 UTC (rev 5833)
+++ pve-manager/pve2/www/new/panel/ConfigPanel.js	2011-04-20 09:34:35 UTC (rev 5834)
@@ -17,12 +17,18 @@
 
 	Ext.applyIf(me, {
 	    title: me.pveSelNode.data.text,
-	    showSearch: true
+	    showSearch: true,
+	    defaults: {} 
 	});
 
+	// pass pveSelNode && viewFilter to all children
+	Ext.apply(me.defaults, {
+	    pveSelNode: me.pveSelNode,
+	    viewFilter: me.viewFilter
+	});
+
 	if (me.showSearch) {
 	    items.unshift({
-		pveSelNode: me.pveSelNode,
 		id: 'search',
 		itemId: 'search', 
 		border: false,

Modified: pve-manager/pve2/www/new/tree/ResourceTree.js
===================================================================
--- pve-manager/pve2/www/new/tree/ResourceTree.js	2011-04-20 07:20:13 UTC (rev 5833)
+++ pve-manager/pve2/www/new/tree/ResourceTree.js	2011-04-20 09:34:35 UTC (rev 5834)
@@ -3,7 +3,6 @@
     requires: ['Ext.tree.*', 
 	       'Ext.state.Manager',
 	       'PVE.Utils', 
-	       'PVE.form.ViewSelector', 
 	       'PVE.data.ResourceStore'],
     alias: ['widget.pveResourceTree'],
 
@@ -157,8 +156,10 @@
 	var rstore = PVE.data.ResourceStore;
 	var sp = Ext.state.Manager.getProvider();
 
+	if (!self.viewFilter)
+	    self.viewFilter = {};
+
 	var pdata = {
-	    view: {},
 	    dataIndex: {},
 	    updateCount: 0
 	};
@@ -182,8 +183,8 @@
 
 	    var index = pdata.dataIndex;
 
-	    var groups = pdata.view.groups;
-	    var filterfn = pdata.view.filterfn;
+	    var groups = self.viewFilter.groups || [];
+	    var filterfn = self.viewFilter.filterfn;
 
 	    // remove vanished or changed items
 	    for (var key in index) {
@@ -250,19 +251,6 @@
 	    pdata.updateCount++;
 	};
 
-	var selview = new PVE.form.ViewSelector({
-	    listeners: {
-		select: function(combo, records) { 
-		    if (records && records.length) {
-			var view = combo.getViewSettings();
-			self.setView(view);
-		    }
-		}
-	    }
-	});
-
-	pdata.view = selview.getViewSettings();
-
 	var statechange = function(sp, key, value) {
 	    if (key === stateid) {
 		self.applyState(value);
@@ -276,17 +264,13 @@
 	    //useArrows: true,
             //rootVisible: false,
             title: 'Resource Tree',
-	    tbar: [ ' ', selview ],
 	    listeners: {
 		destroy: function() {
 		    rstore.un("load", updateTree)
 		}
 	    },
-	    getViewID: function() {
-		return pdata.view.id;
-	    },
-	    setView: function(view) {
-		pdata.view = view;
+	    setViewFilter: function(view) {
+		self.viewFilter = view;
 		self.clearTree();
 		updateTree();
 	    },




More information about the pve-devel mailing list