Every recent check on a monitor page names and links the checker instance that ran it. The checker page shows whether it is active, its version, the checks it runs right now and has queued, and the viewer's latest results on it, refreshing every five seconds. Platform checkers serve all organizations, so other organizations' work appears only as a count. Checks in progress are tracked in Redis between handing out a job and receiving its result. Closes #82 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
107 lines
3.0 KiB
Templ
107 lines
3.0 KiB
Templ
package web
|
|
|
|
import (
|
|
"strconv"
|
|
|
|
"git.zb-server.de/ZB-Server/uptimesebi/internal/i18n"
|
|
)
|
|
|
|
// Page carries what every rendered page needs besides its own content.
|
|
type Page struct {
|
|
TitleID string
|
|
CSRF string
|
|
Languages []string
|
|
// ErrorID and NoticeID name catalog messages shown above the content,
|
|
// typically after a redirect back from an SSO flow.
|
|
ErrorID string
|
|
NoticeID string
|
|
// Legal links the platform's legal notice and privacy policy.
|
|
Legal []LegalLink
|
|
// RefreshSeconds reloads pages that show live state.
|
|
RefreshSeconds int
|
|
}
|
|
|
|
templ Layout(p Page) {
|
|
<!DOCTYPE html>
|
|
<html lang={ i18n.Lang(ctx) }>
|
|
<head>
|
|
<meta charset="utf-8"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
if p.CSRF != "" {
|
|
<meta name="csrf-token" content={ p.CSRF }/>
|
|
}
|
|
if p.RefreshSeconds > 0 {
|
|
<meta http-equiv="refresh" content={ strconv.Itoa(p.RefreshSeconds) }/>
|
|
}
|
|
<title>{ i18n.T(ctx, p.TitleID) } · uptimesebi</title>
|
|
<link rel="stylesheet" href="/static/dist/app.css"/>
|
|
<script src="/static/dist/axios.min.js" defer></script>
|
|
<script src="/static/dist/app.js" defer></script>
|
|
</head>
|
|
<body class="flex min-h-screen flex-col" data-msg-network={ i18n.T(ctx, "app.network_error") }>
|
|
<div class="flex-1">
|
|
{ children... }
|
|
</div>
|
|
@legalFooter(p.Legal)
|
|
</body>
|
|
</html>
|
|
}
|
|
|
|
templ languageSwitch(langs []string) {
|
|
<span class="flex gap-2 font-mono text-xs">
|
|
for _, l := range langs {
|
|
if l == i18n.Lang(ctx) {
|
|
<span class="text-ink" aria-current="true">{ l }</span>
|
|
} else {
|
|
<button type="button" data-locale={ l } class="text-muted hover:text-ink" title={ i18n.T(ctx, "lang."+l) }>{ l }</button>
|
|
}
|
|
}
|
|
</span>
|
|
}
|
|
|
|
templ authShell(p Page) {
|
|
@Layout(p) {
|
|
<main class="mx-auto mt-[12vh] w-full max-w-sm px-6">
|
|
<div class="mb-10 flex items-baseline justify-between">
|
|
<p class="font-mono text-xs tracking-wide text-muted">uptimesebi</p>
|
|
@languageSwitch(p.Languages)
|
|
</div>
|
|
<h1 class="mb-6 text-xl font-semibold">{ i18n.T(ctx, p.TitleID) }</h1>
|
|
@flash(p)
|
|
{ children... }
|
|
</main>
|
|
}
|
|
}
|
|
|
|
templ field(label, name, typ, autocomplete string, required bool) {
|
|
<label class="mb-4 block">
|
|
<span class="mb-1 block text-xs font-medium uppercase tracking-wider text-muted">{ label }</span>
|
|
<input
|
|
class="w-full border border-rule bg-transparent px-2.5 py-1.5 outline-none focus:border-ink"
|
|
type={ typ }
|
|
name={ name }
|
|
autocomplete={ autocomplete }
|
|
required?={ required }
|
|
/>
|
|
</label>
|
|
}
|
|
|
|
templ submit(label string) {
|
|
<button type="submit" class="mt-2 w-full bg-ink px-3 py-2 text-sm font-medium text-paper hover:opacity-90 disabled:opacity-50">
|
|
{ label }
|
|
</button>
|
|
}
|
|
|
|
templ flash(p Page) {
|
|
if p.ErrorID != "" {
|
|
<p class="mb-6 border-l-2 border-down pl-2 text-sm text-down">{ i18n.T(ctx, p.ErrorID) }</p>
|
|
}
|
|
if p.NoticeID != "" {
|
|
<p class="mb-6 border-l-2 border-up pl-2 text-sm">{ i18n.T(ctx, p.NoticeID) }</p>
|
|
}
|
|
}
|
|
|
|
templ formError() {
|
|
<p data-error class="mb-4 hidden border-l-2 border-down pl-2 text-sm text-down"></p>
|
|
}
|