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

svn-commits at proxmox.com svn-commits at proxmox.com
Fri May 13 07:37:06 CEST 2011


Author: dietmar
Date: 2011-05-13 07:37:06 +0200 (Fri, 13 May 2011)
New Revision: 5973

Modified:
   pve-manager/pve2/www/new/grid/ObjectGrid.js
   pve-manager/pve2/www/new/qemu/HardwareView.js
Log:
cleanups



Modified: pve-manager/pve2/www/new/grid/ObjectGrid.js
===================================================================
--- pve-manager/pve2/www/new/grid/ObjectGrid.js	2011-05-13 05:08:39 UTC (rev 5972)
+++ pve-manager/pve2/www/new/grid/ObjectGrid.js	2011-05-13 05:37:06 UTC (rev 5973)
@@ -6,6 +6,26 @@
     ],
     alias: ['widget.pveObjectGrid'],
 
+    renderKey: function(key, metaData, record, rowIndex, colIndex, store) {
+	var me = this;
+	var rows = me.rows;
+	var rowdef = (rows && rows[key]) ?  rows[key] : {};
+	return rowdef.header || key;
+    },
+
+    renderValue: function(value, metaData, record, rowIndex, colIndex, store) {
+	var me = this;
+	var rows = me.rows;
+	var key = record.data.key;
+	var rowdef = (rows && rows[key]) ?  rows[key] : {};
+
+	var renderer = rowdef.renderer;
+	if (renderer)
+	    return renderer(value, metaData, record, rowIndex, colIndex, store);
+
+	return value;
+    },
+
     initComponent : function() {
 	var me = this;
 
@@ -20,7 +40,6 @@
 	var store = Ext.create('Ext.data.Store', {
 	    model: 'KeyValue',
 	    proxy: 'memory',
-	    autoDestory: true,
 	    sorters: {
 		property: 'key'
 	    }
@@ -121,22 +140,6 @@
 	    });
 	});
 
-	var render_key = function(key) {
-	    var rowdef = (rows && rows[key]) ?  rows[key] : {};
-	    return rowdef.header || key;
-	};
-
-	var render_value = function(value, metaData, record, rowIndex, colIndex, store) {
-	    var key = record.data.key;
-	    var rowdef = (rows && rows[key]) ?  rows[key] : {};
-
-	    var renderer = rowdef.renderer;
-	    if (renderer)
-		return renderer(value, metaData, record, rowIndex, colIndex, store);
-
-	    return value;
-	};
-
 	Ext.applyIf(me, {
 	    store: store,
 	    hideHeaders: true,
@@ -146,13 +149,13 @@
 		    header: 'Name',
 		    width: me.cwidth1 || 100,
 		    dataIndex: 'key',
-		    renderer: render_key
+		    renderer: me.renderKey
 		},
 		{
 		    flex: 1,
 		    header: 'Value',
 		    dataIndex: 'value',
-		    renderer: render_value
+		    renderer: me.renderValue
 		}
 	    ]
 	});

Modified: pve-manager/pve2/www/new/qemu/HardwareView.js
===================================================================
--- pve-manager/pve2/www/new/qemu/HardwareView.js	2011-05-13 05:08:39 UTC (rev 5972)
+++ pve-manager/pve2/www/new/qemu/HardwareView.js	2011-05-13 05:37:06 UTC (rev 5973)
@@ -2,6 +2,26 @@
     extend: 'PVE.grid.ObjectGrid',
     alias: ['widget.PVE.qemu.HardwareView'],
 
+    renderKey: function(key, metaData, record, rowIndex, colIndex, store) {
+	var me = this;
+	var rows = me.rows;
+	var rowdef = rows[key] || {};
+
+	if (rowdef.css) {
+	    if (rowdef.css == 'pve-itype-icon-storage') { 
+		if (record.data.value.match(/media=cdrom/)) {
+		    metaData.css = 'pve-itype-icon-cdrom';
+		    return 'CD/DVD';
+		} else {
+		    metaData.css = rowdef.css;
+		    return 'Hard Disk';
+		}
+	    } else
+		metaData.css = rowdef.css;
+	}
+	return rowdef.header || key;
+    },
+
     initComponent : function() {
 	var me = this;
 	var i;
@@ -27,7 +47,7 @@
 		css: 'pve-itype-icon-processor',
 		defaultValue: 1,
 		renderer: function(value, metaData, record, rowIndex, colIndex, store) {
-		    var cores = store.snapshot.get('cores');
+		    var cores = (store.snapshot || store.data).get('cores');
 		    return cores ? value * cores.data.value : value;
 		}
 	    },
@@ -60,39 +80,10 @@
 	    };
 	}
 
-	
-	var render_key = function(key, metaData, record, rowIndex, colIndex, store) {
-	    var rowdef = rows[key] || {};
-
-	    if (rowdef.css) {
-		if (rowdef.css == 'pve-itype-icon-storage') { 
-		    if (record.data.value.match(/media=cdrom/)) {
-			metaData.css = 'pve-itype-icon-cdrom';
-			return 'CD/DVD';
-		    } else {
-			metaData.css = rowdef.css;
-			return 'Hard Disk';
-		    }
-		} else
-		    metaData.css = rowdef.css;
-	    }
-	    return rowdef.header || key;
-	};
-
-	var render_value = function(value, metaData, record, rowIndex, colIndex, store) {
-	    var key = record.data.key;
-	    var rowdef = rows[key] || {};
-
-	    var renderer = rowdef.renderer;
-	    if (renderer)
-		return renderer(value, metaData, record, rowIndex, colIndex, store);
-
-	    return value;
-	};
-
 	Ext.applyIf(me, {
 	    url: "/api2/json/nodes/" + nodename + "/qemu/" + vmid + "/config",
 	    interval: 1000,
+	    cwidth1: 150,
 	    tbar: [ 
 		{
 		    text: "Edit"
@@ -100,21 +91,6 @@
 		}
 	    ],
 	    rows: rows,
-	    columns: [
-		{
-		    header: 'Type',
-		    width: 120,
-		    dataIndex: 'key',
-		    renderer: render_key
-		},
-		{
-		    flex: 1,
-		    header: 'Value',
-		    dataIndex: 'value',
-		    renderer: render_value
-		}
-
-	    ],
 	    listeners: {
 		itemdblclick: function() {
 		    //run_editor();




More information about the pve-devel mailing list