feat: page long and truncated lists
ci / image (pull_request) Successful in 3m18s
ci / build (pull_request) Successful in 8m38s
ci / test (pull_request) Successful in 12m6s
ci / lint (pull_request) Successful in 15m0s

Lists that were cut off by a fixed LIMIT, or could grow without bound,
are paged by keyset: the cursor holds the sort key and an ID, so pages
neither skip nor repeat items as others are added. The audit logs had a
timestamp-only cursor that could skip entries with equal times.

The API returns at most 100 items per list (limit takes up to 500) with
next_cursor and prev_cursor, passed back as after and before. The
console shows Newer/Older (or Previous/Next) links and To the start,
without JavaScript.

Paged: incidents (optionally of one monitor), a monitor's results and
evidence, a checker's results, the audit logs, members, maintenance
windows, firing Alertmanager alerts, the monitors API and the admin
lists of status pages and organizations, which move to their own admin
pages. A monitor's page shows its latest incidents and results and links
to all of them. The dashboard caps every group at 50 of its own monitors
with a link to a paged view of the group, and gains a search by name or
target. Lists filtered by permission after reading may show fewer items
on a page.

Closes #116

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 21:40:25 +01:00
1 parent 98fb5d3a82
commit d7c5cd711e
63 files changed
+5427 -3041

No files matched your search

+36 -6
View File
@@ -39,6 +39,8 @@ func (s *Server) registerPages(r gin.IRouter) {
r.GET("/settings/audit", s.orgPage("audit.title", authz.AuditRead, s.auditView))
r.GET("/admin", s.adminPage)
r.GET("/admin/audit", s.adminAuditPage)
r.GET("/admin/status-pages", s.adminStatusPagesPage)
r.GET("/admin/orgs", s.adminOrgsPage)
r.GET("/admin/legal", s.adminLegalPage)
r.GET("/settings/legal", s.orgPage("legal.org_title", authz.OrgManage, s.orgLegalView))
r.GET("/legal/:kind", s.legalPage)
@@ -218,7 +220,7 @@ func (s *Server) securityPage(c *gin.Context) {
return
}
}
rows, err := s.auditQuery(ctx, tenant.User(sess.UserID), store.ListAuditEventsParams{Kind: "user", Actor: &sess.UserID, MaxRows: 20}, "")
rows, _, err := s.auditQuery(ctx, tenant.User(sess.UserID), store.ListAuditEventsParams{Kind: "user", Actor: &sess.UserID}, pageReq{limit: 20})
if err != nil {
internalError(c, err)
return
@@ -302,7 +304,11 @@ func (s *Server) orgSettingsView(c *gin.Context, p *principal, page web.Page, me
func (s *Server) membersView(c *gin.Context, p *principal, page web.Page, me web.Me) (templ.Component, error) {
c.Set(ctxPrincipal, p)
members, err := s.loadMembers(c)
pg, ok := parsePage(c, consolePageSize)
if !ok {
return nil, errAborted
}
members, info, err := s.loadMembers(c, pg)
if err != nil {
return nil, err
}
@@ -322,7 +328,7 @@ func (s *Server) membersView(c *gin.Context, p *principal, page web.Page, me web
if err != nil {
return nil, err
}
v := web.MembersView{CanManage: p.Grants.Can(authz.MembersManage)}
v := web.MembersView{CanManage: p.Grants.Can(authz.MembersManage), Pager: pager(c, info)}
scopeNames, scopes, err := s.scopeOptions(ctx, p)
if err != nil {
return nil, err
@@ -511,17 +517,41 @@ func (s *Server) adminPage(c *gin.Context) {
for _, t := range check.Types {
types = append(types, web.CheckTypeOption{Type: string(t), Enabled: !off[string(t)]})
}
mod, err := s.moderationView(c)
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))))
}
func (s *Server) adminStatusPagesPage(c *gin.Context) {
me, ok := s.adminMe(c)
if !ok {
return
}
pg, ok := parsePage(c, consolePageSize)
if !ok {
return
}
v, err := s.moderationView(c, pg)
if err != nil {
internalError(c, err)
return
}
orgs, err := s.orgsView(c)
web.Render(c, http.StatusOK, web.AdminStatusPagesPage(s.pageFor(c, "moderation.title"), me, v))
}
func (s *Server) adminOrgsPage(c *gin.Context) {
me, ok := s.adminMe(c)
if !ok {
return
}
pg, ok := parsePage(c, consolePageSize)
if !ok {
return
}
v, err := s.orgsView(c, pg)
if err != nil {
internalError(c, err)
return
}
web.Render(c, http.StatusOK, web.AdminPage(s.pageFor(c, "admin.title"), me, v, storageView(c, stats), types, s.platformPrivate(ctx), mod, orgs))
web.Render(c, http.StatusOK, web.AdminOrgsPage(s.pageFor(c, "orgs.title"), me, v))
}
func (s *Server) buildRegionsView(ctx context.Context, regions []store.Region, agents []store.ListAgentsRow, apiBase, next string, manageable func(store.Region) bool) (web.RegionsView, error) {