[pve-devel] [RFC manager 07/28] use ObjectGrid from widget toolkit

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Dec 11 16:25:56 CET 2017


Signed-off-by: Thomas Lamprecht <t.lamprecht 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/DNSView.js           |   2 +-
 www/manager6/node/Subscription.js      |   2 +-
 www/manager6/node/TimeView.js          |   2 +-
 www/manager6/pool/StatusView.js        |   2 +-
 www/manager6/window/TaskViewer.js      |   2 +-
 13 files changed, 11 insertions(+), 144 deletions(-)
 delete mode 100644 www/manager6/grid/ObjectGrid.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index c1c6f869..efc44364 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -96,7 +96,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 58d6b61d..988ff530 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 f37af204..c0966a96 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 f4e7e901..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;
-	    }
-	}));
-
-	PVE.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 9b17c6f5..bea56b51 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 e3cdd123..5e66147a 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 3359e37e..ad7712b6 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/DNSView.js b/www/manager6/node/DNSView.js
index 9e9683ad..33bc91fc 100644
--- a/www/manager6/node/DNSView.js
+++ b/www/manager6/node/DNSView.js
@@ -1,5 +1,5 @@
 Ext.define('PVE.node.DNSView', {
-    extend: 'PVE.grid.ObjectGrid',
+    extend: 'Proxmox.grid.ObjectGrid',
     alias: ['widget.pveNodeDNSView'],
 
     onlineHelp: 'sysadmin_network_configuration',
diff --git a/www/manager6/node/Subscription.js b/www/manager6/node/Subscription.js
index 0859d85b..f5ad1b54 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/node/TimeView.js b/www/manager6/node/TimeView.js
index 20c83106..2683c580 100644
--- a/www/manager6/node/TimeView.js
+++ b/www/manager6/node/TimeView.js
@@ -1,5 +1,5 @@
 Ext.define('PVE.node.TimeView', {
-    extend: 'PVE.grid.ObjectGrid',
+    extend: 'Proxmox.grid.ObjectGrid',
     alias: ['widget.pveNodeTimeView'],
 
     initComponent : function() {
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 f7843d7a..d3c2fe38 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.11.0





More information about the pve-devel mailing list