Files
FabledSteward/plugins/unifi/templates/unifi/inventory.html
T
bvandeusenandClaude Opus 5.5 414c942cbf
CI / lint (push) Successful in 2s
CI / integration (push) Successful in 1m5s
CI / unit (push) Successful in 1m19s
CI / publish (push) Successful in 57s
feat(plugins): Traefik problems first, UniFi/SNMP/fleet on shared shapes, audit names its entities, templates on tokens (#5126)
Traefik: routers are graded from their latest scrape (router_state: crit on
any real 5xx share, warn on p95 past the latency critical cutoff or a high
4xx share). Failing and slow routers lead as cards that say why; healthy
ones fold into one table that stays open or shut across polls. Proxy
counts are stat tiles; certificates are graded by Settings -> Thresholds
(tls_days).

UniFi: WAN health is a stat strip (latency graded by the thresholds),
devices carry status dots, event categories and firewall actions are
badges, the alarm count reuses .count-badge (renamed from .nav-count).
SNMP: each device wears a status badge and its readings are stat tiles.

Agent fleet: the table comes first, with a Status column (Reporting /
Silent / Never reported, by the host page's stale_after_seconds), silent
agents first, hosts linked, last seen as |ago.

Audit: entries name their entity (one query per type, steward/audit/
service.py) and link it; something deleted since keeps the name its entry
recorded and says "(deleted)".

Tokens: charts read colours through chart-colors.js (stewardColor resolves
a token to the rgb the browser computed; Chart.js defaults take the page's
text and border colours), so host, history, Traefik and SNMP charts drop
their hex. Template hex colours reach 0 (HEX_CEILING = 0), the last rgba
pills go, and heavy weights (600/700/bold, 60 of them) become 500, the
house pair being 400/500; a guard keeps templates there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 18:25:09 -04:00

142 lines
6.0 KiB
HTML

{# plugins/unifi/templates/unifi/inventory.html #}
<div style="column-width:360px;column-count:3;column-gap:1rem;">
{# Networks / VLANs #}
{% if networks %}
<div class="card" style="break-inside:avoid;margin-bottom:1rem;">
<div class="section-title" style="margin-bottom:0.75rem;">Networks / VLANs</div>
<table class="table" style="width:100%;font-size:0.82rem;">
<tr style="color:var(--text-muted);font-size:0.78rem;">
<th style="text-align:left;font-weight:normal;padding:0 0.5rem 0.3rem 0;">Name</th>
<th style="text-align:right;font-weight:normal;padding:0 0.5rem 0.3rem;">VLAN</th>
<th style="text-align:left;font-weight:normal;padding:0 0 0.3rem;">Subnet</th>
</tr>
{% for net in networks %}
<tr>
<td style="padding:0.25rem 0.5rem 0.25rem 0;">
{{ net.name }}
{% if net.is_guest %}<span style="font-size:0.72rem;color:var(--text-dim);"> guest</span>{% endif %}
</td>
<td style="padding:0.25rem 0.5rem;text-align:right;color:var(--text-muted);font-family:monospace;font-size:0.78rem;">
{{ net.vlan or "—" }}
</td>
<td style="padding:0.25rem 0;color:var(--text-dim);font-family:monospace;font-size:0.78rem;">
{{ net.ip_subnet or "—" }}
</td>
</tr>
{% endfor %}
</table>
</div>
{% endif %}
{# Port forwards #}
{% if port_forwards %}
<div class="card" style="break-inside:avoid;margin-bottom:1rem;">
<div class="section-title" style="margin-bottom:0.75rem;">Port Forwards</div>
<table class="table" style="width:100%;font-size:0.82rem;">
{% for pf in port_forwards %}
<tr>
<td style="padding:0.25rem 0.5rem 0.25rem 0;">
<span style="{% if not pf.enabled %}color:var(--text-dim);{% endif %}">
{{ pf.name or "—" }}
</span>
{% if not pf.enabled %}<span style="font-size:0.72rem;color:var(--text-dim);"> disabled</span>{% endif %}
</td>
<td style="padding:0.25rem 0;font-family:monospace;font-size:0.78rem;color:var(--text-muted);white-space:nowrap;">
{{ pf.proto }}:{{ pf.dst_port }} → {{ pf.fwd_ip }}:{{ pf.fwd_port }}
</td>
</tr>
{% endfor %}
</table>
</div>
{% endif %}
{# Firewall rules, grouped by ruleset #}
{% if fw_rules %}
{% set ns = namespace(current_rs=None) %}
<div class="card" style="break-inside:avoid;margin-bottom:1rem;">
<div class="section-title" style="margin-bottom:0.75rem;">Firewall Rules</div>
<table class="table" style="width:100%;font-size:0.82rem;">
{% for rule in fw_rules %}
{% if rule.ruleset != ns.current_rs %}
{% set ns.current_rs = rule.ruleset %}
<tr>
<td colspan="3" style="padding:0.4rem 0 0.2rem;color:var(--text-muted);font-size:0.75rem;font-weight:500;letter-spacing:0.04em;text-transform:uppercase;">
{{ rule.ruleset }}
</td>
</tr>
{% endif %}
<tr>
<td style="padding:0.2rem 0.5rem 0.2rem 0;">
<span style="{% if not rule.enabled %}color:var(--text-dim);{% endif %}">
{{ rule.name }}
</span>
</td>
<td style="padding:0.2rem 0.3rem;white-space:nowrap;">
<span class="badge badge-{{ {'accept': 'ok', 'drop': 'crit'}.get(rule.action, 'warn') }}">{{ rule.action }}</span>
</td>
<td style="padding:0.2rem 0;color:var(--text-dim);font-size:0.76rem;">
{% if rule.protocol %}{{ rule.protocol }}{% endif %}
{% if rule.src_address %} src:{{ rule.src_address }}{% endif %}
{% if rule.dst_address %} dst:{{ rule.dst_address }}{% endif %}
</td>
</tr>
{% endfor %}
</table>
</div>
{% endif %}
{# Known clients #}
{% if known_clients %}
<div class="card" style="break-inside:avoid;margin-bottom:1rem;">
<div class="section-title" style="margin-bottom:0.75rem;">
Known Clients
<span style="float:right;font-weight:normal;font-size:0.78rem;color:var(--text-dim);">{{ known_clients|length }} total</span>
</div>
<table class="table" style="width:100%;font-size:0.82rem;">
<tr style="color:var(--text-muted);font-size:0.78rem;">
<th style="text-align:left;font-weight:normal;padding:0 0.5rem 0.3rem 0;">Name / MAC</th>
<th style="text-align:left;font-weight:normal;padding:0 0.5rem 0.3rem;">IP</th>
<th style="text-align:right;font-weight:normal;padding:0 0 0.3rem;">Last Seen</th>
</tr>
{% for kc in known_clients[:50] %}
<tr>
<td style="padding:0.2rem 0.5rem 0.2rem 0;">
<div style="{% if kc.is_blocked %}color:var(--red);{% endif %}">
{{ kc.name or kc.hostname or kc.mac }}
{% if kc.is_blocked %}<span style="font-size:0.72rem;"> blocked</span>{% endif %}
</div>
{% if kc.name or kc.hostname %}
<div style="color:var(--text-dim);font-size:0.74rem;font-family:monospace;">{{ kc.mac }}</div>
{% endif %}
{% if kc.mac_vendor %}
<div style="color:var(--text-dim);font-size:0.73rem;">{{ kc.mac_vendor }}</div>
{% endif %}
</td>
<td style="padding:0.2rem 0.3rem;color:var(--text-muted);font-family:monospace;font-size:0.78rem;">
{{ kc.ip or "—" }}
</td>
<td style="padding:0.2rem 0;text-align:right;color:var(--text-dim);font-size:0.75rem;white-space:nowrap;">
{% if kc.last_seen %}{{ kc.last_seen.strftime("%m-%d %H:%M") }}{% else %}—{% endif %}
</td>
</tr>
{% endfor %}
{% if known_clients|length > 50 %}
<tr>
<td colspan="3" style="padding:0.4rem 0;color:var(--text-dim);font-size:0.78rem;text-align:center;">
+{{ known_clients|length - 50 }} more
</td>
</tr>
{% endif %}
</table>
</div>
{% endif %}
{% if not networks and not port_forwards and not fw_rules and not known_clients %}
<div class="card">
<p style="color:var(--text-muted);">No inventory data yet. This populates on the next poll cycle.</p>
</div>
{% endif %}
</div>