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 iconCls
: 'fa fa-filter',
130 xtype
: 'proxmoxWindowEdit',
132 subject
: gettext("Regular Expression"),
140 fieldLabel
: gettext("Regular Expression")
144 fieldLabel
: gettext('Test String'),
145 xtype
: 'pmgRegexTester',
146 regexFieldReference
: 'regex'
151 iconCls
: 'fa fa-users',
152 xtype
: 'pmgLDAPGroupEditor',
154 subject
: gettext("LDAP Group")
157 iconCls
: 'fa fa-user',
158 xtype
: 'pmgLDAPUserEditor',
160 subject
: gettext("LDAP User")
163 iconCls
: 'fa fa-filter',
164 xtype
: 'proxmoxWindowEdit',
165 subdir
: 'receiver_regex',
166 subject
: gettext("Regular Expression"),
174 fieldLabel
: gettext("Regular Expression")
179 iconCls
: 'fa fa-envelope-o',
180 xtype
: 'proxmoxWindowEdit',
182 subject
: gettext("E-Mail"),
188 fieldLabel
: gettext("E-Mail")
193 iconCls
: 'fa fa-envelope-o',
194 xtype
: 'proxmoxWindowEdit',
196 subject
: gettext("E-Mail"),
203 fieldLabel
: gettext("E-Mail")
208 iconCls
: 'fa fa-globe',
209 xtype
: 'proxmoxWindowEdit',
211 subject
: gettext("Domain"),
217 fieldLabel
: gettext("Domain")
222 iconCls
: 'fa fa-globe',
223 xtype
: 'proxmoxWindowEdit',
224 subdir
: 'receiver_domain',
225 subject
: gettext("Domain"),
232 fieldLabel
: gettext("Domain")
237 iconCls
: 'fa fa-globe',
238 xtype
: 'proxmoxWindowEdit',
240 subject
: gettext("IP Address"),
246 fieldLabel
: gettext("IP Address")
251 iconCls
: 'fa fa-globe',
252 xtype
: 'proxmoxWindowEdit',
254 subject
: gettext("IP Network"),
260 fieldLabel
: gettext("IP Network")
265 iconCls
: 'fa fa-clock-o',
266 xtype
: 'proxmoxWindowEdit',
268 subject
: gettext("TimeFrame"),
274 fieldLabel
: gettext("Start Time")
280 fieldLabel
: gettext("End Time")
285 iconCls
: 'fa fa-bullhorn',
286 xtype
: 'proxmoxWindowEdit',
287 subdir
: 'spamfilter',
288 subject
: gettext('Spam Filter'),
291 xtype
: 'proxmoxintegerfield',
295 fieldLabel
: gettext('Level')
300 iconCls
: 'fa fa-bug',
301 xtype
: 'proxmoxWindowEdit',
302 subdir
: 'virusfilter',
303 subject
: gettext('Virus Filter'),
305 // there are no parameters to give, so we simply submit it
307 show: function(win
) {
313 iconCls
: 'fa fa-code',
314 xtype
: 'proxmoxWindowEdit',
315 subdir
: 'matchfield',
316 subject
: gettext('Match Field'),
324 fieldLabel
: gettext('Field')
332 fieldLabel
: gettext('Value')
336 fieldLabel
: gettext('Test String'),
337 xtype
: 'pmgRegexTester',
338 regexFieldReference
: 'value'
343 iconCls
: 'fa fa-file-image-o',
344 xtype
: 'proxmoxWindowEdit',
345 subdir
: 'contenttype',
347 subject
: gettext('Content Type Filter'),
351 displayField
: 'text',
353 valueField
: 'mimetype',
361 url
: '/api2/json/config/mimetypes'
364 fieldLabel
: gettext('Content Type'),
366 matchFieldWidth
: false,
368 change: function(cb
, value
) {
370 me
.up().down('displayfield').setValue(value
);
375 xtype
: 'displayfield',
376 fieldLabel
: gettext('Value'),
384 iconCls
: 'fa fa-file-o',
385 xtype
: 'proxmoxWindowEdit',
386 subdir
: 'filenamefilter',
388 subject
: gettext('Match Filename'),
393 reference
: 'filename',
394 fieldLabel
: gettext('Filename'),
400 fieldLabel
: gettext('Test String'),
402 xtype
: 'pmgRegexTester',
403 regexFieldReference
: 'filename'
408 iconCls
: 'fa fa-file-archive-o',
409 xtype
: 'proxmoxWindowEdit',
410 subdir
: 'archivefilter',
412 subject
: gettext('Archive Filter'),
416 displayField
: 'text',
418 valueField
: 'mimetype',
426 url
: '/api2/json/config/mimetypes'
429 fieldLabel
: gettext('Content Type'),
431 matchFieldWidth
: false,
433 change: function(cb
, value
) {
435 me
.up().down('displayfield').setValue(value
);
440 xtype
: 'displayfield',
441 fieldLabel
: gettext('Value'),
449 xtype
: 'proxmoxWindowEdit',
450 subdir
: 'notification',
451 subject
: gettext('Notification'),
458 fieldLabel
: gettext('Name')
461 xtype
: 'textareafield',
463 fieldLabel
: gettext("Description")
470 fieldLabel
: gettext('Receiver')
476 value
: 'Notification: __SUBJECT__',
477 fieldLabel
: gettext('Subject')
486 "Proxmox Notifcation:\n\n" +
487 "Sender: __SENDER__\n" +
488 "Receiver: __RECEIVERS__\n" +
489 "Targets: __TARGETS__\n\n" +
490 "Subject: __SUBJECT__\n\n" +
491 "Matching Rule: __RULE__\n\n" +
492 "__RULE_INFO__\n\n" +
495 fieldLabel
: gettext('Body')
498 xtype
: 'proxmoxcheckbox',
500 fieldLabel
: gettext("Attach orig. Mail")
505 xtype
: 'proxmoxWindowEdit',
507 subject
: gettext('Header Attribute'),
514 fieldLabel
: gettext('Name')
517 xtype
: 'textareafield',
519 fieldLabel
: gettext("Description")
525 fieldLabel
: gettext('Field')
532 fieldLabel
: gettext('Value')
537 xtype
: 'proxmoxWindowEdit',
539 subject
: gettext('BCC'),
546 fieldLabel
: gettext('Name')
549 xtype
: 'textareafield',
551 fieldLabel
: gettext("Description")
557 fieldLabel
: gettext("Target")
560 xtype
: 'proxmoxcheckbox',
563 fieldLabel
: gettext("send orig. Mail")
569 xtype
: 'proxmoxWindowEdit',
570 subdir
: 'removeattachments',
571 subject
: gettext('Remove Attachments'),
581 fieldLabel
: gettext('Name')
584 xtype
: 'textareafield',
586 fieldLabel
: gettext("Description")
589 xtype
: 'textareafield',
593 fieldLabel
: gettext("Text Replacement")
596 xtype
: 'proxmoxcheckbox',
599 fieldLabel
: gettext("Remove all attachments")
604 xtype
: 'proxmoxWindowEdit',
605 subdir
: 'disclaimer',
606 subject
: gettext('Disclaimer'),
613 fieldLabel
: gettext('Name')
616 xtype
: 'textareafield',
618 fieldLabel
: gettext("Description")
621 xtype
: 'textareafield',
625 fieldLabel
: gettext("Disclaimer")
631 updateLoginData: function(data
) {
632 Proxmox
.CSRFPreventionToken
= data
.CSRFPreventionToken
;
633 Proxmox
.UserName
= data
.username
;
634 Ext
.util
.Cookies
.set('PMGAuthCookie', data
.ticket
, null, '/', null, true );
637 quarantineActionExtracted
: false,
639 extractQuarantineAction: function() {
641 if (PMG
.Utils
.quarantineActionExtracted
) { return; }
643 PMG
.Utils
.quarantineActionExtracted
= true;
645 var qs
= Ext
.Object
.fromQueryString(location
.search
);
647 var cselect
= qs
.cselect
;
648 var action
= qs
.action
;
649 var ticket
= qs
.ticket
;
650 var dateString
= qs
.date
;
653 var date
= new Date(dateString
).getTime()/1000;
655 // set from date for QuarantineList
656 /*jslint confusion: true*/
657 /*from is a string above and number here */
658 PMG
.QuarantineList
.from = date
;
659 /*jslint confusion: false*/
667 var newsearch
= Ext
.Object
.toQueryString(qs
);
669 var newurl
= location
.protocol
+ "//" + location
.host
+ location
.pathname
;
670 if (newsearch
) { newurl
+= '?' + newsearch
; }
671 newurl
+= location
.hash
;
673 if (window
.history
) {
674 window
.history
.pushState({ path
:newurl
}, '', newurl
);
677 if (action
|| cselect
) {
678 return { action
: action
, cselect
: cselect
};
682 doQuarantineAction: function(action
, id
, callback
) {
683 var count
= id
.split(';').length
;
684 var successMessage
= "Action '{0}'";
686 successMessage
+= " for '{1}' items";
688 successMessage
+= " successful";
690 /*jslint confusion: true*/
691 /*format is string and function*/
692 Proxmox
.Utils
.API2Request({
693 url
: '/quarantine/content/',
699 failure: function(response
, opts
) {
700 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);
702 success: function(response
, opts
) {
703 var win
= Ext
.create('Ext.window.MessageBox',{
704 closeAction
: 'destroy'
706 title
: gettext('Info'),
707 message
: Ext
.String
.format(successMessage
, action
, count
),
709 icon
: Ext
.MessageBox
.INFO
712 if (Ext
.isFunction(callback
)) {
717 /*jslint confusion: false*/
720 sender_renderer: function(value
, metaData
, rec
) {
721 var subject
= Ext
.htmlEncode(value
);
722 var from = Ext
.htmlEncode(rec
.data
.from);
723 var sender
= Ext
.htmlEncode(rec
.data
.sender
);
725 /*jslint confusion: true*/
726 /*format is a string above*/
727 from = Ext
.String
.format(gettext("{0} on behalf of {1}"),
729 /*jslint confusion: false*/
731 return '<small>' + from + '</small><br>' + subject
;
734 constructor: function() {
737 // do whatever you want here