[pve-devel] [PATCH manager 8/8] add cpu/memory usage, uptime to nodeview

Dominik Csapak d.csapak at proxmox.com
Fri Oct 28 13:11:48 CEST 2016


this patch adds a custom progressbar widget  which changes color,
depending on the value, and adds cpu/memory usage and uptime as columns
to the nodeview
altough those columns are missing in the model/api call, this works , because we
inject the data in our data collectin loop and having the fields not in
the model, causes the store not to overwrite them

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/manager6/dc/NodeView.js | 51 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/www/manager6/dc/NodeView.js b/www/manager6/dc/NodeView.js
index dea5f1d..af5c6e0 100644
--- a/www/manager6/dc/NodeView.js
+++ b/www/manager6/dc/NodeView.js
@@ -46,6 +46,35 @@ Ext.define('PVE.dc.NodeView', {
 	    sortable: true,
 	    dataIndex: 'ip'
 	},
+	{
+	    header: gettext('CPU Usage'),
+	    sortable: true,
+	    width: 110,
+	    dataIndex: 'cpuusage',
+	    tdCls: 'x-progressbar-default-cell',
+	    xtype: 'widgetcolumn',
+	    widget: {
+		xtype: 'pveProgressBar'
+	    }
+	},
+	{
+	    header: gettext('Memory Usage'),
+	    width: 110,
+	    sortable: true,
+	    tdCls: 'x-progressbar-default-cell',
+	    dataIndex: 'memoryusage',
+	    xtype: 'widgetcolumn',
+	    widget: {
+		xtype: 'pveProgressBar'
+	    }
+	},
+	{
+	    header: gettext('Uptime'),
+	    sortable: true,
+	    dataIndex: 'uptime',
+	    align: 'right',
+	    renderer: PVE.Utils.render_uptime
+	}
     ],
 
     stateful: true,
@@ -78,3 +107,25 @@ Ext.define('PVE.dc.NodeView', {
 
 });
 
+Ext.define('PVE.widget.ProgressBar',{
+    extend: 'Ext.Progress',
+    alias: 'widget.pveProgressBar',
+
+    animate: true,
+    textTpl: [
+	'{percent}%'
+    ],
+
+    setValue: function(value){
+	var me = this;
+	me.callParent([value]);
+
+	me.removeCls(['warning', 'critical']);
+
+	if (value > 0.89) {
+	    me.addCls('critical');
+	} else if (value > 0.59) {
+	    me.addCls('warning');
+	}
+    }
+});
-- 
2.1.4





More information about the pve-devel mailing list