Files
bvandeusenandClaude Opus 5.5 0c66c1e7d3
CI / lint (push) Successful in 2s
CI / integration (push) Successful in 55s
CI / unit (push) Failing after 1m25s
CI / publish (push) Skipped
feat(alerts): Steward's own confirm dialog, a verdict-first rules list, and a rule page in three sections (#5314, #5315, #5317)
Confirm dialog (#5314):
- Every data-confirm form now asks in one native <dialog> (base.html + static/confirm.js)
  instead of window.confirm.
- The question becomes the heading and what follows it the detail; the act's
  button is named after the form's own button; Cancel has the focus and Esc
  backs out. Optional data-confirm-title/-detail/-action/-dismiss attributes.
- All 27 existing uses work as they are. Cancelling a run says 'Keep running'.

Alerts list (#5315):
- A verdict line (what is firing, how many rules, where notifications go,
  or 'notifies nobody yet' with a link) replaces the empty Active card.
- Each rule's name opens it; rows show 'last fired' and fold fire/clear into
  the condition; History and Disable stay; Delete leaves the list.
- .docker-verdict becomes the shared .page-verdict.

Rule page (#5317):
- Named for the rule (title and crumb), with when it last fired and how many
  changes of state it holds.
- Three sections: what it watches, when it fires (checks side by side,
  seconds echoed as a duration), what happens (where notifications go, no-data,
  the playbook, whose fields stay folded until ticked).
- Delete at the foot, behind the dialog, saying its history goes with it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 22:58:38 -04:00

67 lines
3.8 KiB
HTML

{# alerts/_active.html — the Alerts page's verdict and Active section, polled
on their own (#5315): one line that says what is firing, how many rules
there are and where their notifications go; then the alerts themselves,
firing first, then no data, then acknowledged, then pending
(alert_svc.active_rows). An acknowledged alert says how long it has been
breaching, and apart from that who acknowledged it and when. #}
{% from "_macros.html" import status_badge %}
{% set can_edit = session.user_role in ('operator', 'admin') %}
{% set words = {"firing": "firing", "no_data": "silent", "acknowledged": "acknowledged", "pending": "pending"} %}
<p class="page-verdict">
{%- set firing = active|selectattr("label", "equalto", "firing")|list|length %}
{%- if firing %}<strong class="tone-crit">{{ firing }} firing</strong>
{%- elif active %}<strong class="tone-warn">Nothing is firing</strong>
{%- else %}<strong class="tone-ok">Nothing is firing</strong>{% endif %}
{%- for key in ("no_data", "acknowledged", "pending") %}
{%- set n = active|selectattr("label", "equalto", key)|list|length %}
{%- if n %} · <span class="tone-warn">{{ n }} {{ words[key] }}</span>{% endif %}
{%- endfor %}
{%- if rules_total %} · {{ rules_total }} rule{{ "s" if rules_total != 1 }}{% if rules_off %}, {{ rules_off }} off{% endif %}{% endif %}
{%- if notify %} · notifies {{ notify|join(" and ") }}
{%- else %} · <span class="tone-warn" title="No email server with recipients and no webhook URL is set, so an alert that fires tells no one">notifies nobody yet</span>
{%- if session.user_role == 'admin' %} — <a href="/settings/notifications/">set up email or a webhook</a>{% endif %}{% endif %}
</p>
{% if active %}
<h2 class="section-title" style="margin-bottom:1rem;">Active</h2>
<div class="card-flush" style="margin-bottom:2rem;">
<table class="table">
<thead>
<tr>
<th>State</th>
<th>What is wrong</th>
<th>Rule</th>
<th></th>
</tr>
</thead>
<tbody>
{% for row in active %}
<tr>
<td>
{{ status_badge(row.label, title=("No sample since " ~ (row.state.last_sample_at.strftime('%Y-%m-%d %H:%M UTC') if row.state.last_sample_at else 'the rule started watching')) if row.label == 'no_data' else none) }}
{% if row.state.no_data_since and row.label != 'no_data' %}
{{ status_badge('no_data', title="Silent since " ~ row.state.no_data_since.strftime('%Y-%m-%d %H:%M UTC')) }}
{% endif %}
</td>
<td>
{{- row.says.lead -}}
{%- if row.url %}<a href="{{ row.url }}">{{ row.says.resource }}</a>{% else %}<strong>{{ row.says.resource }}</strong>{% endif -%}
{{- row.says.tail -}}
{%- if row.label == 'acknowledged' and row.state.acknowledged_at %}
<div class="field-hint" style="margin-top:0.15rem;">Acknowledged{% if row.acked_by %} by {{ row.acked_by }}{% endif %} {{ row.state.acknowledged_at|ago }}</div>
{%- endif %}
</td>
<td style="color:var(--text-muted);"><a href="/alerts/history?rule={{ row.rule.id }}">{{ row.rule.name }}</a></td>
<td class="td-actions">
{% if can_edit and row.state.state.value == 'firing' %}
<form method="post" action="/alerts/{{ row.rule.id }}/acknowledge" style="display:inline;">{{ csrf_field() }}
<button type="submit" class="btn btn-sm btn-warn">Acknowledge</button>
</form>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}