console.html 2.31 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
<div class="btn-toolbar">
        <button id="sendCtrlAltDelButton" class="btn btn-danger small" href="#">Send CtrlAltDel</button>
</div>
<div class="alert alert-info" id="noVNC_status">
</div>

<canvas id="noVNC_canvas" width="640px" height="20px">Canvas not supported.
</canvas>

<script src="{{ STATIC_URL }}dashboard/novnc/util.js"></script>
<script>
    "use strict";

    var INCLUDE_URI = '{{ STATIC_URL }}dashboard/novnc/';

    Util.load_scripts(["webutil.js", "base64.js", "websock.js", "des.js",
                       "input.js", "display.js", "jsunzip.js", "rfb.js"]);

    var rfb;

    function updateState(rfb, state, oldstate, msg) {
        var s, sb, cad
        s = $('#noVNC_status')[0];
        cad = $('#sendCtrlAltDelButton')[0];

        if (state === "normal") { cad.disabled = false; }
        else                    { cad.disabled = true; }

        if (typeof(msg) !== 'undefined') {
            s.innerHTML = msg;
        }
    }

    $('a[data-toggle$="pill"][href!="#console"]').click(function() {
        if (rfb) {
            rfb.disconnect();
            rfb = 0;
        }
        $("#vm-info-pane").fadeIn();
        $("#vm-detail-pane").removeClass("col-md-12");
    });
    $('#sendCtrlAltDelButton').click(function() {
        rfb.sendCtrlAltDel(); return false;});
    $('#akkount-mate').click(function() {
45
        return false;});
46
    $('#akkount-bd').click(function() {
47
        return false;});
48 49 50 51 52 53 54 55 56


    $('a[href$="console"]').click(function() {
        var host, port, password, path;

        $("#vm-info-pane").hide();
        $("#vm-detail-pane").addClass("col-md-12");
        WebUtil.init_logging('warn');

57
        host = window.location.hostname;
Bach Dániel committed
58 59 60 61 62 63
        if (window.location.port == 8080) {
            port = 9999;
        } else {
	    port = window.location.port == "" ? "443" : window.location.port;
        }
        password = '';
64
        path = 'vnc/?d={{ vnc_url }}';
65 66

        rfb = new RFB({'target': $D('noVNC_canvas'),
67
                       'encrypt': (window.location.protocol === "https:"),
68 69 70 71 72 73 74 75
                       'true_color':   true,
                       'local_cursor': true,
                       'shared':       true,
                       'view_only':    false,
                       'updateState':  updateState});
        rfb.connect(host, port, password, path);
    });
    </script>