Permalink
Browse files

Added VNC support.

  • Loading branch information...
1 parent 8167e14 commit 2567b570729944d75bf5335d5ab58e7739b44e6a @Licenser Licenser committed Apr 27, 2012
View
@@ -1,4 +1,4 @@
-OBJ=ebin/wiggle.app ebin/wiggle_app.beam ebin/wiggle_server.beam ebin/wiggle_sup.beam ebin/wiggle.beam ebin/cowboy_utils.beam ebin/wiggle_handler.beam ebin/wiggle_storage.beam ebin/wiggle_keymanager.beam
+OBJ=ebin/wiggle.app ebin/wiggle_app.beam ebin/wiggle_server.beam ebin/wiggle_sup.beam ebin/wiggle.beam ebin/cowboy_utils.beam ebin/wiggle_handler.beam ebin/wiggle_storage.beam ebin/wiggle_keymanager.beam ebin/wiggle_wsproxy.beam
DEPS=deps/jsx deps/lhttpc deps/alogger deps/cowboy
ERL=erl
PA=ebin deps/*/ebin
View
@@ -1,11 +1,10 @@
var ui = new Object();
!function ($) {
+ var rfb;
var center=$("#center");
- var confirm = $(
-);
var machine_details = $(
- "<div class='row-fluid'>" +
+ "<div class='row-fluid'>" +
"<div class='span3'><h3>Machine Details</h3></div>" +
"<div class='span9'>" +
"<div class='btn-group' style='float: right'>" +
@@ -23,7 +22,30 @@ var ui = new Object();
"<div class='span2'>Dataset</div><div class='span9' id='machine-detail-dataset'>-</div>" +
"<div class='span2'>Created</div><div class='span9' id='machine-detail-created'>-</div>" +
"</div>");
-
+ var vnc_view = $(
+ '<ul class="nav nav-tabs" id="detail-tabs">' +
+ '<li class="active"><a href="#tab-details" id="details-btn" data-toggle="tab">Details</a></li>' +
+ '<li><a href="#tab-vnc" id="vnc-btn" data-toggle="tab">vnc</a></li>' +
+ '</ul>' +
+ '<div class="tab-content">' +
+ '<div class="tab-pane active" id="tab-details"></div>' +
+ '<div class="tab-pane" id="tab-vnc">' +
+ '<div id="noVNC_screen">' +
+ '<div id="noVNC_status_bar" class="noVNC_status_bar" style="margin-top: 0px;">' +
+ '<table border=0 width="100%"><tr>' +
+ '<td><div id="noVNC_status">Loading</div></td>' +
+ '<td width="1%"><div id="noVNC_buttons">' +
+ '<input type=button value="Send CtrlAltDel" id="sendCtrlAltDelButton">' +
+ '</div></td>' +
+ '</tr></table>' +
+ '</div>' +
+ '<canvas id="noVNC_canvas" width="640px" height="20px">' +
+ 'Canvas not supported.' +
+ '</canvas>' +
+ '</div>' +
+ '</div>' +
+ '</div>');
+
var machine_form = $(
"<div>" +
"<label>Name</label><input type='text' id='machine-new-name'/></br>" +
@@ -40,7 +62,10 @@ var ui = new Object();
var modal = $("#modal");
var btns = $("#modal .modal-footer");
$("#modal .modal-header h3").text("Delete VM");
- $("#modal .modal-body p").text("You are about to delete a VM, this action can not be reversed! all data willbe lost forever!");
+ $("#modal .modal-body p").
+ append("You are about to delete the VM ").
+ append($("<b>" +$(".machine.active").val() + "</b>")).
+ append(", this action can not be reversed! all data willbe lost forever!");
go.click(function(){
$.ajax({
url: "/my/machines/"+id,
@@ -136,10 +161,25 @@ var ui = new Object();
});;
}
}
+ function disconnect_vnc() {
+ if (rfb)
+ rfb.disconnect();
+ }
function show_machine(data) {
- center.empty();
- center.append(machine_details);
-
+ var c = center;
+ c.empty();
+ disconnect_vnc();
+ if (data.type == "kvm") {
+ //we have VNC
+ c.append(vnc_view);
+ $('#detail-tabs a:first').tab('show')
+ c = $("#tab-details");
+ $("#vnc-btn").click(function () {
+ init_vnc(data.id)
+ });
+ $("#details-btn").click(disconnect_vnc);
+ };
+ c.append(machine_details);
update_machine(data);
$('#machine-detail-start').click(function (){machine_action(data.id, "start")});
$('#machine-detail-reboot').click(function (){machine_action(data.id, "reboot")});
@@ -239,7 +279,6 @@ var ui = new Object();
};
-
function view_add_vm() {
var center = $("#center");
center.empty();
@@ -289,7 +328,7 @@ var ui = new Object();
});
$("#machines-nav-add").click(view_add_vm);
$("#machines-nav-del").click(delete_vm);
- setInterval(function () {
+/* ui.refresh = setInterval(function () {
$.ajax({
url: "/my/machines",
dataType: 'json',
@@ -299,6 +338,57 @@ var ui = new Object();
}
}
});
- }, 1000);
+ }, 1000);*/
+ };
+
+ function updateState(rfb, state, oldstate, msg) {
+ var s, sb, cad, level;
+ s = $D('noVNC_status');
+ sb = $D('noVNC_status_bar');
+ cad = $D('sendCtrlAltDelButton');
+ switch (state) {
+ case 'failed': level = "error"; break;
+ case 'fatal': level = "error"; break;
+ case 'normal': level = "normal"; break;
+ case 'disconnected': level = "normal"; break;
+ case 'loaded': level = "normal"; break;
+ default: level = "warn"; break;
+ }
+
+ if (state === "normal" && cad) { cad.disabled = false; }
+ else { if (cad) cad.disabled = true; }
+
+ if (typeof(msg) !== 'undefined' && sb && s) {
+ sb.setAttribute("class", "noVNC_status_" + level);
+ s.innerHTML = msg;
+ }
+ }
+ function sendCtrlAltDel() {
+ rfb.sendCtrlAltDel();
+ return false;
+ }
+
+ function init_vnc(id) {
+ var host, port, password, path, token;
+
+ $D('sendCtrlAltDelButton').style.display = "inline";
+ $D('sendCtrlAltDelButton').onclick = sendCtrlAltDel;
+
+ // By default, use the host and port of server that served this file
+ host = WebUtil.getQueryVar('host', window.location.hostname);
+ port = WebUtil.getQueryVar('port', window.location.port);
+
+ path = "machines/" + id + "/vnc"
+ rfb = new RFB({'target': $D('noVNC_canvas'),
+ 'encrypt': WebUtil.getQueryVar('encrypt',
+ (window.location.protocol === "https:")),
+ 'true_color': WebUtil.getQueryVar('true_color', true),
+ 'local_cursor': WebUtil.getQueryVar('cursor', true),
+ 'shared': WebUtil.getQueryVar('shared', true),
+ 'view_only': false,
+ 'updateState': updateState});
+ rfb.connect(host, port, password, path);
};
}(window.jQuery);
+
+
View
Binary file not shown.
Binary file not shown.
Oops, something went wrong.

0 comments on commit 2567b57

Please sign in to comment.