]> git.proxmox.com Git - pmg-gui.git/blobdiff - js/UserBlackWhiteList.js
ui: trim whitespaces when adding a subscription key
[pmg-gui.git] / js / UserBlackWhiteList.js
index 02c8c68ffea7218ba8c479324bf2292ff687822d..6cc6b10ac255a628a7ea6ef28a873d2a8162e859 100644 (file)
@@ -1,4 +1,3 @@
-/*global Proxmox*/
 Ext.define('pmg-address-list', {
     extend: 'Ext.data.Model',
     fields: ['address'],
@@ -21,16 +20,16 @@ Ext.define('PMG.UserBlackWhiteList', {
         xclass: 'Ext.app.ViewController',
 
        onAddAddress: function() {
-           var me = this.getView();
-           var params = me.getStore().getProxy().getExtraParams() || {};
+           let view = this.getView();
+           let params = view.getStore().getProxy().getExtraParams() || {};
 
-           var url = '/quarantine/' + me.listname;
+           let url = '/quarantine/' + view.listname;
 
-           var items = [{
+           let items = [{
                xtype: 'proxmoxtextfield',
                name: 'address',
                minLength: 3,
-               regex: /^[^\,\;\s]*$/, // no whitespace no , and no ;
+               regex: /^[^,;\s]*$/, // no whitespace no , and no ;
                fieldLabel: gettext("Address"),
            }];
 
@@ -42,7 +41,7 @@ Ext.define('PMG.UserBlackWhiteList', {
                });
            });
 
-           var config = {
+           let config = {
                method: 'POST',
                url: url,
                onlineHelp: 'pmg_userblackwhitelist',
@@ -51,39 +50,39 @@ Ext.define('PMG.UserBlackWhiteList', {
                items: items,
            };
 
-           if (me.listname === 'blacklist') {
+           if (view.listname === 'blacklist') {
                config.subject = gettext("Blacklist");
-           } else if (me.listname == 'whitelist') {
+           } else if (view.listname === 'whitelist') {
                config.subject = gettext("Whitelist");
            } else {
                throw "unknown list - internal error";
            }
 
-           var win = Ext.createWidget('proxmoxWindowEdit', config);
-           win.on('destroy', function() { me.store.load(); });
+           let win = Ext.createWidget('proxmoxWindowEdit', config);
+           win.on('destroy', function() { view.store.load(); });
            win.show();
        },
 
        onRemoveAddress: function() {
-           var me = this.getView();
-           var records = me.selModel.getSelection();
+           let view = this.getView();
+           let records = view.selModel.getSelection();
            if (records.length < 1) {
                return;
            }
 
-           var url = '/quarantine/' + me.listname + '/';
+           let url = '/quarantine/' + view.listname + '/';
 
            let params = {
                address: records.map((rec) => rec.getId()).join(','),
            };
-           Ext.applyIf(params, me.getStore().getProxy().getExtraParams());
+           Ext.applyIf(params, view.getStore().getProxy().getExtraParams());
 
            Proxmox.Utils.API2Request({
                url: url + '?' + Ext.Object.toQueryString(params),
                method: 'DELETE',
-               waitMsgTarget: me,
+               waitMsgTarget: view,
                callback: function(options, success, response) {
-                   me.store.load();
+                   view.store.load();
                },
                failure: function(response, opts) {
                    Ext.Msg.alert(gettext('Error'), response.htmlStatus);
@@ -92,7 +91,7 @@ Ext.define('PMG.UserBlackWhiteList', {
        },
 
        changeEmail: function(combobox, value) {
-           var view = this.getView();
+           let view = this.getView();
            if (value && combobox.isValid()) {
                view.getStore().getProxy().setExtraParams({
                    pmail: value,
@@ -102,7 +101,7 @@ Ext.define('PMG.UserBlackWhiteList', {
        },
 
        init: function(view) {
-           var emailcb = this.lookupReference('email');
+           let emailcb = this.lookupReference('email');
            if (PMG.view === 'quarantineview') {
                emailcb.setVisible(false);
                view.getStore().load();
@@ -128,7 +127,7 @@ Ext.define('PMG.UserBlackWhiteList', {
        {
            xtype: 'combobox',
            displayField: 'mail',
-           vtype: 'email',
+           vtype: 'PMGMail',
            allowBlank: false,
            valueField: 'mail',
            store: {
@@ -154,7 +153,7 @@ Ext.define('PMG.UserBlackWhiteList', {
                gettext('No data in database') +
                '</div>',
            },
-           fieldLabel: 'E-Mail',
+           fieldLabel: gettext('E-Mail'),
        },
        {
            text: gettext('Add'),
@@ -166,18 +165,16 @@ Ext.define('PMG.UserBlackWhiteList', {
            disabled: true,
            handler: 'onRemoveAddress',
            confirmMsg: function() {
-               var me = this.up('gridpanel');
-
-               var selection = me.selModel.getSelection();
-               var text;
-               var param;
+               let view = this.up('gridpanel');
 
+               let selection = view.selModel.getSelection();
+               let text, param;
                if (selection.length > 1) {
                    text = gettext('Are you sure you want to remove {0} entries');
                    param = selection.length.toString();
                } else if (selection.length > 0) {
-                   var rec = selection[0];
-                   var name = rec.getId();
+                   let rec = selection[0];
+                   let name = rec.getId();
                    text = gettext('Are you sure you want to remove entry {0}');
                    param = "'" + Ext.String.htmlEncode(name) + "'";
                }
@@ -185,6 +182,7 @@ Ext.define('PMG.UserBlackWhiteList', {
                if (text && param) {
                    return Ext.String.format(text, param);
                }
+               return false;
            },
        },
     ],
@@ -227,11 +225,10 @@ Ext.define('PMG.UserBlacklist', {
                'border-left': '0px',
                'border-right': '0px',
            },
-            html: gettext('With this feature, you can manually mark E-mails from certain domains or addresses as spam.') + '<br><br>' +
-               '<b>*.com</b> (all mails from <b>.com</b> domains)' + '<br>' +
-               '<b>*@example.com</b> (all mails from domain <b>example.com</b>)' + '<br>' +
-               '<b>john@example.com</b> (all mails from <b>john@example.com</b>)',
-
+            html: gettext('With this feature, you can manually mark E-mails from certain domains or addresses as spam.') + `<br><br>
+               <b>*.com</b> (all mails from <b>.com</b> domains)<br>
+               <b>*@example.com</b> (all mails from domain <b>example.com</b>)<br>
+               <b>john@example.com</b> (all mails from <b>john@example.com</b>)`,
         },
     ],
 });
@@ -264,10 +261,10 @@ Ext.define('PMG.UserWhitelist', {
                'border-left': '0px',
                'border-right': '0px',
            },
-            html: gettext('With this feature, you can manually bypass spam checking for certain domains or E-mail addresses.') + '<br><br>' +
-               '<b>*.com</b> (all mails from <b>.com</b> domains)' + '<br>' +
-               '<b>*@example.com</b> (all mails from domain <b>example.com</b>)' + '<br>' +
-               '<b>john@example.com</b> (all mails from <b>john@example.com</b>)',
+            html: gettext('With this feature, you can manually bypass spam checking for certain domains or E-mail addresses.') + `<br><br>
+               <b>*.com</b> (all mails from <b>.com</b> domains)<br>
+               <b>*@example.com</b> (all mails from domain <b>example.com</b>)<br>
+               <b>john@example.com</b> (all mails from <b>john@example.com</b>)`,
         },
     ],
 });