Update ops handoff and dashboard last seen
This commit is contained in:
@ -233,6 +233,9 @@
|
||||
|
||||
function lastSeen(value) {
|
||||
if (!value) return "No heartbeat";
|
||||
if (typeof value === "object") {
|
||||
return lastSeen(value.received_at || value.timestamp || value.created_at || value.updated_at);
|
||||
}
|
||||
const date = new Date(value);
|
||||
if (Number.isNaN(date.getTime())) return value;
|
||||
const minutes = Math.floor((Date.now() - date.getTime()) / 60000);
|
||||
@ -242,6 +245,13 @@
|
||||
return `${Math.floor(minutes / 1440)}d ago`;
|
||||
}
|
||||
|
||||
function deviceLastSeen(device) {
|
||||
return device?.latest_heartbeat?.received_at ||
|
||||
device?.latest_heartbeat?.timestamp ||
|
||||
device?.last_seen_at ||
|
||||
null;
|
||||
}
|
||||
|
||||
function statusMeta(value) {
|
||||
const status = normalize(value);
|
||||
if (status === "online") return { label: "Online", badge: "bg-emerald-50 text-emerald-700 border-emerald-200", dot: "bg-emerald-500" };
|
||||
@ -342,7 +352,7 @@
|
||||
</div>
|
||||
<div class="mt-1 text-xs text-slate-500">Health ${healthLabel(device)}</div>
|
||||
</td>
|
||||
<td class="px-5 py-4 text-right text-slate-600">${lastSeen(device.latest_heartbeat)}</td>
|
||||
<td class="px-5 py-4 text-right text-slate-600">${lastSeen(deviceLastSeen(device))}</td>
|
||||
<td class="px-5 py-4 text-right">
|
||||
<a class="inline-flex items-center gap-1 rounded-lg border border-slate-200 px-3 py-1.5 text-xs font-bold text-slate-700 hover:bg-slate-50" href="${detailUrl}">
|
||||
Detail <span class="material-symbols-outlined text-[16px]">open_in_new</span>
|
||||
|
||||
Reference in New Issue
Block a user