perf(statuspages): page, search and compress public status pages
A status page with 3128 components was 30 MB of uncompressed HTML: all components at once, each with 90 bars carrying a tooltip. - The status page server gzips text responses. - Status pages list 50 components at a time (?page=N) and offer a search (?q=) over component and group names once they have more than one page. Group headings keep the status and count of the whole group. Single-file exports still list every component. - Rows linking a detail page draw their bars as one path per status, without tooltips; the detail page keeps them. 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
52d2ce25c9
commit
b051f6c430
12 files changed
+4059
-3094
No files matched your search
@@ -94,11 +94,18 @@ templ PublicStatusPage(s agentapi.PageSnapshot, a PublicAssets) {
|
||||
<p class="text-lg font-medium">{ i18n.T(ctx, "page.status."+s.Status) }</p>
|
||||
</section>
|
||||
@pageMaintenance(i18n.T(ctx, "page.maintenance_ongoing"), s.Ongoing(a.Now))
|
||||
if len(s.Sections) > 0 {
|
||||
if cp := PageComponents(s.Sections, a.Page, a.PageSize, a.Query); len(s.Sections) > 0 {
|
||||
if cp.Pages > 1 || cp.Query != "" {
|
||||
@publicComponentSearch(cp, a)
|
||||
}
|
||||
<section class="mb-12 border-t border-rule">
|
||||
for _, sec := range s.Sections {
|
||||
for _, sec := range cp.Sections {
|
||||
@publicSection(sec, s, a)
|
||||
}
|
||||
if cp.Matches == 0 {
|
||||
<p class="py-6 text-sm text-muted">{ i18n.T(ctx, "page.search_none") }</p>
|
||||
}
|
||||
@publicComponentPager(cp, a)
|
||||
</section>
|
||||
}
|
||||
@publicIncidents(s.Incidents)
|
||||
@@ -158,6 +165,34 @@ templ PublicNoticePage(s agentapi.PageSnapshot, a PublicAssets, title, message s
|
||||
}
|
||||
}
|
||||
|
||||
// publicComponentSearch finds components on pages listing too many to scan.
|
||||
templ publicComponentSearch(cp ComponentPage, a PublicAssets) {
|
||||
<form method="get" action={ templ.SafeURL(BackHref(a.ComponentBase)) } role="search" class="mb-4 flex flex-wrap items-center gap-2 text-sm">
|
||||
<label class="sr-only" for="component-search">{ i18n.T(ctx, "page.search") }</label>
|
||||
<input id="component-search" type="search" name="q" value={ cp.Query } maxlength="100" placeholder={ i18n.T(ctx, "page.search") } class="min-w-0 flex-1 border border-rule bg-transparent px-2 py-1.5"/>
|
||||
<button type="submit" class="border border-ink px-3 py-1.5 hover:bg-ink hover:text-paper">{ i18n.T(ctx, "page.search_submit") }</button>
|
||||
if cp.Query != "" {
|
||||
<a href={ templ.SafeURL(BackHref(a.ComponentBase)) } class="text-muted hover:text-ink">{ i18n.T(ctx, "page.search_clear") }</a>
|
||||
}
|
||||
</form>
|
||||
}
|
||||
|
||||
// publicComponentPager turns the pages of components.
|
||||
templ publicComponentPager(cp ComponentPage, a PublicAssets) {
|
||||
if cp.Pages > 1 {
|
||||
<nav class="flex flex-wrap items-center gap-x-5 gap-y-2 py-4 text-sm" aria-label={ i18n.T(ctx, "pager.label") }>
|
||||
if cp.Page > 0 {
|
||||
<a href={ templ.SafeURL(ComponentPageHref(a.ComponentBase, 0, cp.Query)) } class="text-muted hover:text-ink">{ i18n.T(ctx, "pager.first") }</a>
|
||||
<a href={ templ.SafeURL(ComponentPageHref(a.ComponentBase, cp.Page-1, cp.Query)) } rel="prev" class="text-muted hover:text-ink">← { i18n.T(ctx, "pager.previous") }</a>
|
||||
}
|
||||
<span class="font-mono text-xs text-muted">{ i18n.T(ctx, "page.pages", "Page", cp.Page+1, "Pages", cp.Pages) }</span>
|
||||
if cp.Page < cp.Pages-1 {
|
||||
<a href={ templ.SafeURL(ComponentPageHref(a.ComponentBase, cp.Page+1, cp.Query)) } rel="next" class="ml-auto text-muted hover:text-ink">{ i18n.T(ctx, "pager.next") } →</a>
|
||||
}
|
||||
</nav>
|
||||
}
|
||||
}
|
||||
|
||||
// publicSection renders an unnamed root component list or a collapsible nested
|
||||
// group matching the monitor dashboard hierarchy.
|
||||
templ publicSection(sec agentapi.Section, s agentapi.PageSnapshot, a PublicAssets) {
|
||||
@@ -238,7 +273,12 @@ templ publicComponentBody(comp agentapi.Component, s agentapi.PageSnapshot, clic
|
||||
}
|
||||
</span>
|
||||
</div>
|
||||
@bars(DayBars(comp.Days), 22)
|
||||
if clickable {
|
||||
// The detail page the row links to has the tooltips.
|
||||
@pathBars(DayBars(comp.Days), 22)
|
||||
} else {
|
||||
@bars(DayBars(comp.Days), 22)
|
||||
}
|
||||
<div class="mt-1 flex justify-between font-mono text-xs text-muted">
|
||||
<span>{ i18n.T(ctx, "page.days_ago", "Count", len(comp.Days)) }</span>
|
||||
<span>{ UptimeText(comp.Uptime) }</span>
|
||||
|
||||
Reference in new issue
Block a user