X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=js%2FDashboard.js;h=ce94841621dae0fef963c357db9db55e4f082540;hb=80ccc3425b6bd353a341af7065e628fb05876627;hp=4fc35fd0db8f0796cde3444f1c267cba0de7366d;hpb=771bd0b94b0ccbcfe20c8fa1f7fd1e18a1b1cd83;p=pmg-gui.git
diff --git a/js/Dashboard.js b/js/Dashboard.js
index 4fc35fd..ce94841 100644
--- a/js/Dashboard.js
+++ b/js/Dashboard.js
@@ -1,4 +1,11 @@
/*global Proxmox*/
+/*jslint confusion: true*/
+/* load is a function and string
+ * hours is a number and string
+ * timespan is a number and string
+ * bind is a function and object
+ * handler is a function and string
+ */
Ext.define('PMG.Dashboard', {
extend: 'Ext.panel.Panel',
xtype: 'pmgDashboard',
@@ -18,7 +25,7 @@ Ext.define('PMG.Dashboard', {
},
items: [{
xtype: 'form',
- bodyPadding: 10,
+ bodyPadding: '10 10 10 10',
defaultButton: 'savebutton',
items: [{
xtype: 'proxmoxintegerfield',
@@ -53,7 +60,7 @@ Ext.define('PMG.Dashboard', {
viewModel.notify();
Ext.Array.forEach(['recentmails', 'receivers'], function(item) {
- viewModel.get(item).load();
+ viewModel.getStore(item).reload();
});
if (setState) {
@@ -73,7 +80,7 @@ Ext.define('PMG.Dashboard', {
var bytes_in = 0;
var bytes_out = 0;
var ptime = 0;
- var avg_ptime = 0;
+ var avg_ptime = 'N/A';
records.forEach(function(item) {
bytes_in += item.data.bytes_in;
@@ -84,12 +91,12 @@ Ext.define('PMG.Dashboard', {
});
if (count) {
- avg_ptime = (ptime/count).toFixed(2);
+ avg_ptime = (ptime/count).toFixed(2) + " s";
}
viewModel.set('bytes_in', Proxmox.Utils.format_size(bytes_in));
viewModel.set('bytes_out', Proxmox.Utils.format_size(bytes_out));
- viewModel.set('avg_ptime', avg_ptime + " s");
+ viewModel.set('avg_ptime', avg_ptime);
},
updateClusterStats: function(store, records, success) {
@@ -106,6 +113,7 @@ Ext.define('PMG.Dashboard', {
var mem = 0;
var hd = 0;
var count = records.length;
+ var errors = [];
records.forEach(function(item) {
// subscription level check
@@ -120,9 +128,21 @@ Ext.define('PMG.Dashboard', {
}
// resources count
- cpu += item.data.cpu;
- mem += (item.data.memory.used/item.data.memory.total);
- hd += (item.data.rootfs.used/item.data.rootfs.total);
+ cpu += item.data.cpu || 0;
+
+ var memory = item.data.memory || { used: 0, total: 1 };
+ mem += (memory.used/memory.total);
+
+ var rootfs = item.data.rootfs || { used: 0, total: 1 };
+ hd += (rootfs.used/rootfs.total);
+
+ if (item.data.conn_error && count > 1) {
+ count--;
+ errors.push({
+ name: item.data.name,
+ msg: item.data.conn_error
+ });
+ }
});
var subscriptionPanel = me.lookup('subscription');
@@ -135,11 +155,20 @@ Ext.define('PMG.Dashboard', {
var cpuPanel = me.lookup('cpu');
cpuPanel.updateValue(cpu);
- var memPanel = me.lookup('mem')
+ var memPanel = me.lookup('mem');
memPanel.updateValue(mem);
- var hdPanel = me.lookup('hd')
+ var hdPanel = me.lookup('hd');
hdPanel.updateValue(hd);
+
+ if (errors.length && !viewmodel.get('error_shown')) {
+ var text = "";
+ errors.forEach(function(error) {
+ text += error.name + ':
' + error.msg + '
';
+ });
+ Ext.Msg.alert(gettext('Error'), text);
+ viewmodel.set('error_shown', true);
+ }
},
init: function(view) {
@@ -154,6 +183,7 @@ Ext.define('PMG.Dashboard', {
data: {
timespan: 300, // in seconds
hours: 12, // in hours
+ error_shown: false,
'bytes_in': 0,
'bytes_out': 0,
'avg_ptime': 0.0
@@ -168,6 +198,7 @@ Ext.define('PMG.Dashboard', {
autoLoad: true,
autoDestroy: true,
proxy: {
+ extraParams: { list_single_node: 1 },
type: 'proxmox',
url: '/api2/json/config/cluster/status'
},
@@ -260,7 +291,9 @@ Ext.define('PMG.Dashboard', {
Ext.String.format(gettext('{0} hours'), '{hours}') + ')'
},
- layout: 'column',
+ layout: {
+ type: 'column'
+ },
border: false,
bodyPadding: '20 0 0 20',
@@ -344,9 +377,9 @@ Ext.define('PMG.Dashboard', {
height: 180,
bind: {
data: {
- 'in': '{bytes_in}',
- 'out': '{bytes_out}',
- 'ptime': '{avg_ptime}'
+ 'bytes_in': '{bytes_in}',
+ 'bytes_out': '{bytes_out}',
+ 'avg_ptime': '{avg_ptime}'
}
}
},
@@ -363,7 +396,7 @@ Ext.define('PMG.Dashboard', {
{
height: 250,
iconCls: 'fa fa-tasks',
- title: 'Node Resources',
+ title: gettext('Node Resources'),
bodyPadding: '0 20 0 20',
layout: {
type: 'hbox',
@@ -394,7 +427,7 @@ Ext.define('PMG.Dashboard', {
iconCls: 'fa fa-list',
title: gettext('Top Receivers'),
- bodyPadding: 20,
+ bodyPadding: '20 20 20 20',
layout: {
type: 'vbox',
pack: 'center',