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
: 'matchfield',
292 subject
: gettext('Match Field'),
300 fieldLabel
: gettext('Field')
308 fieldLabel
: gettext('Value')
312 fieldLabel
: gettext('Test String'),
313 xtype
: 'pmgRegexTester',
314 regexFieldReference
: 'value'
319 xtype
: 'proxmoxWindowEdit',
320 subdir
: 'contenttype',
322 subject
: gettext('Content Type Filter'),
326 displayField
: 'text',
328 valueField
: 'mimetype',
336 url
: '/api2/json/config/mimetypes'
339 fieldLabel
: gettext('Content Type'),
341 matchFieldWidth
: false,
343 change: function(cb
, value
) {
345 me
.up().down('displayfield').setValue(value
);
350 xtype
: 'displayfield',
351 fieldLabel
: gettext('Value'),
359 xtype
: 'proxmoxWindowEdit',
360 subdir
: 'filenamefilter',
362 subject
: gettext('Match Filename'),
367 reference
: 'filename',
368 fieldLabel
: gettext('Filename'),
374 fieldLabel
: gettext('Test String'),
376 xtype
: 'pmgRegexTester',
377 regexFieldReference
: 'filename'
382 xtype
: 'proxmoxWindowEdit',
383 subdir
: 'archivefilter',
385 subject
: gettext('Archive Filter'),
389 displayField
: 'text',
391 valueField
: 'mimetype',
399 url
: '/api2/json/config/mimetypes'
402 fieldLabel
: gettext('Content Type'),
404 matchFieldWidth
: false,
406 change: function(cb
, value
) {
408 me
.up().down('displayfield').setValue(value
);
413 xtype
: 'displayfield',
414 fieldLabel
: gettext('Value'),
422 xtype
: 'proxmoxWindowEdit',
424 subject
: gettext('BCC'),
431 fieldLabel
: gettext('Name')
434 xtype
: 'textareafield',
436 fieldLabel
: gettext("Description")
442 fieldLabel
: gettext("Target")
445 xtype
: 'proxmoxcheckbox',
448 fieldLabel
: gettext("send orig. Mail")
455 openVNCViewer: function(consoletype
, nodename
) {
456 var url
= Ext
.urlEncode({
457 console
: consoletype
, // upgrade or shell
461 var nw
= window
.open("?" + url
, '_blank',
462 "innerWidth=745,innerheight=427");
466 updateLoginData: function(data
) {
467 Proxmox
.CSRFPreventionToken
= data
.CSRFPreventionToken
;
468 Proxmox
.UserName
= data
.username
;
469 Ext
.util
.Cookies
.set('PMGAuthCookie', data
.ticket
, null, '/', null, true );
472 quarantineActionExtracted
: false,
474 extractQuarantineAction: function() {
476 if (PMG
.Utils
.quarantineActionExtracted
) { return; }
478 PMG
.Utils
.quarantineActionExtracted
= true;
480 var qs
= Ext
.Object
.fromQueryString(location
.search
);
482 var cselect
= qs
.cselect
;
483 var action
= qs
.action
;
484 var ticket
= qs
.ticket
;
490 var newsearch
= Ext
.Object
.toQueryString(qs
);
492 var newurl
= location
.protocol
+ "//" + location
.host
+ location
.pathname
;
493 if (newsearch
) { newurl
+= '?' + newsearch
; }
494 newurl
+= location
.hash
;
496 if (window
.history
) {
497 window
.history
.pushState({ path
:newurl
}, '', newurl
);
500 if (action
|| cselect
) {
501 return { action
: action
, cselect
: cselect
};
505 doQuarantineAction: function(action
, id
, callback
) {
506 Proxmox
.Utils
.API2Request({
507 url
: '/quarantine/content/',
513 failure: function(response
, opts
) {
514 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);
516 success: function(response
, opts
) {
517 var win
= Ext
.create('Ext.window.MessageBox',{
518 closeAction
: 'destroy'
520 title
: gettext('Info'),
521 message
: "Action '" + action
+ ' ' +
524 icon
: Ext
.MessageBox
.INFO
527 if (Ext
.isFunction(callback
)) {
534 sender_renderer: function(value
, metaData
, rec
) {
535 var subject
= Ext
.htmlEncode(value
);
536 var from = Ext
.htmlEncode(rec
.data
.from);
537 var sender
= Ext
.htmlEncode(rec
.data
.sender
);
539 from = Ext
.String
.format(gettext("{0} on behalf of {1}"),
542 return '<small>' + from + '</small><br>' + subject
;
545 constructor: function() {
548 // do whatever you want here