hyperhive/frontend/packages/dashboard/src/home.js
iris 986b3df9b0 feat(frontend): add forge link tile to H0M3 hub
H0M3 had tiles for every operator surface except the forge. Add a
Forge tile that links straight to the hive-forge web UI. It mirrors
the Matrix tile's gating: hidden by default, revealed by home.js only
when state.forge_present is true, with the href filled from
state.forge_public_url (the gateway-served vhost) or the direct :3000
port fallback — the same precedence the dashboard uses for forge links.
Operators without a forge never see a dead link.
2026-06-10 13:22:24 +02:00

50 lines
1.6 KiB
JavaScript

// H0M3 page script. The page is static markup; this only does
// a few small things off a single `/api/state` read:
// 1. reveal the Matrix tile when the matrix GUI is enabled (same
// gating as the dashboard's M4TR1X tab — no dead link otherwise);
// 2. fill the swarm/hive identity line when configured;
// 3. render the shared server-warnings banner (top of every page).
// No SSE — a portal doesn't need live updates.
import { renderServerWarnings } from './common.js';
const $ = (id) => document.getElementById(id);
async function init() {
let state;
try {
const resp = await fetch('/api/state');
if (!resp.ok) return;
state = await resp.json();
} catch {
return; // best-effort: the tiles still work without it
}
renderServerWarnings(state.server_warnings);
if (state.matrix_gui_enabled) {
const tile = $('home-tile-matrix');
if (tile) tile.hidden = false;
}
// Forge tile: reveal + point at the live forge only when the
// hive-forge container is up. Prefer the gateway-served public URL
// (set when forge.behindGateway=true), fall back to the direct :3000
// port — same precedence the dashboard uses for forge links.
if (state.forge_present) {
const tile = $('home-tile-forge');
if (tile) {
tile.href = state.forge_public_url || `http://${location.hostname}:3000`;
tile.hidden = false;
}
}
const ident = $('hive-identity');
if (ident && (state.swarm_name || state.hive_name)) {
const parts = [state.swarm_name, state.hive_name].filter(Boolean);
ident.textContent = parts.join(' / ');
ident.hidden = false;
}
}
init();