]>
Commit | Line | Data |
---|---|---|
1 | /*global Proxmox */ | |
2 | Ext.ns('PMG'); | |
3 | ||
4 | console.log("Starting PMG Manager"); | |
5 | ||
6 | ||
7 | Ext.define('PMG.Utils', { | |
8 | singleton: true, | |
9 | ||
10 | // this singleton contains miscellaneous utilities | |
11 | ||
12 | senderText: gettext('Sender'), | |
13 | receiverText: gettext('Receiver'), | |
14 | scoreText: gettext('Score'), | |
15 | ||
16 | user_role_text: { | |
17 | root: gettext('Superuser'), | |
18 | admin: gettext('Administrator'), | |
19 | helpdesk: gettext('Help Desk'), | |
20 | qmanager: gettext('Quarantine Manager'), | |
21 | audit: gettext('Auditor') | |
22 | }, | |
23 | ||
24 | format_user_role: function(role) { | |
25 | return PMG.Utils.user_role_text[role] || role; | |
26 | }, | |
27 | ||
28 | oclass_text: { | |
29 | who: gettext('Who Objects'), | |
30 | what: gettext('What Objects'), | |
31 | when: gettext('When Objects'), | |
32 | action: gettext('Action Objects'), | |
33 | from: gettext('From'), | |
34 | to: gettext('To') | |
35 | }, | |
36 | ||
37 | oclass_icon: { | |
38 | who: '<span class="fa fa-fw fa-user-circle"></span> ', | |
39 | what: '<span class="fa fa-fw fa-cube"></span> ', | |
40 | when: '<span class="fa fa-fw fa-clock-o"></span> ', | |
41 | action: '<span class="fa fa-fw fa-flag"></span> ', | |
42 | from: '<span class="fa fa-fw fa-user-circle"></span> ', | |
43 | to: '<span class="fa fa-fw fa-user-circle"></span> ' | |
44 | }, | |
45 | ||
46 | mail_status_map: { | |
47 | 2: 'delivered', | |
48 | 4: 'deferred', | |
49 | 5: 'bounced', | |
50 | N: 'rejected', | |
51 | G: 'greylisted', | |
52 | A: 'accepted', | |
53 | B: 'blocked', | |
54 | Q: 'quarantine' | |
55 | }, | |
56 | ||
57 | icon_status_map_class: { | |
58 | 2: 'check-circle', | |
59 | 4: 'clock-o', | |
60 | 5: 'mail-reply', | |
61 | N: 'times-circle', | |
62 | G: 'list', | |
63 | A: 'check', | |
64 | B: 'ban', | |
65 | Q: 'cube' | |
66 | }, | |
67 | ||
68 | icon_status_map_color: { | |
69 | 2: 'green', | |
70 | 5: 'gray', | |
71 | A: 'green', | |
72 | B: 'red' | |
73 | }, | |
74 | ||
75 | format_status_icon: function(status) { | |
76 | var icon = PMG.Utils.icon_status_map_class[status] || 'question-circle'; | |
77 | var color = PMG.Utils.icon_status_map_color[status] || ''; | |
78 | return '<i class="fa fa-' + icon + ' ' + color + '"></i> '; | |
79 | }, | |
80 | ||
81 | format_oclass: function(oclass) { | |
82 | var icon = PMG.Utils.oclass_icon[oclass] || ''; | |
83 | var text = PMG.Utils.oclass_text[oclass] || oclass; | |
84 | return icon + text; | |
85 | }, | |
86 | ||
87 | rule_direction_text: { | |
88 | 0: gettext('In'), | |
89 | 1: gettext('Out'), | |
90 | 2: gettext('In & Out') | |
91 | }, | |
92 | ||
93 | rule_direction_icon: { | |
94 | 0: '<span class="fa fa-fw fa-long-arrow-left"></span> ', | |
95 | 1: '<span class="fa fa-fw fa-long-arrow-right"></span> ', | |
96 | 2: '<span class="fa fa-fw fa-exchange"></span> ' | |
97 | }, | |
98 | ||
99 | format_rule_direction: function(dir) { | |
100 | var icon = PMG.Utils.rule_direction_icon[dir] || ''; | |
101 | var text = PMG.Utils.rule_direction_text[dir] || dir; | |
102 | return icon + text; | |
103 | }, | |
104 | ||
105 | format_otype: function(otype) { | |
106 | var editor = PMG.Utils.object_editors[otype]; | |
107 | var iconCls = 'fa fa-question-circle'; | |
108 | if (editor) { | |
109 | var icon = '<span class="fa-fw ' + (editor.iconCls || iconCls) + '"></span> '; | |
110 | return icon + editor.subject; | |
111 | } | |
112 | ||
113 | return '<span class="fa-fw ' + iconCls + '"></span> unknown'; | |
114 | }, | |
115 | ||
116 | format_ldap_protocol: function(p) { | |
117 | if (p === undefined) { return 'LDAP'; } | |
118 | if (p === 'ldap') { return 'LDAP'; } | |
119 | if (p === 'ldaps') { return 'LDAPS'; } | |
120 | return 'unknown'; | |
121 | }, | |
122 | ||
123 | convert_field_to_per_min: function(value, record) { | |
124 | return (value/(record.data.timespan/60)); | |
125 | }, | |
126 | ||
127 | object_editors: { | |
128 | 1000: { | |
129 | onlineHelp: 'pmg_mailfilter_regex', | |
130 | iconCls: 'fa fa-filter', | |
131 | xtype: 'proxmoxWindowEdit', | |
132 | subdir: 'regex', | |
133 | subject: gettext("Regular Expression"), | |
134 | width: 400, | |
135 | items: [ | |
136 | { | |
137 | xtype: 'textfield', | |
138 | name: 'regex', | |
139 | labelWidth: 150, | |
140 | reference: 'regex', | |
141 | fieldLabel: gettext("Regular Expression") | |
142 | }, | |
143 | { | |
144 | labelWidth: 150, | |
145 | fieldLabel: gettext('Test String'), | |
146 | xtype: 'pmgRegexTester', | |
147 | wholeMatch: true, | |
148 | regexFieldReference: 'regex' | |
149 | } | |
150 | ] | |
151 | }, | |
152 | 1005: { | |
153 | onlineHelp: 'pmgconfig_ldap', | |
154 | iconCls: 'fa fa-users', | |
155 | xtype: 'pmgLDAPGroupEditor', | |
156 | subdir: 'ldap', | |
157 | subject: gettext("LDAP Group") | |
158 | }, | |
159 | 1006: { | |
160 | onlineHelp: 'pmgconfig_ldap', | |
161 | iconCls: 'fa fa-user', | |
162 | xtype: 'pmgLDAPUserEditor', | |
163 | subdir: 'ldapuser', | |
164 | subject: gettext("LDAP User") | |
165 | }, | |
166 | 1009: { | |
167 | onlineHelp: 'pmg_mailfilter_regex', | |
168 | iconCls: 'fa fa-filter', | |
169 | xtype: 'proxmoxWindowEdit', | |
170 | subdir: 'receiver_regex', | |
171 | subject: gettext("Regular Expression"), | |
172 | receivertest: true, | |
173 | width: 400, | |
174 | items: [ | |
175 | { | |
176 | xtype: 'textfield', | |
177 | name: 'regex', | |
178 | labelWidth: 150, | |
179 | fieldLabel: gettext("Regular Expression") | |
180 | } | |
181 | ] | |
182 | }, | |
183 | 1001: { | |
184 | onlineHelp: 'pmg_mailfilter_who', | |
185 | iconCls: 'fa fa-envelope-o', | |
186 | xtype: 'proxmoxWindowEdit', | |
187 | subdir: 'email', | |
188 | subject: gettext("E-Mail"), | |
189 | width: 400, | |
190 | items: [ | |
191 | { | |
192 | xtype: 'textfield', | |
193 | name: 'email', | |
194 | fieldLabel: gettext("E-Mail") | |
195 | } | |
196 | ] | |
197 | }, | |
198 | 1007: { | |
199 | onlineHelp: 'pmg_mailfilter_who', | |
200 | iconCls: 'fa fa-envelope-o', | |
201 | xtype: 'proxmoxWindowEdit', | |
202 | subdir: 'receiver', | |
203 | subject: gettext("E-Mail"), | |
204 | receivertest: true, | |
205 | width: 400, | |
206 | items: [ | |
207 | { | |
208 | xtype: 'textfield', | |
209 | name: 'email', | |
210 | fieldLabel: gettext("E-Mail") | |
211 | } | |
212 | ] | |
213 | }, | |
214 | 1002: { | |
215 | onlineHelp: 'pmg_mailfilter_who', | |
216 | iconCls: 'fa fa-globe', | |
217 | xtype: 'proxmoxWindowEdit', | |
218 | subdir: 'domain', | |
219 | subject: gettext("Domain"), | |
220 | width: 400, | |
221 | items: [ | |
222 | { | |
223 | xtype: 'textfield', | |
224 | name: 'domain', | |
225 | fieldLabel: gettext("Domain") | |
226 | } | |
227 | ] | |
228 | }, | |
229 | 1008: { | |
230 | onlineHelp: 'pmg_mailfilter_who', | |
231 | iconCls: 'fa fa-globe', | |
232 | xtype: 'proxmoxWindowEdit', | |
233 | subdir: 'receiver_domain', | |
234 | subject: gettext("Domain"), | |
235 | receivertest: true, | |
236 | width: 400, | |
237 | items: [ | |
238 | { | |
239 | xtype: 'textfield', | |
240 | name: 'domain', | |
241 | fieldLabel: gettext("Domain") | |
242 | } | |
243 | ] | |
244 | }, | |
245 | 1003: { | |
246 | onlineHelp: 'pmg_mailfilter_who', | |
247 | iconCls: 'fa fa-globe', | |
248 | xtype: 'proxmoxWindowEdit', | |
249 | subdir: 'ip', | |
250 | subject: gettext("IP Address"), | |
251 | width: 400, | |
252 | items: [ | |
253 | { | |
254 | xtype: 'textfield', | |
255 | name: 'ip', | |
256 | fieldLabel: gettext("IP Address") | |
257 | } | |
258 | ] | |
259 | }, | |
260 | 1004: { | |
261 | onlineHelp: 'pmg_mailfilter_who', | |
262 | iconCls: 'fa fa-globe', | |
263 | xtype: 'proxmoxWindowEdit', | |
264 | subdir: 'network', | |
265 | subject: gettext("IP Network"), | |
266 | width: 400, | |
267 | items: [ | |
268 | { | |
269 | xtype: 'textfield', | |
270 | name: 'cidr', | |
271 | fieldLabel: gettext("IP Network") | |
272 | } | |
273 | ] | |
274 | }, | |
275 | 2000: { | |
276 | onlineHelp: 'pmg_mailfilter_when', | |
277 | iconCls: 'fa fa-clock-o', | |
278 | xtype: 'proxmoxWindowEdit', | |
279 | subdir: 'timeframe', | |
280 | subject: gettext("TimeFrame"), | |
281 | items: [ | |
282 | { | |
283 | xtype: 'timefield', | |
284 | name: 'start', | |
285 | format: 'H:i', | |
286 | fieldLabel: gettext("Start Time") | |
287 | }, | |
288 | { | |
289 | xtype: 'timefield', | |
290 | name: 'end', | |
291 | format: 'H:i', | |
292 | fieldLabel: gettext("End Time") | |
293 | } | |
294 | ] | |
295 | }, | |
296 | 3000: { | |
297 | onlineHelp: 'pmg_mailfilter_what', | |
298 | iconCls: 'fa fa-bullhorn', | |
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, | |
308 | fieldLabel: gettext('Level') | |
309 | } | |
310 | ] | |
311 | }, | |
312 | 3001: { | |
313 | onlineHelp: 'pmg_mailfilter_what', | |
314 | iconCls: 'fa fa-bug', | |
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(); | |
323 | } | |
324 | } | |
325 | }, | |
326 | 3002: { | |
327 | onlineHelp: 'pmg_mailfilter_regex', | |
328 | iconCls: 'fa fa-code', | |
329 | xtype: 'proxmoxWindowEdit', | |
330 | subdir: 'matchfield', | |
331 | subject: gettext('Match Field'), | |
332 | width: 400, | |
333 | items: [ | |
334 | { | |
335 | xtype: 'textfield', | |
336 | name: 'field', | |
337 | labelWidth: 150, | |
338 | allowBlank: false, | |
339 | fieldLabel: gettext('Field') | |
340 | }, | |
341 | { | |
342 | xtype: 'textfield', | |
343 | reference: 'value', | |
344 | name: 'value', | |
345 | labelWidth: 150, | |
346 | allowBlank: false, | |
347 | fieldLabel: gettext('Value') | |
348 | }, | |
349 | { | |
350 | labelWidth: 150, | |
351 | fieldLabel: gettext('Test String'), | |
352 | xtype: 'pmgRegexTester', | |
353 | regexFieldReference: 'value' | |
354 | } | |
355 | ] | |
356 | }, | |
357 | 3003: { | |
358 | onlineHelp: 'pmg_mailfilter_what', | |
359 | iconCls: 'fa fa-file-image-o', | |
360 | xtype: 'proxmoxWindowEdit', | |
361 | subdir: 'contenttype', | |
362 | width: 400, | |
363 | subject: gettext('Content Type Filter'), | |
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', | |
377 | url: '/api2/json/config/mimetypes' | |
378 | } | |
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); | |
387 | } | |
388 | } | |
389 | }, | |
390 | { | |
391 | xtype: 'displayfield', | |
392 | fieldLabel: gettext('Value'), | |
393 | labelWidth: 150, | |
394 | allowBlank: false, | |
395 | reset: Ext.emptyFn | |
396 | } | |
397 | ] | |
398 | }, | |
399 | 3004: { | |
400 | onlineHelp: 'pmg_mailfilter_regex', | |
401 | iconCls: 'fa fa-file-o', | |
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, | |
413 | allowBlank: false | |
414 | }, | |
415 | { | |
416 | labelWidth: 150, | |
417 | fieldLabel: gettext('Test String'), | |
418 | wholeMatch: true, | |
419 | xtype: 'pmgRegexTester', | |
420 | regexFieldReference: 'filename' | |
421 | } | |
422 | ] | |
423 | }, | |
424 | 3005: { | |
425 | onlineHelp: 'pmg_mailfilter_what', | |
426 | iconCls: 'fa fa-file-archive-o', | |
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', | |
444 | url: '/api2/json/config/mimetypes' | |
445 | } | |
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); | |
454 | } | |
455 | } | |
456 | }, | |
457 | { | |
458 | xtype: 'displayfield', | |
459 | fieldLabel: gettext('Value'), | |
460 | labelWidth: 150, | |
461 | allowBlank: false, | |
462 | reset: Ext.emptyFn | |
463 | } | |
464 | ] | |
465 | }, | |
466 | 4002: { | |
467 | onlineHelp: 'pmg_mailfilter_action', | |
468 | xtype: 'proxmoxWindowEdit', | |
469 | subdir: 'notification', | |
470 | subject: gettext('Notification'), | |
471 | width: 400, | |
472 | items: [ | |
473 | { | |
474 | xtype: 'textfield', | |
475 | name: 'name', | |
476 | allowBlank: false, | |
477 | fieldLabel: gettext('Name') | |
478 | }, | |
479 | { | |
480 | xtype: 'textareafield', | |
481 | name: 'info', | |
482 | fieldLabel: gettext("Description") | |
483 | }, | |
484 | { | |
485 | xtype: 'textfield', | |
486 | name: 'to', | |
487 | allowBlank: false, | |
488 | value: '__ADMIN__', | |
489 | fieldLabel: gettext('Receiver') | |
490 | }, | |
491 | { | |
492 | xtype: 'textfield', | |
493 | name: 'subject', | |
494 | allowBlank: false, | |
495 | value: 'Notification: __SUBJECT__', | |
496 | fieldLabel: gettext('Subject') | |
497 | }, | |
498 | { | |
499 | xtype: 'textarea', | |
500 | name: 'body', | |
501 | allowBlank: false, | |
502 | grow: true, | |
503 | growMax: 250, | |
504 | value: | |
505 | "Proxmox Notifcation:\n\n" + | |
506 | "Sender: __SENDER__\n" + | |
507 | "Receiver: __RECEIVERS__\n" + | |
508 | "Targets: __TARGETS__\n\n" + | |
509 | "Subject: __SUBJECT__\n\n" + | |
510 | "Matching Rule: __RULE__\n\n" + | |
511 | "__RULE_INFO__\n\n" + | |
512 | "__VIRUS_INFO__\n" + | |
513 | "__SPAM_INFO__\n", | |
514 | fieldLabel: gettext('Body') | |
515 | }, | |
516 | { | |
517 | xtype: 'proxmoxcheckbox', | |
518 | name: 'attach', | |
519 | fieldLabel: gettext("Attach orig. Mail") | |
520 | } | |
521 | ] | |
522 | }, | |
523 | 4003: { | |
524 | onlineHelp: 'pmg_mailfilter_action', | |
525 | xtype: 'proxmoxWindowEdit', | |
526 | subdir: 'field', | |
527 | subject: gettext('Header Attribute'), | |
528 | width: 400, | |
529 | items: [ | |
530 | { | |
531 | xtype: 'textfield', | |
532 | name: 'name', | |
533 | allowBlank: false, | |
534 | fieldLabel: gettext('Name') | |
535 | }, | |
536 | { | |
537 | xtype: 'textareafield', | |
538 | name: 'info', | |
539 | fieldLabel: gettext("Description") | |
540 | }, | |
541 | { | |
542 | xtype: 'textfield', | |
543 | name: 'field', | |
544 | allowBlank: false, | |
545 | fieldLabel: gettext('Field') | |
546 | }, | |
547 | { | |
548 | xtype: 'textfield', | |
549 | reference: 'value', | |
550 | name: 'value', | |
551 | allowBlank: false, | |
552 | fieldLabel: gettext('Value') | |
553 | } | |
554 | ] | |
555 | }, | |
556 | 4005: { | |
557 | onlineHelp: 'pmg_mailfilter_action', | |
558 | xtype: 'proxmoxWindowEdit', | |
559 | subdir: 'bcc', | |
560 | subject: gettext('BCC'), | |
561 | width: 400, | |
562 | items: [ | |
563 | { | |
564 | xtype: 'textfield', | |
565 | name: 'name', | |
566 | allowBlank: false, | |
567 | fieldLabel: gettext('Name') | |
568 | }, | |
569 | { | |
570 | xtype: 'textareafield', | |
571 | name: 'info', | |
572 | fieldLabel: gettext("Description") | |
573 | }, | |
574 | { | |
575 | xtype: 'textfield', | |
576 | name: 'target', | |
577 | allowBlank: false, | |
578 | fieldLabel: gettext("Target") | |
579 | }, | |
580 | { | |
581 | xtype: 'proxmoxcheckbox', | |
582 | checked: true, | |
583 | name: 'original', | |
584 | fieldLabel: gettext("send orig. Mail") | |
585 | } | |
586 | ] | |
587 | ||
588 | }, | |
589 | 4007: { | |
590 | onlineHelp: 'pmg_mailfilter_action', | |
591 | xtype: 'proxmoxWindowEdit', | |
592 | subdir: 'removeattachments', | |
593 | subject: gettext('Remove Attachments'), | |
594 | width: 500, | |
595 | fieldDefaults: { | |
596 | labelWidth: 150 | |
597 | }, | |
598 | items: [ | |
599 | { | |
600 | xtype: 'textfield', | |
601 | name: 'name', | |
602 | allowBlank: false, | |
603 | fieldLabel: gettext('Name') | |
604 | }, | |
605 | { | |
606 | xtype: 'textareafield', | |
607 | name: 'info', | |
608 | fieldLabel: gettext("Description") | |
609 | }, | |
610 | { | |
611 | xtype: 'textareafield', | |
612 | name: 'text', | |
613 | grow: true, | |
614 | growMax: 250, | |
615 | fieldLabel: gettext("Text Replacement") | |
616 | }, | |
617 | { | |
618 | xtype: 'proxmoxcheckbox', | |
619 | checked: true, | |
620 | name: 'all', | |
621 | fieldLabel: gettext("Remove all attachments") | |
622 | } | |
623 | ] | |
624 | }, | |
625 | 4009: { | |
626 | onlineHelp: 'pmg_mailfilter_action', | |
627 | xtype: 'proxmoxWindowEdit', | |
628 | subdir: 'disclaimer', | |
629 | subject: gettext('Disclaimer'), | |
630 | width: 400, | |
631 | items: [ | |
632 | { | |
633 | xtype: 'textfield', | |
634 | name: 'name', | |
635 | allowBlank: false, | |
636 | fieldLabel: gettext('Name') | |
637 | }, | |
638 | { | |
639 | xtype: 'textareafield', | |
640 | name: 'info', | |
641 | fieldLabel: gettext("Description") | |
642 | }, | |
643 | { | |
644 | xtype: 'textareafield', | |
645 | name: 'disclaimer', | |
646 | grow: true, | |
647 | growMax: 250, | |
648 | fieldLabel: gettext("Disclaimer") | |
649 | } | |
650 | ] | |
651 | } | |
652 | }, | |
653 | ||
654 | updateLoginData: function(data) { | |
655 | Proxmox.CSRFPreventionToken = data.CSRFPreventionToken; | |
656 | Proxmox.UserName = data.username; | |
657 | Ext.util.Cookies.set('PMGAuthCookie', data.ticket, null, '/', null, true ); | |
658 | }, | |
659 | ||
660 | quarantineActionExtracted: false, | |
661 | ||
662 | extractQuarantineAction: function() { | |
663 | ||
664 | if (PMG.Utils.quarantineActionExtracted) { return; } | |
665 | ||
666 | PMG.Utils.quarantineActionExtracted = true; | |
667 | ||
668 | var qs = Ext.Object.fromQueryString(location.search); | |
669 | ||
670 | var cselect = qs.cselect; | |
671 | var action = qs.action; | |
672 | var ticket = qs.ticket; | |
673 | var dateString = qs.date; | |
674 | ||
675 | if (dateString) { | |
676 | var date = new Date(dateString).getTime()/1000; | |
677 | ||
678 | // set from date for QuarantineList | |
679 | /*jslint confusion: true*/ | |
680 | /*from is a string above and number here */ | |
681 | PMG.QuarantineList.from = date; | |
682 | /*jslint confusion: false*/ | |
683 | } | |
684 | ||
685 | delete qs.cselect; | |
686 | delete qs.action; | |
687 | delete qs.ticket; | |
688 | delete qs.date; | |
689 | ||
690 | var newsearch = Ext.Object.toQueryString(qs); | |
691 | ||
692 | var newurl = location.protocol + "//" + location.host + location.pathname; | |
693 | if (newsearch) { newurl += '?' + newsearch; } | |
694 | newurl += location.hash; | |
695 | ||
696 | if (window.history) { | |
697 | window.history.pushState({ path:newurl }, '', newurl); | |
698 | } | |
699 | ||
700 | if (action || cselect) { | |
701 | return { action: action, cselect: cselect }; | |
702 | } | |
703 | }, | |
704 | ||
705 | doQuarantineAction: function(action, id, callback) { | |
706 | var count = id.split(';').length; | |
707 | var successMessage = "Action '{0}'"; | |
708 | if (count > 1) { | |
709 | successMessage += " for '{1}' items"; | |
710 | } | |
711 | successMessage += " successful"; | |
712 | ||
713 | /*jslint confusion: true*/ | |
714 | /*format is string and function*/ | |
715 | Proxmox.Utils.API2Request({ | |
716 | url: '/quarantine/content/', | |
717 | params: { | |
718 | action: action, | |
719 | id: id | |
720 | }, | |
721 | method: 'POST', | |
722 | failure: function(response, opts) { | |
723 | Ext.Msg.alert(gettext('Error'), response.htmlStatus); | |
724 | }, | |
725 | success: function(response, opts) { | |
726 | var win = Ext.create('Ext.window.MessageBox',{ | |
727 | closeAction: 'destroy' | |
728 | }).show({ | |
729 | title: gettext('Info'), | |
730 | message: Ext.String.format(successMessage, action, count), | |
731 | buttons: Ext.Msg.OK, | |
732 | icon: Ext.MessageBox.INFO | |
733 | }); | |
734 | ||
735 | if (Ext.isFunction(callback)) { | |
736 | callback(); | |
737 | } | |
738 | } | |
739 | }); | |
740 | /*jslint confusion: false*/ | |
741 | }, | |
742 | ||
743 | sender_renderer: function(value, metaData, rec) { | |
744 | var subject = Ext.htmlEncode(value); | |
745 | var from = Ext.htmlEncode(rec.data.from); | |
746 | var sender = Ext.htmlEncode(rec.data.sender); | |
747 | if (sender) { | |
748 | /*jslint confusion: true*/ | |
749 | /*format is a string above*/ | |
750 | from = Ext.String.format(gettext("{0} on behalf of {1}"), | |
751 | sender, from); | |
752 | /*jslint confusion: false*/ | |
753 | } | |
754 | return '<small>' + from + '</small><br>' + subject; | |
755 | }, | |
756 | ||
757 | constructor: function() { | |
758 | var me = this; | |
759 | ||
760 | // do whatever you want here | |
761 | } | |
762 | }); |