]>
Commit | Line | Data |
---|---|---|
93d09a01 DM |
1 | Ext.define('PMG.GeneralMailStatistics', { |
2 | extend: 'Ext.panel.Panel', | |
3 | xtype: 'pmgGeneralMailStatistics', | |
4 | ||
5 | scrollable: true, | |
6 | ||
7 | bodyPadding: '0 0 10 0', | |
8 | defaults: { | |
9 | margin: '10 10 0 10' | |
10 | }, | |
11 | ||
3755c9e0 | 12 | title: gettext('Statistics') + ': ' + gettext('Mail'), |
93d09a01 DM |
13 | |
14 | tbar: [ { xtype: 'pmgStatTimeSelector' } ], | |
15 | ||
16 | getInData: function(data) { | |
17 | var res = []; | |
18 | ||
19 | res.push({ | |
20 | name: gettext("Incoming Mails"), | |
21 | value: data.count_in, | |
22 | percentage: 1 | |
23 | }); | |
24 | ||
25 | res.push({ | |
26 | name: gettext("Junk Mails"), | |
27 | value: data.junk_in, | |
28 | percentage: data.junk_in/data.count_in | |
29 | }); | |
30 | ||
31 | res.push({ | |
32 | name: gettext("Greylisted Mails"), | |
33 | value: data.glcount, | |
34 | percentage: data.glcount/data.count_in | |
35 | }); | |
36 | ||
37 | res.push({ | |
38 | name: gettext("Spam Mails"), | |
39 | value: data.spamcount_in, | |
40 | percentage: data.spamcount_in/data.count_in | |
41 | }); | |
42 | ||
43 | res.push({ | |
44 | name: gettext("SPF rejects"), | |
45 | value: data.spfcount, | |
46 | percentage: data.spfcount/data.count_in | |
47 | }); | |
48 | ||
49 | res.push({ | |
50 | name: gettext("Bounces"), | |
51 | value: data.bounces_in, | |
52 | percentage: data.bounces_in/data.count_in | |
53 | }); | |
54 | ||
55 | res.push({ | |
56 | name: gettext("Virus Mails"), | |
57 | value: data.viruscount_in, | |
58 | percentage: data.viruscount_in/data.count_in | |
59 | }); | |
60 | ||
61 | return res; | |
62 | }, | |
63 | ||
64 | getOutData: function(data) { | |
65 | var res = []; | |
66 | ||
67 | res.push({ | |
68 | name: gettext("Outgoing Mails"), | |
69 | value: data.count_out, | |
70 | percentage: 1 | |
71 | }); | |
72 | ||
73 | res.push({ | |
74 | name: gettext("Bounces"), | |
75 | value: data.bounces_out, | |
76 | percentage: data.bounces_out/data.count_out | |
77 | }); | |
78 | ||
79 | res.push({ | |
80 | name: gettext("Virus Mails"), | |
81 | value: data.viruscount_out, | |
82 | percentage: data.viruscount_out/data.count_out | |
83 | }); | |
84 | ||
85 | return res; | |
86 | }, | |
87 | ||
88 | getGeneralData: function(data) { | |
89 | var res = []; | |
90 | ||
91 | res.push({ | |
92 | name: gettext("Total Mails"), | |
93 | value: data.count, | |
94 | percentage: 1 | |
95 | }); | |
96 | ||
97 | res.push({ | |
98 | name: gettext("Incoming Mails"), | |
99 | value: data.count_in, | |
100 | percentage: data.count_in/data.count | |
101 | }); | |
102 | ||
103 | res.push({ | |
104 | name: gettext("Outgoing Mails"), | |
105 | value: data.count_out, | |
106 | percentage: data.count_out/data.count | |
107 | }); | |
108 | ||
109 | res.push({ | |
110 | name: gettext("Virus Outbreaks"), | |
111 | value: data.viruscount_out | |
112 | }); | |
113 | ||
114 | res.push({ | |
115 | name: gettext("Avg. Mail Precessing Time"), | |
116 | value: Ext.String.format(gettext("{0} seconds"), | |
117 | Ext.Number.toFixed(data.avptime, 2)) | |
118 | }); | |
119 | ||
120 | res.push({ | |
121 | name: gettext("Incoming Mail Traffic"), | |
ae68a06f | 122 | value: Ext.Number.toFixed(data.bytes_in/(1024*1024), 2) + ' MByte' |
93d09a01 DM |
123 | }); |
124 | ||
125 | res.push({ | |
126 | name: gettext("Outgoing Mail Traffic"), | |
ae68a06f | 127 | value: Ext.Number.toFixed(data.bytes_out/(1024*1024), 2) + ' MByte' |
93d09a01 DM |
128 | }); |
129 | return res; | |
130 | }, | |
131 | ||
132 | initComponent: function() { | |
133 | var me = this; | |
134 | ||
135 | var countstore = Ext.create('PMG.data.StatStore', { | |
136 | includeTimeSpan: true, | |
137 | staturl: '/api2/json/statistics/mailcount', | |
138 | fields: [ | |
139 | { type: 'integer', name: 'count' }, | |
140 | { type: 'integer', name: 'count_in' }, | |
141 | { type: 'integer', name: 'count_out' }, | |
142 | { type: 'integer', name: 'spamcount_in' }, | |
143 | { type: 'integer', name: 'spamcount_out' }, | |
144 | { type: 'integer', name: 'viruscount_in' }, | |
9fe99203 | 145 | { type: 'integer', name: 'viruscount_out' }, |
93d09a01 DM |
146 | { type: 'integer', name: 'bounces_in' }, |
147 | { type: 'integer', name: 'bounces_out' }, | |
148 | { type: 'date', dateFormat: 'timestamp', name: 'time' } | |
149 | ] | |
150 | }); | |
151 | ||
152 | var totalgrid = Ext.createWidget('pmgMailStatGrid', { | |
153 | dockedItems: [ | |
154 | { | |
155 | dock: 'top', | |
156 | title: gettext("Total Mail Count"), | |
157 | xtype: 'proxmoxRRDChart', | |
158 | fields: ['count', 'count_in', 'count_out'], | |
159 | fieldTitles: [ | |
160 | gettext('Total Mail Count'), | |
161 | gettext('Incoming Mails'), gettext('Outgoing Mails')], | |
162 | store: countstore | |
163 | } | |
164 | ] | |
165 | }); | |
166 | ||
167 | var ingrid = Ext.createWidget('pmgMailStatGrid', { | |
168 | dockedItems: [ | |
169 | { | |
170 | dock: 'top', | |
171 | title: gettext("Incoming Mails"), | |
172 | xtype: 'proxmoxRRDChart', | |
173 | fields: ['count_in', 'spamcount_in', 'viruscount_in', 'bounces_in'], | |
174 | fieldTitles: [ | |
175 | gettext('Incoming Mails'), gettext('Spam Mails'), | |
176 | gettext('Virus Mails'), gettext('Bounces')], | |
177 | store: countstore | |
178 | } | |
179 | ] | |
180 | }); | |
181 | ||
182 | var outgrid = Ext.createWidget('pmgMailStatGrid', { | |
183 | dockedItems: [ | |
184 | { | |
185 | dock: 'top', | |
186 | title: gettext("Outgoing Mails"), | |
187 | xtype: 'proxmoxRRDChart', | |
188 | fields: ['count_out', 'viruscount_out', 'bounces_out'], | |
189 | fieldTitles: [ | |
190 | gettext('Outgoing Mails'), | |
191 | gettext('Virus Mails'), gettext('Bounces')], | |
192 | store: countstore | |
193 | } | |
194 | ] | |
195 | }); | |
196 | ||
197 | var infostore = Ext.create('PMG.data.StatStore', { | |
198 | staturl: "/api2/json/statistics/mail", | |
199 | fields: [ 'name', 'value', 'percentage' ], | |
200 | listeners: { | |
201 | load: function(store, records) { | |
202 | var data = me.getGeneralData(records[0].data); | |
203 | totalgrid.store.setData(data); | |
204 | data = me.getInData(records[0].data); | |
205 | ingrid.store.setData(data); | |
206 | data = me.getOutData(records[0].data); | |
207 | outgrid.store.setData(data); | |
208 | } | |
209 | } | |
210 | }); | |
211 | ||
212 | me.items = [ totalgrid, ingrid, outgrid ]; | |
213 | ||
214 | me.callParent(); | |
215 | ||
216 | me.on('destroy', infostore.destroy, infostore); | |
217 | me.on('destroy', countstore.destroy, countstore); | |
218 | } | |
219 | }); |