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"),
152 fieldLabel
: gettext("Regular Expression")
156 fieldLabel
: gettext('Test String'),
157 xtype
: 'pmgRegexTester',
158 regexFieldReference
: 'regex'
163 iconCls
: 'fa fa-users',
164 xtype
: 'pmgLDAPGroupEditor',
166 subject
: gettext("LDAP Group")
169 iconCls
: 'fa fa-user',
170 xtype
: 'pmgLDAPUserEditor',
172 subject
: gettext("LDAP User")
175 iconCls
: 'fa fa-filter',
176 xtype
: 'proxmoxWindowEdit',
177 subdir
: 'receiver_regex',
178 subject
: gettext("Regular Expression"),
186 fieldLabel
: gettext("Regular Expression")
191 iconCls
: 'fa fa-envelope-o',
192 xtype
: 'proxmoxWindowEdit',
194 subject
: gettext("Email"),
200 fieldLabel
: gettext("Email")
205 iconCls
: 'fa fa-envelope-o',
206 xtype
: 'proxmoxWindowEdit',
208 subject
: gettext("Email"),
215 fieldLabel
: gettext("Email")
220 iconCls
: 'fa fa-globe',
221 xtype
: 'proxmoxWindowEdit',
223 subject
: gettext("Domain"),
229 fieldLabel
: gettext("Domain")
234 iconCls
: 'fa fa-globe',
235 xtype
: 'proxmoxWindowEdit',
236 subdir
: 'receiver_domain',
237 subject
: gettext("Domain"),
244 fieldLabel
: gettext("Domain")
249 iconCls
: 'fa fa-globe',
250 xtype
: 'proxmoxWindowEdit',
252 subject
: gettext("IP Address"),
258 fieldLabel
: gettext("IP Address")
263 iconCls
: 'fa fa-globe',
264 xtype
: 'proxmoxWindowEdit',
266 subject
: gettext("IP Network"),
272 fieldLabel
: gettext("IP Network")
277 iconCls
: 'fa fa-clock-o',
278 xtype
: 'proxmoxWindowEdit',
280 subject
: gettext("TimeFrame"),
286 fieldLabel
: gettext("Start Time")
292 fieldLabel
: gettext("End Time")
297 iconCls
: 'fa fa-bullhorn',
298 xtype
: 'proxmoxWindowEdit',
299 subdir
: 'spamfilter',
300 subject
: gettext('Spam Filter'),
303 xtype
: 'proxmoxintegerfield',
307 fieldLabel
: gettext('Level')
312 iconCls
: 'fa fa-bug',
313 xtype
: 'proxmoxWindowEdit',
314 subdir
: 'virusfilter',
315 subject
: gettext('Virus Filter'),
317 // there are no parameters to give, so we simply submit it
319 show: function(win
) {
325 iconCls
: 'fa fa-code',
326 xtype
: 'proxmoxWindowEdit',
327 subdir
: 'matchfield',
328 subject
: gettext('Match Field'),
336 fieldLabel
: gettext('Field')
344 fieldLabel
: gettext('Value')
348 fieldLabel
: gettext('Test String'),
349 xtype
: 'pmgRegexTester',
350 regexFieldReference
: 'value'
355 iconCls
: 'fa fa-file-image-o',
356 xtype
: 'proxmoxWindowEdit',
357 subdir
: 'contenttype',
359 subject
: gettext('Content Type Filter'),
363 displayField
: 'text',
365 valueField
: 'mimetype',
373 url
: '/api2/json/config/mimetypes'
376 fieldLabel
: gettext('Content Type'),
378 matchFieldWidth
: false,
380 change: function(cb
, value
) {
382 me
.up().down('displayfield').setValue(value
);
387 xtype
: 'displayfield',
388 fieldLabel
: gettext('Value'),
396 iconCls
: 'fa fa-file-o',
397 xtype
: 'proxmoxWindowEdit',
398 subdir
: 'filenamefilter',
400 subject
: gettext('Match Filename'),
405 reference
: 'filename',
406 fieldLabel
: gettext('Filename'),
412 fieldLabel
: gettext('Test String'),
414 xtype
: 'pmgRegexTester',
415 regexFieldReference
: 'filename'
420 iconCls
: 'fa fa-file-archive-o',
421 xtype
: 'proxmoxWindowEdit',
422 subdir
: 'archivefilter',
424 subject
: gettext('Archive Filter'),
428 displayField
: 'text',
430 valueField
: 'mimetype',
438 url
: '/api2/json/config/mimetypes'
441 fieldLabel
: gettext('Content Type'),
443 matchFieldWidth
: false,
445 change: function(cb
, value
) {
447 me
.up().down('displayfield').setValue(value
);
452 xtype
: 'displayfield',
453 fieldLabel
: gettext('Value'),
461 xtype
: 'proxmoxWindowEdit',
462 subdir
: 'notification',
463 subject
: gettext('Notification'),
470 fieldLabel
: gettext('Name')
473 xtype
: 'textareafield',
475 fieldLabel
: gettext("Description")
482 fieldLabel
: gettext('Receiver')
488 value
: 'Notification: __SUBJECT__',
489 fieldLabel
: gettext('Subject')
498 "Proxmox Notifcation:\n\n" +
499 "Sender: __SENDER__\n" +
500 "Receiver: __RECEIVERS__\n" +
501 "Targets: __TARGETS__\n\n" +
502 "Subject: __SUBJECT__\n\n" +
503 "Matching Rule: __RULE__\n\n" +
504 "__RULE_INFO__\n\n" +
507 fieldLabel
: gettext('Body')
510 xtype
: 'proxmoxcheckbox',
512 fieldLabel
: gettext("Attach orig. Mail")
517 xtype
: 'proxmoxWindowEdit',
519 subject
: gettext('Header Attribute'),
526 fieldLabel
: gettext('Name')
529 xtype
: 'textareafield',
531 fieldLabel
: gettext("Description")
537 fieldLabel
: gettext('Field')
544 fieldLabel
: gettext('Value')
549 xtype
: 'proxmoxWindowEdit',
551 subject
: gettext('BCC'),
558 fieldLabel
: gettext('Name')
561 xtype
: 'textareafield',
563 fieldLabel
: gettext("Description")
569 fieldLabel
: gettext("Target")
572 xtype
: 'proxmoxcheckbox',
575 fieldLabel
: gettext("send orig. Mail")
581 xtype
: 'proxmoxWindowEdit',
582 subdir
: 'removeattachments',
583 subject
: gettext('Remove Attachments'),
593 fieldLabel
: gettext('Name')
596 xtype
: 'textareafield',
598 fieldLabel
: gettext("Description")
601 xtype
: 'textareafield',
605 fieldLabel
: gettext("Text Replacement")
608 xtype
: 'proxmoxcheckbox',
611 fieldLabel
: gettext("Remove all attachments")
616 xtype
: 'proxmoxWindowEdit',
617 subdir
: 'disclaimer',
618 subject
: gettext('Disclaimer'),
625 fieldLabel
: gettext('Name')
628 xtype
: 'textareafield',
630 fieldLabel
: gettext("Description")
633 xtype
: 'textareafield',
637 fieldLabel
: gettext("Disclaimer")
643 openVNCViewer: function(consoletype
, nodename
) {
644 var url
= Ext
.urlEncode({
645 console
: consoletype
, // upgrade or shell
649 var nw
= window
.open("?" + url
, '_blank',
650 "innerWidth=745,innerheight=427");
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 Proxmox
.Utils
.API2Request({
707 url
: '/quarantine/content/',
713 failure: function(response
, opts
) {
714 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);
716 success: function(response
, opts
) {
717 var win
= Ext
.create('Ext.window.MessageBox',{
718 closeAction
: 'destroy'
720 title
: gettext('Info'),
721 message
: "Action '" + action
+ ' ' +
724 icon
: Ext
.MessageBox
.INFO
727 if (Ext
.isFunction(callback
)) {
734 sender_renderer: function(value
, metaData
, rec
) {
735 var subject
= Ext
.htmlEncode(value
);
736 var from = Ext
.htmlEncode(rec
.data
.from);
737 var sender
= Ext
.htmlEncode(rec
.data
.sender
);
739 from = Ext
.String
.format(gettext("{0} on behalf of {1}"),
742 return '<small>' + from + '</small><br>' + subject
;
745 constructor: function() {
748 // do whatever you want here