Compare commits

...
5 Commits
Author SHA1 Message Date
Sebi 383b63bc0e Merge pull request 'perf(console): faster dashboard for organizations with thousands of monitors' (#164) from perf/dashboard-large-orgs into main
release / release (push) In progress
ci / lint (push) In progress
ci / test (push) In progress
ci / build (push) Waiting for needed jobs
ci / image (push) Waiting for needed jobs
2026-11-26 20:55:38 +00:00
Sebi 42d741846d Merge pull request 'feat(statuspages): error page linking a home page set by admins' (#163) from feat/statuspage-not-found into main
ci / test (push) Canceled after 15s
ci / image (push) Canceled after 0s
ci / lint (push) Canceled after 27s
ci / build (push) Canceled after 0s
2026-11-26 20:54:49 +00:00
Sebastian UnterschützandClaude Opus 5.5 4fd11cb45b perf(console): 24 h bars from the hourly aggregate
ci / lint (push) Skipped
ci / image (push) Skipped
ci / image (pull_request) Waiting for needed jobs
ci / test (push) Skipped
ci / build (push) Skipped
ci / lint (pull_request) Successful in 7m5s
ci / build (pull_request) In progress
ci / test (pull_request) Successful in 13m31s
The default range bucketed raw results by 30 minutes: for the hundred or
so monitors a dashboard shows, half a million rows on every request. It
shows 24 hourly bars from the real-time hourly aggregate now (bars 150-230
ms to 18 ms locally, the page 570 KB to 335 KB for 3,500 monitors).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
2026-11-26 21:49:50 +01:00
Sebastian UnterschützandClaude Opus 5.5 ec33ef5c56 perf(console): faster dashboard for organizations with thousands of monitors
ci / build (pull_request) Canceled after 1m41s
ci / image (push) Skipped
ci / lint (push) Skipped
ci / build (push) Skipped
ci / test (push) Skipped
ci / lint (pull_request) Successful in 11m12s
ci / test (pull_request) Successful in 12m47s
ci / image (pull_request) Canceled after 0s
- The range picker no longer looks for the first result: on the real-time
  daily aggregate that aggregated the organization's recent raw results
  on every request. The oldest monitor's creation bounds the ranges now.
- Sorting worked out each row's key per comparison; it does so once now
  and moves each row once (40-60 ms to 5 ms for 3,500 monitors).
- The queries behind the monitor list run in parallel.
- The monitor API reads the latest results of the page's monitors only.
- The dashboard reports its steps in a Server-Timing header and logs
  them when it takes a second or more.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
2026-11-26 21:35:09 +01:00
Sebastian UnterschützandClaude Opus 5.5 1f90fe8470 feat(statuspages): error page linking a home page set by admins
ci / build (pull_request) Successful in 16m56s
ci / test (pull_request) Successful in 15m30s
ci / image (pull_request) Successful in 6m1s
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 6m52s
The bare status page domain and pages that do not exist answered with a
plain "404 page not found". They now show an error page with a button to
the platform's home page, which platform admins set under Admin. The
status page servers receive it with the page index and keep it across
restarts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
2026-11-26 20:37:59 +01:00
25 changed files with 1049 additions and 515 deletions

No files matched your search

+11 -5
View File
@@ -362,14 +362,20 @@ type PageRef struct {
Host string `json:"host,omitempty"`
}
// PageIndex lists the pages a status page server serves.
type PageIndex struct {
Pages []PageRef `json:"pages"`
// HomeURL is the platform's home page, which the server links from
// its error page; empty for none.
HomeURL string `json:"home_url,omitempty"`
}
// Pages lists every page this status page server serves, so it can keep
// them all cached before anyone visits.
func (c *Client) Pages(ctx context.Context) ([]PageRef, error) {
var out struct {
Pages []PageRef `json:"pages"`
}
func (c *Client) Pages(ctx context.Context) (PageIndex, error) {
var out PageIndex
err := c.do(ctx, http.MethodGet, "/pages/index", nil, &out)
return out.Pages, err
return out, err
}
// ErrNotFound means no published page matches.
+5
View File
@@ -318,6 +318,11 @@ var endpoints = []endpoint{
{method: "PUT", path: "/api/v1/admin/checker-network", tag: "Platform", summary: "Let platform checkers check private addresses or not",
description: "Unset, they may on self-hosted installations and may not in the cloud edition. Applies from each checker's next poll.",
perm: "platform admin", req: checkerNetwork{}, status: http.StatusNoContent},
{method: "GET", path: "/api/v1/admin/statuspage-home", tag: "Platform", summary: "The home page linked from the status page servers' error page", perm: "platform admin",
resp: statusPageHome{}},
{method: "PUT", path: "/api/v1/admin/statuspage-home", tag: "Platform", summary: "Set the home page linked from the status page servers' error page",
description: "Visitors of the bare status page domain and of pages that do not exist see an error page with a link to this URL. Empty links none.",
perm: "platform admin", req: statusPageHome{}, status: http.StatusNoContent},
{method: "GET", path: "/api/v1/admin/identity-providers", tag: "Platform", summary: "Identity providers for signing up and in",
description: "With the callback URL to register at each provider. Secrets are never returned.", perm: "platform admin",
resp: obj{"providers": []idpView{}, "callback_url": ""}},
+1
View File
@@ -111,6 +111,7 @@ var auditActions = map[string]string{
"PUT /api/v1/org/legal/:kind": "org.legal_update",
"PUT /api/v1/admin/check-types": "platform.check_types_update",
"PUT /api/v1/admin/checker-network": "platform.checker_network_update",
"PUT /api/v1/admin/statuspage-home": "platform.statuspage_home_update",
"PUT /api/v1/admin/limits": "platform.limits_update",
"POST /api/v1/admin/identity-providers": "platform.idp_create",
"PUT /api/v1/admin/identity-providers/:id": "platform.idp_update",
+70 -55
View File
@@ -19,6 +19,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/google/uuid"
"github.com/jackc/pgx/v5"
"golang.org/x/sync/errgroup"
"git.zb-server.de/ZB-Server/uptimesebi/internal/auth"
"git.zb-server.de/ZB-Server/uptimesebi/internal/authz"
@@ -72,8 +73,10 @@ func (s *Server) dashboard(c *gin.Context) {
return
}
v := web.DashboardView{Counts: map[web.Status]int{}, Empty: true}
timer := newStepTimer()
if p != nil && me.Policy == "" {
data, err := s.loadMonitorData(c.Request.Context(), p, web.RangeByKey(c.Query("range")))
timer.done("load")
if err != nil {
internalError(c, err)
return
@@ -84,21 +87,14 @@ func (s *Server) dashboard(c *gin.Context) {
if !s.dashboardPage(c, &v, data) {
return
}
timer.done("arrange")
if err := s.dashboardBars(c.Request.Context(), p, &v, &data); err != nil {
internalError(c, err)
return
}
timer.done("bars")
v.Range = data.rng.Key
var earliest time.Time
if err := s.db.Tx(c.Request.Context(), p.scope(), func(q *store.Queries) error {
var err error
earliest, err = earliestData(c.Request.Context(), q, p.Org.ID, data.now)
return err
}); err != nil {
internalError(c, err)
return
}
v.Ranges = rangeOptions(c, data.rng, earliest, data.now)
v.Ranges = rangeOptions(c, data.rng, data.firstCreated, data.now)
for _, m := range data.rows {
v.Counts[m.Status]++
if m.Unchecked {
@@ -111,7 +107,11 @@ func (s *Server) dashboard(c *gin.Context) {
}
slices.SortFunc(v.DeadRegions, func(a, b web.DeadRegion) int { return strings.Compare(a.Name, b.Name) })
}
timer.done("rest")
timer.header(c)
web.Render(c, http.StatusOK, web.Dashboard(s.pageFor(c, "console.monitors.title"), me, v))
timer.done("render")
timer.logIfSlow(c, s.log)
}
// dashboardBars loads the bars of the monitors v shows, and only those.
@@ -218,13 +218,28 @@ func (o monitorSort) key(m web.MonitorRow) cursor {
}
func (o monitorSort) sort(ms []web.MonitorRow) {
slices.SortFunc(ms, func(a, b web.MonitorRow) int {
ka, kb := o.key(a), o.key(b)
if c := strings.Compare(ka.S, kb.S); c != 0 {
// Keys are worked out once per row, not per comparison, and the rows
// moved once: with thousands of monitors sorting was a good part of
// the dashboard's time.
type keyed struct {
key, id string
i int
}
keys := make([]keyed, len(ms))
for i, m := range ms {
keys[i] = keyed{o.key(m).S, m.ID, i}
}
slices.SortFunc(keys, func(a, b keyed) int {
if c := strings.Compare(a.key, b.key); c != 0 {
return c
}
return strings.Compare(a.ID, b.ID)
return strings.Compare(a.id, b.id)
})
sorted := make([]web.MonitorRow, len(ms))
for i, k := range keys {
sorted[i] = ms[k.i]
}
copy(ms, sorted)
}
// dashboardStatuses are the statuses the dashboard counts, in order.
@@ -379,6 +394,11 @@ type monitorData struct {
regionOf map[uuid.UUID]store.Region
rng web.TimeRange
now time.Time
// firstCreated is when the oldest monitor was created: the monitor
// list offers no ranges reaching far before it. (Finding the first
// result instead read results of every monitor, slow for large
// organizations.)
firstCreated time.Time
// first is when the monitor of a detail page first reported, from
// any region; firstRegion the same per region.
first time.Time
@@ -423,25 +443,6 @@ func loadFirstData(ctx context.Context, q *store.Queries, org, monitor uuid.UUID
return first, perRegion, nil
}
// earliestData finds when any monitor of org first reported, for the
// ranges the monitor list offers: to the day if that was over two days
// ago, otherwise exactly.
func earliestData(ctx context.Context, q *store.Queries, org uuid.UUID, now time.Time) (time.Time, error) {
none := func(t time.Time, err error) (time.Time, bool, error) {
if errors.Is(err, pgx.ErrNoRows) {
return time.Time{}, false, nil
}
return t, err == nil, err
}
recentSince := now.Add(-2 * 24 * time.Hour)
daily, ok, err := none(q.EarliestDataDaily(ctx, org))
if err != nil || (ok && daily.Before(recentSince)) {
return daily, err
}
exact, _, err := none(q.EarliestDataRecent(ctx, store.EarliestDataRecentParams{OrgID: org, Time: recentSince}))
return exact, err
}
// rangeBuckets loads the selected range for the monitors ids.
func rangeBuckets(ctx context.Context, q *store.Queries, org uuid.UUID, ids []uuid.UUID, rng web.TimeRange, now time.Time) (map[uuid.UUID][]web.Bucket, error) {
out := map[uuid.UUID][]web.Bucket{}
@@ -498,39 +499,50 @@ func (s *Server) loadMonitorData(ctx context.Context, p *principal, rng web.Time
spans []store.IncidentsSinceRow
)
var groups []store.MonitorGroup
err := s.db.Tx(ctx, p.scope(), func(q *store.Queries) error {
// The queries run in parallel: for large organizations each takes a
// while, mostly to move its rows.
g, gctx := errgroup.WithContext(ctx)
tx := func(f func(q *store.Queries) error) {
g.Go(func() error { return s.db.Tx(gctx, p.scope(), f) })
}
tx(func(q *store.Queries) error {
var err error
if groups, err = q.ListGroups(ctx); err != nil {
if groups, err = q.ListGroups(gctx); err != nil {
return err
}
if monitors, err = q.ListMonitors(ctx, p.Org.ID); err != nil {
return err
}
if assigned, err = q.AllMonitorRegions(ctx, p.Org.ID); err != nil {
return err
}
if regions, err = q.ListVisibleRegions(ctx); err != nil {
return err
}
if latest, err = q.LatestResults(ctx, p.Org.ID); err != nil {
return err
}
if open, err = q.OpenIncidents(ctx, p.Org.ID); err != nil {
return err
}
if spans, err = q.IncidentsSince(ctx, store.IncidentsSinceParams{OrgID: p.Org.ID, ResolvedAt: ptr(now.Add(-web.SLAWindows[len(web.SLAWindows)-1].Window))}); err != nil {
return err
}
if d.statuses, err = loadCustomStatuses(ctx, q); err != nil {
if monitors, err = q.ListMonitors(gctx, p.Org.ID); err != nil {
return err
}
ids := make([]uuid.UUID, len(monitors))
for i, m := range monitors {
ids[i] = m.ID
}
d.maint, err = maintenanceFor(ctx, q, ids)
d.maint, err = maintenanceFor(gctx, q, ids)
return err
})
tx(func(q *store.Queries) (err error) {
assigned, err = q.AllMonitorRegions(gctx, p.Org.ID)
return err
})
tx(func(q *store.Queries) (err error) {
latest, err = q.LatestResults(gctx, p.Org.ID)
return err
})
tx(func(q *store.Queries) error {
var err error
if regions, err = q.ListVisibleRegions(gctx); err != nil {
return err
}
if open, err = q.OpenIncidents(gctx, p.Org.ID); err != nil {
return err
}
if spans, err = q.IncidentsSince(gctx, store.IncidentsSinceParams{OrgID: p.Org.ID, ResolvedAt: ptr(now.Add(-web.SLAWindows[len(web.SLAWindows)-1].Window))}); err != nil {
return err
}
d.statuses, err = loadCustomStatuses(gctx, q)
return err
})
err := g.Wait()
if err != nil {
return d, err
}
@@ -553,6 +565,9 @@ func (s *Server) loadMonitorData(ctx context.Context, p *principal, rng web.Time
if m.Enabled {
d.usedRegions = append(d.usedRegions, regionsOf[m.ID]...)
}
if d.firstCreated.IsZero() || m.CreatedAt.Before(d.firstCreated) {
d.firstCreated = m.CreatedAt
}
}
slices.SortFunc(d.usedRegions, func(a, b uuid.UUID) int { return strings.Compare(a.String(), b.String()) })
d.usedRegions = slices.Compact(d.usedRegions)
+5 -1
View File
@@ -224,7 +224,11 @@ func (s *Server) listMonitors(c *gin.Context) {
if err != nil {
return err
}
latest, err := q.LatestResults(ctx, p.Org.ID)
ids := make([]uuid.UUID, len(monitors))
for i, m := range monitors {
ids[i] = m.ID
}
latest, err := q.LatestResultsForMonitors(ctx, store.LatestResultsForMonitorsParams{OrgID: p.Org.ID, Ids: ids})
if err != nil {
return err
}
+1 -1
View File
@@ -625,7 +625,7 @@ func (s *Server) adminPage(c *gin.Context) {
for _, t := range check.Types {
types = append(types, web.CheckTypeOption{Type: string(t), Enabled: !off[string(t)]})
}
web.Render(c, http.StatusOK, web.AdminPage(s.pageFor(c, "admin.title"), me, v, storageView(c, stats), types, s.platformPrivate(ctx), webLimits(s.platformLimits(ctx)), s.idpAdminView(ctx)))
web.Render(c, http.StatusOK, web.AdminPage(s.pageFor(c, "admin.title"), me, v, storageView(c, stats), types, s.platformPrivate(ctx), s.statusPageHome(ctx), webLimits(s.platformLimits(ctx)), s.idpAdminView(ctx)))
}
func (s *Server) adminStatusPagesPage(c *gin.Context) {
+10 -2
View File
@@ -8,6 +8,7 @@ import (
"time"
"github.com/google/uuid"
"github.com/jackc/pgx/v5"
)
func TestTimeRangesAndSLA(t *testing.T) {
@@ -53,7 +54,7 @@ func TestTimeRangesAndSLA(t *testing.T) {
}
}
bars := map[string]int{"1h": 60, "3h": 36, "12h": 48, "24h": 48, "7d": 42, "30d": 60, "90d": 45, "180d": 45, "1y": 52}
bars := map[string]int{"1h": 60, "3h": 36, "12h": 48, "24h": 24, "7d": 42, "30d": 60, "90d": 45, "180d": 45, "1y": 52}
for key, n := range bars {
st, _, html := owner.page("/?range=" + key)
if st != http.StatusOK {
@@ -99,9 +100,16 @@ func TestRangeAvailabilityAndRegions(t *testing.T) {
id := uuid.MustParse(body["id"].(string))
org := uuid.MustParse(owner.orgID())
// Two hours of results: eu always fine, us always failing.
// Two hours of results: eu always fine, us always failing. (The
// monitor is as old as its results.)
ctx := context.Background()
now := time.Now()
if err := e.asSystem(t, func(tx pgx.Tx) error {
_, err := tx.Exec(ctx, `UPDATE monitors SET created_at = $1 WHERE id = $2`, now.Add(-121*time.Minute), id)
return err
}); err != nil {
t.Fatal(err)
}
checker := uuid.New()
for m := 0; m <= 120; m += 5 {
at := now.Add(-time.Duration(m) * time.Minute)
+5
View File
@@ -56,6 +56,8 @@ type Server struct {
limits *versioned[Limits]
// support caches how the platform runs support tickets.
support *versioned[supportSettings]
// pageHome caches the home page the status page servers link.
pageHome *versioned[string]
// draining, once closed, ends the long polls of checkers.
draining <-chan struct{}
// handler serves the requests agents send over their streams.
@@ -99,6 +101,7 @@ func New(cfg config.API, d Deps) *Server {
checkerNet: newVersioned[bool]("checker-network"),
limits: newVersioned[Limits]("limits"),
support: newVersioned[supportSettings]("support"),
pageHome: newVersioned[string]("statuspage-home"),
}
}
@@ -224,6 +227,8 @@ func (s *Server) Mount(r gin.IRouter) {
admin.PUT("/users/:id/suspension", s.adminSuspendUser)
admin.DELETE("/users/:id", s.adminDeleteUser)
admin.PUT("/checker-network", s.adminSetCheckerNetwork)
admin.GET("/statuspage-home", s.adminGetStatusPageHome)
admin.PUT("/statuspage-home", s.adminSetStatusPageHome)
admin.GET("/legal", s.adminListLegal)
admin.PUT("/legal/:kind", s.adminSaveLegal)
admin.GET("/regions", s.adminListRegions)
+77
View File
@@ -0,0 +1,77 @@
package api
import (
"context"
"encoding/json"
"errors"
"net/http"
"strings"
"github.com/gin-gonic/gin"
"github.com/jackc/pgx/v5"
"git.zb-server.de/ZB-Server/uptimesebi/internal/store"
"git.zb-server.de/ZB-Server/uptimesebi/internal/tenant"
)
// The status page servers answer visitors of pages that do not exist, and
// of their bare domain, with a page linking the platform's home page.
const settingStatusPageHome = "statuspage_home"
type statusPageHome struct {
// URL is the home page linked from the status page servers' error
// page; empty links none.
URL string `json:"url" binding:"max=2000"`
}
func (s *Server) statusPageHome(ctx context.Context) string {
v, err := s.pageHome.get(ctx, s.rdb, func(ctx context.Context) (string, error) {
var v statusPageHome
err := s.db.Tx(ctx, tenant.System(), func(q *store.Queries) error {
raw, err := q.GetPlatformSetting(ctx, settingStatusPageHome)
if errors.Is(err, pgx.ErrNoRows) {
return nil
}
if err != nil {
return err
}
return json.Unmarshal(raw, &v)
})
return v.URL, err
})
if err != nil {
s.log.WarnContext(ctx, "loading the status page home failed", "error", err)
return ""
}
return v
}
func (s *Server) adminGetStatusPageHome(c *gin.Context) {
c.JSON(http.StatusOK, statusPageHome{URL: s.statusPageHome(c.Request.Context())})
}
func (s *Server) adminSetStatusPageHome(c *gin.Context) {
var req statusPageHome
if !bind(c, &req) {
return
}
req.URL = strings.TrimSpace(req.URL)
if req.URL != "" && !validLegalURL(req.URL) {
fail(c, http.StatusUnprocessableEntity, "invalid_legal_url")
return
}
ctx := c.Request.Context()
raw, _ := json.Marshal(req)
auditDetail(c, "url", req.URL)
if err := s.db.Tx(ctx, tenant.System(), func(q *store.Queries) error {
return q.SetPlatformSetting(ctx, store.SetPlatformSettingParams{Key: settingStatusPageHome, Value: raw})
}); err != nil {
internalError(c, err)
return
}
if err := s.pageHome.bump(ctx, s.rdb); err != nil {
s.log.ErrorContext(ctx, "announcing the status page home failed", "error", err)
}
c.Status(http.StatusNoContent)
}
+46
View File
@@ -0,0 +1,46 @@
package api_test
import (
"context"
"net/http"
"strings"
"testing"
"git.zb-server.de/ZB-Server/uptimesebi/internal/store"
"git.zb-server.de/ZB-Server/uptimesebi/internal/tenant"
)
func TestStatusPageHome(t *testing.T) {
e := newEnv(t)
admin := e.browser(t)
admin.signup("a@"+uniq("home")+".test", uniq("home-"))
if err := tenant.New(e.dbPool).Tx(context.Background(), tenant.Global(), func(q *store.Queries) error {
return q.MakeAdmin(context.Background(), admin.userIDSelf())
}); err != nil {
t.Fatal(err)
}
t.Cleanup(func() { admin.do("PUT", "/api/v1/admin/statuspage-home", map[string]any{"url": ""}) })
pages := e.statuspageClient(t, nil)
st, body := admin.do("PUT", "/api/v1/admin/statuspage-home", map[string]any{"url": "javascript:alert(1)"})
expect(t, "script link", st, body, http.StatusUnprocessableEntity, "invalid_legal_url")
if st, body := admin.do("PUT", "/api/v1/admin/statuspage-home", map[string]any{"url": " https://example.test/ "}); st != http.StatusNoContent {
t.Fatalf("set home = %d %v", st, body)
}
if _, body := admin.do("GET", "/api/v1/admin/statuspage-home", nil); body["url"] != "https://example.test/" {
t.Errorf("home = %v", body)
}
index, err := pages.Pages(context.Background())
if err != nil || index.HomeURL != "https://example.test/" {
t.Errorf("page index home = %q %v", index.HomeURL, err)
}
if _, _, html := admin.page("/admin"); !strings.Contains(html, `value="https://example.test/"`) {
t.Error("the admin page does not show the home page")
}
owner := e.browser(t)
owner.signup("o@"+uniq("home")+".test", uniq("home-"))
if st, _ := owner.do("PUT", "/api/v1/admin/statuspage-home", map[string]any{"url": "https://evil.test/"}); st != http.StatusForbidden {
t.Errorf("non-admin sets the home page = %d, want 403", st)
}
}
+1 -1
View File
@@ -461,7 +461,7 @@ func (s *Server) agentPageIndex(c *gin.Context) {
for i, r := range rows {
out[i] = agentapi.PageRef{Slug: r.Slug, Host: r.Host}
}
c.JSON(http.StatusOK, gin.H{"pages": out})
c.JSON(http.StatusOK, agentapi.PageIndex{Pages: out, HomeURL: s.statusPageHome(ctx)})
}
type statusPageRequest struct {
+2 -1
View File
@@ -205,7 +205,8 @@ func TestStatusPages(t *testing.T) {
own := e.statuspageClient(t, &org)
lists := func(c *agentapi.Client) bool {
t.Helper()
refs, err := c.Pages(context.Background())
index, err := c.Pages(context.Background())
refs := index.Pages
if err != nil {
t.Fatal(err)
}
+61
View File
@@ -0,0 +1,61 @@
package api
import (
"fmt"
"log/slog"
"strings"
"time"
"github.com/gin-gonic/gin"
)
// slowPage is when a console page logs how long its steps took.
const slowPage = time.Second
// stepTimer measures the steps of a request. It reports them to the
// browser in a Server-Timing header and, when the request was slow, in
// the log.
type stepTimer struct {
start, last time.Time
steps []step
}
type step struct {
name string
d time.Duration
}
func newStepTimer() *stepTimer {
now := time.Now()
return &stepTimer{start: now, last: now}
}
// done ends the step name.
func (t *stepTimer) done(name string) {
now := time.Now()
t.steps = append(t.steps, step{name, now.Sub(t.last)})
t.last = now
}
// header sets the Server-Timing header of the steps so far; call it
// before the body is written.
func (t *stepTimer) header(c *gin.Context) {
parts := make([]string, len(t.steps))
for i, s := range t.steps {
parts[i] = fmt.Sprintf("%s;dur=%.1f", s.name, float64(s.d.Microseconds())/1000)
}
c.Header("Server-Timing", strings.Join(parts, ", "))
}
// logIfSlow logs the steps when the request took slowPage or longer.
func (t *stepTimer) logIfSlow(c *gin.Context, log *slog.Logger) {
total := time.Since(t.start)
if total < slowPage {
return
}
attrs := []any{"path", c.Request.URL.Path, "total_ms", total.Milliseconds()}
for _, s := range t.steps {
attrs = append(attrs, s.name+"_ms", s.d.Milliseconds())
}
log.WarnContext(c.Request.Context(), "slow console page", attrs...)
}
+8 -1
View File
@@ -1612,5 +1612,12 @@
"pages.subscribers_limit": "Neue Abos pro Woche für die Organisation: {{.Max}}",
"pages.feeds": "Feed und API",
"pages.feeds_hint": "Jede veröffentlichte Seite hat einen RSS-Feed und eine JSON-API zum Lesen, pro Besucher begrenzt:",
"audit.action.statuspage.subscriber_delete": "Abonnent einer Statusseite entfernt"
"audit.action.statuspage.subscriber_delete": "Abonnent einer Statusseite entfernt",
"page.not_found_title": "Seite nicht gefunden",
"page.not_found": "Unter dieser Adresse gibt es keine Statusseite, oder sie ist nicht veröffentlicht.",
"page.not_found_home": "Zur Hauptseite",
"admin.statuspage_home": "Hauptseite der Statusseiten",
"admin.statuspage_home_hint": "Wer die Statusseiten-Domain ohne Pfad oder eine Seite aufruft, die es nicht gibt, sieht eine Fehlerseite. Sie verlinkt diese Adresse, z. B. eure Website. Leer: kein Link.",
"admin.statuspage_home_url": "Adresse der Hauptseite",
"audit.action.platform.statuspage_home_update": "Hauptseite der Statusseiten geändert"
}
+8 -1
View File
@@ -1612,5 +1612,12 @@
"pages.subscribers_limit": "New subscriptions per week for the organization: {{.Max}}",
"pages.feeds": "Feed and API",
"pages.feeds_hint": "Every published page has an RSS feed and a read-only JSON API, rate limited per visitor:",
"audit.action.statuspage.subscriber_delete": "Status page subscriber removed"
"audit.action.statuspage.subscriber_delete": "Status page subscriber removed",
"page.not_found_title": "Page not found",
"page.not_found": "There is no status page at this address, or it is not published.",
"page.not_found_home": "Go to the home page",
"admin.statuspage_home": "Status page home",
"admin.statuspage_home_hint": "Visitors of the bare status page domain and of pages that do not exist see an error page. It links this address, e.g. your website. Empty: no link.",
"admin.statuspage_home_url": "Home page URL",
"audit.action.platform.statuspage_home_update": "Status page home changed"
}
+43 -5
View File
@@ -63,7 +63,7 @@ type Source interface {
// PageIfChanged answers agentapi.ErrNotModified when the page still
// has checksum.
PageIfChanged(ctx context.Context, host, slug, checksum string) (agentapi.PageSnapshot, error)
Pages(ctx context.Context) ([]agentapi.PageRef, error)
Pages(ctx context.Context) (agentapi.PageIndex, error)
}
// Server renders pages for one status page agent.
@@ -78,7 +78,9 @@ type Server struct {
dir string
now func() time.Time
mu sync.Mutex
mu sync.Mutex
// home is the platform's home page, linked from the error page.
home string
cache map[string]entry
refreshing map[string]bool
// again holds pages that changed while being refreshed, which are
@@ -161,9 +163,39 @@ func (s *Server) loadDisk() error {
if len(s.cache) > 0 {
s.log.Info("loaded cached status pages", "count", len(s.cache))
}
if raw, err := os.ReadFile(filepath.Join(s.dir, homeFile)); err == nil {
s.home = string(raw)
}
return nil
}
// homeFile keeps the home page across restarts; not .json, which are pages.
const homeFile = "home.url"
// setHome records the home page the error page links.
func (s *Server) setHome(url string) {
s.mu.Lock()
changed := s.home != url
s.home = url
s.mu.Unlock()
if changed && s.dir != "" {
if err := os.WriteFile(filepath.Join(s.dir, homeFile), []byte(url), 0o600); err != nil {
s.log.Warn("saving the home page failed", "error", err)
}
}
}
// notFound answers visitors of a page that does not exist with a page
// leading to the platform's home page.
func (s *Server) notFound(c *gin.Context) {
s.localizeRequest(c)
s.mu.Lock()
home := s.home
s.mu.Unlock()
c.Header("Cache-Control", "no-store")
web.Render(c, http.StatusNotFound, web.PublicNotFoundPage("/static/dist/app.css", home))
}
func (s *Server) fileFor(key string) string {
sum := sha256.Sum256([]byte(key))
return filepath.Join(s.dir, hex.EncodeToString(sum[:16])+".json")
@@ -237,7 +269,7 @@ func (s *Server) serve(c *gin.Context) {
key, base = "host:"+host, "/"
} else {
if len(parts) == 0 {
c.Status(http.StatusNotFound)
s.notFound(c)
return
}
slug, parts = parts[0], parts[1:]
@@ -261,7 +293,11 @@ func (s *Server) serve(c *gin.Context) {
}
e, ok := s.lookup(c.Request.Context(), key, host, slug)
if !ok {
c.Status(http.StatusNotFound)
if rt.kind == routeFeed || rt.kind == routeAPI {
c.Status(http.StatusNotFound)
} else {
s.notFound(c)
}
return
}
if rt.kind == routeLegal {
@@ -523,11 +559,13 @@ func (s *Server) Run(ctx context.Context) {
func (s *Server) Sync(ctx context.Context) {
ctx, cancel := context.WithTimeout(ctx, syncInterval)
defer cancel()
refs, err := s.src.Pages(ctx)
index, err := s.src.Pages(ctx)
if err != nil {
s.log.WarnContext(ctx, "listing status pages failed", "error", err)
return
}
s.setHome(index.HomeURL)
refs := index.Pages
todo := map[string]entry{}
s.mu.Lock()
for key, e := range s.cache {
+27 -6
View File
@@ -25,6 +25,7 @@ type fakeSource struct {
err error
delay time.Duration
pages map[string]agentapi.PageSnapshot
home string
}
// PageIfChanged counts calls and answers like the API, sending pages
@@ -65,16 +66,16 @@ func (f *fakeSource) page(ctx context.Context, host, slug string) (agentapi.Page
}
// Pages lists the fake's pages by their keys: "host|" or "|slug".
func (f *fakeSource) Pages(context.Context) ([]agentapi.PageRef, error) {
func (f *fakeSource) Pages(context.Context) (agentapi.PageIndex, error) {
f.mu.Lock()
defer f.mu.Unlock()
if f.err != nil {
return nil, f.err
return agentapi.PageIndex{}, f.err
}
var out []agentapi.PageRef
out := agentapi.PageIndex{HomeURL: f.home}
for k := range f.pages {
host, slug, _ := strings.Cut(k, "|")
out = append(out, agentapi.PageRef{Host: host, Slug: slug})
out.Pages = append(out.Pages, agentapi.PageRef{Host: host, Slug: slug})
}
return out, nil
}
@@ -128,6 +129,26 @@ func (h harness) get(host, path string) (int, string) {
return w.Code, w.Body.String()
}
// The error page links the platform's home page, also after a restart
// while the API is down.
func TestNotFoundLinksHome(t *testing.T) {
dir := t.TempDir()
now := time.Now()
src := newSource()
h := newHarness(t, src, dir, &now)
if code, body := h.get("status.example.test", "/"); code != 404 || strings.Contains(body, "Zur Hauptseite") {
t.Errorf("error page without a home page = %d, links one: %t", code, strings.Contains(body, "Zur Hauptseite"))
}
src.home = "https://example.test/"
h.srv.Sync(context.Background())
restarted := newHarness(t, &fakeSource{err: errors.New("connection refused")}, dir, &now)
for _, hs := range []harness{h, restarted} {
if code, body := hs.get("status.example.test", "/gone"); code != 404 || !strings.Contains(body, `href="https://example.test/"`) {
t.Errorf("error page = %d, lacks the link to the home page", code)
}
}
}
func TestRouting(t *testing.T) {
now := time.Now()
h := newHarness(t, newSource(), t.TempDir(), &now)
@@ -138,8 +159,8 @@ func TestRouting(t *testing.T) {
}{
{"status.example.test", "/acme", 200, "Acme status"},
{"status.example.test:8082", "/acme", 200, "Alle Systeme funktionieren"},
{"status.example.test", "/missing", 404, ""},
{"status.example.test", "/", 404, ""},
{"status.example.test", "/missing", 404, "Seite nicht gefunden"},
{"status.example.test", "/", 404, "Seite nicht gefunden"},
{"status.acme.test", "/", 200, "Acme on own domain"},
{"status.acme.test", "/acme", 404, ""},
{"other.test", "/", 404, ""},
-38
View File
@@ -124,44 +124,6 @@ func (q *Queries) DailyBucketsForMonitors(ctx context.Context, arg DailyBucketsF
return items, nil
}
const earliestDataDaily = `-- name: EarliestDataDaily :one
SELECT bucket::timestamptz AS first FROM check_results_1d WHERE org_id = $1 ORDER BY bucket LIMIT 1
`
// The day the organization's monitors first reported, if any did.
func (q *Queries) EarliestDataDaily(ctx context.Context, orgID uuid.UUID) (time.Time, error) {
row := q.db.QueryRow(ctx, earliestDataDaily, orgID)
var first time.Time
err := row.Scan(&first)
return first, err
}
const earliestDataRecent = `-- name: EarliestDataRecent :one
SELECT f.time FROM monitors m
CROSS JOIN LATERAL (
SELECT c.time FROM check_results c
WHERE c.org_id = $1 AND c.monitor_id = m.id AND c.time >= $2
ORDER BY c.time LIMIT 1
) f
WHERE m.org_id = $1
ORDER BY f.time LIMIT 1
`
type EarliestDataRecentParams struct {
OrgID uuid.UUID
Time time.Time
}
// When the organization's monitors first reported since $2, exactly: the
// first result of each monitor is found through its index, so the cost
// does not grow with the days of results.
func (q *Queries) EarliestDataRecent(ctx context.Context, arg EarliestDataRecentParams) (time.Time, error) {
row := q.db.QueryRow(ctx, earliestDataRecent, arg.OrgID, arg.Time)
var time time.Time
err := row.Scan(&time)
return time, err
}
const firstDataDaily = `-- name: FirstDataDaily :many
SELECT monitor_id, region, min(bucket)::timestamptz AS first
FROM check_results_1d
-6
View File
@@ -133,12 +133,6 @@ type Querier interface {
// for two days, after which only the verify button tries again. A verified
// one is checked daily, hourly once its record went missing.
DomainsToCheck(ctx context.Context, arg DomainsToCheckParams) ([]DomainsToCheckRow, error)
// The day the organization's monitors first reported, if any did.
EarliestDataDaily(ctx context.Context, orgID uuid.UUID) (time.Time, error)
// When the organization's monitors first reported since $2, exactly: the
// first result of each monitor is found through its index, so the cost
// does not grow with the days of results.
EarliestDataRecent(ctx context.Context, arg EarliestDataRecentParams) (time.Time, error)
EmailKeyTaken(ctx context.Context, emailKey *string) (bool, error)
EnableTOTP(ctx context.Context, arg EnableTOTPParams) error
EnqueueNotification(ctx context.Context, arg EnqueueNotificationParams) error
-17
View File
@@ -125,23 +125,6 @@ FROM check_results_1d
WHERE org_id = $1 AND monitor_id = $2
GROUP BY 1, 2;
-- name: EarliestDataDaily :one
-- The day the organization's monitors first reported, if any did.
SELECT bucket::timestamptz AS first FROM check_results_1d WHERE org_id = $1 ORDER BY bucket LIMIT 1;
-- name: EarliestDataRecent :one
-- When the organization's monitors first reported since $2, exactly: the
-- first result of each monitor is found through its index, so the cost
-- does not grow with the days of results.
SELECT f.time FROM monitors m
CROSS JOIN LATERAL (
SELECT c.time FROM check_results c
WHERE c.org_id = $1 AND c.monitor_id = m.id AND c.time >= $2
ORDER BY c.time LIMIT 1
) f
WHERE m.org_id = $1
ORDER BY f.time LIMIT 1;
-- name: FirstDataRecent :many
-- When each region of a monitor first reported since $3, exactly. Used for
-- data younger than the daily aggregate's resolution.
+32
View File
@@ -446,3 +446,35 @@ templ pageMaintenance(heading string, items []agentapi.PageMaintenance) {
</section>
}
}
// PublicNotFoundPage answers visitors of a status page that does not exist,
// and of the bare status page domain, with a link to the home page if set.
templ PublicNotFoundPage(cssHref, home string) {
<!DOCTYPE html>
<html lang={ i18n.Lang(ctx) }>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="robots" content="noindex"/>
<title>{ i18n.T(ctx, "page.not_found_title") }</title>
@faviconLinks()
<link rel="stylesheet" href={ cssHref }/>
</head>
<body class="min-h-screen">
<main class="mx-auto flex min-h-screen max-w-xl flex-col justify-center px-4 py-14 sm:px-6">
<p class="mb-3 font-mono text-xs text-muted">404</p>
<h1 class="mb-3 text-2xl font-semibold">{ i18n.T(ctx, "page.not_found_title") }</h1>
<p class="mb-8 text-muted">{ i18n.T(ctx, "page.not_found") }</p>
if home != "" {
<p>
<a href={ templ.SafeURL(home) } class="inline-block border border-ink px-4 py-2 text-sm hover:bg-ink hover:text-paper">{ i18n.T(ctx, "page.not_found_home") }</a>
</p>
}
<p class="mt-14 flex items-center gap-1 font-mono text-xs text-muted">
@brandMark("h-3.5 w-3.5")
UptimeSebi
</p>
</main>
</body>
</html>
}
+144
View File
@@ -2251,4 +2251,148 @@ func pageMaintenance(heading string, items []agentapi.PageMaintenance) templ.Com
})
}
// PublicNotFoundPage answers visitors of a status page that does not exist,
// and of the bare status page domain, with a link to the home page if set.
func PublicNotFoundPage(cssHref, home string) templ.Component {
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
return templ_7745c5c3_CtxErr
}
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
ctx = templ.ClearChildren(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 186, "<!doctype html><html lang=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var109 string
templ_7745c5c3_Var109, templ_7745c5c3_Err = templruntime.NewAttributeExpression(i18n.Lang(ctx)).Resolve(ctx)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 454, Col: 28}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var109)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 187, "\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><meta name=\"robots\" content=\"noindex\"><title>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var110 string
templ_7745c5c3_Var110, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "page.not_found_title"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 459, Col: 47}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var110))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 188, "</title>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = faviconLinks().Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 189, "<link rel=\"stylesheet\" href=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var111 string
templ_7745c5c3_Var111, templ_7745c5c3_Err = templruntime.NewAttributeExpression(cssHref).ResolveURL(ctx)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 461, Col: 40}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var111)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 190, "\"></head><body class=\"min-h-screen\"><main class=\"mx-auto flex min-h-screen max-w-xl flex-col justify-center px-4 py-14 sm:px-6\"><p class=\"mb-3 font-mono text-xs text-muted\">404</p><h1 class=\"mb-3 text-2xl font-semibold\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var112 string
templ_7745c5c3_Var112, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "page.not_found_title"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 466, Col: 81}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var112))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 191, "</h1><p class=\"mb-8 text-muted\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var113 string
templ_7745c5c3_Var113, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "page.not_found"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 467, Col: 62}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var113))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 192, "</p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if home != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 193, "<p><a href=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var114 string
templ_7745c5c3_Var114, templ_7745c5c3_Err = templruntime.NewAttributeExpression(templ.SafeURL(home)).ResolveURL(ctx)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 470, Col: 35}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var114)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 194, "\" class=\"inline-block border border-ink px-4 py-2 text-sm hover:bg-ink hover:text-paper\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var115 string
templ_7745c5c3_Var115, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "page.not_found_home"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 470, Col: 161}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var115))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 195, "</a></p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 196, "<p class=\"mt-14 flex items-center gap-1 font-mono text-xs text-muted\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = brandMark("h-3.5 w-3.5").Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 197, " UptimeSebi</p></main></body></html>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
var _ = templruntime.GeneratedTemplate
+1 -1
View File
@@ -33,7 +33,7 @@ var Ranges = []TimeRange{
{Key: "1h", Window: time.Hour, Bucket: time.Minute, Layout: "15:04"},
{Key: "3h", Window: 3 * time.Hour, Bucket: 5 * time.Minute, Layout: "15:04"},
{Key: "12h", Window: 12 * time.Hour, Bucket: 15 * time.Minute, Layout: "15:04"},
{Key: "24h", Window: day, Bucket: 30 * time.Minute, Layout: "01-02 15:04"},
{Key: "24h", Window: day, Bucket: time.Hour, Source: SourceHourly, Layout: "01-02 15:04"},
{Key: "7d", Window: 7 * day, Bucket: 4 * time.Hour, Source: SourceHourly, Layout: "01-02 15:04"},
{Key: "30d", Window: 30 * day, Bucket: 12 * time.Hour, Source: SourceHourly, Layout: "2006-01-02 15:04"},
{Key: "90d", Window: 90 * day, Bucket: 2 * day, Source: SourceDaily, Layout: "2006-01-02"},
+19 -1
View File
@@ -195,7 +195,7 @@ templ RegionsPage(p Page, me Me, v RegionsView) {
}
}
templ AdminPage(p Page, me Me, v RegionsView, storage StorageView, checkTypes []CheckTypeOption, platformPrivate bool, limits LimitsView, idps IDPAdminView) {
templ AdminPage(p Page, me Me, v RegionsView, storage StorageView, checkTypes []CheckTypeOption, platformPrivate bool, pageHome string, limits LimitsView, idps IDPAdminView) {
@consoleShell(p, me) {
@settingsHeading("admin.title", "admin.intro")
@adminLinks()
@@ -203,6 +203,7 @@ templ AdminPage(p Page, me Me, v RegionsView, storage StorageView, checkTypes []
@limitsSection(limits)
@regionsBody(v)
@checkerNetworkSection(platformPrivate)
@statusPageHomeSection(pageHome)
@checkTypesSection(checkTypes, "/admin/check-types", "/admin", "admin.check_types_intro")
@storageSection(storage)
}
@@ -228,6 +229,23 @@ templ checkerNetworkSection(allow bool) {
</section>
}
// statusPageHomeSection sets the home page the status page servers link
// from their error page.
templ statusPageHomeSection(url string) {
<section class="mt-12 max-w-3xl">
@sectionHeading("admin.statuspage_home")
<p class="mb-4 text-sm text-muted">{ i18n.T(ctx, "admin.statuspage_home_hint") }</p>
<form data-api="/admin/statuspage-home" data-method="put" data-next="/admin">
@formError()
<label class="mb-4 block">
<span class="mb-1 block text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "admin.statuspage_home_url") }</span>
<input class="w-full border border-rule bg-transparent px-2.5 py-1.5 outline-none focus:border-ink" type="url" name="url" value={ url } maxlength="2000" placeholder="https://example.com"/>
</label>
<button type="submit" class="border border-ink px-3 py-1.5 text-sm hover:bg-ink hover:text-paper">{ i18n.T(ctx, "common.save") }</button>
</form>
</section>
}
// checkTypesSection lets the platform or an organization choose the
// check types it offers.
templ checkTypesSection(types []CheckTypeOption, api, next, introID string) {
File diff suppressed because it is too large. Load diff