[pve-devel] [PATCH manager] Add button to wake nodes via WoL to the node Config.js

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Feb 4 14:11:37 CET 2019


Am 1/28/19 um 3:21 PM schrieb Christian Ebner:
> This adds a WoL button to the Config.js status bar. In order to be able to
> correctly enable/disable the button on node status changes, the monitoring code
> had to be slightly modified.
> 
> Signed-off-by: Christian Ebner <c.ebner at proxmox.com>

patch looks OK, but I do not like to clutter the user interface more with
another button which is very seldom needed. So we could hide it (not only
disable it), or see if the node-power stuff could be moved into a split-menu
like button. But for now I'd do nothing of those and just wait if any users
request a more visible WoL button in the first place, and/or if we get a
better idea :-)

> ---
>  www/manager6/node/Config.js | 38 ++++++++++++++++++++++++++++++--------
>  1 file changed, 30 insertions(+), 8 deletions(-)
> 
> diff --git a/www/manager6/node/Config.js b/www/manager6/node/Config.js
> index f9a62670..0d1d4d13 100644
> --- a/www/manager6/node/Config.js
> +++ b/www/manager6/node/Config.js
> @@ -102,6 +102,29 @@ Ext.define('PVE.node.Config', {
>  	    iconCls: 'fa fa-power-off'
>  	});
>  
> +	var wakeonlanBtn = Ext.create('Proxmox.button.Button', {
> +	    text: gettext('Wake-on-LAN'),
> +	    disabled: me.pveSelNode.data.running || !caps.nodes['Sys.PowerMgmt'],
> +	    handler: function() {
> +		Proxmox.Utils.API2Request({
> +		    param: {},
> +		    url: '/nodes/' + 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}'"), nodename, response.result.data)
> +			});
> +		    }
> +		});
> +	    },
> +	    iconCls: 'fa fa-power-off'
> +	});
> +
>  	var shellBtn = Ext.create('PVE.button.ConsoleButton', {
>  	    disabled: !caps.nodes['Sys.Console'],
>  	    text: gettext('Shell'),
> @@ -115,7 +138,7 @@ Ext.define('PVE.node.Config', {
>  	    title: gettext('Node') + " '" + nodename + "'",
>  	    hstateid: 'nodetab',
>  	    defaults: { statusStore: me.statusStore },
> -	    tbar: [ restartBtn, shutdownBtn, shellBtn, actionBtn]
> +	    tbar: [ restartBtn, shutdownBtn, wakeonlanBtn, shellBtn, actionBtn ]
>  	});
>  
>  	if (caps.nodes['Sys.Audit']) {
> @@ -401,13 +424,12 @@ Ext.define('PVE.node.Config', {
>  
>  	me.mon(me.statusStore, 'load', function(s, records, success) {
>  	    var uptimerec = s.data.get('uptime');
> -	    var powermgmt = uptimerec ? uptimerec.data.value : false;
> -	    if (!caps.nodes['Sys.PowerMgmt']) {
> -		powermgmt = false;
> -	    }
> -	    restartBtn.setDisabled(!powermgmt);
> -	    shutdownBtn.setDisabled(!powermgmt);
> -	    shellBtn.setDisabled(!powermgmt);
> +	    var running = uptimerec ? true : false;
> +	    var powermgmt = caps.nodes['Sys.PowerMgmt'];
> +	    restartBtn.setDisabled(!(powermgmt && running));
> +	    shutdownBtn.setDisabled(!(powermgmt && running));
> +	    shellBtn.setDisabled(!(powermgmt && running));
> +	    wakeonlanBtn.setDisabled(!powermgmt || running);
>  	});
>  
>  	me.on('afterrender', function() {
> 




More information about the pve-devel mailing list