988c13d51f
Milestone 72 phase C — bring the host-view graphs onto the dashboard:
- host_resource_history widget reworked into a real host-view chart: epoch-ms
linear axis (no Chart.js date adapter), themed like the host-detail charts,
maintainAspectRatio:false so it fills the resized panel, unique canvas per
widget instance (wid), and empty states ("pick a host" / "no metrics yet").
Was previously unusable — it had a broken time axis and no way to choose a host.
- Add a "host" param type: the edit form renders a live dropdown of hosts
(dashboard routes now pass the host list to the editor); the chosen host_id is
stored in config and fed to the widget.
- Hosts-overview widget gains a per-row CPU sparkline (last hour) via the shared
sparkline_svg helper — the host-view at-a-glance trend, on the main widget.
Charts/sparklines render only in the browser, so CI can't exercise them — needs
an operator visual check.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
48 lines
3.1 KiB
HTML
48 lines
3.1 KiB
HTML
{# Unified Hosts widget — monitor status + agent glance per host, links to the hub. #}
|
|
{% from "_macros.html" import metric_style %}
|
|
{% if hosts %}
|
|
<div style="display:grid;gap:0.1rem;">
|
|
{% for host in hosts %}
|
|
{% set ping = latest_pings.get(host.id) %}
|
|
{% set dns = latest_dns.get(host.id) %}
|
|
{% set ut = uptime.get(host.id, {}) %}
|
|
{% set a = agent.get(host.name, {}) %}
|
|
{% set down = host.ping_enabled and ping and ping.status.value != 'up' %}
|
|
<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 %}"
|
|
title="{% if not host.ping_enabled %}ping off{% elif ping %}{{ ping.status.value }}{% else %}no data{% endif %}"></span>
|
|
{% set name_style = "flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-weight:500;" %}
|
|
{% if session.user_id %}
|
|
<a href="/hosts/{{ host.id }}" title="{{ host.name }}" style="{{ name_style }}">{{ host.name }}</a>
|
|
{% else %}
|
|
<span title="{{ host.name }}" style="{{ name_style }}">{{ host.name }}</span>
|
|
{% endif %}
|
|
{% set spark = cpu_sparks.get(host.name) %}
|
|
{% if spark %}<span title="CPU — last hour" style="flex-shrink:0;line-height:0;opacity:0.85;">{{ spark | safe }}</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;">
|
|
{# Monitors #}
|
|
{% if host.ping_enabled and ping and ping.response_time_ms is not none %}
|
|
<span title="Ping latency"><span style="color:var(--text-dim);">ping</span> {{ "%.0f"|format(ping.response_time_ms) }}ms</span>
|
|
{% endif %}
|
|
{% if ut.get('24h') is not none %}
|
|
<span title="Uptime 24h"><span style="color:var(--text-dim);">24h</span> {{ "%.1f"|format(ut['24h']) }}%</span>
|
|
{% endif %}
|
|
{# Agent glance — failing metric coloured amber/red (≥80/≥90) #}
|
|
{% if a %}
|
|
{% 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" 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 (/)" 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 %}
|
|
{% else %}
|
|
<span style="color:var(--text-dim);" title="No agent reporting">no agent</span>
|
|
{% endif %}
|
|
</span>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
{% else %}
|
|
<div class="empty" style="color:var(--text-muted);font-size:0.85rem;padding:0.5rem 0;">
|
|
No hosts yet. <a href="/hosts/new">Add one.</a>
|
|
</div>
|
|
{% endif %}
|