feat(api): manage status pages with themes, custom domains and export

Organizations build pages from their monitors, grouped into sections
with public names, choose an accent color, logo and CSS, verify custom
domains with a TXT record and export a page as one self-contained HTML
file. Assignments scoped to a single status page are honored.

Closes #21
Closes #23
Closes #24

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-22 08:39:00 +01:00
1 parent 2b72715a9d
commit a6126b353e
15 files changed
+2382 -228

No files matched your search

+84
View File
@@ -31,6 +31,8 @@ func (s *Server) registerConsole(r gin.IRouter) {
r.GET("/monitors/:id/edit", s.orgPage("monitors.edit", authz.MonitorsWrite, s.monitorEditor))
r.GET("/incidents", s.orgPage("incidents.title", authz.IncidentsRead, s.incidentsView))
r.GET("/settings/channels", s.orgPage("channels.title", authz.NotificationsRead, s.channelsView))
r.GET("/statuspages", s.orgPage("pages.title", "", s.statusPagesView))
r.GET("/statuspages/:id", s.orgPage("pages.title", "", s.statusPageEditor))
}
// dashboard is the landing page. Unlike other console pages it renders for
@@ -426,3 +428,85 @@ func (s *Server) channelsView(c *gin.Context, p *principal, page web.Page, me we
}
return web.ChannelsPage(page, me, v), nil
}
func (s *Server) pageURL(p store.StatusPage) string {
if p.CustomDomain != nil && p.DomainVerifiedAt != nil {
return "https://" + *p.CustomDomain + "/"
}
return strings.TrimSuffix(s.cfg.StatusPageURL, "/") + "/" + p.Slug
}
func (s *Server) statusPagesView(c *gin.Context, p *principal, page web.Page, me web.Me) (templ.Component, error) {
ctx := c.Request.Context()
var rows []store.StatusPage
err := s.db.Tx(ctx, p.scope(), func(q *store.Queries) error {
var err error
rows, err = q.ListStatusPages(ctx)
return err
})
if err != nil {
return nil, err
}
v := web.PagesView{CanWrite: p.Grants.Can(authz.StatusPagesWrite)}
for _, r := range rows {
if !p.Grants.Can(authz.StatusPagesRead, pageResource(r.ID)) {
continue
}
v.Pages = append(v.Pages, web.PageRow{
ID: r.ID.String(), Title: r.Title, Slug: r.Slug, Published: r.Published,
URL: s.pageURL(r), Domain: deref(r.CustomDomain),
})
}
return web.StatusPagesPage(page, me, v), nil
}
func (s *Server) statusPageEditor(c *gin.Context, p *principal, page web.Page, me web.Me) (templ.Component, error) {
id, err := uuid.Parse(c.Param("id"))
if err != nil || !p.Grants.Can(authz.StatusPagesWrite, pageResource(id)) {
return notFoundPage(c)
}
ctx := c.Request.Context()
var (
row store.StatusPage
listed []store.StatusPageMonitorsRow
monitors []store.Monitor
)
err = s.db.Tx(ctx, p.scope(), func(q *store.Queries) error {
var err error
if row, err = q.GetStatusPage(ctx, id); err != nil {
return err
}
if listed, err = q.StatusPageMonitors(ctx, id); err != nil {
return err
}
monitors, err = q.ListMonitors(ctx)
return err
})
if errors.Is(err, pgx.ErrNoRows) {
return notFoundPage(c)
}
if err != nil {
return nil, err
}
v := viewStatusPage(row)
e := web.PageEditor{
ID: row.ID.String(), Title: row.Title, Slug: row.Slug, Description: row.Description,
Published: row.Published, Accent: v.Theme.Accent, LogoURL: v.Theme.LogoURL, CSS: v.Theme.CSS,
URL: s.pageURL(row), Domain: deref(row.CustomDomain), DomainVerified: v.DomainVerified,
}
if v.DomainRecord != nil {
e.RecordName, e.RecordValue = v.DomainRecord.Name, v.DomainRecord.Value
}
// Listed monitors keep their order; the rest follow alphabetically.
seen := map[uuid.UUID]bool{}
for _, l := range listed {
seen[l.MonitorID] = true
e.Monitors = append(e.Monitors, web.PageMonitorOption{ID: l.MonitorID.String(), Name: l.MonitorName, Included: true, Section: l.Section, Label: l.Label})
}
for _, m := range monitors {
if !seen[m.ID] {
e.Monitors = append(e.Monitors, web.PageMonitorOption{ID: m.ID.String(), Name: m.Name})
}
}
return web.StatusPageEditor(page, me, e), nil
}