]> git.proxmox.com Git - pmg-gui.git/blob - js/HourlyMailDistribution.js
add hourly mail distribution bar charts
[pmg-gui.git] / js / HourlyMailDistribution.js
1 Ext.define('PMG.MailDistChart', {
2 extend: 'Ext.chart.CartesianChart',
3 xtype: 'pmgMailDistChart',
4
5 width: 770,
6 height: 300,
7 animation: false,
8
9 axes: [{
10 type: 'numeric',
11 title: gettext('Count'),
12 position: 'left',
13 grid: true,
14 minimum: 0
15 }, {
16 type: 'category',
17 position: 'bottom',
18 fields: ['index']
19 }],
20
21 initComponent: function() {
22 var me = this;
23
24
25 if (!me.store) {
26 throw "cannot work without store";
27 }
28
29 if (!me.field) {
30 throw "cannot work without a field";
31 }
32
33 me.callParent();
34
35 me.addSeries({
36 type: 'bar',
37 xField: 'index',
38 yField: me.field,
39 tooltip: {
40 trackMouse: true,
41 renderer: function(tooltip, record, item) {
42 var start = record.get('index');
43 var end = start+1;
44 tooltip.setHtml('Time: ' + start + ' - ' + end + '<br>' +
45 'Count: ' + record.get(item.field));
46 }
47 }
48 });
49 }
50 });
51
52 Ext.define('PMG.HourlyMailDistribution', {
53 extend: 'Ext.panel.Panel',
54 xtype: 'pmgHourlyMailDistribution',
55
56 scrollable: true,
57
58 bodyPadding: '0 0 10 0',
59 defaults: {
60 margin: '10 10 0 10'
61 },
62
63 title: gettext('Hourly Distribution'),
64
65 tbar: [ { xtype: 'pmgStatTimeSelector' } ],
66
67 initComponent: function() {
68 var me = this;
69
70 var store = Ext.create('PMG.data.StatStore', {
71 staturl: '/api2/json/statistics/maildistribution',
72 fields: [
73 { type: 'integer', name: 'index' },
74 { type: 'integer', name: 'count' },
75 { type: 'integer', name: 'count_in' },
76 { type: 'integer', name: 'count_out' },
77 { type: 'integer', name: 'spamcount_in' },
78 { type: 'integer', name: 'spamcount_out' },
79 { type: 'integer', name: 'viruscount_in' },
80 { type: 'integer', name: 'viruscount_ou' },
81 { type: 'integer', name: 'bounces_in' },
82 { type: 'integer', name: 'bounces_out' },
83 ]
84 });
85
86 me.items = [
87 {
88 xtype: 'pmgMailDistChart',
89 title: gettext('Incoming Mails'),
90 field: 'count_in',
91 store: store
92 },
93 {
94 xtype: 'pmgMailDistChart',
95 title: gettext('Outgoing Mails'),
96 field: 'count_out',
97 store: store
98 }
99 ];
100
101 me.callParent();
102
103 me.on('destroy', store.destroy, store);
104 }
105 });