640 lines
19 KiB
TypeScript
640 lines
19 KiB
TypeScript
import type { ServerWsFrame } from '../../shared/ws-protocol.js';
|
|
import {
|
|
apiFetch,
|
|
registerStepUpHandler,
|
|
registerUnauthorizedHandler,
|
|
registerVaultUnlockHandler,
|
|
setApiSafeMode,
|
|
setCsrfToken,
|
|
} from './api.js';
|
|
import { confirmDialog, promptStepUp } from './dialogs.js';
|
|
import {
|
|
SAFE_MODE_STORAGE_KEY,
|
|
THEME_STORAGE_KEY,
|
|
applyTheme,
|
|
el,
|
|
extractErrorMessage,
|
|
flushViewCleanups,
|
|
getDashboardLivePatchers,
|
|
initialDeviceSafeMode,
|
|
type ClientAuthRequirements,
|
|
type ClientSecuritySettings,
|
|
type ClientState,
|
|
type ConfigOverview,
|
|
type RouteId,
|
|
} from './state.js';
|
|
import { showToast } from './toast.js';
|
|
import { MultiplexWsClient } from './ws-client.js';
|
|
|
|
const VALID_ROUTES = new Set<RouteId>([
|
|
'dashboard',
|
|
'systems',
|
|
'terminal',
|
|
'sftp',
|
|
'workflows',
|
|
'alerts',
|
|
'config',
|
|
'vault',
|
|
'settings',
|
|
]);
|
|
|
|
const wsClient = new MultiplexWsClient();
|
|
const state: ClientState = {
|
|
bootstrapped: false,
|
|
authenticated: false,
|
|
vaultState: 'uninitialized',
|
|
vaultRuntimeReady: true,
|
|
isPanicLocked: false,
|
|
safeMode: false,
|
|
defaultMobileSafeMode: true,
|
|
elevatedUntil: null,
|
|
activeAlertCount: 0,
|
|
theme: localStorage.getItem(THEME_STORAGE_KEY) ?? 'phosphor-green',
|
|
route: 'dashboard',
|
|
overview: null,
|
|
};
|
|
|
|
function parseRouteFromHash(): {
|
|
route: RouteId;
|
|
serverId?: string;
|
|
segments: string[];
|
|
query: Record<string, string>;
|
|
} {
|
|
const raw = window.location.hash.replace(/^#/, '');
|
|
const qIdx = raw.indexOf('?');
|
|
const pathPart = qIdx >= 0 ? raw.slice(0, qIdx) : raw;
|
|
const queryPart = qIdx >= 0 ? raw.slice(qIdx + 1) : '';
|
|
const query: Record<string, string> = {};
|
|
if (queryPart) {
|
|
for (const [k, v] of new URLSearchParams(queryPart)) {
|
|
query[k] = v;
|
|
}
|
|
}
|
|
|
|
const segs = pathPart
|
|
.split('/')
|
|
.filter(Boolean)
|
|
.map((s) => decodeURIComponent(s));
|
|
|
|
if (segs[0] === 'server' && segs[1]) {
|
|
return { route: 'server-detail', serverId: segs[1], segments: segs.slice(1), query };
|
|
}
|
|
const candidate = (segs[0] ?? 'dashboard') as RouteId;
|
|
if (VALID_ROUTES.has(candidate)) {
|
|
return { route: candidate, segments: segs.slice(1), query };
|
|
}
|
|
return { route: 'dashboard', segments: [], query };
|
|
}
|
|
|
|
function updateTopBarUi(): void {
|
|
const topbar = document.getElementById('topbar')!;
|
|
const nav = document.getElementById('primary-nav')!;
|
|
const vaultBadge = document.getElementById('vault-badge')!;
|
|
const safeBtn = document.getElementById('safe-toggle-btn')!;
|
|
const themeSelect = document.getElementById('theme-select') as HTMLSelectElement;
|
|
const stepupBadge = document.getElementById('stepup-badge')!;
|
|
const alertsBadge = document.getElementById('alerts-badge')!;
|
|
const banner = document.getElementById('global-banner')!;
|
|
|
|
topbar.hidden = !state.authenticated;
|
|
nav.hidden = !state.authenticated;
|
|
|
|
document.body.setAttribute('data-safe-mode', state.safeMode ? 'true' : 'false');
|
|
safeBtn.textContent = state.safeMode ? '[SAFE: ON]' : '[SAFE: OFF]';
|
|
safeBtn.setAttribute('aria-pressed', state.safeMode ? 'true' : 'false');
|
|
safeBtn.className = state.safeMode ? 'btn btn-sm btn-safe-on' : 'btn btn-sm';
|
|
|
|
if (!state.vaultRuntimeReady || state.isPanicLocked) {
|
|
vaultBadge.textContent = state.isPanicLocked ? '[VAULT: PANIC]' : '[VAULT: SEALED]';
|
|
vaultBadge.className = 'badge badge-err';
|
|
} else if (state.vaultState === 'unlocked') {
|
|
vaultBadge.textContent = '[VAULT: UNLOCKED]';
|
|
vaultBadge.className = 'badge badge-warn';
|
|
} else {
|
|
vaultBadge.textContent = '[VAULT: LOCKED]';
|
|
vaultBadge.className = 'badge badge-ok';
|
|
}
|
|
|
|
themeSelect.value = state.theme;
|
|
|
|
if (state.security?.stepUpPolicy === 'off') {
|
|
stepupBadge.hidden = false;
|
|
stepupBadge.textContent = '[STEP-UP: OFF]';
|
|
} else if (state.elevatedUntil && state.elevatedUntil > Date.now()) {
|
|
const remSec = Math.ceil((state.elevatedUntil - Date.now()) / 1000);
|
|
stepupBadge.hidden = false;
|
|
stepupBadge.textContent = remSec > 86400 ? '[ELEVATED: SESSION]' : `[2FA: ${remSec}s]`;
|
|
} else {
|
|
state.elevatedUntil = null;
|
|
stepupBadge.hidden = true;
|
|
}
|
|
|
|
if (state.authenticated && state.activeAlertCount > 0) {
|
|
alertsBadge.hidden = false;
|
|
alertsBadge.textContent = `[ALERTS: ${state.activeAlertCount}]`;
|
|
} else {
|
|
alertsBadge.hidden = true;
|
|
}
|
|
|
|
const activeNavRoute = state.route === 'server-detail' ? 'dashboard' : state.route;
|
|
for (const link of nav.querySelectorAll('.nav-link')) {
|
|
const r = link.getAttribute('data-route');
|
|
link.classList.toggle('active', r === activeNavRoute);
|
|
}
|
|
|
|
const errCount = state.overview?.diagnostics.errors.length ?? 0;
|
|
const warnCount = state.overview?.diagnostics.warnings.length ?? 0;
|
|
if (state.authenticated && (errCount > 0 || warnCount > 0)) {
|
|
banner.hidden = false;
|
|
banner.textContent = `Config Diagnostics: ${errCount} error(s), ${warnCount} warning(s). Check Config view for details.`;
|
|
} else {
|
|
banner.hidden = true;
|
|
}
|
|
}
|
|
|
|
async function refreshOverview(): Promise<void> {
|
|
const [overview, alertsSummary] = await Promise.all([
|
|
apiFetch<ConfigOverview>('/api/config/overview'),
|
|
apiFetch<{ activeCount: number }>('/api/alerts?limit=1').catch(() => ({ activeCount: 0 })),
|
|
]);
|
|
state.overview = overview;
|
|
state.activeAlertCount = alertsSummary.activeCount ?? 0;
|
|
updateTopBarUi();
|
|
}
|
|
|
|
let activeViewCleanup: (() => void) | null = null;
|
|
let renderSeq = 0;
|
|
|
|
function runActiveCleanup(): void {
|
|
if (activeViewCleanup) {
|
|
try {
|
|
activeViewCleanup();
|
|
} catch {
|
|
// Ignore view unmount errors
|
|
}
|
|
activeViewCleanup = null;
|
|
}
|
|
flushViewCleanups();
|
|
}
|
|
|
|
function captureCleanup(seq: number, result: unknown): void {
|
|
if (typeof result !== 'function') return;
|
|
const fn = result as () => void;
|
|
if (seq !== renderSeq) {
|
|
try {
|
|
fn();
|
|
} catch {
|
|
// Ignore stale cleanup error
|
|
}
|
|
return;
|
|
}
|
|
activeViewCleanup = fn;
|
|
}
|
|
|
|
async function renderCurrentView(): Promise<void> {
|
|
const mySeq = ++renderSeq;
|
|
runActiveCleanup();
|
|
|
|
const root = document.getElementById('view-root')!;
|
|
updateTopBarUi();
|
|
|
|
try {
|
|
if (!state.authenticated) {
|
|
const { renderAuthView } = await import('./views/auth-view.js');
|
|
if (mySeq !== renderSeq) return;
|
|
const cleanup = await renderAuthView(
|
|
root,
|
|
state.bootstrapped,
|
|
state.safeMode,
|
|
state.authRequirements,
|
|
async () => {
|
|
await bootstrapApp();
|
|
},
|
|
);
|
|
captureCleanup(mySeq, cleanup);
|
|
return;
|
|
}
|
|
|
|
if (!state.overview) {
|
|
await refreshOverview();
|
|
if (mySeq !== renderSeq) return;
|
|
}
|
|
|
|
const route = state.route;
|
|
if (route === 'dashboard') {
|
|
const { renderDashboardView } = await import('./views/dashboard-view.js');
|
|
if (mySeq !== renderSeq) return;
|
|
captureCleanup(mySeq, await renderDashboardView(root, state));
|
|
return;
|
|
}
|
|
if (route === 'server-detail' && state.selectedServerId) {
|
|
const { renderServerDetailView } = await import('./views/server-detail-view.js');
|
|
if (mySeq !== renderSeq) return;
|
|
captureCleanup(
|
|
mySeq,
|
|
await renderServerDetailView(root, state.selectedServerId, () => {
|
|
window.location.hash = '#dashboard';
|
|
}),
|
|
);
|
|
return;
|
|
}
|
|
if (route === 'config') {
|
|
const { renderConfigView } = await import('./views/config-view.js');
|
|
if (mySeq !== renderSeq) return;
|
|
captureCleanup(
|
|
mySeq,
|
|
await renderConfigView(root, state.overview!, state, wsClient, async () => {
|
|
await refreshOverview();
|
|
await renderCurrentView();
|
|
}),
|
|
);
|
|
return;
|
|
}
|
|
if (route === 'vault') {
|
|
const { renderVaultView } = await import('./views/vault-view.js');
|
|
if (mySeq !== renderSeq) return;
|
|
captureCleanup(
|
|
mySeq,
|
|
await renderVaultView(
|
|
root,
|
|
state,
|
|
async () => {
|
|
await syncStatusAndRender();
|
|
},
|
|
triggerPanicLock,
|
|
),
|
|
);
|
|
return;
|
|
}
|
|
if (route === 'settings') {
|
|
const { renderSettingsView } = await import('./views/settings-view.js');
|
|
if (mySeq !== renderSeq) return;
|
|
captureCleanup(
|
|
mySeq,
|
|
await renderSettingsView(
|
|
root,
|
|
state,
|
|
(theme) => {
|
|
state.theme = theme;
|
|
applyTheme(theme);
|
|
updateTopBarUi();
|
|
},
|
|
syncStatusAndRender,
|
|
),
|
|
);
|
|
return;
|
|
}
|
|
|
|
if (route === 'terminal') {
|
|
const { renderTerminalView } = await import('./views/terminal-view.js');
|
|
if (mySeq !== renderSeq) return;
|
|
captureCleanup(mySeq, await renderTerminalView(root, state, wsClient));
|
|
return;
|
|
}
|
|
if (route === 'sftp') {
|
|
const { renderSftpView } = await import('./views/sftp-view.js');
|
|
if (mySeq !== renderSeq) return;
|
|
captureCleanup(mySeq, await renderSftpView(root, state));
|
|
return;
|
|
}
|
|
if (route === 'systems') {
|
|
const { renderSystemsView } = await import('./views/systems-view.js');
|
|
if (mySeq !== renderSeq) return;
|
|
captureCleanup(mySeq, await renderSystemsView(root, state, wsClient));
|
|
return;
|
|
}
|
|
if (route === 'workflows') {
|
|
const { renderWorkflowsView } = await import('./views/workflows-view.js');
|
|
if (mySeq !== renderSeq) return;
|
|
captureCleanup(mySeq, await renderWorkflowsView(root, state, wsClient));
|
|
return;
|
|
}
|
|
if (route === 'alerts') {
|
|
const { renderAlertsView } = await import('./views/alerts-view.js');
|
|
if (mySeq !== renderSeq) return;
|
|
captureCleanup(mySeq, await renderAlertsView(root, state, wsClient));
|
|
}
|
|
} catch (err) {
|
|
if (mySeq !== renderSeq) return;
|
|
const msg = extractErrorMessage(err);
|
|
showToast(`View error: ${msg}`, 'err');
|
|
const retryBtn = el('button', { type: 'button', class: 'btn btn-primary' }, 'Retry View');
|
|
retryBtn.addEventListener('click', () => {
|
|
void renderCurrentView();
|
|
});
|
|
root.replaceChildren(
|
|
el(
|
|
'section',
|
|
{ class: 'panel panel-region' },
|
|
el('h2', { class: 'err-text' }, 'View Render Error'),
|
|
el('p', { class: 'mono muted' }, msg),
|
|
retryBtn,
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
async function triggerPanicLock(): Promise<void> {
|
|
const confirmed = await confirmDialog('dialog-panic');
|
|
if (!confirmed) return;
|
|
await apiFetch('/api/security/panic-lock', { method: 'POST' });
|
|
showToast('Panic lock engaged: Vault zeroized and sessions revoked.', 'warn');
|
|
handleLocalSessionReset(true);
|
|
}
|
|
|
|
async function lockVaultAction(): Promise<void> {
|
|
try {
|
|
await apiFetch('/api/vault/lock', { method: 'POST', body: {} });
|
|
state.vaultState = 'locked';
|
|
updateTopBarUi();
|
|
showToast('Vault locked (write-only mode).', 'ok');
|
|
if (state.route === 'vault') void renderCurrentView();
|
|
} catch (err) {
|
|
showToast(extractErrorMessage(err), 'err');
|
|
}
|
|
}
|
|
|
|
async function toggleSafeMode(): Promise<void> {
|
|
const next = !state.safeMode;
|
|
localStorage.setItem(SAFE_MODE_STORAGE_KEY, next ? '1' : '0');
|
|
state.safeMode = next;
|
|
setApiSafeMode(next);
|
|
if (next) state.elevatedUntil = null;
|
|
wsClient.send({ type: 'safe-mode', enabled: next });
|
|
if (state.authenticated) {
|
|
await apiFetch('/api/auth/safe-mode', {
|
|
method: 'POST',
|
|
body: { enabled: next },
|
|
});
|
|
}
|
|
updateTopBarUi();
|
|
showToast(`Safe Mode ${next ? 'enabled (read-only)' : 'disabled'}.`, next ? 'warn' : 'ok');
|
|
}
|
|
|
|
function handleLocalSessionReset(panic = false): void {
|
|
runActiveCleanup();
|
|
wsClient.disconnect();
|
|
setCsrfToken(null);
|
|
state.authenticated = false;
|
|
state.elevatedUntil = null;
|
|
state.overview = null;
|
|
if (panic) {
|
|
state.vaultState = 'locked';
|
|
state.vaultRuntimeReady = false;
|
|
state.isPanicLocked = true;
|
|
}
|
|
void renderCurrentView();
|
|
}
|
|
|
|
async function syncStatusAndRender(): Promise<void> {
|
|
const status = await apiFetch<{
|
|
bootstrapped: boolean;
|
|
authenticated: boolean;
|
|
safeMode?: boolean;
|
|
elevatedUntil?: number | null;
|
|
vaultState?: ClientState['vaultState'];
|
|
vaultRuntimeReady?: boolean;
|
|
isPanicLocked?: boolean;
|
|
defaultMobileSafeMode: boolean;
|
|
theme: string;
|
|
security?: ClientSecuritySettings;
|
|
authRequirements?: ClientAuthRequirements;
|
|
}>('/api/auth/status');
|
|
|
|
state.bootstrapped = status.bootstrapped;
|
|
state.authenticated = status.authenticated;
|
|
state.vaultState = status.vaultState ?? 'locked';
|
|
state.vaultRuntimeReady = status.vaultRuntimeReady ?? false;
|
|
state.isPanicLocked = Boolean(status.isPanicLocked);
|
|
state.defaultMobileSafeMode = status.defaultMobileSafeMode;
|
|
state.elevatedUntil = status.elevatedUntil ?? null;
|
|
state.security = status.security;
|
|
state.authRequirements = status.authRequirements;
|
|
|
|
if (!localStorage.getItem(THEME_STORAGE_KEY)) {
|
|
state.theme = status.theme;
|
|
}
|
|
applyTheme(state.theme);
|
|
|
|
const deviceSafe = initialDeviceSafeMode(status.defaultMobileSafeMode);
|
|
state.safeMode = status.authenticated ? Boolean(status.safeMode || deviceSafe) : deviceSafe;
|
|
setApiSafeMode(state.safeMode);
|
|
|
|
if (state.authenticated) {
|
|
if (deviceSafe && !status.safeMode) {
|
|
await apiFetch('/api/auth/safe-mode', {
|
|
method: 'POST',
|
|
body: { enabled: true },
|
|
});
|
|
}
|
|
await refreshOverview();
|
|
}
|
|
|
|
await renderCurrentView();
|
|
}
|
|
|
|
async function bootstrapApp(): Promise<void> {
|
|
const parsed = parseRouteFromHash();
|
|
state.route = parsed.route;
|
|
state.selectedServerId = parsed.serverId;
|
|
state.routeSegments = parsed.segments;
|
|
state.routeQuery = parsed.query;
|
|
await syncStatusAndRender();
|
|
if (state.authenticated) {
|
|
wsClient.connect();
|
|
}
|
|
}
|
|
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
applyTheme(state.theme);
|
|
|
|
registerStepUpHandler(() =>
|
|
promptStepUp(
|
|
() => state.authRequirements,
|
|
(until) => {
|
|
state.elevatedUntil = until;
|
|
updateTopBarUi();
|
|
},
|
|
),
|
|
);
|
|
registerVaultUnlockHandler(async () => {
|
|
if (state.vaultRuntimeReady && !state.isPanicLocked) {
|
|
const ok = await confirmDialog(
|
|
'dialog-confirm',
|
|
'The Vault is locked against modifications. Unlock the Vault now to proceed?',
|
|
);
|
|
if (!ok) return false;
|
|
try {
|
|
await apiFetch('/api/vault/unlock', {
|
|
method: 'POST',
|
|
body: {},
|
|
allowVaultUnlockRetry: false,
|
|
});
|
|
state.vaultState = 'unlocked';
|
|
updateTopBarUi();
|
|
return true;
|
|
} catch {
|
|
return false;
|
|
}
|
|
}
|
|
window.location.hash = '#vault';
|
|
return false;
|
|
});
|
|
registerUnauthorizedHandler(() => {
|
|
handleLocalSessionReset(false);
|
|
});
|
|
|
|
wsClient.onStatus((wsStatus) => {
|
|
const badge = document.getElementById('ws-badge')!;
|
|
badge.textContent =
|
|
wsStatus === 'online'
|
|
? '[ONLINE]'
|
|
: wsStatus === 'reconnecting'
|
|
? '[RECONNECTING...]'
|
|
: '[OFFLINE]';
|
|
badge.className = `badge ${
|
|
wsStatus === 'online'
|
|
? 'badge-ok'
|
|
: wsStatus === 'reconnecting'
|
|
? 'badge-warn'
|
|
: 'badge-err'
|
|
}`;
|
|
});
|
|
|
|
wsClient.onFrame((frame: ServerWsFrame) => {
|
|
if (frame.type === 'hello') {
|
|
state.vaultState = frame.vaultState;
|
|
if (frame.vaultRuntimeReady !== undefined) {
|
|
state.vaultRuntimeReady = frame.vaultRuntimeReady;
|
|
}
|
|
state.elevatedUntil = frame.elevatedUntil;
|
|
updateTopBarUi();
|
|
} else if (frame.type === 'vault:state') {
|
|
state.vaultState = frame.vaultState;
|
|
state.vaultRuntimeReady = frame.vaultRuntimeReady;
|
|
state.isPanicLocked = frame.isPanicLocked;
|
|
updateTopBarUi();
|
|
if (state.authenticated && (state.route === 'vault' || state.route === 'dashboard')) {
|
|
void renderCurrentView();
|
|
}
|
|
} else if (frame.type === 'security:panic-lock') {
|
|
showToast('Panic lock engaged remotely — session terminated.', 'err');
|
|
handleLocalSessionReset(true);
|
|
} else if (frame.type === 'config:updated' && state.authenticated) {
|
|
void refreshOverview().then(() => {
|
|
if (state.route === 'config' || state.route === 'dashboard') {
|
|
void renderCurrentView();
|
|
}
|
|
});
|
|
} else if (frame.type === 'metrics:tick' && state.authenticated && state.route === 'dashboard') {
|
|
getDashboardLivePatchers()?.onTick(frame);
|
|
} else if (frame.type === 'servers:state' && state.authenticated && state.route === 'dashboard') {
|
|
const needsRefresh = getDashboardLivePatchers()?.onStates(frame.states) ?? false;
|
|
if (needsRefresh) {
|
|
void renderCurrentView();
|
|
}
|
|
} else if (frame.type === 'alerts:update') {
|
|
const prevAlerts = state.activeAlertCount;
|
|
state.activeAlertCount = frame.activeCount;
|
|
updateTopBarUi();
|
|
if (state.authenticated && frame.activeCount > prevAlerts) {
|
|
showToast(`Active alerts increased to ${frame.activeCount}.`, 'warn');
|
|
}
|
|
if (state.authenticated && state.route === 'alerts') {
|
|
void renderCurrentView();
|
|
}
|
|
}
|
|
});
|
|
|
|
const openPalette = async () => {
|
|
if (!state.authenticated) return;
|
|
const { openCommandPalette } = await import('./command-palette.js');
|
|
openCommandPalette({
|
|
state,
|
|
navigate: (hash) => {
|
|
window.location.hash = hash;
|
|
},
|
|
toggleSafeMode,
|
|
lockVault: lockVaultAction,
|
|
triggerPanic: triggerPanicLock,
|
|
});
|
|
};
|
|
|
|
document.getElementById('cmd-palette-btn')!.addEventListener('click', () => {
|
|
void openPalette();
|
|
});
|
|
|
|
document.getElementById('safe-toggle-btn')!.addEventListener('click', () => {
|
|
void toggleSafeMode();
|
|
});
|
|
|
|
document.addEventListener('keydown', (ev) => {
|
|
const active = document.activeElement;
|
|
if (active && active.closest('.xterm')) return;
|
|
|
|
if ((ev.ctrlKey || ev.metaKey || ev.altKey) && ev.key.toLowerCase() === 'k') {
|
|
if (!state.authenticated) return;
|
|
ev.preventDefault();
|
|
void openPalette();
|
|
return;
|
|
}
|
|
|
|
if ((ev.ctrlKey || ev.metaKey) && ev.key.toLowerCase() === 's') {
|
|
if (!state.authenticated || document.querySelector('dialog[open]')) return;
|
|
ev.preventDefault();
|
|
window.dispatchEvent(new CustomEvent('gcoord:save'));
|
|
}
|
|
});
|
|
|
|
window.addEventListener('storage', (ev) => {
|
|
if (ev.key === THEME_STORAGE_KEY && ev.newValue) {
|
|
state.theme = ev.newValue;
|
|
document.documentElement.setAttribute('data-theme', ev.newValue);
|
|
updateTopBarUi();
|
|
} else if (ev.key === SAFE_MODE_STORAGE_KEY && ev.newValue !== null) {
|
|
const next = ev.newValue === '1';
|
|
if (next !== state.safeMode) {
|
|
state.safeMode = next;
|
|
setApiSafeMode(next);
|
|
if (next) state.elevatedUntil = null;
|
|
wsClient.send({ type: 'safe-mode', enabled: next });
|
|
updateTopBarUi();
|
|
}
|
|
}
|
|
});
|
|
|
|
document.getElementById('theme-select')!.addEventListener('change', (ev) => {
|
|
const theme = (ev.target as HTMLSelectElement).value;
|
|
state.theme = theme;
|
|
applyTheme(theme);
|
|
updateTopBarUi();
|
|
});
|
|
|
|
document.getElementById('panic-btn')!.addEventListener('click', () => {
|
|
void triggerPanicLock();
|
|
});
|
|
|
|
document.getElementById('logout-btn')!.addEventListener('click', async () => {
|
|
try {
|
|
await apiFetch('/api/auth/logout', { method: 'POST' });
|
|
} catch {
|
|
// Proceed with local cleanup even if session already expired
|
|
}
|
|
handleLocalSessionReset(false);
|
|
});
|
|
|
|
window.addEventListener('hashchange', () => {
|
|
const parsed = parseRouteFromHash();
|
|
state.route = parsed.route;
|
|
state.selectedServerId = parsed.serverId;
|
|
state.routeSegments = parsed.segments;
|
|
state.routeQuery = parsed.query;
|
|
void renderCurrentView();
|
|
});
|
|
|
|
window.setInterval(() => {
|
|
if (state.elevatedUntil) updateTopBarUi();
|
|
}, 1000);
|
|
|
|
void bootstrapApp();
|
|
});
|