-/*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',
width: 300,
title: gettext('Dashboard Options'),
layout: {
- type: 'auto'
+ type: 'auto',
},
items: [{
xtype: 'form',
minValue: 1,
maxValue: 24,
value: viewModel.get('hours'),
- fieldLabel: gettext('Hours to show')
+ fieldLabel: gettext('Hours to show'),
}],
buttons: [{
text: gettext('Save'),
var hours = win.down('#hours').getValue();
me.setHours(hours, true);
win.close();
- }
- }]
- }]
+ },
+ }],
+ }],
}).show();
},
subStatus = 0;
}
+ if (item.data.name === Proxmox.NodeName) {
+ let repoStatus = me.lookup('nodeInfo').down('#repositoryStatus');
+ repoStatus.setSubscriptionStatus(!!item.data.level);
+ }
+
// resources count
cpu += item.data.cpu || 0;
var memory = item.data.memory || { used: 0, total: 1 };
- mem += (memory.used/memory.total);
+ mem += memory.used/memory.total;
var rootfs = item.data.rootfs || { used: 0, total: 1 };
- hd += (rootfs.used/rootfs.total);
+ hd += rootfs.used/rootfs.total;
if (item.data.conn_error && count > 1) {
count--;
errors.push({
name: item.data.name,
- msg: item.data.conn_error
+ msg: item.data.conn_error,
});
}
});
var subscriptionPanel = me.lookup('subscription');
subscriptionPanel.setSubStatus(subStatus);
+ // the node info already displays this information in case there is no cluster
+ me.lookup('clusterResources').setHidden(records.length === 1);
+
cpu = cpu/count;
mem = mem/count;
hd = hd/count;
}
},
+ updateRepositoryStatus: function(store, records, success) {
+ if (!success) {
+ return;
+ }
+
+ let me = this;
+ let repoStatus = me.lookup('nodeInfo').down('#repositoryStatus');
+ repoStatus.setRepositoryInfo(records[0].data['standard-repos']);
+ },
+
init: function(view) {
var me = this;
var sp = Ext.state.Manager.getProvider();
var hours = sp.get('dashboard-hours') || 12;
me.setHours(hours, false);
- }
+
+ view.mon(sp, 'statechange', function(provider, key, value) {
+ if (key !== 'summarycolumns') {
+ return;
+ }
+ Proxmox.Utils.updateColumnWidth(view);
+ });
+ },
+ },
+
+ listeners: {
+ resize: panel => Proxmox.Utils.updateColumnWidth(panel),
},
viewModel: {
error_shown: false,
'bytes_in': 0,
'bytes_out': 0,
- 'avg_ptime': 0.0
+ 'avg_ptime': 0.0,
},
stores: {
type: 'update',
interval: 5000,
autoStart: true,
- autoLoad: true,
autoDestroy: true,
proxy: {
extraParams: { list_single_node: 1 },
type: 'proxmox',
- url: '/api2/json/config/cluster/status'
+ url: '/api2/json/config/cluster/status',
},
listeners: {
- load: 'updateClusterStats'
- }
+ load: 'updateClusterStats',
+ },
},
recentmails: {
storeid: 'dash-recent',
interval: 5000,
type: 'update',
autoStart: true,
- autoLoad: true,
autoDestroy: true,
proxy: {
type: 'proxmox',
url: '/api2/json/statistics/recent',
extraParams: {
hours: '{hours}',
- timespan: '{timespan}'
- }
+ timespan: '{timespan}',
+ },
},
fields: [
{
type: 'number', name: 'count',
- convert: PMG.Utils.convert_field_to_per_min
+ convert: PMG.Utils.convert_field_to_per_min,
},
{
type: 'number', name: 'count_in',
- convert: PMG.Utils.convert_field_to_per_min
+ convert: PMG.Utils.convert_field_to_per_min,
},
{
type: 'number', name: 'count_out',
- convert: PMG.Utils.convert_field_to_per_min
+ convert: PMG.Utils.convert_field_to_per_min,
},
{
type: 'number', name: 'spam',
- convert: PMG.Utils.convert_field_to_per_min
+ convert: PMG.Utils.convert_field_to_per_min,
},
{
type: 'number', name: 'spam_in',
- convert: PMG.Utils.convert_field_to_per_min
+ convert: PMG.Utils.convert_field_to_per_min,
},
{
type: 'number', name: 'spam_out',
- convert: PMG.Utils.convert_field_to_per_min
+ convert: PMG.Utils.convert_field_to_per_min,
},
{
type: 'number', name: 'virus',
- convert: PMG.Utils.convert_field_to_per_min
+ convert: PMG.Utils.convert_field_to_per_min,
},
{
type: 'number', name: 'virus_in',
- convert: PMG.Utils.convert_field_to_per_min
+ convert: PMG.Utils.convert_field_to_per_min,
},
{ type: 'integer', name: 'virus_out' },
{ type: 'integer', name: 'bytes_in' },
{ type: 'integer', name: 'bytes_out' },
{ type: 'number', name: 'ptimesum' },
- { type: 'date', dateFormat: 'timestamp', name: 'time' }
+ { type: 'date', dateFormat: 'timestamp', name: 'time' },
],
listeners: {
- load: 'updateMailStats'
- }
+ load: 'updateMailStats',
+ },
},
receivers: {
storeid: 'dash-receivers',
interval: 10000,
type: 'update',
autoStart: true,
- autoLoad: true,
autoDestroy: true,
proxy: {
type: 'proxmox',
url: '/api2/json/statistics/recentreceivers',
extraParams: {
- hours: '{hours}'
- }
+ hours: '{hours}',
+ limit: 10, // make this also configurable?
+ },
},
fields: [
{ type: 'integer', name: 'count' },
- { type: 'string', name: 'receiver' }
- ]
- }
- }
+ { type: 'string', name: 'receiver' },
+ ],
+ },
+ repositories: {
+ storeid: 'dash-repositories',
+ type: 'update',
+ interval: 15000,
+ autoStart: true,
+ autoLoad: true,
+ autoDestroy: true,
+ proxy: {
+ type: 'proxmox',
+ url: '/api2/json/nodes/localhost/apt/repositories',
+ },
+ listeners: {
+ load: 'updateRepositoryStatus',
+ },
+ },
+ },
},
bind: {
title: gettext('Dashboard') + ' (' +
- Ext.String.format(gettext('{0} hours'), '{hours}') + ')'
+ Ext.String.format(gettext('{0} hours'), '{hours}') + ')',
},
layout: {
- type: 'column'
+ type: 'column',
},
border: false,
bodyPadding: '20 0 0 20',
defaults: {
- columnWidth: 0.5,
+ columnWidth: 1,
xtype: 'panel',
- margin: '0 20 20 0'
+ margin: '0 20 20 0',
},
tools: [
{
type: 'gear',
- handler: 'openDashboardOptions'
- }
+ handler: 'openDashboardOptions',
+ },
],
scrollable: true,
title: gettext('E-Mail Volume'),
layout: {
type: 'vbox',
- align: 'stretch'
+ align: 'stretch',
},
defaults: {
xtype: 'pmgMiniGraph',
bind: {
- store: '{recentmails}'
- }
+ store: '{recentmails}',
+ },
},
items: [
{
fields: ['count'],
- fieldTitles: [ gettext('Mails / min') ],
+ fieldTitles: [gettext('Mails / min')],
seriesConfig: {
- colors: [ '#00617F' ],
+ colors: ['#00617F'],
style: {
opacity: 0.60,
- lineWidth: 1
+ lineWidth: 1,
},
highlightCfg: {
opacity: 1,
- scaling: 1
- }
- }
+ scaling: 1,
+ },
+ },
},
{
fields: ['spam'],
- fieldTitles: [ gettext('Spam / min') ],
+ fieldTitles: [gettext('Spam / min')],
seriesConfig: {
- colors: [ '#E67300' ],
+ colors: ['#E67300'],
style: {
opacity: 0.60,
- lineWidth: 1
+ lineWidth: 1,
},
highlightCfg: {
opacity: 1,
- scaling: 1
- }
- }
- }
- ]
+ scaling: 1,
+ },
+ },
+ },
+ ],
},
{
xtype: 'container',
height: 300,
layout: {
type: 'vbox',
- align: 'stretch'
+ align: 'stretch',
},
items: [
{
data: {
'bytes_in': '{bytes_in}',
'bytes_out': '{bytes_out}',
- 'avg_ptime': '{avg_ptime}'
- }
- }
+ 'avg_ptime': '{avg_ptime}',
+ },
+ },
},
{
iconCls: 'fa fa-ticket',
- title: 'Subscription',
+ title: gettext('Subscription'),
reference: 'subscription',
xtype: 'pmgSubscriptionInfo',
margin: '10 0 0 0',
- height: 110
- }
- ]
+ height: 110,
+ },
+ ],
},
{
- height: 250,
+ xtype: 'pmgNodeInfoPanel',
+ reference: 'nodeInfo',
+ height: 300,
+ bodyPadding: '15 5 15 5',
iconCls: 'fa fa-tasks',
- title: gettext('Node Resources'),
- bodyPadding: '0 20 0 20',
- layout: {
- type: 'hbox',
- align: 'center'
- },
- defaults: {
- xtype: 'proxmoxGauge',
- spriteFontSize: '20px',
- flex: 1
- },
- items: [
- {
- title: gettext('CPU'),
- reference: 'cpu'
- },
- {
- title: gettext('Memory'),
- reference: 'mem'
- },
- {
- title: gettext('Storage'),
- reference: 'hd'
- }
- ]
},
{
- height: 250,
+ height: 300,
iconCls: 'fa fa-list',
title: gettext('Top Receivers'),
- bodyPadding: '20 20 20 20',
+ bodyPadding: '10 10 10 10',
layout: {
type: 'vbox',
pack: 'center',
- align: 'stretch'
+ align: 'stretch',
},
items: [{
xtype: 'grid',
bind: {
- store: '{receivers}'
+ store: '{receivers}',
},
-
emptyText: gettext('No data in database'),
-
// remove all borders/lines/headers
border: false,
bodyBorder: false,
columnLines: false,
rowLines: false,
viewConfig: {
- stripeRows: false
+ stripeRows: false,
},
-
columns: [
{
dataIndex: 'receiver',
flex: 1,
- text: gettext('Receiver')
+ text: gettext('Receiver'),
},
{
dataIndex: 'count',
align: 'right',
- text: gettext('Count')
- }
- ]
- }]
- }
- ]
+ text: gettext('Count'),
+ },
+ ],
+ }],
+ },
+ {
+ height: 250,
+ iconCls: 'fa fa-tasks',
+ title: gettext('Cluster Resources (average)'),
+ reference: 'clusterResources',
+ hidden: true,
+ bodyPadding: '0 20 0 20',
+ layout: {
+ type: 'hbox',
+ align: 'center',
+ },
+ defaults: {
+ xtype: 'proxmoxGauge',
+ spriteFontSize: '20px',
+ flex: 1,
+ },
+ items: [
+ {
+ title: gettext('CPU'),
+ reference: 'cpu',
+ },
+ {
+ title: gettext('Memory'),
+ reference: 'mem',
+ },
+ {
+ title: gettext('Storage'),
+ reference: 'hd',
+ },
+ ],
+ },
+ ],
});