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
];
120 return editor
.subject
;
125 format_ldap_protocol: function(p
) {
126 if (p
=== undefined) { return 'LDAP'; }
127 if (p
=== 'ldap') { return 'LDAP'; }
128 if (p
=== 'ldaps') { return 'LDAPS'; }
132 convert_field_to_per_min: function(value
, record
) {
133 return (value
/(record.data.timespan/60));
138 xtype
: 'proxmoxWindowEdit',
140 subject
: gettext("Regular Expression"),
147 fieldLabel
: gettext("Regular Expression")
152 xtype
: 'pmgLDAPGroupEditor',
154 subject
: gettext("LDAP Group")
157 xtype
: 'pmgLDAPUserEditor',
159 subject
: gettext("LDAP User")
162 xtype
: 'proxmoxWindowEdit',
163 subdir
: 'receiver_regex',
164 subject
: gettext("Regular Expression"),
172 fieldLabel
: gettext("Regular Expression")
177 xtype
: 'proxmoxWindowEdit',
179 subject
: gettext("Email"),
185 fieldLabel
: gettext("Email")
190 xtype
: 'proxmoxWindowEdit',
192 subject
: gettext("Email"),
199 fieldLabel
: gettext("Email")
204 xtype
: 'proxmoxWindowEdit',
206 subject
: gettext("Domain"),
212 fieldLabel
: gettext("Domain")
217 xtype
: 'proxmoxWindowEdit',
218 subdir
: 'receiver_domain',
219 subject
: gettext("Domain"),
226 fieldLabel
: gettext("Domain")
231 xtype
: 'proxmoxWindowEdit',
233 subject
: gettext("IP Address"),
239 fieldLabel
: gettext("IP Address")
244 xtype
: 'proxmoxWindowEdit',
246 subject
: gettext("IP Network"),
252 fieldLabel
: gettext("IP Network")
257 xtype
: 'proxmoxWindowEdit',
259 subject
: gettext("TimeFrame"),
265 fieldLabel
: gettext("Start Time")
271 fieldLabel
: gettext("End Time")
276 xtype
: 'proxmoxWindowEdit',
277 subdir
: 'spamfilter',
278 subject
: gettext('Spam Filter'),
281 xtype
: 'proxmoxintegerfield',
285 fieldLabel
: gettext('Level')
290 xtype
: 'proxmoxWindowEdit',
291 subdir
: 'virusfilter',
292 subject
: gettext('Virus Filter'),
294 // there are no parameters to give, so we simply submit it
296 show: function(win
) {
302 xtype
: 'proxmoxWindowEdit',
303 subdir
: 'matchfield',
304 subject
: gettext('Match Field'),
312 fieldLabel
: gettext('Field')
320 fieldLabel
: gettext('Value')
324 fieldLabel
: gettext('Test String'),
325 xtype
: 'pmgRegexTester',
326 regexFieldReference
: 'value'
331 xtype
: 'proxmoxWindowEdit',
332 subdir
: 'contenttype',
334 subject
: gettext('Content Type Filter'),
338 displayField
: 'text',
340 valueField
: 'mimetype',
348 url
: '/api2/json/config/mimetypes'
351 fieldLabel
: gettext('Content Type'),
353 matchFieldWidth
: false,
355 change: function(cb
, value
) {
357 me
.up().down('displayfield').setValue(value
);
362 xtype
: 'displayfield',
363 fieldLabel
: gettext('Value'),
371 xtype
: 'proxmoxWindowEdit',
372 subdir
: 'filenamefilter',
374 subject
: gettext('Match Filename'),
379 reference
: 'filename',
380 fieldLabel
: gettext('Filename'),
386 fieldLabel
: gettext('Test String'),
388 xtype
: 'pmgRegexTester',
389 regexFieldReference
: 'filename'
394 xtype
: 'proxmoxWindowEdit',
395 subdir
: 'archivefilter',
397 subject
: gettext('Archive Filter'),
401 displayField
: 'text',
403 valueField
: 'mimetype',
411 url
: '/api2/json/config/mimetypes'
414 fieldLabel
: gettext('Content Type'),
416 matchFieldWidth
: false,
418 change: function(cb
, value
) {
420 me
.up().down('displayfield').setValue(value
);
425 xtype
: 'displayfield',
426 fieldLabel
: gettext('Value'),
434 xtype
: 'proxmoxWindowEdit',
436 subject
: gettext('BCC'),
443 fieldLabel
: gettext('Name')
446 xtype
: 'textareafield',
448 fieldLabel
: gettext("Description")
454 fieldLabel
: gettext("Target")
457 xtype
: 'proxmoxcheckbox',
460 fieldLabel
: gettext("send orig. Mail")
467 openVNCViewer: function(consoletype
, nodename
) {
468 var url
= Ext
.urlEncode({
469 console
: consoletype
, // upgrade or shell
473 var nw
= window
.open("?" + url
, '_blank',
474 "innerWidth=745,innerheight=427");
478 updateLoginData: function(data
) {
479 Proxmox
.CSRFPreventionToken
= data
.CSRFPreventionToken
;
480 Proxmox
.UserName
= data
.username
;
481 Ext
.util
.Cookies
.set('PMGAuthCookie', data
.ticket
, null, '/', null, true );
484 quarantineActionExtracted
: false,
486 extractQuarantineAction: function() {
488 if (PMG
.Utils
.quarantineActionExtracted
) { return; }
490 PMG
.Utils
.quarantineActionExtracted
= true;
492 var qs
= Ext
.Object
.fromQueryString(location
.search
);
494 var cselect
= qs
.cselect
;
495 var action
= qs
.action
;
496 var ticket
= qs
.ticket
;
502 var newsearch
= Ext
.Object
.toQueryString(qs
);
504 var newurl
= location
.protocol
+ "//" + location
.host
+ location
.pathname
;
505 if (newsearch
) { newurl
+= '?' + newsearch
; }
506 newurl
+= location
.hash
;
508 if (window
.history
) {
509 window
.history
.pushState({ path
:newurl
}, '', newurl
);
512 if (action
|| cselect
) {
513 return { action
: action
, cselect
: cselect
};
517 doQuarantineAction: function(action
, id
, callback
) {
518 Proxmox
.Utils
.API2Request({
519 url
: '/quarantine/content/',
525 failure: function(response
, opts
) {
526 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);
528 success: function(response
, opts
) {
529 var win
= Ext
.create('Ext.window.MessageBox',{
530 closeAction
: 'destroy'
532 title
: gettext('Info'),
533 message
: "Action '" + action
+ ' ' +
536 icon
: Ext
.MessageBox
.INFO
539 if (Ext
.isFunction(callback
)) {
546 sender_renderer: function(value
, metaData
, rec
) {
547 var subject
= Ext
.htmlEncode(value
);
548 var from = Ext
.htmlEncode(rec
.data
.from);
549 var sender
= Ext
.htmlEncode(rec
.data
.sender
);
551 from = Ext
.String
.format(gettext("{0} on behalf of {1}"),
554 return '<small>' + from + '</small><br>' + subject
;
557 constructor: function() {
560 // do whatever you want here