]> git.proxmox.com Git - pmg-gui.git/blame - js/ContactStatistics.js
improve gettext usage
[pmg-gui.git] / js / ContactStatistics.js
CommitLineData
ff735274 1/*global Proxmox*/
de0ebd99
DC
2/*jslint confusion: true*/
3/* filter is a function and object */
575e5e2f
DM
4Ext.define('PMG.ContactDetails', {
5 extend: 'Ext.grid.GridPanel',
6 xtype: 'pmgContactDetails',
7
8 dockedItems: [
9 {
10 dock: 'top',
11 xtype: 'panel',
12 itemId: 'info',
13 bodyPadding: 10,
64fb657f 14 html: gettext('Please select a contact')
575e5e2f
DM
15 }
16 ],
17
18 disableSelection: true,
19
8e346db3
DM
20 plugins: 'gridfilters',
21
575e5e2f
DM
22 setUrl: function(url, title) {
23 var me = this;
24
25 me.store.setUrl(url);
eaf3ebec 26 me.store.setRemoteFilter(url !== undefined);
575e5e2f
DM
27 Proxmox.Utils.setErrorMask(me, false);
28 me.store.reload();
29
30 var infopanel = me.getComponent('info');
31 if (title) {
32 infopanel.update(title);
33 } else {
e9837921 34 infopanel.update(gettext('Please select a contact'));
575e5e2f
DM
35 }
36 },
37
38 store: {
39 type: 'pmgStatStore',
40 autoReload: false,
41 remoteSort: true,
eaf3ebec 42 remoteFilter: false, // enabled dynamically
575e5e2f
DM
43 fields: [
44 'sender', 'virusinfo',
45 { type: 'integer', name: 'bytes' },
46 { type: 'boolean', name: 'blocked' },
47 { type: 'integer', name: 'spamlevel' },
48 { type: 'date', dateFormat: 'timestamp', name: 'time' }
49 ],
50 proxy: {
8e346db3
DM
51 type: 'pmgfilterproxy',
52 filterId: 'x-gridfilter-sender',
575e5e2f
DM
53 sortParam: 'orderby'
54 },
55 sorters: [
56 {
57 property: 'time',
58 direction: 'ASC'
59 }
60 ]
61 },
62
63 columns: [
64 {
65 text: gettext('Sender'),
66 renderer: Ext.htmlEncode,
67 flex: 1,
8e346db3 68 filter: { type: 'string' },
575e5e2f
DM
69 dataIndex: 'sender'
70 },
71 {
72 header: gettext('Size') + ' (KB)',
73 renderer: function(v) { return Ext.Number.toFixed(v/1024, 0); },
74 dataIndex: 'bytes'
75 },
76 {
77 xtype: 'datecolumn',
78 header: gettext('Date'),
79 format: 'Y-m-d',
80 dataIndex: 'time'
81 },
82 {
83 xtype: 'datecolumn',
84 header: gettext('Time'),
bd69f90e 85 format: 'H:i:s',
575e5e2f 86 dataIndex: 'time'
771bd0b9 87 }
575e5e2f
DM
88 ],
89
90 initComponent: function() {
91 var me = this;
92 me.callParent();
93
94 Proxmox.Utils.monStoreErrors(me, me.store, true);
95 }
96});
97
98Ext.define('PMG.ContactList', {
99 extend: 'Ext.grid.GridPanel',
100 alias: 'widget.pmgContactList',
ff8a07c6 101
e9837921
DM
102 title: gettext('Statistics') + ': ' + gettext('Contact') +
103 ' (' + gettext('Receiver') + ', ' + gettext('Outgoing') +')',
ff8a07c6 104
575e5e2f
DM
105 multiColumnSort: true,
106 plugins: 'gridfilters',
107
64fb657f 108 emptyText: gettext('No data in database'),
575e5e2f
DM
109 viewConfig: {
110 deferEmptyText: false
111 },
112
ff8a07c6
DM
113 tbar: [ { xtype: 'pmgStatTimeSelector' } ],
114
575e5e2f
DM
115 store: {
116 type: 'pmgStatStore',
117 staturl: '/api2/json/statistics/contact',
118 remoteSort: true,
119 remoteFilter: true,
120 fields: [
121 'contact',
122 { type: 'integer', name: 'count' },
123 { type: 'integer', name: 'viruscount' },
771bd0b9 124 { type: 'integer', name: 'bytes' }
575e5e2f
DM
125 ],
126 proxy: {
127 type: 'pmgfilterproxy',
128 sortParam: 'orderby',
129 filterId: 'x-gridfilter-contact'
130 },
131 sorters: [
132 {
133 property: 'count',
134 direction: 'DESC'
135 },
136 {
137 property: 'bytes',
138 direction: 'DESC'
139 },
140 {
141 property: 'contact',
142 direction: 'ASC'
143 }
144 ]
145 },
ff8a07c6 146
575e5e2f
DM
147 columns: [
148 {
149 text: gettext('Contact'),
150 flex: 1,
151 renderer: Ext.htmlEncode,
152 dataIndex: 'contact',
153 filter: {
154 type: 'string',
155 itemDefaults: {
156 // any Ext.form.field.Text configs accepted
157 }
158 }
159 },
160 {
161 text: gettext('Count'),
162 columns: [
163 {
164 text: gettext('Mail'),
165 dataIndex: 'count'
166 },
167 {
168 header: gettext('Virus'),
169 dataIndex: 'viruscount'
170 }
171 ]
172 },
173 {
174 text: gettext('Size') + ' (KB)',
175 dataIndex: 'bytes',
176 renderer: function(v) {
177 return Ext.Number.toFixed(v/1024, 0);
178 }
179 }
180 ],
ff8a07c6 181
575e5e2f
DM
182 initComponent: function() {
183 var me = this;
184 me.callParent();
185
186 Proxmox.Utils.monStoreErrors(me, me.store, true);
187 }
ff8a07c6
DM
188});
189
575e5e2f
DM
190Ext.define('PMG.ContactStatistics', {
191 extend: 'Ext.panel.Panel',
192 xtype: 'pmgContactStatistics',
193
194 layout: 'border',
195 border: false,
196 defaults: {
771bd0b9 197 border: false
575e5e2f
DM
198 },
199
200 controller: {
201 xclass: 'Ext.app.ViewController',
ff8a07c6 202
575e5e2f
DM
203 selectionChange: function(grid, selected, eOpts) {
204 var details = this.lookupReference('details');
205 if (selected.length > 0) {
206 var contact = selected[0].data.contact;
207 var url = "/api2/json/statistics/contact/" +
208 encodeURIComponent(contact);
209 details.setUrl(url, '<b>' + gettext('Contact') + ':</b> ' + Ext.htmlEncode(contact));
210 } else {
211 details.setUrl();
212 }
213 }
214 },
215
216 items: [
217 {
218 xtype: 'pmgContactList',
219 multiColumnSort: true,
220 region: 'center',
221 layout: 'fit',
222 flex: 1,
223
771bd0b9 224 listeners: { selectionchange: 'selectionChange' }
575e5e2f
DM
225 },
226 {
227 xtype: 'pmgContactDetails',
228 region: 'east',
229 reference: 'details',
230 split: true,
231 flex: 1
232 }
233 ]
234});