[pve-devel] [PATCH manager 4/4] ui: panel/StatusView: use from widget-toolkit instead

Dominik Csapak d.csapak at proxmox.com
Mon Apr 19 13:00:48 CEST 2021


Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/manager6/Makefile                    |   1 -
 www/manager6/node/StatusView.js          |   2 +-
 www/manager6/panel/GuestStatusView.js    |   2 +-
 www/manager6/panel/StatusView.js         | 126 -----------------------
 www/manager6/panel/TemplateStatusView.js |   2 +-
 www/manager6/storage/StatusView.js       |   2 +-
 6 files changed, 4 insertions(+), 131 deletions(-)
 delete mode 100644 www/manager6/panel/StatusView.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index a2f7be6d..928d8b15 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -81,7 +81,6 @@ JSSRC= 							\
 	panel/NotesView.js				\
 	panel/RunningChart.js				\
 	panel/StatusPanel.js				\
-	panel/StatusView.js				\
 	panel/GuestStatusView.js			\
 	panel/GuestSummary.js				\
 	panel/TemplateStatusView.js			\
diff --git a/www/manager6/node/StatusView.js b/www/manager6/node/StatusView.js
index 573fbfae..afbc57e8 100644
--- a/www/manager6/node/StatusView.js
+++ b/www/manager6/node/StatusView.js
@@ -1,5 +1,5 @@
 Ext.define('PVE.node.StatusView', {
-    extend: 'PVE.panel.StatusView',
+    extend: 'Proxmox.panel.StatusView',
     alias: 'widget.pveNodeStatus',
 
     height: 300,
diff --git a/www/manager6/panel/GuestStatusView.js b/www/manager6/panel/GuestStatusView.js
index d8439e5d..8d16827e 100644
--- a/www/manager6/panel/GuestStatusView.js
+++ b/www/manager6/panel/GuestStatusView.js
@@ -1,5 +1,5 @@
 Ext.define('PVE.panel.GuestStatusView', {
-    extend: 'PVE.panel.StatusView',
+    extend: 'Proxmox.panel.StatusView',
     alias: 'widget.pveGuestStatusView',
     mixins: ['Proxmox.Mixin.CBind'],
 
diff --git a/www/manager6/panel/StatusView.js b/www/manager6/panel/StatusView.js
deleted file mode 100644
index a8f01ce8..00000000
--- a/www/manager6/panel/StatusView.js
+++ /dev/null
@@ -1,126 +0,0 @@
-Ext.define('PVE.panel.StatusView', {
-    extend: 'Ext.panel.Panel',
-    alias: 'widget.pveStatusView',
-
-    layout: {
-	type: 'column',
-    },
-
-    title: gettext('Status'),
-
-    getRecordValue: function(key, store) {
-	if (!key) {
-	    throw "no key given";
-	}
-	var me = this;
-
-	if (store === undefined) {
-	    store = me.getStore();
-	}
-
-	var rec = store.getById(key);
-	if (rec) {
-	    return rec.data.value;
-	}
-
-	return '';
-    },
-
-    fieldRenderer: function(val, max) {
-	if (max === undefined) {
-	    return val;
-	}
-
-	if (!Ext.isNumeric(max) || max === 1) {
-	    return Proxmox.Utils.render_usage(val);
-	}
-	return Proxmox.Utils.render_size_usage(val, max);
-    },
-
-    fieldCalculator: function(used, max) {
-	if (!Ext.isNumeric(max) && Ext.isNumeric(used)) {
-	    return used;
-	} else if (!Ext.isNumeric(used)) {
-	    /* we come here if the field is from a node
-	     * where the records are not mem and maxmem
-	     * but mem.used and mem.total
-	     */
-	    if (used.used !== undefined &&
-		used.total !== undefined) {
-		return used.used/used.total;
-	    }
-	}
-
-	return used/max;
-    },
-
-    updateField: function(field) {
-	var me = this;
-	var text = '';
-	var renderer = me.fieldRenderer;
-	if (Ext.isFunction(field.renderer)) {
-	    renderer = field.renderer;
-	}
-	if (field.multiField === true) {
-	    field.updateValue(renderer.call(field, me.getStore().getRecord()));
-	} else if (field.textField !== undefined) {
-	    field.updateValue(renderer.call(field, me.getRecordValue(field.textField)));
-	} else if (field.valueField !== undefined) {
-	    var used = me.getRecordValue(field.valueField);
-	    /* string and int */
-	    var max = field.maxField !== undefined ? me.getRecordValue(field.maxField) : 1;
-
-	    var calculate = me.fieldCalculator;
-
-	    if (Ext.isFunction(field.calculate)) {
-		calculate = field.calculate;
-	    }
-	    field.updateValue(renderer.call(field, used, max), calculate(used, max));
-	}
-    },
-
-    getStore: function() {
-	var me = this;
-	if (!me.rstore) {
-	    throw "there is no rstore";
-	}
-
-	return me.rstore;
-    },
-
-    updateTitle: function() {
-	var me = this;
-	me.setTitle(me.getRecordValue('name'));
-    },
-
-    updateValues: function(store, records, success) {
-	if (!success) {
-	    return; // do not update if store load was not successful
-	}
-	var me = this;
-	var itemsToUpdate = me.query('pveInfoWidget');
-
-	itemsToUpdate.forEach(me.updateField, me);
-
-	me.updateTitle(store);
-    },
-
-    initComponent: function() {
-	var me = this;
-
-	if (!me.rstore) {
-	    throw "no rstore given";
-	}
-
-	if (!me.title) {
-	    throw "no title given";
-	}
-
-	Proxmox.Utils.monStoreErrors(me, me.rstore);
-
-	me.callParent();
-
-	me.mon(me.rstore, 'load', 'updateValues');
-    },
-
-});
diff --git a/www/manager6/panel/TemplateStatusView.js b/www/manager6/panel/TemplateStatusView.js
index b8e01d43..44d983b3 100644
--- a/www/manager6/panel/TemplateStatusView.js
+++ b/www/manager6/panel/TemplateStatusView.js
@@ -1,5 +1,5 @@
 Ext.define('PVE.panel.TemplateStatusView', {
-    extend: 'PVE.panel.StatusView',
+    extend: 'Proxmox.panel.StatusView',
     alias: 'widget.pveTemplateStatusView',
 
     layout: {
diff --git a/www/manager6/storage/StatusView.js b/www/manager6/storage/StatusView.js
index e42e8a7d..923d73f2 100644
--- a/www/manager6/storage/StatusView.js
+++ b/www/manager6/storage/StatusView.js
@@ -1,5 +1,5 @@
 Ext.define('PVE.storage.StatusView', {
-    extend: 'PVE.panel.StatusView',
+    extend: 'Proxmox.panel.StatusView',
     alias: 'widget.pveStorageStatusView',
 
     height: 230,
-- 
2.20.1






More information about the pve-devel mailing list