feat: rich dashboard with severity bars, heatmap, most flagged, live poll
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
{% block content %}
|
||||
<h1>Dashboard</h1>
|
||||
|
||||
<div hx-get="/api/v1/scans/stats" hx-trigger="every 30s" hx-swap="innerHTML">
|
||||
<div hx-get="/dashboard/stats" hx-trigger="every 30s" hx-swap="innerHTML">
|
||||
{% include "dashboard_stats.html" %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,31 +1,114 @@
|
||||
<div class="stats-grid">
|
||||
<article class="stat-card">
|
||||
<h5>{{ total_scans }}</h5>
|
||||
<h3>{{ total_scans }}</h3>
|
||||
<small>Total Scans</small>
|
||||
</article>
|
||||
<article class="stat-card">
|
||||
<h5 class="flagged">{{ flagged_scans }}</h5>
|
||||
<small>Flagged</small>
|
||||
<h3 class="flagged">{{ flagged_scans }}</h3>
|
||||
<small>⚠ Flagged</small>
|
||||
</article>
|
||||
<article class="stat-card">
|
||||
<h5 class="flagged">{{ recent_flagged }}</h5>
|
||||
<h3>{{ recent_flagged }}</h3>
|
||||
<small>Flagged (7 days)</small>
|
||||
</article>
|
||||
<article class="stat-card">
|
||||
<h5>{{ total_findings }}</h5>
|
||||
<h3>{{ total_findings }}</h3>
|
||||
<small>Total Findings</small>
|
||||
</article>
|
||||
<article class="stat-card">
|
||||
<h3 class="severity-ERROR">{{ errors_count }}</h3>
|
||||
<small>Errors</small>
|
||||
</article>
|
||||
<article class="stat-card">
|
||||
<h3 class="severity-WARNING">{{ warnings_count }}</h3>
|
||||
<small>Warnings</small>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
<h2>Latest Scans</h2>
|
||||
{% if total_findings > 0 %}
|
||||
<div style="margin-bottom: 2rem;">
|
||||
<small>Severity ratio</small>
|
||||
<div style="display: flex; height: 8px; border-radius: 4px; overflow: hidden; margin-top: 4px;">
|
||||
{% set err_pct = (errors_count / total_findings * 100) | int %}
|
||||
{% set warn_pct = 100 - err_pct %}
|
||||
<div style="width: {{ err_pct }}%; background: var(--pico-color-red-400);" title="ERROR: {{ errors_count }}"></div>
|
||||
<div style="width: {{ warn_pct }}%; background: var(--pico-color-yellow-400);" title="WARNING: {{ warnings_count }}"></div>
|
||||
</div>
|
||||
<div style="display: flex; justify-content: space-between; font-size: 0.75rem; margin-top: 2px;">
|
||||
<span class="severity-ERROR">ERROR {{ errors_count }}</span>
|
||||
<span class="severity-WARNING">WARNING {{ warnings_count }}</span>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if days %}
|
||||
<div style="margin-bottom: 2rem;">
|
||||
<small>Scan activity (14 days)</small>
|
||||
<div style="display: flex; align-items: flex-end; gap: 2px; height: 40px; margin-top: 4px;">
|
||||
{% set max_cnt = days | map(attribute=1) | max %}
|
||||
{% for day, cnt, fl in days %}
|
||||
<div style="flex: 1; display: flex; flex-direction: column; justify-content: flex-end;" title="{{ day }}: {{ cnt }} scans, {{ fl }} flagged">
|
||||
{% set h = (cnt / max_cnt * 38) | int if max_cnt > 0 else 0 %}
|
||||
<div style="height: {{ h }}px; background: {% if fl > 0 %}var(--pico-color-red-500){% else %}var(--pico-color-zinc-500){% endif %}; border-radius: 2px 2px 0 0; opacity: 0.8;"></div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if most_flagged %}
|
||||
<div style="margin-bottom: 2rem;">
|
||||
<h3>⚠ Most Flagged Packages</h3>
|
||||
<table>
|
||||
<thead>
|
||||
<tr><th>Package</th><th>Version</th><th>Findings</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for p in most_flagged %}
|
||||
<tr>
|
||||
<td><a href="/packages/{{ p.package_name }}/{{ p.package_version }}"><strong>{{ p.package_name }}</strong></a></td>
|
||||
<td>{{ p.package_version }}</td>
|
||||
<td>
|
||||
<span class="flagged">{{ p.total }}</span>
|
||||
<progress value="{{ p.total }}" max="{{ max_findings }}" style="width: 80px; height: 6px; vertical-align: middle; margin-left: 6px;"></progress>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if latest_flagged %}
|
||||
<div style="margin-bottom: 2rem;">
|
||||
<h3>🔴 Latest Flagged</h3>
|
||||
<table>
|
||||
<thead>
|
||||
<tr><th>Package</th><th>Version</th><th>Findings</th><th>Time</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for s in latest_flagged %}
|
||||
<tr>
|
||||
<td><a href="/scans/{{ s.id }}"><strong class="flagged">{{ s.package_name }}</strong></a></td>
|
||||
<td>{{ s.package_version }}</td>
|
||||
<td><span class="flagged">{{ s.total_findings }}</span></td>
|
||||
<td>{{ s.started_at.strftime('%m-%d %H:%M') if s.started_at }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<h3>Latest Scans</h3>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Package</th>
|
||||
<th>Version</th>
|
||||
<th>Ecosystem</th>
|
||||
<th>Repo</th>
|
||||
<th>Status</th>
|
||||
<th>Findings</th>
|
||||
<th></th>
|
||||
<th>Time</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -34,17 +117,18 @@
|
||||
<tr>
|
||||
<td><a href="/packages/{{ s.package_name }}/{{ s.package_version }}">{{ s.package_name }}</a></td>
|
||||
<td>{{ s.package_version }}</td>
|
||||
<td>{{ s.ecosystem }}</td>
|
||||
<td><small>{{ s.repository }}</small></td>
|
||||
<td><span class="status-{{ s.status }}">{{ s.status }}</span></td>
|
||||
<td>{% if s.flagged %}<span class="flagged">{{ s.total_findings }}</span>{% else %}<span class="clean">{{ s.total_findings }}</span>{% endif %}</td>
|
||||
<td>{{ s.started_at.strftime('%Y-%m-%d %H:%M') if s.started_at }}</td>
|
||||
<td>{% if s.flagged %}<span class="flagged">⚠ {{ s.total_findings }}</span>{% elif s.status == 'completed' %}<span class="clean">✓</span>{% else %}<span>-</span>{% endif %}</td>
|
||||
<td>{{ s.started_at.strftime('%m-%d %H:%M') if s.started_at }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<small><a href="/scans">View all scans →</a></small>
|
||||
|
||||
{% if top_rules %}
|
||||
<h2>Top Rules Triggered</h2>
|
||||
<h3>Top Rules Triggered</h3>
|
||||
<table>
|
||||
<thead><tr><th>Rule</th><th>Count</th></tr></thead>
|
||||
<tbody>
|
||||
@@ -54,3 +138,5 @@
|
||||
</tbody>
|
||||
</table>
|
||||
{% endif %}
|
||||
|
||||
<small style="opacity: 0.5;">Last refresh: {{ now.strftime('%H:%M:%S') }} (auto every 30s)</small>
|
||||
|
||||
Reference in New Issue
Block a user