Files
DokkuStatus/templates/apps_table.html
2025-12-22 13:47:34 +11:00

311 lines
18 KiB
HTML

{% macro donut(label, pct, subtitle, value_text=None) %}
{% set p = pct if pct is not none else 0 %}
{% if p < 0 %}{% set p=0 %}{% endif %} {% if p> 100 %}{% set p = 100 %}{% endif %}
{% if p < 60 %} {% set col="#16a34a" %} {% elif p < 85 %} {% set col="#f59e0b" %} {% else %} {% set col="#ef4444" %}
{% endif %} {% set r=24 %} {% set stroke=10 %} {% set c=2 * 3.1415926 * r %} {% set dash=(p / 100.0) * c %} {%
set txt=value_text if value_text else (p|round(0) ~ "%" ) %} <div style="
border:1px solid rgba(0,0,0,.08);
border-radius: 16px;
padding: 14px;
background: linear-gradient(180deg, rgba(255,255,255,.95), rgba(255,255,255,.80));
box-shadow: 0 8px 24px rgba(0,0,0,.06);
display:flex;
align-items:center;
gap: 14px;
min-height: 92px;
">
<svg width="72" height="72" viewBox="0 0 72 72" style="flex: 0 0 auto;">
<defs>
<filter id="softShadow" x="-50%" y="-50%" width="200%" height="200%">
<feDropShadow dx="0" dy="2" stdDeviation="2" flood-opacity="0.18" />
</filter>
</defs>
<!-- track -->
<circle cx="36" cy="36" r="{{ r }}" fill="none" stroke="rgba(0,0,0,.08)" stroke-width="{{ stroke }}"
stroke-linecap="round" />
<!-- progress -->
<circle cx="36" cy="36" r="{{ r }}" fill="none" stroke="{{ col }}" stroke-width="{{ stroke }}"
stroke-linecap="round" stroke-dasharray="{{ dash }} {{ c - dash }}" transform="rotate(-90 36 36)"
filter="url(#softShadow)" />
<!-- center -->
<text x="36" y="40" text-anchor="middle" font-size="14" font-weight="800"
font-family="system-ui, -apple-system, Segoe UI, Roboto" fill="rgba(0,0,0,.82)">{{ txt }}</text>
</svg>
<div style="min-width: 0; width: 100%;">
<div style="display:flex; align-items:center; justify-content:space-between; gap: 10px;">
<div style="font-weight:800; letter-spacing:-0.2px;">{{ label }}</div>
<div style="
font-size:12px;
padding: 2px 8px;
border-radius: 999px;
background: rgba(0,0,0,.04);
color: rgba(0,0,0,.65);
flex: 0 0 auto;">
live
</div>
</div>
<div
style="margin-top:4px; font-size:12.5px; color: rgba(0,0,0,.62); white-space:nowrap; overflow:hidden; text-overflow:ellipsis;">
{{ subtitle }}
</div>
<div
style="margin-top:10px; height:8px; border-radius:999px; background: rgba(0,0,0,.07); overflow:hidden;">
<div style="height:100%; width: {{ p }}%; background: {{ col }}; border-radius:999px;"></div>
</div>
</div>
</div>
{% endmacro %}
<h2
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("RAM", data.gauges.ram_pct, "All containers vs host RAM", (data.gauges.ram_used_h ~ " / " ~
data.gauges.ram_total_h)) }}
{{ donut("Docker disk", data.gauges.docker_images_pct, "Images used vs total store") }}
</div>
<h2 style="font-size: 22px; font-weight: 800; letter-spacing: -0.3px; color: #1e293b; margin-bottom: 16px;">💻
System</h2>
<div
style="display:grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin: 0 0 32px 0;">
<div style="
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 style="
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;">
⚡ 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 style="
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;">
🐳 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>
<h3 style="font-size: 18px; font-weight: 700; letter-spacing: -0.2px; color: #334155; margin: 32px 0 16px 0;">💾
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>
<tr>
<th
style="background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);">
Type</th>
<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>
</thead>
<tbody>
{% for typ, r in data.system.system_df.items() %}
<tr style="transition: background-color 0.2s ease;"
onmouseover="this.style.backgroundColor='rgba(102, 126, 234, 0.04)';"
onmouseout="this.style.backgroundColor='transparent';">
<td><strong style="color: #667eea;">{{ typ }}</strong></td>
<td style="color: #334155;">{{ r.total }}</td>
<td style="color: #334155;">{{ r.active }}</td>
<td style="color: #334155;">{{ r.size }}</td>
<td style="color: #334155;">{{ r.reclaimable }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div style="margin-top: 16px; color: #64748b; font-size: 13px; font-weight: 500;">⏱️ Generated at: {{
data.generated_at }}</div>
{% if data.warnings %}
<div style="
margin: 20px 0;
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 %}
<li style="margin: 6px 0;">{{ w }}</li>
{% endfor %}
</ul>
</div>
{% endif %}
<h2 style="font-size: 22px; font-weight: 800; letter-spacing: -0.3px; color: #1e293b; margin: 40px 0 16px 0;">🚀
Apps</h2>
<div style="overflow-x: auto; border-radius: 12px; border: 1px solid rgba(0,0,0,0.06);">
<table style="margin: 0;">
<thead>
<tr>
<th
style="background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);">
App</th>
<th
style="background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);">
URL</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>
</thead>
<tbody>
{% for r in data.apps %}
<tr style="transition: background-color 0.2s ease;"
onmouseover="this.style.backgroundColor='rgba(102, 126, 234, 0.04)';"
onmouseout="this.style.backgroundColor='transparent';">
<td><strong style="color: #667eea;">{{ r.app }}</strong></td>
<td><a href="{{ r.url }}"
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 %}
{{ r.mem_used }} / {{ r.mem_limit }} <span style="color: #667eea; font-weight: 600;">({{
r.mem_pct }})</span>
{% else %} — {% endif %}
</td>
<td style="color: #334155; font-weight: 600;">{{ r.restarts }}</td>
<td style="color: #64748b; font-size: 12px;">{{ r.image }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% if data.infra %}
<h2 style="font-size: 22px; font-weight: 800; letter-spacing: -0.3px; color: #1e293b; margin: 40px 0 16px 0;">
🏗️ Infra</h2>
<div style="overflow-x: auto; border-radius: 12px; border: 1px solid rgba(0,0,0,0.06);">
<table style="margin: 0;">
<thead>
<tr>
<th
style="background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);">
Container</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>
</thead>
<tbody>
{% for r in data.infra %}
<tr style="transition: background-color 0.2s ease;"
onmouseover="this.style.backgroundColor='rgba(102, 126, 234, 0.04)';"
onmouseout="this.style.backgroundColor='transparent';">
<td><strong style="color: #667eea;">{{ r.container }}</strong></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 %}
{{ r.mem_used }} / {{ r.mem_limit }} <span style="color: #667eea; font-weight: 600;">({{
r.mem_pct }})</span>
{% else %} — {% endif %}
</td>
<td style="color: #334155; font-weight: 600;">{{ r.restarts }}</td>
<td style="color: #64748b; font-size: 12px;">{{ r.image }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}