]> git.proxmox.com Git - pmg-gui.git/blobdiff - js/Utils.js
make who regex tests anchored
[pmg-gui.git] / js / Utils.js
index bb25f7c2bd33f6ae8e4918ec208444d7046289d0..ce15d06ebbe0d9a1443cb4a1e8fa12c73e399e18 100644 (file)
+/*global Proxmox */
 Ext.ns('PMG');
 
-// TODO: implement gettext
-function gettext(buf) { return buf; }
-
-// avoid errors related to Accessible Rich Internet Applications
-// (access for people with disabilities)
-// TODO reenable after all components are upgraded
-Ext.enableAria = false;
-Ext.enableAriaButtons = false;
-Ext.enableAriaPanels = false;
-
-// avoid errors when running without development tools
-if (!Ext.isDefined(Ext.global.console)) {
-    var console = {
-       dir: function() {},
-       log: function() {}
-    };
-}
 console.log("Starting PMG Manager");
 
-Ext.Ajax.defaultHeaders = {
-    'Accept': 'application/json'
-};
 
-Ext.Ajax.on('beforerequest', function(conn, options) {
-    if (PMG.CSRFPreventionToken) {
-       if (!options.headers) {
-           options.headers = {};
-       }
-       options.headers.CSRFPreventionToken = PMG.CSRFPreventionToken;
-    }
-});
-
-Ext.define('PMG.Utils', { utilities: {
+Ext.define('PMG.Utils', {
+    singleton: true,
 
     // this singleton contains miscellaneous utilities
 
-    authOK: function() {
-       return Ext.util.Cookies.get('PMGAuthCookie');
+    senderText: gettext('Sender'),
+    receiverText: gettext('Receiver'),
+    scoreText: gettext('Score'),
+
+    user_role_text: {
+       root: gettext('Superuser'),
+       admin: gettext('Administrator'),
+       helpdesk: gettext('Help Desk'),
+       qmanager: gettext('Quarantine Manager'),
+       audit: gettext('Auditor')
     },
 
-    authClear: function() {
-       Ext.util.Cookies.clear("PMGAuthCookie");
+    format_user_role: function(role) {
+       return PMG.Utils.user_role_text[role] || role;
     },
 
-    // comp.setLoading() is buggy in ExtJS 4.0.7, so we
-    // use el.mask() instead
-    setErrorMask: function(comp, msg) {
-       var el = comp.el;
-       if (!el) {
-           return;
-       }
-       if (!msg) {
-           el.unmask();
-       } else {
-           if (msg === true) {
-               el.mask(gettext("Loading..."));
-           } else {
-               el.mask(msg);
-           }
-       }
+    oclass_text: {
+       who: gettext('Who Objects'),
+       what: gettext('What Objects'),
+       when: gettext('When Objects'),
+       action: gettext('Action Objects'),
+       from: gettext('From'),
+       to: gettext('To')
     },
 
-    extractRequestError: function(result, verbose) {
-       var msg = gettext('Successful');
+    oclass_icon: {
+       who: '<span class="fa fa-fw fa-user-circle"></span> ',
+       what: '<span class="fa fa-fw fa-cube"></span> ',
+       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> '
+    },
 
-       if (!result.success) {
-           msg = gettext("Unknown error");
-           if (result.message) {
-               msg = result.message;
-               if (result.status) {
-                   msg += ' (' + result.status + ')';
-               }
-           }
-           if (verbose && Ext.isObject(result.errors)) {
-               msg += "<br>";
-               Ext.Object.each(result.errors, function(prop, desc) {
-                   msg += "<br><b>" + Ext.htmlEncode(prop) + "</b>: " +
-                       Ext.htmlEncode(desc);
-               });
-           }
-       }
+    mail_status_map: {
+       2: 'delivered',
+       4: 'deferred',
+       5: 'bounced',
+       N: 'rejected',
+       G: 'greylisted',
+       A: 'accepted',
+       B: 'blocked',
+       Q: 'quarantine'
+    },
 
-       return msg;
+    icon_status_map_class: {
+       2: 'check-circle',
+       4: 'clock-o',
+       5: 'mail-reply',
+       N: 'times-circle',
+       G: 'list',
+       A: 'check',
+       B: 'ban',
+       Q: 'cube'
     },
 
-    // Ext.Ajax.request
-    API2Request: function(reqOpts) {
+    icon_status_map_color: {
+       2: 'green',
+       5: 'gray',
+       A: 'green',
+       B: 'red'
+    },
 
-       var newopts = Ext.apply({
-           waitMsg: gettext('Please wait...')
-       }, reqOpts);
+    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> ';
+    },
 
-       if (!newopts.url.match(/^\/api2/)) {
-           newopts.url = '/api2/extjs' + newopts.url;
+    format_oclass: function(oclass) {
+       var icon = PMG.Utils.oclass_icon[oclass] || '';
+       var text = PMG.Utils.oclass_text[oclass] || oclass;
+       return icon + text;
+    },
+
+    rule_direction_text: {
+       0: gettext('In'),
+       1: gettext('Out'),
+       2: gettext('In & Out')
+    },
+
+    rule_direction_icon: {
+       0: '<span class="fa fa-fw fa-long-arrow-left"></span> ',
+       1: '<span class="fa fa-fw fa-long-arrow-right"></span> ',
+       2: '<span class="fa fa-fw fa-exchange"></span> '
+    },
+
+    format_rule_direction: function(dir) {
+       var icon = PMG.Utils.rule_direction_icon[dir] || '';
+       var text = PMG.Utils.rule_direction_text[dir] || dir;
+       return icon + text;
+    },
+
+    format_otype: function(otype) {
+       var editor = PMG.Utils.object_editors[otype];
+       var iconCls = 'fa fa-question-circle';
+       if (editor) {
+           var icon = '<span class="fa-fw ' + (editor.iconCls || iconCls) + '"></span> ';
+           return icon + editor.subject;
        }
-       delete newopts.callback;
 
-       var createWrapper = function(successFn, callbackFn, failureFn) {
-           Ext.apply(newopts, {
-               success: function(response, options) {
-                   if (options.waitMsgTarget) {
-                       options.waitMsgTarget.setLoading(false);
-                   }
-                   var result = Ext.decode(response.responseText);
-                   response.result = result;
-                   if (!result.success) {
-                       response.htmlStatus = PMG.Utils.extractRequestError(result, true);
-                       Ext.callback(callbackFn, options.scope, [options, false, response]);
-                       Ext.callback(failureFn, options.scope, [response, options]);
-                       return;
-                   }
-                   Ext.callback(callbackFn, options.scope, [options, true, response]);
-                   Ext.callback(successFn, options.scope, [response, options]);
+       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'; }
+       return 'unknown';
+    },
+
+    convert_field_to_per_min: function(value, record) {
+       return (value/(record.data.timespan/60));
+    },
+
+    object_editors: {
+       1000: {
+           onlineHelp: 'pmg_mailfilter_regex',
+           iconCls: 'fa fa-filter',
+           xtype: 'proxmoxWindowEdit',
+           subdir: 'regex',
+           subject: gettext("Regular Expression"),
+           width: 400,
+           items: [
+               {
+                   xtype: 'textfield',
+                   name: 'regex',
+                   labelWidth: 150,
+                   reference: 'regex',
+                   fieldLabel: gettext("Regular Expression")
+               },
+               {
+                   labelWidth: 150,
+                   fieldLabel: gettext('Test String'),
+                   xtype: 'pmgRegexTester',
+                   wholeMatch: true,
+                   regexFieldReference: 'regex'
+               }
+           ]
+       },
+       1005: {
+           onlineHelp: 'pmgconfig_ldap',
+           iconCls: 'fa fa-users',
+           xtype: 'pmgLDAPGroupEditor',
+           subdir: 'ldap',
+           subject: gettext("LDAP Group")
+       },
+       1006: {
+           onlineHelp: 'pmgconfig_ldap',
+           iconCls: 'fa fa-user',
+           xtype: 'pmgLDAPUserEditor',
+           subdir: 'ldapuser',
+           subject: gettext("LDAP User")
+       },
+       1009: {
+           onlineHelp: 'pmg_mailfilter_regex',
+           iconCls: 'fa fa-filter',
+           xtype: 'proxmoxWindowEdit',
+           subdir: 'receiver_regex',
+           subject: gettext("Regular Expression"),
+           receivertest: true,
+           width: 400,
+           items: [
+               {
+                   xtype: 'textfield',
+                   name: 'regex',
+                   labelWidth: 150,
+                   fieldLabel: gettext("Regular Expression")
+               }
+           ]
+       },
+       1001: {
+           onlineHelp: 'pmg_mailfilter_who',
+           iconCls: 'fa fa-envelope-o',
+           xtype: 'proxmoxWindowEdit',
+           subdir: 'email',
+           subject: gettext("E-Mail"),
+           width: 400,
+           items: [
+               {
+                   xtype: 'textfield',
+                   name: 'email',
+                   fieldLabel: gettext("E-Mail")
+               }
+           ]
+       },
+       1007: {
+           onlineHelp: 'pmg_mailfilter_who',
+           iconCls: 'fa fa-envelope-o',
+           xtype: 'proxmoxWindowEdit',
+           subdir: 'receiver',
+           subject: gettext("E-Mail"),
+           receivertest: true,
+           width: 400,
+           items: [
+               {
+                   xtype: 'textfield',
+                   name: 'email',
+                   fieldLabel: gettext("E-Mail")
+               }
+           ]
+       },
+       1002: {
+           onlineHelp: 'pmg_mailfilter_who',
+           iconCls: 'fa fa-globe',
+           xtype: 'proxmoxWindowEdit',
+           subdir: 'domain',
+           subject: gettext("Domain"),
+           width: 400,
+           items: [
+               {
+                   xtype: 'textfield',
+                   name: 'domain',
+                   fieldLabel: gettext("Domain")
+               }
+           ]
+       },
+       1008: {
+           onlineHelp: 'pmg_mailfilter_who',
+           iconCls: 'fa fa-globe',
+           xtype: 'proxmoxWindowEdit',
+           subdir: 'receiver_domain',
+           subject: gettext("Domain"),
+           receivertest: true,
+           width: 400,
+           items: [
+               {
+                   xtype: 'textfield',
+                   name: 'domain',
+                   fieldLabel: gettext("Domain")
+               }
+           ]
+       },
+       1003: {
+           onlineHelp: 'pmg_mailfilter_who',
+           iconCls: 'fa fa-globe',
+           xtype: 'proxmoxWindowEdit',
+           subdir: 'ip',
+           subject: gettext("IP Address"),
+           width: 400,
+           items: [
+               {
+                   xtype: 'textfield',
+                   name: 'ip',
+                   fieldLabel: gettext("IP Address")
+               }
+           ]
+       },
+       1004: {
+           onlineHelp: 'pmg_mailfilter_who',
+           iconCls: 'fa fa-globe',
+           xtype: 'proxmoxWindowEdit',
+           subdir: 'network',
+           subject: gettext("IP Network"),
+           width: 400,
+           items: [
+               {
+                   xtype: 'textfield',
+                   name: 'cidr',
+                   fieldLabel: gettext("IP Network")
+               }
+           ]
+       },
+       2000: {
+           onlineHelp: 'pmg_mailfilter_when',
+           iconCls: 'fa fa-clock-o',
+           xtype: 'proxmoxWindowEdit',
+           subdir: 'timeframe',
+           subject: gettext("TimeFrame"),
+           items: [
+               {
+                   xtype: 'timefield',
+                   name: 'start',
+                   format: 'H:i',
+                   fieldLabel: gettext("Start Time")
                },
-               failure: function(response, options) {
-                   if (options.waitMsgTarget) {
-                       options.waitMsgTarget.setLoading(false);
+               {
+                   xtype: 'timefield',
+                   name: 'end',
+                   format: 'H:i',
+                   fieldLabel: gettext("End Time")
+               }
+           ]
+       },
+       3000: {
+           onlineHelp: 'pmg_mailfilter_what',
+           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: {
+           onlineHelp: 'pmg_mailfilter_what',
+           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: {
+           onlineHelp: 'pmg_mailfilter_regex',
+           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: {
+           onlineHelp: 'pmg_mailfilter_what',
+           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);
+                       }
                    }
-                   response.result = {};
-                   try {
-                       response.result = Ext.decode(response.responseText);
-                   } catch(e) {}
-                   var msg = gettext('Connection error') + ' - server offline?';
-                   if (response.aborted) {
-                       msg = gettext('Connection error') + ' - aborted.';
-                   } else if (response.timedout) {
-                       msg = gettext('Connection error') + ' - Timeout.';
-                   } else if (response.status && response.statusText) {
-                       msg = gettext('Connection error') + ' ' + response.status + ': ' + response.statusText;
+               },
+               {
+                   xtype: 'displayfield',
+                   fieldLabel: gettext('Value'),
+                   labelWidth: 150,
+                   allowBlank: false,
+                   reset: Ext.emptyFn
+               }
+           ]
+       },
+       3004: {
+           onlineHelp: 'pmg_mailfilter_regex',
+           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: {
+           onlineHelp: 'pmg_mailfilter_what',
+           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);
+                       }
                    }
-                   response.htmlStatus = msg;
-                   Ext.callback(callbackFn, options.scope, [options, false, response]);
-                   Ext.callback(failureFn, options.scope, [response, options]);
+               },
+               {
+                   xtype: 'displayfield',
+                   fieldLabel: gettext('Value'),
+                   labelWidth: 150,
+                   allowBlank: false,
+                   reset: Ext.emptyFn
                }
-           });
-       };
-
-       createWrapper(reqOpts.success, reqOpts.callback, reqOpts.failure);
+           ]
+       },
+       4002: {
+           onlineHelp: 'pmg_mailfilter_action',
+           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: {
+           onlineHelp: 'pmg_mailfilter_action',
+           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: {
+           onlineHelp: 'pmg_mailfilter_action',
+           xtype: 'proxmoxWindowEdit',
+           subdir: 'bcc',
+           subject: gettext('BCC'),
+           width: 400,
+           items: [
+               {
+                   xtype: 'textfield',
+                   name: 'name',
+                   allowBlank: false,
+                   fieldLabel: gettext('Name')
+               },
+               {
+                   xtype: 'textareafield',
+                   name: 'info',
+                   fieldLabel: gettext("Description")
+               },
+               {
+                   xtype: 'textfield',
+                   name: 'target',
+                   allowBlank: false,
+                   fieldLabel: gettext("Target")
+               },
+               {
+                   xtype: 'proxmoxcheckbox',
+                   checked: true,
+                   name: 'original',
+                   fieldLabel: gettext("send orig. Mail")
+               }
+           ]
 
-       var target = newopts.waitMsgTarget;
-       if (target) {
-           // Note: ExtJS bug - this does not work when component is not rendered
-           target.setLoading(newopts.waitMsg);
+       },
+       4007: {
+           onlineHelp: 'pmg_mailfilter_action',
+           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: {
+           onlineHelp: 'pmg_mailfilter_action',
+           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")
+               }
+           ]
        }
-       Ext.Ajax.request(newopts);
     },
 
-    yesText: gettext('Yes'),
-    noText: gettext('No') 
-
+    updateLoginData: function(data) {
+       Proxmox.CSRFPreventionToken = data.CSRFPreventionToken;
+       Proxmox.UserName = data.username;
+       Ext.util.Cookies.set('PMGAuthCookie', data.ticket, null, '/', null, true );
     },
-                         
-    singleton: true,
-    constructor: function() {
-       var me = this;
-       Ext.apply(me, me.utilities);
 
-       var IPV4_OCTET = "(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])";
-       var IPV4_REGEXP = "(?:(?:" + IPV4_OCTET + "\\.){3}" + IPV4_OCTET + ")";
-       var IPV6_H16 = "(?:[0-9a-fA-F]{1,4})";
-       var IPV6_LS32 = "(?:(?:" + IPV6_H16 + ":" + IPV6_H16 + ")|" + IPV4_REGEXP + ")";
+    quarantineActionExtracted: false,
+
+    extractQuarantineAction: function() {
+
+       if (PMG.Utils.quarantineActionExtracted) { return; }
+
+       PMG.Utils.quarantineActionExtracted = true;
+
+       var qs = Ext.Object.fromQueryString(location.search);
+
+       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; }
+       newurl += location.hash;
 
+       if (window.history) {
+           window.history.pushState({ path:newurl }, '', newurl);
+       }
 
-       me.IP4_match = new RegExp("^(?:" + IPV4_REGEXP + ")$");
-       me.IP4_cidr_match = new RegExp("^(?:" + IPV4_REGEXP + ")\/([0-9]{1,2})$");
+       if (action || cselect) {
+           return { action: action, cselect: cselect };
+       }
+    },
 
-       var IPV6_REGEXP = "(?:" +
-           "(?:(?:"                                                  + "(?:" + IPV6_H16 + ":){6})" + IPV6_LS32 + ")|" +
-           "(?:(?:"                                         +   "::" + "(?:" + IPV6_H16 + ":){5})" + IPV6_LS32 + ")|" +
-           "(?:(?:(?:"                           + IPV6_H16 + ")?::" + "(?:" + IPV6_H16 + ":){4})" + IPV6_LS32 + ")|" +
-           "(?:(?:(?:(?:" + IPV6_H16 + ":){0,1}" + IPV6_H16 + ")?::" + "(?:" + IPV6_H16 + ":){3})" + IPV6_LS32 + ")|" +
-           "(?:(?:(?:(?:" + IPV6_H16 + ":){0,2}" + IPV6_H16 + ")?::" + "(?:" + IPV6_H16 + ":){2})" + IPV6_LS32 + ")|" +
-           "(?:(?:(?:(?:" + IPV6_H16 + ":){0,3}" + IPV6_H16 + ")?::" + "(?:" + IPV6_H16 + ":){1})" + IPV6_LS32 + ")|" +
-           "(?:(?:(?:(?:" + IPV6_H16 + ":){0,4}" + IPV6_H16 + ")?::" +                         ")" + IPV6_LS32 + ")|" +
-           "(?:(?:(?:(?:" + IPV6_H16 + ":){0,5}" + IPV6_H16 + ")?::" +                         ")" + IPV6_H16  + ")|" +
-           "(?:(?:(?:(?:" + IPV6_H16 + ":){0,7}" + IPV6_H16 + ")?::" +                         ")"             + ")"  +
-           ")";
+    doQuarantineAction: function(action, id, callback) {
+       var count = id.split(';').length;
+       var successMessage = "Action '{0}'";
+       if (count > 1) {
+           successMessage += " for '{1}' items";
+       }
+       successMessage += " successful";
 
-       me.IP6_match = new RegExp("^(?:" + IPV6_REGEXP + ")$");
-       me.IP6_cidr_match = new RegExp("^(?:" + IPV6_REGEXP + ")\/([0-9]{1,3})$");
-       me.IP6_bracket_match = new RegExp("^\\[(" + IPV6_REGEXP + ")\\]");
+       /*jslint confusion: true*/
+       /*format is string and function*/
+       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: Ext.String.format(successMessage, action, count),
+                   buttons: Ext.Msg.OK,
+                   icon: Ext.MessageBox.INFO
+               });
 
-       me.IP64_match = new RegExp("^(?:" + IPV6_REGEXP + "|" + IPV4_REGEXP + ")$");
+               if (Ext.isFunction(callback)) {
+                   callback();
+               }
+           }
+       });
+       /*jslint confusion: false*/
+    },
+
+    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;
+    },
 
-       var DnsName_REGEXP = "(?:(([a-zA-Z0-9]([a-zA-Z0-9\\-]*[a-zA-Z0-9])?)\\.)*([A-Za-z0-9]([A-Za-z0-9\\-]*[A-Za-z0-9])?))";
-       me.DnsName_match = new RegExp("^" + DnsName_REGEXP + "$");
+    constructor: function() {
+       var me = this;
 
-       me.HostPort_match = new RegExp("^(" + IPV4_REGEXP + "|" + DnsName_REGEXP + ")(:\\d+)?$");
-       me.HostPortBrackets_match = new RegExp("^\\[(?:" + IPV6_REGEXP + "|" + IPV4_REGEXP + "|" + DnsName_REGEXP + ")\\](:\\d+)?$");
-       me.IP6_dotnotation_match = new RegExp("^" + IPV6_REGEXP + "(\\.\\d+)?$");
+       // do whatever you want here
     }
 });