]>
Commit | Line | Data |
---|---|---|
fe81f069 DM |
1 | Ext.ns('PMG'); |
2 | ||
fe81f069 DM |
3 | console.log("Starting PMG Manager"); |
4 | ||
fe81f069 | 5 | |
2c7b542d DM |
6 | Ext.define('PMG.Utils', { |
7 | singleton: true, | |
ad834b6f | 8 | |
fe81f069 DM |
9 | // this singleton contains miscellaneous utilities |
10 | ||
f9b851e8 DM |
11 | senderText: gettext('Sender'), |
12 | receiverText: gettext('Receiver'), | |
ad88af09 | 13 | scoreText: gettext('Score'), |
012f0f49 | 14 | |
7818f0a3 DM |
15 | user_role_text: { |
16 | root: gettext('Superuser'), | |
17 | admin: gettext('Administrator'), | |
751d131c | 18 | helpdesk: gettext('Help Desk'), |
7818f0a3 | 19 | qmanager: gettext('Quarantine Manager'), |
8153da61 | 20 | audit: gettext('Auditor'), |
7818f0a3 DM |
21 | }, |
22 | ||
23 | format_user_role: function(role) { | |
24 | return PMG.Utils.user_role_text[role] || role; | |
25 | }, | |
26 | ||
c790d2ab DM |
27 | oclass_text: { |
28 | who: gettext('Who Objects'), | |
29 | what: gettext('What Objects'), | |
30 | when: gettext('When Objects'), | |
076d6a72 DC |
31 | action: gettext('Action Objects'), |
32 | from: gettext('From'), | |
8153da61 | 33 | to: gettext('To'), |
076d6a72 DC |
34 | }, |
35 | ||
36 | oclass_icon: { | |
37 | who: '<span class="fa fa-fw fa-user-circle"></span> ', | |
38 | what: '<span class="fa fa-fw fa-cube"></span> ', | |
39 | when: '<span class="fa fa-fw fa-clock-o"></span> ', | |
40 | action: '<span class="fa fa-fw fa-flag"></span> ', | |
41 | from: '<span class="fa fa-fw fa-user-circle"></span> ', | |
8153da61 | 42 | to: '<span class="fa fa-fw fa-user-circle"></span> ', |
076d6a72 DC |
43 | }, |
44 | ||
cf248533 DM |
45 | mail_status_map: { |
46 | 2: 'delivered', | |
47 | 4: 'deferred', | |
48 | 5: 'bounced', | |
49 | N: 'rejected', | |
50 | G: 'greylisted', | |
51 | A: 'accepted', | |
52 | B: 'blocked', | |
8153da61 | 53 | Q: 'quarantine', |
cf248533 DM |
54 | }, |
55 | ||
20d8d037 DC |
56 | icon_status_map_class: { |
57 | 2: 'check-circle', | |
58 | 4: 'clock-o', | |
59 | 5: 'mail-reply', | |
60 | N: 'times-circle', | |
61 | G: 'list', | |
62 | A: 'check', | |
63 | B: 'ban', | |
8153da61 | 64 | Q: 'cube', |
20d8d037 DC |
65 | }, |
66 | ||
67 | icon_status_map_color: { | |
68 | 2: 'green', | |
69 | 5: 'gray', | |
70 | A: 'green', | |
8153da61 | 71 | B: 'red', |
c4ff49f7 DC |
72 | }, |
73 | ||
74 | format_status_icon: function(status) { | |
20d8d037 DC |
75 | var icon = PMG.Utils.icon_status_map_class[status] || 'question-circle'; |
76 | var color = PMG.Utils.icon_status_map_color[status] || ''; | |
77 | return '<i class="fa fa-' + icon + ' ' + color + '"></i> '; | |
c4ff49f7 DC |
78 | }, |
79 | ||
076d6a72 DC |
80 | format_oclass: function(oclass) { |
81 | var icon = PMG.Utils.oclass_icon[oclass] || ''; | |
82 | var text = PMG.Utils.oclass_text[oclass] || oclass; | |
83 | return icon + text; | |
c790d2ab | 84 | }, |
ad834b6f DM |
85 | |
86 | rule_direction_text: { | |
87 | 0: gettext('In'), | |
88 | 1: gettext('Out'), | |
8153da61 | 89 | 2: gettext('In & Out'), |
ad834b6f DM |
90 | }, |
91 | ||
4b7e5c48 | 92 | rule_direction_icon: { |
2b97521b DC |
93 | 0: '<span class="fa fa-fw fa-long-arrow-left"></span> ', |
94 | 1: '<span class="fa fa-fw fa-long-arrow-right"></span> ', | |
8153da61 | 95 | 2: '<span class="fa fa-fw fa-exchange"></span> ', |
4b7e5c48 DC |
96 | }, |
97 | ||
ad834b6f | 98 | format_rule_direction: function(dir) { |
4b7e5c48 DC |
99 | var icon = PMG.Utils.rule_direction_icon[dir] || ''; |
100 | var text = PMG.Utils.rule_direction_text[dir] || dir; | |
101 | return icon + text; | |
ad834b6f DM |
102 | }, |
103 | ||
012f0f49 DM |
104 | format_otype: function(otype) { |
105 | var editor = PMG.Utils.object_editors[otype]; | |
ea4f2a79 | 106 | var iconCls = 'fa fa-question-circle'; |
012f0f49 | 107 | if (editor) { |
ea4f2a79 DC |
108 | var icon = '<span class="fa-fw ' + (editor.iconCls || iconCls) + '"></span> '; |
109 | return icon + editor.subject; | |
012f0f49 | 110 | } |
ea4f2a79 DC |
111 | |
112 | return '<span class="fa-fw ' + iconCls + '"></span> unknown'; | |
f6b1b3bf DM |
113 | }, |
114 | ||
115 | format_ldap_protocol: function(p) { | |
cc6b80b6 DM |
116 | if (p === undefined) { return 'LDAP'; } |
117 | if (p === 'ldap') { return 'LDAP'; } | |
118 | if (p === 'ldaps') { return 'LDAPS'; } | |
3600c3c7 | 119 | if (p === 'ldap+starttls') { return 'LDAP+STARTTLS'; } |
f6b1b3bf | 120 | return 'unknown'; |
012f0f49 DM |
121 | }, |
122 | ||
b79fbba8 | 123 | convert_field_to_per_min: function(value, record) { |
8153da61 | 124 | return value/(record.data.timespan/60); |
b79fbba8 DC |
125 | }, |
126 | ||
012f0f49 DM |
127 | object_editors: { |
128 | 1000: { | |
573a6e8b | 129 | onlineHelp: 'pmg_mailfilter_regex', |
ea4f2a79 | 130 | iconCls: 'fa fa-filter', |
5f3ec152 | 131 | xtype: 'proxmoxWindowEdit', |
012f0f49 DM |
132 | subdir: 'regex', |
133 | subject: gettext("Regular Expression"), | |
f7be608f | 134 | width: 400, |
012f0f49 DM |
135 | items: [ |
136 | { | |
137 | xtype: 'textfield', | |
138 | name: 'regex', | |
f7be608f | 139 | labelWidth: 150, |
6994550a | 140 | reference: 'regex', |
8153da61 | 141 | fieldLabel: gettext("Regular Expression"), |
6994550a DC |
142 | }, |
143 | { | |
144 | labelWidth: 150, | |
145 | fieldLabel: gettext('Test String'), | |
146 | xtype: 'pmgRegexTester', | |
4eab05c2 | 147 | wholeMatch: true, |
8153da61 TL |
148 | regexFieldReference: 'regex', |
149 | }, | |
150 | ], | |
012f0f49 | 151 | }, |
5f3ec152 | 152 | 1005: { |
573a6e8b | 153 | onlineHelp: 'pmgconfig_ldap', |
ea4f2a79 | 154 | iconCls: 'fa fa-users', |
5f3ec152 DM |
155 | xtype: 'pmgLDAPGroupEditor', |
156 | subdir: 'ldap', | |
8153da61 | 157 | subject: gettext("LDAP Group"), |
5f3ec152 | 158 | }, |
6c137003 | 159 | 1006: { |
573a6e8b | 160 | onlineHelp: 'pmgconfig_ldap', |
ea4f2a79 | 161 | iconCls: 'fa fa-user', |
6c137003 DM |
162 | xtype: 'pmgLDAPUserEditor', |
163 | subdir: 'ldapuser', | |
8153da61 | 164 | subject: gettext("LDAP User"), |
6c137003 | 165 | }, |
012f0f49 | 166 | 1009: { |
573a6e8b | 167 | onlineHelp: 'pmg_mailfilter_regex', |
ea4f2a79 | 168 | iconCls: 'fa fa-filter', |
5f3ec152 | 169 | xtype: 'proxmoxWindowEdit', |
012f0f49 DM |
170 | subdir: 'receiver_regex', |
171 | subject: gettext("Regular Expression"), | |
f7be608f DM |
172 | receivertest: true, |
173 | width: 400, | |
012f0f49 DM |
174 | items: [ |
175 | { | |
176 | xtype: 'textfield', | |
177 | name: 'regex', | |
f7be608f | 178 | labelWidth: 150, |
8153da61 TL |
179 | fieldLabel: gettext("Regular Expression"), |
180 | }, | |
181 | ], | |
012f0f49 DM |
182 | }, |
183 | 1001: { | |
573a6e8b | 184 | onlineHelp: 'pmg_mailfilter_who', |
ea4f2a79 | 185 | iconCls: 'fa fa-envelope-o', |
5f3ec152 | 186 | xtype: 'proxmoxWindowEdit', |
012f0f49 | 187 | subdir: 'email', |
64fb657f | 188 | subject: gettext("E-Mail"), |
f7be608f | 189 | width: 400, |
012f0f49 DM |
190 | items: [ |
191 | { | |
192 | xtype: 'textfield', | |
193 | name: 'email', | |
8153da61 TL |
194 | fieldLabel: gettext("E-Mail"), |
195 | }, | |
196 | ], | |
012f0f49 DM |
197 | }, |
198 | 1007: { | |
573a6e8b | 199 | onlineHelp: 'pmg_mailfilter_who', |
ea4f2a79 | 200 | iconCls: 'fa fa-envelope-o', |
5f3ec152 | 201 | xtype: 'proxmoxWindowEdit', |
012f0f49 | 202 | subdir: 'receiver', |
64fb657f | 203 | subject: gettext("E-Mail"), |
f7be608f DM |
204 | receivertest: true, |
205 | width: 400, | |
012f0f49 DM |
206 | items: [ |
207 | { | |
208 | xtype: 'textfield', | |
209 | name: 'email', | |
8153da61 TL |
210 | fieldLabel: gettext("E-Mail"), |
211 | }, | |
212 | ], | |
012f0f49 DM |
213 | }, |
214 | 1002: { | |
573a6e8b | 215 | onlineHelp: 'pmg_mailfilter_who', |
ea4f2a79 | 216 | iconCls: 'fa fa-globe', |
5f3ec152 | 217 | xtype: 'proxmoxWindowEdit', |
012f0f49 DM |
218 | subdir: 'domain', |
219 | subject: gettext("Domain"), | |
f7be608f | 220 | width: 400, |
012f0f49 DM |
221 | items: [ |
222 | { | |
223 | xtype: 'textfield', | |
224 | name: 'domain', | |
8153da61 TL |
225 | fieldLabel: gettext("Domain"), |
226 | }, | |
227 | ], | |
012f0f49 DM |
228 | }, |
229 | 1008: { | |
573a6e8b | 230 | onlineHelp: 'pmg_mailfilter_who', |
ea4f2a79 | 231 | iconCls: 'fa fa-globe', |
5f3ec152 | 232 | xtype: 'proxmoxWindowEdit', |
012f0f49 DM |
233 | subdir: 'receiver_domain', |
234 | subject: gettext("Domain"), | |
f7be608f DM |
235 | receivertest: true, |
236 | width: 400, | |
012f0f49 DM |
237 | items: [ |
238 | { | |
239 | xtype: 'textfield', | |
240 | name: 'domain', | |
8153da61 TL |
241 | fieldLabel: gettext("Domain"), |
242 | }, | |
243 | ], | |
012f0f49 DM |
244 | }, |
245 | 1003: { | |
573a6e8b | 246 | onlineHelp: 'pmg_mailfilter_who', |
ea4f2a79 | 247 | iconCls: 'fa fa-globe', |
5f3ec152 | 248 | xtype: 'proxmoxWindowEdit', |
012f0f49 DM |
249 | subdir: 'ip', |
250 | subject: gettext("IP Address"), | |
f7be608f | 251 | width: 400, |
012f0f49 DM |
252 | items: [ |
253 | { | |
254 | xtype: 'textfield', | |
255 | name: 'ip', | |
8153da61 TL |
256 | fieldLabel: gettext("IP Address"), |
257 | }, | |
258 | ], | |
012f0f49 DM |
259 | }, |
260 | 1004: { | |
573a6e8b | 261 | onlineHelp: 'pmg_mailfilter_who', |
ea4f2a79 | 262 | iconCls: 'fa fa-globe', |
5f3ec152 | 263 | xtype: 'proxmoxWindowEdit', |
012f0f49 DM |
264 | subdir: 'network', |
265 | subject: gettext("IP Network"), | |
f7be608f | 266 | width: 400, |
012f0f49 DM |
267 | items: [ |
268 | { | |
269 | xtype: 'textfield', | |
270 | name: 'cidr', | |
8153da61 TL |
271 | fieldLabel: gettext("IP Network"), |
272 | }, | |
273 | ], | |
b4eee4f7 DM |
274 | }, |
275 | 2000: { | |
573a6e8b | 276 | onlineHelp: 'pmg_mailfilter_when', |
ea4f2a79 | 277 | iconCls: 'fa fa-clock-o', |
5f3ec152 | 278 | xtype: 'proxmoxWindowEdit', |
b4eee4f7 DM |
279 | subdir: 'timeframe', |
280 | subject: gettext("TimeFrame"), | |
281 | items: [ | |
282 | { | |
283 | xtype: 'timefield', | |
284 | name: 'start', | |
285 | format: 'H:i', | |
8153da61 | 286 | fieldLabel: gettext("Start Time"), |
b4eee4f7 DM |
287 | }, |
288 | { | |
289 | xtype: 'timefield', | |
290 | name: 'end', | |
291 | format: 'H:i', | |
8153da61 TL |
292 | fieldLabel: gettext("End Time"), |
293 | }, | |
294 | ], | |
f5de8682 | 295 | }, |
bed64e74 | 296 | 3000: { |
573a6e8b | 297 | onlineHelp: 'pmg_mailfilter_what', |
ea4f2a79 | 298 | iconCls: 'fa fa-bullhorn', |
bed64e74 DC |
299 | xtype: 'proxmoxWindowEdit', |
300 | subdir: 'spamfilter', | |
301 | subject: gettext('Spam Filter'), | |
302 | items: [ | |
303 | { | |
304 | xtype: 'proxmoxintegerfield', | |
305 | name: 'spamlevel', | |
306 | allowBlank: false, | |
307 | minValue: 0, | |
8153da61 TL |
308 | fieldLabel: gettext('Level'), |
309 | }, | |
310 | ], | |
bed64e74 | 311 | }, |
8ddd9c44 | 312 | 3001: { |
573a6e8b | 313 | onlineHelp: 'pmg_mailfilter_what', |
ea4f2a79 | 314 | iconCls: 'fa fa-bug', |
8ddd9c44 DC |
315 | xtype: 'proxmoxWindowEdit', |
316 | subdir: 'virusfilter', | |
317 | subject: gettext('Virus Filter'), | |
318 | uneditable: true, | |
319 | // there are no parameters to give, so we simply submit it | |
320 | listeners: { | |
321 | show: function(win) { | |
322 | win.submit(); | |
8153da61 TL |
323 | }, |
324 | }, | |
8ddd9c44 | 325 | }, |
3a9b95a7 | 326 | 3002: { |
573a6e8b | 327 | onlineHelp: 'pmg_mailfilter_regex', |
ea4f2a79 | 328 | iconCls: 'fa fa-code', |
3a9b95a7 DC |
329 | xtype: 'proxmoxWindowEdit', |
330 | subdir: 'matchfield', | |
331 | subject: gettext('Match Field'), | |
50fa6520 | 332 | width: 400, |
3a9b95a7 DC |
333 | items: [ |
334 | { | |
335 | xtype: 'textfield', | |
336 | name: 'field', | |
50fa6520 | 337 | labelWidth: 150, |
3a9b95a7 | 338 | allowBlank: false, |
8153da61 | 339 | fieldLabel: gettext('Field'), |
3a9b95a7 DC |
340 | }, |
341 | { | |
342 | xtype: 'textfield', | |
50fa6520 | 343 | reference: 'value', |
3a9b95a7 | 344 | name: 'value', |
50fa6520 | 345 | labelWidth: 150, |
3a9b95a7 | 346 | allowBlank: false, |
8153da61 | 347 | fieldLabel: gettext('Value'), |
3a9b95a7 | 348 | }, |
50fa6520 DC |
349 | { |
350 | labelWidth: 150, | |
351 | fieldLabel: gettext('Test String'), | |
352 | xtype: 'pmgRegexTester', | |
8153da61 TL |
353 | regexFieldReference: 'value', |
354 | }, | |
355 | ], | |
3a9b95a7 DC |
356 | }, |
357 | 3003: { | |
573a6e8b | 358 | onlineHelp: 'pmg_mailfilter_what', |
ea4f2a79 | 359 | iconCls: 'fa fa-file-image-o', |
3a9b95a7 DC |
360 | xtype: 'proxmoxWindowEdit', |
361 | subdir: 'contenttype', | |
362 | width: 400, | |
3fb5067f | 363 | subject: gettext('Content Type Filter'), |
3a9b95a7 DC |
364 | items: [ |
365 | { | |
366 | xtype: 'combobox', | |
367 | displayField: 'text', | |
368 | labelWidth: 150, | |
369 | valueField: 'mimetype', | |
370 | name: 'contenttype', | |
371 | editable: true, | |
372 | queryMode: 'local', | |
373 | store: { | |
374 | autoLoad: true, | |
375 | proxy: { | |
376 | type: 'proxmox', | |
8153da61 TL |
377 | url: '/api2/json/config/mimetypes', |
378 | }, | |
3a9b95a7 DC |
379 | }, |
380 | fieldLabel: gettext('Content Type'), | |
381 | anyMatch: true, | |
382 | matchFieldWidth: false, | |
383 | listeners: { | |
384 | change: function(cb, value) { | |
385 | var me = this; | |
386 | me.up().down('displayfield').setValue(value); | |
8153da61 TL |
387 | }, |
388 | }, | |
3a9b95a7 DC |
389 | }, |
390 | { | |
391 | xtype: 'displayfield', | |
392 | fieldLabel: gettext('Value'), | |
393 | labelWidth: 150, | |
394 | allowBlank: false, | |
8153da61 TL |
395 | reset: Ext.emptyFn, |
396 | }, | |
397 | ], | |
3a9b95a7 | 398 | }, |
6af39772 | 399 | 3004: { |
573a6e8b | 400 | onlineHelp: 'pmg_mailfilter_regex', |
ea4f2a79 | 401 | iconCls: 'fa fa-file-o', |
6af39772 DC |
402 | xtype: 'proxmoxWindowEdit', |
403 | subdir: 'filenamefilter', | |
404 | width: 400, | |
405 | subject: gettext('Match Filename'), | |
406 | items: [ | |
407 | { | |
408 | xtype: 'textfield', | |
409 | name: 'filename', | |
410 | reference: 'filename', | |
411 | fieldLabel: gettext('Filename'), | |
412 | labelWidth: 150, | |
8153da61 | 413 | allowBlank: false, |
6af39772 DC |
414 | }, |
415 | { | |
416 | labelWidth: 150, | |
417 | fieldLabel: gettext('Test String'), | |
418 | wholeMatch: true, | |
419 | xtype: 'pmgRegexTester', | |
8153da61 TL |
420 | regexFieldReference: 'filename', |
421 | }, | |
422 | ], | |
6af39772 | 423 | }, |
e234e99d | 424 | 3005: { |
573a6e8b | 425 | onlineHelp: 'pmg_mailfilter_what', |
ea4f2a79 | 426 | iconCls: 'fa fa-file-archive-o', |
e234e99d DC |
427 | xtype: 'proxmoxWindowEdit', |
428 | subdir: 'archivefilter', | |
429 | width: 400, | |
430 | subject: gettext('Archive Filter'), | |
431 | items: [ | |
432 | { | |
433 | xtype: 'combobox', | |
434 | displayField: 'text', | |
435 | labelWidth: 150, | |
436 | valueField: 'mimetype', | |
437 | name: 'contenttype', | |
438 | editable: true, | |
439 | queryMode: 'local', | |
440 | store: { | |
441 | autoLoad: true, | |
442 | proxy: { | |
443 | type: 'proxmox', | |
8153da61 TL |
444 | url: '/api2/json/config/mimetypes', |
445 | }, | |
e234e99d DC |
446 | }, |
447 | fieldLabel: gettext('Content Type'), | |
448 | anyMatch: true, | |
449 | matchFieldWidth: false, | |
450 | listeners: { | |
451 | change: function(cb, value) { | |
452 | var me = this; | |
453 | me.up().down('displayfield').setValue(value); | |
8153da61 TL |
454 | }, |
455 | }, | |
e234e99d DC |
456 | }, |
457 | { | |
458 | xtype: 'displayfield', | |
459 | fieldLabel: gettext('Value'), | |
460 | labelWidth: 150, | |
461 | allowBlank: false, | |
8153da61 TL |
462 | reset: Ext.emptyFn, |
463 | }, | |
464 | ], | |
e234e99d | 465 | }, |
74468b03 DC |
466 | 3006: { |
467 | onlineHelp: 'pmg_mailfilter_regex', | |
468 | iconCls: 'fa fa-file-archive-o', | |
469 | xtype: 'proxmoxWindowEdit', | |
470 | subdir: 'archivefilenamefilter', | |
471 | width: 400, | |
472 | subject: gettext('Match Archive Filename'), | |
473 | items: [ | |
474 | { | |
475 | xtype: 'textfield', | |
476 | name: 'filename', | |
477 | reference: 'filename', | |
478 | fieldLabel: gettext('Filename'), | |
479 | labelWidth: 150, | |
8153da61 | 480 | allowBlank: false, |
74468b03 DC |
481 | }, |
482 | { | |
483 | labelWidth: 150, | |
484 | fieldLabel: gettext('Test String'), | |
485 | wholeMatch: true, | |
486 | xtype: 'pmgRegexTester', | |
8153da61 TL |
487 | regexFieldReference: 'filename', |
488 | }, | |
489 | ], | |
74468b03 | 490 | }, |
628eccdb | 491 | 4002: { |
573a6e8b | 492 | onlineHelp: 'pmg_mailfilter_action', |
628eccdb DC |
493 | xtype: 'proxmoxWindowEdit', |
494 | subdir: 'notification', | |
495 | subject: gettext('Notification'), | |
496 | width: 400, | |
497 | items: [ | |
498 | { | |
499 | xtype: 'textfield', | |
500 | name: 'name', | |
501 | allowBlank: false, | |
8153da61 | 502 | fieldLabel: gettext('Name'), |
628eccdb DC |
503 | }, |
504 | { | |
505 | xtype: 'textareafield', | |
506 | name: 'info', | |
8153da61 | 507 | fieldLabel: gettext("Comment"), |
628eccdb DC |
508 | }, |
509 | { | |
510 | xtype: 'textfield', | |
511 | name: 'to', | |
512 | allowBlank: false, | |
513 | value: '__ADMIN__', | |
8153da61 | 514 | fieldLabel: gettext('Receiver'), |
628eccdb DC |
515 | }, |
516 | { | |
517 | xtype: 'textfield', | |
518 | name: 'subject', | |
519 | allowBlank: false, | |
520 | value: 'Notification: __SUBJECT__', | |
8153da61 | 521 | fieldLabel: gettext('Subject'), |
628eccdb DC |
522 | }, |
523 | { | |
524 | xtype: 'textarea', | |
525 | name: 'body', | |
526 | allowBlank: false, | |
527 | grow: true, | |
528 | growMax: 250, | |
529 | value: | |
530 | "Proxmox Notifcation:\n\n" + | |
531 | "Sender: __SENDER__\n" + | |
532 | "Receiver: __RECEIVERS__\n" + | |
533 | "Targets: __TARGETS__\n\n" + | |
534 | "Subject: __SUBJECT__\n\n" + | |
535 | "Matching Rule: __RULE__\n\n" + | |
536 | "__RULE_INFO__\n\n" + | |
537 | "__VIRUS_INFO__\n" + | |
538 | "__SPAM_INFO__\n", | |
8153da61 | 539 | fieldLabel: gettext('Body'), |
628eccdb DC |
540 | }, |
541 | { | |
542 | xtype: 'proxmoxcheckbox', | |
543 | name: 'attach', | |
8153da61 TL |
544 | fieldLabel: gettext("Attach orig. Mail"), |
545 | }, | |
546 | ], | |
628eccdb DC |
547 | }, |
548 | 4003: { | |
573a6e8b | 549 | onlineHelp: 'pmg_mailfilter_action', |
628eccdb DC |
550 | xtype: 'proxmoxWindowEdit', |
551 | subdir: 'field', | |
552 | subject: gettext('Header Attribute'), | |
553 | width: 400, | |
554 | items: [ | |
555 | { | |
556 | xtype: 'textfield', | |
557 | name: 'name', | |
558 | allowBlank: false, | |
8153da61 | 559 | fieldLabel: gettext('Name'), |
628eccdb DC |
560 | }, |
561 | { | |
562 | xtype: 'textareafield', | |
563 | name: 'info', | |
8153da61 | 564 | fieldLabel: gettext("Comment"), |
628eccdb DC |
565 | }, |
566 | { | |
567 | xtype: 'textfield', | |
568 | name: 'field', | |
569 | allowBlank: false, | |
8153da61 | 570 | fieldLabel: gettext('Field'), |
628eccdb DC |
571 | }, |
572 | { | |
573 | xtype: 'textfield', | |
574 | reference: 'value', | |
575 | name: 'value', | |
576 | allowBlank: false, | |
8153da61 TL |
577 | fieldLabel: gettext('Value'), |
578 | }, | |
579 | ], | |
628eccdb | 580 | }, |
f5de8682 | 581 | 4005: { |
573a6e8b | 582 | onlineHelp: 'pmg_mailfilter_action', |
5f3ec152 | 583 | xtype: 'proxmoxWindowEdit', |
f5de8682 DM |
584 | subdir: 'bcc', |
585 | subject: gettext('BCC'), | |
586 | width: 400, | |
587 | items: [ | |
588 | { | |
589 | xtype: 'textfield', | |
590 | name: 'name', | |
591 | allowBlank: false, | |
8153da61 | 592 | fieldLabel: gettext('Name'), |
f5de8682 DM |
593 | }, |
594 | { | |
595 | xtype: 'textareafield', | |
596 | name: 'info', | |
8153da61 | 597 | fieldLabel: gettext("Comment"), |
f5de8682 DM |
598 | }, |
599 | { | |
600 | xtype: 'textfield', | |
601 | name: 'target', | |
602 | allowBlank: false, | |
8153da61 | 603 | fieldLabel: gettext("Target"), |
f5de8682 DM |
604 | }, |
605 | { | |
606 | xtype: 'proxmoxcheckbox', | |
607 | checked: true, | |
608 | name: 'original', | |
8153da61 TL |
609 | fieldLabel: gettext("send orig. Mail"), |
610 | }, | |
611 | ], | |
f5de8682 | 612 | |
628eccdb DC |
613 | }, |
614 | 4007: { | |
573a6e8b | 615 | onlineHelp: 'pmg_mailfilter_action', |
628eccdb DC |
616 | xtype: 'proxmoxWindowEdit', |
617 | subdir: 'removeattachments', | |
618 | subject: gettext('Remove Attachments'), | |
619 | width: 500, | |
620 | fieldDefaults: { | |
8153da61 | 621 | labelWidth: 150, |
628eccdb DC |
622 | }, |
623 | items: [ | |
624 | { | |
625 | xtype: 'textfield', | |
626 | name: 'name', | |
627 | allowBlank: false, | |
8153da61 | 628 | fieldLabel: gettext('Name'), |
628eccdb DC |
629 | }, |
630 | { | |
631 | xtype: 'textareafield', | |
632 | name: 'info', | |
8153da61 | 633 | fieldLabel: gettext("Comment"), |
628eccdb DC |
634 | }, |
635 | { | |
636 | xtype: 'textareafield', | |
637 | name: 'text', | |
638 | grow: true, | |
639 | growMax: 250, | |
8153da61 | 640 | fieldLabel: gettext("Text Replacement"), |
628eccdb DC |
641 | }, |
642 | { | |
643 | xtype: 'proxmoxcheckbox', | |
644 | checked: true, | |
645 | name: 'all', | |
8153da61 | 646 | fieldLabel: gettext("Remove all attachments"), |
572198b7 DC |
647 | }, |
648 | { | |
649 | xtype: 'proxmoxcheckbox', | |
650 | checked: false, | |
651 | name: 'quarantine', | |
8153da61 TL |
652 | fieldLabel: gettext("Copy orignal mail to Attachment Quarantine"), |
653 | }, | |
654 | ], | |
628eccdb DC |
655 | }, |
656 | 4009: { | |
573a6e8b | 657 | onlineHelp: 'pmg_mailfilter_action', |
628eccdb DC |
658 | xtype: 'proxmoxWindowEdit', |
659 | subdir: 'disclaimer', | |
660 | subject: gettext('Disclaimer'), | |
661 | width: 400, | |
662 | items: [ | |
663 | { | |
664 | xtype: 'textfield', | |
665 | name: 'name', | |
666 | allowBlank: false, | |
8153da61 | 667 | fieldLabel: gettext('Name'), |
628eccdb DC |
668 | }, |
669 | { | |
670 | xtype: 'textareafield', | |
671 | name: 'info', | |
8153da61 | 672 | fieldLabel: gettext("Comment"), |
628eccdb DC |
673 | }, |
674 | { | |
675 | xtype: 'textareafield', | |
676 | name: 'disclaimer', | |
677 | grow: true, | |
678 | growMax: 250, | |
8153da61 TL |
679 | fieldLabel: gettext("Disclaimer"), |
680 | }, | |
681 | ], | |
682 | }, | |
012f0f49 | 683 | }, |
ad834b6f | 684 | |
f1ab2a14 DC |
685 | updateLoginData: function(data) { |
686 | Proxmox.CSRFPreventionToken = data.CSRFPreventionToken; | |
687 | Proxmox.UserName = data.username; | |
8153da61 | 688 | Ext.util.Cookies.set('PMGAuthCookie', data.ticket, null, '/', null, true); |
f1ab2a14 DC |
689 | }, |
690 | ||
258d48b5 DM |
691 | quarantineActionExtracted: false, |
692 | ||
693 | extractQuarantineAction: function() { | |
8153da61 TL |
694 | if (PMG.Utils.quarantineActionExtracted) { |
695 | return null; | |
696 | } | |
258d48b5 DM |
697 | |
698 | PMG.Utils.quarantineActionExtracted = true; | |
699 | ||
8153da61 | 700 | let qs = Ext.Object.fromQueryString(location.search); |
258d48b5 | 701 | |
8153da61 TL |
702 | let cselect = qs.cselect; |
703 | let action = qs.action; | |
704 | let dateString = qs.date; | |
a0a98b8d DC |
705 | |
706 | if (dateString) { | |
8153da61 | 707 | let date = new Date(dateString).getTime()/1000; |
a0a98b8d DC |
708 | |
709 | // set from date for QuarantineList | |
a0a98b8d | 710 | PMG.QuarantineList.from = date; |
a0a98b8d | 711 | } |
258d48b5 DM |
712 | |
713 | delete qs.cselect; | |
714 | delete qs.action; | |
715 | delete qs.ticket; | |
a0a98b8d | 716 | delete qs.date; |
258d48b5 DM |
717 | |
718 | var newsearch = Ext.Object.toQueryString(qs); | |
719 | ||
720 | var newurl = location.protocol + "//" + location.host + location.pathname; | |
cc6b80b6 | 721 | if (newsearch) { newurl += '?' + newsearch; } |
258d48b5 DM |
722 | newurl += location.hash; |
723 | ||
724 | if (window.history) { | |
8153da61 | 725 | window.history.pushState({ path: newurl }, '', newurl); |
258d48b5 DM |
726 | } |
727 | ||
207471c0 | 728 | if (action || cselect) { |
8153da61 TL |
729 | return { |
730 | action: action, | |
731 | cselect: cselect, | |
732 | }; | |
258d48b5 | 733 | } |
8153da61 | 734 | return null; |
258d48b5 DM |
735 | }, |
736 | ||
aac17b9b | 737 | doQuarantineAction: function(action, id, callback) { |
cf5268ca DC |
738 | Proxmox.Utils.API2Request({ |
739 | url: '/quarantine/content/', | |
aac17b9b DM |
740 | params: { |
741 | action: action, | |
8153da61 | 742 | id: id, |
aac17b9b | 743 | }, |
cf5268ca DC |
744 | method: 'POST', |
745 | failure: function(response, opts) { | |
746 | Ext.Msg.alert(gettext('Error'), response.htmlStatus); | |
747 | }, | |
748 | success: function(response, opts) { | |
467eb50b TL |
749 | let count = id.split(';').length; |
750 | let fmt = count > 1 | |
751 | ? gettext("Action '{0}' for '{1}' items successful") | |
752 | : gettext("Action '{0}' successful") | |
753 | ; | |
754 | let message = Ext.String.format(fmt, action, count); | |
755 | let title = Ext.String.format("{0} successful", Ext.String.capitalize(action)); | |
756 | ||
757 | Ext.toast({ | |
758 | html: message, | |
759 | title: title, | |
760 | minWidth: 200, | |
761 | hideDuration: 250, | |
762 | slideBackDuration: 250, | |
763 | slideBackAnimation: 'easeOut', | |
764 | iconCls: 'fa fa-check', | |
92b6c1f3 | 765 | shadow: true, |
cf5268ca DC |
766 | }); |
767 | ||
768 | if (Ext.isFunction(callback)) { | |
769 | callback(); | |
770 | } | |
8153da61 | 771 | }, |
cf5268ca DC |
772 | }); |
773 | }, | |
774 | ||
19b455dd DC |
775 | render_filetype: function(value) { |
776 | let iconCls = 'fa-file-o'; | |
777 | let text = Proxmox.Utils.unknownText; | |
778 | ||
779 | if (!value) { | |
780 | return `<i class='fa ${iconCls}'></i> ${text}`; | |
781 | } | |
782 | ||
783 | text = value.toString().toLowerCase(); | |
8153da61 | 784 | const type = text.split('/')[0]; |
19b455dd DC |
785 | |
786 | switch (type) { | |
787 | case 'audio': | |
788 | case 'image': | |
789 | case 'video': | |
790 | case 'text': | |
791 | iconCls = `fa-file-${type}-o`; | |
792 | break; | |
8153da61 TL |
793 | case 'application': { |
794 | const subtypes = ['excel', 'pdf', 'word', 'powerpoint']; | |
19b455dd DC |
795 | let found = subtypes.find(st => text.includes(st)); |
796 | if (found !== undefined) { | |
797 | iconCls = `fa-file-${found}-o`; | |
798 | } | |
8153da61 | 799 | } break; |
19b455dd DC |
800 | default: |
801 | break; | |
802 | } | |
803 | ||
804 | return `<i class='fa ${iconCls}'></i> ${text}`; | |
805 | }, | |
806 | ||
cf5268ca DC |
807 | sender_renderer: function(value, metaData, rec) { |
808 | var subject = Ext.htmlEncode(value); | |
809 | var from = Ext.htmlEncode(rec.data.from); | |
810 | var sender = Ext.htmlEncode(rec.data.sender); | |
811 | if (sender) { | |
812 | from = Ext.String.format(gettext("{0} on behalf of {1}"), | |
813 | sender, from); | |
814 | } | |
815 | return '<small>' + from + '</small><br>' + subject; | |
816 | }, | |
817 | ||
fe81f069 DM |
818 | constructor: function() { |
819 | var me = this; | |
fe81f069 | 820 | |
2c7b542d | 821 | // do whatever you want here |
8153da61 | 822 | }, |
fe81f069 | 823 | }); |