diff --git a/plugins/host_agent/templates/panel.html b/plugins/host_agent/templates/panel.html index 9982ca3..d85904d 100644 --- a/plugins/host_agent/templates/panel.html +++ b/plugins/host_agent/templates/panel.html @@ -1,4 +1,5 @@ {# Per-host agent panel — embedded into /hosts/ via HTMX. Self-contained. #} +{% from "_macros.html" import metric_style %} {% set scope = "steward:target:" ~ target.id if target else "" %}
@@ -21,19 +22,20 @@
CPU
-
{{ '%.0f%%'|format(cpu) if cpu is not none else '—' }}
+
{{ '%.0f%%'|format(cpu) if cpu is not none else '—' }}
{{ sparks.cpu | safe }}
Memory
-
{{ '%.0f%%'|format(mem) if mem is not none else '—' }}
+
{{ '%.0f%%'|format(mem) if mem is not none else '—' }}
{{ sparks.mem | safe }}
Disk /
-
{{ '%.0f%%'|format(disk_root) if disk_root is not none else '—' }}
+
{{ '%.0f%%'|format(disk_root) if disk_root is not none else '—' }}
{{ sparks.disk | safe }}
+ {# Load /core: 100% = run queue matches CPU capacity, so warn 80 / crit 100. #}
Load /core
-
{{ '%d%%'|format(load_per_core) if load_per_core is not none else ('%.2f'|format(load1) if load1 is not none else '—') }}
+
{{ '%d%%'|format(load_per_core) if load_per_core is not none else ('%.2f'|format(load1) if load1 is not none else '—') }}
{{ sparks.load | safe }}
{% if psi.cpu is not none or psi.mem is not none or psi.io is not none %} diff --git a/plugins/host_agent/templates/widget_table.html b/plugins/host_agent/templates/widget_table.html index 14a5bbd..df3f489 100644 --- a/plugins/host_agent/templates/widget_table.html +++ b/plugins/host_agent/templates/widget_table.html @@ -1,4 +1,5 @@ {# host_agent widget — fleet glance, flex rows (no header wrap) #} +{% from "_macros.html" import metric_style %} {% if rows %}
{% for r in rows %} @@ -6,19 +7,21 @@
- - {{ r.host.name }} - + {% set name_style = "flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-weight:500;" %} + {% if session.user_id %} + {{ r.host.name }} + {% else %} + {{ r.host.name }} + {% endif %} {% if r.cpu_pct is not none %} - cpu {{ "%.0f"|format(r.cpu_pct) }}% + cpu {{ "%.0f"|format(r.cpu_pct) }}% {% endif %} {% if r.mem_used_pct is not none %} - mem {{ "%.0f"|format(r.mem_used_pct) }}% + mem {{ "%.0f"|format(r.mem_used_pct) }}% {% endif %} {% if r.disk_root is not none %} - disk / {{ "%.0f"|format(r.disk_root) }}% + disk / {{ "%.0f"|format(r.disk_root) }}% {% endif %} {% if r.load_1m is not none %} load {{ "%.2f"|format(r.load_1m) }} diff --git a/steward/templates/_macros.html b/steward/templates/_macros.html index 4cb4b16..2867b70 100644 --- a/steward/templates/_macros.html +++ b/steward/templates/_macros.html @@ -16,3 +16,16 @@ {%- endfor -%} {%- 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 %} diff --git a/steward/templates/base.html b/steward/templates/base.html index 49dff1f..84a83f8 100644 --- a/steward/templates/base.html +++ b/steward/templates/base.html @@ -164,6 +164,7 @@ textarea { resize: vertical; } .ping-row:last-child { border-bottom:none; } .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; } +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-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; } diff --git a/steward/templates/dns/rows.html b/steward/templates/dns/rows.html index 1aa4a7c..6df4664 100644 --- a/steward/templates/dns/rows.html +++ b/steward/templates/dns/rows.html @@ -3,7 +3,13 @@ {% set d = latest.get(host.id) %}
- {{ host.name }} + {# 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 %} + {{ host.name }} + {% else %} + {{ host.name }} + {% endif %} {{ host.address }}
diff --git a/steward/templates/hosts/overview_widget.html b/steward/templates/hosts/overview_widget.html index 6cb2323..6e4ebf8 100644 --- a/steward/templates/hosts/overview_widget.html +++ b/steward/templates/hosts/overview_widget.html @@ -1,4 +1,5 @@ {# Unified Hosts widget — monitor status + agent glance per host, links to the hub. #} +{% from "_macros.html" import metric_style %} {% if hosts %}
{% for host in hosts %} @@ -10,10 +11,12 @@
- - {{ host.name }} - + {% set name_style = "flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-weight:500;" %} + {% if session.user_id %} + {{ host.name }} + {% else %} + {{ host.name }} + {% endif %} {# Monitors #} {% 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 %} 24h {{ "%.1f"|format(ut['24h']) }}% {% endif %} - {# Agent glance #} + {# Agent glance — failing metric coloured amber/red (≥80/≥90) #} {% if a %} - {% if a.get('cpu_pct') is not none %}cpu {{ "%.0f"|format(a.cpu_pct) }}%{% endif %} - {% if a.get('mem_used_pct') is not none %}mem {{ "%.0f"|format(a.mem_used_pct) }}%{% endif %} - {% if a.get('disk_root') is not none %}disk / {{ "%.0f"|format(a.disk_root) }}%{% endif %} + {% if a.get('cpu_pct') is not none %}cpu {{ "%.0f"|format(a.cpu_pct) }}%{% endif %} + {% if a.get('mem_used_pct') is not none %}mem {{ "%.0f"|format(a.mem_used_pct) }}%{% endif %} + {% if a.get('disk_root') is not none %}disk / {{ "%.0f"|format(a.disk_root) }}%{% endif %} {% if not a.fresh %}stale{% endif %} {% else %} no agent diff --git a/steward/templates/hosts/uptime_widget.html b/steward/templates/hosts/uptime_widget.html index 0f4df37..50b34ed 100644 --- a/steward/templates/hosts/uptime_widget.html +++ b/steward/templates/hosts/uptime_widget.html @@ -15,7 +15,12 @@ {% for host in hosts %} {% set ut = uptime.get(host.id, {}) %}
- {{ host.name }} + {% if session.user_id %} + {{ host.name }} + {% else %} + {{ host.name }} + {% endif %} {% for window in ["24h", "7d", "30d"] %} {% set pct = ut.get(window) %} diff --git a/steward/templates/ping/rows.html b/steward/templates/ping/rows.html index 1adcd88..c20ee06 100644 --- a/steward/templates/ping/rows.html +++ b/steward/templates/ping/rows.html @@ -22,7 +22,13 @@ {% set last = host_pings[-1] if host_pings else none %}
- {{ host.name }} + {# 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 %} + {{ host.name }} + {% else %} + {{ host.name }} + {% endif %} {{ host.address }}
diff --git a/steward/templates/status/widget.html b/steward/templates/status/widget.html index 2acc92f..486e104 100644 --- a/steward/templates/status/widget.html +++ b/steward/templates/status/widget.html @@ -15,7 +15,13 @@ {% for e in problems[:8] %}
- {{ e.name }} + {% 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 %} + {{ e.name }} + {% else %} + {{ e.name }} + {% endif %} {{ e.kind }} {{ e.status }}