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> '
56 icon_status_map_class
: {
67 icon_status_map_color
: {
74 format_status_icon: function(status
) {
75 var icon
= PMG
.Utils
.icon_status_map_class
[status
] || 'question-circle';
76 var color
= PMG
.Utils
.icon_status_map_color
[status
] || '';
77 return '<i class="fa fa-' + icon
+ ' ' + color
+ '"></i> ';
80 format_oclass: function(oclass
) {
81 var icon
= PMG
.Utils
.oclass_icon
[oclass
] || '';
82 var text
= PMG
.Utils
.oclass_text
[oclass
] || oclass
;
86 rule_direction_text
: {
89 2: gettext('In & Out')
92 rule_direction_icon
: {
93 0: '<span class="fa fa-fw fa-long-arrow-left"></span> ',
94 1: '<span class="fa fa-fw fa-long-arrow-right"></span> ',
95 2: '<span class="fa fa-fw fa-exchange"></span> '
98 format_rule_direction: function(dir
) {
99 var icon
= PMG
.Utils
.rule_direction_icon
[dir
] || '';
100 var text
= PMG
.Utils
.rule_direction_text
[dir
] || dir
;
104 format_otype: function(otype
) {
105 var editor
= PMG
.Utils
.object_editors
[otype
];
106 var iconCls
= 'fa fa-question-circle';
108 var icon
= '<span class="fa-fw ' + (editor
.iconCls
|| iconCls
) + '"></span> ';
109 return icon
+ editor
.subject
;
112 return '<span class="fa-fw ' + iconCls
+ '"></span> unknown';
115 format_ldap_protocol: function(p
) {
116 if (p
=== undefined) { return 'LDAP'; }
117 if (p
=== 'ldap') { return 'LDAP'; }
118 if (p
=== 'ldaps') { return 'LDAPS'; }
122 convert_field_to_per_min: function(value
, record
) {
123 return (value
/(record.data.timespan/60));
128 iconCls
: 'fa fa-filter',
129 xtype
: 'proxmoxWindowEdit',
131 subject
: gettext("Regular Expression"),
139 fieldLabel
: gettext("Regular Expression")
143 fieldLabel
: gettext('Test String'),
144 xtype
: 'pmgRegexTester',
145 regexFieldReference
: 'regex'
150 iconCls
: 'fa fa-users',
151 xtype
: 'pmgLDAPGroupEditor',
153 subject
: gettext("LDAP Group")
156 iconCls
: 'fa fa-user',
157 xtype
: 'pmgLDAPUserEditor',
159 subject
: gettext("LDAP User")
162 iconCls
: 'fa fa-filter',
163 xtype
: 'proxmoxWindowEdit',
164 subdir
: 'receiver_regex',
165 subject
: gettext("Regular Expression"),
173 fieldLabel
: gettext("Regular Expression")
178 iconCls
: 'fa fa-envelope-o',
179 xtype
: 'proxmoxWindowEdit',
181 subject
: gettext("Email"),
187 fieldLabel
: gettext("Email")
192 iconCls
: 'fa fa-envelope-o',
193 xtype
: 'proxmoxWindowEdit',
195 subject
: gettext("Email"),
202 fieldLabel
: gettext("Email")
207 iconCls
: 'fa fa-globe',
208 xtype
: 'proxmoxWindowEdit',
210 subject
: gettext("Domain"),
216 fieldLabel
: gettext("Domain")
221 iconCls
: 'fa fa-globe',
222 xtype
: 'proxmoxWindowEdit',
223 subdir
: 'receiver_domain',
224 subject
: gettext("Domain"),
231 fieldLabel
: gettext("Domain")
236 iconCls
: 'fa fa-globe',
237 xtype
: 'proxmoxWindowEdit',
239 subject
: gettext("IP Address"),
245 fieldLabel
: gettext("IP Address")
250 iconCls
: 'fa fa-globe',
251 xtype
: 'proxmoxWindowEdit',
253 subject
: gettext("IP Network"),
259 fieldLabel
: gettext("IP Network")
264 iconCls
: 'fa fa-clock-o',
265 xtype
: 'proxmoxWindowEdit',
267 subject
: gettext("TimeFrame"),
273 fieldLabel
: gettext("Start Time")
279 fieldLabel
: gettext("End Time")
284 iconCls
: 'fa fa-bullhorn',
285 xtype
: 'proxmoxWindowEdit',
286 subdir
: 'spamfilter',
287 subject
: gettext('Spam Filter'),
290 xtype
: 'proxmoxintegerfield',
294 fieldLabel
: gettext('Level')
299 iconCls
: 'fa fa-bug',
300 xtype
: 'proxmoxWindowEdit',
301 subdir
: 'virusfilter',
302 subject
: gettext('Virus Filter'),
304 // there are no parameters to give, so we simply submit it
306 show: function(win
) {
312 iconCls
: 'fa fa-code',
313 xtype
: 'proxmoxWindowEdit',
314 subdir
: 'matchfield',
315 subject
: gettext('Match Field'),
323 fieldLabel
: gettext('Field')
331 fieldLabel
: gettext('Value')
335 fieldLabel
: gettext('Test String'),
336 xtype
: 'pmgRegexTester',
337 regexFieldReference
: 'value'
342 iconCls
: 'fa fa-file-image-o',
343 xtype
: 'proxmoxWindowEdit',
344 subdir
: 'contenttype',
346 subject
: gettext('Content Type Filter'),
350 displayField
: 'text',
352 valueField
: 'mimetype',
360 url
: '/api2/json/config/mimetypes'
363 fieldLabel
: gettext('Content Type'),
365 matchFieldWidth
: false,
367 change: function(cb
, value
) {
369 me
.up().down('displayfield').setValue(value
);
374 xtype
: 'displayfield',
375 fieldLabel
: gettext('Value'),
383 iconCls
: 'fa fa-file-o',
384 xtype
: 'proxmoxWindowEdit',
385 subdir
: 'filenamefilter',
387 subject
: gettext('Match Filename'),
392 reference
: 'filename',
393 fieldLabel
: gettext('Filename'),
399 fieldLabel
: gettext('Test String'),
401 xtype
: 'pmgRegexTester',
402 regexFieldReference
: 'filename'
407 iconCls
: 'fa fa-file-archive-o',
408 xtype
: 'proxmoxWindowEdit',
409 subdir
: 'archivefilter',
411 subject
: gettext('Archive Filter'),
415 displayField
: 'text',
417 valueField
: 'mimetype',
425 url
: '/api2/json/config/mimetypes'
428 fieldLabel
: gettext('Content Type'),
430 matchFieldWidth
: false,
432 change: function(cb
, value
) {
434 me
.up().down('displayfield').setValue(value
);
439 xtype
: 'displayfield',
440 fieldLabel
: gettext('Value'),
448 xtype
: 'proxmoxWindowEdit',
449 subdir
: 'notification',
450 subject
: gettext('Notification'),
457 fieldLabel
: gettext('Name')
460 xtype
: 'textareafield',
462 fieldLabel
: gettext("Description")
469 fieldLabel
: gettext('Receiver')
475 value
: 'Notification: __SUBJECT__',
476 fieldLabel
: gettext('Subject')
485 "Proxmox Notifcation:\n\n" +
486 "Sender: __SENDER__\n" +
487 "Receiver: __RECEIVERS__\n" +
488 "Targets: __TARGETS__\n\n" +
489 "Subject: __SUBJECT__\n\n" +
490 "Matching Rule: __RULE__\n\n" +
491 "__RULE_INFO__\n\n" +
494 fieldLabel
: gettext('Body')
497 xtype
: 'proxmoxcheckbox',
499 fieldLabel
: gettext("Attach orig. Mail")
504 xtype
: 'proxmoxWindowEdit',
506 subject
: gettext('Header Attribute'),
513 fieldLabel
: gettext('Name')
516 xtype
: 'textareafield',
518 fieldLabel
: gettext("Description")
524 fieldLabel
: gettext('Field')
531 fieldLabel
: gettext('Value')
536 xtype
: 'proxmoxWindowEdit',
538 subject
: gettext('BCC'),
545 fieldLabel
: gettext('Name')
548 xtype
: 'textareafield',
550 fieldLabel
: gettext("Description")
556 fieldLabel
: gettext("Target")
559 xtype
: 'proxmoxcheckbox',
562 fieldLabel
: gettext("send orig. Mail")
568 xtype
: 'proxmoxWindowEdit',
569 subdir
: 'removeattachments',
570 subject
: gettext('Remove Attachments'),
580 fieldLabel
: gettext('Name')
583 xtype
: 'textareafield',
585 fieldLabel
: gettext("Description")
588 xtype
: 'textareafield',
592 fieldLabel
: gettext("Text Replacement")
595 xtype
: 'proxmoxcheckbox',
598 fieldLabel
: gettext("Remove all attachments")
603 xtype
: 'proxmoxWindowEdit',
604 subdir
: 'disclaimer',
605 subject
: gettext('Disclaimer'),
612 fieldLabel
: gettext('Name')
615 xtype
: 'textareafield',
617 fieldLabel
: gettext("Description")
620 xtype
: 'textareafield',
624 fieldLabel
: gettext("Disclaimer")
630 openVNCViewer: function(consoletype
, nodename
) {
631 var url
= Ext
.urlEncode({
632 console
: consoletype
, // upgrade or shell
636 var nw
= window
.open("?" + url
, '_blank',
637 "innerWidth=745,innerheight=427");
641 updateLoginData: function(data
) {
642 Proxmox
.CSRFPreventionToken
= data
.CSRFPreventionToken
;
643 Proxmox
.UserName
= data
.username
;
644 Ext
.util
.Cookies
.set('PMGAuthCookie', data
.ticket
, null, '/', null, true );
647 quarantineActionExtracted
: false,
649 extractQuarantineAction: function() {
651 if (PMG
.Utils
.quarantineActionExtracted
) { return; }
653 PMG
.Utils
.quarantineActionExtracted
= true;
655 var qs
= Ext
.Object
.fromQueryString(location
.search
);
657 var cselect
= qs
.cselect
;
658 var action
= qs
.action
;
659 var ticket
= qs
.ticket
;
660 var dateString
= qs
.date
;
663 var date
= new Date(dateString
).getTime()/1000;
665 // set from date for QuarantineList
666 /*jslint confusion: true*/
667 /*from is a string above and number here */
668 PMG
.QuarantineList
.from = date
;
669 /*jslint confusion: false*/
677 var newsearch
= Ext
.Object
.toQueryString(qs
);
679 var newurl
= location
.protocol
+ "//" + location
.host
+ location
.pathname
;
680 if (newsearch
) { newurl
+= '?' + newsearch
; }
681 newurl
+= location
.hash
;
683 if (window
.history
) {
684 window
.history
.pushState({ path
:newurl
}, '', newurl
);
687 if (action
|| cselect
) {
688 return { action
: action
, cselect
: cselect
};
692 doQuarantineAction: function(action
, id
, callback
) {
693 Proxmox
.Utils
.API2Request({
694 url
: '/quarantine/content/',
700 failure: function(response
, opts
) {
701 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);
703 success: function(response
, opts
) {
704 var win
= Ext
.create('Ext.window.MessageBox',{
705 closeAction
: 'destroy'
707 title
: gettext('Info'),
708 message
: "Action '" + action
+ ' ' +
711 icon
: Ext
.MessageBox
.INFO
714 if (Ext
.isFunction(callback
)) {
721 sender_renderer: function(value
, metaData
, rec
) {
722 var subject
= Ext
.htmlEncode(value
);
723 var from = Ext
.htmlEncode(rec
.data
.from);
724 var sender
= Ext
.htmlEncode(rec
.data
.sender
);
726 /*jslint confusion: true*/
727 /*format is a string above*/
728 from = Ext
.String
.format(gettext("{0} on behalf of {1}"),
730 /*jslint confusion: false*/
732 return '<small>' + from + '</small><br>' + subject
;
735 constructor: function() {
738 // do whatever you want here