import { qs, VIEW_LABELS } from "./modules/dom.js"; import { updateClock } from "./modules/ui.js"; import { loadDashboard } from "./views/dashboard.js"; import { loadEvents, initEvents } from "./views/events.js"; import { loadRobots, initRobots } from "./views/robots.js"; import { initInspection, resetSession } from "./views/inspection.js"; import { renderRobots } from "./views/robotCards.js"; function switchView(viewName) { if (!VIEW_LABELS[viewName]) return; document.querySelectorAll("[data-view-panel]").forEach((panel) => { panel.classList.toggle("is-active", panel.dataset.viewPanel === viewName); }); document.querySelectorAll("[data-view]").forEach((button) => { button.classList.toggle("is-active", button.dataset.view === viewName); }); qs("#viewTitle").textContent = VIEW_LABELS[viewName]; qs("#viewBreadcrumb").textContent = VIEW_LABELS[viewName]; qs("#sidebar").classList.remove("is-open"); if (viewName === "events") loadEvents(); if (viewName === "robots") loadRobots(); if (["overview", "risks", "settings"].includes(viewName)) loadDashboard(); } document.querySelectorAll("[data-view], [data-view-jump]").forEach((control) => { control.addEventListener("click", () => switchView(control.dataset.view || control.dataset.viewJump)); }); qs("#menuButton").addEventListener("click", () => qs("#sidebar").classList.toggle("is-open")); initInspection(); initEvents(); initRobots(); updateClock(); setInterval(updateClock, 1000); resetSession(); renderRobots(); Promise.all([loadDashboard(), loadEvents()]);