Terra-Dash/templates/index.html

94 lines
3.2 KiB
HTML
Raw Permalink Normal View History

2024-09-13 15:07:56 +02:00
<!DOCTYPE html>
<html lang="de">
<head>
<script>
let termdiv;
2024-09-16 21:01:46 +02:00
let terminput;
let timer;
let timertext;
const COMMAND = "command";
function sendcommand(contentlist) {
fetch("/term",{
method:"POST",
body: JSON.stringify({"content":contentlist}),
headers: {"Content-type":"application/json; charset=UTF-8"}
}).then(getterm());
}
function sendtermcommand() {
sendcommand([COMMAND,
`terminal-command`,
terminput.value]
);
terminput.value = "";
}
2024-09-13 15:07:56 +02:00
function getterm() {
let tmpterm = "";
2024-09-13 15:07:56 +02:00
fetch("/term", { method: "GET" })
.then(response => response.json())
.then(termarray => {
console.log(termarray);
for (let line of termarray) {
tmpterm += `${line}<br>`;
2024-09-13 15:07:56 +02:00
}
termdiv.innerHTML = tmpterm;
})
.catch(termdiv.innerHTML = 'Fehler beim Abrufen der Daten');
2024-09-13 15:07:56 +02:00
}
2024-09-16 21:01:46 +02:00
function getterminterval() {
timer -= 1
timertext.innerHTML = `Reload in ${timer} Seconds`
if (timer == 0) {
getterm()
timer = 5
}
}
function initstuff() {
timer = 5
timertext = document.getElementById("timer")
termdiv = document.getElementById("terminaltext");
terminput = document.getElementById("terminalinput");
getterm();
setInterval(getterminterval,1000)
}
2024-09-13 15:07:56 +02:00
window.onload = initstuff;
</script>
<link rel="stylesheet" href="/static/style.css">
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Terradash</title>
</head>
<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">
2024-09-13 15:07:56 +02:00
<div id="dash">
<div id="buttons">
2024-09-16 21:01:46 +02:00
<button style="margin-bottom: 10px;"
class="button"
onclick="sendcommand([COMMAND,`start`]);timer=2">start</button>
<button style="margin-bottom: 10px; background-color: rgb(255, 0, 0);"
class="button"
onclick="sendcommand([COMMAND,`stop`]);timer=1">stop</button>
</div>
<div style="width: 100%;height: 100%;">
<p style="font-size: 11px;margin: 0px;margin-left: 15px;" id="timer">Reload in _ Seconds</p>
<div id="terminal">
<div id="terminaltext"></div>
<input id="terminalinput" type="text">
<button
style="margin-top: 15px;"
class="button"
onclick="sendtermcommand();
terminput.value = ``">send</button>
</div>
2024-09-13 15:07:56 +02:00
</div>
</div>
</body>
</html>