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 who
: gettext('Who Objects'),
18 what
: gettext('What Objects'),
19 when
: gettext('When Objects'),
20 action
: gettext('Action Objects'),
21 from: gettext('From'),
26 who
: '<span class="fa fa-fw fa-user-circle"></span> ',
27 what
: '<span class="fa fa-fw fa-cube"></span> ',
28 when
: '<span class="fa fa-fw fa-clock-o"></span> ',
29 action
: '<span class="fa fa-fw fa-flag"></span> ',
30 from: '<span class="fa fa-fw fa-user-circle"></span> ',
31 to
: '<span class="fa fa-fw fa-user-circle"></span> '
76 format_status_icon: function(status
) {
77 var icon
= PMG
.Utils
.icon_status_map
[status
] || {};
78 return '<i class="fa fa-' + (icon
.fa
|| 'question-circle') + ' ' +
79 (icon
.color
|| '') + '"></i> ';
82 format_oclass: function(oclass
) {
83 var icon
= PMG
.Utils
.oclass_icon
[oclass
] || '';
84 var text
= PMG
.Utils
.oclass_text
[oclass
] || oclass
;
88 rule_direction_text
: {
91 2: gettext('In & Out')
94 rule_direction_icon
: {
95 0: '<span class="fa fa-fw fa-long-arrow-left"></span> ',
96 1: '<span class="fa fa-fw fa-long-arrow-right"></span> ',
97 2: '<span class="fa fa-fw fa-exchange"></span> '
100 format_rule_direction: function(dir
) {
101 var icon
= PMG
.Utils
.rule_direction_icon
[dir
] || '';
102 var text
= PMG
.Utils
.rule_direction_text
[dir
] || dir
;
106 format_otype: function(otype
) {
107 var editor
= PMG
.Utils
.object_editors
[otype
];
109 return editor
.subject
;
114 format_ldap_protocol: function(p
) {
115 if (p
=== undefined) { return 'LDAP'; }
116 if (p
=== 'ldap') { return 'LDAP'; }
117 if (p
=== 'ldaps') { return 'LDAPS'; }
123 xtype
: 'proxmoxWindowEdit',
125 subject
: gettext("Regular Expression"),
132 fieldLabel
: gettext("Regular Expression")
137 xtype
: 'pmgLDAPGroupEditor',
139 subject
: gettext("LDAP Group")
142 xtype
: 'pmgLDAPUserEditor',
144 subject
: gettext("LDAP User")
147 xtype
: 'proxmoxWindowEdit',
148 subdir
: 'receiver_regex',
149 subject
: gettext("Regular Expression"),
157 fieldLabel
: gettext("Regular Expression")
162 xtype
: 'proxmoxWindowEdit',
164 subject
: gettext("Email"),
170 fieldLabel
: gettext("Email")
175 xtype
: 'proxmoxWindowEdit',
177 subject
: gettext("Email"),
184 fieldLabel
: gettext("Email")
189 xtype
: 'proxmoxWindowEdit',
191 subject
: gettext("Domain"),
197 fieldLabel
: gettext("Domain")
202 xtype
: 'proxmoxWindowEdit',
203 subdir
: 'receiver_domain',
204 subject
: gettext("Domain"),
211 fieldLabel
: gettext("Domain")
216 xtype
: 'proxmoxWindowEdit',
218 subject
: gettext("IP Address"),
224 fieldLabel
: gettext("IP Address")
229 xtype
: 'proxmoxWindowEdit',
231 subject
: gettext("IP Network"),
237 fieldLabel
: gettext("IP Network")
242 xtype
: 'proxmoxWindowEdit',
244 subject
: gettext("TimeFrame"),
250 fieldLabel
: gettext("Start Time")
256 fieldLabel
: gettext("End Time")
261 xtype
: 'proxmoxWindowEdit',
262 subdir
: 'spamfilter',
263 subject
: gettext('Spam Filter'),
266 xtype
: 'proxmoxintegerfield',
270 fieldLabel
: gettext('Level')
275 xtype
: 'proxmoxWindowEdit',
276 subdir
: 'matchfield',
277 subject
: gettext('Match Field'),
285 fieldLabel
: gettext('Field')
293 fieldLabel
: gettext('Value')
297 fieldLabel
: gettext('Test String'),
298 xtype
: 'pmgRegexTester',
299 regexFieldReference
: 'value'
304 xtype
: 'proxmoxWindowEdit',
305 subdir
: 'contenttype',
307 subject
: gettext('Content Type Filter'),
311 displayField
: 'text',
313 valueField
: 'mimetype',
321 url
: '/api2/json/config/mimetypes'
324 fieldLabel
: gettext('Content Type'),
326 matchFieldWidth
: false,
328 change: function(cb
, value
) {
330 me
.up().down('displayfield').setValue(value
);
335 xtype
: 'displayfield',
336 fieldLabel
: gettext('Value'),
344 xtype
: 'proxmoxWindowEdit',
345 subdir
: 'filenamefilter',
347 subject
: gettext('Match Filename'),
352 reference
: 'filename',
353 fieldLabel
: gettext('Filename'),
359 fieldLabel
: gettext('Test String'),
361 xtype
: 'pmgRegexTester',
362 regexFieldReference
: 'filename'
367 xtype
: 'proxmoxWindowEdit',
368 subdir
: 'archivefilter',
370 subject
: gettext('Archive Filter'),
374 displayField
: 'text',
376 valueField
: 'mimetype',
384 url
: '/api2/json/config/mimetypes'
387 fieldLabel
: gettext('Content Type'),
389 matchFieldWidth
: false,
391 change: function(cb
, value
) {
393 me
.up().down('displayfield').setValue(value
);
398 xtype
: 'displayfield',
399 fieldLabel
: gettext('Value'),
407 xtype
: 'proxmoxWindowEdit',
409 subject
: gettext('BCC'),
416 fieldLabel
: gettext('Name')
419 xtype
: 'textareafield',
421 fieldLabel
: gettext("Description")
427 fieldLabel
: gettext("Target")
430 xtype
: 'proxmoxcheckbox',
433 fieldLabel
: gettext("send orig. Mail")
440 openVNCViewer: function(consoletype
, nodename
) {
441 var url
= Ext
.urlEncode({
442 console
: consoletype
, // upgrade or shell
446 var nw
= window
.open("?" + url
, '_blank',
447 "innerWidth=745,innerheight=427");
451 updateLoginData: function(data
) {
452 Proxmox
.CSRFPreventionToken
= data
.CSRFPreventionToken
;
453 Proxmox
.UserName
= data
.username
;
454 Ext
.util
.Cookies
.set('PMGAuthCookie', data
.ticket
, null, '/', null, true );
457 quarantineActionExtracted
: false,
459 extractQuarantineAction: function() {
461 if (PMG
.Utils
.quarantineActionExtracted
) { return; }
463 PMG
.Utils
.quarantineActionExtracted
= true;
465 var qs
= Ext
.Object
.fromQueryString(location
.search
);
467 var cselect
= qs
.cselect
;
468 var action
= qs
.action
;
469 var ticket
= qs
.ticket
;
475 var newsearch
= Ext
.Object
.toQueryString(qs
);
477 var newurl
= location
.protocol
+ "//" + location
.host
+ location
.pathname
;
478 if (newsearch
) { newurl
+= '?' + newsearch
; }
479 newurl
+= location
.hash
;
481 if (window
.history
) {
482 window
.history
.pushState({ path
:newurl
}, '', newurl
);
485 if (action
|| cselect
) {
486 return { action
: action
, cselect
: cselect
};
490 doQuarantineAction: function(action
, id
, callback
) {
491 Proxmox
.Utils
.API2Request({
492 url
: '/quarantine/content/',
498 failure: function(response
, opts
) {
499 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);
501 success: function(response
, opts
) {
503 title
: gettext('Info'),
504 message
: "Action '" + action
+ ' ' +
507 icon
: Ext
.MessageBox
.INFO
510 if (Ext
.isFunction(callback
)) {
517 sender_renderer: function(value
, metaData
, rec
) {
518 var subject
= Ext
.htmlEncode(value
);
519 var from = Ext
.htmlEncode(rec
.data
.from);
520 var sender
= Ext
.htmlEncode(rec
.data
.sender
);
522 from = Ext
.String
.format(gettext("{0} on behalf of {1}"),
525 return '<small>' + from + '</small><br>' + subject
;
528 constructor: function() {
531 // do whatever you want here