ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 6m4s
ci / test (pull_request) Successful in 11m52s
ci / build (pull_request) Successful in 17m48s
ci / image (pull_request) Successful in 5m28s
- The console header folds its navigation into a menu below 1024px. - Pages use narrower gutters on phones. - Monitor rows keep name and uptime in place on narrow screens. - Toolbars and the range switch wrap. - Tables scroll sideways instead of squeezing their columns. - Form fields keep 16px text on touch screens so iOS does not zoom in. - The status page footer wraps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
230 lines
7.2 KiB
Templ
230 lines
7.2 KiB
Templ
package web
|
||
|
||
import (
|
||
"strconv"
|
||
|
||
"git.zb-server.de/ZB-Server/uptimesebi/internal/i18n"
|
||
)
|
||
|
||
// EvidenceView shows what a checker saw of one HTTP exchange.
|
||
type EvidenceView struct {
|
||
MonitorID string
|
||
MonitorName string
|
||
Time string
|
||
Region string
|
||
OK bool
|
||
Error string
|
||
// FailedAt is the catalog key of the stage a failed exchange stopped
|
||
// in, or empty.
|
||
FailedAt string
|
||
RemoteAddr string
|
||
Phases []TimingPhase
|
||
Total string
|
||
Steps []EvidenceStep
|
||
TLS *TLSView
|
||
ContentType string
|
||
Body string
|
||
Truncated bool
|
||
Binary bool
|
||
}
|
||
|
||
// TimingPhase is one part of the request time; Percent sizes its bar.
|
||
type TimingPhase struct {
|
||
Key string
|
||
Value string
|
||
Percent float64
|
||
}
|
||
|
||
// EvidenceStep is one request and response of the redirect chain.
|
||
type EvidenceStep struct {
|
||
Method string
|
||
URL string
|
||
Status string
|
||
Proto string
|
||
RequestHeaders [][2]string
|
||
ResponseHeaders [][2]string
|
||
}
|
||
|
||
// TLSView describes the server certificate.
|
||
type TLSView struct {
|
||
Version string
|
||
Cipher string
|
||
Subject string
|
||
Issuer string
|
||
Names string
|
||
NotBefore string
|
||
NotAfter string
|
||
DaysLeft int
|
||
}
|
||
|
||
// EvidenceRow links to evidence from the monitor page.
|
||
type EvidenceRow struct {
|
||
URL string
|
||
Time string
|
||
Region string
|
||
OK bool
|
||
Detail string
|
||
}
|
||
|
||
templ evidenceList(rows []EvidenceRow) {
|
||
<section class="mb-10">
|
||
@sectionHeading("evidence.title")
|
||
<p class="mb-3 max-w-2xl text-xs text-muted">{ i18n.T(ctx, "evidence.intro") }</p>
|
||
<ul class="divide-y divide-rule border-y border-rule text-sm">
|
||
for _, r := range rows {
|
||
<li>
|
||
<a href={ templ.SafeURL(r.URL) } class="grid grid-cols-[8rem_8rem_1rem_1fr] items-center gap-3 py-1.5 hover:bg-rule/30">
|
||
<span class="font-mono text-xs text-muted">{ r.Time }</span>
|
||
<span class="truncate">{ r.Region }</span>
|
||
if r.OK {
|
||
<span class="text-up">●</span>
|
||
} else {
|
||
<span class="text-down">●</span>
|
||
}
|
||
<span class="truncate font-mono text-xs text-muted">{ r.Detail }</span>
|
||
</a>
|
||
</li>
|
||
}
|
||
</ul>
|
||
</section>
|
||
}
|
||
|
||
templ headerTable(rows [][2]string) {
|
||
<div class="overflow-x-auto">
|
||
<table class="w-full text-left font-mono text-xs">
|
||
<tbody>
|
||
for _, h := range rows {
|
||
<tr class="align-top">
|
||
<td class="w-1/3 py-0.5 pr-3 text-muted">{ h[0] }</td>
|
||
<td class="break-all py-0.5">{ h[1] }</td>
|
||
</tr>
|
||
}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
}
|
||
|
||
templ EvidencePage(p Page, me Me, v EvidenceView) {
|
||
@consoleShell(p, me) {
|
||
<p class="mb-4 text-sm">
|
||
<a href={ templ.SafeURL("/monitors/" + v.MonitorID) } class="text-muted hover:text-ink">← { v.MonitorName }</a>
|
||
</p>
|
||
<h1 class="mb-1 flex items-center gap-2.5 text-lg font-semibold">
|
||
if v.OK {
|
||
@statusDot(StatusUp)
|
||
} else {
|
||
@statusDot(StatusDown)
|
||
}
|
||
{ i18n.T(ctx, "evidence.heading") }
|
||
</h1>
|
||
<p class="mb-8 font-mono text-xs text-muted">
|
||
{ v.Time } · { v.Region }
|
||
if v.RemoteAddr != "" {
|
||
{ " · " + v.RemoteAddr }
|
||
}
|
||
</p>
|
||
if !v.OK {
|
||
<p class="mb-8 border-l-2 border-down pl-3 text-sm">
|
||
{ v.Error }
|
||
if v.FailedAt != "" {
|
||
<span class="block text-xs text-muted">{ i18n.T(ctx, "evidence.failed_at", "Stage", i18n.T(ctx, "evidence.stage_"+v.FailedAt)) }</span>
|
||
}
|
||
</p>
|
||
}
|
||
<section class="mb-10">
|
||
@sectionHeading("evidence.timing")
|
||
<div class="mb-2 flex h-3 w-full overflow-hidden bg-rule/40" role="img" aria-label={ i18n.T(ctx, "evidence.timing") }>
|
||
for i, ph := range v.Phases {
|
||
<div class={ "h-full", timingColor(i) } style={ widthStyle(ph.Percent) } title={ i18n.T(ctx, "evidence.phase_"+ph.Key) + " " + ph.Value }></div>
|
||
}
|
||
</div>
|
||
<dl class="grid grid-cols-3 gap-x-4 gap-y-1 font-mono text-xs sm:grid-cols-6">
|
||
for i, ph := range v.Phases {
|
||
<div>
|
||
<dt class="flex items-center gap-1.5 text-muted"><span class={ "inline-block h-2 w-2", timingColor(i) }></span>{ i18n.T(ctx, "evidence.phase_"+ph.Key) }</dt>
|
||
<dd>{ ph.Value }</dd>
|
||
</div>
|
||
}
|
||
<div>
|
||
<dt class="text-muted">{ i18n.T(ctx, "evidence.total") }</dt>
|
||
<dd>{ v.Total }</dd>
|
||
</div>
|
||
</dl>
|
||
</section>
|
||
<section class="mb-10">
|
||
@sectionHeading("evidence.chain")
|
||
<ol class="space-y-3">
|
||
for i, st := range v.Steps {
|
||
<li class="border border-rule">
|
||
<div class="flex flex-wrap items-baseline gap-x-3 gap-y-1 px-3 py-2 text-sm">
|
||
<span class="font-mono text-xs text-muted">{ strconv.Itoa(i + 1) }</span>
|
||
<span class="font-mono text-xs">{ st.Method }</span>
|
||
<span class="min-w-0 flex-1 break-all font-mono text-xs">{ st.URL }</span>
|
||
if st.Status != "" {
|
||
<span class="font-mono text-xs">{ st.Status } <span class="text-muted">{ st.Proto }</span></span>
|
||
} else {
|
||
<span class="font-mono text-xs text-down">{ i18n.T(ctx, "evidence.no_response") }</span>
|
||
}
|
||
</div>
|
||
<details class="border-t border-rule px-3 py-2">
|
||
<summary class="cursor-pointer text-xs text-muted">{ i18n.T(ctx, "evidence.headers") }</summary>
|
||
<div class="mt-2 grid gap-4 md:grid-cols-2">
|
||
<div>
|
||
<h3 class="mb-1 text-xs text-muted">{ i18n.T(ctx, "evidence.request") }</h3>
|
||
@headerTable(st.RequestHeaders)
|
||
</div>
|
||
<div>
|
||
<h3 class="mb-1 text-xs text-muted">{ i18n.T(ctx, "evidence.response") }</h3>
|
||
@headerTable(st.ResponseHeaders)
|
||
</div>
|
||
</div>
|
||
</details>
|
||
</li>
|
||
}
|
||
</ol>
|
||
</section>
|
||
if v.TLS != nil {
|
||
<section class="mb-10">
|
||
@sectionHeading("evidence.certificate")
|
||
<dl class="grid gap-x-6 gap-y-1 text-sm sm:grid-cols-[10rem_1fr]">
|
||
<dt class="text-muted">{ i18n.T(ctx, "evidence.cert_subject") }</dt>
|
||
<dd class="break-all font-mono text-xs">{ v.TLS.Subject }</dd>
|
||
<dt class="text-muted">{ i18n.T(ctx, "evidence.cert_names") }</dt>
|
||
<dd class="break-all font-mono text-xs">{ v.TLS.Names }</dd>
|
||
<dt class="text-muted">{ i18n.T(ctx, "evidence.cert_issuer") }</dt>
|
||
<dd class="break-all font-mono text-xs">{ v.TLS.Issuer }</dd>
|
||
<dt class="text-muted">{ i18n.T(ctx, "evidence.cert_valid") }</dt>
|
||
<dd class="font-mono text-xs">
|
||
{ v.TLS.NotBefore } – { v.TLS.NotAfter }
|
||
<span class={ templ.KV("text-down", v.TLS.DaysLeft < 14), templ.KV("text-muted", v.TLS.DaysLeft >= 14) }>
|
||
if v.TLS.DaysLeft < 0 {
|
||
{ i18n.T(ctx, "evidence.cert_expired") }
|
||
} else {
|
||
{ i18n.T(ctx, "evidence.cert_days_left", "Count", v.TLS.DaysLeft) }
|
||
}
|
||
</span>
|
||
</dd>
|
||
<dt class="text-muted">{ i18n.T(ctx, "evidence.tls_version") }</dt>
|
||
<dd class="font-mono text-xs">{ v.TLS.Version } · { v.TLS.Cipher }</dd>
|
||
</dl>
|
||
</section>
|
||
}
|
||
<section class="mb-10">
|
||
@sectionHeading("evidence.body")
|
||
if v.Binary {
|
||
<p class="text-sm text-muted">{ i18n.T(ctx, "evidence.body_binary") }</p>
|
||
} else if v.Body == "" {
|
||
<p class="text-sm text-muted">{ i18n.T(ctx, "evidence.body_empty") }</p>
|
||
} else {
|
||
<p class="mb-2 font-mono text-xs text-muted">
|
||
{ v.ContentType }
|
||
if v.Truncated {
|
||
{ " · " + i18n.T(ctx, "evidence.body_truncated") }
|
||
}
|
||
</p>
|
||
<pre class="max-h-[32rem] overflow-auto border border-rule px-3 py-2 font-mono text-xs leading-relaxed whitespace-pre-wrap break-all">{ v.Body }</pre>
|
||
}
|
||
</section>
|
||
}
|
||
}
|