[pve-devel] r6253 - in pve-manager/pve2/www/manager: grid qemu

svn-commits at proxmox.com svn-commits at proxmox.com
Thu Jul 7 11:44:55 CEST 2011


Author: dietmar
Date: 2011-07-07 11:44:55 +0200 (Thu, 07 Jul 2011)
New Revision: 6253

Modified:
   pve-manager/pve2/www/manager/grid/ObjectGrid.js
   pve-manager/pve2/www/manager/qemu/HardwareView.js
Log:
sort items in hardware view


Modified: pve-manager/pve2/www/manager/grid/ObjectGrid.js
===================================================================
--- pve-manager/pve2/www/manager/grid/ObjectGrid.js	2011-07-07 08:37:22 UTC (rev 6252)
+++ pve-manager/pve2/www/manager/grid/ObjectGrid.js	2011-07-07 09:44:55 UTC (rev 6253)
@@ -65,6 +65,12 @@
 	    });
 	}
 
+	if (me.sorterFn) {
+	    store.sorters.add(new Ext.util.Sorter({
+		sorterFn: me.sorterFn
+	    }));
+	}
+
 	store.filters.add(new Ext.util.Filter({
 	    filterFn: function(item) {
 		if (rows) {

Modified: pve-manager/pve2/www/manager/qemu/HardwareView.js
===================================================================
--- pve-manager/pve2/www/manager/qemu/HardwareView.js	2011-07-07 08:37:22 UTC (rev 6252)
+++ pve-manager/pve2/www/manager/qemu/HardwareView.js	2011-07-07 09:44:55 UTC (rev 6253)
@@ -838,6 +838,7 @@
 	for (i = 0; i < 4; i++) {
 	    confid = "ide" + i;
 	    rows[confid] = {
+		group: 1,
 		tdCls: 'pve-itype-icon-storage',
 		editor: 'PVE.qemu.HDEdit',
 		header: 'Hard Disk ' + '(' + confid +')'
@@ -846,6 +847,7 @@
 	for (i = 0; i < 16; i++) {
 	    confid = "scsi" + i;
 	    rows[confid] = {
+		group: 1,
 		tdCls: 'pve-itype-icon-storage',
 		editor: 'PVE.qemu.HDEdit',
 		header: 'Hard Disk ' + '(' + confid +')'
@@ -854,6 +856,7 @@
 	for (i = 0; i < 16; i++) {
 	    confid = "virtio" + i;
 	    rows[confid] = {
+		group: 1,
 		tdCls: 'pve-itype-icon-storage',
 		editor: 'PVE.qemu.HDEdit',
 		header: 'Hard Disk ' + '(' + confid +')'
@@ -862,6 +865,7 @@
 	for (i = 0; i < 32; i++) {
 	    confid = "net" + i;
 	    rows[confid] = {
+		group: 2,
 		tdCls: 'pve-itype-icon-network',
 		editor: 'PVE.qemu.NetworkEdit',
 		header: 'Network Adapter '+ '(' + confid +')'
@@ -869,12 +873,24 @@
 	}
 	for (i = 0; i < 8; i++) {
 	    rows["unused" + i] = {
+		group: 3,
 		tdCls: 'pve-itype-icon-storage',
 		editor: 'PVE.qemu.HDCreate',
 		header: 'Unused Disk'
 	    };
 	}
 
+	var sorterFn = function(rec1, rec2) {
+	    var v1 = rec1.data.key;
+	    var v2 = rec2.data.key;
+	    var g1 = rows[v1].group || 0;
+	    var g2 = rows[v2].group || 0;
+	    if (g1 !== g2)
+		return g1 > g2 ? 1 : -1;
+
+            return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
+	};
+
 	var reload = function() {
 	    me.rstore.load();
 	};
@@ -974,7 +990,7 @@
 	Ext.applyIf(me, {
 	    url: '/api2/json/' + baseurl,
 	    cwidth1: 170,
-	    tbar: [ 
+ 	    tbar: [ 
 		{
 		    text: 'Add',
 		    menu: new Ext.menu.Menu({
@@ -1023,6 +1039,7 @@
 		edit_btn
 	    ],
 	    rows: rows,
+	    sorterFn: sorterFn,
 	    listeners: {
 		itemdblclick: function() {
 		    run_editor();




More information about the pve-devel mailing list