feat: server console (Feature 2) & complete roadmap
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { api } from "../core/api.js";
|
||||
import { api, getToken } from "../core/api.js";
|
||||
import { $, toast } from "../core/ui.js";
|
||||
import { track } from "./jobs.js";
|
||||
|
||||
@@ -24,8 +24,19 @@ function mount() {
|
||||
<button id="w-os-update">OS-Updates installieren (apt update)</button>
|
||||
<button id="w-reboot" class="danger">Server Reboot</button>
|
||||
</div>
|
||||
<div class="hint" style="margin-top:12px">
|
||||
<div class="hint" style="margin-top:12px; margin-bottom:32px">
|
||||
Für tiefe Eingriffe fragt das Dashboard einmalig das sudo-Passwort ab.
|
||||
</div>
|
||||
|
||||
<div class="card-h">
|
||||
<h3>Live-Konsole</h3>
|
||||
<select id="w-console-sel" style="margin-left:auto; width:200px">
|
||||
<option value="llama-swap">llama-swap</option>
|
||||
<option value="mission-control">mission-control</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="w-console" style="background:#111; color:#0f0; font-family:monospace; font-size:12px; padding:12px; border-radius:8px; height:400px; overflow-y:auto; white-space:pre-wrap;">
|
||||
Verbinde...
|
||||
</div>`;
|
||||
|
||||
$("#w-restart-swap").addEventListener("click", () => restartService("llama-swap"));
|
||||
@@ -35,6 +46,33 @@ function mount() {
|
||||
|
||||
$("#w-os-update").addEventListener("click", osUpdate);
|
||||
$("#w-reboot").addEventListener("click", rebootServer);
|
||||
|
||||
$("#w-console-sel").addEventListener("change", () => connectConsole());
|
||||
connectConsole();
|
||||
}
|
||||
|
||||
let ws = null;
|
||||
|
||||
function connectConsole() {
|
||||
if (ws) {
|
||||
ws.close();
|
||||
ws = null;
|
||||
}
|
||||
const svc = $("#w-console-sel").value;
|
||||
const out = $("#w-console");
|
||||
out.innerHTML = "Verbinde mit " + svc + "...\n";
|
||||
|
||||
const proto = location.protocol === "https:" ? "wss:" : "ws:";
|
||||
const url = `${proto}//${location.host}/api/logs/${svc}?token=${getToken()}`;
|
||||
ws = new WebSocket(url);
|
||||
|
||||
ws.onmessage = (e) => {
|
||||
out.innerHTML += e.data;
|
||||
out.scrollTop = out.scrollHeight;
|
||||
};
|
||||
ws.onclose = () => {
|
||||
out.innerHTML += "\n--- Verbindung getrennt ---";
|
||||
};
|
||||
}
|
||||
|
||||
async function restartService(name) {
|
||||
@@ -81,4 +119,4 @@ async function unloadAll() {
|
||||
} catch (e) { toast(e.message, true); }
|
||||
}
|
||||
|
||||
export default { id: "maintenance", mount };
|
||||
export default { id: "server", mount };
|
||||
Reference in New Issue
Block a user