[pve-devel] [PATCH manager 29/49] use ObjectGrid from widget toolkit

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Jan 23 11:05:46 CET 2018


Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
Reviewed-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/manager6/Makefile                  |   1 -
 www/manager6/dc/OptionView.js          |   2 +-
 www/manager6/grid/FirewallOptions.js   |   2 +-
 www/manager6/grid/ObjectGrid.js        | 132 ---------------------------------
 www/manager6/grid/PendingObjectGrid.js |   2 +-
 www/manager6/lxc/DNS.js                |   2 +-
 www/manager6/lxc/Options.js            |   2 +-
 www/manager6/lxc/Resources.js          |   2 +-
 www/manager6/node/Subscription.js      |   2 +-
 www/manager6/pool/StatusView.js        |   2 +-
 www/manager6/window/TaskViewer.js      |   2 +-
 11 files changed, 9 insertions(+), 142 deletions(-)
 delete mode 100644 www/manager6/grid/ObjectGrid.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 4129e2bc..c94a23f1 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -86,7 +86,6 @@ JSSRC= 				                 	\
 	window/Settings.js				\
 	window/StartupEdit.js				\
 	panel/NotesView.js				\
-	grid/ObjectGrid.js				\
 	grid/PendingObjectGrid.js			\
 	grid/ResourceGrid.js				\
 	grid/PoolMembers.js				\
diff --git a/www/manager6/dc/OptionView.js b/www/manager6/dc/OptionView.js
index 2ca5ff55..74388475 100644
--- a/www/manager6/dc/OptionView.js
+++ b/www/manager6/dc/OptionView.js
@@ -126,7 +126,7 @@ Ext.define('PVE.dc.MacPrefixEdit', {
 });
 
 Ext.define('PVE.dc.OptionView', {
-    extend: 'PVE.grid.ObjectGrid',
+    extend: 'Proxmox.grid.ObjectGrid',
     alias: ['widget.pveDcOptionView'],
 
     onlineHelp: 'datacenter_configuration_file',
diff --git a/www/manager6/grid/FirewallOptions.js b/www/manager6/grid/FirewallOptions.js
index 64f3d21c..abf5a6bf 100644
--- a/www/manager6/grid/FirewallOptions.js
+++ b/www/manager6/grid/FirewallOptions.js
@@ -1,5 +1,5 @@
 Ext.define('PVE.FirewallOptions', {
-    extend: 'PVE.grid.ObjectGrid',
+    extend: 'Proxmox.grid.ObjectGrid',
     alias: ['widget.pveFirewallOptions'],
 
     fwtype: undefined, // 'dc', 'node' or 'vm'
diff --git a/www/manager6/grid/ObjectGrid.js b/www/manager6/grid/ObjectGrid.js
deleted file mode 100644
index b901a584..00000000
--- a/www/manager6/grid/ObjectGrid.js
+++ /dev/null
@@ -1,132 +0,0 @@
-/* Renders a list of key values objets
-
-mandatory config parameters:
-rows: an object container where each propery is a key-value object we want to render
-       var rows = {
-           keyboard: {
-               header: gettext('Keyboard Layout'),
-               editor: 'PVE.dc.KeyboardEdit',
-               renderer: PVE.Utils.render_kvm_language,
-               required: true
-           },
-
-optional:
-disabled: setting this parameter to true will disable selection and focus on the
-pveObjectGrid as well as greying out input elements.
-Useful for a readonly tabular display
-
-*/
-
-Ext.define('PVE.grid.ObjectGrid', {
-    extend: 'Ext.grid.GridPanel',
-    alias: ['widget.pveObjectGrid'],
-    disabled: false,
-    hideHeaders: true,
-
-    getObjectValue: function(key, defaultValue) {
-	var me = this;
-	var rec = me.store.getById(key);
-	if (rec) {
-	    return rec.data.value;
-	}
-	return defaultValue;
-    },
-
-    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;
-
-	var rows = me.rows;
-
-	if (!me.rstore) {
-	    if (!me.url) {
-		throw "no url specified";
-	    }
-
-	    me.rstore = Ext.create('PVE.data.ObjectStore', {
-		url: me.url,
-		interval: me.interval,
-		extraParams: me.extraParams,
-		rows: me.rows
-	    });
-	}
-
-	var rstore = me.rstore;
-
-	var store = Ext.create('PVE.data.DiffStore', { rstore: rstore,
-	    sorters: [],
-	    filters: []
-	});
-
-	if (rows) {
-	    Ext.Object.each(rows, function(key, rowdef) {
-		if (Ext.isDefined(rowdef.defaultValue)) {
-		    store.add({ key: key, value: rowdef.defaultValue });
-		} else if (rowdef.required) {
-		    store.add({ key: key, value: undefined });
-		}
-	    });
-	}
-
-	if (me.sorterFn) {
-	    store.sorters.add(Ext.create('Ext.util.Sorter', {
-		sorterFn: me.sorterFn
-	    }));
-	}
-
-	store.filters.add(Ext.create('Ext.util.Filter', {
-	    filterFn: function(item) {
-		if (rows) {
-		    var rowdef = rows[item.data.key];
-		    if (!rowdef || (rowdef.visible === false)) {
-			return false;
-		    }
-		}
-		return true;
-	    }
-	}));
-
-	Proxmox.Utils.monStoreErrors(me, rstore);
-
-	Ext.applyIf(me, {
-	    store: store,
-	    stateful: false,
-	    columns: [
-		{
-		    header: gettext('Name'),
-		    width: me.cwidth1 || 200,
-		    dataIndex: 'key',
-		    renderer: me.renderKey
-		},
-		{
-		    flex: 1,
-		    header: gettext('Value'),
-		    dataIndex: 'value',
-		    renderer: me.renderValue
-		}
-	    ]
-	});
-
-	me.callParent();
-   }
-});
diff --git a/www/manager6/grid/PendingObjectGrid.js b/www/manager6/grid/PendingObjectGrid.js
index d5702f2e..102b9b0d 100644
--- a/www/manager6/grid/PendingObjectGrid.js
+++ b/www/manager6/grid/PendingObjectGrid.js
@@ -1,5 +1,5 @@
 Ext.define('PVE.grid.PendingObjectGrid', {
-    extend: 'PVE.grid.ObjectGrid',
+    extend: 'Proxmox.grid.ObjectGrid',
     alias: ['widget.pvePendingObjectGrid'],
 
     getObjectValue: function(key, defaultValue, pending) {
diff --git a/www/manager6/lxc/DNS.js b/www/manager6/lxc/DNS.js
index 31900d3e..9818ff2f 100644
--- a/www/manager6/lxc/DNS.js
+++ b/www/manager6/lxc/DNS.js
@@ -134,7 +134,7 @@ Ext.define('PVE.lxc.DNSEdit', {
 
 /*jslint confusion: true */
 Ext.define('PVE.lxc.DNS', {
-    extend: 'PVE.grid.ObjectGrid',
+    extend: 'Proxmox.grid.ObjectGrid',
     alias: ['widget.pveLxcDNS'],
 
     onlineHelp: 'pct_container_network',
diff --git a/www/manager6/lxc/Options.js b/www/manager6/lxc/Options.js
index aadce038..0871fc92 100644
--- a/www/manager6/lxc/Options.js
+++ b/www/manager6/lxc/Options.js
@@ -1,6 +1,6 @@
 /*jslint confusion: true */
 Ext.define('PVE.lxc.Options', {
-    extend: 'PVE.grid.ObjectGrid',
+    extend: 'Proxmox.grid.ObjectGrid',
     alias: ['widget.pveLxcOptions'],
 
     onlineHelp: 'pct_options',
diff --git a/www/manager6/lxc/Resources.js b/www/manager6/lxc/Resources.js
index 40eefe1f..0ed9c2ff 100644
--- a/www/manager6/lxc/Resources.js
+++ b/www/manager6/lxc/Resources.js
@@ -1,6 +1,6 @@
 /*jslint confusion: true */
 Ext.define('PVE.lxc.RessourceView', {
-    extend: 'PVE.grid.ObjectGrid',
+    extend: 'Proxmox.grid.ObjectGrid',
     alias: ['widget.pveLxcRessourceView'],
 
     onlineHelp: 'pct_configuration',
diff --git a/www/manager6/node/Subscription.js b/www/manager6/node/Subscription.js
index fa49f540..61af058f 100644
--- a/www/manager6/node/Subscription.js
+++ b/www/manager6/node/Subscription.js
@@ -19,7 +19,7 @@ Ext.define('PVE.node.SubscriptionKeyEdit', {
 });
 
 Ext.define('PVE.node.Subscription', {
-    extend: 'PVE.grid.ObjectGrid',
+    extend: 'Proxmox.grid.ObjectGrid',
 
     alias: ['widget.pveNodeSubscription'],
 
diff --git a/www/manager6/pool/StatusView.js b/www/manager6/pool/StatusView.js
index 0454a295..8628964b 100644
--- a/www/manager6/pool/StatusView.js
+++ b/www/manager6/pool/StatusView.js
@@ -1,5 +1,5 @@
 Ext.define('PVE.pool.StatusView', {
-    extend: 'PVE.grid.ObjectGrid',
+    extend: 'Proxmox.grid.ObjectGrid',
     alias: ['widget.pvePoolStatusView'],
     disabled: true,
 
diff --git a/www/manager6/window/TaskViewer.js b/www/manager6/window/TaskViewer.js
index 2187168e..fe097a96 100644
--- a/www/manager6/window/TaskViewer.js
+++ b/www/manager6/window/TaskViewer.js
@@ -171,7 +171,7 @@ Ext.define('PVE.window.TaskViewer', {
 	    handler: stop_task
 	});
 
-	statgrid = Ext.create('PVE.grid.ObjectGrid', {
+	statgrid = Ext.create('Proxmox.grid.ObjectGrid', {
 	    title: gettext('Status'),
 	    layout: 'fit',
 	    tbar: [ stop_btn1 ],
-- 
2.14.2





More information about the pve-devel mailing list