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'; }
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_action',
468 xtype
: 'proxmoxWindowEdit',
469 subdir
: 'notification',
470 subject
: gettext('Notification'),
477 fieldLabel
: gettext('Name')
480 xtype
: 'textareafield',
482 fieldLabel
: gettext("Description")
489 fieldLabel
: gettext('Receiver')
495 value
: 'Notification: __SUBJECT__',
496 fieldLabel
: gettext('Subject')
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" +
514 fieldLabel
: gettext('Body')
517 xtype
: 'proxmoxcheckbox',
519 fieldLabel
: gettext("Attach orig. Mail")
524 onlineHelp
: 'pmg_mailfilter_action',
525 xtype
: 'proxmoxWindowEdit',
527 subject
: gettext('Header Attribute'),
534 fieldLabel
: gettext('Name')
537 xtype
: 'textareafield',
539 fieldLabel
: gettext("Description")
545 fieldLabel
: gettext('Field')
552 fieldLabel
: gettext('Value')
557 onlineHelp
: 'pmg_mailfilter_action',
558 xtype
: 'proxmoxWindowEdit',
560 subject
: gettext('BCC'),
567 fieldLabel
: gettext('Name')
570 xtype
: 'textareafield',
572 fieldLabel
: gettext("Description")
578 fieldLabel
: gettext("Target")
581 xtype
: 'proxmoxcheckbox',
584 fieldLabel
: gettext("send orig. Mail")
590 onlineHelp
: 'pmg_mailfilter_action',
591 xtype
: 'proxmoxWindowEdit',
592 subdir
: 'removeattachments',
593 subject
: gettext('Remove Attachments'),
603 fieldLabel
: gettext('Name')
606 xtype
: 'textareafield',
608 fieldLabel
: gettext("Description")
611 xtype
: 'textareafield',
615 fieldLabel
: gettext("Text Replacement")
618 xtype
: 'proxmoxcheckbox',
621 fieldLabel
: gettext("Remove all attachments")
626 onlineHelp
: 'pmg_mailfilter_action',
627 xtype
: 'proxmoxWindowEdit',
628 subdir
: 'disclaimer',
629 subject
: gettext('Disclaimer'),
636 fieldLabel
: gettext('Name')
639 xtype
: 'textareafield',
641 fieldLabel
: gettext("Description")
644 xtype
: 'textareafield',
648 fieldLabel
: gettext("Disclaimer")
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 );
660 quarantineActionExtracted
: false,
662 extractQuarantineAction: function() {
664 if (PMG
.Utils
.quarantineActionExtracted
) { return; }
666 PMG
.Utils
.quarantineActionExtracted
= true;
668 var qs
= Ext
.Object
.fromQueryString(location
.search
);
670 var cselect
= qs
.cselect
;
671 var action
= qs
.action
;
672 var ticket
= qs
.ticket
;
673 var dateString
= qs
.date
;
676 var date
= new Date(dateString
).getTime()/1000;
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*/
690 var newsearch
= Ext
.Object
.toQueryString(qs
);
692 var newurl
= location
.protocol
+ "//" + location
.host
+ location
.pathname
;
693 if (newsearch
) { newurl
+= '?' + newsearch
; }
694 newurl
+= location
.hash
;
696 if (window
.history
) {
697 window
.history
.pushState({ path
:newurl
}, '', newurl
);
700 if (action
|| cselect
) {
701 return { action
: action
, cselect
: cselect
};
705 doQuarantineAction: function(action
, id
, callback
) {
706 var count
= id
.split(';').length
;
707 var successMessage
= "Action '{0}'";
709 successMessage
+= " for '{1}' items";
711 successMessage
+= " successful";
713 /*jslint confusion: true*/
714 /*format is string and function*/
715 Proxmox
.Utils
.API2Request({
716 url
: '/quarantine/content/',
722 failure: function(response
, opts
) {
723 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);
725 success: function(response
, opts
) {
726 var win
= Ext
.create('Ext.window.MessageBox',{
727 closeAction
: 'destroy'
729 title
: gettext('Info'),
730 message
: Ext
.String
.format(successMessage
, action
, count
),
732 icon
: Ext
.MessageBox
.INFO
735 if (Ext
.isFunction(callback
)) {
740 /*jslint confusion: false*/
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
);
748 /*jslint confusion: true*/
749 /*format is a string above*/
750 from = Ext
.String
.format(gettext("{0} on behalf of {1}"),
752 /*jslint confusion: false*/
754 return '<small>' + from + '</small><br>' + subject
;
757 constructor: function() {
760 // do whatever you want here