feat(dashboard): phase A widget clarity — threshold colours, host links, tooltips
Milestone 72 phase A (clarity wins, no schema change): - Add shared metric_style() macro in _macros.html: colours a numeric metric amber (>=warn) / red (>=crit) on the value ITSELF, not just the status dot. Defaults 80/90 for percentage gauges; load /core uses warn 80 / crit 100. Applied to CPU/mem/disk across host_agent panel + fleet widget + the unified hosts-overview widget. - Link every host reference to the host hub (/hosts/<id>) in ping, dns, hosts-overview, host_agent fleet, and uptime widgets; status widget entries link to their own detail_url. All guarded on session.user_id so the public share view degrades to plain text (the bare href carries no share token). - Fix truncation: title= tooltips on all names that ellipsis, plus a hover underline affordance on the now-clickable ping-name links. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
{# Per-host agent panel — embedded into /hosts/<id> via HTMX. Self-contained. #}
|
{# Per-host agent panel — embedded into /hosts/<id> via HTMX. Self-contained. #}
|
||||||
|
{% from "_macros.html" import metric_style %}
|
||||||
{% set scope = "steward:target:" ~ target.id if target else "" %}
|
{% set scope = "steward:target:" ~ target.id if target else "" %}
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div style="display:flex;align-items:baseline;justify-content:space-between;margin-bottom:0.75rem;gap:1rem;flex-wrap:wrap;">
|
<div style="display:flex;align-items:baseline;justify-content:space-between;margin-bottom:0.75rem;gap:1rem;flex-wrap:wrap;">
|
||||||
@@ -21,19 +22,20 @@
|
|||||||
<div style="display:flex;gap:1.5rem;flex-wrap:wrap;margin-bottom:0.6rem;">
|
<div style="display:flex;gap:1.5rem;flex-wrap:wrap;margin-bottom:0.6rem;">
|
||||||
<div title="Average CPU utilization across all cores">
|
<div title="Average CPU utilization across all cores">
|
||||||
<div style="{{ lbl }}">CPU</div>
|
<div style="{{ lbl }}">CPU</div>
|
||||||
<div style="font-weight:600;">{{ '%.0f%%'|format(cpu) if cpu is not none else '—' }}</div>
|
<div style="font-weight:600;{{ metric_style(cpu) }}">{{ '%.0f%%'|format(cpu) if cpu is not none else '—' }}</div>
|
||||||
{{ sparks.cpu | safe }}</div>
|
{{ sparks.cpu | safe }}</div>
|
||||||
<div title="RAM in use (total minus available; cache/buffers count as free)">
|
<div title="RAM in use (total minus available; cache/buffers count as free)">
|
||||||
<div style="{{ lbl }}">Memory</div>
|
<div style="{{ lbl }}">Memory</div>
|
||||||
<div style="font-weight:600;">{{ '%.0f%%'|format(mem) if mem is not none else '—' }}</div>
|
<div style="font-weight:600;{{ metric_style(mem) }}">{{ '%.0f%%'|format(mem) if mem is not none else '—' }}</div>
|
||||||
{{ sparks.mem | safe }}</div>
|
{{ sparks.mem | safe }}</div>
|
||||||
<div title="Root filesystem (/) usage — see Full metrics for every mount">
|
<div title="Root filesystem (/) usage — see Full metrics for every mount">
|
||||||
<div style="{{ lbl }}">Disk /</div>
|
<div style="{{ lbl }}">Disk /</div>
|
||||||
<div style="font-weight:600;">{{ '%.0f%%'|format(disk_root) if disk_root is not none else '—' }}</div>
|
<div style="font-weight:600;{{ metric_style(disk_root) }}">{{ '%.0f%%'|format(disk_root) if disk_root is not none else '—' }}</div>
|
||||||
{{ sparks.disk | safe }}</div>
|
{{ sparks.disk | safe }}</div>
|
||||||
|
{# Load /core: 100% = run queue matches CPU capacity, so warn 80 / crit 100. #}
|
||||||
<div title="1-minute load average ÷ {{ cores or '?' }} CPU cores (100% = run queue matches capacity). Raw 1m load: {{ '%.2f'|format(load1) if load1 is not none else '—' }}.">
|
<div title="1-minute load average ÷ {{ cores or '?' }} CPU cores (100% = run queue matches capacity). Raw 1m load: {{ '%.2f'|format(load1) if load1 is not none else '—' }}.">
|
||||||
<div style="{{ lbl }}">Load /core</div>
|
<div style="{{ lbl }}">Load /core</div>
|
||||||
<div style="font-weight:600;">{{ '%d%%'|format(load_per_core) if load_per_core is not none else ('%.2f'|format(load1) if load1 is not none else '—') }}</div>
|
<div style="font-weight:600;{{ metric_style(load_per_core, warn=80, crit=100) }}">{{ '%d%%'|format(load_per_core) if load_per_core is not none else ('%.2f'|format(load1) if load1 is not none else '—') }}</div>
|
||||||
{{ sparks.load | safe }}</div>
|
{{ sparks.load | safe }}</div>
|
||||||
</div>
|
</div>
|
||||||
{% if psi.cpu is not none or psi.mem is not none or psi.io is not none %}
|
{% if psi.cpu is not none or psi.mem is not none or psi.io is not none %}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
{# host_agent widget — fleet glance, flex rows (no header wrap) #}
|
{# host_agent widget — fleet glance, flex rows (no header wrap) #}
|
||||||
|
{% from "_macros.html" import metric_style %}
|
||||||
{% if rows %}
|
{% if rows %}
|
||||||
<div style="display:grid;gap:0.1rem;">
|
<div style="display:grid;gap:0.1rem;">
|
||||||
{% for r in rows %}
|
{% for r in rows %}
|
||||||
@@ -6,19 +7,21 @@
|
|||||||
<div style="display:flex;align-items:center;gap:0.6rem;font-size:0.82rem;padding:0.3rem 0;border-bottom:1px solid var(--border);">
|
<div style="display:flex;align-items:center;gap:0.6rem;font-size:0.82rem;padding:0.3rem 0;border-bottom:1px solid var(--border);">
|
||||||
<span class="dot {% if stale %}dot-dim{% elif (r.cpu_pct or 0) >= 90 or (r.mem_used_pct or 0) >= 90 or (r.disk_worst or 0) >= 90 %}dot-warn{% else %}dot-up{% endif %}"
|
<span class="dot {% if stale %}dot-dim{% elif (r.cpu_pct or 0) >= 90 or (r.mem_used_pct or 0) >= 90 or (r.disk_worst or 0) >= 90 %}dot-warn{% else %}dot-up{% endif %}"
|
||||||
title="{% if stale %}stale / no recent data{% else %}warns at CPU/memory ≥90% or any disk mount ≥90% (the 'disk /' figure shows root only){% endif %}"></span>
|
title="{% if stale %}stale / no recent data{% else %}warns at CPU/memory ≥90% or any disk mount ≥90% (the 'disk /' figure shows root only){% endif %}"></span>
|
||||||
<a href="/hosts/{{ r.host.id }}"
|
{% set name_style = "flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-weight:500;" %}
|
||||||
style="flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-weight:500;">
|
{% if session.user_id %}
|
||||||
{{ r.host.name }}
|
<a href="/hosts/{{ r.host.id }}" title="{{ r.host.name }}" style="{{ name_style }}">{{ r.host.name }}</a>
|
||||||
</a>
|
{% else %}
|
||||||
|
<span title="{{ r.host.name }}" style="{{ name_style }}">{{ r.host.name }}</span>
|
||||||
|
{% endif %}
|
||||||
<span style="display:flex;gap:0.75rem;font-variant-numeric:tabular-nums;color:var(--text-muted);font-size:0.75rem;flex-shrink:0;">
|
<span style="display:flex;gap:0.75rem;font-variant-numeric:tabular-nums;color:var(--text-muted);font-size:0.75rem;flex-shrink:0;">
|
||||||
{% if r.cpu_pct is not none %}
|
{% if r.cpu_pct is not none %}
|
||||||
<span title="CPU"><span style="color:var(--text-dim);">cpu</span> {{ "%.0f"|format(r.cpu_pct) }}%</span>
|
<span title="CPU" style="{{ metric_style(r.cpu_pct) }}"><span style="color:var(--text-dim);">cpu</span> {{ "%.0f"|format(r.cpu_pct) }}%</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if r.mem_used_pct is not none %}
|
{% if r.mem_used_pct is not none %}
|
||||||
<span title="Memory"><span style="color:var(--text-dim);">mem</span> {{ "%.0f"|format(r.mem_used_pct) }}%</span>
|
<span title="Memory" style="{{ metric_style(r.mem_used_pct) }}"><span style="color:var(--text-dim);">mem</span> {{ "%.0f"|format(r.mem_used_pct) }}%</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if r.disk_root is not none %}
|
{% if r.disk_root is not none %}
|
||||||
<span title="Root filesystem (/) usage"><span style="color:var(--text-dim);">disk /</span> {{ "%.0f"|format(r.disk_root) }}%</span>
|
<span title="Root filesystem (/) usage" style="{{ metric_style(r.disk_root) }}"><span style="color:var(--text-dim);">disk /</span> {{ "%.0f"|format(r.disk_root) }}%</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if r.load_1m is not none %}
|
{% if r.load_1m is not none %}
|
||||||
<span title="Load average 1m"><span style="color:var(--text-dim);">load</span> {{ "%.2f"|format(r.load_1m) }}</span>
|
<span title="Load average 1m"><span style="color:var(--text-dim);">load</span> {{ "%.2f"|format(r.load_1m) }}</span>
|
||||||
|
|||||||
@@ -16,3 +16,16 @@
|
|||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
</nav>
|
</nav>
|
||||||
{%- endmacro %}
|
{%- endmacro %}
|
||||||
|
|
||||||
|
{# Threshold emphasis for a numeric metric (CPU/mem/disk %, etc).
|
||||||
|
Returns an inline-style fragment to drop into a span's style="": amber +
|
||||||
|
semibold at >= warn, red + bold at >= crit, empty (inherit) when the value
|
||||||
|
is normal or None. This makes the FAILING METRIC ITSELF stand out — not just
|
||||||
|
the status dot. Defaults suit percentage gauges (warn 80 / crit 90); pass
|
||||||
|
explicit warn/crit for other scales. Keep thresholds here so they live in one
|
||||||
|
place rather than hardcoded per template. #}
|
||||||
|
{% macro metric_style(value, warn=80, crit=90) -%}
|
||||||
|
{%- if value is not none and value >= crit -%}color:var(--red);font-weight:700;
|
||||||
|
{%- elif value is not none and value >= warn -%}color:var(--yellow);font-weight:600;
|
||||||
|
{%- endif -%}
|
||||||
|
{%- endmacro %}
|
||||||
|
|||||||
@@ -164,6 +164,7 @@ textarea { resize: vertical; }
|
|||||||
.ping-row:last-child { border-bottom:none; }
|
.ping-row:last-child { border-bottom:none; }
|
||||||
.ping-meta { min-width:120px; max-width:180px; flex-shrink:1; overflow:hidden; }
|
.ping-meta { min-width:120px; max-width:180px; flex-shrink:1; overflow:hidden; }
|
||||||
.ping-name { font-size:0.875rem; font-weight:500; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; display:block; }
|
.ping-name { font-size:0.875rem; font-weight:500; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; display:block; }
|
||||||
|
a.ping-name:hover { text-decoration:underline; }
|
||||||
.ping-addr { display:block; color:var(--text-muted); font-size:0.75rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
|
.ping-addr { display:block; color:var(--text-muted); font-size:0.75rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
|
||||||
.ping-pills { display:flex; gap:2px; flex:1; min-width:0; overflow:hidden; align-items:center; }
|
.ping-pills { display:flex; gap:2px; flex:1; min-width:0; overflow:hidden; align-items:center; }
|
||||||
.pill { display:inline-block; width:7px; height:22px; border-radius:2px; cursor:default; transition:opacity .1s; }
|
.pill { display:inline-block; width:7px; height:22px; border-radius:2px; cursor:default; transition:opacity .1s; }
|
||||||
|
|||||||
@@ -3,7 +3,13 @@
|
|||||||
{% set d = latest.get(host.id) %}
|
{% set d = latest.get(host.id) %}
|
||||||
<div class="ping-row">
|
<div class="ping-row">
|
||||||
<div class="ping-meta">
|
<div class="ping-meta">
|
||||||
<span class="ping-name">{{ host.name }}</span>
|
{# Link to the host hub for logged-in users; plain text on the public share view (no auth, no token on the href). #}
|
||||||
|
{% if session.user_id %}
|
||||||
|
<a class="ping-name" href="/hosts/{{ host.id }}" title="{{ host.name }}"
|
||||||
|
style="color:inherit;text-decoration:none;">{{ host.name }}</a>
|
||||||
|
{% else %}
|
||||||
|
<span class="ping-name" title="{{ host.name }}">{{ host.name }}</span>
|
||||||
|
{% endif %}
|
||||||
<span class="ping-addr">{{ host.address }}</span>
|
<span class="ping-addr">{{ host.address }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div style="flex:1;">
|
<div style="flex:1;">
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
{# Unified Hosts widget — monitor status + agent glance per host, links to the hub. #}
|
{# Unified Hosts widget — monitor status + agent glance per host, links to the hub. #}
|
||||||
|
{% from "_macros.html" import metric_style %}
|
||||||
{% if hosts %}
|
{% if hosts %}
|
||||||
<div style="display:grid;gap:0.1rem;">
|
<div style="display:grid;gap:0.1rem;">
|
||||||
{% for host in hosts %}
|
{% for host in hosts %}
|
||||||
@@ -10,10 +11,12 @@
|
|||||||
<div style="display:flex;align-items:center;gap:0.6rem;font-size:0.82rem;padding:0.3rem 0;border-bottom:1px solid var(--border);">
|
<div style="display:flex;align-items:center;gap:0.6rem;font-size:0.82rem;padding:0.3rem 0;border-bottom:1px solid var(--border);">
|
||||||
<span class="dot {% if down %}dot-down{% elif host.ping_enabled and ping %}dot-up{% else %}dot-dim{% endif %}"
|
<span class="dot {% if down %}dot-down{% elif host.ping_enabled and ping %}dot-up{% else %}dot-dim{% endif %}"
|
||||||
title="{% if not host.ping_enabled %}ping off{% elif ping %}{{ ping.status.value }}{% else %}no data{% endif %}"></span>
|
title="{% if not host.ping_enabled %}ping off{% elif ping %}{{ ping.status.value }}{% else %}no data{% endif %}"></span>
|
||||||
<a href="/hosts/{{ host.id }}"
|
{% set name_style = "flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-weight:500;" %}
|
||||||
style="flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-weight:500;">
|
{% if session.user_id %}
|
||||||
{{ host.name }}
|
<a href="/hosts/{{ host.id }}" title="{{ host.name }}" style="{{ name_style }}">{{ host.name }}</a>
|
||||||
</a>
|
{% else %}
|
||||||
|
<span title="{{ host.name }}" style="{{ name_style }}">{{ host.name }}</span>
|
||||||
|
{% endif %}
|
||||||
<span style="display:flex;gap:0.75rem;font-variant-numeric:tabular-nums;color:var(--text-muted);font-size:0.75rem;flex-shrink:0;">
|
<span style="display:flex;gap:0.75rem;font-variant-numeric:tabular-nums;color:var(--text-muted);font-size:0.75rem;flex-shrink:0;">
|
||||||
{# Monitors #}
|
{# Monitors #}
|
||||||
{% if host.ping_enabled and ping and ping.response_time_ms is not none %}
|
{% if host.ping_enabled and ping and ping.response_time_ms is not none %}
|
||||||
@@ -22,11 +25,11 @@
|
|||||||
{% if ut.get('24h') is not none %}
|
{% if ut.get('24h') is not none %}
|
||||||
<span title="Uptime 24h"><span style="color:var(--text-dim);">24h</span> {{ "%.1f"|format(ut['24h']) }}%</span>
|
<span title="Uptime 24h"><span style="color:var(--text-dim);">24h</span> {{ "%.1f"|format(ut['24h']) }}%</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{# Agent glance #}
|
{# Agent glance — failing metric coloured amber/red (≥80/≥90) #}
|
||||||
{% if a %}
|
{% if a %}
|
||||||
{% if a.get('cpu_pct') is not none %}<span title="CPU"><span style="color:var(--text-dim);">cpu</span> {{ "%.0f"|format(a.cpu_pct) }}%</span>{% endif %}
|
{% if a.get('cpu_pct') is not none %}<span title="CPU" style="{{ metric_style(a.cpu_pct) }}"><span style="color:var(--text-dim);">cpu</span> {{ "%.0f"|format(a.cpu_pct) }}%</span>{% endif %}
|
||||||
{% if a.get('mem_used_pct') is not none %}<span title="Memory"><span style="color:var(--text-dim);">mem</span> {{ "%.0f"|format(a.mem_used_pct) }}%</span>{% endif %}
|
{% if a.get('mem_used_pct') is not none %}<span title="Memory" style="{{ metric_style(a.mem_used_pct) }}"><span style="color:var(--text-dim);">mem</span> {{ "%.0f"|format(a.mem_used_pct) }}%</span>{% endif %}
|
||||||
{% if a.get('disk_root') is not none %}<span title="Root filesystem (/)"><span style="color:var(--text-dim);">disk /</span> {{ "%.0f"|format(a.disk_root) }}%</span>{% endif %}
|
{% if a.get('disk_root') is not none %}<span title="Root filesystem (/)" style="{{ metric_style(a.disk_root) }}"><span style="color:var(--text-dim);">disk /</span> {{ "%.0f"|format(a.disk_root) }}%</span>{% endif %}
|
||||||
{% if not a.fresh %}<span title="Agent data is stale" style="color:var(--yellow);">stale</span>{% endif %}
|
{% if not a.fresh %}<span title="Agent data is stale" style="color:var(--yellow);">stale</span>{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<span style="color:var(--text-dim);" title="No agent reporting">no agent</span>
|
<span style="color:var(--text-dim);" title="No agent reporting">no agent</span>
|
||||||
|
|||||||
@@ -15,7 +15,12 @@
|
|||||||
{% for host in hosts %}
|
{% for host in hosts %}
|
||||||
{% set ut = uptime.get(host.id, {}) %}
|
{% set ut = uptime.get(host.id, {}) %}
|
||||||
<div style="display:grid;grid-template-columns:1fr 52px 52px 52px;gap:0.35rem;align-items:center;padding:0.15rem 0;font-size:0.82rem;">
|
<div style="display:grid;grid-template-columns:1fr 52px 52px 52px;gap:0.35rem;align-items:center;padding:0.15rem 0;font-size:0.82rem;">
|
||||||
<span style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">{{ host.name }}</span>
|
{% if session.user_id %}
|
||||||
|
<a href="/hosts/{{ host.id }}" title="{{ host.name }}"
|
||||||
|
style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:inherit;text-decoration:none;">{{ host.name }}</a>
|
||||||
|
{% else %}
|
||||||
|
<span style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;" title="{{ host.name }}">{{ host.name }}</span>
|
||||||
|
{% endif %}
|
||||||
{% for window in ["24h", "7d", "30d"] %}
|
{% for window in ["24h", "7d", "30d"] %}
|
||||||
{% set pct = ut.get(window) %}
|
{% set pct = ut.get(window) %}
|
||||||
<span style="text-align:center;font-family:ui-monospace,monospace;font-size:0.78rem;">
|
<span style="text-align:center;font-family:ui-monospace,monospace;font-size:0.78rem;">
|
||||||
|
|||||||
@@ -22,7 +22,13 @@
|
|||||||
{% set last = host_pings[-1] if host_pings else none %}
|
{% set last = host_pings[-1] if host_pings else none %}
|
||||||
<div class="ping-row">
|
<div class="ping-row">
|
||||||
<div class="ping-meta">
|
<div class="ping-meta">
|
||||||
<span class="ping-name">{{ host.name }}</span>
|
{# Link to the host hub for logged-in users; plain text on the public share view (no auth, no token on the href). #}
|
||||||
|
{% if session.user_id %}
|
||||||
|
<a class="ping-name" href="/hosts/{{ host.id }}" title="{{ host.name }}"
|
||||||
|
style="color:inherit;text-decoration:none;">{{ host.name }}</a>
|
||||||
|
{% else %}
|
||||||
|
<span class="ping-name" title="{{ host.name }}">{{ host.name }}</span>
|
||||||
|
{% endif %}
|
||||||
<span class="ping-addr">{{ host.address }}</span>
|
<span class="ping-addr">{{ host.address }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="ping-pills">
|
<div class="ping-pills">
|
||||||
|
|||||||
@@ -15,7 +15,13 @@
|
|||||||
{% for e in problems[:8] %}
|
{% for e in problems[:8] %}
|
||||||
<div style="display:flex;align-items:center;gap:0.5rem;padding:0.2rem 0;font-size:0.82rem;">
|
<div style="display:flex;align-items:center;gap:0.5rem;padding:0.2rem 0;font-size:0.82rem;">
|
||||||
<span class="dot {% if e.status == 'down' %}dot-down{% else %}dot-dim{% endif %}"></span>
|
<span class="dot {% if e.status == 'down' %}dot-down{% else %}dot-dim{% endif %}"></span>
|
||||||
<span style="flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">{{ e.name }}</span>
|
{% set nm_style = "flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;" %}
|
||||||
|
{# Link to the monitor's own detail view for logged-in users; plain text on the public share view. #}
|
||||||
|
{% if session.user_id and e.detail_url %}
|
||||||
|
<a href="{{ e.detail_url }}" title="{{ e.name }}" style="{{ nm_style }}color:inherit;text-decoration:none;">{{ e.name }}</a>
|
||||||
|
{% else %}
|
||||||
|
<span title="{{ e.name }}" style="{{ nm_style }}">{{ e.name }}</span>
|
||||||
|
{% endif %}
|
||||||
<span style="color:var(--text-dim);font-size:0.7rem;text-transform:uppercase;">{{ e.kind }}</span>
|
<span style="color:var(--text-dim);font-size:0.7rem;text-transform:uppercase;">{{ e.kind }}</span>
|
||||||
<span style="color:{% if e.status == 'down' %}var(--red){% else %}var(--yellow){% endif %};font-size:0.75rem;font-weight:600;">{{ e.status }}</span>
|
<span style="color:{% if e.status == 'down' %}var(--red){% else %}var(--yellow){% endif %};font-size:0.75rem;font-weight:600;">{{ e.status }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user