-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unified the layout for VNC/SPICE remote consoles
- Created a common HAML view for both console types - Separate JS files with preprocessed dependencies - Removed the old HAML views for VNC/SPICE - Removed some dead code in the related controller
- Loading branch information
Showing
7 changed files
with
159 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//= require jquery | ||
//= require spice-html5-bower/spiceHTML5/spicearraybuffer | ||
//= require spice-html5-bower | ||
|
||
$(function() { | ||
var host = window.location.hostname; | ||
var encrypt = window.location.protocol === 'https:'; | ||
var port = encrypt ? 443 : 80; | ||
if (window.location.port) { | ||
port = window.location.port; | ||
} | ||
|
||
$('#ctrlaltdel').click(sendCtrlAltDel); | ||
|
||
var spice = new SpiceMainConn({ | ||
uri: (encrypt ? 'wss://' : 'ws://') + host + ':' + port + '/' + $('#remote-console').attr('data-url'), | ||
screen_id: "remote-console", | ||
password: $('#remote-console').attr('data-secret'), | ||
onerror: function(e) { | ||
spice.stop(); | ||
$('#connection-status').removeClass('label-success label-warning').addClass('label-danger'); | ||
$('#connection-status').text('Disconnected'); | ||
console.error("SPICE", e); | ||
}, | ||
onsuccess: function() { | ||
$('#connection-status').removeClass('label-danger label-warning').addClass('label-success'); | ||
$('#connection-status').text('Connected'); | ||
}, | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//= require jquery | ||
//= require novnc-rails | ||
|
||
$(function() { | ||
var host = window.location.hostname; | ||
var encrypt = window.location.protocol === 'https:'; | ||
var port = encrypt ? 443 : 80; | ||
if (window.location.port) { | ||
port = window.location.port; | ||
} | ||
|
||
// noVNC requires an empty canvas item | ||
var canvas = document.createElement('canvas'); | ||
$('#remote-console').append(canvas); | ||
|
||
var vnc = new RFB({ | ||
target: canvas, | ||
encrypt: encrypt, | ||
true_color: true, | ||
local_cursor: true, | ||
shared: true, | ||
view_only: false, | ||
onUpdateState: function(_, state, _, msg) { | ||
if (['normal', 'loaded'].includes(state)) { | ||
$('#connection-status').removeClass('label-danger label-warning').addClass('label-success'); | ||
$('#connection-status').text('Connected'); | ||
} else if (state === 'disconnected') { | ||
$('#connection-status').removeClass('label-success label-warning').addClass('label-danger'); | ||
$('#connection-status').text('Disconnected'); | ||
console.error('VNC', msg); | ||
} | ||
}, | ||
}); | ||
|
||
$('#ctrlaltdel').click(vnc.sendCtrlAltDel); | ||
vnc.connect(host, port, $('#remote-console').attr('data-secret'), $('#remote-console').attr('data-url')); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
= render :partial => 'layouts/doctype' | ||
%html{:lang => I18n.locale.to_s.sub('-', '_')} | ||
%head | ||
%title | ||
= _('ManageIQ HTML5 Remote Console') | ||
= favicon_link_tag | ||
= stylesheet_link_tag 'application' | ||
-# Load the required JS based on the console type | ||
= javascript_include_tag 'jquery', "remote_consoles/#{@console[:type]}" | ||
-# Css for the unified look & feel | ||
:css | ||
#remote-console { | ||
position: fixed; | ||
width: 100%; | ||
height: calc(100% - 30px) !important; | ||
overflow: auto; | ||
} | ||
footer { | ||
position: fixed; | ||
line-height: 30px; | ||
vertical-align: middle; | ||
height: 30px; | ||
width: 100%; | ||
top: calc(100% - 32px); | ||
padding-left: 0.2em; | ||
padding-right: 0.2em; | ||
} | ||
-# Handling the fullscreen button | ||
:javascript | ||
$(function () { | ||
$('#fullscreen').click(function () { | ||
switch(true) { | ||
case document.fullScreenEnabled: | ||
if (document.fullscreenElement) { | ||
document.exitFullscreen(); | ||
} else { | ||
document.documentElement.requestFullscreen(); | ||
} | ||
break; | ||
case document.webkitFullscreenEnabled: | ||
if (document.webkitFullscreenElement) { | ||
document.webkitExitFullscreen(); | ||
} else { | ||
document.documentElement.webkitRequestFullscreen(); | ||
} | ||
break; | ||
case document.mozFullScreenEnabled: | ||
if (document.mozFullscreenElement) { | ||
document.mozExitFullscreen(); | ||
} else { | ||
document.documentElement.mozRequestFullscreen(); | ||
} | ||
break; | ||
case document.msFullscreenEnabled: | ||
if (document.msFullscreenElement) { | ||
document.msExitFullscreen(); | ||
} else { | ||
document.documentElement.msRequestFullscreen(); | ||
} | ||
break; | ||
} | ||
}); | ||
|
||
}); | ||
%body | ||
#remote-console{'data-url' => @console[:url], 'data-secret' => @console[:secret]} | ||
%footer | ||
.pull-left | ||
%span#console-type.label.label-info= @console[:type].upcase | ||
%span#connection-status.label.label-warning Connecting | ||
.pull-right | ||
%button#ctrlaltdel.btn.btn-default | ||
%i.fa.fa-keyboard-o | ||
%button#fullscreen.btn.btn-default | ||
%i.fa.fa-arrows-alt |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Rails.application.config.assets.precompile += %w( | ||
remote_consoles/*.js | ||
) |