funktionsfähing und mit schöneren design

This commit is contained in:
megamichi 2024-09-15 20:38:22 +02:00
parent fadf7b15c5
commit 8be81d7421
10 changed files with 110 additions and 58 deletions

View file

@ -4,27 +4,30 @@
<script>
let termdiv;
function button() {
function sendcommand(list) {
fetch("/term",{
method:"POST",
body: JSON.stringify("bla"),
body: list,
headers: {"Content-type":"application/json; charset=UTF-8"}
});
getterm();
};
function getterm() {
termdiv.innerHTML = "";
let tmpterm = "";
fetch("/term", { method: "GET" })
.then(response => response.json())
.then(termarray => {
console.log(termarray);
for (let line of termarray) {
termdiv.innerHTML += `
${line}<br>`;
tmpterm += `${line}<br>`;
}
});
termdiv.innerHTML = tmpterm;
})
.catch(termdiv.innerHTML = 'Fehler beim Abrufen der Daten');
}
function initstuff() {
termdiv = document.getElementById("terminal");
getterm();
@ -41,11 +44,12 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Terradash</title>
</head>
<body >
<h1>Dash</h1>
<body style="background-size: cover; background-image: url({{ url_for('static', filename='background.png') }});">
<img src="{{ url_for('static', filename='logo.png') }}" alt="Terra-Dash">
<div id="dash">
<div id="buttons">
<button class="button" onclick="button()">test</button>
<button class="button" onclick="sendcommand([`start`])">start</button>
<button style="background-color: rgb(186, 0, 0);" class="button" onclick="sendcommand([`stop`])">stop</button>
</div>
<div id="terminal">
</div>