3 console
.log("Starting PMG Manager");
6 Ext
.define('PMG.Utils', {
9 // this singleton contains miscellaneous utilities
11 senderText
: gettext('Sender'),
12 receiverText
: gettext('Receiver'),
13 scoreText
: gettext('Score'),
16 root
: gettext('Superuser'),
17 admin
: gettext('Administrator'),
18 helpdesk
: gettext('Help Desk'),
19 qmanager
: gettext('Quarantine Manager'),
20 audit
: gettext('Auditor'),
23 format_user_role: function(role
) {
24 return PMG
.Utils
.user_role_text
[role
] || role
;
28 who
: gettext('Who Objects'),
29 what
: gettext('What Objects'),
30 when
: gettext('When Objects'),
31 action
: gettext('Action Objects'),
32 from: gettext('From'),
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> ',
42 to
: '<span class="fa fa-fw fa-user-circle"></span> ',
56 icon_status_map_class
: {
67 icon_status_map_color
: {
74 format_status_icon: function(status
) {
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> ';
80 format_oclass: function(oclass
) {
81 var icon
= PMG
.Utils
.oclass_icon
[oclass
] || '';
82 var text
= PMG
.Utils
.oclass_text
[oclass
] || oclass
;
86 rule_direction_text
: {
89 2: gettext('In & Out'),
92 rule_direction_icon
: {
93 0: '<span class="fa fa-fw fa-long-arrow-left"></span> ',
94 1: '<span class="fa fa-fw fa-long-arrow-right"></span> ',
95 2: '<span class="fa fa-fw fa-exchange"></span> ',
98 format_rule_direction: function(dir
) {
99 var icon
= PMG
.Utils
.rule_direction_icon
[dir
] || '';
100 var text
= PMG
.Utils
.rule_direction_text
[dir
] || dir
;
104 format_otype: function(otype
) {
105 var editor
= PMG
.Utils
.object_editors
[otype
];
106 var iconCls
= 'fa fa-question-circle';
108 var icon
= '<span class="fa-fw ' + (editor
.iconCls
|| iconCls
) + '"></span> ';
109 return icon
+ editor
.subject
;
112 return '<span class="fa-fw ' + iconCls
+ '"></span> unknown';
115 format_ldap_protocol: function(p
) {
116 if (p
=== undefined) { return 'LDAP'; }
117 if (p
=== 'ldap') { return 'LDAP'; }
118 if (p
=== 'ldaps') { return 'LDAPS'; }
119 if (p
=== 'ldap+starttls') { return 'LDAP+STARTTLS'; }
123 convert_field_to_per_min: function(value
, record
) {
124 return value
/(record.data.timespan/60);
129 onlineHelp
: 'pmg_mailfilter_regex',
130 iconCls
: 'fa fa-filter',
131 xtype
: 'proxmoxWindowEdit',
133 subject
: gettext("Regular Expression"),
141 fieldLabel
: gettext("Regular Expression"),
145 fieldLabel
: gettext('Test String'),
146 xtype
: 'pmgRegexTester',
148 regexFieldReference
: 'regex',
153 onlineHelp
: 'pmgconfig_ldap',
154 iconCls
: 'fa fa-users',
155 xtype
: 'pmgLDAPGroupEditor',
157 subject
: gettext("LDAP Group"),
160 onlineHelp
: 'pmgconfig_ldap',
161 iconCls
: 'fa fa-user',
162 xtype
: 'pmgLDAPUserEditor',
164 subject
: gettext("LDAP User"),
167 onlineHelp
: 'pmg_mailfilter_regex',
168 iconCls
: 'fa fa-filter',
169 xtype
: 'proxmoxWindowEdit',
170 subdir
: 'receiver_regex',
171 subject
: gettext("Regular Expression"),
179 fieldLabel
: gettext("Regular Expression"),
184 onlineHelp
: 'pmg_mailfilter_who',
185 iconCls
: 'fa fa-envelope-o',
186 xtype
: 'proxmoxWindowEdit',
188 subject
: gettext("E-Mail"),
194 fieldLabel
: gettext("E-Mail"),
199 onlineHelp
: 'pmg_mailfilter_who',
200 iconCls
: 'fa fa-envelope-o',
201 xtype
: 'proxmoxWindowEdit',
203 subject
: gettext("E-Mail"),
210 fieldLabel
: gettext("E-Mail"),
215 onlineHelp
: 'pmg_mailfilter_who',
216 iconCls
: 'fa fa-globe',
217 xtype
: 'proxmoxWindowEdit',
219 subject
: gettext("Domain"),
225 fieldLabel
: gettext("Domain"),
230 onlineHelp
: 'pmg_mailfilter_who',
231 iconCls
: 'fa fa-globe',
232 xtype
: 'proxmoxWindowEdit',
233 subdir
: 'receiver_domain',
234 subject
: gettext("Domain"),
241 fieldLabel
: gettext("Domain"),
246 onlineHelp
: 'pmg_mailfilter_who',
247 iconCls
: 'fa fa-globe',
248 xtype
: 'proxmoxWindowEdit',
250 subject
: gettext("IP Address"),
256 fieldLabel
: gettext("IP Address"),
261 onlineHelp
: 'pmg_mailfilter_who',
262 iconCls
: 'fa fa-globe',
263 xtype
: 'proxmoxWindowEdit',
265 subject
: gettext("IP Network"),
271 fieldLabel
: gettext("IP Network"),
276 onlineHelp
: 'pmg_mailfilter_when',
277 iconCls
: 'fa fa-clock-o',
278 xtype
: 'proxmoxWindowEdit',
280 subject
: gettext("TimeFrame"),
286 fieldLabel
: gettext("Start Time"),
292 fieldLabel
: gettext("End Time"),
297 onlineHelp
: 'pmg_mailfilter_what',
298 iconCls
: 'fa fa-bullhorn',
299 xtype
: 'proxmoxWindowEdit',
300 subdir
: 'spamfilter',
301 subject
: gettext('Spam Filter'),
304 xtype
: 'proxmoxintegerfield',
308 fieldLabel
: gettext('Level'),
313 onlineHelp
: 'pmg_mailfilter_what',
314 iconCls
: 'fa fa-bug',
315 xtype
: 'proxmoxWindowEdit',
316 subdir
: 'virusfilter',
317 subject
: gettext('Virus Filter'),
319 // there are no parameters to give, so we simply submit it
321 show: function(win
) {
327 onlineHelp
: 'pmg_mailfilter_regex',
328 iconCls
: 'fa fa-code',
329 xtype
: 'proxmoxWindowEdit',
330 subdir
: 'matchfield',
331 subject
: gettext('Match Field'),
339 fieldLabel
: gettext('Field'),
347 fieldLabel
: gettext('Value'),
351 fieldLabel
: gettext('Test String'),
352 xtype
: 'pmgRegexTester',
353 regexFieldReference
: 'value',
358 onlineHelp
: 'pmg_mailfilter_what',
359 iconCls
: 'fa fa-file-image-o',
360 xtype
: 'proxmoxWindowEdit',
361 subdir
: 'contenttype',
363 subject
: gettext('Content Type Filter'),
367 displayField
: 'text',
369 valueField
: 'mimetype',
377 url
: '/api2/json/config/mimetypes',
380 fieldLabel
: gettext('Content Type'),
382 matchFieldWidth
: false,
384 change: function(cb
, value
) {
386 me
.up().down('displayfield').setValue(value
);
391 xtype
: 'displayfield',
392 fieldLabel
: gettext('Value'),
400 onlineHelp
: 'pmg_mailfilter_regex',
401 iconCls
: 'fa fa-file-o',
402 xtype
: 'proxmoxWindowEdit',
403 subdir
: 'filenamefilter',
405 subject
: gettext('Match Filename'),
410 reference
: 'filename',
411 fieldLabel
: gettext('Filename'),
417 fieldLabel
: gettext('Test String'),
419 xtype
: 'pmgRegexTester',
420 regexFieldReference
: 'filename',
425 onlineHelp
: 'pmg_mailfilter_what',
426 iconCls
: 'fa fa-file-archive-o',
427 xtype
: 'proxmoxWindowEdit',
428 subdir
: 'archivefilter',
430 subject
: gettext('Archive Filter'),
434 displayField
: 'text',
436 valueField
: 'mimetype',
444 url
: '/api2/json/config/mimetypes',
447 fieldLabel
: gettext('Content Type'),
449 matchFieldWidth
: false,
451 change: function(cb
, value
) {
453 me
.up().down('displayfield').setValue(value
);
458 xtype
: 'displayfield',
459 fieldLabel
: gettext('Value'),
467 onlineHelp
: 'pmg_mailfilter_regex',
468 iconCls
: 'fa fa-file-archive-o',
469 xtype
: 'proxmoxWindowEdit',
470 subdir
: 'archivefilenamefilter',
472 subject
: gettext('Match Archive Filename'),
477 reference
: 'filename',
478 fieldLabel
: gettext('Filename'),
484 fieldLabel
: gettext('Test String'),
486 xtype
: 'pmgRegexTester',
487 regexFieldReference
: 'filename',
492 onlineHelp
: 'pmg_mailfilter_action',
493 xtype
: 'proxmoxWindowEdit',
494 subdir
: 'notification',
495 subject
: gettext('Notification'),
502 fieldLabel
: gettext('Name'),
505 xtype
: 'textareafield',
507 fieldLabel
: gettext("Comment"),
514 fieldLabel
: gettext('Receiver'),
520 value
: 'Notification: __SUBJECT__',
521 fieldLabel
: gettext('Subject'),
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" +
539 fieldLabel
: gettext('Body'),
542 xtype
: 'proxmoxcheckbox',
544 fieldLabel
: gettext("Attach orig. Mail"),
549 onlineHelp
: 'pmg_mailfilter_action',
550 xtype
: 'proxmoxWindowEdit',
552 subject
: gettext('Header Attribute'),
559 fieldLabel
: gettext('Name'),
562 xtype
: 'textareafield',
564 fieldLabel
: gettext("Comment"),
570 fieldLabel
: gettext('Field'),
577 fieldLabel
: gettext('Value'),
582 onlineHelp
: 'pmg_mailfilter_action',
583 xtype
: 'proxmoxWindowEdit',
585 subject
: gettext('BCC'),
592 fieldLabel
: gettext('Name'),
595 xtype
: 'textareafield',
597 fieldLabel
: gettext("Comment"),
603 fieldLabel
: gettext("Target"),
606 xtype
: 'proxmoxcheckbox',
609 fieldLabel
: gettext("send orig. Mail"),
615 onlineHelp
: 'pmg_mailfilter_action',
616 xtype
: 'proxmoxWindowEdit',
617 subdir
: 'removeattachments',
618 subject
: gettext('Remove Attachments'),
628 fieldLabel
: gettext('Name'),
631 xtype
: 'textareafield',
633 fieldLabel
: gettext("Comment"),
636 xtype
: 'textareafield',
640 fieldLabel
: gettext("Text Replacement"),
643 xtype
: 'proxmoxcheckbox',
646 fieldLabel
: gettext("Remove all attachments"),
649 xtype
: 'proxmoxcheckbox',
652 fieldLabel
: gettext("Copy orignal mail to Attachment Quarantine"),
657 onlineHelp
: 'pmg_mailfilter_action',
658 xtype
: 'proxmoxWindowEdit',
659 subdir
: 'disclaimer',
660 subject
: gettext('Disclaimer'),
667 fieldLabel
: gettext('Name'),
670 xtype
: 'textareafield',
672 fieldLabel
: gettext("Comment"),
675 xtype
: 'textareafield',
679 fieldLabel
: gettext("Disclaimer"),
685 updateLoginData: function(data
) {
686 Proxmox
.CSRFPreventionToken
= data
.CSRFPreventionToken
;
687 Proxmox
.UserName
= data
.username
;
688 Ext
.util
.Cookies
.set('PMGAuthCookie', data
.ticket
, null, '/', null, true);
691 quarantineActionExtracted
: false,
693 extractQuarantineAction: function() {
694 if (PMG
.Utils
.quarantineActionExtracted
) {
698 PMG
.Utils
.quarantineActionExtracted
= true;
700 let qs
= Ext
.Object
.fromQueryString(location
.search
);
702 let cselect
= qs
.cselect
;
703 let action
= qs
.action
;
704 let dateString
= qs
.date
;
707 let date
= new Date(dateString
).getTime()/1000;
709 // set from date for QuarantineList
710 PMG
.QuarantineList
.from = date
;
718 var newsearch
= Ext
.Object
.toQueryString(qs
);
720 var newurl
= location
.protocol
+ "//" + location
.host
+ location
.pathname
;
721 if (newsearch
) { newurl
+= '?' + newsearch
; }
722 newurl
+= location
.hash
;
724 if (window
.history
) {
725 window
.history
.pushState({ path
: newurl
}, '', newurl
);
728 if (action
|| cselect
) {
737 doQuarantineAction: function(action
, id
, callback
) {
738 Proxmox
.Utils
.API2Request({
739 url
: '/quarantine/content/',
745 failure: function(response
, opts
) {
746 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);
748 success: function(response
, opts
) {
749 let count
= id
.split(';').length
;
751 ? gettext("Action '{0}' for '{1}' items successful")
752 : gettext("Action '{0}' successful")
754 let message
= Ext
.String
.format(fmt
, action
, count
);
755 let title
= Ext
.String
.format("{0} successful", Ext
.String
.capitalize(action
));
762 slideBackDuration
: 250,
763 slideBackAnimation
: 'easeOut',
764 iconCls
: 'fa fa-check',
768 if (Ext
.isFunction(callback
)) {
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 const type
= text
.split('/')[0];
791 iconCls
= `fa-file-${type}-o`;
793 case 'application': {
794 const 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 from = Ext
.String
.format(gettext("{0} on behalf of {1}"),
815 return '<small>' + from + '</small><br>' + subject
;
818 constructor: function() {
821 // do whatever you want here
822 Proxmox
.Utils
.override_task_descriptions({
823 applycustomscores
: ['', gettext('Apply custom SpamAssassin scores')],
824 avupdate
: ['', gettext('ClamAV update')],
825 backup
: ['', gettext('Backup')],
826 clustercreate
: ['', gettext('Create Cluster')],
827 clusterjoin
: ['', gettext('Join Cluster')],
828 restore
: ['', gettext('Restore')],
829 saupdate
: ['', gettext('SpamAssassin update')],