]> git.proxmox.com Git - pmg-gui.git/commitdiff
eslint fixes
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 30 Oct 2020 13:08:16 +0000 (14:08 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 30 Oct 2020 13:08:16 +0000 (14:08 +0100)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
26 files changed:
js/ActionList.js
js/Application.js
js/AttachmentGrid.js
js/BackupRestore.js
js/ClusterAdministration.js
js/ConfigPanel.js
js/LDAPConfig.js
js/LDAPGroupEditor.js
js/LoginView.js
js/MailTracker.js
js/MainView.js
js/ObjectGroup.js
js/QuarantineList.js
js/QuarantineView.js
js/RegexTester.js
js/RuleConfiguration.js
js/ServerStatus.js
js/SpamContextMenu.js
js/SpamDetectorCustom.js
js/SpamDetectorLanguages.js
js/SpamDetectorStatus.js
js/StatTimeSelector.js
js/Subscription.js
js/SystemOptions.js
js/UserBlackWhiteList.js
js/ViewMailHeaders.js

index a375636a98ec095fede154ab8e3358479eaf0eb9..bb13a5bb51ffbc16e0aff649c29720f01b4a9771 100644 (file)
@@ -85,7 +85,7 @@ Ext.define('PMG.ActionList', {
            menu_items.push({
                text: config.subject,
                handler: function() {
-                   if (me.baseurl == undefined) {
+                   if (me.baseurl === undefined) {
                        return;
                    }
                    config.url = me.baseurl + '/' + editor.subdir;
index beaf816d01ce84773e921634cae597ea733881b2..f5f673c5420050fcf1ce1df38210e81835b45b1a 100644 (file)
@@ -33,7 +33,7 @@ Ext.define('PMG.Application', {
            targetview: me.targetview,
        });
        if (skipCheck !== true) {
-           Proxmox.Utils.checked_command(function() {}); // display subscription status
+           Proxmox.Utils.checked_command(Ext.emptyFn); // display subscription status
        }
     },
 
@@ -57,7 +57,7 @@ Ext.define('PMG.Application', {
        if (pathname === "/quarantine") {
            me.targetview = 'quarantineview';
 
-           if (qs.ticket == undefined && loggedin) {
+           if (qs.ticket === undefined && loggedin) {
                me.view = 'quarantineview';
            }
        } else if (loggedin && cookie.substr(0, 7) !== 'PMGQUAR') {
index c86d4da33d440d360eecb10b8ddc23271b5d721f..7e630dee2bcf15268781604536bcd7b6688c7f13 100644 (file)
@@ -25,7 +25,7 @@ Ext.define('PMG.grid.AttachmentGrid', {
     emptyText: gettext('No Attachments'),
 
     download: function() {
-       alert(arguments);
+       Ext.Msg.alert(arguments);
     },
 
     columns: [
@@ -50,11 +50,10 @@ Ext.define('PMG.grid.AttachmentGrid', {
            header: gettext('Download'),
            renderer: function(value, mD, rec) {
                var me = this;
-               let url = '/api2/json/quarantine/download';
-               url += '?mailid=' + me.mailid;
-               url += '&attachmentid=' + rec.data.id;
-               return "<a target='_blank' class='download' download='"+ rec.data.name +"' href='" +
-               url + "'><i class='fa fa-fw fa-download'</i></a>";
+               let url = `/api2/json/quarantine/download?mailid=${me.mailid}&attachmentid=${rec.data.id}`;
+               return `<a target='_blank' class='download' download='${rec.data.name}' href='${url}'>
+                   <i class='fa fa-fw fa-download'</i>
+               </a>`;
            },
        },
     ],
index 6c9723065f7f6ecdf0939a16595fc8e6c9877a8e..b66a80ebc3ca374b244f8205e12707bf6c30ca27 100644 (file)
@@ -39,9 +39,8 @@ Ext.define('PMG.RestoreWindow', {
            uncheckedValue: 0,
            fieldLabel: gettext('Rule Database'),
            listeners: {
-               change: function(cb, value) {
-                   var me = this;
-                   me.up().down('field[name=statistic]').setDisabled(!value);
+               change: function(field, value) {
+                   field.nextSibling('field[name=statistic]').setDisabled(!value);
                },
            },
        },
@@ -53,13 +52,13 @@ Ext.define('PMG.RestoreWindow', {
     ],
 
     initComponent: function() {
-       var me = this;
+       let me = this;
 
        if (!me.filename) {
            throw "no filename given";
        }
 
-       me.url = "/nodes/" + Proxmox.NodeName + "/backup/" + encodeURIComponent(me.filename);
+       me.url = `/nodes/${Proxmox.NodeName}/backup/${encodeURIComponent(me.filename)}`;
 
        me.callParent();
     },
@@ -75,29 +74,29 @@ Ext.define('PMG.BackupRestore', {
        xclass: 'Ext.app.ViewController',
 
        createBackup: function() {
-           var me = this.getView();
+           let view = this.getView();
            Proxmox.Utils.API2Request({
                url: "/nodes/" + Proxmox.NodeName + "/backup",
                method: 'POST',
-               waitMsgTarget: me,
+               waitMsgTarget: view,
                failure: function(response, opts) {
                    Ext.Msg.alert(gettext('Error'), response.htmlStatus);
                },
                success: function(response, opts) {
-                   var upid = response.result.data;
+                   let upid = response.result.data;
 
-                   var win = Ext.create('Proxmox.window.TaskViewer', {
+                   let win = Ext.create('Proxmox.window.TaskViewer', {
                        upid: upid,
+                       autoShow: true,
                    });
-                   win.show();
-                   me.mon(win, 'close', function() { me.store.load(); });
+                   view.mon(win, 'close', () => view.store.load());
                },
            });
        },
 
        onRestore: function() {
-           var me = this.getView();
-           var rec = me.getSelection()[0];
+           let view = this.getView();
+           let rec = view.getSelection()[0];
 
            if (!(rec && rec.data && rec.data.filename)) {
                return;
@@ -109,8 +108,8 @@ Ext.define('PMG.BackupRestore', {
        },
 
        onAfterRemove: function(btn, res) {
-           var me = this.getView();
-           me.store.load();
+           let view = this.getView();
+           view.store.load();
        },
     },
 
index e22a083013b753941c001b5c188921a22e50b9fe..105b2a69873a08e8df60606248bc7d222026275c 100644 (file)
@@ -170,7 +170,6 @@ Ext.define('PMG.ClusterAdministration', {
                },
 
                onJoin: function() {
-                   var view = this.getView();
                    var win = Ext.create('PMG.ClusterJoinNodeWindow', {});
                    win.show();
                    win.on('destroy', function() {
@@ -256,7 +255,7 @@ Ext.define('PMG.ClusterAdministration', {
                            var html = '<p>' + Ext.htmlEncode(d.conn_error) + '</p>';
                            html = html.replace(/\n/g, '<br>');
                            metaData.tdAttr = 'data-qwidth=600 data-qtitle="ERROR" data-qtip="' +
-                               html.replace(/\"/g, '&quot;') + '"';
+                               html.replace(/"/g, '&quot;') + '"';
                            state = 'error';
                        }
                        return state;
index 27b767cdeabc8eaa265e7bd8cae62d149b099bb8..c7148cbaef1cbb1b6b3415198cb3c57bbf002354 100644 (file)
@@ -65,11 +65,11 @@ Ext.define('PMG.panel.Config', {
            singleExpand: false,
            listeners: {
                selectionchange: function(treeList, selection) {
-                   var me = this.up('panel');
-                   me.suspendLayout = true;
-                   me.activateCard(selection.data.id);
-                   me.suspendLayout = false;
-                   me.updateLayout();
+                   let view = this.up('panel');
+                   view.suspendLayout = true;
+                   view.activateCard(selection.data.id);
+                   view.suspendLayout = false;
+                   view.updateLayout();
                },
                itemclick: function(treelist, info) {
                    var olditem = treelist.getSelection();
@@ -113,13 +113,14 @@ Ext.define('PMG.panel.Config', {
            menu.setSelection(selection);
            return cardid;
        }
+       return null;
     },
 
     activateCard: function(cardid) {
        var me = this;
        if (me.savedItems[cardid]) {
            var curcard = me.getLayout().getActiveItem();
-           var newcard = me.add(me.savedItems[cardid]);
+           me.add(me.savedItems[cardid]);
            if (curcard) {
                me.setActiveItem(cardid);
                me.remove(curcard, true);
@@ -156,23 +157,6 @@ Ext.define('PMG.panel.Config', {
            }
        }
 
-       // get title
-       var title = me.title;
-       me.title = undefined;
-
-       // create toolbar
-       //var tbar = me.tbar || [];
-       //me.tbar = undefined;
-
-       //tbar.unshift('->');
-       //tbar.unshift({
-       //    xtype: 'tbtext',
-       //    text: title,
-       //    baseCls: 'x-panel-header-text'
-       //});
-
-       //me.dockedItems[1].items = tbar;
-
        // include search tab
        me.items = me.items || [];
 
@@ -251,14 +235,14 @@ Ext.define('PMG.panel.Config', {
 
        // on a state change,
        // select the new item
-       var statechange = function(sp, key, state) {
+       const statechange = function(sp, key, newState) {
            // it the state change is for this panel
-           if (stateid && (key === stateid) && state) {
+           if (stateid && (key === stateid) && newState) {
                // get active item
                var acard = me.getLayout().getActiveItem().itemId;
                // get the itemid of the new value
-               var ncard = state.value || me.firstItem;
-               if (ncard && (acard != ncard)) {
+               var ncard = newState.value || me.firstItem;
+               if (ncard && (acard !== ncard)) {
                    // select the chosen item
                    menu.setSelection(root.findChild('id', ncard, true) || root.firstChild);
                }
index 0a4937eabfbfcdefa87c655a779a1e8161cbbf1c..19ec702efb625befdb3e6b894d9b238da38355f9 100644 (file)
@@ -480,9 +480,9 @@ Ext.define('PMG.LDAPConfigGrid', {
 
 
        reload: function() {
-           var me = this.getView();
-           me.getStore().load();
-           me.fireEvent('load', me);
+           let view = this.getView();
+           view.getStore().load();
+           view.fireEvent('load', view);
        },
 
        sync: function() {
index ae44dc0c8908a2101bc15a668ae3f7d87fc2c624..e8640dd4cae8c03dc7854bcb89f0ac5b9a633867 100644 (file)
@@ -13,7 +13,7 @@ Ext.define('PMG.LDAPGroupInputPanel', {
     },
 
     setValues: function(values) {
-       var me = this;
+       let me = this;
 
        if (values.profile !== undefined) {
            if (values.mode === 'any') {
@@ -24,7 +24,7 @@ Ext.define('PMG.LDAPGroupInputPanel', {
        }
 
        if (values.profile !== undefined) {
-           var groupField = this.lookupReference('groupField');
+           let groupField = this.lookupReference('groupField');
            groupField.setProfile(values.profile);
        }
 
@@ -36,17 +36,17 @@ Ext.define('PMG.LDAPGroupInputPanel', {
        xclass: 'Ext.app.ViewController',
 
        changeMode: function(f, value) {
-           var groupField = this.lookupReference('groupField');
+           let groupField = this.lookupReference('groupField');
            groupField.setDisabled(value !== 'group');
            groupField.setVisible(value === 'group');
-           var profileField = this.lookupReference('profileField');
-           var enabled = (value != 'any') && (value != 'none');
+           let profileField = this.lookupReference('profileField');
+           let enabled = (value !== 'any') && (value !== 'none');
            profileField.setDisabled(!enabled);
            profileField.setVisible(enabled);
        },
 
        changeProfile: function(f, value) {
-           var groupField = this.lookupReference('groupField');
+           let groupField = this.lookupReference('groupField');
            groupField.setProfile(value);
        },
 
index 2bfc75e523e92e065e61ce8f714d48661a911091..8e610aab79b077cc4316111eda26a564cf32afc1 100644 (file)
@@ -6,9 +6,9 @@ Ext.define('PMG.LoginView', {
        xclass: 'Ext.app.ViewController',
 
        init: function(view) {
-           var me = this;
+           let me = this;
 
-           var realmfield = me.lookup('realmfield');
+           let realmfield = me.lookup('realmfield');
 
            if (view.targetview !== 'quarantineview') {
                return;
@@ -18,15 +18,17 @@ Ext.define('PMG.LoginView', {
 
            // try autologin with quarantine ticket from URL
 
-           var loginForm = this.lookupReference('loginForm');
-
-           var qs = Ext.Object.fromQueryString(location.search);
-           if (qs.ticket == undefined) { return; }
-           var ticket = decodeURIComponent(qs.ticket);
-           var match = ticket.match(/^PMGQUAR:([^\s\:]+):/);
-           if (!match) { return; }
-           var username = match[1];
-           var loginwin = me.lookup('loginwindow');
+           let qs = Ext.Object.fromQueryString(location.search);
+           if (qs.ticket === undefined) {
+               return;
+           }
+           let ticket = decodeURIComponent(qs.ticket);
+           let match = ticket.match(/^PMGQUAR:([^\s:]+):/);
+           if (!match) {
+               return;
+           }
+           let username = match[1];
+           let loginwin = me.lookup('loginwindow');
            loginwin.autoShow = false;
            loginwin.setVisible(false);
            realmfield.setDisabled(true);
@@ -38,9 +40,9 @@ Ext.define('PMG.LoginView', {
        },
 
        submitForm: function() {
-           var me = this;
-           var view = me.getView();
-           var loginForm = me.lookupReference('loginForm');
+           let me = this;
+           let view = me.getView();
+           let loginForm = me.lookupReference('loginForm');
 
            if (loginForm.isValid()) {
                if (loginForm.isVisible()) {
@@ -66,10 +68,10 @@ Ext.define('PMG.LoginView', {
        control: {
            'field[name=lang]': {
                change: function(f, value) {
-                   var dt = Ext.Date.add(new Date(), Ext.Date.YEAR, 10);
+                   let dt = Ext.Date.add(new Date(), Ext.Date.YEAR, 10);
                    Ext.util.Cookies.set('PMGLangCookie', value, dt);
 
-                   var loginwin = this.lookupReference('loginwindow');
+                   let loginwin = this.lookupReference('loginwindow');
                    loginwin.mask(gettext('Please wait...'), 'x-mask-loading');
                    window.location.reload();
                },
index 7c16185097a5273eca6f5c667790b67ec239dda3..52641a4ebd91888d1da2975ca85fc19525bb5e9f 100644 (file)
@@ -27,24 +27,24 @@ Ext.define('PMG.MailTrackerFilter', {
         xclass: 'Ext.app.ViewController',
 
        onFilterChange: function() {
-           var view = this.getView();
+           let view = this.getView();
            view.fireEvent('filterChanged');
        },
 
        onSpecialKey: function(field, e) {
-           if (e.getKey() == e.ENTER) {
+           if (e.getKey() === e.ENTER) {
                this.onFilterChange();
            }
        },
     },
 
     getFilterParams: function() {
-       var me = this;
-       var param = {};
+       let me = this;
+       let param = {};
 
-       var names = ['from', 'target', 'xfilter', 'starttime', 'endtime', 'ndr', 'greylist'];
+       let names = ['from', 'target', 'xfilter', 'starttime', 'endtime', 'ndr', 'greylist'];
        Ext.Array.each(names, function(name) {
-           var value = me.lookupReference(name).getSubmitValue();
+           let value = me.lookupReference(name).getSubmitValue();
            if (value) { param[name] = value; }
        });
 
@@ -103,7 +103,7 @@ Ext.define('PMG.MailTrackerFilter', {
                        },
                    },
                    value: (function() {
-                       var now = new Date();
+                       let now = new Date();
                        return new Date(now.getTime() - 3600000);
                    }()),
                    xtype: 'promxoxDateTimeField',
@@ -118,8 +118,8 @@ Ext.define('PMG.MailTrackerFilter', {
                        },
                    },
                    value: (function() {
-                       var now = new Date();
-                       var tomorrow = new Date();
+                       let now = new Date();
+                       let tomorrow = new Date();
                        tomorrow.setDate(now.getDate()+1);
                        tomorrow.setHours(0);
                        tomorrow.setMinutes(0);
@@ -177,7 +177,7 @@ Ext.define('PMG.MaiLogWindow', {
     bodyPadding: 5,
 
     load: function() {
-       var me = this;
+       let me = this;
 
        Proxmox.Utils.API2Request({
            method: 'GET',
@@ -188,9 +188,9 @@ Ext.define('PMG.MaiLogWindow', {
                me.update(gettext('Error') + " " + response.htmlStatus);
            },
            success: function(response, opts) {
-               var data = response.result.data;
+               let data = response.result.data;
 
-               var logs = "<pre style='margin: 0;'>";
+               let logs = "<pre style='margin: 0;'>";
                Ext.Array.each(data.logs, function(line) {
                    logs += Ext.htmlEncode(line) + "\n";
                });
@@ -201,7 +201,7 @@ Ext.define('PMG.MaiLogWindow', {
     },
 
     initComponent: function() {
-       var me = this;
+       let me = this;
 
        if (!me.logid) {
            throw "no logid specified";
@@ -236,7 +236,7 @@ Ext.define('PMG.MailTracker', {
        deferEmptyText: false,
        enableTextSelection: true,
        getRowClass: function(record, index) {
-           var status = record.data.rstatus || record.data.dstatus;
+           let status = record.data.rstatus || record.data.dstatus;
            return PMG.Utils.mail_status_map[status];
        },
     },
@@ -260,11 +260,11 @@ Ext.define('PMG.MailTracker', {
         xclass: 'Ext.app.ViewController',
 
        onSearch: function() {
-           var view = this.getView();
+           let view = this.getView();
            view.setEmptyText(gettext('No data in database'));
-           var filter = this.lookupReference('filter');
-           var status = this.lookupReference('status');
-           var params = filter.getFilterParams();
+           let filter = this.lookupReference('filter');
+           let status = this.lookupReference('status');
+           let params = filter.getFilterParams();
            if (params === undefined) {
                return; // something went wrong with the filters bail out
            }
@@ -272,10 +272,10 @@ Ext.define('PMG.MailTracker', {
            view.store.proxy.setExtraParams(params);
            view.store.proxy.setUrl('/api2/json/nodes/' + Proxmox.NodeName + '/tracker');
            view.store.load(function(records, operation, success) {
-               var response = operation.getResponse();
+               let response = operation.getResponse();
                if (success) {
                    // fixme: howto avoid duplicate Ext.decode ?
-                   var result = Ext.decode(response.responseText);
+                   let result = Ext.decode(response.responseText);
                    if (result.changes) {
                        status.update(result.changes);
                    }
@@ -284,9 +284,9 @@ Ext.define('PMG.MailTracker', {
        },
 
        showDetails: function(rowNode, record) {
-           var view = this.getView();
+           let view = this.getView();
 
-           var params = view.store.proxy.getExtraParams();
+           let params = view.store.proxy.getExtraParams();
 
            Proxmox.Utils.API2Request({
                method: 'GET',
@@ -297,8 +297,8 @@ Ext.define('PMG.MailTracker', {
                    record.set('logs', gettext('Error') + " " + response.htmlStatus);
                },
                success: function(response, opts) {
-                   var data = response.result.data;
-                   var logs = "";
+                   let data = response.result.data;
+                   let logs = "";
 
                    Ext.Array.each(data.logs, function(line) {
                        logs += Ext.htmlEncode(line) + "<br>";
@@ -379,16 +379,16 @@ Ext.define('PMG.MailTracker', {
            header: gettext('Status'),
            width: 150,
            renderer: function(v, metaData, rec) {
-               var returntext = 'unknown';
-               var icon = 'question-circle';
-               var rstatus = rec.data.rstatus;
+               let returntext = 'unknown';
+               let icon = 'question-circle';
+               let rstatus = rec.data.rstatus;
                if (v !== undefined && v !== '') {
-                   var vtext = PMG.Utils.mail_status_map[v] || v;
+                   let vtext = PMG.Utils.mail_status_map[v] || v;
                    icon = v;
                    if (v === 'Q' || v === 'B') {
                        returntext = vtext;
                    } else if (rstatus !== undefined && rstatus !== '') {
-                       var rtext = PMG.Utils.mail_status_map[rstatus] || rstatus;
+                       let rtext = PMG.Utils.mail_status_map[rstatus] || rstatus;
                        returntext = vtext + '/' + rtext;
                        icon = rstatus;
                    } else if (rec.data.qid !== undefined) {
@@ -424,7 +424,7 @@ Ext.define('PMG.MailTracker', {
     ],
 
     initComponent: function() {
-       var me = this;
+       let me = this;
 
        me.callParent();
 
index 7a05776c5787c87d4e07ad82f7858373a0b860b2..01b9658d9ea006a3ff3af3f2adcfce2b6e6017bf 100644 (file)
@@ -18,7 +18,7 @@ Ext.define('PMG.MainView', {
        },
 
        beforeChangePath: function(path, subpath, action) {
-           var me = this;
+           let me = this;
 
            if (!Ext.ClassManager.getByAlias('widget.'+ path)) {
                console.warn('xtype "'+path+'" not found');
@@ -26,7 +26,7 @@ Ext.define('PMG.MainView', {
                return;
            }
 
-           var lastpanel = me.lookupReference('contentpanel').getLayout().getActiveItem();
+           let lastpanel = me.lookupReference('contentpanel').getLayout().getActiveItem();
            if (lastpanel && lastpanel.xtype === path) {
                // we have the right component already,
                // we just need to select the correct tab
@@ -48,12 +48,12 @@ Ext.define('PMG.MainView', {
        },
 
        changePath: function(path, subpath) {
-           var me = this;
-           var contentpanel = me.lookupReference('contentpanel');
-           var lastpanel = contentpanel.getLayout().getActiveItem();
+           let me = this;
+           let contentpanel = me.lookupReference('contentpanel');
+           let lastpanel = contentpanel.getLayout().getActiveItem();
 
-           var obj = contentpanel.add({ xtype: path });
-           var treelist = me.lookupReference('navtree');
+           let obj = contentpanel.add({ xtype: path });
+           let treelist = me.lookupReference('navtree');
 
            treelist.suspendEvents();
            treelist.select(path);
@@ -62,7 +62,7 @@ Ext.define('PMG.MainView', {
            if (Ext.isFunction(obj.setActiveTab)) {
                obj.setActiveTab(subpath || 0);
                obj.addListener('tabchange', function(tabpanel, newc, oldc) {
-                   var newpath = path;
+                   let newpath = path;
 
                    // only add the subpath part for the
                    // non-default tabs
@@ -105,7 +105,7 @@ Ext.define('PMG.MainView', {
        },
 
        init: function(view) {
-           var me = this;
+           let me = this;
 
            // load username
            me.lookupReference('usernameinfo').setText(Proxmox.UserName);
@@ -113,7 +113,7 @@ Ext.define('PMG.MainView', {
            // show login on requestexception
            // fixme: what about other errors
            Ext.Ajax.on('requestexception', function(conn, response, options) {
-               if (response.status == 401) { // auth failure
+               if (response.status === 401) { // auth failure
                    me.logout();
                }
            });
@@ -121,7 +121,7 @@ Ext.define('PMG.MainView', {
            // get ticket periodically
            Ext.TaskManager.start({
                run: function() {
-                   var ticket = Proxmox.Utils.authOK();
+                   let ticket = Proxmox.Utils.authOK();
                    if (!ticket || !Proxmox.UserName) {
                        return;
                    }
@@ -137,7 +137,7 @@ Ext.define('PMG.MainView', {
                            me.logout();
                        },
                        success: function(response, opts) {
-                           var obj = Ext.decode(response.responseText);
+                           let obj = Ext.decode(response.responseText);
                            PMG.Utils.updateLoginData(obj.data);
                        },
                    });
@@ -146,7 +146,7 @@ Ext.define('PMG.MainView', {
            });
 
            // select treeitem and load page from url fragment
-           var token = Ext.util.History.getToken() || 'pmgDashboard';
+           let token = Ext.util.History.getToken() || 'pmgDashboard';
            this.redirectTo(token, true);
        },
     },
index 5ddbcd09264069daab9c65a3faf494d103640d27..2223ffa3e26a0e3b6e5bd69a03889449679d0298 100644 (file)
@@ -14,7 +14,7 @@ Ext.define('PMG.ObjectGroup', {
     emptyText: gettext('Please select an object.'),
 
     setBaseUrl: function(baseurl) {
-       var me = this;
+       let me = this;
 
        me.baseurl = baseurl;
 
@@ -23,21 +23,21 @@ Ext.define('PMG.ObjectGroup', {
            me.store.setData([]);
            me.setButtonState(me.store, [], false);
        } else {
-           var url = '/api2/json' + me.baseurl + '/objects';
+           let url = '/api2/json' + me.baseurl + '/objects';
            me.store.proxy.setUrl(url);
            me.store.load();
        }
     },
 
     setObjectInfo: function(ogdata) {
-       var me = this;
+       let me = this;
 
        me.ogdata = ogdata;
 
        if (me.ogdata === undefined) {
            me.down('#oginfo').update(me.emptyText);
        } else {
-           var html = '<b>' + Ext.String.htmlEncode(me.ogdata.name) + '</b>';
+           let html = '<b>' + Ext.String.htmlEncode(me.ogdata.name) + '</b>';
            html += "<br><br>";
            html += Ext.String.htmlEncode(Ext.String.trim(me.ogdata.info));
 
@@ -47,7 +47,7 @@ Ext.define('PMG.ObjectGroup', {
     },
 
     setButtonState: function(store, records, success) {
-       var me = this;
+       let me = this;
        if (!success || !me.baseurl) {
            me.down('#addMenuButton').setDisabled(true);
            return;
@@ -56,7 +56,7 @@ Ext.define('PMG.ObjectGroup', {
     },
 
     initComponent: function() {
-       var me = this;
+       let me = this;
 
        me.store = new Ext.data.Store({
            model: 'pmg-object-list',
@@ -98,13 +98,13 @@ Ext.define('PMG.ObjectGroup', {
            flex: 1,
        });
 
-       var reload = function() {
+       let reload = function() {
             me.store.load();
         };
 
        me.selModel = Ext.create('Ext.selection.RowModel', {});
 
-       var remove_btn = Ext.createWidget('proxmoxStdRemoveButton', {
+       let remove_btn = Ext.createWidget('proxmoxStdRemoveButton', {
            selModel: me.selModel,
            getUrl: function(rec) {
                return me.baseurl + '/objects/' + rec.data.id;
@@ -117,9 +117,9 @@ Ext.define('PMG.ObjectGroup', {
            waitMsgTarget: me,
        });
 
-       var full_subject = function(subject, receivertest) {
+       let full_subject = function(subject, receivertest) {
            if (me.showDirection) {
-               var direction = receivertest
+               let direction = receivertest
                    ? PMG.Utils.receiverText : PMG.Utils.senderText;
 
                return subject + ' (' + direction + ')';
@@ -128,45 +128,45 @@ Ext.define('PMG.ObjectGroup', {
            }
        };
 
-       var run_editor = function() {
-           var rec = me.selModel.getSelection()[0];
+       let run_editor = function() {
+           let rec = me.selModel.getSelection()[0];
            if (!rec) {
                return;
            }
 
-           var editor = PMG.Utils.object_editors[rec.data.otype];
+           let editor = PMG.Utils.object_editors[rec.data.otype];
            if (!editor || editor.uneditable) {
                return;
            }
 
-           var config = Ext.apply({ method: 'PUT' }, editor);
+           let config = Ext.apply({ method: 'PUT' }, editor);
            config.subject = full_subject(editor.subject, rec.data.receivertest);
            config.url = me.baseurl + '/' + editor.subdir + '/' + rec.data.id;
 
-           var win = Ext.createWidget(config);
+           let win = Ext.createWidget(config);
 
            win.load();
            win.on('destroy', reload);
            win.show();
        };
 
-       var menu_items = [];
+       let menu_items = [];
 
        Ext.Array.each(me.otype_list, function(otype) {
-           var editor = PMG.Utils.object_editors[otype];
+           let editor = PMG.Utils.object_editors[otype];
 
-           var config = Ext.apply({ method: 'POST' }, editor);
+           let config = Ext.apply({ method: 'POST' }, editor);
            config.subject = full_subject(editor.subject, editor.receivertest);
 
            menu_items.push({
                text: config.subject,
                iconCls: config.iconCls || 'fa fa-question-circle',
                handler: function() {
-                   if (me.baseurl == undefined) {
+                   if (me.baseurl === undefined) {
                        return;
                    }
                    config.url = me.baseurl + '/' + editor.subdir;
-                   var win = Ext.create(config);
+                   let win = Ext.create(config);
                    win.on('destroy', reload);
                    win.show();
                },
@@ -193,7 +193,7 @@ Ext.define('PMG.ObjectGroup', {
                    disabled: true,
                    selModel: me.selModel,
                    enableFn: function(rec) {
-                       var editor = PMG.Utils.object_editors[rec.data.otype];
+                       let editor = PMG.Utils.object_editors[rec.data.otype];
                        return editor && !editor.uneditable;
                    },
                    handler: run_editor,
index 51157f7a26a2dd5b96c4776020d76c928aade0d7..ede20f1525b71d08e2d6c733be2d09adbded2aef 100644 (file)
@@ -23,24 +23,24 @@ Ext.define('PMG.QuarantineList', {
        xclass: 'Ext.app.ViewController',
 
         init: function(view) {
-           var me = this;
+           let me = this;
            if (PMG.view === 'quarantineview') {
                view.emailSelection = false;
                me.setEmptyText();
            }
-           var emailCombobox = me.lookupReference('email');
+           let emailCombobox = me.lookupReference('email');
            emailCombobox.setVisible(view.emailSelection);
            emailCombobox.setDisabled(!view.emailSelection);
 
-           var from;
-           if (PMG.QuarantineList.from != 0) {
+           let from;
+           if (PMG.QuarantineList.from !== 0) {
                from = new Date(PMG.QuarantineList.from * 1000);
            } else {
-               from = new Date(Date.now() - 7*24*60*60*1000);
+               from = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000);
            }
 
-           var to;
-           if (PMG.QuarantineList.to != 0) {
+           let to;
+           if (PMG.QuarantineList.to !== 0) {
                to = new Date(PMG.QuarantineList.to * 1000);
            } else {
                to = new Date();
@@ -60,17 +60,17 @@ Ext.define('PMG.QuarantineList', {
        // extjs has no method to dynamically change the emptytext on
        // grids, so we have to do it this way
        setEmptyText: function(emptyText) {
-           var me = this;
-           var view = me.getView();
-           var tableview = view.getView();
+           let me = this;
+           let view = me.getView();
+           let tableview = view.getView();
            tableview.emptyText = '<div class="x-grid-empty">'+ (emptyText || view.notFoundText) + '</div>';
        },
 
        load: function(callback) {
-           var me = this;
+           let me = this;
            me.allowPositionSave = false;
-           var view = me.getView();
-           var store = view.getStore();
+           let view = me.getView();
+           let store = view.getStore();
            if (view.emailSelection) {
                if (!me.lookupReference('email').getSelection()) {
                    // if the combobox has no selection we do not reload
@@ -95,33 +95,32 @@ Ext.define('PMG.QuarantineList', {
        },
 
        setFrom: function(from) {
-           var me = this.getView();
-           var params = me.getStore().getProxy().getExtraParams();
+           let view = this.getView();
+           let params = view.getStore().getProxy().getExtraParams();
            params.starttime = from;
            PMG.QuarantineList.from = from;
-           me.getStore().getProxy().setExtraParams(params);
+           view.getStore().getProxy().setExtraParams(params);
        },
 
        setTo: function(to) {
-           var end_of_to = to + 24*60*60; // we want the end of the day
-           var me = this.getView();
-           var params = me.getStore().getProxy().getExtraParams();
+           let end_of_to = to + 24*60*60; // we want the end of the day
+           let view = this.getView();
+           let params = view.getStore().getProxy().getExtraParams();
            params.endtime = end_of_to;
            PMG.QuarantineList.to = to; // we save the start of the day here
-           me.getStore().getProxy().setExtraParams(params);
+           view.getStore().getProxy().setExtraParams(params);
        },
 
        setUser: function(user) {
-           var me = this.getView();
-           var params = me.getStore().getProxy().getExtraParams();
+           let view = this.getView();
+           let params = view.getStore().getProxy().getExtraParams();
            params.pmail = user;
-           me.getStore().getProxy().setExtraParams(params);
-           me.user = user;
+           view.getStore().getProxy().setExtraParams(params);
+           view.user = user;
        },
 
        changeTime: function(field, value) {
-           var me = this;
-           var list = me.getView();
+           let me = this;
 
            me.allowPositionSave = false;
            me.savedPosition = undefined;
@@ -130,12 +129,12 @@ Ext.define('PMG.QuarantineList', {
                return;
            }
 
-           var val = value.getTime()/1000;
-           var combobox = me.lookupReference('email');
-           var params = combobox.getStore().getProxy().getExtraParams();
+           let val = value.getTime() / 1000;
+           let combobox = me.lookupReference('email');
+           let params = combobox.getStore().getProxy().getExtraParams();
 
-           var to = me.lookupReference('to');
-           var from = me.lookupReference('from');
+           let to = me.lookupReference('to');
+           let from = me.lookupReference('from');
 
            if (field.name === 'from') {
                me.setFrom(val);
@@ -156,15 +155,15 @@ Ext.define('PMG.QuarantineList', {
        },
 
        resetEmail: function() {
-           var me = this;
-           var view = me.getView();
+           let me = this;
+           let view = me.getView();
            if (view.emailSelection) {
                me.setUser(undefined);
            }
        },
 
        changeEmail: function(tb, value) {
-           var me = this;
+           let me = this;
            me.savedPosition = undefined;
            me.allowPositionSave = false;
            me.setUser(value);
@@ -181,8 +180,8 @@ Ext.define('PMG.QuarantineList', {
                return;
            }
 
-           var view = me.getView();
-           var id = view.getStore().indexOf(selected[0]);
+           let view = me.getView();
+           let id = view.getStore().indexOf(selected[0]);
 
            me.savedPosition = id;
        },
index bdbc8331a1e4261a497d9f1c654923b8f66ac33b..424fd0901ada07ce662d620f773985900aed41fb 100644 (file)
@@ -3,8 +3,8 @@ Ext.define('PMG.QuarantineNavigationTree', {
     xtype: 'quarantinenavigationtree',
 
     select: function(path) {
-       var me = this;
-       var item = me.getStore().findRecord('path', path, 0, false, true, true);
+       let me = this;
+       let item = me.getStore().findRecord('path', path, 0, false, true, true);
        me.setSelection(item);
     },
 
@@ -62,7 +62,7 @@ Ext.define('PMG.QuarantineView', {
        },
 
        beforeChangePath: function(path, subpath, action) {
-           var me = this;
+           let me = this;
 
            if (!Ext.ClassManager.getByAlias('widget.'+ path)) {
                console.warn('xtype "'+path+'" not found');
@@ -70,7 +70,7 @@ Ext.define('PMG.QuarantineView', {
                return;
            }
 
-           var lastpanel = me.lookupReference('contentpanel').getLayout().getActiveItem();
+           let lastpanel = me.lookupReference('contentpanel').getLayout().getActiveItem();
            if (lastpanel && lastpanel.xtype === path) {
                // we have the right component already,
                // we just need to select the correct tab
@@ -92,12 +92,12 @@ Ext.define('PMG.QuarantineView', {
        },
 
        changePath: function(path, subpath) {
-           var me = this;
-           var contentpanel = me.lookupReference('contentpanel');
-           var lastpanel = contentpanel.getLayout().getActiveItem();
+           let me = this;
+           let contentpanel = me.lookupReference('contentpanel');
+           let lastpanel = contentpanel.getLayout().getActiveItem();
 
-           var obj = contentpanel.add({ xtype: path, cselect: subpath });
-           var treelist = me.lookupReference('navtree');
+           let obj = contentpanel.add({ xtype: path, cselect: subpath });
+           let treelist = me.lookupReference('navtree');
 
            treelist.suspendEvents();
            treelist.select(path);
@@ -106,7 +106,7 @@ Ext.define('PMG.QuarantineView', {
            if (Ext.isFunction(obj.setActiveTab)) {
                obj.setActiveTab(subpath || 0);
                obj.addListener('tabchange', function(tabpanel, newc, oldc) {
-                   var newpath = path;
+                   let newpath = path;
 
                    // only add the subpath part for the
                    // non-default tabs
@@ -153,22 +153,22 @@ Ext.define('PMG.QuarantineView', {
        },
 
        init: function(view) {
-           var me = this;
+           let me = this;
 
            // load username
-           var username = Proxmox.UserName.replace(/\@quarantine$/, '');
+           let username = Proxmox.UserName.replace(/@quarantine$/, '');
            me.lookupReference('usernameinfo').setText(username);
 
            // show login on requestexception
            // fixme: what about other errors
            Ext.Ajax.on('requestexception', function(conn, response, options) {
-               if (response.status == 401) { // auth failure
+               if (response.status === 401) { // auth failure
                    me.logout();
                }
            });
 
-           var qa = PMG.Utils.extractQuarantineAction();
-           var token;
+           let qa = PMG.Utils.extractQuarantineAction();
+           let token;
            if (qa) {
                token = 'pmgSpamQuarantine';
                if (qa.action === 'blacklist') { token = 'pmgUserBlacklist'; }
index c631e07c304f46ddb166bf12a38909725b13a6c7..3b03f6de6cd16891fe2597b0fd566e0ebafe1ea4 100644 (file)
@@ -12,54 +12,54 @@ Ext.define('PMG.RegexTester', {
     layout: 'hbox',
     submitValue: false,
 
-    items: [{
-       xtype: 'textfield',
-       submitValue: false,
-       name: 'teststring',
-       isDirty: function() { return false; },
-       reset: Ext.emptyFn,
-    }, {
-       margin: '0 0 0 5',
-       xtype: 'button',
-       text: 'Test',
-       handler: function() {
-           var me = this.up();
-           var regexField = me.up().down('field[reference=' + me.regexFieldReference +']');
-           var regex = '';
+    items: [
+       {
+           xtype: 'textfield',
+           submitValue: false,
+           name: 'teststring',
+           isDirty: () => false,
+           reset: Ext.emptyFn,
+       },
+       {
+           margin: '0 0 0 5',
+           xtype: 'button',
+           text: 'Test',
+           handler: function(btn) {
+               let view = this.up();
+               let regexField = btn.nextSibling(`field[reference=${view.regexFieldReference}]`);
 
-           if (me.wholeMatch) {
-               regex = '^' + regexField.getValue() + '$';
-           } else {
-               regex = regexField.getValue();
-           }
+               let regex = regexField.getValue();
+               if (view.wholeMatch) {
+                   regex = `^${regex}$`;
+               }
 
-           Proxmox.Utils.API2Request({
-               url: '/api2/extjs/config/regextest',
-               waitMsgTarget: me.up('window'),
-               params: {
-                   regex: regex,
-                   text: me.down('textfield[name=teststring]').getValue(),
-               },
-               method: 'POST',
-               success: function(response) {
-                   Ext.Msg.show({
-                       title: gettext('Success'),
-                       message: gettext('OK') +
-                           ' (elapsed time: ' +
-                           response.result.data + 'ms' + ')',
-                       buttons: Ext.Msg.OK,
-                       icon: Ext.MessageBox.INFO,
-                   });
-               },
-               failure: function(response, opts) {
-                   Ext.Msg.alert(gettext('Error'), response.htmlStatus);
-               },
-           });
+               Proxmox.Utils.API2Request({
+                   url: '/api2/extjs/config/regextest',
+                   waitMsgTarget: view.up('window'),
+                   params: {
+                       regex: regex,
+                       text: view.down('textfield[name=teststring]').getValue(),
+                   },
+                   method: 'POST',
+                   success: function(response) {
+                       let elapsed = response.result.data;
+                       Ext.Msg.show({
+                           title: gettext('Success'),
+                           message: gettext('OK') + ` (elapsed time: ${elapsed}ms)`,
+                           buttons: Ext.Msg.OK,
+                           icon: Ext.MessageBox.INFO,
+                       });
+                   },
+                   failure: function(response, opts) {
+                       Ext.Msg.alert(gettext('Error'), response.htmlStatus);
+                   },
+               });
+           },
        },
-    }],
+    ],
 
     initComponent: function() {
-       var me = this;
+       let me = this;
 
        if (!me.regexFieldReference) {
            throw "No regex field reference given";
index 93094c269bbf73b1cadd488e6598b1aedb07e1ee..859a3d96f43e4019a582f1988ee94e60ce945932 100644 (file)
@@ -23,26 +23,26 @@ Ext.define('PMG.RulesConfiguration', {
        xclass: 'Ext.app.ViewController',
 
        selectedRuleChange: function(grid, selected, eOpts) {
-           var me = this;
-           var infoPanel = me.lookupReference('infopanel');
-           var baseurl = '';
+           let me = this;
+           let infoPanel = me.lookupReference('infopanel');
+           let baseurl = '';
 
            if (selected.length > 0) {
-               baseurl = '/config/ruledb/rules/' + selected[0].data.id;
+               baseurl = `/config/ruledb/rules/${selected[0].data.id}`;
            }
 
            infoPanel.getController().setBaseUrl(baseurl);
        },
 
        editIconClick: function(gridView, rowindex, colindex, column, e, record) {
-           var me = this;
+           let me = this;
            me.showEditWindow(gridView, record);
        },
 
        showEditWindow: function(gridView, record) {
-           var me = this;
-           var win = Ext.create('PMG.RuleEditor', {
-               url: '/api2/extjs/config/ruledb/rules/' + record.data.id + '/config',
+           let me = this;
+           let win = Ext.create('PMG.RuleEditor', {
+               url: `/api2/extjs/config/ruledb/rules/${record.data.id}/config`,
                listeners: {
                    destroy: function() {
                        gridView.getStore().load();
@@ -54,9 +54,9 @@ Ext.define('PMG.RulesConfiguration', {
        },
 
        toggleIconClick: function(gridView, rowindex, colindex, column, e, record) {
-           var me = this;
+           let me = this;
            Proxmox.Utils.API2Request({
-               url: '/config/ruledb/rules/' + record.data.id + '/config',
+               url: `/config/ruledb/rules/${record.data.id}/config`,
                params: {
                    active: record.data.active ? 0 : 1,
                },
@@ -71,13 +71,13 @@ Ext.define('PMG.RulesConfiguration', {
        },
 
        reload: function() {
-           var me = this;
+           let me = this;
            me.lookupReference('rulegrid').getStore().load();
        },
 
        addRule: function() {
-           var me = this;
-           var win = Ext.create('PMG.RuleEditor', {
+           let me = this;
+           let win = Ext.create('PMG.RuleEditor', {
                url: '/api2/extjs/config/ruledb/rules/',
                method: 'POST',
                isCreate: true,
@@ -92,7 +92,7 @@ Ext.define('PMG.RulesConfiguration', {
        },
 
        onFactoryDefaults: function() {
-           var me = this;
+           let me = this;
 
            Ext.Msg.confirm(
                gettext('Confirm'),
@@ -101,7 +101,6 @@ Ext.define('PMG.RulesConfiguration', {
                    if (button !== 'yes') {
                        return;
                    }
-                   var url = '/config/ruledb';
                    Proxmox.Utils.API2Request({
                        url: '/config/ruledb',
                        method: 'POST',
@@ -118,7 +117,7 @@ Ext.define('PMG.RulesConfiguration', {
        },
 
        init: function(view) {
-           var grid = this.lookupReference('rulegrid');
+           let grid = this.lookupReference('rulegrid');
            Proxmox.Utils.monStoreErrors(grid, grid.getStore(), true);
        },
 
index a342291062bdbf16ff589afd264ba0e4b7f2857e..e91b3a7f187c2822614cd0e4d64bfc0ab60b5086 100644 (file)
@@ -24,12 +24,12 @@ Ext.define('PMG.ServerStatus', {
        },
 
        nodeCommand: function(cmd) {
-           var me = this.getView();
+           var view = this.getView();
            Proxmox.Utils.API2Request({
                params: { command: cmd },
-               url: '/nodes/' + Proxmox.NodeName + '/status',
+               url: `/nodes/${Proxmox.NodeName}/status`,
                method: 'POST',
-               waitMsgTarget: me,
+               waitMsgTarget: view,
                failure: function(response, opts) {
                    Ext.Msg.alert(gettext('Error'), response.htmlStatus);
                },
index 6b3ac1fb23a13a1c906c75a2f0559610cf360c27..e37971e57e4458a95094f08d4d3984c4ee0ff735 100644 (file)
@@ -6,9 +6,9 @@ Ext.define('PMG.menu.SpamContextMenu', {
     controller: {
        xclass: 'Ext.app.ViewController',
        callCallback: function(btn) {
-           var me = this.getView();
-           if (Ext.isFunction(me.callback)) {
-               me.callback(btn.action);
+           let view = this.getView();
+           if (Ext.isFunction(view.callback)) {
+               view.callback(btn.action);
            }
        },
     },
index 7c7c57d0c41021dbd42d03ce0f6d7f4ec5460555..72bf224c500b316cf1b13e9a2863f47cd54aa797 100644 (file)
@@ -22,9 +22,9 @@ Ext.define('PMG.SpamDetectorCustomScores', {
        xclass: 'Ext.app.ViewController',
 
        reload: function() {
-           var me = this;
-           var vm = this.getViewModel();
-           var grid = me.lookup('grid');
+           let me = this;
+           let vm = me.getViewModel();
+           let grid = me.lookup('grid');
 
            Proxmox.Utils.API2Request({
                url: '/config/customscores',
@@ -49,8 +49,9 @@ Ext.define('PMG.SpamDetectorCustomScores', {
        },
 
        revert: function() {
-           var me = this;
-           var vm = this.getViewModel();
+           let me = this;
+           let vm = me.getViewModel();
+           let grid = me.lookup('grid');
 
            Proxmox.Utils.API2Request({
                url: '/config/customscores',
@@ -73,7 +74,7 @@ Ext.define('PMG.SpamDetectorCustomScores', {
            var me = this;
            var vm = this.getViewModel();
 
-           var win = Ext.createWidget('proxmoxWindowEdit', {
+           Ext.createWidget('proxmoxWindowEdit', {
                method: 'PUT',
                url: "/api2/extjs/config/customscores",
                isCreate: true,
index 970ac61228b197405e5599b003adab90c8bbfce3..bc76ece66d978790c38db350d6e6cafc22b350ad 100644 (file)
@@ -117,17 +117,21 @@ Ext.define('PMG.SpamDetectorLanguages', {
 
     subject: 'Languages',
 
-    initComponent: function() {
-       var me = this;
+    items: [
+       {
+           xtype: 'pmgSpamDetectorLanguagesInputPanel',
+       },
+    ],
 
-       me.items = Ext.create('PMG.SpamDetectorLanguagesInputPanel');
+    initComponent: function() {
+       let me = this;
 
        me.callParent();
 
        me.load({
            success: function(response, options) {
-               var value = response.result.data.languages || '';
-               var languages = value.split(/[\ \,\;]+/);
+               let value = response.result.data.languages || '';
+               let languages = value.split(/[ ,;]+/);
                me.setValues({ languages: languages });
            },
        });
index 5d4435b9be260abff200719431f953c282343afb..4b6d0fb6e8d44082a405af2dcac4447bc7aa7980 100644 (file)
@@ -62,7 +62,7 @@ Ext.define('PMG.SpamDetectorStatusGrid', {
        {
            text: gettext('Update Now'),
            handler: function() {
-               var me = this.up('grid');
+               let view = this.up('grid');
                Proxmox.Utils.API2Request({
                    url: '/nodes/' + Proxmox.NodeName + '/spamassassin/rules',
                    method: 'POST',
@@ -70,13 +70,13 @@ Ext.define('PMG.SpamDetectorStatusGrid', {
                        Ext.Msg.alert(gettext('Error'), response.htmlStatus);
                    },
                    success: function(response) {
-                       var upid = response.result.data;
+                       const upid = response.result.data;
 
-                       var win = Ext.create('Proxmox.window.TaskViewer', {
+                       let win = Ext.create('Proxmox.window.TaskViewer', {
                            upid: upid,
+                           autoShow: true,
                        });
-                       win.show();
-                       me.mon(win, 'close', function() { me.store.load(); });
+                       view.mon(win, 'close', () => view.store.load());
                    },
                });
            },
index 18c7849fd47d864db835fe8cc42cb77142fa6858..f01b058e778b7aa7e0f5ad3485218fddc6ebf969 100644 (file)
@@ -7,13 +7,22 @@ Ext.define('PMG.StatTimeSelector', {
        selected_month: undefined,
        selected_day: undefined,
 
-       getTimeSpan: function() {
-           var year = this.selected_year;
-           var month = this.selected_month;
-           var day = this.selected_day;
+       initSelected: function() {
+           let today = new Date();
+           this.selected_year = today.getFullYear();
+           this.selected_month = today.getMonth() + 1;
+           this.selected_day = today.getDate();
+       },
 
-           var starttime, endtime, span;
+       getTimeSpan: function() {
+           if (this.selected_year === undefined) {
+               this.initSelected();
+           }
+           const year = this.selected_year;
+           const month = this.selected_month;
+           const day = this.selected_day;
 
+           let starttime, endtime;
            if (!month) {
                starttime = new Date(year, 0);
                endtime = new Date(year + 1, 0);
@@ -25,12 +34,10 @@ Ext.define('PMG.StatTimeSelector', {
                endtime = new Date(year, month - 1, day + 1);
            }
 
-           var data = {};
-
-           data.starttime = (starttime.getTime() / 1000).toFixed(0);
-           data.endtime = (endtime.getTime() / 1000).toFixed(0);
-
-           return data;
+           return {
+               starttime: (starttime.getTime() / 1000).toFixed(0),
+               endtime: (endtime.getTime() / 1000).toFixed(0),
+           };
        },
     },
 
@@ -42,27 +49,27 @@ Ext.define('PMG.StatTimeSelector', {
        xclass: 'Ext.app.ViewController',
 
        updateVisibility: function() {
-           var view = this.getView();
+           let view = this.getView();
 
-           var yearsel = this.lookupReference('yearsel');
-           var monthsel = this.lookupReference('monthsel');
-           var daysel = this.lookupReference('daysel');
+           let yearsel = this.lookupReference('yearsel');
+           let monthsel = this.lookupReference('monthsel');
+           let daysel = this.lookupReference('daysel');
 
-           var year = yearsel.getValue();
-           var month = monthsel.getValue();
+           let year = yearsel.getValue();
+           let month = monthsel.getValue();
            daysel.setVisible(month !== 0);
            if (!month) {
                daysel.setValue(0);
            }
-           var day = daysel.getValue();
+           let day = daysel.getValue();
 
-           var statics = Ext.getClass(view);
+           let statics = Ext.getClass(view);
 
            statics.selected_year = year;
            statics.selected_month = month;
            statics.selected_day = day;
 
-           var data = statics.getTimeSpan();
+           let data = statics.getTimeSpan();
            Ext.GlobalEvents.fireEvent('pmgStatTimeSelectorUpdate', data);
        },
 
@@ -71,11 +78,11 @@ Ext.define('PMG.StatTimeSelector', {
        },
 
        init: function(view) {
-           var statics = Ext.getClass(view);
+           let statics = Ext.getClass(view);
 
-           var yearsel = this.lookupReference('yearsel');
-           var monthsel = this.lookupReference('monthsel');
-           var daysel = this.lookupReference('daysel');
+           let yearsel = this.lookupReference('yearsel');
+           let monthsel = this.lookupReference('monthsel');
+           let daysel = this.lookupReference('daysel');
 
            yearsel.setValue(statics.selected_year);
            monthsel.setValue(statics.selected_month);
@@ -92,8 +99,8 @@ Ext.define('PMG.StatTimeSelector', {
            store: {
                fields: ['year'],
                data: (function() {
-                   var today = new Date();
-                   var year = today.getFullYear();
+                   let today = new Date();
+                   let year = today.getFullYear();
                    return [{ year: year }, { year: year -1 }, { year: year -2 }];
                }()),
            },
@@ -110,8 +117,8 @@ Ext.define('PMG.StatTimeSelector', {
            store: {
                fields: ['month', 'name'],
                data: (function() {
-                   var i;
-                   var data = [{ month: 0, name: gettext('Whole year') }];
+                   let i;
+                   let data = [{ month: 0, name: gettext('Whole year') }];
                    for (i = 1; i <= 12; i++) {
                        data.push({ month: i, name: Ext.Date.monthNames[i-1] });
                    }
@@ -130,8 +137,8 @@ Ext.define('PMG.StatTimeSelector', {
            store: {
                fields: ['day', 'name'],
                data: (function() {
-                   var i;
-                   var data = [{ day: 0, name: gettext('Whole month') }];
+                   let i;
+                   let data = [{ day: 0, name: gettext('Whole month') }];
                    for (i = 1; i <= 31; i++) {
                        data.push({ day: i, name: i });
                    }
@@ -145,10 +152,4 @@ Ext.define('PMG.StatTimeSelector', {
            valueField: 'day',
        },
     ],
-}, function() {
-    var today = new Date();
-
-    this.selected_year = today.getFullYear();
-    this.selected_month = today.getMonth() + 1;
-    this.selected_day = today.getDate();
 });
index 5d8cb5d50e5fe4db13a4f06bd4b07141d1dac37f..8d3bc8073e959e6e8137b21c17430da962084fdf 100644 (file)
@@ -1,4 +1,3 @@
-/*global Blob,Proxmox*/
 Ext.define('PMG.SubscriptionKeyEdit', {
     extend: 'Proxmox.window.Edit',
 
@@ -31,14 +30,14 @@ Ext.define('PMG.Subscription', {
     },
 
     showReport: function() {
-       var me = this;
+       let me = this;
 
-       var getReportFileName = function() {
-           var now = Ext.Date.format(new Date(), 'D-d-F-Y-G-i');
+       const getReportFileName = function() {
+           let now = Ext.Date.format(new Date(), 'D-d-F-Y-G-i');
            return Proxmox.NodeName + '-report-' + now + '.txt';
        };
 
-       var view = Ext.createWidget('component', {
+       let view = Ext.createWidget('component', {
            itemId: 'system-report-view',
            scrollable: true,
            style: {
@@ -49,7 +48,7 @@ Ext.define('PMG.Subscription', {
            },
        });
 
-       var reportWindow = Ext.create('Ext.window.Window', {
+       let reportWindow = Ext.create('Ext.window.Window', {
            title: gettext('System Report'),
            width: 1024,
            height: 600,
@@ -60,14 +59,14 @@ Ext.define('PMG.Subscription', {
                {
                    text: gettext('Download'),
                    handler: function() {
-                       var fileContent = Ext.String.htmlDecode(reportWindow.getComponent('system-report-view').html);
-                       var fileName = getReportFileName();
+                       let fileContent = Ext.String.htmlDecode(reportWindow.getComponent('system-report-view').html);
+                       let fileName = getReportFileName();
 
                        // Internet Explorer
                        if (window.navigator.msSaveOrOpenBlob) {
                            navigator.msSaveOrOpenBlob(new Blob([fileContent]), fileName);
                        } else {
-                           var element = document.createElement('a');
+                           let element = document.createElement('a');
                            element.setAttribute('href', 'data:text/plain;charset=utf-8,'
                              + encodeURIComponent(fileContent));
                            element.setAttribute('download', fileName);
@@ -90,7 +89,7 @@ Ext.define('PMG.Subscription', {
                Ext.Msg.alert(gettext('Error'), response.htmlStatus);
            },
            success: function(response) {
-               var report = Ext.htmlEncode(response.result.data);
+               let report = Ext.htmlEncode(response.result.data);
                reportWindow.show();
                view.update(report);
            },
@@ -98,23 +97,23 @@ Ext.define('PMG.Subscription', {
     },
 
     initComponent: function() {
-       var me = this;
+       let me = this;
 
-       var reload = function() {
+       const reload = function() {
            me.rstore.load();
        };
 
-       var baseurl = '/nodes/' + Proxmox.NodeName + '/subscription';
+       let baseurl = `/nodes/${Proxmox.NodeName}/subscription`;
 
-       var render_status = function(value) {
-           var message = me.getObjectValue('message');
+       let render_status = function(value) {
+           let message = me.getObjectValue('message');
            if (message) {
                return value + ": " + message;
            }
            return value;
        };
 
-       var rows = {
+       let rows = {
            productname: {
                header: gettext('Type'),
            },
@@ -150,10 +149,10 @@ Ext.define('PMG.Subscription', {
                {
                    text: gettext('Upload Subscription Key'),
                    handler: function() {
-                       var win = Ext.create('PMG.SubscriptionKeyEdit', {
+                       let win = Ext.create('PMG.SubscriptionKeyEdit', {
                            url: '/api2/extjs/' + baseurl,
+                           autoShow: true,
                        });
-                       win.show();
                        win.on('destroy', reload);
                    },
                },
index cb4f7e0e3e6b5f53c0510816469057cfd9e32ac8..675dde446f48b7c0d5b4df1bb8626f2f2738c8ec 100644 (file)
@@ -16,8 +16,8 @@ Ext.define('PMG.SystemOptions', {
        xclass: 'Ext.app.ViewController',
 
        onEdit: function() {
-           var me = this.getView();
-           me.run_editor();
+           let view = this.getView();
+           view.run_editor();
        },
     },
 
@@ -33,7 +33,7 @@ Ext.define('PMG.SystemOptions', {
     },
 
     add_proxy_row: function(name, text, opts) {
-       var me = this;
+       let me = this;
 
        opts = opts || {};
        me.rows = me.rows || {};
@@ -61,7 +61,7 @@ Ext.define('PMG.SystemOptions', {
     },
 
     initComponent: function() {
-       var me = this;
+       let me = this;
 
        me.add_boolean_row('dailyreport', gettext('Send daily admin reports'),
                           { defaultValue: 1 });
index 7632360c1c8fd6a41172d8c65f75c7c06fc20399..4f4a756563294f82434f08d8c3085c03411c43a6 100644 (file)
@@ -20,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"),
            }];
 
@@ -41,7 +41,7 @@ Ext.define('PMG.UserBlackWhiteList', {
                });
            });
 
-           var config = {
+           let config = {
                method: 'POST',
                url: url,
                onlineHelp: 'pmg_userblackwhitelist',
@@ -50,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);
@@ -91,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,
@@ -101,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();
@@ -165,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) + "'";
                }
@@ -184,6 +182,7 @@ Ext.define('PMG.UserBlackWhiteList', {
                if (text && param) {
                    return Ext.String.format(text, param);
                }
+               return false;
            },
        },
     ],
@@ -226,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>)`,
         },
     ],
 });
@@ -263,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>)`,
         },
     ],
 });
index 6d1db6520ea8924cf4c38fb2cd421ad4ef22766f..0ee369b6ae5cdd352afcd89de87b20334bfedf9c 100644 (file)
@@ -23,7 +23,6 @@ Ext.define('PMG.ViewMailHeaders', {
 
        init: function(view) {
            var panel = view.lookupReference('contentPanel');
-           var fromField =
            Proxmox.Utils.API2Request({
                url: view.url,
                waitMsgTarget: view,