diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js index af03958c5..d0de3829e 100644 --- a/www/manager6/Utils.js +++ b/www/manager6/Utils.js @@ -278,20 +278,23 @@ Ext.define('PVE.Utils', { utilities: { return data; }, + console_map: { + '__default__': Proxmox.Utils.defaultText + ' (HTML5)', + 'vv': 'SPICE (remote-viewer)', + 'html5': 'HTML5 (noVNC)', + 'xtermjs': 'xterm.js', + }, + render_console_viewer: function(value) { - if (!value || value === '__default__') { - return Proxmox.Utils.defaultText + ' (HTML5)'; - } else if (value === 'vv') { - return 'SPICE (remote-viewer)'; - } else if (value === 'html5') { - return 'HTML5 (noVNC)'; - } else { - return value; + value = value || '__default__'; + if (PVE.Utils.console_map[value]) { + return PVE.Utils.console_map[value]; } + return value; }, console_viewer_array: function() { - return Ext.Array.map(['__default__','vv', 'html5'], function(v) { + return Ext.Array.map(Object.keys(PVE.Utils.console_map), function(v) { return [v, PVE.Utils.render_console_viewer(v)]; }); }, @@ -723,8 +726,8 @@ Ext.define('PVE.Utils', { utilities: { function(m, addr, offset, original) { return addr; }); }, - openDefaultConsoleWindow: function(allowSpice, vmtype, vmid, nodename, vmname) { - var dv = PVE.Utils.defaultViewer(allowSpice); + openDefaultConsoleWindow: function(consoles, vmtype, vmid, nodename, vmname) { + var dv = PVE.Utils.defaultViewer(consoles); PVE.Utils.openConsoleWindow(dv, vmtype, vmid, nodename, vmname); }, @@ -765,10 +768,20 @@ Ext.define('PVE.Utils', { utilities: { } }, - defaultViewer: function(allowSpice) { + defaultViewer: function(consoles) { + + var allowSpice, allowXtermjs; + + if (consoles === true) { + allowSpice = true; + allowXtermjs = true; + } else if (typeof consoles === 'object') { + allowSpice = consoles.spice; + allowXtermjs = consoles.xtermjs; + } var vncdefault = 'html5'; var dv = PVE.VersionInfo.console || vncdefault; - if (dv === 'vv' && !allowSpice) { + if ((dv === 'vv' && !allowSpice) || (dv === 'xtermjs' && !allowXtermjs)) { dv = vncdefault; } diff --git a/www/manager6/button/ConsoleButton.js b/www/manager6/button/ConsoleButton.js index 97bed1700..d825e1fbb 100644 --- a/www/manager6/button/ConsoleButton.js +++ b/www/manager6/button/ConsoleButton.js @@ -33,7 +33,11 @@ Ext.define('PVE.button.ConsoleButton', { handler: function() { var me = this; - PVE.Utils.openDefaultConsoleWindow(me.enableSpice, me.consoleType, me.vmid, + var consoles = { + spice: me.enableSpice, + xtermjs: me.enableXtermjs + }; + PVE.Utils.openDefaultConsoleWindow(consoles, me.consoleType, me.vmid, me.nodename, me.consoleName); }, diff --git a/www/manager6/qemu/CmdMenu.js b/www/manager6/qemu/CmdMenu.js index 00af7cbca..da6f556ab 100644 --- a/www/manager6/qemu/CmdMenu.js +++ b/www/manager6/qemu/CmdMenu.js @@ -169,7 +169,12 @@ Ext.define('PVE.qemu.CmdMenu', { }, success: function(response, opts) { var allowSpice = response.result.data.spice; - PVE.Utils.openDefaultConsoleWindow(allowSpice, 'kvm', vmid, nodename, vmname); + var allowXtermjs = response.result.data.serial; + var consoles = { + spice: allowSpice, + xtermjs: allowXtermjs + }; + PVE.Utils.openDefaultConsoleWindow(consoles, 'kvm', vmid, nodename, vmname); } }); }