From aad460fa13f9b769029176c3bdd0a9b0918a997e Mon Sep 17 00:00:00 2001 From: Jorge Miguel Lobo Escalona <47326048+jloboescalona2@users.noreply.github.com> Date: Wed, 15 Dec 2021 18:15:30 +0100 Subject: [PATCH] F #5672: disable info header on guacamole console (#1673) (cherry picked from commit e1476fb24553216f4eb3c379e3a962c30b1ba34f) --- .../public/app/utils/remote-actions.js | 68 ++++++++++--------- src/sunstone/views/index.erb | 1 + 2 files changed, 36 insertions(+), 33 deletions(-) diff --git a/src/sunstone/public/app/utils/remote-actions.js b/src/sunstone/public/app/utils/remote-actions.js index 9aeda42392..859ec634c6 100644 --- a/src/sunstone/public/app/utils/remote-actions.js +++ b/src/sunstone/public/app/utils/remote-actions.js @@ -19,15 +19,15 @@ define(function(require) { Sunstone = require("sunstone"), Config = require("sunstone-config"), OpenNebulaVM = require("opennebula/vm"), - FireedgeValidator = require('utils/fireedge-validator'), - Notifier = require('utils/notifier'); - + FireedgeValidator = require("utils/fireedge-validator"), + Notifier = require("utils/notifier"); + function _callSpice(data) { - if (data.hasOwnProperty('id')) Sunstone.runAction('VM.startspice_action', String(data.id)); + if (data.hasOwnProperty("id")) Sunstone.runAction("VM.startspice_action", String(data.id)); } function _callVNC(data) { - if (data.hasOwnProperty('id')) Sunstone.runAction('VM.startvnc_action', String(data.id)); + if (data.hasOwnProperty("id")) Sunstone.runAction("VM.startvnc_action", String(data.id)); } function _callSaveRDP(data) { @@ -293,58 +293,60 @@ define(function(require) { } /** - * - * @param {Object} response Callback response with the token and info - * @param {Object} options - * @returns + * + * @param {Object} response Callback response with the token and info + * @param {Object} options + * @returns */ function _getLink(response, options){ options = $.extend({ host: undefined, port: undefined, - connnection_type: '', - extra_path: '', + connnection_type: "", + extra_path: "", extra_params: [] }, options); + var paramInfo = config && config.system_config && !config.system_config.disable_guacamole_info_header && response.info && "info=" + response.info; + var params = options.extra_params.concat([ - response.token && 'token=' + response.token, - response.info && 'info=' + response.info + response.token && "token=" + response.token, + paramInfo ]).filter(Boolean); var endpoint = new URL(window.location.href); - var websocketProtocol = endpoint.protocol === 'https:' ? 'wss:' : 'ws:'; + var websocketProtocol = endpoint.protocol === "https:" ? "wss:" : "ws:"; - var websocket = websocketProtocol + '//'; + var websocket = websocketProtocol + "//"; if (options.host && options.port) - websocket += options.host + ':' + options.port + websocket += options.host + ":" + options.port; else if (options.port) - websocket += endpoint.hostname + ':' + options.port - else + websocket += endpoint.hostname + ":" + options.port; + else websocket += endpoint.host; - - websocket += options.extra_path + '?' + params.join("&"); + + websocket += options.extra_path + "?" + params.join("&"); var encoded_socket = btoa(websocket); var link = endpoint.origin + "/" + options.connnection_type + "?socket=" + encoded_socket; - + return link; } return { - 'callSpice': _callSpice, - 'callVNC': _callVNC, - 'callSaveRDP': _callSaveRDP, - 'callSaveWFile': _callSaveWFile, - 'callVMRC': _callVMRC, - 'callGuacVNC': _callGuacVNC, - 'callGuacSSH': _callGuacSSH, - 'callGuacRDP': _callGuacRDP, - 'callGuacVNC': _callGuacVNC, - 'renderActionsHtml': _renderActionsHtml, - 'bindActionsToContext': _bindActionsToContext, - 'getLink': _getLink + "callSpice": _callSpice, + "callVNC": _callVNC, + "callSaveRDP": _callSaveRDP, + "callSaveWFile": _callSaveWFile, + "callVMRC": _callVMRC, + "callGuacVNC": _callGuacVNC, + "callGuacSSH": _callGuacSSH, + "callGuacRDP": _callGuacRDP, + "callGuacVNC": _callGuacVNC, + "renderActionsHtml": _renderActionsHtml, + "bindActionsToContext": _bindActionsToContext, + "getLink": _getLink }; }); diff --git a/src/sunstone/views/index.erb b/src/sunstone/views/index.erb index 46de7ab9a8..423e03e9d5 100644 --- a/src/sunstone/views/index.erb +++ b/src/sunstone/views/index.erb @@ -59,6 +59,7 @@ 'vnc_client_port' : '<%= $conf[:vnc_client_port] %>', 'allow_vnc_federation' : '<%= (!$conf[:allow_vnc_federation].nil?)? $conf[:allow_vnc_federation] : "no" %>', 'max_upload_file_size' : <%= $conf[:max_upload_file_size] ? $conf[:max_upload_file_size] : "undefined" %>, + 'disable_guacamole_info_header' : <%= $conf[:disable_guacamole_info_header] === 'yes' %>, 'leases' : <%= $conf[:leases] ? $conf[:leases].to_json : "null" %>, 'mapped_ips' : '<%= $conf[:mapped_ips] ? $conf[:mapped_ips] : false %>', 'get_extended_vm_info': '<%= $conf[:get_extended_vm_info] ? $conf[:get_extended_vm_info] : false %>',