feat(ui): Disk, Traefik, UniFi and Settings say things plainly (#5212)
#5212 "Plain labels: no raw ids, scopes, metric keys or unexplained jargon", batch 3: - Disk page: each tile says what it holds. "Writable layers" becomes "Container files" and Build cache says it is safe to clear. Shared is "Shared with other images" with a tooltip, and "dangling" is gone. Untagged images show by id instead of "<none>", a capped list says "The 50 largest of N images", and each host shows "as of" its report. - Traefik: an expired certificate reads "expired 12 days ago", not "-12 days" (cert_left). The Traffic empty state knows whether the access log is on: off points to Settings → Plugins → Traefik; on says to check the mounted log path. - Moments use |ago with an exact UTC tooltip: UniFi last seen, alarms, events, speed test and DPI; AI token last used. - Settings: the Auth tab is "Authentication" like its breadcrumb, plugin fields read "Metrics URL" not metrics_url (field_label), a source's pull interval is "every 1h", and the last report time drops the ISO "T". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+2
-1
@@ -146,7 +146,8 @@ def create_app(
|
||||
app.jinja_env.globals["status_info"] = _fmt.status_info
|
||||
app.jinja_env.globals["required"] = _fmt.required
|
||||
# A metric and its source in words, a reading in its unit (alerts pages).
|
||||
for _name in ("metric_label", "metric_about", "metric_unit", "metric_value", "source_label"):
|
||||
for _name in ("metric_label", "metric_about", "metric_unit", "metric_value", "source_label",
|
||||
"cert_left", "field_label"):
|
||||
app.jinja_env.globals[_name] = getattr(_fmt, _name)
|
||||
from .alerts.service import rule_condition as _rule_condition
|
||||
app.jinja_env.globals["rule_condition"] = _rule_condition
|
||||
|
||||
@@ -229,6 +229,37 @@ SOURCES: dict[str, str] = {
|
||||
}
|
||||
|
||||
|
||||
def cert_left(days: float | None) -> str:
|
||||
"""Time left on a certificate: "12 days", "1 day", "today", or "expired
|
||||
3 days ago" rather than "-3 days"."""
|
||||
if days is None:
|
||||
return NONE
|
||||
whole = int(days)
|
||||
if days < 0:
|
||||
gone = int(-days)
|
||||
return "expired today" if gone == 0 else f"expired {gone} day{'s' if gone != 1 else ''} ago"
|
||||
if whole == 0:
|
||||
return "expires today"
|
||||
return f"{whole} day{'s' if whole != 1 else ''}"
|
||||
|
||||
|
||||
# Words a settings key spells in lower case that read in capitals.
|
||||
_ACRONYMS = {"url": "URL", "urls": "URLs", "ssl": "SSL", "tls": "TLS", "ip": "IP", "api": "API",
|
||||
"dns": "DNS", "http": "HTTP", "https": "HTTPS", "snmp": "SNMP", "oid": "OID",
|
||||
"oids": "OIDs", "id": "ID", "geoip": "GeoIP", "db": "database", "mmdb": "MMDB",
|
||||
"wan": "WAN", "dpi": "DPI", "smtp": "SMTP"}
|
||||
|
||||
|
||||
def field_label(key: str) -> str:
|
||||
"""A config key as a form label: "metrics_url" → "Metrics URL",
|
||||
"scrape_interval_seconds" → "Scrape interval seconds"."""
|
||||
words = [_ACRONYMS.get(w.lower(), w) for w in str(key or "").replace("-", "_").split("_") if w]
|
||||
if not words:
|
||||
return ""
|
||||
words[0] = words[0][:1].upper() + words[0][1:]
|
||||
return " ".join(words)
|
||||
|
||||
|
||||
def metric_label(name: str) -> str:
|
||||
entry = METRICS.get(name or "")
|
||||
return entry[0] if entry else (name or "").replace("_", " ")
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
<td><span class="badge badge-dim">{{ t.role.value }}</span></td>
|
||||
<td style="white-space:nowrap;">{{ t.created_at.strftime("%Y-%m-%d") }}</td>
|
||||
<td style="white-space:nowrap;">
|
||||
{% if t.last_used_at %}{{ t.last_used_at.strftime("%Y-%m-%d %H:%M") }} UTC{% else %}<span style="color:var(--text-muted);">Never</span>{% endif %}
|
||||
{% if t.last_used_at %}{{ t.last_used_at|ago }}{% else %}<span style="color:var(--text-muted);">Never</span>{% endif %}
|
||||
</td>
|
||||
<td style="white-space:nowrap;">
|
||||
{% if row.state == 'revoked' %}<span class="badge badge-red">Revoked</span>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
{% if src.type == 'git' %}
|
||||
{{ src.url or '(no URL)' }}
|
||||
<span style="color:var(--text-dim);margin-left:0.5rem;">branch: {{ src.branch or 'main' }}</span>
|
||||
{% if src.pull_interval_seconds %}<span style="color:var(--text-dim);margin-left:0.5rem;">· pull every {{ src.pull_interval_seconds }}s</span>{% endif %}
|
||||
{% if src.pull_interval_seconds %}<span style="color:var(--text-dim);margin-left:0.5rem;">· pulled every {{ src.pull_interval_seconds|duration }}</span>{% endif %}
|
||||
{% else %}
|
||||
{{ src.path or '(no path)' }}
|
||||
{% endif %}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
("thresholds", "Thresholds & Retention", "/settings/thresholds/"),
|
||||
("notifications", "Notifications", "/settings/notifications/"),
|
||||
("reports", "Reports", "/settings/reports/"),
|
||||
("auth", "Auth", "/settings/auth/"),
|
||||
("auth", "Authentication", "/settings/auth/"),
|
||||
("ansible", "Ansible", "/settings/ansible/"),
|
||||
("plugins", "Plugins", "/settings/plugins/"),
|
||||
] %}
|
||||
|
||||
@@ -72,14 +72,14 @@
|
||||
background:var(--bg);border-radius:5px;border:1px solid var(--border);
|
||||
font-size:0.82rem;color:var(--text-muted);">
|
||||
<span style="flex-shrink:0;">📋</span>
|
||||
<span><strong style="color:var(--text);">{{ cfg_key }}</strong> — list config, edit in
|
||||
<span><strong style="color:var(--text);">{{ field_label(cfg_key) }}</strong> — list config, edit in
|
||||
<code>plugin.yaml</code> ({{ cfg_default | length }} item{{ 's' if cfg_default | length != 1 }}).</span>
|
||||
</div>
|
||||
|
||||
{% elif cfg_default is mapping %}
|
||||
<div style="padding:0.75rem;background:var(--bg);border-radius:5px;border:1px solid var(--border);">
|
||||
<div style="font-size:0.74rem;color:var(--text-muted);text-transform:uppercase;
|
||||
letter-spacing:0.05em;margin-bottom:0.6rem;">{{ cfg_key }}</div>
|
||||
letter-spacing:0.05em;margin-bottom:0.6rem;">{{ field_label(cfg_key) }}</div>
|
||||
{% set sub_cfg = plugin._config.get(cfg_key, cfg_default) if plugin._config.get(cfg_key, cfg_default) is mapping else cfg_default %}
|
||||
<div style="display:grid;gap:0.5rem;">
|
||||
{% for sub_key, sub_default in cfg_default.items() %}
|
||||
@@ -90,11 +90,11 @@
|
||||
id="plugin-{{ plugin._dir }}-{{ cfg_key }}-{{ sub_key }}"
|
||||
{% if sub_cfg.get(sub_key, sub_default) %}checked{% endif %}>
|
||||
<label for="plugin-{{ plugin._dir }}-{{ cfg_key }}-{{ sub_key }}"
|
||||
style="margin:0;font-size:0.85rem;color:var(--text);">{{ sub_key }}</label>
|
||||
style="margin:0;font-size:0.85rem;color:var(--text);">{{ field_label(sub_key) }}</label>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="form-group" style="margin:0;">
|
||||
<label style="font-size:0.82rem;">{{ sub_key }}</label>
|
||||
<label style="font-size:0.82rem;">{{ field_label(sub_key) }}</label>
|
||||
<input type="text"
|
||||
name="plugin.{{ plugin._dir }}.{{ cfg_key }}.{{ sub_key }}"
|
||||
value="{{ sub_cfg.get(sub_key, sub_default) }}">
|
||||
@@ -111,12 +111,12 @@
|
||||
id="plugin-{{ plugin._dir }}-{{ cfg_key }}"
|
||||
{% if plugin._config.get(cfg_key, cfg_default) %}checked{% endif %}>
|
||||
<label for="plugin-{{ plugin._dir }}-{{ cfg_key }}"
|
||||
style="margin:0;font-size:0.85rem;color:var(--text);">{{ cfg_key }}</label>
|
||||
style="margin:0;font-size:0.85rem;color:var(--text);">{{ field_label(cfg_key) }}</label>
|
||||
</div>
|
||||
|
||||
{% else %}
|
||||
<div class="form-group" style="margin:0;">
|
||||
<label style="font-size:0.82rem;">{{ cfg_key }}</label>
|
||||
<label style="font-size:0.82rem;">{{ field_label(cfg_key) }}</label>
|
||||
<input type="{% if 'password' in cfg_key or 'secret' in cfg_key %}password{% else %}text{% endif %}"
|
||||
name="plugin.{{ plugin._dir }}.{{ cfg_key }}"
|
||||
value="{% if 'password' in cfg_key or 'secret' in cfg_key %}{% else %}{{ plugin._config.get(cfg_key, cfg_default) }}{% endif %}"
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
<p style="font-size:0.78rem;color:var(--text-muted);margin-top:0.25rem;">
|
||||
Requires SMTP configured in <a href="/settings/notifications/">Notifications</a>.
|
||||
{% if settings['reports.last_sent_at'] %}
|
||||
Last sent: {{ settings['reports.last_sent_at'][:16] }} UTC.
|
||||
Last sent: {{ settings['reports.last_sent_at'][:16]|replace("T", " ") }} UTC.
|
||||
{% endif %}
|
||||
</p>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user