Improve look of templates

This commit is contained in:
Peter Stockings
2025-12-22 13:47:34 +11:00
parent 2171b73b5f
commit ee7d2e2538
2 changed files with 384 additions and 120 deletions

View File

@@ -64,135 +64,248 @@
{% endmacro %} {% endmacro %}
<h2 style="margin-top: 0;">Live usage</h2> <h2
<div style="display:grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 12px 0 18px 0;"> style="margin-top: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.3px; color: #1e293b; margin-bottom: 16px;">
📊 Live Usage</h2>
<div
style="display:grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin: 0 0 32px 0;">
{{ donut("CPU", data.gauges.cpu_total_pct, "Sum of container CPU% (clamped)") }} {{ donut("CPU", data.gauges.cpu_total_pct, "Sum of container CPU% (clamped)") }}
{{ donut("RAM", data.gauges.ram_pct, "All containers vs host RAM", (data.gauges.ram_used_h ~ " / " ~ {{ donut("RAM", data.gauges.ram_pct, "All containers vs host RAM", (data.gauges.ram_used_h ~ " / " ~
data.gauges.ram_total_h)) }} data.gauges.ram_total_h)) }}
{{ donut("Docker disk", data.gauges.docker_images_pct, "Images used vs total store") }} {{ donut("Docker disk", data.gauges.docker_images_pct, "Images used vs total store") }}
</div> </div>
<h2>System</h2> <h2 style="font-size: 22px; font-weight: 800; letter-spacing: -0.3px; color: #1e293b; margin-bottom: 16px;">💻
<div style="display:grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 12px 0 18px 0;"> System</h2>
<div style="border:1px solid #ddd; border-radius: 10px; padding: 12px;"> <div
<div class="muted">Host</div> style="display:grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin: 0 0 32px 0;">
<div><strong>{{ data.system.name or "—" }}</strong></div> <div style="
<div class="muted">{{ data.system.operating_system }} · {{ data.system.kernel_version }}</div> border: 1px solid rgba(102, 126, 234, 0.15);
border-radius: 16px;
padding: 20px;
background: linear-gradient(135deg, rgba(102, 126, 234, 0.03) 0%, rgba(118, 75, 162, 0.03) 100%);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
transition: all 0.3s ease;
" onmouseover="this.style.transform='translateY(-2px)'; this.style.boxShadow='0 8px 20px rgba(0,0,0,0.08)';"
onmouseout="this.style.transform='translateY(0)'; this.style.boxShadow='0 4px 12px rgba(0,0,0,0.04)';">
<div
style="color: #64748b; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px;">
🖥️ Host</div>
<div style="font-size: 18px; font-weight: 800; color: #1e293b; margin-bottom: 6px;">{{ data.system.name
or "—" }}</div>
<div style="color: #64748b; font-size: 13px; line-height: 1.5;">{{ data.system.operating_system }} · {{
data.system.kernel_version }}</div>
</div> </div>
<div style="border:1px solid #ddd; border-radius: 10px; padding: 12px;"> <div style="
<div class="muted">Compute</div> border: 1px solid rgba(102, 126, 234, 0.15);
<div><strong>{{ data.system.cpus or "—" }}</strong> CPUs</div> border-radius: 16px;
<div><strong>{{ data.system.mem_total_h or "—" }}</strong> RAM</div> padding: 20px;
background: linear-gradient(135deg, rgba(102, 126, 234, 0.03) 0%, rgba(118, 75, 162, 0.03) 100%);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
transition: all 0.3s ease;
" onmouseover="this.style.transform='translateY(-2px)'; this.style.boxShadow='0 8px 20px rgba(0,0,0,0.08)';"
onmouseout="this.style.transform='translateY(0)'; this.style.boxShadow='0 4px 12px rgba(0,0,0,0.04)';">
<div
style="color: #64748b; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px;">
⚡ Compute</div>
<div style="font-size: 15px; font-weight: 600; color: #334155; margin-bottom: 4px;"><strong
style="color: #667eea; font-size: 18px;">{{ data.system.cpus or "—" }}</strong> CPUs</div>
<div style="font-size: 15px; font-weight: 600; color: #334155;"><strong
style="color: #667eea; font-size: 18px;">{{ data.system.mem_total_h or "—" }}</strong> RAM</div>
</div> </div>
<div style="border:1px solid #ddd; border-radius: 10px; padding: 12px;"> <div style="
<div class="muted">Docker</div> border: 1px solid rgba(102, 126, 234, 0.15);
<div>Engine: <strong>{{ data.system.server_version or "—" }}</strong></div> border-radius: 16px;
<div>Images: <strong>{{ data.system.images or "—" }}</strong></div> padding: 20px;
<div>Containers: <strong>{{ data.system.containers_running or "—" }}</strong> running / <strong>{{ background: linear-gradient(135deg, rgba(102, 126, 234, 0.03) 0%, rgba(118, 75, 162, 0.03) 100%);
data.system.containers_stopped or "—" }}</strong> stopped</div> box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
transition: all 0.3s ease;
" onmouseover="this.style.transform='translateY(-2px)'; this.style.boxShadow='0 8px 20px rgba(0,0,0,0.08)';"
onmouseout="this.style.transform='translateY(0)'; this.style.boxShadow='0 4px 12px rgba(0,0,0,0.04)';">
<div
style="color: #64748b; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px;">
🐳 Docker</div>
<div style="font-size: 13px; color: #334155; margin-bottom: 4px; line-height: 1.6;">Engine: <strong
style="color: #667eea;">{{ data.system.server_version or "—" }}</strong></div>
<div style="font-size: 13px; color: #334155; margin-bottom: 4px; line-height: 1.6;">Images: <strong
style="color: #667eea;">{{ data.system.images or "—" }}</strong></div>
<div style="font-size: 13px; color: #334155; line-height: 1.6;">Containers: <strong
style="color: #16a34a;">{{ data.system.containers_running or "—" }}</strong> running / <strong
style="color: #64748b;">{{ data.system.containers_stopped or "—" }}</strong> stopped</div>
</div> </div>
</div> </div>
<h3>Docker disk usage</h3> <h3 style="font-size: 18px; font-weight: 700; letter-spacing: -0.2px; color: #334155; margin: 32px 0 16px 0;">💾
<table> Docker Disk Usage</h3>
<div style="overflow-x: auto; border-radius: 12px; border: 1px solid rgba(0,0,0,0.06);">
<table style="margin: 0;">
<thead> <thead>
<tr> <tr>
<th>Type</th> <th
<th>Total</th> style="background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);">
<th>Active</th> Type</th>
<th>Size</th> <th
<th>Reclaimable</th> style="background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);">
Total</th>
<th
style="background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);">
Active</th>
<th
style="background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);">
Size</th>
<th
style="background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);">
Reclaimable</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for typ, r in data.system.system_df.items() %} {% for typ, r in data.system.system_df.items() %}
<tr> <tr style="transition: background-color 0.2s ease;"
<td><strong>{{ typ }}</strong></td> onmouseover="this.style.backgroundColor='rgba(102, 126, 234, 0.04)';"
<td>{{ r.total }}</td> onmouseout="this.style.backgroundColor='transparent';">
<td>{{ r.active }}</td> <td><strong style="color: #667eea;">{{ typ }}</strong></td>
<td>{{ r.size }}</td> <td style="color: #334155;">{{ r.total }}</td>
<td>{{ r.reclaimable }}</td> <td style="color: #334155;">{{ r.active }}</td>
<td style="color: #334155;">{{ r.size }}</td>
<td style="color: #334155;">{{ r.reclaimable }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
</div>
<div class="muted">Generated at: {{ data.generated_at }}</div> <div style="margin-top: 16px; color: #64748b; font-size: 13px; font-weight: 500;">⏱️ Generated at: {{
data.generated_at }}</div>
{% if data.warnings %} {% if data.warnings %}
<div style="margin: 10px 0; padding: 10px; border: 1px solid #f2c037; background: #fff7db; border-radius: 8px;"> <div style="
<strong>Warnings</strong> margin: 20px 0;
<ul> padding: 16px 20px;
border: 1px solid #fbbf24;
background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
border-radius: 12px;
box-shadow: 0 4px 12px rgba(251, 191, 36, 0.15);
">
<strong
style="color: #92400e; font-size: 16px; display: flex; align-items: center; gap: 8px; margin-bottom: 12px;">⚠️
Warnings</strong>
<ul style="margin: 0; padding-left: 20px; color: #78350f;">
{% for w in data.warnings %} {% for w in data.warnings %}
<li>{{ w }}</li> <li style="margin: 6px 0;">{{ w }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
</div> </div>
{% endif %} {% endif %}
<h2>Apps</h2> <h2 style="font-size: 22px; font-weight: 800; letter-spacing: -0.3px; color: #1e293b; margin: 40px 0 16px 0;">🚀
<table> Apps</h2>
<div style="overflow-x: auto; border-radius: 12px; border: 1px solid rgba(0,0,0,0.06);">
<table style="margin: 0;">
<thead> <thead>
<tr> <tr>
<th>App</th> <th
<th>URL</th> style="background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);">
<th>Status</th> App</th>
<th>CPU</th> <th
<th>RAM</th> style="background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);">
<th>Restarts</th> URL</th>
<th>Image</th> <th
style="background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);">
Status</th>
<th
style="background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);">
CPU</th>
<th
style="background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);">
RAM</th>
<th
style="background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);">
Restarts</th>
<th
style="background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);">
Image</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for r in data.apps %} {% for r in data.apps %}
<tr> <tr style="transition: background-color 0.2s ease;"
<td><strong>{{ r.app }}</strong></td> onmouseover="this.style.backgroundColor='rgba(102, 126, 234, 0.04)';"
<td><a href="{{ r.url }}">{{ r.url }}</a></td> onmouseout="this.style.backgroundColor='transparent';">
<td class="muted">{{ r.status }}</td> <td><strong style="color: #667eea;">{{ r.app }}</strong></td>
<td>{{ r.cpu or "—" }}</td> <td><a href="{{ r.url }}"
<td> style="color: #667eea; text-decoration: none; transition: all 0.2s ease;"
onmouseover="this.style.textDecoration='underline'; this.style.color='#764ba2';"
onmouseout="this.style.textDecoration='none'; this.style.color='#667eea';">{{ r.url
}}</a></td>
<td><span
style="padding: 4px 10px; background: rgba(102, 126, 234, 0.1); color: #667eea; border-radius: 6px; font-size: 12px; font-weight: 600;">{{
r.status }}</span></td>
<td style="color: #334155; font-weight: 600;">{{ r.cpu or "—" }}</td>
<td style="color: #334155; font-size: 13px;">
{% if r.mem_used %} {% if r.mem_used %}
{{ r.mem_used }} / {{ r.mem_limit }} ({{ r.mem_pct }}) {{ r.mem_used }} / {{ r.mem_limit }} <span style="color: #667eea; font-weight: 600;">({{
r.mem_pct }})</span>
{% else %} — {% endif %} {% else %} — {% endif %}
</td> </td>
<td>{{ r.restarts }}</td> <td style="color: #334155; font-weight: 600;">{{ r.restarts }}</td>
<td class="muted">{{ r.image }}</td> <td style="color: #64748b; font-size: 12px;">{{ r.image }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
</div>
{% if data.infra %} {% if data.infra %}
<h2 style="margin-top: 24px;">Infra</h2> <h2 style="font-size: 22px; font-weight: 800; letter-spacing: -0.3px; color: #1e293b; margin: 40px 0 16px 0;">
<table> 🏗️ Infra</h2>
<div style="overflow-x: auto; border-radius: 12px; border: 1px solid rgba(0,0,0,0.06);">
<table style="margin: 0;">
<thead> <thead>
<tr> <tr>
<th>Container</th> <th
<th>Status</th> style="background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);">
<th>CPU</th> Container</th>
<th>RAM</th> <th
<th>Restarts</th> style="background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);">
<th>Image</th> Status</th>
<th
style="background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);">
CPU</th>
<th
style="background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);">
RAM</th>
<th
style="background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);">
Restarts</th>
<th
style="background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);">
Image</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for r in data.infra %} {% for r in data.infra %}
<tr> <tr style="transition: background-color 0.2s ease;"
<td><strong>{{ r.container }}</strong></td> onmouseover="this.style.backgroundColor='rgba(102, 126, 234, 0.04)';"
<td class="muted">{{ r.status }}</td> onmouseout="this.style.backgroundColor='transparent';">
<td>{{ r.cpu or "—" }}</td> <td><strong style="color: #667eea;">{{ r.container }}</strong></td>
<td> <td><span
style="padding: 4px 10px; background: rgba(102, 126, 234, 0.1); color: #667eea; border-radius: 6px; font-size: 12px; font-weight: 600;">{{
r.status }}</span></td>
<td style="color: #334155; font-weight: 600;">{{ r.cpu or "—" }}</td>
<td style="color: #334155; font-size: 13px;">
{% if r.mem_used %} {% if r.mem_used %}
{{ r.mem_used }} / {{ r.mem_limit }} ({{ r.mem_pct }}) {{ r.mem_used }} / {{ r.mem_limit }} <span style="color: #667eea; font-weight: 600;">({{
r.mem_pct }})</span>
{% else %} — {% endif %} {% else %} — {% endif %}
</td> </td>
<td>{{ r.restarts }}</td> <td style="color: #334155; font-weight: 600;">{{ r.restarts }}</td>
<td class="muted">{{ r.image }}</td> <td style="color: #64748b; font-size: 12px;">{{ r.image }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
</div>
{% endif %} {% endif %}

View File

@@ -3,12 +3,118 @@
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Status - peterstockings.com</title> <title>Status - peterstockings.com</title>
<script src="https://unpkg.com/htmx.org@1.9.10"></script> <script src="https://unpkg.com/htmx.org@1.9.10"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800&display=swap" rel="stylesheet">
<style> <style>
* {
box-sizing: border-box;
}
body { body {
font-family: system-ui, Arial; font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
margin: 24px; margin: 0;
padding: 0;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
}
.container {
max-width: 1400px;
margin: 0 auto;
padding: 32px 24px;
}
.header-card {
background: rgba(255, 255, 255, 0.98);
backdrop-filter: blur(10px);
border-radius: 20px;
padding: 28px 32px;
margin-bottom: 24px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15),
0 0 0 1px rgba(255, 255, 255, 0.3) inset;
border: 1px solid rgba(255, 255, 255, 0.5);
}
h1 {
margin: 0 0 8px 0;
font-size: 36px;
font-weight: 800;
letter-spacing: -0.5px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.meta-info {
display: flex;
align-items: center;
gap: 12px;
flex-wrap: wrap;
color: #64748b;
font-size: 14px;
font-weight: 500;
}
.meta-info a {
color: #667eea;
text-decoration: none;
padding: 4px 12px;
background: rgba(102, 126, 234, 0.1);
border-radius: 6px;
font-weight: 600;
transition: all 0.2s ease;
display: inline-flex;
align-items: center;
}
.meta-info a:hover {
background: rgba(102, 126, 234, 0.2);
transform: translateY(-1px);
}
.content-card {
background: rgba(255, 255, 255, 0.98);
backdrop-filter: blur(10px);
border-radius: 20px;
padding: 32px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15),
0 0 0 1px rgba(255, 255, 255, 0.3) inset;
border: 1px solid rgba(255, 255, 255, 0.5);
}
.loading {
text-align: center;
padding: 60px 20px;
color: #64748b;
font-size: 16px;
font-weight: 500;
}
.loading::after {
content: '...';
animation: dots 1.5s steps(4, end) infinite;
}
@keyframes dots {
0%,
20% {
content: '.';
}
40% {
content: '..';
}
60%,
100% {
content: '...';
}
} }
table { table {
@@ -18,38 +124,83 @@
th, th,
td { td {
border-bottom: 1px solid #ddd; border-bottom: 1px solid rgba(0, 0, 0, 0.06);
padding: 8px; padding: 12px;
vertical-align: top; vertical-align: top;
} }
th { th {
text-align: left; text-align: left;
font-weight: 700;
color: #1e293b;
font-size: 13px;
text-transform: uppercase;
letter-spacing: 0.5px;
background: rgba(102, 126, 234, 0.04);
}
td {
color: #334155;
font-size: 14px;
}
tbody tr {
transition: background-color 0.2s ease;
}
tbody tr:hover {
background: rgba(102, 126, 234, 0.03);
} }
.muted { .muted {
color: #666; color: #64748b;
font-size: 0.9em; font-size: 0.9em;
} }
.pill { .pill {
display: inline-block; display: inline-block;
padding: 2px 8px; padding: 4px 10px;
border-radius: 999px; border-radius: 999px;
background: #eee; background: rgba(102, 126, 234, 0.1);
color: #667eea;
font-size: 12px;
font-weight: 600;
}
h2 {
font-size: 22px;
font-weight: 800;
letter-spacing: -0.3px;
color: #1e293b;
margin: 0 0 16px 0;
}
h3 {
font-size: 18px;
font-weight: 700;
letter-spacing: -0.2px;
color: #334155;
margin: 24px 0 12px 0;
} }
</style> </style>
</head> </head>
<body> <body>
<h1>Status</h1> <div class="container">
<div class="muted"> <div class="header-card">
Auto-refresh every {{ poll_seconds }}s <h1>Status Dashboard</h1>
· <a href="/api/status">JSON</a> <div class="meta-info">
<span>🔄 Auto-refresh every {{ poll_seconds }}s</span>
<span></span>
<a href="/api/status">📊 JSON API</a>
</div>
</div> </div>
<div class="content-card">
<div hx-get="/partial/apps" hx-trigger="load, every {{ poll_seconds }}s" hx-swap="innerHTML"> <div hx-get="/partial/apps" hx-trigger="load, every {{ poll_seconds }}s" hx-swap="innerHTML">
Loading… <div class="loading">Loading status data</div>
</div>
</div>
</div> </div>
</body> </body>