feat: page long and truncated lists
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:
1 parent
98fb5d3a82
commit
d7c5cd711e
63 files changed
+5427
-3041
No files matched your search
+33
-25
@@ -1,10 +1,6 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/i18n"
|
||||
)
|
||||
import "git.zb-server.de/ZB-Server/uptimesebi/internal/i18n"
|
||||
|
||||
// Region is a row in a region list.
|
||||
type Region struct {
|
||||
@@ -163,16 +159,11 @@ templ RegionsPage(p Page, me Me, v RegionsView) {
|
||||
}
|
||||
}
|
||||
|
||||
templ AdminPage(p Page, me Me, v RegionsView, storage StorageView, checkTypes []CheckTypeOption, platformPrivate bool, mod ModerationView, orgs OrgsView) {
|
||||
templ AdminPage(p Page, me Me, v RegionsView, storage StorageView, checkTypes []CheckTypeOption, platformPrivate bool, limits LimitsView) {
|
||||
@consoleShell(p, me) {
|
||||
@settingsHeading("admin.title", "admin.intro")
|
||||
<p class="-mt-4 mb-8 flex gap-4 text-sm">
|
||||
<a href="/admin/audit" class="underline underline-offset-2">{ i18n.T(ctx, "audit.platform_title") }</a>
|
||||
<a href="/admin/legal" class="underline underline-offset-2">{ i18n.T(ctx, "legal.platform_title") }</a>
|
||||
</p>
|
||||
@moderationSection(mod)
|
||||
@orgsSection(orgs)
|
||||
@limitsSection(orgs.Defaults)
|
||||
@adminLinks()
|
||||
@limitsSection(limits)
|
||||
@regionsBody(v)
|
||||
@checkerNetworkSection(platformPrivate)
|
||||
@checkTypesSection(checkTypes, "/admin/check-types", "/admin", "admin.check_types_intro")
|
||||
@@ -223,8 +214,9 @@ templ checkTypesSection(types []CheckTypeOption, api, next, introID string) {
|
||||
type ModerationView struct {
|
||||
Search string
|
||||
Pages []ModeratedPage
|
||||
// Limited is set when more pages match than are shown.
|
||||
Limited bool
|
||||
Pager Pager
|
||||
// Next is the page to return to after an action.
|
||||
Next string
|
||||
}
|
||||
|
||||
// ModeratedPage is a status page with the organization and account
|
||||
@@ -245,18 +237,13 @@ type ModeratedTarget struct {
|
||||
Admin bool
|
||||
}
|
||||
|
||||
func (v ModerationView) next() string {
|
||||
if v.Search == "" {
|
||||
return "/admin#moderation"
|
||||
}
|
||||
return "/admin?q=" + url.QueryEscape(v.Search) + "#moderation"
|
||||
}
|
||||
func (v ModerationView) next() string { return v.Next }
|
||||
|
||||
templ moderationSection(v ModerationView) {
|
||||
<section id="moderation" class="mb-12">
|
||||
@sectionHeading("moderation.title")
|
||||
<p class="mb-4 max-w-3xl text-sm text-muted">{ i18n.T(ctx, "moderation.intro") }</p>
|
||||
<form method="get" action="/admin#moderation" class="mb-4 flex max-w-xl gap-2">
|
||||
<form method="get" action="/admin/status-pages" class="mb-4 flex max-w-xl gap-2">
|
||||
<input
|
||||
type="search"
|
||||
name="q"
|
||||
@@ -323,10 +310,8 @@ templ moderationSection(v ModerationView) {
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
if v.Limited {
|
||||
<p class="mt-3 text-xs text-muted">{ i18n.T(ctx, "moderation.limited") }</p>
|
||||
}
|
||||
}
|
||||
@pager(v.Pager, "newer", "older")
|
||||
</section>
|
||||
}
|
||||
|
||||
@@ -374,3 +359,26 @@ templ moderationActions(kind, api, suspended, name, next string) {
|
||||
>{ i18n.T(ctx, "moderation.delete_"+kind) }</button>
|
||||
</div>
|
||||
}
|
||||
|
||||
templ adminLinks() {
|
||||
<p class="-mt-4 mb-8 flex flex-wrap gap-x-4 gap-y-1 text-sm">
|
||||
<a href="/admin/status-pages" class="underline underline-offset-2">{ i18n.T(ctx, "moderation.title") }</a>
|
||||
<a href="/admin/orgs" class="underline underline-offset-2">{ i18n.T(ctx, "orgs.title") }</a>
|
||||
<a href="/admin/audit" class="underline underline-offset-2">{ i18n.T(ctx, "audit.platform_title") }</a>
|
||||
<a href="/admin/legal" class="underline underline-offset-2">{ i18n.T(ctx, "legal.platform_title") }</a>
|
||||
</p>
|
||||
}
|
||||
|
||||
templ AdminStatusPagesPage(p Page, me Me, v ModerationView) {
|
||||
@consoleShell(p, me) {
|
||||
<p class="mb-4 text-sm"><a href="/admin" class="text-muted hover:text-ink">← { i18n.T(ctx, "admin.title") }</a></p>
|
||||
@moderationSection(v)
|
||||
}
|
||||
}
|
||||
|
||||
templ AdminOrgsPage(p Page, me Me, v OrgsView) {
|
||||
@consoleShell(p, me) {
|
||||
<p class="mb-4 text-sm"><a href="/admin" class="text-muted hover:text-ink">← { i18n.T(ctx, "admin.title") }</a></p>
|
||||
@orgsSection(v)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user