]>
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, | |
e9837921 | 11 | html: gettext('Please select a contact.') |
575e5e2f DM |
12 | } |
13 | ], | |
14 | ||
15 | disableSelection: true, | |
16 | ||
8e346db3 DM |
17 | plugins: 'gridfilters', |
18 | ||
575e5e2f DM |
19 | setUrl: function(url, title) { |
20 | var me = this; | |
21 | ||
22 | me.store.setUrl(url); | |
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' }, | |
45 | { type: 'date', dateFormat: 'timestamp', name: 'time' } | |
46 | ], | |
47 | proxy: { | |
8e346db3 DM |
48 | type: 'pmgfilterproxy', |
49 | filterId: 'x-gridfilter-sender', | |
575e5e2f DM |
50 | sortParam: 'orderby' |
51 | }, | |
52 | sorters: [ | |
53 | { | |
54 | property: 'time', | |
55 | direction: 'ASC' | |
56 | } | |
57 | ] | |
58 | }, | |
59 | ||
60 | columns: [ | |
61 | { | |
62 | text: gettext('Sender'), | |
63 | renderer: Ext.htmlEncode, | |
64 | flex: 1, | |
8e346db3 | 65 | filter: { type: 'string' }, |
575e5e2f DM |
66 | dataIndex: 'sender' |
67 | }, | |
68 | { | |
69 | header: gettext('Size') + ' (KB)', | |
70 | renderer: function(v) { return Ext.Number.toFixed(v/1024, 0); }, | |
71 | dataIndex: 'bytes' | |
72 | }, | |
73 | { | |
74 | xtype: 'datecolumn', | |
75 | header: gettext('Date'), | |
76 | format: 'Y-m-d', | |
77 | dataIndex: 'time' | |
78 | }, | |
79 | { | |
80 | xtype: 'datecolumn', | |
81 | header: gettext('Time'), | |
bd69f90e | 82 | format: 'H:i:s', |
575e5e2f DM |
83 | dataIndex: 'time' |
84 | }, | |
85 | ], | |
86 | ||
87 | initComponent: function() { | |
88 | var me = this; | |
89 | me.callParent(); | |
90 | ||
91 | Proxmox.Utils.monStoreErrors(me, me.store, true); | |
92 | } | |
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 | ||
105 | emptyText: gettext('No data in database.'), | |
106 | viewConfig: { | |
107 | deferEmptyText: false | |
108 | }, | |
109 | ||
ff8a07c6 DM |
110 | tbar: [ { xtype: 'pmgStatTimeSelector' } ], |
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' }, | |
121 | { type: 'integer', name: 'bytes' }, | |
122 | ], | |
123 | proxy: { | |
124 | type: 'pmgfilterproxy', | |
125 | sortParam: 'orderby', | |
126 | filterId: 'x-gridfilter-contact' | |
127 | }, | |
128 | sorters: [ | |
129 | { | |
130 | property: 'count', | |
131 | direction: 'DESC' | |
132 | }, | |
133 | { | |
134 | property: 'bytes', | |
135 | direction: 'DESC' | |
136 | }, | |
137 | { | |
138 | property: 'contact', | |
139 | direction: 'ASC' | |
140 | } | |
141 | ] | |
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 | |
154 | } | |
155 | } | |
156 | }, | |
157 | { | |
158 | text: gettext('Count'), | |
159 | columns: [ | |
160 | { | |
161 | text: gettext('Mail'), | |
162 | dataIndex: 'count' | |
163 | }, | |
164 | { | |
165 | header: gettext('Virus'), | |
166 | dataIndex: 'viruscount' | |
167 | } | |
168 | ] | |
169 | }, | |
170 | { | |
171 | text: gettext('Size') + ' (KB)', | |
172 | dataIndex: 'bytes', | |
173 | renderer: function(v) { | |
174 | return Ext.Number.toFixed(v/1024, 0); | |
175 | } | |
176 | } | |
177 | ], | |
ff8a07c6 | 178 | |
575e5e2f DM |
179 | initComponent: function() { |
180 | var me = this; | |
181 | me.callParent(); | |
182 | ||
183 | Proxmox.Utils.monStoreErrors(me, me.store, true); | |
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: { | |
194 | border: false, | |
195 | }, | |
196 | ||
197 | controller: { | |
198 | xclass: 'Ext.app.ViewController', | |
ff8a07c6 | 199 | |
575e5e2f DM |
200 | selectionChange: function(grid, selected, eOpts) { |
201 | var details = this.lookupReference('details'); | |
202 | if (selected.length > 0) { | |
203 | var contact = selected[0].data.contact; | |
204 | var url = "/api2/json/statistics/contact/" + | |
205 | encodeURIComponent(contact); | |
206 | details.setUrl(url, '<b>' + gettext('Contact') + ':</b> ' + Ext.htmlEncode(contact)); | |
207 | } else { | |
208 | details.setUrl(); | |
209 | } | |
210 | } | |
211 | }, | |
212 | ||
213 | items: [ | |
214 | { | |
215 | xtype: 'pmgContactList', | |
216 | multiColumnSort: true, | |
217 | region: 'center', | |
218 | layout: 'fit', | |
219 | flex: 1, | |
220 | ||
221 | listeners: { selectionchange: 'selectionChange' }, | |
222 | }, | |
223 | { | |
224 | xtype: 'pmgContactDetails', | |
225 | region: 'east', | |
226 | reference: 'details', | |
227 | split: true, | |
228 | flex: 1 | |
229 | } | |
230 | ] | |
231 | }); |