better terminal

This commit is contained in:
piair
2024-02-28 11:41:13 +01:00
parent 0f60d67951
commit a089fdfdf1
12 changed files with 630 additions and 25 deletions

View File

@ -1,35 +1,42 @@
{% extends "base.html" %}
{% block left_pannel %}override{% endblock %}
{% block content %}
{%if not current_user.is_authenticated %}
<button class="unselected" onclick="location.href = '/login';">login</button>
{% else %}
<table>
<tr>
<td width="20%" height="90%">
<div id="console"></div>
</td>
<td width="80%">
<iframe src="/novnc/vnc.html?resize=scale&path=novnc/websockify&autoconnect=true&view_only" width="100%" height="100%" frameborder="0"></iframe>
</td>
</tr>
</table>
{% if not current_user.is_authenticated %}
<button class="unselected" onclick="location.href = '/login';">login</button>
{% else %}
<link rel="stylesheet" href="{{ url_for('static', filename='node_modules/xterm/css/xterm.css') }}"/>
<script src="{{ url_for('static', filename='node_modules/xterm/lib/xterm.js') }}"></script>
<table>
<tr>
<td width="20%" height="90%">
<div id="console"></div>
</td>
<td width="80%">
<iframe src="/novnc/vnc.html?resize=scale&path=novnc/websockify&autoconnect=true&view_only"
width="100%" height="100%" frameborder="0"></iframe>
</td>
</tr>
</table>
<script>
<script>
const consoleElement = document.getElementById('console');
const eventSource = new EventSource('/stream');
eventSource.onmessage = (event) => {
document.getElementById("console").innerHTML = event.data + document.getElementById("console").innerHTML
};
</script>
</script>
<script>
var term = new Terminal();
term.open(document.getElementById('terminal'));
const consoleElement = document.getElementById('console');
const eventSource = new EventSource('/stream');
{% endif %}
eventSource.onmessage = (event) => {
term.writeln(event.data)
};
{%endblock %}
</script>
{% endif %}
{% endblock %}