]> git.proxmox.com Git - pmg-gui.git/blobdiff - js/Utils.js
make who regex tests anchored
[pmg-gui.git] / js / Utils.js
index 73cd336b12b14df924452b32309f3ddd46772295..ce15d06ebbe0d9a1443cb4a1e8fa12c73e399e18 100644 (file)
@@ -16,8 +16,9 @@ Ext.define('PMG.Utils', {
     user_role_text: {
        root: gettext('Superuser'),
        admin: gettext('Administrator'),
+       helpdesk: gettext('Help Desk'),
        qmanager: gettext('Quarantine Manager'),
-       audit: gettext('Auditor'),
+       audit: gettext('Auditor')
     },
 
     format_user_role: function(role) {
@@ -53,41 +54,28 @@ Ext.define('PMG.Utils', {
        Q: 'quarantine'
     },
 
-    icon_status_map: {
-       2: {
-           fa: 'check-circle',
-           color: 'green'
-       },
-       4: {
-           fa: 'clock-o',
-       },
-       5: {
-           fa: 'mail-reply',
-           color: 'gray'
-       },
-       N: {
-           fa: 'times-circle'
-       },
-       G: {
-           fa: 'list'
-       },
-       A: {
-           fa: 'check',
-           color: 'green'
-       },
-       B: {
-           fa: 'ban',
-           color: 'red'
-       },
-       Q: {
-           fa: 'cube'
-       }
+    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[status] || {};
-       return '<i class="fa fa-' + (icon.fa || 'question-circle') + ' ' +
-              (icon.color || '') + '"></i> ';
+       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) {
@@ -138,6 +126,7 @@ Ext.define('PMG.Utils', {
 
     object_editors: {
        1000: {
+           onlineHelp: 'pmg_mailfilter_regex',
            iconCls: 'fa fa-filter',
            xtype: 'proxmoxWindowEdit',
            subdir: 'regex',
@@ -155,23 +144,27 @@ Ext.define('PMG.Utils', {
                    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',
@@ -188,35 +181,38 @@ Ext.define('PMG.Utils', {
            ]
        },
        1001: {
+           onlineHelp: 'pmg_mailfilter_who',
            iconCls: 'fa fa-envelope-o',
            xtype: 'proxmoxWindowEdit',
            subdir: 'email',
-           subject: gettext("Email"),
+           subject: gettext("E-Mail"),
            width: 400,
            items: [
                {
                    xtype: 'textfield',
                    name: 'email',
-                   fieldLabel: gettext("Email")
+                   fieldLabel: gettext("E-Mail")
                }
            ]
        },
        1007: {
+           onlineHelp: 'pmg_mailfilter_who',
            iconCls: 'fa fa-envelope-o',
            xtype: 'proxmoxWindowEdit',
            subdir: 'receiver',
-           subject: gettext("Email"),
+           subject: gettext("E-Mail"),
            receivertest: true,
            width: 400,
            items: [
                {
                    xtype: 'textfield',
                    name: 'email',
-                   fieldLabel: gettext("Email")
+                   fieldLabel: gettext("E-Mail")
                }
            ]
        },
        1002: {
+           onlineHelp: 'pmg_mailfilter_who',
            iconCls: 'fa fa-globe',
            xtype: 'proxmoxWindowEdit',
            subdir: 'domain',
@@ -231,6 +227,7 @@ Ext.define('PMG.Utils', {
            ]
        },
        1008: {
+           onlineHelp: 'pmg_mailfilter_who',
            iconCls: 'fa fa-globe',
            xtype: 'proxmoxWindowEdit',
            subdir: 'receiver_domain',
@@ -246,6 +243,7 @@ Ext.define('PMG.Utils', {
            ]
        },
        1003: {
+           onlineHelp: 'pmg_mailfilter_who',
            iconCls: 'fa fa-globe',
            xtype: 'proxmoxWindowEdit',
            subdir: 'ip',
@@ -260,6 +258,7 @@ Ext.define('PMG.Utils', {
            ]
        },
        1004: {
+           onlineHelp: 'pmg_mailfilter_who',
            iconCls: 'fa fa-globe',
            xtype: 'proxmoxWindowEdit',
            subdir: 'network',
@@ -274,6 +273,7 @@ Ext.define('PMG.Utils', {
            ]
        },
        2000: {
+           onlineHelp: 'pmg_mailfilter_when',
            iconCls: 'fa fa-clock-o',
            xtype: 'proxmoxWindowEdit',
            subdir: 'timeframe',
@@ -294,6 +294,7 @@ Ext.define('PMG.Utils', {
            ]
        },
        3000: {
+           onlineHelp: 'pmg_mailfilter_what',
            iconCls: 'fa fa-bullhorn',
            xtype: 'proxmoxWindowEdit',
            subdir: 'spamfilter',
@@ -309,6 +310,7 @@ Ext.define('PMG.Utils', {
            ]
        },
        3001: {
+           onlineHelp: 'pmg_mailfilter_what',
            iconCls: 'fa fa-bug',
            xtype: 'proxmoxWindowEdit',
            subdir: 'virusfilter',
@@ -322,6 +324,7 @@ Ext.define('PMG.Utils', {
            }
        },
        3002: {
+           onlineHelp: 'pmg_mailfilter_regex',
            iconCls: 'fa fa-code',
            xtype: 'proxmoxWindowEdit',
            subdir: 'matchfield',
@@ -352,6 +355,7 @@ Ext.define('PMG.Utils', {
            ]
        },
        3003: {
+           onlineHelp: 'pmg_mailfilter_what',
            iconCls: 'fa fa-file-image-o',
            xtype: 'proxmoxWindowEdit',
            subdir: 'contenttype',
@@ -393,6 +397,7 @@ Ext.define('PMG.Utils', {
            ]
        },
        3004: {
+           onlineHelp: 'pmg_mailfilter_regex',
            iconCls: 'fa fa-file-o',
            xtype: 'proxmoxWindowEdit',
            subdir: 'filenamefilter',
@@ -417,6 +422,7 @@ Ext.define('PMG.Utils', {
            ]
        },
        3005: {
+           onlineHelp: 'pmg_mailfilter_what',
            iconCls: 'fa fa-file-archive-o',
            xtype: 'proxmoxWindowEdit',
            subdir: 'archivefilter',
@@ -458,6 +464,7 @@ Ext.define('PMG.Utils', {
            ]
        },
        4002: {
+           onlineHelp: 'pmg_mailfilter_action',
            xtype: 'proxmoxWindowEdit',
            subdir: 'notification',
            subject: gettext('Notification'),
@@ -514,6 +521,7 @@ Ext.define('PMG.Utils', {
            ]
        },
        4003: {
+           onlineHelp: 'pmg_mailfilter_action',
            xtype: 'proxmoxWindowEdit',
            subdir: 'field',
            subject: gettext('Header Attribute'),
@@ -546,6 +554,7 @@ Ext.define('PMG.Utils', {
            ]
        },
        4005: {
+           onlineHelp: 'pmg_mailfilter_action',
            xtype: 'proxmoxWindowEdit',
            subdir: 'bcc',
            subject: gettext('BCC'),
@@ -578,6 +587,7 @@ Ext.define('PMG.Utils', {
 
        },
        4007: {
+           onlineHelp: 'pmg_mailfilter_action',
            xtype: 'proxmoxWindowEdit',
            subdir: 'removeattachments',
            subject: gettext('Remove Attachments'),
@@ -613,6 +623,7 @@ Ext.define('PMG.Utils', {
            ]
        },
        4009: {
+           onlineHelp: 'pmg_mailfilter_action',
            xtype: 'proxmoxWindowEdit',
            subdir: 'disclaimer',
            subject: gettext('Disclaimer'),
@@ -640,17 +651,6 @@ Ext.define('PMG.Utils', {
        }
     },
 
-    openVNCViewer: function(consoletype, nodename) {
-       var url = Ext.urlEncode({
-           console: consoletype, // upgrade or shell
-           novnc: 1,
-           node: nodename
-       });
-       var nw = window.open("?" + url, '_blank',
-                            "innerWidth=745,innerheight=427");
-       nw.focus();
-    },
-
     updateLoginData: function(data) {
        Proxmox.CSRFPreventionToken = data.CSRFPreventionToken;
        Proxmox.UserName = data.username;
@@ -670,10 +670,22 @@ Ext.define('PMG.Utils', {
        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);
 
@@ -691,6 +703,15 @@ Ext.define('PMG.Utils', {
     },
 
     doQuarantineAction: function(action, id, callback) {
+       var count = id.split(';').length;
+       var successMessage = "Action '{0}'";
+       if (count > 1) {
+           successMessage += " for '{1}' items";
+       }
+       successMessage += " successful";
+
+       /*jslint confusion: true*/
+       /*format is string and function*/
        Proxmox.Utils.API2Request({
            url: '/quarantine/content/',
            params: {
@@ -706,8 +727,7 @@ Ext.define('PMG.Utils', {
                    closeAction: 'destroy'
                }).show({
                    title: gettext('Info'),
-                   message: "Action '" + action + ' ' +
-                   id + "' successful",
+                   message: Ext.String.format(successMessage, action, count),
                    buttons: Ext.Msg.OK,
                    icon: Ext.MessageBox.INFO
                });
@@ -717,6 +737,7 @@ Ext.define('PMG.Utils', {
                }
            }
        });
+       /*jslint confusion: false*/
     },
 
     sender_renderer: function(value, metaData, rec) {
@@ -724,8 +745,11 @@ Ext.define('PMG.Utils', {
        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;
     },