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 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> '
87 format_status_icon: function(status
) {
88 var icon
= PMG
.Utils
.icon_status_map
[status
] || {};
89 return '<i class="fa fa-' + (icon
.fa
|| 'question-circle') + ' ' +
90 (icon
.color
|| '') + '"></i> ';
93 format_oclass: function(oclass
) {
94 var icon
= PMG
.Utils
.oclass_icon
[oclass
] || '';
95 var text
= PMG
.Utils
.oclass_text
[oclass
] || oclass
;
99 rule_direction_text
: {
102 2: gettext('In & Out')
105 rule_direction_icon
: {
106 0: '<span class="fa fa-fw fa-long-arrow-left"></span> ',
107 1: '<span class="fa fa-fw fa-long-arrow-right"></span> ',
108 2: '<span class="fa fa-fw fa-exchange"></span> '
111 format_rule_direction: function(dir
) {
112 var icon
= PMG
.Utils
.rule_direction_icon
[dir
] || '';
113 var text
= PMG
.Utils
.rule_direction_text
[dir
] || dir
;
117 format_otype: function(otype
) {
118 var editor
= PMG
.Utils
.object_editors
[otype
];
119 var iconCls
= 'fa fa-question-circle';
121 var icon
= '<span class="fa-fw ' + (editor
.iconCls
|| iconCls
) + '"></span> ';
122 return icon
+ editor
.subject
;
125 return '<span class="fa-fw ' + iconCls
+ '"></span> unknown';
128 format_ldap_protocol: function(p
) {
129 if (p
=== undefined) { return 'LDAP'; }
130 if (p
=== 'ldap') { return 'LDAP'; }
131 if (p
=== 'ldaps') { return 'LDAPS'; }
135 convert_field_to_per_min: function(value
, record
) {
136 return (value
/(record.data.timespan/60));
141 iconCls
: 'fa fa-filter',
142 xtype
: 'proxmoxWindowEdit',
144 subject
: gettext("Regular Expression"),
151 fieldLabel
: gettext("Regular Expression")
156 iconCls
: 'fa fa-users',
157 xtype
: 'pmgLDAPGroupEditor',
159 subject
: gettext("LDAP Group")
162 iconCls
: 'fa fa-user',
163 xtype
: 'pmgLDAPUserEditor',
165 subject
: gettext("LDAP User")
168 iconCls
: 'fa fa-filter',
169 xtype
: 'proxmoxWindowEdit',
170 subdir
: 'receiver_regex',
171 subject
: gettext("Regular Expression"),
179 fieldLabel
: gettext("Regular Expression")
184 iconCls
: 'fa fa-envelope-o',
185 xtype
: 'proxmoxWindowEdit',
187 subject
: gettext("Email"),
193 fieldLabel
: gettext("Email")
198 iconCls
: 'fa fa-envelope-o',
199 xtype
: 'proxmoxWindowEdit',
201 subject
: gettext("Email"),
208 fieldLabel
: gettext("Email")
213 iconCls
: 'fa fa-globe',
214 xtype
: 'proxmoxWindowEdit',
216 subject
: gettext("Domain"),
222 fieldLabel
: gettext("Domain")
227 iconCls
: 'fa fa-globe',
228 xtype
: 'proxmoxWindowEdit',
229 subdir
: 'receiver_domain',
230 subject
: gettext("Domain"),
237 fieldLabel
: gettext("Domain")
242 iconCls
: 'fa fa-globe',
243 xtype
: 'proxmoxWindowEdit',
245 subject
: gettext("IP Address"),
251 fieldLabel
: gettext("IP Address")
256 iconCls
: 'fa fa-globe',
257 xtype
: 'proxmoxWindowEdit',
259 subject
: gettext("IP Network"),
265 fieldLabel
: gettext("IP Network")
270 iconCls
: 'fa fa-clock-o',
271 xtype
: 'proxmoxWindowEdit',
273 subject
: gettext("TimeFrame"),
279 fieldLabel
: gettext("Start Time")
285 fieldLabel
: gettext("End Time")
290 iconCls
: 'fa fa-bullhorn',
291 xtype
: 'proxmoxWindowEdit',
292 subdir
: 'spamfilter',
293 subject
: gettext('Spam Filter'),
296 xtype
: 'proxmoxintegerfield',
300 fieldLabel
: gettext('Level')
305 iconCls
: 'fa fa-bug',
306 xtype
: 'proxmoxWindowEdit',
307 subdir
: 'virusfilter',
308 subject
: gettext('Virus Filter'),
310 // there are no parameters to give, so we simply submit it
312 show: function(win
) {
318 iconCls
: 'fa fa-code',
319 xtype
: 'proxmoxWindowEdit',
320 subdir
: 'matchfield',
321 subject
: gettext('Match Field'),
329 fieldLabel
: gettext('Field')
337 fieldLabel
: gettext('Value')
341 fieldLabel
: gettext('Test String'),
342 xtype
: 'pmgRegexTester',
343 regexFieldReference
: 'value'
348 iconCls
: 'fa fa-file-image-o',
349 xtype
: 'proxmoxWindowEdit',
350 subdir
: 'contenttype',
352 subject
: gettext('Content Type Filter'),
356 displayField
: 'text',
358 valueField
: 'mimetype',
366 url
: '/api2/json/config/mimetypes'
369 fieldLabel
: gettext('Content Type'),
371 matchFieldWidth
: false,
373 change: function(cb
, value
) {
375 me
.up().down('displayfield').setValue(value
);
380 xtype
: 'displayfield',
381 fieldLabel
: gettext('Value'),
389 iconCls
: 'fa fa-file-o',
390 xtype
: 'proxmoxWindowEdit',
391 subdir
: 'filenamefilter',
393 subject
: gettext('Match Filename'),
398 reference
: 'filename',
399 fieldLabel
: gettext('Filename'),
405 fieldLabel
: gettext('Test String'),
407 xtype
: 'pmgRegexTester',
408 regexFieldReference
: 'filename'
413 iconCls
: 'fa fa-file-archive-o',
414 xtype
: 'proxmoxWindowEdit',
415 subdir
: 'archivefilter',
417 subject
: gettext('Archive Filter'),
421 displayField
: 'text',
423 valueField
: 'mimetype',
431 url
: '/api2/json/config/mimetypes'
434 fieldLabel
: gettext('Content Type'),
436 matchFieldWidth
: false,
438 change: function(cb
, value
) {
440 me
.up().down('displayfield').setValue(value
);
445 xtype
: 'displayfield',
446 fieldLabel
: gettext('Value'),
454 xtype
: 'proxmoxWindowEdit',
455 subdir
: 'notification',
456 subject
: gettext('Notification'),
463 fieldLabel
: gettext('Name')
466 xtype
: 'textareafield',
468 fieldLabel
: gettext("Description")
475 fieldLabel
: gettext('Receiver')
481 value
: 'Notification: __SUBJECT__',
482 fieldLabel
: gettext('Subject')
491 "Proxmox Notifcation:\n\n" +
492 "Sender: __SENDER__\n" +
493 "Receiver: __RECEIVERS__\n" +
494 "Targets: __TARGETS__\n\n" +
495 "Subject: __SUBJECT__\n\n" +
496 "Matching Rule: __RULE__\n\n" +
497 "__RULE_INFO__\n\n" +
500 fieldLabel
: gettext('Body')
503 xtype
: 'proxmoxcheckbox',
505 fieldLabel
: gettext("Attach orig. Mail")
510 xtype
: 'proxmoxWindowEdit',
512 subject
: gettext('Header Attribute'),
519 fieldLabel
: gettext('Name')
522 xtype
: 'textareafield',
524 fieldLabel
: gettext("Description")
530 fieldLabel
: gettext('Field')
537 fieldLabel
: gettext('Value')
542 xtype
: 'proxmoxWindowEdit',
544 subject
: gettext('BCC'),
551 fieldLabel
: gettext('Name')
554 xtype
: 'textareafield',
556 fieldLabel
: gettext("Description")
562 fieldLabel
: gettext("Target")
565 xtype
: 'proxmoxcheckbox',
568 fieldLabel
: gettext("send orig. Mail")
574 xtype
: 'proxmoxWindowEdit',
575 subdir
: 'removeattachments',
576 subject
: gettext('Remove Attachments'),
586 fieldLabel
: gettext('Name')
589 xtype
: 'textareafield',
591 fieldLabel
: gettext("Description")
594 xtype
: 'textareafield',
598 fieldLabel
: gettext("Text Replacement")
601 xtype
: 'proxmoxcheckbox',
604 fieldLabel
: gettext("Remove all attachments")
609 xtype
: 'proxmoxWindowEdit',
610 subdir
: 'disclaimer',
611 subject
: gettext('Disclaimer'),
618 fieldLabel
: gettext('Name')
621 xtype
: 'textareafield',
623 fieldLabel
: gettext("Description")
626 xtype
: 'textareafield',
630 fieldLabel
: gettext("Disclaimer")
636 openVNCViewer: function(consoletype
, nodename
) {
637 var url
= Ext
.urlEncode({
638 console
: consoletype
, // upgrade or shell
642 var nw
= window
.open("?" + url
, '_blank',
643 "innerWidth=745,innerheight=427");
647 updateLoginData: function(data
) {
648 Proxmox
.CSRFPreventionToken
= data
.CSRFPreventionToken
;
649 Proxmox
.UserName
= data
.username
;
650 Ext
.util
.Cookies
.set('PMGAuthCookie', data
.ticket
, null, '/', null, true );
653 quarantineActionExtracted
: false,
655 extractQuarantineAction: function() {
657 if (PMG
.Utils
.quarantineActionExtracted
) { return; }
659 PMG
.Utils
.quarantineActionExtracted
= true;
661 var qs
= Ext
.Object
.fromQueryString(location
.search
);
663 var cselect
= qs
.cselect
;
664 var action
= qs
.action
;
665 var ticket
= qs
.ticket
;
671 var newsearch
= Ext
.Object
.toQueryString(qs
);
673 var newurl
= location
.protocol
+ "//" + location
.host
+ location
.pathname
;
674 if (newsearch
) { newurl
+= '?' + newsearch
; }
675 newurl
+= location
.hash
;
677 if (window
.history
) {
678 window
.history
.pushState({ path
:newurl
}, '', newurl
);
681 if (action
|| cselect
) {
682 return { action
: action
, cselect
: cselect
};
686 doQuarantineAction: function(action
, id
, callback
) {
687 Proxmox
.Utils
.API2Request({
688 url
: '/quarantine/content/',
694 failure: function(response
, opts
) {
695 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);
697 success: function(response
, opts
) {
698 var win
= Ext
.create('Ext.window.MessageBox',{
699 closeAction
: 'destroy'
701 title
: gettext('Info'),
702 message
: "Action '" + action
+ ' ' +
705 icon
: Ext
.MessageBox
.INFO
708 if (Ext
.isFunction(callback
)) {
715 sender_renderer: function(value
, metaData
, rec
) {
716 var subject
= Ext
.htmlEncode(value
);
717 var from = Ext
.htmlEncode(rec
.data
.from);
718 var sender
= Ext
.htmlEncode(rec
.data
.sender
);
720 from = Ext
.String
.format(gettext("{0} on behalf of {1}"),
723 return '<small>' + from + '</small><br>' + subject
;
726 constructor: function() {
729 // do whatever you want here