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