+/*global Proxmox */
Ext.ns('PMG');
console.log("Starting PMG Manager");
receiverText: gettext('Receiver'),
scoreText: gettext('Score'),
+ user_role_text: {
+ root: gettext('Superuser'),
+ admin: gettext('Administrator'),
+ qmanager: gettext('Quarantine Manager'),
+ audit: gettext('Auditor')
+ },
+
+ format_user_role: function(role) {
+ return PMG.Utils.user_role_text[role] || role;
+ },
+
oclass_text: {
who: gettext('Who Objects'),
what: gettext('What Objects'),
when: '<span class="fa fa-fw fa-clock-o"></span> ',
action: '<span class="fa fa-fw fa-flag"></span> ',
from: '<span class="fa fa-fw fa-user-circle"></span> ',
- to: '<span class="fa fa-fw fa-user-circle"></span> ',
+ to: '<span class="fa fa-fw fa-user-circle"></span> '
+ },
+
+ mail_status_map: {
+ 2: 'delivered',
+ 4: 'deferred',
+ 5: 'bounced',
+ N: 'rejected',
+ G: 'greylisted',
+ A: 'accepted',
+ B: 'blocked',
+ Q: 'quarantine'
+ },
+
+ icon_status_map_class: {
+ 2: 'check-circle',
+ 4: 'clock-o',
+ 5: 'mail-reply',
+ N: 'times-circle',
+ G: 'list',
+ A: 'check',
+ B: 'ban',
+ Q: 'cube'
+ },
+
+ icon_status_map_color: {
+ 2: 'green',
+ 5: 'gray',
+ A: 'green',
+ B: 'red'
+ },
+
+ format_status_icon: function(status) {
+ var icon = PMG.Utils.icon_status_map_class[status] || 'question-circle';
+ var color = PMG.Utils.icon_status_map_color[status] || '';
+ return '<i class="fa fa-' + icon + ' ' + color + '"></i> ';
},
format_oclass: function(oclass) {
format_otype: function(otype) {
var editor = PMG.Utils.object_editors[otype];
+ var iconCls = 'fa fa-question-circle';
if (editor) {
- return editor.subject;
+ var icon = '<span class="fa-fw ' + (editor.iconCls || iconCls) + '"></span> ';
+ return icon + editor.subject;
}
- return 'unknown';
+
+ return '<span class="fa-fw ' + iconCls + '"></span> unknown';
},
format_ldap_protocol: function(p) {
- if (p === undefined) return 'LDAP';
- if (p === 'ldap') return 'LDAP';
- if (p === 'ldaps') return 'LDAPS';
+ if (p === undefined) { return 'LDAP'; }
+ if (p === 'ldap') { return 'LDAP'; }
+ if (p === 'ldaps') { return 'LDAPS'; }
return 'unknown';
},
+ convert_field_to_per_min: function(value, record) {
+ return (value/(record.data.timespan/60));
+ },
+
object_editors: {
1000: {
+ iconCls: 'fa fa-filter',
xtype: 'proxmoxWindowEdit',
subdir: 'regex',
subject: gettext("Regular Expression"),
xtype: 'textfield',
name: 'regex',
labelWidth: 150,
+ reference: 'regex',
fieldLabel: gettext("Regular Expression")
+ },
+ {
+ labelWidth: 150,
+ fieldLabel: gettext('Test String'),
+ xtype: 'pmgRegexTester',
+ regexFieldReference: 'regex'
}
]
},
1005: {
+ iconCls: 'fa fa-users',
xtype: 'pmgLDAPGroupEditor',
subdir: 'ldap',
subject: gettext("LDAP Group")
},
1006: {
+ iconCls: 'fa fa-user',
xtype: 'pmgLDAPUserEditor',
subdir: 'ldapuser',
subject: gettext("LDAP User")
},
1009: {
+ iconCls: 'fa fa-filter',
xtype: 'proxmoxWindowEdit',
subdir: 'receiver_regex',
subject: gettext("Regular Expression"),
]
},
1001: {
+ iconCls: 'fa fa-envelope-o',
xtype: 'proxmoxWindowEdit',
subdir: 'email',
subject: gettext("Email"),
]
},
1007: {
+ iconCls: 'fa fa-envelope-o',
xtype: 'proxmoxWindowEdit',
subdir: 'receiver',
subject: gettext("Email"),
]
},
1002: {
+ iconCls: 'fa fa-globe',
xtype: 'proxmoxWindowEdit',
subdir: 'domain',
subject: gettext("Domain"),
]
},
1008: {
+ iconCls: 'fa fa-globe',
xtype: 'proxmoxWindowEdit',
subdir: 'receiver_domain',
subject: gettext("Domain"),
]
},
1003: {
+ iconCls: 'fa fa-globe',
xtype: 'proxmoxWindowEdit',
subdir: 'ip',
subject: gettext("IP Address"),
]
},
1004: {
+ iconCls: 'fa fa-globe',
xtype: 'proxmoxWindowEdit',
subdir: 'network',
subject: gettext("IP Network"),
]
},
2000: {
+ iconCls: 'fa fa-clock-o',
xtype: 'proxmoxWindowEdit',
subdir: 'timeframe',
subject: gettext("TimeFrame"),
}
]
},
+ 3000: {
+ iconCls: 'fa fa-bullhorn',
+ xtype: 'proxmoxWindowEdit',
+ subdir: 'spamfilter',
+ subject: gettext('Spam Filter'),
+ items: [
+ {
+ xtype: 'proxmoxintegerfield',
+ name: 'spamlevel',
+ allowBlank: false,
+ minValue: 0,
+ fieldLabel: gettext('Level')
+ }
+ ]
+ },
+ 3001: {
+ iconCls: 'fa fa-bug',
+ xtype: 'proxmoxWindowEdit',
+ subdir: 'virusfilter',
+ subject: gettext('Virus Filter'),
+ uneditable: true,
+ // there are no parameters to give, so we simply submit it
+ listeners: {
+ show: function(win) {
+ win.submit();
+ }
+ }
+ },
+ 3002: {
+ iconCls: 'fa fa-code',
+ xtype: 'proxmoxWindowEdit',
+ subdir: 'matchfield',
+ subject: gettext('Match Field'),
+ width: 400,
+ items: [
+ {
+ xtype: 'textfield',
+ name: 'field',
+ labelWidth: 150,
+ allowBlank: false,
+ fieldLabel: gettext('Field')
+ },
+ {
+ xtype: 'textfield',
+ reference: 'value',
+ name: 'value',
+ labelWidth: 150,
+ allowBlank: false,
+ fieldLabel: gettext('Value')
+ },
+ {
+ labelWidth: 150,
+ fieldLabel: gettext('Test String'),
+ xtype: 'pmgRegexTester',
+ regexFieldReference: 'value'
+ }
+ ]
+ },
+ 3003: {
+ iconCls: 'fa fa-file-image-o',
+ xtype: 'proxmoxWindowEdit',
+ subdir: 'contenttype',
+ width: 400,
+ subject: gettext('Content Type Filter'),
+ items: [
+ {
+ xtype: 'combobox',
+ displayField: 'text',
+ labelWidth: 150,
+ valueField: 'mimetype',
+ name: 'contenttype',
+ editable: true,
+ queryMode: 'local',
+ store: {
+ autoLoad: true,
+ proxy: {
+ type: 'proxmox',
+ url: '/api2/json/config/mimetypes'
+ }
+ },
+ fieldLabel: gettext('Content Type'),
+ anyMatch: true,
+ matchFieldWidth: false,
+ listeners: {
+ change: function(cb, value) {
+ var me = this;
+ me.up().down('displayfield').setValue(value);
+ }
+ }
+ },
+ {
+ xtype: 'displayfield',
+ fieldLabel: gettext('Value'),
+ labelWidth: 150,
+ allowBlank: false,
+ reset: Ext.emptyFn
+ }
+ ]
+ },
+ 3004: {
+ iconCls: 'fa fa-file-o',
+ xtype: 'proxmoxWindowEdit',
+ subdir: 'filenamefilter',
+ width: 400,
+ subject: gettext('Match Filename'),
+ items: [
+ {
+ xtype: 'textfield',
+ name: 'filename',
+ reference: 'filename',
+ fieldLabel: gettext('Filename'),
+ labelWidth: 150,
+ allowBlank: false
+ },
+ {
+ labelWidth: 150,
+ fieldLabel: gettext('Test String'),
+ wholeMatch: true,
+ xtype: 'pmgRegexTester',
+ regexFieldReference: 'filename'
+ }
+ ]
+ },
+ 3005: {
+ iconCls: 'fa fa-file-archive-o',
+ xtype: 'proxmoxWindowEdit',
+ subdir: 'archivefilter',
+ width: 400,
+ subject: gettext('Archive Filter'),
+ items: [
+ {
+ xtype: 'combobox',
+ displayField: 'text',
+ labelWidth: 150,
+ valueField: 'mimetype',
+ name: 'contenttype',
+ editable: true,
+ queryMode: 'local',
+ store: {
+ autoLoad: true,
+ proxy: {
+ type: 'proxmox',
+ url: '/api2/json/config/mimetypes'
+ }
+ },
+ fieldLabel: gettext('Content Type'),
+ anyMatch: true,
+ matchFieldWidth: false,
+ listeners: {
+ change: function(cb, value) {
+ var me = this;
+ me.up().down('displayfield').setValue(value);
+ }
+ }
+ },
+ {
+ xtype: 'displayfield',
+ fieldLabel: gettext('Value'),
+ labelWidth: 150,
+ allowBlank: false,
+ reset: Ext.emptyFn
+ }
+ ]
+ },
+ 4002: {
+ xtype: 'proxmoxWindowEdit',
+ subdir: 'notification',
+ subject: gettext('Notification'),
+ width: 400,
+ items: [
+ {
+ xtype: 'textfield',
+ name: 'name',
+ allowBlank: false,
+ fieldLabel: gettext('Name')
+ },
+ {
+ xtype: 'textareafield',
+ name: 'info',
+ fieldLabel: gettext("Description")
+ },
+ {
+ xtype: 'textfield',
+ name: 'to',
+ allowBlank: false,
+ value: '__ADMIN__',
+ fieldLabel: gettext('Receiver')
+ },
+ {
+ xtype: 'textfield',
+ name: 'subject',
+ allowBlank: false,
+ value: 'Notification: __SUBJECT__',
+ fieldLabel: gettext('Subject')
+ },
+ {
+ xtype: 'textarea',
+ name: 'body',
+ allowBlank: false,
+ grow: true,
+ growMax: 250,
+ value:
+ "Proxmox Notifcation:\n\n" +
+ "Sender: __SENDER__\n" +
+ "Receiver: __RECEIVERS__\n" +
+ "Targets: __TARGETS__\n\n" +
+ "Subject: __SUBJECT__\n\n" +
+ "Matching Rule: __RULE__\n\n" +
+ "__RULE_INFO__\n\n" +
+ "__VIRUS_INFO__\n" +
+ "__SPAM_INFO__\n",
+ fieldLabel: gettext('Body')
+ },
+ {
+ xtype: 'proxmoxcheckbox',
+ name: 'attach',
+ fieldLabel: gettext("Attach orig. Mail")
+ }
+ ]
+ },
+ 4003: {
+ xtype: 'proxmoxWindowEdit',
+ subdir: 'field',
+ subject: gettext('Header Attribute'),
+ width: 400,
+ items: [
+ {
+ xtype: 'textfield',
+ name: 'name',
+ allowBlank: false,
+ fieldLabel: gettext('Name')
+ },
+ {
+ xtype: 'textareafield',
+ name: 'info',
+ fieldLabel: gettext("Description")
+ },
+ {
+ xtype: 'textfield',
+ name: 'field',
+ allowBlank: false,
+ fieldLabel: gettext('Field')
+ },
+ {
+ xtype: 'textfield',
+ reference: 'value',
+ name: 'value',
+ allowBlank: false,
+ fieldLabel: gettext('Value')
+ }
+ ]
+ },
4005: {
xtype: 'proxmoxWindowEdit',
subdir: 'bcc',
}
]
+ },
+ 4007: {
+ xtype: 'proxmoxWindowEdit',
+ subdir: 'removeattachments',
+ subject: gettext('Remove Attachments'),
+ width: 500,
+ fieldDefaults: {
+ labelWidth: 150
+ },
+ items: [
+ {
+ xtype: 'textfield',
+ name: 'name',
+ allowBlank: false,
+ fieldLabel: gettext('Name')
+ },
+ {
+ xtype: 'textareafield',
+ name: 'info',
+ fieldLabel: gettext("Description")
+ },
+ {
+ xtype: 'textareafield',
+ name: 'text',
+ grow: true,
+ growMax: 250,
+ fieldLabel: gettext("Text Replacement")
+ },
+ {
+ xtype: 'proxmoxcheckbox',
+ checked: true,
+ name: 'all',
+ fieldLabel: gettext("Remove all attachments")
+ }
+ ]
+ },
+ 4009: {
+ xtype: 'proxmoxWindowEdit',
+ subdir: 'disclaimer',
+ subject: gettext('Disclaimer'),
+ width: 400,
+ items: [
+ {
+ xtype: 'textfield',
+ name: 'name',
+ allowBlank: false,
+ fieldLabel: gettext('Name')
+ },
+ {
+ xtype: 'textareafield',
+ name: 'info',
+ fieldLabel: gettext("Description")
+ },
+ {
+ xtype: 'textareafield',
+ name: 'disclaimer',
+ grow: true,
+ growMax: 250,
+ fieldLabel: gettext("Disclaimer")
+ }
+ ]
}
},
extractQuarantineAction: function() {
- if (PMG.Utils.quarantineActionExtracted) return;
+ if (PMG.Utils.quarantineActionExtracted) { return; }
PMG.Utils.quarantineActionExtracted = true;
var cselect = qs.cselect;
var action = qs.action;
var ticket = qs.ticket;
+ var dateString = qs.date;
+
+ if (dateString) {
+ var date = new Date(dateString).getTime()/1000;
+
+ // set from date for QuarantineList
+ /*jslint confusion: true*/
+ /*from is a string above and number here */
+ PMG.QuarantineList.from = date;
+ /*jslint confusion: false*/
+ }
delete qs.cselect;
delete qs.action;
delete qs.ticket;
+ delete qs.date;
var newsearch = Ext.Object.toQueryString(qs);
var newurl = location.protocol + "//" + location.host + location.pathname;
- if (newsearch) newurl += '?' + newsearch;
+ if (newsearch) { newurl += '?' + newsearch; }
newurl += location.hash;
if (window.history) {
window.history.pushState({ path:newurl }, '', newurl);
}
- if (action && cselect) {
+ if (action || cselect) {
return { action: action, cselect: cselect };
}
},
+ doQuarantineAction: function(action, id, callback) {
+ Proxmox.Utils.API2Request({
+ url: '/quarantine/content/',
+ params: {
+ action: action,
+ id: id
+ },
+ method: 'POST',
+ failure: function(response, opts) {
+ Ext.Msg.alert(gettext('Error'), response.htmlStatus);
+ },
+ success: function(response, opts) {
+ var win = Ext.create('Ext.window.MessageBox',{
+ closeAction: 'destroy'
+ }).show({
+ title: gettext('Info'),
+ message: "Action '" + action + ' ' +
+ id + "' successful",
+ buttons: Ext.Msg.OK,
+ icon: Ext.MessageBox.INFO
+ });
+
+ if (Ext.isFunction(callback)) {
+ callback();
+ }
+ }
+ });
+ },
+
+ sender_renderer: function(value, metaData, rec) {
+ var subject = Ext.htmlEncode(value);
+ var from = Ext.htmlEncode(rec.data.from);
+ var sender = Ext.htmlEncode(rec.data.sender);
+ if (sender) {
+ /*jslint confusion: true*/
+ /*format is a string above*/
+ from = Ext.String.format(gettext("{0} on behalf of {1}"),
+ sender, from);
+ /*jslint confusion: false*/
+ }
+ return '<small>' + from + '</small><br>' + subject;
+ },
+
constructor: function() {
var me = this;