import { Show, createSignal, onMount, type Component } from "solid-js"; import { fetchAllState, fetchVersion } from "./api/rest"; import { openEventStream } from "./api/sse"; import { replaceAll, state } from "./stores/state"; import { scope, setScope } from "./stores/scope"; import ScopeSelector from "./components/ScopeSelector"; import Overview from "./views/Overview"; import DebugPanel from "./views/DebugPanel"; import type { VersionInfo } from "./types"; import logoUrl from "./assets/logo-bimi.svg"; import { isAdmin } from "./stores/mode"; const App: Component = () => { const [error, setError] = createSignal(); const [version, setVersion] = createSignal(); onMount(async () => { try { const [snaps, ver] = await Promise.all([fetchAllState(), fetchVersion()]); replaceAll(snaps); setVersion(ver); if (!scope() && snaps.length > 0) { setScope(snaps[0].maglevd.name); } openEventStream(); } catch (err) { setError(`${err}`); } }); // The admin toggle is only shown when the server reports that admin // credentials are configured. Without this gate, we'd link operators // to a /admin/ URL that returns 404 and surprise them. const adminAvailable = () => version()?.admin_enabled === true; return (
maglev {version() && ( {version()!.version} ({version()!.commit}) )}
{isAdmin ? "admin" : "view"} {isAdmin ? "exit admin" : "admin…"}
{error() && } {!error() && Object.keys(state.byName).length === 0 &&

Loading…

} {/* Admin-only sections — everything below this line is hidden on /view/ and only rendered when the SPA was loaded at /admin/. The basic-auth gate on /admin/ means only authenticated users ever reach this branch. Future admin-only features drop in here, one per block, so the /view-vs-/admin diff stays localized and reviewable. */}
); }; export default App;