364939466f
Architektur auf Separation of Concerns umgestellt – ohne Build-Schritt,
ohne neues Framework, ohne DB (KISS bleibt). Endpoint-URLs unveraendert,
daher 1:1-kompatibel zum bisherigen Stand.
Backend (Top-Level-Helfer + ein Router je Bereich):
- app.py auf duennen Einstieg reduziert (FastAPI + include_router + static)
- config/auth/jobengine/llamaswap als getrennte Helfer-Module
- Endpoints in routers/{models,jobs,maintenance}.py
Frontend (native ES-Module statt Single-File):
- index.html = Huelle: Sidebar-Nav, Topbar, Alert-Banner, Hash-Routing
- css/{base,components}.css – Tokens + Komponenten
- js/core/{api,ui,nav}.js + js/panels/{overview,models,maintenance,jobs}.js + main.js
- Panel-Vertrag: { id, mount?(), onStatus?(s), onJobs?(jobs) }
- Optik an docs/mission-control-overview.png angelehnt (Hero, KPI-Kacheln,
Listen, Aktivitaets-Stream, getoente Karten)
Doku: CLAUDE.md + README auf die neue Struktur aktualisiert.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
25 lines
715 B
JavaScript
25 lines
715 B
JavaScript
// api.js — zentraler Fetch-Wrapper + Token-Handling.
|
|
// Einziges Modul, das localStorage nutzt (nur fuers Token-Feld — laut Konvention ok).
|
|
|
|
let TOKEN = localStorage.getItem("mc_token") || "";
|
|
|
|
export function getToken() { return TOKEN; }
|
|
|
|
export function setToken(t) {
|
|
TOKEN = (t || "").trim();
|
|
localStorage.setItem("mc_token", TOKEN);
|
|
}
|
|
|
|
export function hdr() {
|
|
const h = { "Content-Type": "application/json" };
|
|
if (TOKEN) h["X-MC-Token"] = TOKEN;
|
|
return h;
|
|
}
|
|
|
|
export async function api(path, opts = {}) {
|
|
const r = await fetch(path, { headers: hdr(), ...opts });
|
|
const data = await r.json().catch(() => ({}));
|
|
if (!r.ok) throw new Error(data.error || ("HTTP " + r.status));
|
|
return data;
|
|
}
|