[pve-devel] [PATCH manager] Add context menu entry for WoL calls to nodes in GUI
Dominik Csapak
d.csapak at proxmox.com
Fri Jan 25 10:29:17 CET 2019
looks good, 2 comments inline
On 1/24/19 2:38 PM, Christian Ebner wrote:
> 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 at proxmox.com>
> ---
> www/manager6/node/CmdMenu.js | 28 ++++++++++++++++++++++++++++
> 1 file changed, 28 insertions(+)
>
> diff --git a/www/manager6/node/CmdMenu.js b/www/manager6/node/CmdMenu.js
> index 05a92f62..0bf6f246 100644
> --- a/www/manager6/node/CmdMenu.js
> +++ b/www/manager6/node/CmdMenu.js
> @@ -84,6 +84,29 @@ 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',
i would like to see a iconCls here, e.g. 'fa fa-fw fa-power-off'
a list of icons we can use are here:
https://fontawesome.com/v4.7.0/icons/
> + 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: gettext("Wake on LAN packet send for '" + response.result.data + "'")
i am afraid that will not work this way (since the text in the gettext
is not fixed)
please use Ext.String.format(gettext("foo {0} bar"), 'baz') instead,
where {0} is the placeholder for the data
> + });
> + }
> + });
> + }
> }
> ],
>
> @@ -108,10 +131,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);
> + }
> }
> });
>
More information about the pve-devel
mailing list