perf(console): keep the status page editor light with many monitors
The editor rendered a group select and label field for every monitor of the organization, about 2 MB of HTML for 3000 monitors. Only monitors on the page carry their fields now; others get them from a template when ticked. A filter field narrows long lists, and "Add all" ticks only the monitors it leaves visible. 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
b88ed4bfd2
commit
2a440b9c5e
6 files changed
+473
-336
No files matched your search
@@ -283,7 +283,13 @@ templ StatusPageEditor(p Page, me Me, e PageEditor) {
|
||||
<button type="button" data-check-all="off" data-check-target="[data-field=include]" class="text-muted hover:text-ink">{ i18n.T(ctx, "pages.monitors_none") }</button>
|
||||
</p>
|
||||
}
|
||||
<ul class="mb-4 divide-y divide-rule border-y border-rule text-sm">
|
||||
if len(e.Monitors) > monitorFilterFrom {
|
||||
<input type="search" data-filter-rows="#page-monitors" placeholder={ i18n.T(ctx, "pages.monitors_filter") } aria-label={ i18n.T(ctx, "pages.monitors_filter") } class="mb-2 w-full border border-rule bg-transparent px-2 py-1 text-sm outline-none focus:border-ink"/>
|
||||
}
|
||||
<template data-row-fields>
|
||||
@pageMonitorFields(e, PageMonitorOption{})
|
||||
</template>
|
||||
<ul id="page-monitors" class="mb-4 divide-y divide-rule border-y border-rule text-sm">
|
||||
for _, m := range e.Monitors {
|
||||
<li data-row class="grid grid-cols-[auto_1fr] items-center gap-x-3 gap-y-1.5 py-2">
|
||||
<input type="checkbox" data-field="include" checked?={ m.Included } class="accent-ink" aria-label={ m.Name }/>
|
||||
@@ -294,16 +300,11 @@ templ StatusPageEditor(p Page, me Me, e PageEditor) {
|
||||
}
|
||||
</span>
|
||||
<input type="hidden" data-field="monitor_id" value={ m.ID }/>
|
||||
<span></span>
|
||||
<span class="flex gap-2">
|
||||
<select data-field="group_id" data-nullable aria-label={ i18n.T(ctx, "pages.group") } class="w-1/2 border border-rule bg-transparent px-2 py-1 text-xs outline-none focus:border-ink">
|
||||
<option value="">{ i18n.T(ctx, "pages.no_group") }</option>
|
||||
for _, opt := range e.Groups {
|
||||
<option value={ opt.ID } selected?={ opt.ID == m.GroupID }>{ opt.Label }</option>
|
||||
}
|
||||
</select>
|
||||
<input data-field="label" value={ m.Label } placeholder={ i18n.T(ctx, "pages.label") } class="w-1/2 border border-rule bg-transparent px-2 py-1 text-xs outline-none focus:border-ink"/>
|
||||
</span>
|
||||
// Organizations may have thousands of monitors: only those on
|
||||
// the page carry their fields, the others get them when ticked.
|
||||
if m.Included {
|
||||
@pageMonitorFields(e, m)
|
||||
}
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
@@ -379,3 +380,21 @@ templ dnsRecordList(kind, name, value string) {
|
||||
templ verifyButton(pageID, label string) {
|
||||
<button type="button" data-post={ "/org/statuspages/" + pageID + "/domain/verify" } data-ok={ i18n.T(ctx, "pages.domain_verified") } data-reload class="mt-3 border border-ink px-3 py-1.5 text-sm hover:bg-ink hover:text-paper">{ i18n.T(ctx, label) }</button>
|
||||
}
|
||||
|
||||
// monitorFilterFrom is how many monitors the page editor lists before it
|
||||
// offers to filter them.
|
||||
const monitorFilterFrom = 15
|
||||
|
||||
// pageMonitorFields are the group and label of m on the page.
|
||||
templ pageMonitorFields(e PageEditor, m PageMonitorOption) {
|
||||
<span data-row-extra></span>
|
||||
<span class="flex gap-2">
|
||||
<select data-field="group_id" data-nullable aria-label={ i18n.T(ctx, "pages.group") } class="w-1/2 border border-rule bg-transparent px-2 py-1 text-xs outline-none focus:border-ink">
|
||||
<option value="">{ i18n.T(ctx, "pages.no_group") }</option>
|
||||
for _, opt := range e.Groups {
|
||||
<option value={ opt.ID } selected?={ opt.ID == m.GroupID }>{ opt.Label }</option>
|
||||
}
|
||||
</select>
|
||||
<input data-field="label" value={ m.Label } placeholder={ i18n.T(ctx, "pages.label") } class="w-1/2 border border-rule bg-transparent px-2 py-1 text-xs outline-none focus:border-ink"/>
|
||||
</span>
|
||||
}
|
||||
Reference in new issue
Block a user