mirror of
https://git.proxmox.com/git/pmg-gui
synced 2025-08-14 10:11:38 +00:00
add DomainStatistics class
This commit is contained in:
parent
106ed6a2cd
commit
73360b1121
152
js/DomainStatistics.js
Normal file
152
js/DomainStatistics.js
Normal file
@ -0,0 +1,152 @@
|
||||
Ext.define('PMG.DomainStatistics', {
|
||||
extend: 'Ext.panel.Panel',
|
||||
xtype: 'pmgDomainStatistics',
|
||||
|
||||
title: 'Mail Domain Statistics',
|
||||
|
||||
tbar: [ { xtype: 'pmgStatTimeSelector' } ],
|
||||
|
||||
layout: 'fit',
|
||||
|
||||
initComponent: function() {
|
||||
var me = this;
|
||||
|
||||
var fields = [
|
||||
'domain',
|
||||
{ type: 'integer', name: 'count_in' },
|
||||
{ type: 'integer', name: 'count_out' },
|
||||
{ type: 'integer', name: 'spamcount_in' },
|
||||
{ type: 'integer', name: 'spamcount_out' },
|
||||
{ type: 'integer', name: 'viruscount_in' },
|
||||
{ type: 'integer', name: 'viruscount_out' },
|
||||
{ type: 'number', name: 'mbytes_in' },
|
||||
{ type: 'number', name: 'mbytes_out' }
|
||||
];
|
||||
|
||||
var store = Ext.create('PMG.data.StatStore', {
|
||||
staturl: '/api2/json/statistics/domains',
|
||||
fields: fields
|
||||
});
|
||||
|
||||
var store_in = Ext.create('Ext.data.ArrayStore', {
|
||||
fields: fields,
|
||||
filters: [ function(item) { return item.data.count_in > 0; } ]
|
||||
});
|
||||
|
||||
var store_out = Ext.create('Ext.data.ArrayStore', {
|
||||
fields: fields,
|
||||
filters: [ function(item) { return item.data.count_out > 0; } ]
|
||||
});
|
||||
|
||||
store.on('load', function(s, records, successful) {
|
||||
if (!successful) {
|
||||
store_in.setData([]);
|
||||
store_out.setData([]);
|
||||
} else {
|
||||
store_in.setData(records);
|
||||
store_out.setData(records);
|
||||
}
|
||||
})
|
||||
|
||||
var render_domain = function(v) {
|
||||
return v === '' ? '--- EMPTY ADDRESS ---' : v;
|
||||
};
|
||||
|
||||
me.items = {
|
||||
xtype: 'tabpanel',
|
||||
border: false,
|
||||
items: [
|
||||
{
|
||||
xtype: 'grid',
|
||||
title: gettext('Incoming'),
|
||||
border: false,
|
||||
disableSelection: true,
|
||||
store: store_in,
|
||||
emptyText: gettext('No data in database.'),
|
||||
viewConfig: {
|
||||
deferEmptyText: false
|
||||
},
|
||||
columns: [
|
||||
{
|
||||
text: gettext('Domain')+ ' (' +
|
||||
gettext('Receiver') + ')',
|
||||
flex: 1,
|
||||
renderer: render_domain,
|
||||
dataIndex: 'domain'
|
||||
},
|
||||
{
|
||||
text: gettext('Traffic') + ' (MB)',
|
||||
dataIndex: 'mbytes_in',
|
||||
renderer: function(v) {
|
||||
return Ext.Number.toFixed(v, 2);
|
||||
}
|
||||
},
|
||||
{
|
||||
text: gettext('Count'),
|
||||
columns: [
|
||||
{
|
||||
text: gettext('Mail'),
|
||||
dataIndex: 'count_in'
|
||||
},
|
||||
{
|
||||
header: gettext('Virus'),
|
||||
dataIndex: 'viruscount_in'
|
||||
},
|
||||
{
|
||||
header: gettext('Spam'),
|
||||
dataIndex: 'spamcount_in'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
xtype: 'grid',
|
||||
title: gettext('Outgoing'),
|
||||
border: false,
|
||||
disableSelection: true,
|
||||
store: store_out,
|
||||
emptyText: gettext('No data in database.'),
|
||||
viewConfig: {
|
||||
deferEmptyText: false
|
||||
},
|
||||
columns: [
|
||||
{
|
||||
text: gettext('Domain')+ ' (' +
|
||||
gettext('Receiver') + ')',
|
||||
flex: 1,
|
||||
renderer: render_domain,
|
||||
dataIndex: 'domain'
|
||||
},
|
||||
{
|
||||
text: gettext('Traffic') + ' (MB)',
|
||||
dataIndex: 'mbytes_out',
|
||||
renderer: function(v) {
|
||||
return Ext.Number.toFixed(v, 2);
|
||||
}
|
||||
},
|
||||
{
|
||||
text: gettext('Count'),
|
||||
columns: [
|
||||
{
|
||||
text: gettext('Mail'),
|
||||
dataIndex: 'count_out'
|
||||
},
|
||||
{
|
||||
header: gettext('Virus'),
|
||||
dataIndex: 'viruscount_out'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
me.callParent();
|
||||
|
||||
Proxmox.Utils.monStoreErrors(me, store);
|
||||
|
||||
me.on('destroy', store.destroy, store);
|
||||
}
|
||||
});
|
@ -59,6 +59,7 @@ JSSRC= \
|
||||
VirusCharts.js \
|
||||
SpamScoreDistribution.js \
|
||||
GeneralMailStatistics.js \
|
||||
DomainStatistics.js \
|
||||
HourlyMailDistribution.js \
|
||||
Application.js
|
||||
|
||||
|
@ -118,6 +118,13 @@ Ext.define('PMG.store.NavigationStore', {
|
||||
path: 'pmgHourlyMailDistribution',
|
||||
border: false,
|
||||
leaf: true
|
||||
},
|
||||
{
|
||||
text: gettext('Domain'),
|
||||
path: 'pmgDomainStatistics',
|
||||
border: false,
|
||||
leaf: true
|
||||
|
||||
}
|
||||
]
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user