]> git.proxmox.com Git - pve-manager.git/commitdiff
ui: node/command menu: eslint fixes and code cleanup/refactoring/modernize
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 19 May 2021 09:17:24 +0000 (11:17 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 19 May 2021 09:17:24 +0000 (11:17 +0200)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
www/manager6/node/CmdMenu.js

index b650bfa0163baff1a29bb827899f0e101b202838..3d60e9cba6dd30749c1332362761ea231d73bd42 100644 (file)
@@ -10,11 +10,10 @@ Ext.define('PVE.node.CmdMenu', {
            itemId: 'createvm',
            iconCls: 'fa fa-desktop',
            handler: function() {
-               var me = this.up('menu');
-               var wiz = Ext.create('PVE.qemu.CreateWizard', {
-                   nodename: me.nodename,
+               Ext.create('PVE.qemu.CreateWizard', {
+                   nodename: this.up('menu').nodename,
+                   autoShow: true,
                });
-               wiz.show();
            },
        },
        {
@@ -22,11 +21,10 @@ Ext.define('PVE.node.CmdMenu', {
            itemId: 'createct',
            iconCls: 'fa fa-cube',
            handler: function() {
-               var me = this.up('menu');
-               var wiz = Ext.create('PVE.lxc.CreateWizard', {
-                   nodename: me.nodename,
+               Ext.create('PVE.lxc.CreateWizard', {
+                   nodename: this.up('menu').nodename,
+                   autoShow: true,
                });
-               wiz.show();
            },
        },
        { xtype: 'menuseparator' },
@@ -35,14 +33,13 @@ Ext.define('PVE.node.CmdMenu', {
            itemId: 'bulkstart',
            iconCls: 'fa fa-fw fa-play',
            handler: function() {
-               var me = this.up('menu');
-               var win = Ext.create('PVE.window.BulkAction', {
-                   nodename: me.nodename,
+               Ext.create('PVE.window.BulkAction', {
+                   nodename: this.up('menu').nodename,
                    title: gettext('Bulk Start'),
                    btnText: gettext('Start'),
                    action: 'startall',
+                   autoShow: true,
                });
-               win.show();
            },
        },
        {
@@ -50,14 +47,13 @@ Ext.define('PVE.node.CmdMenu', {
            itemId: 'bulkstop',
            iconCls: 'fa fa-fw fa-stop',
            handler: function() {
-               var me = this.up('menu');
-               var win = Ext.create('PVE.window.BulkAction', {
-                   nodename: me.nodename,
+               Ext.create('PVE.window.BulkAction', {
+                   nodename: this.up('menu').nodename,
                    title: gettext('Bulk Stop'),
                    btnText: gettext('Stop'),
                    action: 'stopall',
+                   autoShow: true,
                });
-               win.show();
            },
        },
        {
@@ -65,14 +61,13 @@ Ext.define('PVE.node.CmdMenu', {
            itemId: 'bulkmigrate',
            iconCls: 'fa fa-fw fa-send-o',
            handler: function() {
-               var me = this.up('menu');
-               var win = Ext.create('PVE.window.BulkAction', {
-                   nodename: me.nodename,
+               Ext.create('PVE.window.BulkAction', {
+                   nodename: this.up('menu').nodename,
                    title: gettext('Bulk Migrate'),
                    btnText: gettext('Migrate'),
                    action: 'migrateall',
+                   autoShow: true,
                });
-               win.show();
            },
        },
        { xtype: 'menuseparator' },
@@ -81,8 +76,8 @@ Ext.define('PVE.node.CmdMenu', {
            itemId: 'shell',
            iconCls: 'fa fa-fw fa-terminal',
            handler: function() {
-               var me = this.up('menu');
-               PVE.Utils.openDefaultConsoleWindow(true, 'shell', undefined, me.nodename, undefined);
+               let nodename = this.up('menu').nodename;
+               PVE.Utils.openDefaultConsoleWindow(true, 'shell', undefined, nodename, undefined);
            },
        },
        { xtype: 'menuseparator' },
@@ -91,19 +86,20 @@ Ext.define('PVE.node.CmdMenu', {
            itemId: 'wakeonlan',
            iconCls: 'fa fa-fw fa-power-off',
            handler: function() {
-               var me = this.up('menu');
+               let nodename = this.up('menu').nodename;
                Proxmox.Utils.API2Request({
-                   param: {},
-                   url: '/nodes/' + me.nodename + '/wakeonlan',
+                   url: `/nodes/${nodename}/wakeonlan`,
                    method: 'POST',
-                   failure: function(response, opts) {
-                       Ext.Msg.alert(gettext('Error'), response.htmlStatus);
-                   },
+                   failure: (response, opts) => Ext.Msg.alert(gettext('Error'), response.htmlStatus),
                    success: function(response, opts) {
                        Ext.Msg.show({
                            title: 'Success',
                            icon: Ext.Msg.INFO,
-                           msg: Ext.String.format(gettext("Wake on LAN packet send for '{0}': '{1}'"), me.nodename, response.result.data),
+                           msg: Ext.String.format(
+                               gettext("Wake on LAN packet send for '{0}': '{1}'"),
+                               nodename,
+                               response.result.data,
+                           ),
                        });
                    },
                });
@@ -112,7 +108,7 @@ Ext.define('PVE.node.CmdMenu', {
     ],
 
     initComponent: function() {
-       var me = this;
+       let me = this;
 
        if (!me.nodename) {
            throw 'no nodename specified';
@@ -121,24 +117,21 @@ Ext.define('PVE.node.CmdMenu', {
        me.title = gettext('Node') + " '" + me.nodename + "'";
        me.callParent();
 
-       var caps = Ext.state.Manager.get('GuiCap');
-       // disable not allowed options
+       let caps = Ext.state.Manager.get('GuiCap');
+
        if (!caps.vms['VM.Allocate']) {
            me.getComponent('createct').setDisabled(true);
            me.getComponent('createvm').setDisabled(true);
        }
-
        if (!caps.nodes['Sys.PowerMgmt']) {
            me.getComponent('bulkstart').setDisabled(true);
            me.getComponent('bulkstop').setDisabled(true);
            me.getComponent('bulkmigrate').setDisabled(true);
            me.getComponent('wakeonlan').setDisabled(true);
        }
-
        if (!caps.nodes['Sys.Console']) {
            me.getComponent('shell').setDisabled(true);
        }
-
        if (me.pveSelNode.data.running) {
            me.getComponent('wakeonlan').setDisabled(true);
        }