]> git.proxmox.com Git - pmg-gui.git/blobdiff - js/Utils.js
reword the action success message to not show the id
[pmg-gui.git] / js / Utils.js
index 942ccbbf520e256f3bcc22878b6350535b4e743e..852f653bb14a608ba33d969326672be71c9ae33d 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) {
@@ -148,7 +136,14 @@ Ext.define('PMG.Utils', {
                    xtype: 'textfield',
                    name: 'regex',
                    labelWidth: 150,
+                   reference: 'regex',
                    fieldLabel: gettext("Regular Expression")
+               },
+               {
+                   labelWidth: 150,
+                   fieldLabel: gettext('Test String'),
+                   xtype: 'pmgRegexTester',
+                   regexFieldReference: 'regex'
                }
            ]
        },
@@ -184,13 +179,13 @@ Ext.define('PMG.Utils', {
            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")
                }
            ]
        },
@@ -198,14 +193,14 @@ Ext.define('PMG.Utils', {
            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")
                }
            ]
        },
@@ -633,17 +628,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;
@@ -663,10 +647,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);
 
@@ -684,6 +680,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: {
@@ -699,8 +704,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
                });
@@ -710,6 +714,7 @@ Ext.define('PMG.Utils', {
                }
            }
        });
+       /*jslint confusion: false*/
     },
 
     sender_renderer: function(value, metaData, rec) {
@@ -717,8 +722,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;
     },