diff --git a/config.php b/config.php index 4af454d..3c4f5f8 100644 --- a/config.php +++ b/config.php @@ -1,7 +1,7 @@ document.getElementById(id); -// ── Settings / persisted state ── -// -// We use localStorage for now. Later we might persist via a hyprcrd setting -// or a plugin-level table — see TODO.md. +const CONFIG = { + baseUrl: 'http://localhost:8085', + authToken: '', // Keycloak bearer; empty = no auth yet + pollIntervalSec: 15, +}; -const LS_KEY = 'oumta-dashboard-settings'; const state = { - settings: { - baseUrl: 'http://localhost:8080', // e.g. https://dashboard.oumta.internal; default fits local dev - authToken: '', // Keycloak bearer; empty = no auth yet - pollIntervalSec: 15, - }, namespaces: [], // [{ id, label, namespace }] activeNamespace: null, activeView: 'overview', @@ -28,31 +25,21 @@ const state = { data: { overview: null, workloads: [], timeline: [], scopeWorkload: null }, }; -function loadSettings() { - try { - const raw = localStorage.getItem(LS_KEY); - if (raw) Object.assign(state.settings, JSON.parse(raw)); - } catch {} -} -function saveSettings() { - localStorage.setItem(LS_KEY, JSON.stringify(state.settings)); -} - // ── Central API surface ───────────────────────────────────────── // -// Every backend call routes through `api()`. Requests go against -// `state.settings.baseUrl`; the active namespace (if any) is attached -// as a `namespace` query parameter, and the configured auth token is -// sent as a bearer header. Response shapes are defined by the Go -// backend in `internal/httpapi/contracts.go`. +// Every backend call routes through `api()`. Requests go against the +// hardwired baseUrl; the active namespace (if any) is attached as a +// `namespace` query parameter, and the bearer token (if any) is sent as +// Authorization. Response shapes are defined by the Go backend in +// `internal/httpapi/contracts.go`. async function api(path, opts = {}) { - const url = new URL(path, state.settings.baseUrl); + const url = new URL(path, CONFIG.baseUrl); if (!url.searchParams.has('namespace') && state.activeNamespace) { url.searchParams.set('namespace', state.activeNamespace.namespace); } - const headers = state.settings.authToken - ? { Authorization: 'Bearer ' + state.settings.authToken } + const headers = CONFIG.authToken + ? { Authorization: 'Bearer ' + CONFIG.authToken } : {}; const res = await fetch(url, { ...opts, headers }); if (!res.ok) throw new Error(`${res.status}: ${await res.text()}`); @@ -337,7 +324,7 @@ function stopLive() { setLive('off'); } function startPolling() { - const ms = (state.settings.pollIntervalSec || 15) * 1000; + const ms = (CONFIG.pollIntervalSec || 15) * 1000; state.pollHandle = setInterval(refresh, ms); setLive('polling'); } @@ -394,46 +381,6 @@ if (document.readyState === 'loading') { injectHeaderButton(); } -// ── Settings tab in hyprcrd settings ───────────────────────── - -function renderSettingsPanel(panelEl) { - panelEl.innerHTML = ` -
Authorization: Bearer <token>. Leave empty if the API is unauthenticated.