swarm-ui: wire hive overview to the real status aggregate
App.tsx now fetches GET /api/hives/status (the swarm-controller aggregate: one row per roster hive, freshness derived at read time from the status bucket) instead of GET /api/hives + a static 'configured' chip. Renders fresh/stale/never_reported/unknown as StatusChip tones with a relative age, per the placeholder comment that was already waiting on this endpoint to exist. Adds a small local fmtAgo helper (src/util.ts) mirroring the dashboard package's near-identical formatter — not worth sharing across a vanilla-JS and a Preact/TS call site.
This commit is contained in:
parent
4f8b78a4d4
commit
2460d7fec7
2 changed files with 62 additions and 22 deletions
15
frontend/packages/swarm-ui/src/util.ts
Normal file
15
frontend/packages/swarm-ui/src/util.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
// Small pure render helpers shared across swarm-ui pages. Not folded
|
||||
// into `@hive/shared` — these are swarm-ui's own formatting choices
|
||||
// (compact, one unit deep), not a cross-package contract, and the
|
||||
// dashboard package already has its own near-identical `fmtAgo` in
|
||||
// `util.js` for the same reason: two small vanilla-vs-Preact call
|
||||
// sites don't justify a shared abstraction over a five-line function.
|
||||
|
||||
// Relative age in whole seconds, coarsened to one unit ("5m ago").
|
||||
export function fmtAgo(ageSeconds: number): string {
|
||||
const age = Math.max(0, Math.floor(ageSeconds));
|
||||
if (age < 60) return age + 's ago';
|
||||
if (age < 3600) return Math.floor(age / 60) + 'm ago';
|
||||
if (age < 86400) return Math.floor(age / 3600) + 'h ago';
|
||||
return Math.floor(age / 86400) + 'd ago';
|
||||
}
|
||||
Loading…
Reference in a new issue