[pve-devel] r5784 - pve-manager/pve2/www/new

svn-commits at proxmox.com svn-commits at proxmox.com
Tue Apr 5 12:37:33 CEST 2011


Author: dietmar
Date: 2011-04-05 12:37:33 +0200 (Tue, 05 Apr 2011)
New Revision: 5784

Modified:
   pve-manager/pve2/www/new/ResourceTree.js
Log:
display nice text instead of id


Modified: pve-manager/pve2/www/new/ResourceTree.js
===================================================================
--- pve-manager/pve2/www/new/ResourceTree.js	2011-04-05 09:54:47 UTC (rev 5783)
+++ pve-manager/pve2/www/new/ResourceTree.js	2011-04-05 10:37:33 UTC (rev 5784)
@@ -6,14 +6,27 @@
     alias: ['widget.pveResourceTree'],
 
     statics: {
-	iconClsHash: {
-	    node: 'x-tree-node-server',
-	    storage: 'x-tree-node-harddisk',
-	    qemu: 'x-tree-node-computer',
-	    openvz: 'x-tree-node-computer',
-	} 
+	typeDefaults: {
+	    node: { 
+		iconCls: 'x-tree-node-server',
+		text: 'Node list'
+	    },
+	    storage: {
+		iconCls: 'x-tree-node-harddisk',
+		text: 'Storage list'
+	    },
+	    qemu: {
+		iconCls: 'x-tree-node-computer',
+		text: 'Virtual machines'
+	    },
+	    openvz: {
+		iconCls: 'x-tree-node-computer',
+		text: 'OpenVZ containers'
+	    } 
+	}
     },
 
+    // private
     nodeSortFn: function(node1, node2) {
 	var n1 = node1.data;
 	var n2 = node2.data;
@@ -45,7 +58,7 @@
 	}
     },
 
-    // fast binary search
+    // private: fast binary search
     findInsertIndex: function(node, child, start, end) {
 	var self = this;
 
@@ -63,13 +76,14 @@
 	    return self.findInsertIndex(node, child, mid + 1, end);
     },
 
+    // private
     addChildSorted: function(node, info) {
 	var self = this;
 
 	var statics = self.statics();
-	var iconCls = statics.iconClsHash[info.type];
-	if (iconCls) 
-	    info.iconCls = iconCls;
+	var defaults = statics.typeDefaults[info.type];
+	if (defaults && defaults.iconCls)
+	    info.iconCls = defaults.iconCls;
 
 	if (info.type === 'node') {
 	    info.text = info.node;
@@ -79,6 +93,12 @@
 	    info.text = info.vmid;
 	    if (info.name)
 		info.text += " (" + info.name + ')';
+	} else if (info.type === 'type') {
+	    defaults = statics.typeDefaults[info.groupbyid];
+	    if (defaults && defaults.text)
+		info.text = defaults.text;
+	    else 
+		info.text = info.groupbyid;	    
 	} else {
 	    info.text = info.id;
 	}
@@ -103,6 +123,7 @@
 	return child;
     },
 
+    // private
     groupChild: function(node, info, groups, level) {
 	var self = this;
 




More information about the pve-devel mailing list