diff --git a/cmd/statuspage/main.go b/cmd/statuspage/main.go index 7c74a50..149838e 100644 --- a/cmd/statuspage/main.go +++ b/cmd/statuspage/main.go @@ -14,7 +14,9 @@ import ( "git.zb-server.de/ZB-Server/uptimesebi/internal/agentapi" "git.zb-server.de/ZB-Server/uptimesebi/internal/buildinfo" "git.zb-server.de/ZB-Server/uptimesebi/internal/config" + "git.zb-server.de/ZB-Server/uptimesebi/internal/i18n" "git.zb-server.de/ZB-Server/uptimesebi/internal/platform" + "git.zb-server.de/ZB-Server/uptimesebi/internal/statuspage" "git.zb-server.de/ZB-Server/uptimesebi/internal/web" ) @@ -49,12 +51,17 @@ func run(log *slog.Logger, level *slog.LevelVar) error { return fmt.Errorf("token belongs to a %s agent, not a status page server", hello.Kind) } + catalog, err := i18n.Load() + if err != nil { + return err + } health := platform.NewHealth(map[string]platform.Probe{ "api": func(ctx context.Context) error { _, err := client.Hello(ctx); return err }, }) r := platform.NewRouter(log) health.Register(r) r.StaticFS("/static", web.Static()) + statuspage.New(client, catalog, log, cfg.Hosts).Mount(r) return platform.Serve(ctx, log, platform.NewHTTPServer(cfg.Listen, r), health, 5*time.Second, cfg.ShutdownTimeout) } diff --git a/internal/agentapi/agentapi.go b/internal/agentapi/agentapi.go index b1b8cd0..d9df484 100644 --- a/internal/agentapi/agentapi.go +++ b/internal/agentapi/agentapi.go @@ -147,6 +147,8 @@ func (c *Client) do(ctx context.Context, method, path string, in, out any) error switch { case resp.StatusCode == http.StatusUnauthorized: return ErrUnauthorized + case resp.StatusCode == http.StatusNotFound: + return ErrNotFound case resp.StatusCode >= 300: msg, _ := io.ReadAll(io.LimitReader(resp.Body, 1024)) return fmt.Errorf("agentapi: %s %s: %d %s", method, path, resp.StatusCode, bytes.TrimSpace(msg)) diff --git a/internal/agentapi/pages.go b/internal/agentapi/pages.go new file mode 100644 index 0000000..b74ec44 --- /dev/null +++ b/internal/agentapi/pages.go @@ -0,0 +1,83 @@ +package agentapi + +import ( + "context" + "errors" + "net/http" + "net/url" + "time" +) + +// Page states, from best to worst. +const ( + PageOperational = "operational" + PageDegraded = "degraded" + PageOutage = "outage" + PageUnknown = "unknown" +) + +// Theme customizes a page. +type Theme struct { + // Accent is a #rrggbb color for headings and links. + Accent string `json:"accent,omitempty"` + LogoURL string `json:"logo_url,omitempty"` + // CSS is appended to the page's styles. + CSS string `json:"css,omitempty"` +} + +// Day is one bar of a component's 90-day history. Uptime is -1 without data. +type Day struct { + Date string `json:"date"` + Uptime float64 `json:"uptime"` +} + +// Component is one monitor as the public sees it. Targets, check details +// and error messages stay private. +type Component struct { + Name string `json:"name"` + Status string `json:"status"` + Uptime float64 `json:"uptime"` + Days []Day `json:"days"` +} + +// Section groups components under a heading; the first may be unnamed. +type Section struct { + Name string `json:"name"` + Components []Component `json:"components"` +} + +// PageIncident is an incident of a listed component. +type PageIncident struct { + Component string `json:"component"` + StartedAt time.Time `json:"started_at"` + ResolvedAt *time.Time `json:"resolved_at,omitempty"` +} + +// PageSnapshot is everything needed to render a status page. +type PageSnapshot struct { + Slug string `json:"slug"` + Title string `json:"title"` + Description string `json:"description"` + Theme Theme `json:"theme"` + Status string `json:"status"` + Sections []Section `json:"sections"` + Incidents []PageIncident `json:"incidents"` + GeneratedAt time.Time `json:"generated_at"` +} + +// ErrNotFound means no published page matches. +var ErrNotFound = errors.New("agentapi: not found") + +// Page fetches the published page for a custom domain host, or for slug if +// host is empty. +func (c *Client) Page(ctx context.Context, host, slug string) (PageSnapshot, error) { + q := url.Values{} + if host != "" { + q.Set("host", host) + } else { + q.Set("slug", slug) + } + var p PageSnapshot + err := c.do(ctx, http.MethodGet, "/pages?"+q.Encode(), nil, &p) + return p, err +} diff --git a/internal/statuspage/statuspage.go b/internal/statuspage/statuspage.go new file mode 100644 index 0000000..895a96c --- /dev/null +++ b/internal/statuspage/statuspage.go @@ -0,0 +1,143 @@ +// Package statuspage serves public status pages from snapshots fetched +// through the agent API. It keeps a short in-memory cache and keeps serving +// the last snapshot for a while if the API is unreachable, so a page stays +// up during the incidents it is meant to report. +package statuspage + +import ( + "context" + "errors" + "log/slog" + "net" + "net/http" + "strings" + "sync" + "time" + + "github.com/gin-gonic/gin" + + "git.zb-server.de/ZB-Server/uptimesebi/internal/agentapi" + "git.zb-server.de/ZB-Server/uptimesebi/internal/i18n" + "git.zb-server.de/ZB-Server/uptimesebi/internal/web" +) + +const ( + freshFor = 30 * time.Second + staleFor = 10 * time.Minute +) + +// Source fetches snapshots; *agentapi.Client implements it. +type Source interface { + Page(ctx context.Context, host, slug string) (agentapi.PageSnapshot, error) +} + +// Server renders pages for one status page agent. +type Server struct { + src Source + catalog *i18n.Catalog + log *slog.Logger + // ownHosts are the hosts that serve pages by slug; any other host is + // looked up as a custom domain. + ownHosts map[string]bool + now func() time.Time + + mu sync.Mutex + cache map[string]entry +} + +type entry struct { + snap agentapi.PageSnapshot + missing bool + fetched time.Time +} + +// New returns a Server. ownHosts lists the host names of the default +// domain, e.g. "status.example.com"; requests to other hosts are matched +// against verified custom domains. +func New(src Source, catalog *i18n.Catalog, log *slog.Logger, ownHosts []string) *Server { + s := &Server{src: src, catalog: catalog, log: log, ownHosts: map[string]bool{}, now: time.Now, cache: map[string]entry{}} + for _, h := range ownHosts { + s.ownHosts[strings.ToLower(h)] = true + } + return s +} + +// Mount registers the page routes. +func (s *Server) Mount(r *gin.Engine) { + r.NoRoute(s.serve) +} + +// IsCustomDomain reports whether host is served as a custom domain. +func (s *Server) IsCustomDomain(host string) bool { + return !s.ownHosts[hostOnly(host)] +} + +func hostOnly(h string) string { + if host, _, err := net.SplitHostPort(h); err == nil { + h = host + } + return strings.ToLower(strings.TrimSuffix(h, ".")) +} + +func (s *Server) serve(c *gin.Context) { + if c.Request.Method != http.MethodGet && c.Request.Method != http.MethodHead { + c.Status(http.StatusMethodNotAllowed) + return + } + host := hostOnly(c.Request.Host) + var key, slug string + switch { + case s.IsCustomDomain(host): + if c.Request.URL.Path != "/" { + c.Status(http.StatusNotFound) + return + } + key = "host:" + host + default: + slug = strings.Trim(c.Request.URL.Path, "/") + if slug == "" || strings.Contains(slug, "/") { + c.Status(http.StatusNotFound) + return + } + key = "slug:" + slug + host = "" + } + snap, ok := s.snapshot(c.Request.Context(), key, host, slug) + if !ok { + c.Status(http.StatusNotFound) + return + } + l := s.catalog.Match(c.GetHeader("Accept-Language")) + c.Request = c.Request.WithContext(i18n.NewContext(c.Request.Context(), l)) + c.Header("Cache-Control", "public, max-age=30") + c.Header("Content-Language", l.Lang()) + web.Render(c, http.StatusOK, web.PublicStatusPage(snap, web.PublicAssets{CSSHref: "/static/dist/app.css"})) +} + +func (s *Server) snapshot(ctx context.Context, key, host, slug string) (agentapi.PageSnapshot, bool) { + now := s.now() + s.mu.Lock() + e, cached := s.cache[key] + s.mu.Unlock() + if cached && now.Sub(e.fetched) < freshFor { + return e.snap, !e.missing + } + snap, err := s.src.Page(ctx, host, slug) + switch { + case err == nil: + e = entry{snap: snap, fetched: now} + case errors.Is(err, agentapi.ErrNotFound): + e = entry{missing: true, fetched: now} + default: + if cached && now.Sub(e.fetched) < staleFor { + s.log.WarnContext(ctx, "serving stale status page", "page", key, "error", err) + return e.snap, !e.missing + } + s.log.ErrorContext(ctx, "fetching status page failed", "page", key, "error", err) + return agentapi.PageSnapshot{}, false + } + s.mu.Lock() + s.cache[key] = e + s.mu.Unlock() + return e.snap, !e.missing +} diff --git a/internal/statuspage/statuspage_test.go b/internal/statuspage/statuspage_test.go new file mode 100644 index 0000000..796e780 --- /dev/null +++ b/internal/statuspage/statuspage_test.go @@ -0,0 +1,104 @@ +package statuspage + +import ( + "context" + "errors" + "log/slog" + "net/http" + "net/http/httptest" + "strings" + "testing" + "time" + + "github.com/gin-gonic/gin" + + "git.zb-server.de/ZB-Server/uptimesebi/internal/agentapi" + "git.zb-server.de/ZB-Server/uptimesebi/internal/i18n" +) + +type fakeSource struct { + calls int + err error + pages map[string]agentapi.PageSnapshot +} + +func (f *fakeSource) Page(_ context.Context, host, slug string) (agentapi.PageSnapshot, error) { + f.calls++ + if f.err != nil { + return agentapi.PageSnapshot{}, f.err + } + p, ok := f.pages[host+"|"+slug] + if !ok { + return p, agentapi.ErrNotFound + } + return p, nil +} + +func newTest(t *testing.T) (*Server, *fakeSource, *gin.Engine, *time.Time) { + t.Helper() + cat, err := i18n.Load() + if err != nil { + t.Fatal(err) + } + src := &fakeSource{pages: map[string]agentapi.PageSnapshot{ + "|acme": {Title: "Acme status", Status: agentapi.PageOperational}, + "status.acme.test|": {Title: "Acme on own domain", Status: agentapi.PageOutage}, + }} + s := New(src, cat, slog.New(slog.DiscardHandler), []string{"status.example.test"}) + now := time.Now() + s.now = func() time.Time { return now } + gin.SetMode(gin.TestMode) + r := gin.New() + s.Mount(r) + return s, src, r, &now +} + +func get(r http.Handler, host, path string) (int, string) { + req := httptest.NewRequest(http.MethodGet, path, nil) + req.Host = host + req.Header.Set("Accept-Language", "de") + w := httptest.NewRecorder() + r.ServeHTTP(w, req) + return w.Code, w.Body.String() +} + +func TestRouting(t *testing.T) { + _, _, r, _ := newTest(t) + tests := []struct { + host, path string + want int + contains string + }{ + {"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.acme.test", "/", 200, "Acme on own domain"}, + {"status.acme.test", "/acme", 404, ""}, + {"other.test", "/", 404, ""}, + } + for _, tt := range tests { + code, body := get(r, tt.host, tt.path) + if code != tt.want || !strings.Contains(body, tt.contains) { + t.Errorf("GET %s%s = %d (contains %q: %t), want %d", tt.host, tt.path, code, tt.contains, strings.Contains(body, tt.contains), tt.want) + } + } +} + +func TestCacheAndStaleFallback(t *testing.T) { + _, src, r, now := newTest(t) + get(r, "status.example.test", "/acme") + get(r, "status.example.test", "/acme") + if src.calls != 1 { + t.Errorf("source calls within freshness window = %d, want 1", src.calls) + } + src.err = errors.New("api down") + *now = now.Add(time.Minute) + if code, body := get(r, "status.example.test", "/acme"); code != 200 || !strings.Contains(body, "Acme status") { + t.Errorf("GET with API down = %d, want stale page", code) + } + *now = now.Add(time.Hour) + if code, _ := get(r, "status.example.test", "/acme"); code != 404 { + t.Errorf("GET with API down long after = %d, want 404", code) + } +} diff --git a/internal/web/public.go b/internal/web/public.go new file mode 100644 index 0000000..7a853f6 --- /dev/null +++ b/internal/web/public.go @@ -0,0 +1,54 @@ +package web + +import ( + "io/fs" + + "git.zb-server.de/ZB-Server/uptimesebi/internal/agentapi" +) + +// PublicAssets decides how a public status page loads its stylesheet: +// linked from the status page server or inlined for a static export. +type PublicAssets struct { + CSSHref string + InlineCSS string +} + +// StylesheetText returns the built stylesheet for inlining. +func StylesheetText() (string, error) { + b, err := fs.ReadFile(static, "static/dist/app.css") + return string(b), err +} + +// DayBars turns a component's history into bars. +func DayBars(days []agentapi.Day) []Bar { + out := make([]Bar, len(days)) + for i, d := range days { + if d.Uptime < 0 { + out[i] = Bar{Status: StatusUnknown, Title: d.Date + " · –"} + continue + } + out[i] = Bar{Status: ratioStatus(d.Uptime), Title: d.Date + " · " + Percent(d.Uptime)} + } + return out +} + +// PageStatus maps a page state to the chart statuses used for colors. +func PageStatus(s string) Status { + switch s { + case agentapi.PageOperational: + return StatusUp + case agentapi.PageDegraded: + return StatusDegraded + case agentapi.PageOutage: + return StatusDown + } + return StatusUnknown +} + +// UptimeText formats a component's 90-day uptime. +func UptimeText(r float64) string { + if r < 0 { + return "–" + } + return Percent(r) +} diff --git a/internal/web/public.templ b/internal/web/public.templ new file mode 100644 index 0000000..f507fe1 --- /dev/null +++ b/internal/web/public.templ @@ -0,0 +1,107 @@ +package web + +import ( + "time" + + "git.zb-server.de/ZB-Server/uptimesebi/internal/agentapi" + "git.zb-server.de/ZB-Server/uptimesebi/internal/i18n" +) + +templ PublicStatusPage(s agentapi.PageSnapshot, a PublicAssets) { + + + + + + + { s.Title } + if a.InlineCSS != "" { + @templ.Raw("") + } else { + + } + if s.Theme.Accent != "" { + @templ.Raw("") + } + if s.Theme.CSS != "" { + @templ.Raw("") + } + + +
+
+ if s.Theme.LogoURL != "" { + { + } +

{ s.Title }

+ if s.Description != "" { +

{ s.Description }

+ } +
+
+

{ i18n.T(ctx, "page.status."+s.Status) }

+
+ for _, sec := range s.Sections { +
+ if sec.Name != "" { +

{ sec.Name }

+ } + +
+ } +
+

{ i18n.T(ctx, "page.incidents") }

+ if len(s.Incidents) == 0 { +

{ i18n.T(ctx, "page.no_incidents") }

+ } else { + + } +
+ +
+ + +} diff --git a/internal/web/public_templ.go b/internal/web/public_templ.go new file mode 100644 index 0000000..cc22856 --- /dev/null +++ b/internal/web/public_templ.go @@ -0,0 +1,517 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.3.1118 + +package web + +//lint:file-ignore SA4006 This context is only used if a nested component is present. + +import "github.com/a-h/templ" +import templruntime "github.com/a-h/templ/runtime" + +import ( + "time" + + "git.zb-server.de/ZB-Server/uptimesebi/internal/agentapi" + "git.zb-server.de/ZB-Server/uptimesebi/internal/i18n" +) + +func PublicStatusPage(s agentapi.PageSnapshot, a PublicAssets) 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, 1, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var3 string + templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(s.Title) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 17, Col: 19} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if a.InlineCSS != "" { + templ_7745c5c3_Err = templ.Raw("").Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + if s.Theme.Accent != "" { + templ_7745c5c3_Err = templ.Raw("").Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + if s.Theme.CSS != "" { + templ_7745c5c3_Err = templ.Raw("").Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if s.Theme.LogoURL != "" { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "\"")") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var7 string + templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(s.Title) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 36, Col: 90} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if s.Description != "" { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var8 string + templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(s.Description) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 38, Col: 48} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + { + templ_7745c5c3_ElementWriter := templ_7745c5c3_Buffer + templ_7745c5c3_Buffer := templ.GetBuffer() + var templ_7745c5c3_ElementScripts []templ.ComponentScript + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var11 string + templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "page.status."+s.Status)) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 48, Col: 74} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + for _, sec := range s.Sections { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if sec.Name != "" { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var12 string + templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(sec.Name) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 53, Col: 90} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var18 string + templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "page.incidents")) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 75, Col: 109} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if len(s.Incidents) == 0 { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var19 string + templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "page.no_incidents")) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 77, Col: 70} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 49, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +var _ = templruntime.GeneratedTemplate