[pve-devel] [PATCH manager 5/5] add xtermjs to consolebutton
Thomas Lamprecht
t.lamprecht at proxmox.com
Mon Dec 4 10:07:27 CET 2017
On 12/01/2017 09:29 AM, Dominik Csapak wrote:
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
> www/manager6/button/ConsoleButton.js | 27 ++++++++++++++++++++-------
> www/manager6/lxc/Config.js | 30 +++++++++++++++++++++---------
> www/manager6/node/Config.js | 9 +++++++++
> 3 files changed, 50 insertions(+), 16 deletions(-)
>
> diff --git a/www/manager6/button/ConsoleButton.js b/www/manager6/button/ConsoleButton.js
> index 98ebea0e..d8a69980 100644
> --- a/www/manager6/button/ConsoleButton.js
> +++ b/www/manager6/button/ConsoleButton.js
> @@ -16,7 +16,7 @@ Ext.define('PVE.button.ConsoleButton', {
> var me = this;
>
> me.enableSpice = enable;
> - me.spiceMenu.setDisabled(!enable);
> + me.down('#spicemenu').setDisabled(!enable);
> },
>
> initComponent: function() {
> @@ -26,7 +26,20 @@ Ext.define('PVE.button.ConsoleButton', {
> throw "no node name specified";
> }
>
> - me.spiceMenu = Ext.create('Ext.menu.Item', {
> + var items = [];
> +
> + items.push({
> + xtype:'menuitem',
> + text: 'noVNC',
> + iconCls: 'pve-itype-icon-novnc',
> + handler: function() {
> + PVE.Utils.openConsoleWindow('html5', me.consoleType, me.vmid, me.nodename, me.consoleName);
> + }
> + });
> +
> + items.push({
> + xterm: 'menuitem',
> + itemId: 'spicemenu',
> text: 'SPICE',
> iconCls: 'pve-itype-icon-virt-viewer',
> handler: function() {
as all those items gets pushed unconditionally the could be added when
declaring the items array above. Buut it's not the first time we use this
pattern, so it's OK for me either way.
> @@ -34,11 +47,11 @@ Ext.define('PVE.button.ConsoleButton', {
> }
> });
>
> - var noVncMenu = Ext.create('Ext.menu.Item', {
> - text: 'noVNC',
> - iconCls: 'pve-itype-icon-novnc',
> + items.push({
> + text: 'xterm.js',
> + iconCls: 'fa fa-terminal',
> handler: function() {
> - PVE.Utils.openConsoleWindow('html5', me.consoleType, me.vmid, me.nodename, me.consoleName);
> + PVE.Utils.openConsoleWindow('xtermjs', me.consoleType, me.vmid, me.nodename, me.consoleName);
All those almost identical handler let me think that a higher order
closure taking the type as argument and returning the real handler
could be nice here, so that just:
handler: gethandler('xtermjs')
would be needed.
But not really important and could be always done later one in a cleanup
patch for the whole file.
> }
> });
>
> @@ -52,7 +65,7 @@ Ext.define('PVE.button.ConsoleButton', {
> me.nodename, me.consoleName);
> },
> menu: new Ext.menu.Menu({
> - items: [ noVncMenu, me.spiceMenu ]
> + items: items
> })
> });
>
> diff --git a/www/manager6/lxc/Config.js b/www/manager6/lxc/Config.js
> index 0ffc4841..bcff47ba 100644
> --- a/www/manager6/lxc/Config.js
> +++ b/www/manager6/lxc/Config.js
> @@ -148,15 +148,27 @@ Ext.define('PVE.lxc.Config', {
> });
>
> if (caps.vms['VM.Console']) {
> - me.items.push({
> - title: gettext('Console'),
> - itemId: 'console',
> - iconCls: 'fa fa-terminal',
> - xtype: 'pveNoVncConsole',
> - vmid: vmid,
> - consoleType: 'lxc',
> - nodename: nodename
> - });
> + me.items.push(
> + {
> + title: gettext('Console'),
> + itemId: 'console',
> + iconCls: 'fa fa-terminal',
> + xtype: 'pveNoVncConsole',
> + vmid: vmid,
> + consoleType: 'lxc',
> + nodename: nodename
> + },
> + {
> + title: gettext('Console (JS)'),
> + itemId: 'consolejs',
> + iconCls: 'fa fa-terminal',
> + xtype: 'pveNoVncConsole',
> + vmid: vmid,
> + consoleType: 'lxc',
> + xtermjs: true,
> + nodename: nodename
> + }
I assume this is temporarily for testing? Or do we want to have both,
noVNC and xtermjs side by side as inline console for CTs/ Node Shell?
Probably at least not forever.
> + );
> }
>
> me.items.push(
> diff --git a/www/manager6/node/Config.js b/www/manager6/node/Config.js
> index 49f1186f..4d6b51ef 100644
> --- a/www/manager6/node/Config.js
> +++ b/www/manager6/node/Config.js
> @@ -139,6 +139,15 @@ Ext.define('PVE.node.Config', {
> xtype: 'pveNoVncConsole',
> consoleType: 'shell',
> nodename: nodename
> + },
> + {
> + title: gettext('Shell (JS)'),
> + iconCls: 'fa fa-terminal',
> + itemId: 'jsconsole',
> + xtype: 'pveNoVncConsole',
> + consoleType: 'shell',
> + xtermjs: true,
> + nodename: nodename
> }
> );
> }
>
More information about the pve-devel
mailing list