#5099 "A name containing a quote runs script when an admin clicks Delete". Inline handlers like onclick="return confirm('Delete {{ rule.name }}?')" are HTML-decoded before the JavaScript is parsed, so autoescaping did not stop a name such as x');fetch(…);// from running. - Every prompt (22 handlers, plus the docker prune and token revoke ones) is now data-confirm="…", read through dataset by one submit listener in base.html; nothing rendered is parsed as JavaScript. - The remaining inline handlers take integers only (|int), and the time range buttons pass this.dataset.range. - tests/test_inline_handlers.py fails on any {{ }} in an inline handler that is not |int, with a self-test; tests/_templates.py is the one template walker the template guards now share. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
118 lines
6.6 KiB
HTML
118 lines
6.6 KiB
HTML
{# docker/disk.html — image/disk usage: reclaimable space, per-image sizes #}
|
|
{% extends "base.html" %}
|
|
{% from "_macros.html" import crumbs %}
|
|
{% block title %}Disk — Docker — Steward{% endblock %}
|
|
{% block breadcrumb %}{{ crumbs([("Docker", "/plugins/docker/"), ("Image & disk usage", "")]) }}{% endblock %}
|
|
{% block content %}
|
|
|
|
<h1 class="page-title" style="margin-bottom:0.4rem;">Image & disk usage</h1>
|
|
<p style="font-size:0.82rem;color:var(--text-muted);margin-bottom:1.5rem;">
|
|
Reclaimable = space held by images no container references. Admins can prune
|
|
per host below; each action runs an audited Ansible playbook on that host.
|
|
</p>
|
|
|
|
{% if host_groups %}
|
|
{% for g in host_groups %}
|
|
<div style="margin-bottom:2rem;">
|
|
<div style="font-weight:600;font-size:0.95rem;margin-bottom:0.75rem;">{{ g.host_name }}</div>
|
|
|
|
{# ── Summary stats ────────────────────────────────────────────────────── #}
|
|
<div style="display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:0.75rem;margin-bottom:1rem;">
|
|
<div class="card" style="margin-bottom:0;">
|
|
<div class="section-title" style="margin-bottom:0.3rem;">Reclaimable</div>
|
|
<span class="stat-val" style="color:{% if g.summary.images_reclaimable != '0 B' %}var(--orange){% else %}var(--green){% endif %};">{{ g.summary.images_reclaimable }}</span>
|
|
</div>
|
|
<div class="card" style="margin-bottom:0;">
|
|
<div class="section-title" style="margin-bottom:0.3rem;">Images</div>
|
|
<span class="stat-val">{{ g.summary.images_size }}</span>
|
|
<div style="font-size:0.74rem;color:var(--text-muted);">{{ g.summary.images_active }}/{{ g.summary.images_total }} in use</div>
|
|
</div>
|
|
<div class="card" style="margin-bottom:0;">
|
|
<div class="section-title" style="margin-bottom:0.3rem;">Stopped</div>
|
|
<span class="stat-val" style="{% if g.stopped %}color:var(--text-muted){% endif %};">{{ g.stopped }}</span>
|
|
</div>
|
|
<div class="card" style="margin-bottom:0;">
|
|
<div class="section-title" style="margin-bottom:0.3rem;">Writable layers</div>
|
|
<span class="stat-val">{{ g.summary.containers_size }}</span>
|
|
<div style="font-size:0.74rem;color:var(--text-muted);">{{ g.summary.containers_count }} containers</div>
|
|
</div>
|
|
<div class="card" style="margin-bottom:0;">
|
|
<div class="section-title" style="margin-bottom:0.3rem;">Volumes</div>
|
|
<span class="stat-val">{{ g.summary.volumes_size }}</span>
|
|
<div style="font-size:0.74rem;color:var(--text-muted);">{{ g.summary.volumes_count }} volumes</div>
|
|
</div>
|
|
<div class="card" style="margin-bottom:0;">
|
|
<div class="section-title" style="margin-bottom:0.3rem;">Build cache</div>
|
|
<span class="stat-val">{{ g.summary.build_cache_size }}</span>
|
|
</div>
|
|
</div>
|
|
|
|
{# ── Cleanup actions (admin only; audited Ansible prune run) ───────────── #}
|
|
{% if session.user_role == 'admin' %}
|
|
<div style="margin-bottom:1rem;">
|
|
{% if ansible_available and g.has_target %}
|
|
<div style="display:flex;flex-wrap:wrap;gap:0.5rem;align-items:center;">
|
|
<form method="post" action="/plugins/docker/disk/{{ g.host_id }}/prune" style="margin:0;"
|
|
data-confirm="Remove all STOPPED containers on {{ g.host_name }}? This cannot be undone.">{{ csrf_field() }}
|
|
<input type="hidden" name="target" value="containers">
|
|
<button type="submit" class="btn btn-sm">Prune stopped containers</button>
|
|
</form>
|
|
<form method="post" action="/plugins/docker/disk/{{ g.host_id }}/prune" style="margin:0;"
|
|
data-confirm="Remove ALL unused images on {{ g.host_name }} (docker image prune -a)? Any image not used by a container is deleted.">{{ csrf_field() }}
|
|
<input type="hidden" name="target" value="images">
|
|
<button type="submit" class="btn btn-sm">Prune unused images</button>
|
|
</form>
|
|
<form method="post" action="/plugins/docker/disk/{{ g.host_id }}/prune" style="margin:0;"
|
|
data-confirm="Run a full system prune on {{ g.host_name }}? Removes stopped containers, unused networks, dangling images and build cache.">{{ csrf_field() }}
|
|
<input type="hidden" name="target" value="system">
|
|
<button type="submit" class="btn btn-sm btn-danger">System prune…</button>
|
|
</form>
|
|
</div>
|
|
<div style="font-size:0.72rem;color:var(--text-muted);margin-top:0.4rem;">
|
|
Reclaimed space appears on the next agent sample.
|
|
</div>
|
|
{% elif not ansible_available %}
|
|
<div style="font-size:0.74rem;color:var(--text-muted);">Cleanup needs the Ansible runner (currently unavailable).</div>
|
|
{% else %}
|
|
<div style="font-size:0.74rem;color:var(--text-muted);">
|
|
Link an <a href="/hosts/{{ g.host_id }}">Ansible target</a> to this host to enable prune actions.
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
{% endif %}
|
|
|
|
{# ── Per-image table ──────────────────────────────────────────────────── #}
|
|
<div class="card-flush">
|
|
<table class="table">
|
|
<thead>
|
|
<tr><th>Image</th><th>Size</th><th>Shared</th><th>Containers</th></tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for im in g.images %}
|
|
<tr>
|
|
<td style="font-size:0.84rem;font-family:ui-monospace,monospace;max-width:340px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">
|
|
{{ im.repo_tag }}
|
|
{% if im.reclaimable %}<span title="not referenced by any container" style="font-size:0.68rem;color:var(--orange);border:1px solid var(--orange);border-radius:3px;padding:0 0.3rem;margin-left:0.4rem;">reclaimable</span>{% endif %}
|
|
</td>
|
|
<td style="font-family:ui-monospace,monospace;font-size:0.86rem;">{{ im.size }}</td>
|
|
<td style="font-family:ui-monospace,monospace;font-size:0.86rem;color:var(--text-muted);">{{ im.shared }}</td>
|
|
<td style="font-size:0.86rem;color:{% if im.containers %}var(--text){% else %}var(--text-muted){% endif %};">{{ im.containers }}</td>
|
|
</tr>
|
|
{% else %}
|
|
<tr><td colspan="4" style="color:var(--text-muted);font-size:0.85rem;text-align:center;padding:1.5rem;">No images reported.</td></tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
{% endfor %}
|
|
{% else %}
|
|
<div class="card" style="text-align:center;padding:3rem;">
|
|
<div style="color:var(--text-muted);font-size:0.9rem;">
|
|
No disk usage reported yet. The host agent reports image/disk usage from
|
|
<code>docker system df</code> on hosts running Docker.
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
{% endblock %}
|