]> git.proxmox.com Git - pve-manager.git/commitdiff
Add context menu entry for WoL calls to nodes in GUI
authorChristian Ebner <c.ebner@proxmox.com>
Fri, 25 Jan 2019 10:32:27 +0000 (11:32 +0100)
committerDominik Csapak <d.csapak@proxmox.com>
Fri, 25 Jan 2019 13:22:26 +0000 (14:22 +0100)
This adds a context menu entry to the cluster nodes which triggers the wake on
LAN API call for the selected node.
The entry is disabled if the node is already running or the user has no
Sys.PowerMgmt capabilities.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
www/manager6/node/CmdMenu.js

index 05a92f627a798b6401bc55b1b6073da122b3ecc7..f718f69a891e92b9c93c6892369e5143f6ca07ee 100644 (file)
@@ -84,6 +84,30 @@ Ext.define('PVE.node.CmdMenu', {
                var me = this.up('menu');
                PVE.Utils.openDefaultConsoleWindow(true, 'shell', undefined, me.nodename, undefined);
            }
+       },
+       { xtype: 'menuseparator' },
+       {
+           text: gettext('Wake-on-LAN'),
+           itemId: 'wakeonlan',
+           iconCls: 'fa fa-fw fa-power-off',
+           handler: function() {
+               var me = this.up('menu');
+               Proxmox.Utils.API2Request({
+                   param: {},
+                   url: '/nodes/' + me.nodename + '/wakeonlan',
+                   method: 'POST',
+                   failure: function(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)
+                       });
+                   }
+               });
+           }
        }
     ],
 
@@ -108,10 +132,15 @@ Ext.define('PVE.node.CmdMenu', {
            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);
+       }
     }
 });