1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-24 21:34:01 +03:00

B #4020: Fix status of NoVNC server (#4151)

(cherry picked from commit aa7fd0e889)
This commit is contained in:
Sergio Betanzos 2020-02-03 16:42:27 +01:00 committed by Tino Vazquez
parent 97f3febe7f
commit cf86a53f46
No known key found for this signature in database
GPG Key ID: 2FE9C32E94AEABBE
4 changed files with 66 additions and 17 deletions

View File

@ -17,7 +17,35 @@
define(function(require) {
var RFB = require("vnc-rfb").default;
var Config = require("sunstone-config");
var rfb;
var _rfb;
var _is_encrypted = "";
function setStatus(message="", status=""){
$(".NOVNC_message").text(message);
$("#noVNC_status").text(status);
}
function connected(){
setStatus(null, "VNC " + _rfb._rfb_connection_state + " (" + _is_encrypted + ") to: " + _rfb._fb_name);
}
function disconnectedFromServer(e){
if (e.detail.clean) {
setStatus(null, "VNC " + _rfb._rfb_connection_state + " (" + _is_encrypted + ") to: " + _rfb._fb_name);
} else {
setStatus("Something went wrong, connection is closed", "Failed");
}
}
function desktopNameChange(e) {
if (e.detail.name) {
setStatus(null, "VNC " + _rfb._rfb_connection_state + " (" + _is_encrypted + ") to: " + e.detail.name);
}
}
function credentialsRequired(e) {
setStatus("Something went wrong, more credentials must be given to continue", "Failed");
}
function passwordRequired(rfb) {
var msg;
@ -31,24 +59,24 @@ define(function(require) {
document.querySelector("#setPasswordForm").addEventListener("submit", setPassword);
}
function setPassword(event) {
rfb.sendPassword(document.querySelector("#password_input").value);
_rfb.sendPassword(document.querySelector("#password_input").value);
event.preventDefault();
return false;
}
function sendCtrlAltDel() {
rfb.sendCtrlAltDel();
_rfb.sendCtrlAltDel();
return false;
}
function xvpShutdown() {
rfb.xvpShutdown();
_rfb.xvpShutdown();
return false;
}
function xvpReboot() {
rfb.xvpReboot();
_rfb.xvpReboot();
return false;
}
function xvpReset() {
rfb.xvpReset();
_rfb.xvpReset();
return false;
}
function updateState(rfb, state, oldstate, msg) {
@ -109,8 +137,10 @@ define(function(require) {
if (window.location.protocol === "https:") {
URL = "wss";
_is_encrypted = "encrypted";
} else {
URL = "ws";
_is_encrypted = "unencrypted";
}
URL += "://" + window.location.hostname;
URL += ":" + proxy_port;
@ -133,8 +163,13 @@ define(function(require) {
return;
}
try{
rfb = new RFB(document.querySelector("#VNC_canvas"), URL, rfbConfig);
_rfb = new RFB(document.querySelector("#VNC_canvas"), URL, rfbConfig);
_rfb.addEventListener("connect", connected);
_rfb.addEventListener("disconnect", disconnectedFromServer);
_rfb.addEventListener("desktopname", desktopNameChange);
_rfb.addEventListener("credentialsrequired", credentialsRequired);
}catch(err){
setStatus("Something went wrong, connection is closed", "Failed");
console.log("error start NOVNC ", err);
}
});

View File

@ -18,7 +18,6 @@
<div class="row text-center">
<div class="large-12 columns">
<h5 class="subheader" id="vnc_dialog">
{{tr "VNC"}}
<span id="VNC_status"></span>
<span id="VNC_buttons" class="right">
<button class="button alert" value="Send CtrlAltDel" id="sendCtrlAltDelButton">{{tr "Send CtrlAltDel"}}</button>

View File

@ -21,6 +21,7 @@ define(function(require) {
var _rfb;
var _message = "";
var _status = "Loading";
var _is_encrypted = "";
return {
"lockStatus": lockStatus,
@ -43,25 +44,35 @@ define(function(require) {
_lock = false;
}
function connected(){
status("","Loaded");
}
function status(message="", status=""){
function setStatus(message="", status=""){
_message = message;
_status = status;
$(".NOVNC_message").text(_message);
$("#VNC_status").text(_status);
}
function connected(){
setStatus(null, "VNC " + _rfb._rfb_connection_state + " (" + _is_encrypted + ") to: " + _rfb._fb_name);
}
function disconnectedFromServer(e){
if (e.detail.clean) {
status("", "Loaded");
setStatus(null, "VNC " + _rfb._rfb_connection_state + " (" + _is_encrypted + ") to: " + _rfb._fb_name);
} else {
status("Something went wrong, connection is closed", "Failed");
setStatus("Something went wrong, connection is closed", "Failed");
}
}
function desktopNameChange(e) {
if (e.detail.name) {
setStatus(null, "VNC " + _rfb._rfb_connection_state + " (" + _is_encrypted + ") to: " + e.detail.name);
}
}
function credentialsRequired(e) {
setStatus("Something went wrong, more credentials must be given to continue", "Failed");
}
function vncCallback(response) {
var URL = "";
var proxy_host = window.location.hostname;
@ -76,8 +87,10 @@ define(function(require) {
if (protocol === "https:") {
URL = "wss";
_is_encrypted ="encrypted";
} else {
URL = "ws";
_is_encrypted ="unencrypted";
}
URL += "://" + hostname;
URL += ":" + proxy_port;
@ -97,8 +110,10 @@ define(function(require) {
_rfb = new RFB(document.querySelector("#VNC_canvas"), URL, rfbConfig);
_rfb.addEventListener("connect", connected);
_rfb.addEventListener("disconnect", disconnectedFromServer);
_rfb.addEventListener("desktopname", desktopNameChange);
_rfb.addEventListener("credentialsrequired", credentialsRequired);
}catch(err){
status("Something went wrong, connection is closed", "Failed");
setStatus("Something went wrong, connection is closed", "Failed");
console.log("error start NOVNC ", err);
}

View File

@ -70,7 +70,7 @@
<td width="1%" >
<img src="images/one_small_logo.png" style="height:40px; vertical-align:top; margin-left: 30px"></td>
<td>
<div id="noVNC_status" style="position: relative; height: auto;">Loading</div>
<div id="noVNC_status" style="position: relative; height: auto; color: #000;">Loading</div>
</td>
<td width="1%" >
<div id="noVNC_buttons" style="margin-right: 30px">