]>
Commit | Line | Data |
---|---|---|
73360b11 DM |
1 | Ext.define('PMG.DomainStatistics', { |
2 | extend: 'Ext.panel.Panel', | |
3 | xtype: 'pmgDomainStatistics', | |
4 | ||
3755c9e0 | 5 | title: gettext('Statistics') + ': ' + gettext('Domain'), |
73360b11 DM |
6 | |
7 | tbar: [ { xtype: 'pmgStatTimeSelector' } ], | |
8 | ||
9 | layout: 'fit', | |
50531ef9 | 10 | border: false, |
73360b11 DM |
11 | |
12 | initComponent: function() { | |
13 | var me = this; | |
14 | ||
15 | var fields = [ | |
16 | 'domain', | |
17 | { type: 'integer', name: 'count_in' }, | |
18 | { type: 'integer', name: 'count_out' }, | |
19 | { type: 'integer', name: 'spamcount_in' }, | |
20 | { type: 'integer', name: 'spamcount_out' }, | |
21 | { type: 'integer', name: 'viruscount_in' }, | |
22 | { type: 'integer', name: 'viruscount_out' }, | |
23 | { type: 'number', name: 'mbytes_in' }, | |
24 | { type: 'number', name: 'mbytes_out' } | |
25 | ]; | |
26 | ||
27 | var store = Ext.create('PMG.data.StatStore', { | |
28 | staturl: '/api2/json/statistics/domains', | |
29 | fields: fields | |
30 | }); | |
31 | ||
32 | var store_in = Ext.create('Ext.data.ArrayStore', { | |
33 | fields: fields, | |
34 | filters: [ function(item) { return item.data.count_in > 0; } ] | |
35 | }); | |
36 | ||
37 | var store_out = Ext.create('Ext.data.ArrayStore', { | |
38 | fields: fields, | |
39 | filters: [ function(item) { return item.data.count_out > 0; } ] | |
40 | }); | |
41 | ||
42 | store.on('load', function(s, records, successful) { | |
43 | if (!successful) { | |
44 | store_in.setData([]); | |
45 | store_out.setData([]); | |
46 | } else { | |
47 | store_in.setData(records); | |
48 | store_out.setData(records); | |
49 | } | |
50 | }) | |
51 | ||
52 | var render_domain = function(v) { | |
96fba078 | 53 | return v === '' ? '--- EMPTY ADDRESS ---' : Ext.htmlEncode(v); |
73360b11 DM |
54 | }; |
55 | ||
56 | me.items = { | |
57 | xtype: 'tabpanel', | |
58 | border: false, | |
59 | items: [ | |
60 | { | |
61 | xtype: 'grid', | |
62 | title: gettext('Incoming'), | |
63 | border: false, | |
64 | disableSelection: true, | |
65 | store: store_in, | |
66 | emptyText: gettext('No data in database.'), | |
67 | viewConfig: { | |
68 | deferEmptyText: false | |
69 | }, | |
70 | columns: [ | |
71 | { | |
72 | text: gettext('Domain')+ ' (' + | |
73 | gettext('Receiver') + ')', | |
74 | flex: 1, | |
75 | renderer: render_domain, | |
76 | dataIndex: 'domain' | |
77 | }, | |
78 | { | |
79 | text: gettext('Traffic') + ' (MB)', | |
80 | dataIndex: 'mbytes_in', | |
81 | renderer: function(v) { | |
82 | return Ext.Number.toFixed(v, 2); | |
83 | } | |
84 | }, | |
85 | { | |
86 | text: gettext('Count'), | |
87 | columns: [ | |
88 | { | |
89 | text: gettext('Mail'), | |
90 | dataIndex: 'count_in' | |
91 | }, | |
92 | { | |
93 | header: gettext('Virus'), | |
94 | dataIndex: 'viruscount_in' | |
95 | }, | |
96 | { | |
97 | header: gettext('Spam'), | |
98 | dataIndex: 'spamcount_in' | |
99 | } | |
100 | ] | |
101 | } | |
102 | ] | |
103 | }, | |
104 | { | |
105 | xtype: 'grid', | |
106 | title: gettext('Outgoing'), | |
107 | border: false, | |
108 | disableSelection: true, | |
109 | store: store_out, | |
110 | emptyText: gettext('No data in database.'), | |
111 | viewConfig: { | |
112 | deferEmptyText: false | |
113 | }, | |
114 | columns: [ | |
115 | { | |
116 | text: gettext('Domain')+ ' (' + | |
117 | gettext('Receiver') + ')', | |
118 | flex: 1, | |
119 | renderer: render_domain, | |
120 | dataIndex: 'domain' | |
121 | }, | |
122 | { | |
123 | text: gettext('Traffic') + ' (MB)', | |
124 | dataIndex: 'mbytes_out', | |
125 | renderer: function(v) { | |
126 | return Ext.Number.toFixed(v, 2); | |
127 | } | |
128 | }, | |
129 | { | |
130 | text: gettext('Count'), | |
131 | columns: [ | |
132 | { | |
133 | text: gettext('Mail'), | |
134 | dataIndex: 'count_out' | |
135 | }, | |
136 | { | |
137 | header: gettext('Virus'), | |
138 | dataIndex: 'viruscount_out' | |
139 | } | |
140 | ] | |
141 | } | |
142 | ] | |
143 | } | |
144 | ] | |
145 | }; | |
146 | ||
147 | me.callParent(); | |
148 | ||
149 | Proxmox.Utils.monStoreErrors(me, store); | |
150 | ||
151 | me.on('destroy', store.destroy, store); | |
152 | } | |
153 | }); |