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