#5093 "Shared format filters and status_class driven by Settings → Thresholds". - steward/core/formatting.py: human_bytes (binary units), human_rate, human_duration (two largest units), ago (a <time> titled with the absolute UTC time) and status_class(value, kind, thresholds) -> ok/warn/crit/unknown, which raises on a kind the thresholds don't name. - app.py registers them as the bytes, rate, duration and ago filters and the status_class global; threshold_style is now graded by status_class (and caps its weight at 500). - Replaces the copies: docker's _human_bytes/_human_uptime, core alerts' _duration, the host-agent fmt_bps/fmt_bytes macros, the Traefik and UniFi byte-rate arithmetic, the swarm-failures ago macro and two uptime spans. - Tests: a table per helper, and every template compiled against the app's filters, so an unknown filter fails CI rather than a page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
60 lines
2.4 KiB
HTML
60 lines
2.4 KiB
HTML
{# plugins/unifi/templates/unifi/dpi.html #}
|
|
{% if not snapshot %}
|
|
<div class="card">
|
|
<p style="color:var(--text-muted);">No DPI data yet. DPI must be enabled on the UniFi controller.</p>
|
|
</div>
|
|
{% else %}
|
|
<div style="column-width:340px;column-count:3;column-gap:1rem;">
|
|
|
|
{# Category breakdown #}
|
|
{% if categories %}
|
|
<div class="card" style="break-inside:avoid;margin-bottom:1rem;">
|
|
<div class="section-title" style="margin-bottom:0.75rem;">
|
|
Traffic by Category
|
|
<span style="float:right;font-weight:normal;font-size:0.78rem;color:var(--text-dim);">{{ snapshot.scraped_at.strftime("%H:%M") }}</span>
|
|
</div>
|
|
{% set total_bytes = categories | sum(attribute='rx_bytes') + categories | sum(attribute='tx_bytes') %}
|
|
<table class="table" style="width:100%;font-size:0.82rem;">
|
|
{% for cat in categories[:20] %}
|
|
{% set bytes = cat.rx_bytes + cat.tx_bytes %}
|
|
{% set pct = (bytes / total_bytes * 100) if total_bytes else 0 %}
|
|
<tr>
|
|
<td style="padding:0.25rem 0.5rem 0.25rem 0;">{{ cat.cat_name or cat.cat_id }}</td>
|
|
<td style="padding:0.25rem 0.3rem;text-align:right;color:var(--text-muted);font-size:0.78rem;white-space:nowrap;">
|
|
{{ bytes|bytes }}
|
|
</td>
|
|
<td style="padding:0.25rem 0;width:4rem;">
|
|
<div style="background:var(--border);border-radius:2px;height:6px;overflow:hidden;">
|
|
<div style="background:var(--accent);height:100%;width:{{ "%.1f"|format(pct) }}%;"></div>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</table>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{# Top clients by DPI #}
|
|
{% if top_clients %}
|
|
<div class="card" style="break-inside:avoid;margin-bottom:1rem;">
|
|
<div class="section-title" style="margin-bottom:0.75rem;">Top Clients by Traffic</div>
|
|
<table class="table" style="width:100%;font-size:0.82rem;">
|
|
{% for c in top_clients %}
|
|
<tr>
|
|
<td style="padding:0.25rem 0.5rem 0.25rem 0;word-break:break-all;">
|
|
{{ c.hostname or c.mac }}
|
|
<span style="color:var(--text-dim);font-size:0.75rem;font-family:monospace;margin-left:0.3rem;">{{ c.mac }}</span>
|
|
</td>
|
|
<td style="padding:0.25rem 0;text-align:right;font-size:0.78rem;color:var(--text-muted);white-space:nowrap;">
|
|
{% set bytes = c.bytes %}
|
|
{{ bytes|bytes }}
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</table>
|
|
</div>
|
|
{% endif %}
|
|
|
|
</div>
|
|
{% endif %}
|