pending invite link, the rest is finished

This commit is contained in:
mdares
2026-01-03 21:56:26 +00:00
parent a0ed517047
commit b6eed8b6db
4 changed files with 45 additions and 12 deletions

View File

@@ -170,7 +170,13 @@ export default function MachineDetailClient() {
function isOffline(ts?: string) {
if (!ts) return true;
return Date.now() - new Date(ts).getTime() > 15000;
return Date.now() - new Date(ts).getTime() > 30000;
}
function normalizeStatus(status?: string) {
const s = (status ?? "").toUpperCase();
if (s === "ONLINE") return "RUN";
return s;
}
function statusBadgeClass(status?: string, offline?: boolean) {
@@ -192,7 +198,8 @@ export default function MachineDetailClient() {
const hb = machine?.latestHeartbeat ?? null;
const kpi = machine?.latestKpi ?? null;
const offline = useMemo(() => isOffline(hb?.ts), [hb?.ts]);
const statusLabel = offline ? "OFFLINE" : (hb?.status ?? "UNKNOWN");
const normalizedStatus = normalizeStatus(hb?.status);
const statusLabel = offline ? "OFFLINE" : (normalizedStatus || "UNKNOWN");
const cycleTarget = (machine as any)?.effectiveCycleTime ?? kpi?.cycleTime ?? null;
const ActiveRing = (props: any) => {
@@ -574,7 +581,7 @@ const timeline = useMemo(() => {
<h1 className="truncate text-2xl font-semibold text-white">
{machine?.name ?? "Machine"}
</h1>
<span className={`rounded-full px-3 py-1 text-xs ${statusBadgeClass(hb?.status, offline)}`}>
<span className={`rounded-full px-3 py-1 text-xs ${statusBadgeClass(normalizedStatus, offline)}`}>
{statusLabel}
</span>
</div>

View File

@@ -26,7 +26,13 @@ function secondsAgo(ts?: string) {
function isOffline(ts?: string) {
if (!ts) return true;
return Date.now() - new Date(ts).getTime() > 15000; // 15s threshold
return Date.now() - new Date(ts).getTime() > 30000; // 30s threshold
}
function normalizeStatus(status?: string) {
const s = (status ?? "").toUpperCase();
if (s === "ONLINE") return "RUN";
return s;
}
function badgeClass(status?: string, offline?: boolean) {
@@ -261,7 +267,8 @@ export default function MachinesPage() {
{(!loading ? machines : []).map((m) => {
const hb = m.latestHeartbeat;
const offline = isOffline(hb?.ts);
const statusLabel = offline ? "OFFLINE" : hb?.status ?? "UNKNOWN";
const normalizedStatus = normalizeStatus(hb?.status);
const statusLabel = offline ? "OFFLINE" : normalizedStatus || "UNKNOWN";
const lastSeen = secondsAgo(hb?.ts);
return (
@@ -280,7 +287,7 @@ export default function MachinesPage() {
<span
className={`shrink-0 rounded-full px-3 py-1 text-xs ${badgeClass(
hb?.status,
normalizedStatus,
offline
)}`}
>