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> '
45 format_oclass: function(oclass
) {
46 var icon
= PMG
.Utils
.oclass_icon
[oclass
] || '';
47 var text
= PMG
.Utils
.oclass_text
[oclass
] || oclass
;
51 rule_direction_text
: {
54 2: gettext('In & Out')
57 rule_direction_icon
: {
58 0: '<span class="fa fa-fw fa-long-arrow-left"></span> ',
59 1: '<span class="fa fa-fw fa-long-arrow-right"></span> ',
60 2: '<span class="fa fa-fw fa-exchange"></span> '
63 format_rule_direction: function(dir
) {
64 var icon
= PMG
.Utils
.rule_direction_icon
[dir
] || '';
65 var text
= PMG
.Utils
.rule_direction_text
[dir
] || dir
;
69 format_otype: function(otype
) {
70 var editor
= PMG
.Utils
.object_editors
[otype
];
72 return editor
.subject
;
77 format_ldap_protocol: function(p
) {
78 if (p
=== undefined) { return 'LDAP'; }
79 if (p
=== 'ldap') { return 'LDAP'; }
80 if (p
=== 'ldaps') { return 'LDAPS'; }
86 xtype
: 'proxmoxWindowEdit',
88 subject
: gettext("Regular Expression"),
95 fieldLabel
: gettext("Regular Expression")
100 xtype
: 'pmgLDAPGroupEditor',
102 subject
: gettext("LDAP Group")
105 xtype
: 'pmgLDAPUserEditor',
107 subject
: gettext("LDAP User")
110 xtype
: 'proxmoxWindowEdit',
111 subdir
: 'receiver_regex',
112 subject
: gettext("Regular Expression"),
120 fieldLabel
: gettext("Regular Expression")
125 xtype
: 'proxmoxWindowEdit',
127 subject
: gettext("Email"),
133 fieldLabel
: gettext("Email")
138 xtype
: 'proxmoxWindowEdit',
140 subject
: gettext("Email"),
147 fieldLabel
: gettext("Email")
152 xtype
: 'proxmoxWindowEdit',
154 subject
: gettext("Domain"),
160 fieldLabel
: gettext("Domain")
165 xtype
: 'proxmoxWindowEdit',
166 subdir
: 'receiver_domain',
167 subject
: gettext("Domain"),
174 fieldLabel
: gettext("Domain")
179 xtype
: 'proxmoxWindowEdit',
181 subject
: gettext("IP Address"),
187 fieldLabel
: gettext("IP Address")
192 xtype
: 'proxmoxWindowEdit',
194 subject
: gettext("IP Network"),
200 fieldLabel
: gettext("IP Network")
205 xtype
: 'proxmoxWindowEdit',
207 subject
: gettext("TimeFrame"),
213 fieldLabel
: gettext("Start Time")
219 fieldLabel
: gettext("End Time")
224 xtype
: 'proxmoxWindowEdit',
225 subdir
: 'spamfilter',
226 subject
: gettext('Spam Filter'),
229 xtype
: 'proxmoxintegerfield',
233 fieldLabel
: gettext('Level')
238 xtype
: 'proxmoxWindowEdit',
239 subdir
: 'matchfield',
240 subject
: gettext('Match Field'),
248 fieldLabel
: gettext('Field')
256 fieldLabel
: gettext('Value')
260 fieldLabel
: gettext('Test String'),
261 xtype
: 'pmgRegexTester',
262 regexFieldReference
: 'value'
267 xtype
: 'proxmoxWindowEdit',
268 subdir
: 'contenttype',
270 subject
: gettext('Content Type Filter'),
274 displayField
: 'text',
276 valueField
: 'mimetype',
284 url
: '/api2/json/config/mimetypes'
287 fieldLabel
: gettext('Content Type'),
289 matchFieldWidth
: false,
291 change: function(cb
, value
) {
293 me
.up().down('displayfield').setValue(value
);
298 xtype
: 'displayfield',
299 fieldLabel
: gettext('Value'),
307 xtype
: 'proxmoxWindowEdit',
308 subdir
: 'filenamefilter',
310 subject
: gettext('Match Filename'),
315 reference
: 'filename',
316 fieldLabel
: gettext('Filename'),
322 fieldLabel
: gettext('Test String'),
324 xtype
: 'pmgRegexTester',
325 regexFieldReference
: 'filename'
330 xtype
: 'proxmoxWindowEdit',
331 subdir
: 'archivefilter',
333 subject
: gettext('Archive Filter'),
337 displayField
: 'text',
339 valueField
: 'mimetype',
347 url
: '/api2/json/config/mimetypes'
350 fieldLabel
: gettext('Content Type'),
352 matchFieldWidth
: false,
354 change: function(cb
, value
) {
356 me
.up().down('displayfield').setValue(value
);
361 xtype
: 'displayfield',
362 fieldLabel
: gettext('Value'),
370 xtype
: 'proxmoxWindowEdit',
372 subject
: gettext('BCC'),
379 fieldLabel
: gettext('Name')
382 xtype
: 'textareafield',
384 fieldLabel
: gettext("Description")
390 fieldLabel
: gettext("Target")
393 xtype
: 'proxmoxcheckbox',
396 fieldLabel
: gettext("send orig. Mail")
403 openVNCViewer: function(consoletype
, nodename
) {
404 var url
= Ext
.urlEncode({
405 console
: consoletype
, // upgrade or shell
409 var nw
= window
.open("?" + url
, '_blank',
410 "innerWidth=745,innerheight=427");
414 updateLoginData: function(data
) {
415 Proxmox
.CSRFPreventionToken
= data
.CSRFPreventionToken
;
416 Proxmox
.UserName
= data
.username
;
417 Ext
.util
.Cookies
.set('PMGAuthCookie', data
.ticket
, null, '/', null, true );
420 quarantineActionExtracted
: false,
422 extractQuarantineAction: function() {
424 if (PMG
.Utils
.quarantineActionExtracted
) { return; }
426 PMG
.Utils
.quarantineActionExtracted
= true;
428 var qs
= Ext
.Object
.fromQueryString(location
.search
);
430 var cselect
= qs
.cselect
;
431 var action
= qs
.action
;
432 var ticket
= qs
.ticket
;
438 var newsearch
= Ext
.Object
.toQueryString(qs
);
440 var newurl
= location
.protocol
+ "//" + location
.host
+ location
.pathname
;
441 if (newsearch
) { newurl
+= '?' + newsearch
; }
442 newurl
+= location
.hash
;
444 if (window
.history
) {
445 window
.history
.pushState({ path
:newurl
}, '', newurl
);
448 if (action
&& cselect
) {
449 return { action
: action
, cselect
: cselect
};
453 doQuarantineAction: function(action
, id
, callback
) {
454 Proxmox
.Utils
.API2Request({
455 url
: '/quarantine/content/',
461 failure: function(response
, opts
) {
462 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);
464 success: function(response
, opts
) {
466 title
: gettext('Info'),
467 message
: "Action '" + action
+ ' ' +
470 icon
: Ext
.MessageBox
.INFO
473 if (Ext
.isFunction(callback
)) {
480 sender_renderer: function(value
, metaData
, rec
) {
481 var subject
= Ext
.htmlEncode(value
);
482 var from = Ext
.htmlEncode(rec
.data
.from);
483 var sender
= Ext
.htmlEncode(rec
.data
.sender
);
485 from = Ext
.String
.format(gettext("{0} on behalf of {1}"),
488 return '<small>' + from + '</small><br>' + subject
;
491 constructor: function() {
494 // do whatever you want here