Files
FabledSteward/steward/templates/_macros.html
T
bvandeusen e446b7099e
CI / lint (push) Successful in 3s
CI / unit (push) Successful in 8s
CI / integration (push) Successful in 2m18s
CI / publish (push) Successful in 55s
feat(dashboard): threshold colors on Hosts-Overview ping + 24h uptime
Add an inverted uptime_style macro (low-is-bad mirror of metric_style) and
color the inline ping latency (warn 100ms / crit 250ms) and 24h uptime values
in the Hosts-Overview widget, which were the remaining uncolored metrics.
(Uptime/SLA + Ping widgets already colored degraded values.)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 20:41:44 -04:00

41 lines
2.0 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{# Shared template macros. Import with: {% from "_macros.html" import crumbs %} #}
{# Breadcrumb trail. `items` is a list of (label, href) pairs, ordered root→current.
Intermediate items with a truthy href render as links; the last item (or any
item with an empty href) renders as plain current text. #}
{% macro crumbs(items) -%}
<nav class="breadcrumb" aria-label="Breadcrumb">
{%- for label, href in items -%}
{%- if loop.last -%}
<span class="breadcrumb-cur" aria-current="page">{{ label }}</span>
{%- elif href -%}
<a href="{{ href }}">{{ label }}</a><span class="breadcrumb-sep"></span>
{%- else -%}
<span>{{ label }}</span><span class="breadcrumb-sep"></span>
{%- endif -%}
{%- endfor -%}
</nav>
{%- 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 %}
{# Inverted emphasis for "higher is better" metrics like uptime %: amber below
`warn`, red below `crit`. The mirror of metric_style — same one-place-for-
thresholds discipline, opposite direction. Defaults suit SLA percentages. #}
{% macro uptime_style(value, warn=99.0, crit=95.0) -%}
{%- 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 %}