refactor: make ui endpoint configurable
* use askama template for UI endpoint * make UI endpoint configurable
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
<!doctype html>
|
||||
<!--
|
||||
Copyright (c) 2019 Fabian Freyer <fabian.freyer@physik.tu-berlin.de>
|
||||
SPDX-License-Identifier: BSD-3-Clause
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="stylesheet" href="{{ static_path|safe }}/xterm/dist/xterm.css" />
|
||||
<script src="{{ static_path|safe }}/xterm/dist/xterm.js"></script>
|
||||
<script src="{{ static_path|safe }}/xterm/dist/addons/attach/attach.js"></script>
|
||||
<script src="{{ static_path|safe }}/xterm/dist/addons/terminado/terminado.js"></script>
|
||||
<script src="{{ static_path|safe }}/xterm/dist/addons/fit/fit.js"></script>
|
||||
<script src="{{ static_path|safe }}/xterm/dist/addons/search/search.js"></script>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
html, body, #terminal {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="terminal"></div>
|
||||
<script>
|
||||
Terminal.applyAddon(terminado);
|
||||
Terminal.applyAddon(fit);
|
||||
Terminal.applyAddon(search);
|
||||
|
||||
var term = new Terminal();
|
||||
var protocol = (location.protocol === 'https:') ? 'wss://' : 'ws://';
|
||||
var socketURL = protocol + location.hostname + ((location.port) ? (':' + location.port) : '') + "{{ websocket_path|safe }}";
|
||||
var sock = new WebSocket(socketURL);
|
||||
|
||||
sock.addEventListener('open', function() {
|
||||
term.terminadoAttach(sock);
|
||||
term.fit();
|
||||
});
|
||||
|
||||
sock.addEventListener('close', function() {
|
||||
term.writeln("");
|
||||
term.writeln("Connection closed.");
|
||||
term.terminadoDetach(sock);
|
||||
});
|
||||
|
||||
term.open(document.getElementById('terminal'));
|
||||
window.onresize = function() {term.fit();};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user