/*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',
},
items: [{
xtype: 'form',
- bodyPadding: 10,
+ bodyPadding: '10 10 10 10',
defaultButton: 'savebutton',
items: [{
xtype: 'proxmoxintegerfield',
win.close();
}
}]
- }],
+ }]
}).show();
},
viewModel.notify();
Ext.Array.forEach(['recentmails', 'receivers'], function(item) {
- viewModel.get(item).load();
+ viewModel.getStore(item).reload();
});
if (setState) {
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;
});
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) {
var mem = 0;
var hd = 0;
var count = records.length;
+ var errors = [];
records.forEach(function(item) {
// subscription level check
}
// 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');
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 + ':<br>' + error.msg + '<br>';
+ });
+ Ext.Msg.alert(gettext('Error'), text);
+ viewmodel.set('error_shown', true);
+ }
},
init: function(view) {
data: {
timespan: 300, // in seconds
hours: 12, // in hours
+ error_shown: false,
'bytes_in': 0,
'bytes_out': 0,
- 'avg_ptime': 0.0,
+ 'avg_ptime': 0.0
},
stores: {
autoLoad: true,
autoDestroy: true,
proxy: {
+ extraParams: { list_single_node: 1 },
type: 'proxmox',
url: '/api2/json/config/cluster/status'
},
type: 'proxmox',
url: '/api2/json/statistics/recentreceivers',
extraParams: {
- hours: '{hours}',
+ hours: '{hours}'
}
},
fields: [
Ext.String.format(gettext('{0} hours'), '{hours}') + ')'
},
- layout: 'column',
+ layout: {
+ type: 'column'
+ },
border: false,
bodyPadding: '20 0 0 20',
title: gettext('E-Mail Volume'),
layout: {
type: 'vbox',
- align: 'stretch',
+ align: 'stretch'
},
defaults: {
xtype: 'pmgMiniGraph',
highlightCfg: {
opacity: 1,
scaling: 1
- },
- },
+ }
+ }
},
{
fields: ['spam'],
highlightCfg: {
opacity: 1,
scaling: 1
- },
- },
- },
+ }
+ }
+ }
]
},
{
height: 300,
layout: {
type: 'vbox',
- align: 'stretch',
+ align: 'stretch'
},
items: [
{
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}'
}
- },
+ }
},
{
iconCls: 'fa fa-ticket',
reference: 'subscription',
xtype: 'pmgSubscriptionInfo',
margin: '10 0 0 0',
- height: 110,
+ height: 110
}
]
},
{
height: 250,
iconCls: 'fa fa-tasks',
- title: 'Node Resources',
+ title: gettext('Node Resources'),
bodyPadding: '0 20 0 20',
layout: {
type: 'hbox',
iconCls: 'fa fa-list',
title: gettext('Top Receivers'),
- bodyPadding: 20,
+ bodyPadding: '20 20 20 20',
layout: {
type: 'vbox',
pack: 'center',
columnLines: false,
rowLines: false,
viewConfig: {
- stripeRows: false,
+ stripeRows: false
},
columns: [