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',
147 regexFieldReference
: 'regex'
152 onlineHelp
: 'pmgconfig_ldap',
153 iconCls
: 'fa fa-users',
154 xtype
: 'pmgLDAPGroupEditor',
156 subject
: gettext("LDAP Group")
159 onlineHelp
: 'pmgconfig_ldap',
160 iconCls
: 'fa fa-user',
161 xtype
: 'pmgLDAPUserEditor',
163 subject
: gettext("LDAP User")
166 onlineHelp
: 'pmg_mailfilter_regex',
167 iconCls
: 'fa fa-filter',
168 xtype
: 'proxmoxWindowEdit',
169 subdir
: 'receiver_regex',
170 subject
: gettext("Regular Expression"),
178 fieldLabel
: gettext("Regular Expression")
183 onlineHelp
: 'pmg_mailfilter_who',
184 iconCls
: 'fa fa-envelope-o',
185 xtype
: 'proxmoxWindowEdit',
187 subject
: gettext("E-Mail"),
193 fieldLabel
: gettext("E-Mail")
198 onlineHelp
: 'pmg_mailfilter_who',
199 iconCls
: 'fa fa-envelope-o',
200 xtype
: 'proxmoxWindowEdit',
202 subject
: gettext("E-Mail"),
209 fieldLabel
: gettext("E-Mail")
214 onlineHelp
: 'pmg_mailfilter_who',
215 iconCls
: 'fa fa-globe',
216 xtype
: 'proxmoxWindowEdit',
218 subject
: gettext("Domain"),
224 fieldLabel
: gettext("Domain")
229 onlineHelp
: 'pmg_mailfilter_who',
230 iconCls
: 'fa fa-globe',
231 xtype
: 'proxmoxWindowEdit',
232 subdir
: 'receiver_domain',
233 subject
: gettext("Domain"),
240 fieldLabel
: gettext("Domain")
245 onlineHelp
: 'pmg_mailfilter_who',
246 iconCls
: 'fa fa-globe',
247 xtype
: 'proxmoxWindowEdit',
249 subject
: gettext("IP Address"),
255 fieldLabel
: gettext("IP Address")
260 onlineHelp
: 'pmg_mailfilter_who',
261 iconCls
: 'fa fa-globe',
262 xtype
: 'proxmoxWindowEdit',
264 subject
: gettext("IP Network"),
270 fieldLabel
: gettext("IP Network")
275 onlineHelp
: 'pmg_mailfilter_when',
276 iconCls
: 'fa fa-clock-o',
277 xtype
: 'proxmoxWindowEdit',
279 subject
: gettext("TimeFrame"),
285 fieldLabel
: gettext("Start Time")
291 fieldLabel
: gettext("End Time")
296 onlineHelp
: 'pmg_mailfilter_what',
297 iconCls
: 'fa fa-bullhorn',
298 xtype
: 'proxmoxWindowEdit',
299 subdir
: 'spamfilter',
300 subject
: gettext('Spam Filter'),
303 xtype
: 'proxmoxintegerfield',
307 fieldLabel
: gettext('Level')
312 onlineHelp
: 'pmg_mailfilter_what',
313 iconCls
: 'fa fa-bug',
314 xtype
: 'proxmoxWindowEdit',
315 subdir
: 'virusfilter',
316 subject
: gettext('Virus Filter'),
318 // there are no parameters to give, so we simply submit it
320 show: function(win
) {
326 onlineHelp
: 'pmg_mailfilter_regex',
327 iconCls
: 'fa fa-code',
328 xtype
: 'proxmoxWindowEdit',
329 subdir
: 'matchfield',
330 subject
: gettext('Match Field'),
338 fieldLabel
: gettext('Field')
346 fieldLabel
: gettext('Value')
350 fieldLabel
: gettext('Test String'),
351 xtype
: 'pmgRegexTester',
352 regexFieldReference
: 'value'
357 onlineHelp
: 'pmg_mailfilter_what',
358 iconCls
: 'fa fa-file-image-o',
359 xtype
: 'proxmoxWindowEdit',
360 subdir
: 'contenttype',
362 subject
: gettext('Content Type Filter'),
366 displayField
: 'text',
368 valueField
: 'mimetype',
376 url
: '/api2/json/config/mimetypes'
379 fieldLabel
: gettext('Content Type'),
381 matchFieldWidth
: false,
383 change: function(cb
, value
) {
385 me
.up().down('displayfield').setValue(value
);
390 xtype
: 'displayfield',
391 fieldLabel
: gettext('Value'),
399 onlineHelp
: 'pmg_mailfilter_regex',
400 iconCls
: 'fa fa-file-o',
401 xtype
: 'proxmoxWindowEdit',
402 subdir
: 'filenamefilter',
404 subject
: gettext('Match Filename'),
409 reference
: 'filename',
410 fieldLabel
: gettext('Filename'),
416 fieldLabel
: gettext('Test String'),
418 xtype
: 'pmgRegexTester',
419 regexFieldReference
: 'filename'
424 onlineHelp
: 'pmg_mailfilter_what',
425 iconCls
: 'fa fa-file-archive-o',
426 xtype
: 'proxmoxWindowEdit',
427 subdir
: 'archivefilter',
429 subject
: gettext('Archive Filter'),
433 displayField
: 'text',
435 valueField
: 'mimetype',
443 url
: '/api2/json/config/mimetypes'
446 fieldLabel
: gettext('Content Type'),
448 matchFieldWidth
: false,
450 change: function(cb
, value
) {
452 me
.up().down('displayfield').setValue(value
);
457 xtype
: 'displayfield',
458 fieldLabel
: gettext('Value'),
466 onlineHelp
: 'pmg_mailfilter_action',
467 xtype
: 'proxmoxWindowEdit',
468 subdir
: 'notification',
469 subject
: gettext('Notification'),
476 fieldLabel
: gettext('Name')
479 xtype
: 'textareafield',
481 fieldLabel
: gettext("Description")
488 fieldLabel
: gettext('Receiver')
494 value
: 'Notification: __SUBJECT__',
495 fieldLabel
: gettext('Subject')
504 "Proxmox Notifcation:\n\n" +
505 "Sender: __SENDER__\n" +
506 "Receiver: __RECEIVERS__\n" +
507 "Targets: __TARGETS__\n\n" +
508 "Subject: __SUBJECT__\n\n" +
509 "Matching Rule: __RULE__\n\n" +
510 "__RULE_INFO__\n\n" +
513 fieldLabel
: gettext('Body')
516 xtype
: 'proxmoxcheckbox',
518 fieldLabel
: gettext("Attach orig. Mail")
523 onlineHelp
: 'pmg_mailfilter_action',
524 xtype
: 'proxmoxWindowEdit',
526 subject
: gettext('Header Attribute'),
533 fieldLabel
: gettext('Name')
536 xtype
: 'textareafield',
538 fieldLabel
: gettext("Description")
544 fieldLabel
: gettext('Field')
551 fieldLabel
: gettext('Value')
556 onlineHelp
: 'pmg_mailfilter_action',
557 xtype
: 'proxmoxWindowEdit',
559 subject
: gettext('BCC'),
566 fieldLabel
: gettext('Name')
569 xtype
: 'textareafield',
571 fieldLabel
: gettext("Description")
577 fieldLabel
: gettext("Target")
580 xtype
: 'proxmoxcheckbox',
583 fieldLabel
: gettext("send orig. Mail")
589 onlineHelp
: 'pmg_mailfilter_action',
590 xtype
: 'proxmoxWindowEdit',
591 subdir
: 'removeattachments',
592 subject
: gettext('Remove Attachments'),
602 fieldLabel
: gettext('Name')
605 xtype
: 'textareafield',
607 fieldLabel
: gettext("Description")
610 xtype
: 'textareafield',
614 fieldLabel
: gettext("Text Replacement")
617 xtype
: 'proxmoxcheckbox',
620 fieldLabel
: gettext("Remove all attachments")
625 onlineHelp
: 'pmg_mailfilter_action',
626 xtype
: 'proxmoxWindowEdit',
627 subdir
: 'disclaimer',
628 subject
: gettext('Disclaimer'),
635 fieldLabel
: gettext('Name')
638 xtype
: 'textareafield',
640 fieldLabel
: gettext("Description")
643 xtype
: 'textareafield',
647 fieldLabel
: gettext("Disclaimer")
653 updateLoginData: function(data
) {
654 Proxmox
.CSRFPreventionToken
= data
.CSRFPreventionToken
;
655 Proxmox
.UserName
= data
.username
;
656 Ext
.util
.Cookies
.set('PMGAuthCookie', data
.ticket
, null, '/', null, true );
659 quarantineActionExtracted
: false,
661 extractQuarantineAction: function() {
663 if (PMG
.Utils
.quarantineActionExtracted
) { return; }
665 PMG
.Utils
.quarantineActionExtracted
= true;
667 var qs
= Ext
.Object
.fromQueryString(location
.search
);
669 var cselect
= qs
.cselect
;
670 var action
= qs
.action
;
671 var ticket
= qs
.ticket
;
672 var dateString
= qs
.date
;
675 var date
= new Date(dateString
).getTime()/1000;
677 // set from date for QuarantineList
678 /*jslint confusion: true*/
679 /*from is a string above and number here */
680 PMG
.QuarantineList
.from = date
;
681 /*jslint confusion: false*/
689 var newsearch
= Ext
.Object
.toQueryString(qs
);
691 var newurl
= location
.protocol
+ "//" + location
.host
+ location
.pathname
;
692 if (newsearch
) { newurl
+= '?' + newsearch
; }
693 newurl
+= location
.hash
;
695 if (window
.history
) {
696 window
.history
.pushState({ path
:newurl
}, '', newurl
);
699 if (action
|| cselect
) {
700 return { action
: action
, cselect
: cselect
};
704 doQuarantineAction: function(action
, id
, callback
) {
705 var count
= id
.split(';').length
;
706 var successMessage
= "Action '{0}'";
708 successMessage
+= " for '{1}' items";
710 successMessage
+= " successful";
712 /*jslint confusion: true*/
713 /*format is string and function*/
714 Proxmox
.Utils
.API2Request({
715 url
: '/quarantine/content/',
721 failure: function(response
, opts
) {
722 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);
724 success: function(response
, opts
) {
725 var win
= Ext
.create('Ext.window.MessageBox',{
726 closeAction
: 'destroy'
728 title
: gettext('Info'),
729 message
: Ext
.String
.format(successMessage
, action
, count
),
731 icon
: Ext
.MessageBox
.INFO
734 if (Ext
.isFunction(callback
)) {
739 /*jslint confusion: false*/
742 sender_renderer: function(value
, metaData
, rec
) {
743 var subject
= Ext
.htmlEncode(value
);
744 var from = Ext
.htmlEncode(rec
.data
.from);
745 var sender
= Ext
.htmlEncode(rec
.data
.sender
);
747 /*jslint confusion: true*/
748 /*format is a string above*/
749 from = Ext
.String
.format(gettext("{0} on behalf of {1}"),
751 /*jslint confusion: false*/
753 return '<small>' + from + '</small><br>' + subject
;
756 constructor: function() {
759 // do whatever you want here