[pve-devel] [PATCH manager v2 1/4] allow xtermjs to be the default console
Dominik Csapak
d.csapak at proxmox.com
Fri Apr 20 15:37:47 CEST 2018
if not available for a vm, we fallback to novnc like with spice
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
www/manager6/Utils.js | 39 ++++++++++++++++++++++++------------
www/manager6/button/ConsoleButton.js | 6 +++++-
www/manager6/qemu/CmdMenu.js | 7 ++++++-
3 files changed, 37 insertions(+), 15 deletions(-)
diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index af03958c..d0de3829 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 97bed170..d825e1fb 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 00af7cbc..da6f556a 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);
}
});
}
--
2.11.0
More information about the pve-devel
mailing list