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'; }
134 xtype
: 'proxmoxWindowEdit',
136 subject
: gettext("Regular Expression"),
143 fieldLabel
: gettext("Regular Expression")
148 xtype
: 'pmgLDAPGroupEditor',
150 subject
: gettext("LDAP Group")
153 xtype
: 'pmgLDAPUserEditor',
155 subject
: gettext("LDAP User")
158 xtype
: 'proxmoxWindowEdit',
159 subdir
: 'receiver_regex',
160 subject
: gettext("Regular Expression"),
168 fieldLabel
: gettext("Regular Expression")
173 xtype
: 'proxmoxWindowEdit',
175 subject
: gettext("Email"),
181 fieldLabel
: gettext("Email")
186 xtype
: 'proxmoxWindowEdit',
188 subject
: gettext("Email"),
195 fieldLabel
: gettext("Email")
200 xtype
: 'proxmoxWindowEdit',
202 subject
: gettext("Domain"),
208 fieldLabel
: gettext("Domain")
213 xtype
: 'proxmoxWindowEdit',
214 subdir
: 'receiver_domain',
215 subject
: gettext("Domain"),
222 fieldLabel
: gettext("Domain")
227 xtype
: 'proxmoxWindowEdit',
229 subject
: gettext("IP Address"),
235 fieldLabel
: gettext("IP Address")
240 xtype
: 'proxmoxWindowEdit',
242 subject
: gettext("IP Network"),
248 fieldLabel
: gettext("IP Network")
253 xtype
: 'proxmoxWindowEdit',
255 subject
: gettext("TimeFrame"),
261 fieldLabel
: gettext("Start Time")
267 fieldLabel
: gettext("End Time")
272 xtype
: 'proxmoxWindowEdit',
273 subdir
: 'spamfilter',
274 subject
: gettext('Spam Filter'),
277 xtype
: 'proxmoxintegerfield',
281 fieldLabel
: gettext('Level')
286 xtype
: 'proxmoxWindowEdit',
287 subdir
: 'matchfield',
288 subject
: gettext('Match Field'),
296 fieldLabel
: gettext('Field')
304 fieldLabel
: gettext('Value')
308 fieldLabel
: gettext('Test String'),
309 xtype
: 'pmgRegexTester',
310 regexFieldReference
: 'value'
315 xtype
: 'proxmoxWindowEdit',
316 subdir
: 'contenttype',
318 subject
: gettext('Content Type Filter'),
322 displayField
: 'text',
324 valueField
: 'mimetype',
332 url
: '/api2/json/config/mimetypes'
335 fieldLabel
: gettext('Content Type'),
337 matchFieldWidth
: false,
339 change: function(cb
, value
) {
341 me
.up().down('displayfield').setValue(value
);
346 xtype
: 'displayfield',
347 fieldLabel
: gettext('Value'),
355 xtype
: 'proxmoxWindowEdit',
356 subdir
: 'filenamefilter',
358 subject
: gettext('Match Filename'),
363 reference
: 'filename',
364 fieldLabel
: gettext('Filename'),
370 fieldLabel
: gettext('Test String'),
372 xtype
: 'pmgRegexTester',
373 regexFieldReference
: 'filename'
378 xtype
: 'proxmoxWindowEdit',
379 subdir
: 'archivefilter',
381 subject
: gettext('Archive Filter'),
385 displayField
: 'text',
387 valueField
: 'mimetype',
395 url
: '/api2/json/config/mimetypes'
398 fieldLabel
: gettext('Content Type'),
400 matchFieldWidth
: false,
402 change: function(cb
, value
) {
404 me
.up().down('displayfield').setValue(value
);
409 xtype
: 'displayfield',
410 fieldLabel
: gettext('Value'),
418 xtype
: 'proxmoxWindowEdit',
420 subject
: gettext('BCC'),
427 fieldLabel
: gettext('Name')
430 xtype
: 'textareafield',
432 fieldLabel
: gettext("Description")
438 fieldLabel
: gettext("Target")
441 xtype
: 'proxmoxcheckbox',
444 fieldLabel
: gettext("send orig. Mail")
451 openVNCViewer: function(consoletype
, nodename
) {
452 var url
= Ext
.urlEncode({
453 console
: consoletype
, // upgrade or shell
457 var nw
= window
.open("?" + url
, '_blank',
458 "innerWidth=745,innerheight=427");
462 updateLoginData: function(data
) {
463 Proxmox
.CSRFPreventionToken
= data
.CSRFPreventionToken
;
464 Proxmox
.UserName
= data
.username
;
465 Ext
.util
.Cookies
.set('PMGAuthCookie', data
.ticket
, null, '/', null, true );
468 quarantineActionExtracted
: false,
470 extractQuarantineAction: function() {
472 if (PMG
.Utils
.quarantineActionExtracted
) { return; }
474 PMG
.Utils
.quarantineActionExtracted
= true;
476 var qs
= Ext
.Object
.fromQueryString(location
.search
);
478 var cselect
= qs
.cselect
;
479 var action
= qs
.action
;
480 var ticket
= qs
.ticket
;
486 var newsearch
= Ext
.Object
.toQueryString(qs
);
488 var newurl
= location
.protocol
+ "//" + location
.host
+ location
.pathname
;
489 if (newsearch
) { newurl
+= '?' + newsearch
; }
490 newurl
+= location
.hash
;
492 if (window
.history
) {
493 window
.history
.pushState({ path
:newurl
}, '', newurl
);
496 if (action
|| cselect
) {
497 return { action
: action
, cselect
: cselect
};
501 doQuarantineAction: function(action
, id
, callback
) {
502 Proxmox
.Utils
.API2Request({
503 url
: '/quarantine/content/',
509 failure: function(response
, opts
) {
510 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);
512 success: function(response
, opts
) {
513 var win
= Ext
.create('Ext.window.MessageBox',{
514 closeAction
: 'destroy'
516 title
: gettext('Info'),
517 message
: "Action '" + action
+ ' ' +
520 icon
: Ext
.MessageBox
.INFO
523 if (Ext
.isFunction(callback
)) {
530 sender_renderer: function(value
, metaData
, rec
) {
531 var subject
= Ext
.htmlEncode(value
);
532 var from = Ext
.htmlEncode(rec
.data
.from);
533 var sender
= Ext
.htmlEncode(rec
.data
.sender
);
535 from = Ext
.String
.format(gettext("{0} on behalf of {1}"),
538 return '<small>' + from + '</small><br>' + subject
;
541 constructor: function() {
544 // do whatever you want here