4 console
.log("Starting PMG Manager");
7 Ext
.define('PMG.Utils', {
10 // this singleton contains miscellaneous utilities
12 senderText
: gettext('Sender'),
13 receiverText
: gettext('Receiver'),
14 scoreText
: gettext('Score'),
17 root
: gettext('Superuser'),
18 admin
: gettext('Administrator'),
19 helpdesk
: gettext('Help Desk'),
20 qmanager
: gettext('Quarantine Manager'),
21 audit
: gettext('Auditor')
24 format_user_role: function(role
) {
25 return PMG
.Utils
.user_role_text
[role
] || role
;
29 who
: gettext('Who Objects'),
30 what
: gettext('What Objects'),
31 when
: gettext('When Objects'),
32 action
: gettext('Action Objects'),
33 from: gettext('From'),
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> '
57 icon_status_map_class
: {
68 icon_status_map_color
: {
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> ';
81 format_oclass: function(oclass
) {
82 var icon
= PMG
.Utils
.oclass_icon
[oclass
] || '';
83 var text
= PMG
.Utils
.oclass_text
[oclass
] || oclass
;
87 rule_direction_text
: {
90 2: gettext('In & Out')
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> '
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
;
105 format_otype: function(otype
) {
106 var editor
= PMG
.Utils
.object_editors
[otype
];
107 var iconCls
= 'fa fa-question-circle';
109 var icon
= '<span class="fa-fw ' + (editor
.iconCls
|| iconCls
) + '"></span> ';
110 return icon
+ editor
.subject
;
113 return '<span class="fa-fw ' + iconCls
+ '"></span> unknown';
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 if (p
=== 'ldap+starttls') { return 'LDAP+STARTTLS'; }
124 convert_field_to_per_min: function(value
, record
) {
125 return (value
/(record.data.timespan/60));
130 onlineHelp
: 'pmg_mailfilter_regex',
131 iconCls
: 'fa fa-filter',
132 xtype
: 'proxmoxWindowEdit',
134 subject
: gettext("Regular Expression"),
142 fieldLabel
: gettext("Regular Expression")
146 fieldLabel
: gettext('Test String'),
147 xtype
: 'pmgRegexTester',
149 regexFieldReference
: 'regex'
154 onlineHelp
: 'pmgconfig_ldap',
155 iconCls
: 'fa fa-users',
156 xtype
: 'pmgLDAPGroupEditor',
158 subject
: gettext("LDAP Group")
161 onlineHelp
: 'pmgconfig_ldap',
162 iconCls
: 'fa fa-user',
163 xtype
: 'pmgLDAPUserEditor',
165 subject
: gettext("LDAP User")
168 onlineHelp
: 'pmg_mailfilter_regex',
169 iconCls
: 'fa fa-filter',
170 xtype
: 'proxmoxWindowEdit',
171 subdir
: 'receiver_regex',
172 subject
: gettext("Regular Expression"),
180 fieldLabel
: gettext("Regular Expression")
185 onlineHelp
: 'pmg_mailfilter_who',
186 iconCls
: 'fa fa-envelope-o',
187 xtype
: 'proxmoxWindowEdit',
189 subject
: gettext("E-Mail"),
195 fieldLabel
: gettext("E-Mail")
200 onlineHelp
: 'pmg_mailfilter_who',
201 iconCls
: 'fa fa-envelope-o',
202 xtype
: 'proxmoxWindowEdit',
204 subject
: gettext("E-Mail"),
211 fieldLabel
: gettext("E-Mail")
216 onlineHelp
: 'pmg_mailfilter_who',
217 iconCls
: 'fa fa-globe',
218 xtype
: 'proxmoxWindowEdit',
220 subject
: gettext("Domain"),
226 fieldLabel
: gettext("Domain")
231 onlineHelp
: 'pmg_mailfilter_who',
232 iconCls
: 'fa fa-globe',
233 xtype
: 'proxmoxWindowEdit',
234 subdir
: 'receiver_domain',
235 subject
: gettext("Domain"),
242 fieldLabel
: gettext("Domain")
247 onlineHelp
: 'pmg_mailfilter_who',
248 iconCls
: 'fa fa-globe',
249 xtype
: 'proxmoxWindowEdit',
251 subject
: gettext("IP Address"),
257 fieldLabel
: gettext("IP Address")
262 onlineHelp
: 'pmg_mailfilter_who',
263 iconCls
: 'fa fa-globe',
264 xtype
: 'proxmoxWindowEdit',
266 subject
: gettext("IP Network"),
272 fieldLabel
: gettext("IP Network")
277 onlineHelp
: 'pmg_mailfilter_when',
278 iconCls
: 'fa fa-clock-o',
279 xtype
: 'proxmoxWindowEdit',
281 subject
: gettext("TimeFrame"),
287 fieldLabel
: gettext("Start Time")
293 fieldLabel
: gettext("End Time")
298 onlineHelp
: 'pmg_mailfilter_what',
299 iconCls
: 'fa fa-bullhorn',
300 xtype
: 'proxmoxWindowEdit',
301 subdir
: 'spamfilter',
302 subject
: gettext('Spam Filter'),
305 xtype
: 'proxmoxintegerfield',
309 fieldLabel
: gettext('Level')
314 onlineHelp
: 'pmg_mailfilter_what',
315 iconCls
: 'fa fa-bug',
316 xtype
: 'proxmoxWindowEdit',
317 subdir
: 'virusfilter',
318 subject
: gettext('Virus Filter'),
320 // there are no parameters to give, so we simply submit it
322 show: function(win
) {
328 onlineHelp
: 'pmg_mailfilter_regex',
329 iconCls
: 'fa fa-code',
330 xtype
: 'proxmoxWindowEdit',
331 subdir
: 'matchfield',
332 subject
: gettext('Match Field'),
340 fieldLabel
: gettext('Field')
348 fieldLabel
: gettext('Value')
352 fieldLabel
: gettext('Test String'),
353 xtype
: 'pmgRegexTester',
354 regexFieldReference
: 'value'
359 onlineHelp
: 'pmg_mailfilter_what',
360 iconCls
: 'fa fa-file-image-o',
361 xtype
: 'proxmoxWindowEdit',
362 subdir
: 'contenttype',
364 subject
: gettext('Content Type Filter'),
368 displayField
: 'text',
370 valueField
: 'mimetype',
378 url
: '/api2/json/config/mimetypes'
381 fieldLabel
: gettext('Content Type'),
383 matchFieldWidth
: false,
385 change: function(cb
, value
) {
387 me
.up().down('displayfield').setValue(value
);
392 xtype
: 'displayfield',
393 fieldLabel
: gettext('Value'),
401 onlineHelp
: 'pmg_mailfilter_regex',
402 iconCls
: 'fa fa-file-o',
403 xtype
: 'proxmoxWindowEdit',
404 subdir
: 'filenamefilter',
406 subject
: gettext('Match Filename'),
411 reference
: 'filename',
412 fieldLabel
: gettext('Filename'),
418 fieldLabel
: gettext('Test String'),
420 xtype
: 'pmgRegexTester',
421 regexFieldReference
: 'filename'
426 onlineHelp
: 'pmg_mailfilter_what',
427 iconCls
: 'fa fa-file-archive-o',
428 xtype
: 'proxmoxWindowEdit',
429 subdir
: 'archivefilter',
431 subject
: gettext('Archive Filter'),
435 displayField
: 'text',
437 valueField
: 'mimetype',
445 url
: '/api2/json/config/mimetypes'
448 fieldLabel
: gettext('Content Type'),
450 matchFieldWidth
: false,
452 change: function(cb
, value
) {
454 me
.up().down('displayfield').setValue(value
);
459 xtype
: 'displayfield',
460 fieldLabel
: gettext('Value'),
468 onlineHelp
: 'pmg_mailfilter_regex',
469 iconCls
: 'fa fa-file-archive-o',
470 xtype
: 'proxmoxWindowEdit',
471 subdir
: 'archivefilenamefilter',
473 subject
: gettext('Match Archive Filename'),
478 reference
: 'filename',
479 fieldLabel
: gettext('Filename'),
485 fieldLabel
: gettext('Test String'),
487 xtype
: 'pmgRegexTester',
488 regexFieldReference
: 'filename'
493 onlineHelp
: 'pmg_mailfilter_action',
494 xtype
: 'proxmoxWindowEdit',
495 subdir
: 'notification',
496 subject
: gettext('Notification'),
503 fieldLabel
: gettext('Name')
506 xtype
: 'textareafield',
508 fieldLabel
: gettext("Comment")
515 fieldLabel
: gettext('Receiver')
521 value
: 'Notification: __SUBJECT__',
522 fieldLabel
: gettext('Subject')
531 "Proxmox Notifcation:\n\n" +
532 "Sender: __SENDER__\n" +
533 "Receiver: __RECEIVERS__\n" +
534 "Targets: __TARGETS__\n\n" +
535 "Subject: __SUBJECT__\n\n" +
536 "Matching Rule: __RULE__\n\n" +
537 "__RULE_INFO__\n\n" +
540 fieldLabel
: gettext('Body')
543 xtype
: 'proxmoxcheckbox',
545 fieldLabel
: gettext("Attach orig. Mail")
550 onlineHelp
: 'pmg_mailfilter_action',
551 xtype
: 'proxmoxWindowEdit',
553 subject
: gettext('Header Attribute'),
560 fieldLabel
: gettext('Name')
563 xtype
: 'textareafield',
565 fieldLabel
: gettext("Comment")
571 fieldLabel
: gettext('Field')
578 fieldLabel
: gettext('Value')
583 onlineHelp
: 'pmg_mailfilter_action',
584 xtype
: 'proxmoxWindowEdit',
586 subject
: gettext('BCC'),
593 fieldLabel
: gettext('Name')
596 xtype
: 'textareafield',
598 fieldLabel
: gettext("Comment")
604 fieldLabel
: gettext("Target")
607 xtype
: 'proxmoxcheckbox',
610 fieldLabel
: gettext("send orig. Mail")
616 onlineHelp
: 'pmg_mailfilter_action',
617 xtype
: 'proxmoxWindowEdit',
618 subdir
: 'removeattachments',
619 subject
: gettext('Remove Attachments'),
629 fieldLabel
: gettext('Name')
632 xtype
: 'textareafield',
634 fieldLabel
: gettext("Comment")
637 xtype
: 'textareafield',
641 fieldLabel
: gettext("Text Replacement")
644 xtype
: 'proxmoxcheckbox',
647 fieldLabel
: gettext("Remove all attachments")
650 xtype
: 'proxmoxcheckbox',
653 fieldLabel
: gettext("Copy orignal mail to Attachment Quarantine")
658 onlineHelp
: 'pmg_mailfilter_action',
659 xtype
: 'proxmoxWindowEdit',
660 subdir
: 'disclaimer',
661 subject
: gettext('Disclaimer'),
668 fieldLabel
: gettext('Name')
671 xtype
: 'textareafield',
673 fieldLabel
: gettext("Comment")
676 xtype
: 'textareafield',
680 fieldLabel
: gettext("Disclaimer")
686 updateLoginData: function(data
) {
687 Proxmox
.CSRFPreventionToken
= data
.CSRFPreventionToken
;
688 Proxmox
.UserName
= data
.username
;
689 Ext
.util
.Cookies
.set('PMGAuthCookie', data
.ticket
, null, '/', null, true );
692 quarantineActionExtracted
: false,
694 extractQuarantineAction: function() {
696 if (PMG
.Utils
.quarantineActionExtracted
) { return; }
698 PMG
.Utils
.quarantineActionExtracted
= true;
700 var qs
= Ext
.Object
.fromQueryString(location
.search
);
702 var cselect
= qs
.cselect
;
703 var action
= qs
.action
;
704 var ticket
= qs
.ticket
;
705 var dateString
= qs
.date
;
708 var date
= new Date(dateString
).getTime()/1000;
710 // set from date for QuarantineList
711 /*jslint confusion: true*/
712 /*from is a string above and number here */
713 PMG
.QuarantineList
.from = date
;
714 /*jslint confusion: false*/
722 var newsearch
= Ext
.Object
.toQueryString(qs
);
724 var newurl
= location
.protocol
+ "//" + location
.host
+ location
.pathname
;
725 if (newsearch
) { newurl
+= '?' + newsearch
; }
726 newurl
+= location
.hash
;
728 if (window
.history
) {
729 window
.history
.pushState({ path
:newurl
}, '', newurl
);
732 if (action
|| cselect
) {
733 return { action
: action
, cselect
: cselect
};
737 doQuarantineAction: function(action
, id
, callback
) {
738 var count
= id
.split(';').length
;
739 var successMessage
= "Action '{0}'";
741 successMessage
+= " for '{1}' items";
743 successMessage
+= " successful";
745 /*jslint confusion: true*/
746 /*format is string and function*/
747 Proxmox
.Utils
.API2Request({
748 url
: '/quarantine/content/',
754 failure: function(response
, opts
) {
755 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);
757 success: function(response
, opts
) {
758 var win
= Ext
.create('Ext.window.MessageBox',{
759 closeAction
: 'destroy'
761 title
: gettext('Info'),
762 message
: Ext
.String
.format(successMessage
, action
, count
),
764 icon
: Ext
.MessageBox
.INFO
767 if (Ext
.isFunction(callback
)) {
772 /*jslint confusion: false*/
775 render_filetype: function(value
) {
776 let iconCls
= 'fa-file-o';
777 let text
= Proxmox
.Utils
.unknownText
;
780 return `<i class='fa ${iconCls}'></i> ${text}`;
783 text
= value
.toString().toLowerCase();
784 let type
= text
.split('/')[0];
791 iconCls
= `fa-file-${type}-o`;
794 let subtypes
= ['excel', 'pdf', 'word', 'powerpoint'];
795 let found
= subtypes
.find(st
=> text
.includes(st
));
796 if (found
!== undefined) {
797 iconCls
= `fa-file-${found}-o`;
804 return `<i class='fa ${iconCls}'></i> ${text}`;
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
);
812 /*jslint confusion: true*/
813 /*format is a string above*/
814 from = Ext
.String
.format(gettext("{0} on behalf of {1}"),
816 /*jslint confusion: false*/
818 return '<small>' + from + '</small><br>' + subject
;
821 constructor: function() {
824 // do whatever you want here