feat: animated live gauge circles (PageSpeed-style)

Backend:
- Re-add --out json=- but properly route: JSON lines → metric
  aggregation, non-JSON lines → text log (summary text lands in log)
- Aggregate http_req_duration / http_reqs / http_req_failed / checks
  per test into live state (capped 50k samples)
- Broadcast { metrics: {...} } SSE events every second with
  score, checksRate, httpOkRate, p90/p95/p99, req/s etc.
- computeScore() composite 0-100 based on p95 + error rate

Frontend:
- 3 animated SVG ring gauges: Score (/100), Checks OK (%), HTTP OK (%)
- Smooth CSS transition on stroke-dashoffset (0.7s cubic-bezier)
- Pulse animation while test is live, stops on completion
- Color: green ≥90/98/99, yellow mid-range, red below thresholds
- Stats strip: Requests, Req/s, Avg, p(90), p(95), p(99)
- p(95) cell color-coded green/yellow/red vs latency
- Threshold pass/fail banner at bottom of gauges panel
- Raw output collapsed in <details> by default
- History items show mini score ring gauge (44px) inline
- History detail expands 3 medium gauges + stat grid

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-01 20:24:59 +02:00
parent cf51a4620b
commit 175ba3ec7a
4 changed files with 645 additions and 229 deletions

View File

@@ -21,7 +21,7 @@ body {
min-height: 100vh;
}
.app { max-width: 900px; margin: 0 auto; padding: 2rem 1.5rem; }
.app { max-width: 920px; margin: 0 auto; padding: 2rem 1.5rem; }
header {
display: flex;
@@ -33,7 +33,6 @@ header {
}
h1 { font-size: 1.6rem; font-weight: 700; color: var(--accent2); }
nav { display: flex; gap: .5rem; }
.tab-btn {
@@ -46,25 +45,24 @@ nav { display: flex; gap: .5rem; }
font-size: .9rem;
transition: all .15s;
}
.tab-btn:hover { color: var(--text); border-color: var(--accent); }
.tab-btn:hover { color: var(--text); border-color: var(--accent); }
.tab-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.tab { display: none; }
.tab.active { display: block; }
/* FORM */
/* ── FORM ───────────────────────────────────────────────────────────────────── */
.form-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1.2rem;
margin-bottom: 1.5rem;
}
.form-group { display: flex; flex-direction: column; gap: .4rem; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: .85rem; color: var(--muted); font-weight: 500; }
.hint { font-weight: 400; font-size: .78rem; }
.hint { font-weight: 400; font-size: .78rem; color: var(--muted); }
input[type=url],
input[type=text],
@@ -85,7 +83,7 @@ input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { font-family: var(--mono); resize: vertical; }
.range-row { display: flex; align-items: center; gap: .75rem; }
.range-row input[type=range] { flex: 1; accent-color: var(--accent); }
.range-row input[type=range] { flex: 1; accent-color: var(--accent); }
.range-row input[type=number] { width: 80px; flex-shrink: 0; }
.btn-primary {
@@ -99,7 +97,7 @@ textarea { font-family: var(--mono); resize: vertical; }
cursor: pointer;
transition: background .15s, opacity .15s;
}
.btn-primary:hover { background: #6d28d9; }
.btn-primary:hover { background: #6d28d9; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-secondary {
@@ -112,6 +110,7 @@ textarea { font-family: var(--mono); resize: vertical; }
cursor: pointer;
transition: background .15s;
}
.btn-secondary:hover { background: rgba(124,58,237,.15); }
/* TOGGLE SWITCH */
.toggle-row { display: flex; align-items: center; gap: .75rem; margin-top: .15rem; }
@@ -138,23 +137,6 @@ textarea { font-family: var(--mono); resize: vertical; }
.toggle input:checked + .toggle-track::after { transform: translateX(18px); }
.toggle-label { font-size: .88rem; color: var(--text); }
/* PILLS */
.pill {
display: inline-block;
font-size: .72rem;
font-weight: 600;
padding: .15rem .5rem;
border-radius: 999px;
letter-spacing: .04em;
}
.pill.cached { background: rgba(34,197,94,.12); color: #4ade80; }
.pill.no-cache { background: rgba(245,158,11,.12); color: #fbbf24; }
.pill.bust { background: rgba(239,68,68,.12); color: #f87171; }
.pill.gzip { background: rgba(124,58,237,.15); color: var(--accent2); }
.pill.no-gzip { background: rgba(100,116,139,.12); color: var(--muted); }
.pill.desktop { background: rgba(56,189,248,.12); color: #38bdf8; }
.pill.mobile { background: rgba(251,146,60,.12); color: #fb923c; }
/* DEVICE TOGGLE */
.device-toggle { display: flex; gap: 0; margin-top: .15rem; }
.device-toggle input[type=radio] { display: none; }
@@ -172,83 +154,214 @@ textarea { font-family: var(--mono); resize: vertical; }
.device-btn:first-of-type { border-radius: 6px 0 0 6px; }
.device-btn:last-of-type { border-radius: 0 6px 6px 0; border-left: none; }
.device-toggle input[type=radio]:checked + .device-btn {
background: var(--accent);
color: #fff;
border-color: var(--accent);
background: var(--accent); color: #fff; border-color: var(--accent);
}
.btn-secondary:hover { background: rgba(124,58,237,.15); }
/* RESULT */
/* PILLS */
.pill {
display: inline-block;
font-size: .72rem;
font-weight: 600;
padding: .15rem .5rem;
border-radius: 999px;
letter-spacing: .04em;
}
.pill.cached { background: rgba(34,197,94,.12); color: #4ade80; }
.pill.no-cache { background: rgba(245,158,11,.12); color: #fbbf24; }
.pill.bust { background: rgba(239,68,68,.12); color: #f87171; }
.pill.gzip { background: rgba(124,58,237,.15); color: var(--accent2); }
.pill.no-gzip { background: rgba(100,116,139,.12); color: var(--muted); }
.pill.desktop { background: rgba(56,189,248,.12); color: #38bdf8; }
.pill.mobile { background: rgba(251,146,60,.12); color: #fb923c; }
/* ── RESULT HEADER ──────────────────────────────────────────────────────────── */
.result-header {
display: flex;
align-items: center;
gap: 1rem;
margin: 2rem 0 1rem;
margin: 2rem 0 1.5rem;
}
.result-header h2 { font-size: 1.1rem; }
.badge {
font-size: .75rem;
font-weight: 600;
font-size: .75rem; font-weight: 600;
padding: .25rem .65rem;
border-radius: 999px;
text-transform: uppercase;
letter-spacing: .05em;
}
.badge.running { background: rgba(245,158,11,.15); color: var(--yellow); }
.badge.completed{ background: rgba(34,197,94,.15); color: var(--green); }
.badge.failed { background: rgba(239,68,68,.15); color: var(--red); }
.badge.running { background: rgba(245,158,11,.15); color: var(--yellow); }
.badge.completed { background: rgba(34,197,94,.15); color: var(--green); }
.badge.failed { background: rgba(239,68,68,.15); color: var(--red); }
#output-log {
background: #0a0c12;
/* ── GAUGE CIRCLES ──────────────────────────────────────────────────────────── */
#gauges-panel {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 8px;
padding: 1rem;
font-family: var(--mono);
font-size: .8rem;
line-height: 1.6;
max-height: 400px;
overflow-y: auto;
white-space: pre-wrap;
word-break: break-all;
color: #a5f3fc;
border-radius: 12px;
padding: 1.5rem 1rem 1.2rem;
margin-bottom: 1rem;
}
/* THRESHOLD BANNER */
.threshold-banner {
.gauges-main {
display: flex;
justify-content: center;
gap: 2.5rem;
flex-wrap: wrap;
margin-bottom: 1.5rem;
}
.gauge-wrap {
position: relative;
width: 130px;
flex-shrink: 0;
}
.gauge-svg {
width: 130px;
height: 130px;
transform: rotate(-90deg);
overflow: visible;
}
.gauge-track {
fill: none;
stroke: var(--border);
stroke-width: 8;
}
.gauge-ring {
fill: none;
stroke: var(--border);
stroke-width: 8;
stroke-linecap: round;
stroke-dasharray: 314.16;
stroke-dashoffset: 314.16;
transition: stroke-dashoffset .7s cubic-bezier(.4,0,.2,1),
stroke .5s ease;
filter: drop-shadow(0 0 5px currentColor);
}
/* Pulse animation while test is live */
@keyframes gauge-pulse {
0%, 100% { opacity: 1; }
50% { opacity: .7; }
}
#gauges-panel.live .gauge-ring {
animation: gauge-pulse 2s ease-in-out infinite;
}
.gauge-inner {
position: absolute;
inset: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
pointer-events: none;
}
.gauge-value {
font-size: 2rem;
font-weight: 800;
font-family: var(--mono);
line-height: 1;
}
.gauge-sub {
font-size: .75rem;
color: var(--muted);
margin-top: .1rem;
}
.gauge-title {
font-size: .72rem;
color: var(--muted);
text-transform: uppercase;
letter-spacing: .06em;
margin-top: .35rem;
}
/* ── STATS STRIP ────────────────────────────────────────────────────────────── */
.stats-strip {
display: grid;
grid-template-columns: repeat(6, 1fr);
gap: .5rem;
border-top: 1px solid var(--border);
padding-top: 1rem;
}
.stat-cell {
display: flex;
flex-direction: column;
align-items: center;
gap: .2rem;
}
.sc-val {
font-size: 1.05rem;
font-weight: 700;
font-family: var(--mono);
transition: color .4s;
}
.sc-lbl {
font-size: .68rem;
color: var(--muted);
text-transform: uppercase;
letter-spacing: .05em;
}
/* ── THRESHOLD BANNER ───────────────────────────────────────────────────────── */
#threshold-banner {
border-radius: 8px;
padding: .85rem 1rem;
margin-bottom: 1rem;
margin-top: 1rem;
border: 1px solid;
}
.threshold-banner.pass { background: rgba(34,197,94,.08); border-color: rgba(34,197,94,.3); color: var(--green); }
.threshold-banner.fail { background: rgba(239,68,68,.08); border-color: rgba(239,68,68,.3); color: var(--red); }
.threshold-banner ul { list-style: none; margin-top: .4rem; padding: 0; }
.threshold-banner li { font-size: .85rem; padding: .15rem 0; font-family: var(--mono); }
.threshold-banner ul { list-style: none; margin-top: .4rem; padding: 0; }
.threshold-banner li { font-size: .85rem; padding: .15rem 0; font-family: var(--mono); }
.threshold-banner li.pass { color: var(--green); }
.threshold-banner li.fail { color: var(--red); }
/* SUMMARY CARDS */
#summary-cards { margin-top: .5rem; }
.summary-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
gap: 1rem;
margin-top: .75rem;
}
.summary-card {
background: var(--surface);
/* ── COLLAPSIBLE LOG ────────────────────────────────────────────────────────── */
#log-details {
margin-top: 1rem;
border: 1px solid var(--border);
border-radius: 8px;
padding: 1rem;
overflow: hidden;
}
.summary-card .label { font-size: .75rem; color: var(--muted); margin-bottom: .3rem; }
.summary-card .value { font-size: 1.2rem; font-weight: 700; font-family: var(--mono); }
.summary-card .value.good { color: var(--green); }
.summary-card .value.bad { color: var(--red); }
.summary-card .value.info { color: var(--accent2); }
#log-details summary {
padding: .6rem 1rem;
cursor: pointer;
font-size: .85rem;
color: var(--muted);
user-select: none;
list-style: none;
display: flex;
align-items: center;
gap: .5rem;
}
#log-details summary::before {
content: '▶';
font-size: .7rem;
transition: transform .15s;
}
#log-details[open] summary::before { transform: rotate(90deg); }
#log-details summary:hover { color: var(--text); background: rgba(255,255,255,.02); }
/* HISTORY */
#output-log {
background: #0a0c12;
padding: 1rem;
font-family: var(--mono);
font-size: .78rem;
line-height: 1.6;
max-height: 380px;
overflow-y: auto;
white-space: pre-wrap;
word-break: break-all;
color: #a5f3fc;
border-top: 1px solid var(--border);
}
/* ── HISTORY ────────────────────────────────────────────────────────────────── */
.history-header {
display: flex;
align-items: center;
@@ -259,67 +372,135 @@ textarea { font-family: var(--mono); resize: vertical; }
.history-item {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 8px;
padding: 1rem 1.2rem;
border-radius: 10px;
padding: .9rem 1.1rem;
margin-bottom: .75rem;
display: grid;
grid-template-columns: 1fr auto;
gap: .5rem;
grid-template-columns: 48px 1fr auto;
gap: .85rem;
align-items: center;
cursor: pointer;
transition: border-color .15s;
}
.history-item:hover { border-color: var(--accent); }
.history-item .row1 {
.history-left { display: flex; align-items: center; justify-content: center; }
.mini-gauge { width: 44px; height: 44px; overflow: visible; }
.history-body { min-width: 0; }
.history-body .row1 {
display: flex;
align-items: center;
gap: .75rem;
gap: .6rem;
flex-wrap: wrap;
}
.history-item .url { font-weight: 600; word-break: break-all; }
.history-item .meta { font-size: .8rem; color: var(--muted); }
.history-body .url { font-weight: 600; word-break: break-all; font-size: .9rem; }
.history-body .meta { font-size: .78rem; color: var(--muted); }
.history-summary { font-size: .78rem; color: var(--muted); margin-top: .3rem; font-family: var(--mono); }
.history-item .actions { display: flex; align-items: flex-start; gap: .5rem; }
.history-item .btn-del {
.history-item .actions { display: flex; align-items: center; }
.btn-del {
background: transparent;
border: none;
color: var(--muted);
cursor: pointer;
font-size: 1rem;
line-height: 1;
padding: .2rem;
padding: .25rem;
border-radius: 4px;
transition: color .15s;
}
.history-item .btn-del:hover { color: var(--red); }
.history-summary { font-size: .8rem; color: var(--muted); margin-top: .4rem; font-family: var(--mono); }
.btn-del:hover { color: var(--red); }
.empty { color: var(--muted); font-size: .9rem; }
/* Detail modal / inline */
/* ── HISTORY DETAIL ─────────────────────────────────────────────────────────── */
#history-detail {
margin-top: 1rem;
background: var(--surface);
border: 1px solid var(--border);
border-radius: 8px;
border: 1px solid var(--accent);
border-radius: 10px;
padding: 1.2rem;
margin-bottom: .75rem;
}
.detail-title {
font-size: .95rem;
font-weight: 600;
margin-bottom: 1rem;
color: var(--accent2);
word-break: break-all;
}
.detail-gauges {
display: flex;
gap: 1.5rem;
justify-content: center;
flex-wrap: wrap;
margin-bottom: 1rem;
}
.dg-wrap { position: relative; width: 80px; text-align: center; }
.dg-svg { width: 80px; height: 80px; transform: rotate(-90deg); overflow: visible; }
.dg-inner {
position: absolute;
inset: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.dg-val { font-size: 1.2rem; font-weight: 800; font-family: var(--mono); line-height: 1; }
.dg-unit { font-size: .65rem; color: var(--muted); }
.dg-title { font-size: .6rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-top: .3rem; }
.detail-stats {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
gap: .5rem;
margin-bottom: 1rem;
}
.detail-stat {
background: var(--bg);
border: 1px solid var(--border);
border-radius: 6px;
padding: .5rem .6rem;
display: flex;
flex-direction: column;
align-items: center;
gap: .2rem;
}
.ds-val { font-size: .95rem; font-weight: 700; font-family: var(--mono); }
.ds-lbl { font-size: .65rem; color: var(--muted); text-transform: uppercase; }
#history-detail details { margin-top: .5rem; }
#history-detail details summary {
cursor: pointer;
font-size: .82rem;
color: var(--muted);
padding: .3rem 0;
user-select: none;
list-style: none;
}
#history-detail details summary:hover { color: var(--text); }
#history-detail pre {
background: #0a0c12;
border: 1px solid var(--border);
border-radius: 6px;
padding: .75rem;
font-family: var(--mono);
font-size: .78rem;
max-height: 350px;
font-size: .75rem;
max-height: 300px;
overflow-y: auto;
white-space: pre-wrap;
color: #a5f3fc;
margin-top: .75rem;
margin-top: .5rem;
}
@media (max-width: 600px) {
.form-grid { grid-template-columns: 1fr; }
/* ── RESPONSIVE ─────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
.form-grid { grid-template-columns: 1fr; }
.form-group.full { grid-column: 1; }
.stats-strip { grid-template-columns: repeat(3, 1fr); }
.gauges-main { gap: 1.5rem; }
.gauge-wrap, .gauge-svg { width: 110px; height: 110px; }
.gauge-value { font-size: 1.6rem; }
.history-item { grid-template-columns: 40px 1fr auto; }
}