set_status: add status_set_at timestamp (mtime of status file)
This commit is contained in:
parent
fe2933b213
commit
8e8e8a771f
7 changed files with 75 additions and 14 deletions
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
// ─── helpers ────────────────────────────────────────────────────────────
|
||||
const $ = (id) => document.getElementById(id);
|
||||
const fmtAgeSecs = (s) => s < 60 ? `${s}s` : s < 3600 ? `${Math.floor(s/60)}m`
|
||||
: s < 86400 ? `${Math.floor(s/3600)}h` : `${Math.floor(s/86400)}d`;
|
||||
const esc = (s) => String(s).replace(/[&<>"]/g, (c) =>
|
||||
({ '&':'&', '<':'<', '>':'>', '"':'"' }[c])
|
||||
);
|
||||
|
|
@ -729,9 +731,16 @@
|
|||
|
||||
// ── agent status text ─────────────────────────────────────────
|
||||
if (c.status_text) {
|
||||
body.append(el('div', { class: 'agent-status', title: 'agent self-reported status' },
|
||||
const nowUnix = Math.floor(Date.now() / 1000);
|
||||
const ageStr = c.status_set_at != null
|
||||
? ` (set ${fmtAgeSecs(nowUnix - c.status_set_at)} ago)` : '';
|
||||
body.append(el('div', {
|
||||
class: 'agent-status',
|
||||
title: `agent self-reported status${ageStr}`,
|
||||
},
|
||||
el('span', { class: 'status-icon' }, '◈ '),
|
||||
c.status_text,
|
||||
el('span', { class: 'status-age' }, ageStr),
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -216,6 +216,7 @@ a:hover {
|
|||
text-overflow: ellipsis;
|
||||
}
|
||||
.agent-status .status-icon { opacity: 0.65; }
|
||||
.agent-status .status-age { opacity: 0.5; font-size: 0.9em; margin-left: 0.2em; }
|
||||
|
||||
.container-row.tombstone {
|
||||
border-style: dashed;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue