diff --git a/app/(app)/machines/[machineId]/MachineDetailClient.tsx b/app/(app)/machines/[machineId]/MachineDetailClient.tsx index d4707f6..1aa4e49 100644 --- a/app/(app)/machines/[machineId]/MachineDetailClient.tsx +++ b/app/(app)/machines/[machineId]/MachineDetailClient.tsx @@ -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(() => {

{machine?.name ?? "Machine"}

- + {statusLabel} diff --git a/app/(app)/machines/page.tsx b/app/(app)/machines/page.tsx index b2974a8..4b308ab 100644 --- a/app/(app)/machines/page.tsx +++ b/app/(app)/machines/page.tsx @@ -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() { diff --git a/app/(app)/overview/page.tsx b/app/(app)/overview/page.tsx index 59ae519..9a70c95 100644 --- a/app/(app)/overview/page.tsx +++ b/app/(app)/overview/page.tsx @@ -56,7 +56,7 @@ type CycleRow = { ideal: number | null; }; -const OFFLINE_MS = 15000; +const OFFLINE_MS = 30000; const EVENT_WINDOW_SEC = 1800; const MAX_EVENT_MACHINES = 6; const TOL = 0.10; @@ -74,6 +74,12 @@ function isOffline(ts?: string) { return Date.now() - new Date(ts).getTime() > OFFLINE_MS; } +function normalizeStatus(status?: string) { + const s = (status ?? "").toUpperCase(); + if (s === "ONLINE") return "RUN"; + return s; +} + function fmtPct(v?: number | null) { if (v === null || v === undefined || Number.isNaN(v)) return "--"; return `${v.toFixed(1)}%`; @@ -273,7 +279,7 @@ export default function OverviewPage() { const offline = isOffline(hb?.ts); if (!offline) online += 1; - const status = (hb?.status ?? "").toUpperCase(); + const status = normalizeStatus(hb?.status); if (!offline) { if (status === "RUN") running += 1; else if (status === "IDLE") idle += 1; diff --git a/app/(app)/reports/page.tsx b/app/(app)/reports/page.tsx index b69474d..53706d8 100644 --- a/app/(app)/reports/page.tsx +++ b/app/(app)/reports/page.tsx @@ -139,6 +139,22 @@ function CycleTooltip({ active, payload }: any) { ); } +function DowntimeTooltip({ active, payload }: any) { + if (!active || !payload?.length) return null; + const row = payload[0]?.payload ?? {}; + const label = row.name ?? payload[0]?.name ?? ""; + const value = row.value ?? payload[0]?.value ?? 0; + + return ( +
+
{label}
+
+ Downtime: {Number(value)} min +
+
+ ); +} + function buildCsv(report: ReportPayload) { const rows = new Map>(); const addSeries = (series: ReportTrendPoint[], key: string) => { @@ -674,10 +690,7 @@ export default function ReportsPage() { - [`${Number(val)} min`, "Downtime"]} - /> + } /> {downtimeSeries.map((row, idx) => (