]> git.proxmox.com Git - pmg-gui.git/blobdiff - js/Utils.js
add archivefilter,spamlevel and filenamefilter to the otype_list
[pmg-gui.git] / js / Utils.js
index 80542494075f73688f704aa5c566167ffd0dbd08..af20b5377a9af4e19394e9b28a4aaa07af0ef350 100644 (file)
@@ -10,12 +10,30 @@ Ext.define('PMG.Utils', {
 
     senderText: gettext('Sender'),
     receiverText: gettext('Receiver'),
+    scoreText: gettext('Score'),
 
     oclass_text: {
        who: gettext('Who Objects'),
        what: gettext('What Objects'),
        when: gettext('When Objects'),
-       action: gettext('Action Objects')
+       action: gettext('Action Objects'),
+       from: gettext('From'),
+       to: gettext('To')
+    },
+
+    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> ',
+    },
+
+    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: {
@@ -24,8 +42,16 @@ Ext.define('PMG.Utils', {
        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) {
-       return PMG.Utils.rule_direction_text[dir] || 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) {
@@ -182,6 +208,152 @@ Ext.define('PMG.Utils', {
                }
            ]
        },
+       3000: {
+           xtype: 'proxmoxWindowEdit',
+           subdir: 'spamfilter',
+           subject: gettext('Spam Filter'),
+           items: [
+               {
+                   xtype: 'proxmoxintegerfield',
+                   name: 'spamlevel',
+                   allowBlank: false,
+                   minValue: 0,
+                   fieldLabel: gettext('Level')
+               },
+           ]
+       },
+       3002: {
+           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: {
+           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: {
+           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: {
+           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
+               }
+           ]
+       },
        4005: {
            xtype: 'proxmoxWindowEdit',
            subdir: 'bcc',
@@ -233,6 +405,39 @@ Ext.define('PMG.Utils', {
        Ext.util.Cookies.set('PMGAuthCookie', data.ticket, null, '/', null, true );
     },
 
+    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;
+
+       delete qs.cselect;
+       delete qs.action;
+       delete qs.ticket;
+
+       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);
+       }
+
+       if (action && cselect) {
+           return { action: action, cselect: cselect };
+       }
+    },
+
     constructor: function() {
        var me = this;