Repository Public
1/**2 * =============================================================================3 * SP BOUCHER | INFRASTRUCTURE & AUTOMATION4 * ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project : MacLustr Command Center (MCC)8 * File : apps/web/src/features/nodes/parts.tsx9 * Module : features10 * Repository : https://git.spboucher.ai/maclustr-command-center11 * Project Website : https://clustr.spboucher.ai12 * Created : 2026-11-1813 * Last Modified : 2026-11-1814 *15 * Author : Simon-Pierre Boucher16 * Position : Professor of Finance17 * Institution : Université du Québec en Outaouais (UQO)18 * Organization : SP Boucher19 * Website : https://spboucher.ai20 * Git : https://git.spboucher.ai21 *22 * Preferred Contact: admin@spboucher.ai23 * Technical Contact: dev@spboucher.ai24 * Security/Admin : admin@spboucher.ai25 *26 * Copyright (c) 202627 * Simon-Pierre Boucher28 * All rights reserved where applicable. This file is governed by the29 * applicable project license, copyright notices and relevant law.30 * Existing third-party rights and notices remain unaffected.31 *32 * License : None specified (no license file in this repository)33 *34 * Do not embed credentials, private keys, access tokens,35 * certificates or confidential personal information.36 *37 * =============================================================================38 * END OF SP BOUCHER SOURCE HEADER39 * =============================================================================40 */4142"use client";43import type { Schemas } from "@/api/client";44import { useI18n } from "@/i18n";45import { Badge, FreshnessBadge, Meter, Unmeasured } from "@/ui";4647type Node = Schemas["Node"];4849/** Freshness (icon + text) and, when set, the maintenance flag — never colour alone. */50export function NodeState({ node, subtle }: { node: Pick<Node, "freshness" | "maintenance" | "retired_at">; subtle?: boolean }) {51 const { t } = useI18n();52 return (53 <span className="nodes-state">54 <FreshnessBadge freshness={node.freshness} subtle={subtle ?? false} />55 {node.maintenance ? <Badge tone="maintenance">{t("nodes.state.maintenance")}</Badge> : null}56 {node.retired_at ? <Badge tone="offline" icon="offline">{t("nodes.state.retired")}</Badge> : null}57 </span>58 );59}6061/** Utilisation from the node headline: meter with its value, or the explicit "not observed" state. */62export function HeadlinePct({ value, label }: { value: number | undefined; label: string }) {63 const { fmt } = useI18n();64 if (value === undefined) return <Unmeasured availability="not_observed" />;65 return <Meter value={value} label={label} text={fmt.percent(value)} />;66}6768export function LastContact({ at }: { at: string | undefined }) {69 const { t, fmt } = useI18n();70 if (!at) return <span className="faint">{t("nodes.neverSeen")}</span>;71 return <time dateTime={at} title={fmt.dateTime(at, { seconds: true })} className="num nowrap">{fmt.relative(at)}</time>;72}73