Files
FabledSteward/plugins/prometheus/templates/prometheus/_preview.html
T
bvandeusenandClaude Opus 5.5 bd762307e0
CI / lint (push) Successful in 2s
CI / integration (push) Successful in 1m16s
CI / unit (push) Failing after 1m29s
CI / publish (push) Skipped
feat(prometheus): the widget template library: list, edit with live preview, paste in, upload, export, duplicate (#5692)
Prometheus gains a "Widget templates" tab beside Targets. It lists the
built-in templates and an admin's own, any that no longer pass the checker
first. A template opens as its YAML beside a live preview drawn over a
chosen target exactly as the dashboard widget draws it (routes.draw, now
shared by both). An admin writes or pastes a new one, reads a .yaml upload
into the editor to look over, duplicates any template under a free name,
edits and deletes their own; anyone can export the YAML. Built-in
templates are read-only.

Custom templates are rows in prometheus_widget_templates (migration
prometheus_002_templates), kept in backups, keyed "custom:<id>" so a
rename keeps its widgets. Saving needs a template that passes the checker
and a name no other template has. Create, update and delete are audited
and link to the template.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 09:22:31 -04:00

15 lines
807 B
HTML

{# prometheus/_preview.html — the template editor's live preview (#5692):
what's typed, checked; when it passes, drawn over the chosen target as
the dashboard widget would draw it (widget.html, the same fragment). #}
{% if problems %}
<div class="w-verdict tone-warn">{{ problems|length }} problem{{ "s" if problems|length != 1 }} to fix before it draws.</div>
<ul class="tpl-problems">{% for p in problems %}<li>{{ p }}</li>{% endfor %}</ul>
{% elif empty %}
<p class="field-hint">Paste or write a template, and it's drawn here as you type.</p>
{% elif view is none %}
<div class="w-verdict tone-ok">“{{ template.name }}” passes the checker.</div>
<p class="field-hint">Add a Prometheus target to see it drawn over real values.</p>
{% else %}
{% include "prometheus/widget.html" %}
{% endif %}