Skip to content

Commit cbced66

Browse files
committed
Tweaking novnc to work
1 parent 2962e1f commit cbced66

File tree

4 files changed

+130
-138
lines changed

4 files changed

+130
-138
lines changed

server/src/main/java/com/cloud/servlet/ConsoleProxyServlet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ private String composeConsoleAccessUrl(String rootUrl, VirtualMachine vm, HostVO
484484
if (param.getHypervHost() != null || !ConsoleProxyManager.NoVncConsoleDefault.value()) {
485485
sb.append("/ajax?token=" + encryptor.encryptObject(ConsoleProxyClientParam.class, param));
486486
} else {
487-
sb.append("/resource/noVNC/vnc_lite.html?port=" + ConsoleProxyManager.DEFAULT_NOVNC_PORT + "&token="
487+
sb.append("/resource/noVNC/vnc.html?port=" + ConsoleProxyManager.DEFAULT_NOVNC_PORT + "&token="
488488
+ encryptor.encryptObject(ConsoleProxyClientParam.class, param));
489489
}
490490

systemvm/agent/noVNC/app/ui.js

Lines changed: 11 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ const UI = {
4141
reconnectCallback: null,
4242
reconnectPassword: null,
4343

44+
fullScreen: false,
45+
4446
prime() {
4547
return WebUtil.initSettings().then(() => {
4648
if (document.readyState === "interactive" || document.readyState === "complete") {
@@ -158,6 +160,7 @@ const UI = {
158160
/* Populate the controls if defaults are provided in the URL */
159161
UI.initSetting('host', window.location.hostname);
160162
UI.initSetting('port', port);
163+
UI.initSetting('token', window.location.token);
161164
UI.initSetting('encrypt', (window.location.protocol === "https:"));
162165
UI.initSetting('view_clip', false);
163166
UI.initSetting('resize', 'off');
@@ -317,10 +320,8 @@ const UI = {
317320
addClipboardHandlers() {
318321
document.getElementById("noVNC_clipboard_button")
319322
.addEventListener('click', UI.toggleClipboardPanel);
320-
document.getElementById("noVNC_clipboard_text")
321-
.addEventListener('change', UI.clipboardSend);
322-
document.getElementById("noVNC_clipboard_clear_button")
323-
.addEventListener('click', UI.clipboardClear);
323+
document.getElementById("noVNC_clipboard_send_button")
324+
.addEventListener('click', UI.clipboardSend);
324325
},
325326

326327
// Add a call to save settings when the element changes,
@@ -953,16 +954,10 @@ const UI = {
953954
Log.Debug("<< UI.clipboardReceive");
954955
},
955956

956-
clipboardClear() {
957-
document.getElementById('noVNC_clipboard_text').value = "";
958-
UI.rfb.clipboardPasteFrom("");
959-
},
960-
961957
clipboardSend() {
962958
const text = document.getElementById('noVNC_clipboard_text').value;
963-
Log.Debug(">> UI.clipboardSend: " + text.substr(0, 40) + "...");
964-
UI.rfb.clipboardPasteFrom(text);
965-
Log.Debug("<< UI.clipboardSend");
959+
UI.rfb.sendText(text)
960+
return false;
966961
},
967962

968963
/* ------^-------
@@ -991,6 +986,7 @@ const UI = {
991986
const host = UI.getSetting('host');
992987
const port = UI.getSetting('port');
993988
const path = UI.getSetting('path');
989+
const token = UI.getSetting('token')
994990

995991
if (typeof password === 'undefined') {
996992
password = WebUtil.getConfigVar('password');
@@ -1022,6 +1018,7 @@ const UI = {
10221018
url += ':' + port;
10231019
}
10241020
url += '/' + path;
1021+
url += '?token=' + token;
10251022

10261023
UI.rfb = new RFB(document.getElementById('noVNC_container'), url,
10271024
{ shared: UI.getSetting('shared'),
@@ -1206,31 +1203,8 @@ const UI = {
12061203
* ------v------*/
12071204

12081205
toggleFullscreen() {
1209-
if (document.fullscreenElement || // alternative standard method
1210-
document.mozFullScreenElement || // currently working methods
1211-
document.webkitFullscreenElement ||
1212-
document.msFullscreenElement) {
1213-
if (document.exitFullscreen) {
1214-
document.exitFullscreen();
1215-
} else if (document.mozCancelFullScreen) {
1216-
document.mozCancelFullScreen();
1217-
} else if (document.webkitExitFullscreen) {
1218-
document.webkitExitFullscreen();
1219-
} else if (document.msExitFullscreen) {
1220-
document.msExitFullscreen();
1221-
}
1222-
} else {
1223-
if (document.documentElement.requestFullscreen) {
1224-
document.documentElement.requestFullscreen();
1225-
} else if (document.documentElement.mozRequestFullScreen) {
1226-
document.documentElement.mozRequestFullScreen();
1227-
} else if (document.documentElement.webkitRequestFullscreen) {
1228-
document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
1229-
} else if (document.body.msRequestFullscreen) {
1230-
document.body.msRequestFullscreen();
1231-
}
1232-
}
1233-
UI.updateFullscreenButton();
1206+
this.fullScreen = !this.fullScreen
1207+
UI.rfb.scaleViewport = this.fullScreen
12341208
},
12351209

12361210
updateFullscreenButton() {

systemvm/agent/noVNC/core/rfb.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,13 @@ export default class RFB extends EventTargetMixin {
419419
setTimeout(this._initMsg.bind(this), 0);
420420
}
421421

422+
sendText(text) {
423+
for (var i = 0; i < text.length; i++) {
424+
this.sendKey(text.charCodeAt(i), text.charAt(i), true);
425+
this.sendKey(text.charCodeAt(i), text.charAt(i), false);
426+
}
427+
}
428+
422429
sendCtrlAltDel() {
423430
if (this._rfbConnectionState !== 'connected' || this._viewOnly) { return; }
424431
Log.Info("Sending Ctrl-Alt-Del");

systemvm/agent/noVNC/vnc.html

Lines changed: 111 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<title>noVNC</title>
1717

1818
<meta charset="utf-8">
19-
19+
2020
<!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
2121
Remove this if you use the .htaccess -->
2222
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
@@ -67,7 +67,7 @@
6767
<!-- end scripts -->
6868
</head>
6969

70-
<body>
70+
<body id="body">
7171

7272
<div id="noVNC_fallback_error" class="noVNC_center">
7373
<div>
@@ -151,8 +151,8 @@ <h1 class="noVNC_logo" translate="no"><span>no</span><br>VNC</h1>
151151
</div>
152152
<textarea id="noVNC_clipboard_text" rows=5></textarea>
153153
<br>
154-
<input id="noVNC_clipboard_clear_button" type="button"
155-
value="Clear" class="noVNC_submit">
154+
<input id="noVNC_clipboard_send_button" type="button"
155+
value="Send" class="noVNC_submit">
156156
</div>
157157
</div>
158158

@@ -162,103 +162,109 @@ <h1 class="noVNC_logo" translate="no"><span>no</span><br>VNC</h1>
162162
title="Fullscreen">
163163

164164
<!-- Settings -->
165-
<input type="image" alt="Settings" src="app/images/settings.svg"
166-
id="noVNC_settings_button" class="noVNC_button"
167-
title="Settings">
168-
<div class="noVNC_vcenter">
169-
<div id="noVNC_settings" class="noVNC_panel">
170-
<ul>
171-
<li class="noVNC_heading">
172-
<img alt="" src="app/images/settings.svg"> Settings
173-
</li>
174-
<li>
175-
<label><input id="noVNC_setting_shared" type="checkbox"> Shared Mode</label>
176-
</li>
177-
<li>
178-
<label><input id="noVNC_setting_view_only" type="checkbox"> View Only</label>
179-
</li>
180-
<li><hr></li>
181-
<li>
182-
<label><input id="noVNC_setting_view_clip" type="checkbox"> Clip to Window</label>
183-
</li>
184-
<li>
185-
<label for="noVNC_setting_resize">Scaling Mode:</label>
186-
<select id="noVNC_setting_resize" name="vncResize">
187-
<option value="off">None</option>
188-
<option value="scale">Local Scaling</option>
189-
<option value="remote">Remote Resizing</option>
190-
</select>
191-
</li>
192-
<li><hr></li>
193-
<li>
194-
<div class="noVNC_expander">Advanced</div>
195-
<div><ul>
196-
<li>
197-
<label for="noVNC_setting_quality">Quality:</label>
198-
<input id="noVNC_setting_quality" type="range" min="0" max="9" value="6">
199-
</li>
200-
<li>
201-
<label for="noVNC_setting_compression">Compression level:</label>
202-
<input id="noVNC_setting_compression" type="range" min="0" max="9" value="2">
203-
</li>
204-
<li><hr></li>
205-
<li>
206-
<label for="noVNC_setting_repeaterID">Repeater ID:</label>
207-
<input id="noVNC_setting_repeaterID" type="text" value="">
208-
</li>
209-
<li>
210-
<div class="noVNC_expander">WebSocket</div>
211-
<div><ul>
212-
<li>
213-
<label><input id="noVNC_setting_encrypt" type="checkbox"> Encrypt</label>
214-
</li>
215-
<li>
216-
<label for="noVNC_setting_host">Host:</label>
217-
<input id="noVNC_setting_host">
218-
</li>
219-
<li>
220-
<label for="noVNC_setting_port">Port:</label>
221-
<input id="noVNC_setting_port" type="number">
222-
</li>
223-
<li>
224-
<label for="noVNC_setting_path">Path:</label>
225-
<input id="noVNC_setting_path" type="text" value="websockify">
226-
</li>
227-
</ul></div>
228-
</li>
229-
<li><hr></li>
230-
<li>
231-
<label><input id="noVNC_setting_reconnect" type="checkbox"> Automatic Reconnect</label>
232-
</li>
233-
<li>
234-
<label for="noVNC_setting_reconnect_delay">Reconnect Delay (ms):</label>
235-
<input id="noVNC_setting_reconnect_delay" type="number">
236-
</li>
237-
<li><hr></li>
238-
<li>
239-
<label><input id="noVNC_setting_show_dot" type="checkbox"> Show Dot when No Cursor</label>
240-
</li>
241-
<li><hr></li>
242-
<!-- Logging selection dropdown -->
243-
<li>
244-
<label>Logging:
245-
<select id="noVNC_setting_logging" name="vncLogging">
246-
</select>
247-
</label>
248-
</li>
249-
</ul></div>
250-
</li>
251-
<li class="noVNC_version_separator"><hr></li>
252-
<li class="noVNC_version_wrapper">
253-
<span>Version:</span>
254-
<span class="noVNC_version"></span>
255-
</li>
256-
</ul>
257-
</div>
258-
</div>
165+
<span style="display: none;">
166+
<input type="image" alt="Settings" src="app/images/settings.svg"
167+
id="noVNC_settings_button" class="noVNC_button"
168+
title="Settings">
169+
<div class="noVNC_vcenter">
170+
<div id="noVNC_settings" class="noVNC_panel">
171+
<ul>
172+
<li class="noVNC_heading">
173+
<img alt="" src="app/images/settings.svg"> Settings
174+
</li>
175+
<li>
176+
<label><input id="noVNC_setting_shared" type="checkbox"> Shared Mode</label>
177+
</li>
178+
<li>
179+
<label><input id="noVNC_setting_view_only" type="checkbox"> View Only</label>
180+
</li>
181+
<li><hr></li>
182+
<li>
183+
<label><input id="noVNC_setting_view_clip" type="checkbox"> Clip to Window</label>
184+
</li>
185+
<li>
186+
<label for="noVNC_setting_resize">Scaling Mode:</label>
187+
<select id="noVNC_setting_resize" name="vncResize">
188+
<option value="off">None</option>
189+
<option value="scale">Local Scaling</option>
190+
<option value="remote">Remote Resizing</option>
191+
</select>
192+
</li>
193+
<li><hr></li>
194+
<li>
195+
<div class="noVNC_expander">Advanced</div>
196+
<div><ul>
197+
<li>
198+
<label for="noVNC_setting_quality">Quality:</label>
199+
<input id="noVNC_setting_quality" type="range" min="0" max="9" value="6">
200+
</li>
201+
<li>
202+
<label for="noVNC_setting_compression">Compression level:</label>
203+
<input id="noVNC_setting_compression" type="range" min="0" max="9" value="2">
204+
</li>
205+
<li><hr></li>
206+
<li>
207+
<label for="noVNC_setting_repeaterID">Repeater ID:</label>
208+
<input id="noVNC_setting_repeaterID" type="text" value="">
209+
</li>
210+
<li>
211+
<div class="noVNC_expander">WebSocket</div>
212+
<div><ul>
213+
<li>
214+
<label><input id="noVNC_setting_encrypt" type="checkbox"> Encrypt</label>
215+
</li>
216+
<li>
217+
<label for="noVNC_setting_host">Host:</label>
218+
<input id="noVNC_setting_host">
219+
</li>
220+
<li>
221+
<label for="noVNC_setting_port">Port:</label>
222+
<input id="noVNC_setting_port" type="number">
223+
</li>
224+
<li>
225+
<label for="noVNC_setting_path">Path:</label>
226+
<input id="noVNC_setting_path" type="text" value="websockify">
227+
</li>
228+
<li>
229+
<label for="noVNC_setting_token">Token:</label>
230+
<input id="noVNC_setting_token" type="text">
231+
</li>
232+
</ul></div>
233+
</li>
234+
<li><hr></li>
235+
<li>
236+
<label><input id="noVNC_setting_reconnect" type="checkbox"> Automatic Reconnect</label>
237+
</li>
238+
<li>
239+
<label for="noVNC_setting_reconnect_delay">Reconnect Delay (ms):</label>
240+
<input id="noVNC_setting_reconnect_delay" type="number">
241+
</li>
242+
<li><hr></li>
243+
<li>
244+
<label><input id="noVNC_setting_show_dot" type="checkbox"> Show Dot when No Cursor</label>
245+
</li>
246+
<li><hr></li>
247+
<!-- Logging selection dropdown -->
248+
<li>
249+
<label>Logging:
250+
<select id="noVNC_setting_logging" name="vncLogging">
251+
</select>
252+
</label>
253+
</li>
254+
</ul></div>
255+
</li>
256+
<li class="noVNC_version_separator"><hr></li>
257+
<li class="noVNC_version_wrapper">
258+
<span>Version:</span>
259+
<span class="noVNC_version"></span>
260+
</li>
261+
</ul>
262+
</div>
263+
</div>
264+
</span>
259265

260266
<!-- Connection Controls -->
261-
<input type="image" alt="Disconnect" src="app/images/disconnect.svg"
267+
<input style="display: none;" type="image" alt="Disconnect" src="app/images/disconnect.svg"
262268
id="noVNC_disconnect_button" class="noVNC_button"
263269
title="Disconnect">
264270

@@ -273,7 +279,7 @@ <h1 class="noVNC_logo" translate="no"><span>no</span><br>VNC</h1>
273279
<div id="noVNC_status"></div>
274280

275281
<!-- Connect button -->
276-
<div class="noVNC_center">
282+
<div class="noVNC_center" style="display: none;">
277283
<div id="noVNC_connect_dlg">
278284
<div class="noVNC_logo" translate="no"><span>no</span>VNC</div>
279285
<div id="noVNC_connect_button"><div>
@@ -325,4 +331,9 @@ <h1 class="noVNC_logo" translate="no"><span>no</span><br>VNC</h1>
325331
<source src="app/sounds/bell.mp3" type="audio/mpeg">
326332
</audio>
327333
</body>
334+
<script type="application/javascript">
335+
window.onload = function() {
336+
document.getElementById("noVNC_connect_button").click(); //example function call.
337+
}
338+
</script>
328339
</html>

0 commit comments

Comments
 (0)