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',
456 subject
: gettext('BCC'),
463 fieldLabel
: gettext('Name')
466 xtype
: 'textareafield',
468 fieldLabel
: gettext("Description")
474 fieldLabel
: gettext("Target")
477 xtype
: 'proxmoxcheckbox',
480 fieldLabel
: gettext("send orig. Mail")
487 openVNCViewer: function(consoletype
, nodename
) {
488 var url
= Ext
.urlEncode({
489 console
: consoletype
, // upgrade or shell
493 var nw
= window
.open("?" + url
, '_blank',
494 "innerWidth=745,innerheight=427");
498 updateLoginData: function(data
) {
499 Proxmox
.CSRFPreventionToken
= data
.CSRFPreventionToken
;
500 Proxmox
.UserName
= data
.username
;
501 Ext
.util
.Cookies
.set('PMGAuthCookie', data
.ticket
, null, '/', null, true );
504 quarantineActionExtracted
: false,
506 extractQuarantineAction: function() {
508 if (PMG
.Utils
.quarantineActionExtracted
) { return; }
510 PMG
.Utils
.quarantineActionExtracted
= true;
512 var qs
= Ext
.Object
.fromQueryString(location
.search
);
514 var cselect
= qs
.cselect
;
515 var action
= qs
.action
;
516 var ticket
= qs
.ticket
;
522 var newsearch
= Ext
.Object
.toQueryString(qs
);
524 var newurl
= location
.protocol
+ "//" + location
.host
+ location
.pathname
;
525 if (newsearch
) { newurl
+= '?' + newsearch
; }
526 newurl
+= location
.hash
;
528 if (window
.history
) {
529 window
.history
.pushState({ path
:newurl
}, '', newurl
);
532 if (action
|| cselect
) {
533 return { action
: action
, cselect
: cselect
};
537 doQuarantineAction: function(action
, id
, callback
) {
538 Proxmox
.Utils
.API2Request({
539 url
: '/quarantine/content/',
545 failure: function(response
, opts
) {
546 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);
548 success: function(response
, opts
) {
549 var win
= Ext
.create('Ext.window.MessageBox',{
550 closeAction
: 'destroy'
552 title
: gettext('Info'),
553 message
: "Action '" + action
+ ' ' +
556 icon
: Ext
.MessageBox
.INFO
559 if (Ext
.isFunction(callback
)) {
566 sender_renderer: function(value
, metaData
, rec
) {
567 var subject
= Ext
.htmlEncode(value
);
568 var from = Ext
.htmlEncode(rec
.data
.from);
569 var sender
= Ext
.htmlEncode(rec
.data
.sender
);
571 from = Ext
.String
.format(gettext("{0} on behalf of {1}"),
574 return '<small>' + from + '</small><br>' + subject
;
577 constructor: function() {
580 // do whatever you want here