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