diff --git a/internal/api/apidocs.go b/internal/api/apidocs.go index 1785996..19a0691 100644 --- a/internal/api/apidocs.go +++ b/internal/api/apidocs.go @@ -90,6 +90,9 @@ var endpoints = []endpoint{ {method: "POST", path: "/api/v1/org/monitors", tag: "Monitors", summary: "Create a monitor", description: "`type` is one of http, json, prometheus, tcp, tls, dns, icmp, postgres, mysql, mssql, mongodb, redis, mqtt, kafka, rabbitmq, grpc, smtp, radius, snmp, steam, minecraft, docker, heartbeat or alertmanager (GET /api/v1/org/check-types lists those offered); `config` depends on it (see HTTPConfig, JSONConfig, PrometheusConfig, DNSConfig, TLSConfig, DBConfig, BrokerConfig, GRPCConfig, SMTPConfig, RADIUSConfig, SNMPConfig, GameConfig, DockerConfig, HeartbeatConfig, AlertmanagerConfig). Passwords, RADIUS secrets and SNMP communities are stored encrypted and never returned: `secrets_set` names those set, and an update that leaves one empty keeps it. Heartbeat and alertmanager monitors take neither target nor regions; heartbeats return their `ping_url`. Omit `alert_group_ids` to assign the default alert group; an empty array disables notifications.", perm: "monitors.write", req: monitorRequest{}, status: http.StatusCreated, resp: monitorView{}}, + {method: "PUT", path: "/api/v1/org/monitors/order", tag: "Monitors", summary: "Put monitors in the organization's own order", perm: "monitors.write", + description: "Positions follow the order of monitor_ids, usually the monitors of one group; the monitor list sorted by its own order shows positioned monitors first, the rest by name. Needs write access to every monitor given.", + req: monitorOrderRequest{}}, {method: "PUT", path: "/api/v1/org/monitors/:id", tag: "Monitors", summary: "Change a monitor", perm: "monitors.write", description: "Omitting alert_group_ids preserves existing assignments; an empty array removes all alert groups.", req: monitorRequest{}, resp: monitorView{}}, @@ -106,7 +109,7 @@ var endpoints = []endpoint{ description: "Platform checkers serve every organization; other organizations' work appears only as a count. `recent` is paged, newest first; a page may hold fewer results than `limit` when some belong to monitors you cannot read.", resp: checkerActivity{}}, {method: "GET", path: "/api/v1/org/limits", tag: "Organization", summary: "Limits in effect for the organization and its usage", - description: "0 means unlimited. Creating beyond a limit gives 422 monitor_limit, status_page_limit, region_limit or platform_region_limit.", + description: "0 means unlimited. Creating beyond a limit gives 422 monitor_limit, status_page_limit, page_monitor_limit, region_limit or platform_region_limit.", resp: usageView{}}, {method: "GET", path: "/api/v1/org/check-types", tag: "Monitors", summary: "Monitor types members can create", description: "`own_checkers_only` are the types the platform's checkers do not run: monitors of them use the organization's own regions only, or 422 check_type_own_checkers_only.", diff --git a/internal/api/audit.go b/internal/api/audit.go index 2191ac2..822192b 100644 --- a/internal/api/audit.go +++ b/internal/api/audit.go @@ -64,6 +64,7 @@ var auditActions = map[string]string{ "PUT /api/v1/org/policy": "org.policy_update", "POST /api/v1/org/monitors": "monitor.create", "PUT /api/v1/org/monitors/:id": "monitor.update", + "PUT /api/v1/org/monitors/order": "monitor.order", "DELETE /api/v1/org/monitors/:id": "monitor.delete", "POST /api/v1/org/alertmanager/receivers": "alertmanager.receiver_create", "DELETE /api/v1/org/alertmanager/receivers/:id": "alertmanager.receiver_delete", diff --git a/internal/api/console.go b/internal/api/console.go index aefd208..aa82529 100644 --- a/internal/api/console.go +++ b/internal/api/console.go @@ -6,6 +6,7 @@ import ( "encoding/json" "errors" "fmt" + "math" "net" "net/http" "net/url" @@ -79,10 +80,10 @@ func (s *Server) dashboard(c *gin.Context) { } v.Root = buildGroupNodes(data.tree, data.rows) v.Empty = len(data.rows) == 0 && len(v.Root.Children) == 0 + v.CanWrite = writableAnywhere(p, data.tree) if !s.dashboardPage(c, &v, data) { return } - v.CanWrite = writableAnywhere(p, data.tree) v.Range = data.rng.Key var earliest time.Time for _, m := range data.byID { @@ -97,6 +98,7 @@ func (s *Server) dashboard(c *gin.Context) { v.Unchecked++ } } + v.Filters = statusFilters(c, v.Counts, v.Filter) for id, since := range s.regionsWithoutChecker(c.Request.Context(), data.usedRegions) { v.DeadRegions = append(v.DeadRegions, web.DeadRegion{Name: data.regionOf[id].Name, Since: since.Local().Format("2006-01-02 15:04")}) } @@ -112,14 +114,64 @@ const groupMonitorsShown = 50 // ungrouped names the pseudo-group of monitors outside any group. const ungrouped = "none" -func monitorKey(m web.MonitorRow) cursor { - id, _ := uuid.Parse(m.ID) - return cursor{S: strings.ToLower(m.Name), ID: id} +// monitorSort is an order of the monitor list: the organization's own, +// or by name, status (problems first), uptime (worst first) or latency +// (slowest first). Monitors without a position or data come last. +type monitorSort string + +var monitorSorts = []monitorSort{"custom", "name", "status", "uptime", "latency"} + +const sortCookie = "monitor_sort" + +// sortOf returns the order asked for, remembering it in a cookie, or the +// one remembered, or the organization's own. +func sortOf(c *gin.Context) monitorSort { + if q := monitorSort(c.Query("sort")); slices.Contains(monitorSorts, q) { + c.SetSameSite(http.SameSiteLaxMode) + c.SetCookie(sortCookie, string(q), 365*24*3600, "/", "", c.Request.TLS != nil, true) + return q + } + if v, err := c.Cookie(sortCookie); err == nil && slices.Contains(monitorSorts, monitorSort(v)) { + return monitorSort(v) + } + return "custom" } -func sortMonitors(ms []web.MonitorRow) { +// key orders m by o as a string, so pages can continue after it. +func (o monitorSort) key(m web.MonitorRow) cursor { + id, _ := uuid.Parse(m.ID) + name := strings.ToLower(m.Name) + var k string + switch o { + case "name": + k = name + case "status": + k = fmt.Sprintf("%d|%s", statusRank[m.Status], name) + case "uptime": + if m.Ratio < 0 { + k = "1|" + name + } else { + k = fmt.Sprintf("0|%.9f|%s", m.Ratio, name) + } + case "latency": + if m.LatencyMS < 0 { + k = "1|" + name + } else { + k = fmt.Sprintf("0|%010d|%s", math.MaxInt32-m.LatencyMS, name) + } + default: + if m.Position < 0 { + k = "1|" + name + } else { + k = fmt.Sprintf("0|%010d|%s", m.Position, name) + } + } + return cursor{S: k, ID: id} +} + +func (o monitorSort) sort(ms []web.MonitorRow) { slices.SortFunc(ms, func(a, b web.MonitorRow) int { - ka, kb := monitorKey(a), monitorKey(b) + ka, kb := o.key(a), o.key(b) if c := strings.Compare(ka.S, kb.S); c != 0 { return c } @@ -127,6 +179,46 @@ func sortMonitors(ms []web.MonitorRow) { }) } +// dashboardStatuses are the statuses the dashboard counts, in order. +var dashboardStatuses = []web.Status{web.StatusUp, web.StatusDegraded, web.StatusDown, web.StatusUnknown, web.StatusMaintenance, web.StatusPaused} + +// dashboardURL is the dashboard with key set to value, or removed when +// value is empty, keeping the search and range but not the page. +func dashboardURL(c *gin.Context, key, value string) string { + q := url.Values{} + for _, k := range []string{"q", "range", "status", "arrange"} { + if v := c.Query(k); v != "" { + q.Set(k, v) + } + } + if value == "" { + q.Del(key) + } else { + q.Set(key, value) + } + if len(q) == 0 { + return "/" + } + return "/?" + q.Encode() +} + +// statusFilters are the counts of the statuses present, each linking to +// its monitors, the active one back to all. +func statusFilters(c *gin.Context, counts map[web.Status]int, active web.Status) []web.StatusFilter { + var out []web.StatusFilter + for _, st := range dashboardStatuses { + if counts[st] == 0 && st != active { + continue + } + f := web.StatusFilter{Status: st, Count: counts[st], Active: st == active, URL: dashboardURL(c, "status", string(st))} + if f.Active { + f.URL = dashboardURL(c, "status", "") + } + out = append(out, f) + } + return out +} + // dashboardPage narrows the dashboard to a search or one group, pages it // and caps every group's own monitors. It reports false after answering // with an error. @@ -135,6 +227,20 @@ func (s *Server) dashboardPage(c *gin.Context, v *web.DashboardView, data monito if !ok { return false } + order := sortOf(c) + v.Sort = string(order) + for _, o := range monitorSorts { + v.Sorts = append(v.Sorts, web.SortOption{Key: string(o), Active: o == order, URL: dashboardURL(c, "sort", string(o))}) + } + // Arranging by hand shows the whole tree in the organization's order. + arranging := order == "custom" && v.CanWrite && c.Query("q") == "" && c.Query("status") == "" && c.Query("group") == "" + v.Arrange = arranging && c.Query("arrange") == "1" + if arranging { + v.ArrangeURL = dashboardURL(c, "arrange", "1") + if v.Arrange { + v.ArrangeURL = dashboardURL(c, "arrange", "") + } + } link := func(group string) string { q := url.Values{"group": {group}} if r := c.Query("range"); r != "" { @@ -144,8 +250,8 @@ func (s *Server) dashboardPage(c *gin.Context, v *web.DashboardView, data monito } var capNode func(n *web.GroupNode) capNode = func(n *web.GroupNode) { - sortMonitors(n.Monitors) - if len(n.Monitors) > groupMonitorsShown { + order.sort(n.Monitors) + if len(n.Monitors) > groupMonitorsShown && !v.Arrange { n.More = len(n.Monitors) - groupMonitorsShown n.Monitors = n.Monitors[:groupMonitorsShown] n.MoreURL = link(cmp.Or(n.ID, ungrouped)) @@ -155,18 +261,25 @@ func (s *Server) dashboardPage(c *gin.Context, v *web.DashboardView, data monito } } var info pageInfo + if f := web.Status(c.Query("status")); slices.Contains(dashboardStatuses, f) { + v.Filter = f + v.AllURL = dashboardURL(c, "status", "") + } switch group := c.Query("group"); { - case strings.TrimSpace(c.Query("q")) != "": + case strings.TrimSpace(c.Query("q")) != "" || v.Filter != "": v.Search = strings.TrimSpace(c.Query("q")) needle := strings.ToLower(v.Search) var hits []web.MonitorRow for _, m := range data.rows { + if v.Filter != "" && m.Status != v.Filter { + continue + } if strings.Contains(strings.ToLower(m.Name), needle) || strings.Contains(strings.ToLower(m.Target), needle) { hits = append(hits, m) } } - sortMonitors(hits) - v.Results, info = pageSlice(hits, pg, monitorKey) + order.sort(hits) + v.Results, info = pageSlice(hits, pg, order.key) case group != "": var focus web.GroupNode found := false @@ -191,8 +304,8 @@ func (s *Server) dashboardPage(c *gin.Context, v *web.DashboardView, data monito c.Redirect(http.StatusSeeOther, "/") return false } - sortMonitors(focus.Monitors) - focus.Monitors, info = pageSlice(focus.Monitors, pg, monitorKey) + order.sort(focus.Monitors) + focus.Monitors, info = pageSlice(focus.Monitors, pg, order.key) for i := range focus.Children { capNode(&focus.Children[i]) } @@ -400,7 +513,10 @@ func (s *Server) loadMonitorData(ctx context.Context, p *principal, rng web.Time continue } d.byID[m.ID] = m - row := web.MonitorRow{ID: m.ID.String(), Name: m.Name, Type: m.Type, Target: m.Target, Latency: "–", Uptime: "–"} + row := web.MonitorRow{ID: m.ID.String(), Name: m.Name, Type: m.Type, Target: m.Target, Latency: "–", Uptime: "–", Position: -1, LatencyMS: -1} + if m.Position != nil { + row.Position = int(*m.Position) + } keys := idStrings(regionsOf[m.ID]) if check.Passive(check.Type(m.Type)) { // The target of a heartbeat is its secret ping token. @@ -461,8 +577,10 @@ func (s *Server) loadMonitorData(ctx context.Context, p *principal, rng web.Time sum += l } row.Latency = fmt.Sprintf("%d ms", sum/int32(len(latencies))) + row.LatencyMS = int(sum / int32(len(latencies))) } - row.Uptime = web.SLAText(d.slaFor(m, rng.Window)) + row.Ratio = d.slaFor(m, rng.Window) + row.Uptime = web.SLAText(row.Ratio) row.Bars = web.UptimeBars(d.buckets[m.ID], now, rng.Bucket, rng.Bars(), rng.Layout) d.rows = append(d.rows, row) } @@ -1155,6 +1273,7 @@ func (s *Server) statusPageEditor(c *gin.Context, p *principal, page web.Page, m e.RecordName, e.RecordValue = v.DomainRecord.Name, v.DomainRecord.Value } e.DomainChangesPerDay = domainChangesPerDay + e.MonitorLimit = s.orgLimits(c.Request.Context(), p.Org).MonitorsPerPage if v.CNAMERecord != nil { e.CNAMEValue = v.CNAMERecord.Value } diff --git a/internal/api/dashboard_filter_test.go b/internal/api/dashboard_filter_test.go new file mode 100644 index 0000000..5202c51 --- /dev/null +++ b/internal/api/dashboard_filter_test.go @@ -0,0 +1,151 @@ +package api_test + +import ( + "net/http" + "strings" + "testing" +) + +func TestDashboardFiltersByStatus(t *testing.T) { + e := newEnv(t) + _, region := e.platformChecker(t, uniq("eu-")) + owner := e.browser(t) + owner.signup("o@"+uniq("flt")+".test", uniq("flt-")) + create := func(name string) string { + t.Helper() + st, m := owner.do("POST", "/api/v1/org/monitors", map[string]any{"name": name, "type": "http", "target": "https://" + strings.ToLower(name) + ".test", "interval_seconds": 60, "regions": []string{region}}) + if st != http.StatusCreated { + t.Fatalf("create %s = %d %v", name, st, m) + } + return m["id"].(string) + } + create("Alpha") + create("Beta") + gamma := create("Gamma") + owner.do("PUT", "/api/v1/org/monitors/"+gamma, map[string]any{"name": "Gamma", "type": "http", "target": "https://gamma.test", "interval_seconds": 60, "regions": []string{region}, "enabled": false}) + + _, _, all := owner.page("/") + for _, want := range []string{`href="/?status=unknown"`, `href="/?status=paused"`, "Show only the 2 monitors that are no data", "Show only the 1 monitor that is paused"} { + if !strings.Contains(all, want) { + t.Errorf("the dashboard lacks %q", want) + } + } + + _, _, paused := owner.page("/?status=paused") + if !strings.Contains(paused, "Gamma") || strings.Contains(paused, "Alpha") || strings.Contains(paused, "Beta") { + t.Error("?status=paused does not show only the paused monitor") + } + // The active filter links back to all, and the search keeps it. + if !strings.Contains(paused, `aria-current="true"`) || !strings.Contains(paused, `title="Show all statuses"`) { + t.Error("the active filter is not marked") + } + if !strings.Contains(paused, `name="status" value="paused"`) { + t.Error("the search form drops the status filter") + } + + _, _, both := owner.page("/?status=unknown&q=alp") + if !strings.Contains(both, "Alpha") || strings.Contains(both, "Beta") || strings.Contains(both, "Gamma") { + t.Error("status filter and search do not combine") + } + if _, _, none := owner.page("/?status=down"); !strings.Contains(none, "No monitor has this status right now.") { + t.Error("an empty filter does not say so") + } + // An unknown status shows everything. + if _, _, bogus := owner.page("/?status=bogus"); !strings.Contains(bogus, "Alpha") || !strings.Contains(bogus, "Gamma") { + t.Error("an unknown status filter hides monitors") + } +} + +func TestSignupSendsSignedInUsersToTheMonitors(t *testing.T) { + e := newEnv(t) + visitor := e.browser(t) + if st, path, _ := visitor.page("/signup"); st != http.StatusOK || path != "/signup" { + t.Fatalf("signup for a visitor = %d at %s", st, path) + } + owner := e.browser(t) + owner.signup("o@"+uniq("su")+".test", uniq("su-")) + if st, path, html := owner.page("/signup"); st != http.StatusOK || path != "/" || !strings.Contains(html, "Monitors") { + t.Errorf("signup when signed in ended at %s (%d), want the monitor list", path, st) + } +} + +func TestPageEditorOffersAddAndRemoveAll(t *testing.T) { + e := newEnv(t) + _, region := e.platformChecker(t, uniq("eu-")) + owner := e.browser(t) + owner.signup("o@"+uniq("pa")+".test", uniq("pa-")) + owner.do("POST", "/api/v1/org/monitors", map[string]any{"name": "Shop", "type": "http", "target": "https://shop.test", "interval_seconds": 60, "regions": []string{region}}) + _, p := owner.do("POST", "/api/v1/org/statuspages", map[string]any{"slug": uniq("pa-"), "title": "Status"}) + _, _, html := owner.page("/statuspages/" + p["id"].(string)) + for _, want := range []string{`data-check-all="on"`, `data-check-all="off"`, "Add all", "Remove all"} { + if !strings.Contains(html, want) { + t.Errorf("the page editor lacks %q", want) + } + } +} + +func TestMonitorOrder(t *testing.T) { + e := newEnv(t) + _, region := e.platformChecker(t, uniq("eu-")) + owner := e.browser(t) + owner.signup("o@"+uniq("ord")+".test", uniq("ord-")) + ids := map[string]string{} + for _, n := range []string{"Alpha", "Bravo", "Charlie"} { + _, m := owner.do("POST", "/api/v1/org/monitors", map[string]any{"name": n, "type": "http", "target": "https://" + strings.ToLower(n) + ".test", "interval_seconds": 60, "regions": []string{region}}) + ids[n] = m["id"].(string) + } + order := func(html string, names ...string) bool { + last := -1 + for _, n := range names { + i := strings.Index(html, ">"+n+"<") + if i < last || i < 0 { + return false + } + last = i + } + return true + } + + // Without an order of its own, by name. + if _, _, html := owner.page("/"); !order(html, "Alpha", "Bravo", "Charlie") { + t.Error("monitors without positions are not by name") + } + st, body := owner.do("PUT", "/api/v1/org/monitors/order", map[string]any{"monitor_ids": []string{ids["Charlie"], ids["Alpha"]}}) + if st != http.StatusNoContent { + t.Fatalf("order = %d %v", st, body) + } + // Positioned ones first, in their order; the rest after, by name. + _, _, html := owner.page("/") + if !order(html, "Charlie", "Alpha", "Bravo") { + t.Error("the list does not follow the organization's order") + } + if !strings.Contains(html, "?arrange=1") || !strings.Contains(html, "?sort=name") { + t.Error("the dashboard offers neither arranging nor sorting") + } + if _, _, arr := owner.page("/?arrange=1"); !strings.Contains(arr, `data-sortable="/org/monitors/order"`) || !strings.Contains(arr, `data-sort-id="`+ids["Charlie"]+`"`) { + t.Error("arranging does not show the sortable list") + } + + // Sorting by name is remembered until changed. + if _, _, byName := owner.page("/?sort=name"); !order(byName, "Alpha", "Bravo", "Charlie") { + t.Error("?sort=name does not sort by name") + } + if _, _, again := owner.page("/"); !order(again, "Alpha", "Bravo", "Charlie") || strings.Contains(again, "?arrange=1") { + t.Error("the sort order is not remembered, or arranging is offered outside the own order") + } + owner.page("/?sort=custom") + + // Unknown and duplicate monitors are refused, and nothing changes. + st, body = owner.do("PUT", "/api/v1/org/monitors/order", map[string]any{"monitor_ids": []string{ids["Bravo"], "00000000-0000-0000-0000-000000000001"}}) + expect(t, "unknown monitor", st, body, http.StatusUnprocessableEntity, "invalid_monitor") + st, body = owner.do("PUT", "/api/v1/org/monitors/order", map[string]any{"monitor_ids": []string{ids["Bravo"], ids["Bravo"]}}) + expect(t, "duplicate monitor", st, body, http.StatusUnprocessableEntity, "invalid_monitor") + if _, _, html := owner.page("/"); !order(html, "Charlie", "Alpha", "Bravo") { + t.Error("a refused order changed the list") + } + // Another organization cannot touch them. + other := e.browser(t) + other.signup("x@"+uniq("ord")+".test", uniq("ord-")) + st, body = other.do("PUT", "/api/v1/org/monitors/order", map[string]any{"monitor_ids": []string{ids["Alpha"]}}) + expect(t, "another organization's monitor", st, body, http.StatusUnprocessableEntity, "invalid_monitor") +} diff --git a/internal/api/limits.go b/internal/api/limits.go index ddd0767..aab72d5 100644 --- a/internal/api/limits.go +++ b/internal/api/limits.go @@ -36,6 +36,8 @@ type Limits struct { OwnRegionsCount bool `json:"own_regions_count"` // OrgsPerAccount limits the organizations an account owns. OrgsPerAccount int `json:"orgs_per_account"` + // MonitorsPerPage limits the monitors one status page shows. + MonitorsPerPage int `json:"monitors_per_page"` } func (s *Server) defaultLimits() Limits { @@ -79,6 +81,7 @@ func (s *Server) orgLimits(ctx context.Context, org store.Org) Limits { override(&l.Monitors, org.LimitMonitors) override(&l.StatusPages, org.LimitStatusPages) override(&l.RegionsPerMonitor, org.LimitRegionsPerMonitor) + override(&l.MonitorsPerPage, org.LimitMonitorsPerPage) if org.LimitOwnRegionsCount != nil { l.OwnRegionsCount = *org.LimitOwnRegionsCount } @@ -189,6 +192,7 @@ type limitsRequest struct { RegionsPerMonitor int `json:"regions_per_monitor" binding:"min=0,max=1000"` OwnRegionsCount bool `json:"own_regions_count"` OrgsPerAccount int `json:"orgs_per_account" binding:"min=0,max=100000"` + MonitorsPerPage int `json:"monitors_per_page" binding:"min=0,max=200"` } func (s *Server) adminSetLimits(c *gin.Context) { @@ -243,6 +247,7 @@ type orgLimitsRequest struct { StatusPages *int32 `json:"status_pages" binding:"omitempty,min=0,max=1000000"` RegionsPerMonitor *int32 `json:"regions_per_monitor" binding:"omitempty,min=0,max=1000"` OwnRegionsCount optBool `json:"own_regions_count"` + MonitorsPerPage *int32 `json:"monitors_per_page" binding:"omitempty,min=0,max=200"` } func (s *Server) adminSetOrgLimits(c *gin.Context) { @@ -261,6 +266,7 @@ func (s *Server) adminSetOrgLimits(c *gin.Context) { row, err := q.SetOrgLimits(ctx, store.SetOrgLimitsParams{ ID: id, Monitors: req.Monitors, StatusPages: req.StatusPages, RegionsPerMonitor: req.RegionsPerMonitor, OwnRegionsCount: req.OwnRegionsCount.v, + MonitorsPerPage: req.MonitorsPerPage, }) auditDetail(c, "slug", row.Slug) return err @@ -316,6 +322,7 @@ type orgLimitsView struct { StatusPages *int32 `json:"status_pages"` RegionsPerMonitor *int32 `json:"regions_per_monitor"` OwnRegionsCount *bool `json:"own_regions_count"` + MonitorsPerPage *int32 `json:"monitors_per_page"` } type adminOwner struct { @@ -342,9 +349,10 @@ func (s *Server) adminOrgs(ctx context.Context, search string, pg pageReq) ([]ad o := &out[i] o.moderatedOrg = moderatedOrg{r.ID, r.Slug, r.Name, r.SuspendedAt, r.SuspendedReason} o.Created = r.CreatedAt.Format("2006-01-02") - o.Overrides = orgLimitsView{r.LimitMonitors, r.LimitStatusPages, r.LimitRegionsPerMonitor, r.LimitOwnRegionsCount} + o.Overrides = orgLimitsView{r.LimitMonitors, r.LimitStatusPages, r.LimitRegionsPerMonitor, r.LimitOwnRegionsCount, r.LimitMonitorsPerPage} o.Limits = s.orgLimits(ctx, store.Org{LimitMonitors: r.LimitMonitors, LimitStatusPages: r.LimitStatusPages, - LimitRegionsPerMonitor: r.LimitRegionsPerMonitor, LimitOwnRegionsCount: r.LimitOwnRegionsCount}) + LimitRegionsPerMonitor: r.LimitRegionsPerMonitor, LimitOwnRegionsCount: r.LimitOwnRegionsCount, + LimitMonitorsPerPage: r.LimitMonitorsPerPage}) o.Limits.OrgsPerAccount = defaults.OrgsPerAccount o.Usage.Monitors, o.Usage.StatusPages = int(r.Monitors), int(r.StatusPages) if r.OwnerID != uuid.Nil { @@ -403,7 +411,7 @@ func (s *Server) orgsView(c *gin.Context, pg pageReq) (web.OrgsView, error) { ID: o.ID.String(), Name: o.Name, Slug: o.Slug, Created: o.Created, Suspended: state(o.SuspendedAt, o.Reason), Monitors: o.Usage.Monitors, StatusPages: o.Usage.StatusPages, Limits: webLimits(o.Limits), MonitorsOverride: optInt(o.Overrides.Monitors), StatusPagesOverride: optInt(o.Overrides.StatusPages), - RegionsOverride: optInt(o.Overrides.RegionsPerMonitor), + RegionsOverride: optInt(o.Overrides.RegionsPerMonitor), PerPageOverride: optInt(o.Overrides.MonitorsPerPage), } if o.Overrides.OwnRegionsCount != nil { row.OwnRegionsOverride = strconv.FormatBool(*o.Overrides.OwnRegionsCount) diff --git a/internal/api/limits_test.go b/internal/api/limits_test.go index 40ef931..1f3e7d2 100644 --- a/internal/api/limits_test.go +++ b/internal/api/limits_test.go @@ -155,3 +155,68 @@ func TestLimits(t *testing.T) { t.Error("the organization settings lack the usage") } } + +func TestMonitorsPerStatusPageLimit(t *testing.T) { + e := newEnv(t) + ctx := context.Background() + reset := func() { + _ = e.asSystem(t, func(tx pgx.Tx) error { + _, err := tx.Exec(ctx, `DELETE FROM platform_settings WHERE key = 'limits'`) + return err + }) + } + reset() + t.Cleanup(reset) + admin := e.browser(t) + admin.signup("admin@"+uniq("mpp")+".test", uniq("mpp-admin-")) + if err := tenant.New(e.dbPool).Tx(ctx, tenant.Global(), func(q *store.Queries) error { + return q.MakeAdmin(ctx, admin.userIDSelf()) + }); err != nil { + t.Fatal(err) + } + if st, body := admin.do("PUT", "/api/v1/admin/limits", map[string]any{"monitors_per_page": 2}); st != http.StatusNoContent { + t.Fatalf("set defaults = %d %v", st, body) + } + + owner := e.browser(t) + owner.signup("o@"+uniq("mpp")+".test", uniq("mpp-")) + var ids []map[string]any + for range 3 { + _, m := owner.do("POST", "/api/v1/org/monitors", map[string]any{"name": "hb", "type": "heartbeat", "interval_seconds": 3600}) + ids = append(ids, map[string]any{"monitor_id": m["id"]}) + } + _, page := owner.do("POST", "/api/v1/org/statuspages", map[string]any{"slug": uniq("mpp-"), "title": "Status"}) + set := func(n int) (int, map[string]any) { + return owner.do("PUT", "/api/v1/org/statuspages/"+page["id"].(string)+"/monitors", map[string]any{"monitors": ids[:n]}) + } + if st, body := set(2); st != http.StatusNoContent { + t.Fatalf("two monitors = %d %v", st, body) + } + st, body := set(3) + expect(t, "three monitors", st, body, http.StatusUnprocessableEntity, "page_monitor_limit") + if _, _, html := owner.page("/statuspages/" + page["id"].(string)); !strings.Contains(html, "at most 2 monitors") { + t.Error("the editor does not name the limit") + } + + // An override for the organization raises it; lowered again, the page + // keeps its monitors but cannot grow. + org := owner.orgID() + if st, body := admin.do("PUT", "/api/v1/admin/orgs/"+org+"/limits", map[string]any{"monitors_per_page": 3}); st != http.StatusNoContent { + t.Fatalf("override = %d %v", st, body) + } + if st, body := set(3); st != http.StatusNoContent { + t.Fatalf("three monitors with the override = %d %v", st, body) + } + admin.do("PUT", "/api/v1/admin/orgs/"+org+"/limits", map[string]any{"monitors_per_page": 1}) + if st, body := set(3); st != http.StatusNoContent { + t.Errorf("saving a page beyond a lowered limit = %d %v", st, body) + } + if st, body := set(2); st != http.StatusNoContent { + t.Errorf("shrinking a page beyond a lowered limit = %d %v", st, body) + } + st, body = set(3) + expect(t, "growing again beyond the lowered limit", st, body, http.StatusUnprocessableEntity, "page_monitor_limit") + if _, _, html := admin.page("/admin"); !strings.Contains(html, "Monitors per status page") { + t.Error("the admin page does not offer the limit") + } +} diff --git a/internal/api/monitororder.go b/internal/api/monitororder.go new file mode 100644 index 0000000..11f4523 --- /dev/null +++ b/internal/api/monitororder.go @@ -0,0 +1,66 @@ +package api + +import ( + "errors" + "net/http" + + "github.com/gin-gonic/gin" + "github.com/google/uuid" + "github.com/jackc/pgx/v5" + + "git.zb-server.de/ZB-Server/uptimesebi/internal/authz" + "git.zb-server.de/ZB-Server/uptimesebi/internal/store" +) + +type monitorOrderRequest struct { + // MonitorIDs in the order wanted; usually the monitors of one group. + MonitorIDs []uuid.UUID `json:"monitor_ids" binding:"required,min=1,max=1000"` +} + +// orderMonitors stores the organization's own order of the monitors given, +// which the monitor list follows when sorted by its own order. It needs +// write access to every one of them. +func (s *Server) orderMonitors(c *gin.Context) { + var req monitorOrderRequest + if !bind(c, &req) { + return + } + p := current(c) + ctx := c.Request.Context() + t, err := s.loadGroupTree(ctx, p.scope()) + if err != nil { + internalError(c, err) + return + } + errDenied := errors.New("denied") + seen := map[uuid.UUID]bool{} + err = s.db.Tx(ctx, p.scope(), func(q *store.Queries) error { + for i, id := range req.MonitorIDs { + if seen[id] { + return pgx.ErrNoRows + } + seen[id] = true + m, err := q.GetMonitor(ctx, id) + if err != nil { + return err + } + if !canInGroup(p, authz.MonitorsWrite, t, m.GroupID) { + return errDenied + } + if _, err := q.SetMonitorPosition(ctx, store.SetMonitorPositionParams{ID: id, Position: new(int32(i))}); err != nil { + return err + } + } + return nil + }) + switch { + case errors.Is(err, errDenied): + fail(c, http.StatusForbidden, "forbidden") + case errors.Is(err, pgx.ErrNoRows): + fail(c, http.StatusUnprocessableEntity, "invalid_monitor") + case err != nil: + internalError(c, err) + default: + c.Status(http.StatusNoContent) + } +} diff --git a/internal/api/pages.go b/internal/api/pages.go index 21e4cb8..0079d96 100644 --- a/internal/api/pages.go +++ b/internal/api/pages.go @@ -122,6 +122,11 @@ func (s *Server) signupOptions(ctx context.Context) (bool, []web.IDPButton, erro } func (s *Server) signupPage(c *gin.Context) { + // Signed in already: straight to the monitors. + if auth.Current(c) != nil { + c.Redirect(http.StatusSeeOther, "/") + return + } email, providers, err := s.signupOptions(c.Request.Context()) if err != nil { internalError(c, err) diff --git a/internal/api/server.go b/internal/api/server.go index d608b0b..c9ccbca 100644 --- a/internal/api/server.go +++ b/internal/api/server.go @@ -156,6 +156,7 @@ func (s *Server) Mount(r gin.IRouter) { // scoped to a group grant access below that group only. org.GET("/monitors", s.listMonitors) org.POST("/monitors", s.createMonitor) + org.PUT("/monitors/order", s.orderMonitors) org.PUT("/monitors/:id", s.updateMonitor) org.DELETE("/monitors/:id", s.deleteMonitor) org.GET("/monitors/:id/evidence", s.listEvidence) diff --git a/internal/api/statuspages.go b/internal/api/statuspages.go index 580f02a..f2506b3 100644 --- a/internal/api/statuspages.go +++ b/internal/api/statuspages.go @@ -698,6 +698,16 @@ func (s *Server) setPageMonitors(c *gin.Context) { } } } + // A page beyond a lowered limit may keep its monitors but not add any. + if max := s.orgLimits(ctx, p.Org).MonitorsPerPage; max > 0 && len(req.Monitors) > max { + had, err := q.CountStatusPageMonitors(ctx, id) + if err != nil { + return err + } + if int64(len(req.Monitors)) > had { + return limitError{"page_monitor_limit", max} + } + } if err := q.ClearStatusPageMonitors(ctx, id); err != nil { return err } @@ -725,6 +735,7 @@ func (s *Server) setPageMonitors(c *gin.Context) { case isForeignKeyViolation(err), isUniqueViolation(err, "status_page_monitors_pkey"): // Unknown monitors, monitors of other orgs and duplicates. fail(c, http.StatusUnprocessableEntity, "invalid_monitor") + case failLimit(c, err): case err != nil: internalError(c, err) default: diff --git a/internal/i18n/locales/de.json b/internal/i18n/locales/de.json index 5ba0d1c..6febd01 100644 --- a/internal/i18n/locales/de.json +++ b/internal/i18n/locales/de.json @@ -107,6 +107,7 @@ "audit.action.member.role_unassign": "Rolle entzogen", "audit.action.monitor.create": "Monitor erstellt", "audit.action.monitor.delete": "Monitor gelöscht", + "audit.action.monitor.order": "Monitore angeordnet", "audit.action.monitor.update": "Monitor geändert", "audit.action.org.check_types_update": "Check-Typen geändert", "audit.action.org.create": "Organisation angelegt", @@ -619,6 +620,7 @@ "error.owner_cannot_be_removed": "Owner können nicht entfernt werden. Entziehe zuerst die Owner-Rechte.", "error.owner_has_all_permissions": "Der Owner hat bereits alle Berechtigungen.", "error.owner_only": "Nur Owner können ändern, wem die Organisation gehört.", + "error.page_monitor_limit": "Eine Statusseite darf höchstens {{.Max}} Monitore zeigen.", "error.password_too_short": "Das Passwort braucht mindestens {{.Min}} Zeichen.", "error.permission_escalation": "Du kannst keine Berechtigungen vergeben, die du selbst nicht hast.", "error.platform_region_limit": "Ein Monitor darf aus höchstens {{.Max}} Plattform-Regionen geprüft werden; eigene Checker-Regionen zählen nicht.", @@ -902,6 +904,7 @@ "limits.default": "Standard: {{.Value}}", "limits.intro": "Gelten für jede Organisation und jeden Account ohne eigenen Wert, auch wenn du sie später änderst. 0 heißt unbegrenzt. Ein gesenktes Limit lässt alles Bestehende stehen; nur neue Monitore, Statusseiten, Regionen oder Organisationen werden abgelehnt.", "limits.monitors": "Monitore", + "limits.monitors_per_page": "Monitore pro Statusseite", "limits.org_title": "Kontingent", "limits.orgs_per_account": "Organisationen pro Account", "limits.own_false": "zählen nicht", @@ -1019,6 +1022,9 @@ "monitors.alertmanager_hint": "Ausgefallen, solange ein Alert feuert, der alle Matcher erfüllt. Alerts kommen über einen Empfänger:", "monitors.all": "Alle Monitore", "monitors.all_results": "Alle Ergebnisse", + "monitors.arrange": "Monitore anordnen", + "monitors.arrange_done": "Anordnen beenden", + "monitors.arrange_hint": "Zieh die Monitore oder verschieb sie mit ↑ und ↓ in die gewünschte Reihenfolge innerhalb ihrer Gruppe. Jede Änderung wird sofort gespeichert und gilt für alle in der Organisation.", "monitors.assertion_op": "Operator", "monitors.assertion_path": "Pfad", "monitors.assertion_value": "Wert", @@ -1064,6 +1070,13 @@ "monitors.docker_host": "Docker-Host (unix://-Socket oder tcp://host:2375)", "monitors.edit": "Monitor bearbeiten", "monitors.expect_status": "Erwarteter Status (z. B. 2xx, 301)", + "monitors.filter_clear": "Alle Status anzeigen", + "monitors.filter_label": "Monitore nach Status anzeigen", + "monitors.filter_only": "Nur", + "monitors.filter_show": { + "one": "Nur den {{.Count}} Monitor mit Status „{{.Status}}“ anzeigen", + "other": "Nur die {{.Count}} Monitore mit Status „{{.Status}}“ anzeigen" + }, "monitors.follow_redirects": "Weiterleitungen folgen", "monitors.game_min_free_slots": "Mindestens freie Plätze", "monitors.game_min_free_slots_hint": "0 prüft nur, ob der Server antwortet.", @@ -1090,10 +1103,13 @@ "monitors.minecraft_edition": "Edition", "monitors.minecraft_hint": "Ziel ist host:port (Java meist 25565, Bedrock 19132). Pingt den Server wie die Serverliste im Spiel.", "monitors.minecraft_java": "Java Edition", + "monitors.move_down": "{{.Name}} nach unten", + "monitors.move_up": "{{.Name}} nach oben", "monitors.new": "Neuer Monitor", "monitors.no_data_since": "keine Daten seit {{.Time}}", "monitors.no_match": "Kein Monitor gefunden.", "monitors.no_results": "Noch keine Ergebnisse.", + "monitors.no_status_match": "Gerade hat kein Monitor diesen Status.", "monitors.op_absent": "fehlt", "monitors.op_contains": "enthält", "monitors.op_eq": "gleich", @@ -1144,6 +1160,12 @@ "monitors.snmp_oid": "OID", "monitors.snmp_value": "Wert", "monitors.snmp_version": "Version", + "monitors.sort": "Sortierung", + "monitors.sort_custom": "eigene Reihenfolge", + "monitors.sort_latency": "Latenz", + "monitors.sort_name": "Name", + "monitors.sort_status": "Status", + "monitors.sort_uptime": "Uptime", "monitors.stale_hours": "Verfällt nach (Stunden)", "monitors.stale_hours_hint": "Ein feuernder Alert, den Alertmanager nicht mehr wiederholt, gilt nach dieser Zeit als beendet. Halte sie über repeat_interval.", "monitors.steam_hint": "Ziel ist host:port des Query-Ports (meist der Spielport, z. B. 27015). Fragt den Server wie der Steam-Serverbrowser nach seinen Infos (A2S); funktioniert für Source- und die meisten Steam-Spiele.", @@ -1282,6 +1304,9 @@ "pages.intro": "Öffentliche Seiten mit dem Zustand ausgewählter Monitore. Jede Seite kann eine eigene Domain nutzen oder als einzelne HTML-Datei exportiert werden.", "pages.label": "Öffentlicher Name", "pages.logo": "Logo-URL (https)", + "pages.monitor_limit": "Diese Seite darf höchstens {{.Max}} Monitore zeigen.", + "pages.monitors_all": "Alle hinzufügen", + "pages.monitors_none": "Alle entfernen", "pages.no_group": "Ohne Gruppe", "pages.open": "Öffnen", "pages.own_servers": "Die Statusseiten dieser Organisation liefern nur ihre eigenen Statusseiten-Server aus, nicht die der Plattform. Ruf sie über die Adresse deiner Server auf oder verbinde eine eigene Domain, die auf sie zeigt.", diff --git a/internal/i18n/locales/en.json b/internal/i18n/locales/en.json index 0b5b463..b60a962 100644 --- a/internal/i18n/locales/en.json +++ b/internal/i18n/locales/en.json @@ -107,6 +107,7 @@ "audit.action.member.role_unassign": "Role removed", "audit.action.monitor.create": "Monitor created", "audit.action.monitor.delete": "Monitor deleted", + "audit.action.monitor.order": "Monitors put in order", "audit.action.monitor.update": "Monitor changed", "audit.action.org.check_types_update": "Check types changed", "audit.action.org.create": "Organization created", @@ -619,6 +620,7 @@ "error.owner_cannot_be_removed": "Owners cannot be removed. Take their ownership away first.", "error.owner_has_all_permissions": "The owner already has every permission.", "error.owner_only": "Only owners can change who owns the organization.", + "error.page_monitor_limit": "A status page may show at most {{.Max}} monitors.", "error.password_too_short": "The password needs at least {{.Min}} characters.", "error.permission_escalation": "You cannot grant permissions you do not hold yourself.", "error.platform_region_limit": "A monitor may be checked from at most {{.Max}} platform regions; your own checker regions do not count.", @@ -902,6 +904,7 @@ "limits.default": "default: {{.Value}}", "limits.intro": "Apply to every organization and account without an override of its own, also when you change them later. 0 means unlimited. Lowering a limit keeps everything that exists; only new monitors, status pages, regions or organizations are refused.", "limits.monitors": "Monitors", + "limits.monitors_per_page": "Monitors per status page", "limits.org_title": "Usage", "limits.orgs_per_account": "Organizations per account", "limits.own_false": "do not count", @@ -1019,6 +1022,9 @@ "monitors.alertmanager_hint": "Down while an alert matching all matchers fires. Alerts arrive through a receiver:", "monitors.all": "All monitors", "monitors.all_results": "All results", + "monitors.arrange": "Arrange monitors", + "monitors.arrange_done": "Done arranging", + "monitors.arrange_hint": "Drag the monitors, or move them with ↑ and ↓, into the order you want within each group. Every change is saved at once and is the same for everybody in the organization.", "monitors.assertion_op": "Operator", "monitors.assertion_path": "Path", "monitors.assertion_value": "Value", @@ -1064,6 +1070,13 @@ "monitors.docker_host": "Docker host (unix:// socket or tcp://host:2375)", "monitors.edit": "Edit monitor", "monitors.expect_status": "Expected status (e.g. 2xx, 301)", + "monitors.filter_clear": "Show all statuses", + "monitors.filter_label": "Show monitors by status", + "monitors.filter_only": "Only", + "monitors.filter_show": { + "one": "Show only the {{.Count}} monitor that is {{.Status}}", + "other": "Show only the {{.Count}} monitors that are {{.Status}}" + }, "monitors.follow_redirects": "Follow redirects", "monitors.game_min_free_slots": "Minimum free slots", "monitors.game_min_free_slots_hint": "0 only checks that the server answers.", @@ -1090,10 +1103,13 @@ "monitors.minecraft_edition": "Edition", "monitors.minecraft_hint": "Target is host:port (Java usually 25565, Bedrock 19132). Pings the server like the in-game server list.", "monitors.minecraft_java": "Java Edition", + "monitors.move_down": "Move {{.Name}} down", + "monitors.move_up": "Move {{.Name}} up", "monitors.new": "New monitor", "monitors.no_data_since": "no data since {{.Time}}", "monitors.no_match": "No monitor matches.", "monitors.no_results": "No results yet.", + "monitors.no_status_match": "No monitor has this status right now.", "monitors.op_absent": "is absent", "monitors.op_contains": "contains", "monitors.op_eq": "equals", @@ -1144,6 +1160,12 @@ "monitors.snmp_oid": "OID", "monitors.snmp_value": "Value", "monitors.snmp_version": "Version", + "monitors.sort": "Sort order", + "monitors.sort_custom": "own order", + "monitors.sort_latency": "latency", + "monitors.sort_name": "name", + "monitors.sort_status": "status", + "monitors.sort_uptime": "uptime", "monitors.stale_hours": "Stale after (hours)", "monitors.stale_hours_hint": "A firing alert Alertmanager stops repeating counts as over after this time. Keep it above repeat_interval.", "monitors.steam_hint": "Target is host:port of the query port (usually the game port, e.g. 27015). Asks the server for its info like the Steam server browser (A2S); works for Source and most Steam games.", @@ -1282,6 +1304,9 @@ "pages.intro": "Public pages showing the state of selected monitors. Each page can use its own domain or be exported as a single HTML file.", "pages.label": "Public name", "pages.logo": "Logo URL (https)", + "pages.monitor_limit": "This page may show at most {{.Max}} monitors.", + "pages.monitors_all": "Add all", + "pages.monitors_none": "Remove all", "pages.no_group": "No group", "pages.open": "Open", "pages.own_servers": "Your organization's own status page servers serve its pages; the platform's do not. Open them at the address of your servers or connect a custom domain pointing at them.", diff --git a/internal/migrations/sql/00053_limit_monitors_per_page.sql b/internal/migrations/sql/00053_limit_monitors_per_page.sql new file mode 100644 index 0000000..9a72830 --- /dev/null +++ b/internal/migrations/sql/00053_limit_monitors_per_page.sql @@ -0,0 +1,7 @@ +-- +goose Up +-- How many monitors one status page of the organization may show; NULL +-- follows the platform default, 0 means unlimited. +ALTER TABLE orgs ADD COLUMN limit_monitors_per_page integer CHECK (limit_monitors_per_page >= 0); + +-- +goose Down +ALTER TABLE orgs DROP COLUMN limit_monitors_per_page; diff --git a/internal/migrations/sql/00054_monitor_position.sql b/internal/migrations/sql/00054_monitor_position.sql new file mode 100644 index 0000000..dc0ffd6 --- /dev/null +++ b/internal/migrations/sql/00054_monitor_position.sql @@ -0,0 +1,7 @@ +-- +goose Up +-- The organization's own order of its monitors on the monitor list, within +-- each group; NULL sorts after positioned monitors, by name. +ALTER TABLE monitors ADD COLUMN position integer; + +-- +goose Down +ALTER TABLE monitors DROP COLUMN position; diff --git a/internal/store/limits.sql.go b/internal/store/limits.sql.go index 4df739e..c56c63e 100644 --- a/internal/store/limits.sql.go +++ b/internal/store/limits.sql.go @@ -15,6 +15,7 @@ import ( const adminListOrgs = `-- name: AdminListOrgs :many SELECT o.id, o.slug, o.name, o.created_at, o.suspended_at, o.suspended_reason, o.limit_monitors, o.limit_status_pages, o.limit_regions_per_monitor, o.limit_own_regions_count, + o.limit_monitors_per_page, (SELECT count(*) FROM monitors m WHERE m.org_id = o.id)::integer AS monitors, (SELECT count(*) FROM status_pages p WHERE p.org_id = o.id)::integer AS status_pages, coalesce(ow.id, '00000000-0000-0000-0000-000000000000'::uuid)::uuid AS owner_id, @@ -61,6 +62,7 @@ type AdminListOrgsRow struct { LimitStatusPages *int32 LimitRegionsPerMonitor *int32 LimitOwnRegionsCount *bool + LimitMonitorsPerPage *int32 Monitors int32 StatusPages int32 OwnerID uuid.UUID @@ -102,6 +104,7 @@ func (q *Queries) AdminListOrgs(ctx context.Context, arg AdminListOrgsParams) ([ &i.LimitStatusPages, &i.LimitRegionsPerMonitor, &i.LimitOwnRegionsCount, + &i.LimitMonitorsPerPage, &i.Monitors, &i.StatusPages, &i.OwnerID, @@ -133,6 +136,17 @@ func (q *Queries) CountMonitors(ctx context.Context, orgID uuid.UUID) (int64, er return count, err } +const countStatusPageMonitors = `-- name: CountStatusPageMonitors :one +SELECT count(*) FROM status_page_monitors WHERE page_id = $1 +` + +func (q *Queries) CountStatusPageMonitors(ctx context.Context, pageID uuid.UUID) (int64, error) { + row := q.db.QueryRow(ctx, countStatusPageMonitors, pageID) + var count int64 + err := row.Scan(&count) + return count, err +} + const countStatusPages = `-- name: CountStatusPages :one SELECT count(*) FROM status_pages WHERE org_id = $1 ` @@ -157,8 +171,9 @@ func (q *Queries) LockOrgUsage(ctx context.Context, orgID uuid.UUID) error { const setOrgLimits = `-- name: SetOrgLimits :one UPDATE orgs SET limit_monitors = $1, limit_status_pages = $2, - limit_regions_per_monitor = $3, limit_own_regions_count = $4 -WHERE id = $5 + limit_regions_per_monitor = $3, limit_own_regions_count = $4, + limit_monitors_per_page = $5 +WHERE id = $6 RETURNING id, slug ` @@ -167,6 +182,7 @@ type SetOrgLimitsParams struct { StatusPages *int32 RegionsPerMonitor *int32 OwnRegionsCount *bool + MonitorsPerPage *int32 ID uuid.UUID } @@ -181,6 +197,7 @@ func (q *Queries) SetOrgLimits(ctx context.Context, arg SetOrgLimitsParams) (Set arg.StatusPages, arg.RegionsPerMonitor, arg.OwnRegionsCount, + arg.MonitorsPerPage, arg.ID, ) var i SetOrgLimitsRow diff --git a/internal/store/models.go b/internal/store/models.go index 92e4e1b..301c5ed 100644 --- a/internal/store/models.go +++ b/internal/store/models.go @@ -257,6 +257,7 @@ type Monitor struct { UpdatedAt time.Time Confirmations int32 GroupID *uuid.UUID + Position *int32 } type MonitorAlertGroup struct { @@ -321,6 +322,7 @@ type Org struct { LimitStatusPages *int32 LimitRegionsPerMonitor *int32 LimitOwnRegionsCount *bool + LimitMonitorsPerPage *int32 } type PlatformIdentity struct { diff --git a/internal/store/monitors.sql.go b/internal/store/monitors.sql.go index 0a5e9a8..3e8a6e7 100644 --- a/internal/store/monitors.sql.go +++ b/internal/store/monitors.sql.go @@ -58,7 +58,7 @@ func (q *Queries) AllMonitorRegions(ctx context.Context) ([]AllMonitorRegionsRow const createMonitor = `-- name: CreateMonitor :one INSERT INTO monitors (org_id, name, type, target, interval_seconds, timeout_ms, config, enabled, confirmations, group_id) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) -RETURNING id, org_id, name, type, target, interval_seconds, timeout_ms, config, enabled, created_at, updated_at, confirmations, group_id +RETURNING id, org_id, name, type, target, interval_seconds, timeout_ms, config, enabled, created_at, updated_at, confirmations, group_id, position ` type CreateMonitorParams struct { @@ -102,6 +102,7 @@ func (q *Queries) CreateMonitor(ctx context.Context, arg CreateMonitorParams) (M &i.UpdatedAt, &i.Confirmations, &i.GroupID, + &i.Position, ) return i, err } @@ -128,7 +129,7 @@ func (q *Queries) DeleteMonitorRegions(ctx context.Context, monitorID uuid.UUID) } const getMonitor = `-- name: GetMonitor :one -SELECT id, org_id, name, type, target, interval_seconds, timeout_ms, config, enabled, created_at, updated_at, confirmations, group_id FROM monitors WHERE id = $1 +SELECT id, org_id, name, type, target, interval_seconds, timeout_ms, config, enabled, created_at, updated_at, confirmations, group_id, position FROM monitors WHERE id = $1 ` func (q *Queries) GetMonitor(ctx context.Context, id uuid.UUID) (Monitor, error) { @@ -148,6 +149,7 @@ func (q *Queries) GetMonitor(ctx context.Context, id uuid.UUID) (Monitor, error) &i.UpdatedAt, &i.Confirmations, &i.GroupID, + &i.Position, ) return i, err } @@ -190,7 +192,7 @@ func (q *Queries) ListEnabledMonitorsForSchedule(ctx context.Context) ([]ListEna } const listMonitors = `-- name: ListMonitors :many -SELECT id, org_id, name, type, target, interval_seconds, timeout_ms, config, enabled, created_at, updated_at, confirmations, group_id FROM monitors ORDER BY name +SELECT id, org_id, name, type, target, interval_seconds, timeout_ms, config, enabled, created_at, updated_at, confirmations, group_id, position FROM monitors ORDER BY name ` func (q *Queries) ListMonitors(ctx context.Context) ([]Monitor, error) { @@ -216,6 +218,7 @@ func (q *Queries) ListMonitors(ctx context.Context) ([]Monitor, error) { &i.UpdatedAt, &i.Confirmations, &i.GroupID, + &i.Position, ); err != nil { return nil, err } @@ -228,7 +231,7 @@ func (q *Queries) ListMonitors(ctx context.Context) ([]Monitor, error) { } const listMonitorsPage = `-- name: ListMonitorsPage :many -SELECT id, org_id, name, type, target, interval_seconds, timeout_ms, config, enabled, created_at, updated_at, confirmations, group_id FROM monitors +SELECT id, org_id, name, type, target, interval_seconds, timeout_ms, config, enabled, created_at, updated_at, confirmations, group_id, position FROM monitors WHERE true AND ($1::text IS NULL OR (name, id) > ($1, $2::uuid)) AND ($3::text IS NULL OR (name, id) < ($3, $4::uuid)) @@ -277,6 +280,7 @@ func (q *Queries) ListMonitorsPage(ctx context.Context, arg ListMonitorsPagePara &i.UpdatedAt, &i.Confirmations, &i.GroupID, + &i.Position, ); err != nil { return nil, err } @@ -313,7 +317,7 @@ func (q *Queries) MonitorRegions(ctx context.Context, monitorID uuid.UUID) ([]uu } const monitorsForJobs = `-- name: MonitorsForJobs :many -SELECT m.id, m.org_id, m.name, m.type, m.target, m.interval_seconds, m.timeout_ms, m.config, m.enabled, m.created_at, m.updated_at, m.confirmations, m.group_id FROM monitors m +SELECT m.id, m.org_id, m.name, m.type, m.target, m.interval_seconds, m.timeout_ms, m.config, m.enabled, m.created_at, m.updated_at, m.confirmations, m.group_id, m.position FROM monitors m JOIN monitor_regions r ON r.monitor_id = m.id AND r.region_id = $1 JOIN orgs o ON o.id = m.org_id AND o.suspended_at IS NULL WHERE m.id = ANY ($2::uuid[]) AND m.enabled @@ -352,6 +356,7 @@ func (q *Queries) MonitorsForJobs(ctx context.Context, arg MonitorsForJobsParams &i.UpdatedAt, &i.Confirmations, &i.GroupID, + &i.Position, ); err != nil { return nil, err } @@ -419,11 +424,28 @@ func (q *Queries) MonitorsForResults(ctx context.Context, arg MonitorsForResults return items, nil } +const setMonitorPosition = `-- name: SetMonitorPosition :execrows +UPDATE monitors SET position = $1 WHERE id = $2 +` + +type SetMonitorPositionParams struct { + Position *int32 + ID uuid.UUID +} + +func (q *Queries) SetMonitorPosition(ctx context.Context, arg SetMonitorPositionParams) (int64, error) { + result, err := q.db.Exec(ctx, setMonitorPosition, arg.Position, arg.ID) + if err != nil { + return 0, err + } + return result.RowsAffected(), nil +} + const updateMonitor = `-- name: UpdateMonitor :one UPDATE monitors SET name = $2, type = $3, target = $4, interval_seconds = $5, timeout_ms = $6, config = $7, enabled = $8, confirmations = $9, group_id = $10, updated_at = now() WHERE id = $1 -RETURNING id, org_id, name, type, target, interval_seconds, timeout_ms, config, enabled, created_at, updated_at, confirmations, group_id +RETURNING id, org_id, name, type, target, interval_seconds, timeout_ms, config, enabled, created_at, updated_at, confirmations, group_id, position ` type UpdateMonitorParams struct { @@ -467,6 +489,7 @@ func (q *Queries) UpdateMonitor(ctx context.Context, arg UpdateMonitorParams) (M &i.UpdatedAt, &i.Confirmations, &i.GroupID, + &i.Position, ) return i, err } diff --git a/internal/store/orgs.sql.go b/internal/store/orgs.sql.go index 2cca851..fdd0a8a 100644 --- a/internal/store/orgs.sql.go +++ b/internal/store/orgs.sql.go @@ -13,7 +13,7 @@ import ( const createOrg = `-- name: CreateOrg :one INSERT INTO orgs (id, slug, name) VALUES ($1, $2, $3) -RETURNING id, slug, name, created_at, updated_at, require_totp, require_sso, api_token_max_days, disabled_check_types, suspended_at, suspended_reason, limit_monitors, limit_status_pages, limit_regions_per_monitor, limit_own_regions_count +RETURNING id, slug, name, created_at, updated_at, require_totp, require_sso, api_token_max_days, disabled_check_types, suspended_at, suspended_reason, limit_monitors, limit_status_pages, limit_regions_per_monitor, limit_own_regions_count, limit_monitors_per_page ` type CreateOrgParams struct { @@ -41,6 +41,7 @@ func (q *Queries) CreateOrg(ctx context.Context, arg CreateOrgParams) (Org, erro &i.LimitStatusPages, &i.LimitRegionsPerMonitor, &i.LimitOwnRegionsCount, + &i.LimitMonitorsPerPage, ) return i, err } @@ -58,7 +59,7 @@ func (q *Queries) DeleteOrg(ctx context.Context, id uuid.UUID) (int64, error) { } const getOrg = `-- name: GetOrg :one -SELECT id, slug, name, created_at, updated_at, require_totp, require_sso, api_token_max_days, disabled_check_types, suspended_at, suspended_reason, limit_monitors, limit_status_pages, limit_regions_per_monitor, limit_own_regions_count FROM orgs WHERE id = $1 +SELECT id, slug, name, created_at, updated_at, require_totp, require_sso, api_token_max_days, disabled_check_types, suspended_at, suspended_reason, limit_monitors, limit_status_pages, limit_regions_per_monitor, limit_own_regions_count, limit_monitors_per_page FROM orgs WHERE id = $1 ` func (q *Queries) GetOrg(ctx context.Context, id uuid.UUID) (Org, error) { @@ -80,12 +81,13 @@ func (q *Queries) GetOrg(ctx context.Context, id uuid.UUID) (Org, error) { &i.LimitStatusPages, &i.LimitRegionsPerMonitor, &i.LimitOwnRegionsCount, + &i.LimitMonitorsPerPage, ) return i, err } const getOrgBySlug = `-- name: GetOrgBySlug :one -SELECT id, slug, name, created_at, updated_at, require_totp, require_sso, api_token_max_days, disabled_check_types, suspended_at, suspended_reason, limit_monitors, limit_status_pages, limit_regions_per_monitor, limit_own_regions_count FROM orgs WHERE slug = $1 +SELECT id, slug, name, created_at, updated_at, require_totp, require_sso, api_token_max_days, disabled_check_types, suspended_at, suspended_reason, limit_monitors, limit_status_pages, limit_regions_per_monitor, limit_own_regions_count, limit_monitors_per_page FROM orgs WHERE slug = $1 ` func (q *Queries) GetOrgBySlug(ctx context.Context, slug string) (Org, error) { @@ -107,12 +109,13 @@ func (q *Queries) GetOrgBySlug(ctx context.Context, slug string) (Org, error) { &i.LimitStatusPages, &i.LimitRegionsPerMonitor, &i.LimitOwnRegionsCount, + &i.LimitMonitorsPerPage, ) return i, err } const listOrgs = `-- name: ListOrgs :many -SELECT id, slug, name, created_at, updated_at, require_totp, require_sso, api_token_max_days, disabled_check_types, suspended_at, suspended_reason, limit_monitors, limit_status_pages, limit_regions_per_monitor, limit_own_regions_count FROM orgs ORDER BY name +SELECT id, slug, name, created_at, updated_at, require_totp, require_sso, api_token_max_days, disabled_check_types, suspended_at, suspended_reason, limit_monitors, limit_status_pages, limit_regions_per_monitor, limit_own_regions_count, limit_monitors_per_page FROM orgs ORDER BY name ` func (q *Queries) ListOrgs(ctx context.Context) ([]Org, error) { @@ -140,6 +143,7 @@ func (q *Queries) ListOrgs(ctx context.Context) ([]Org, error) { &i.LimitStatusPages, &i.LimitRegionsPerMonitor, &i.LimitOwnRegionsCount, + &i.LimitMonitorsPerPage, ); err != nil { return nil, err } @@ -168,7 +172,7 @@ func (q *Queries) SetOrgDisabledCheckTypes(ctx context.Context, arg SetOrgDisabl const updateOrgPolicy = `-- name: UpdateOrgPolicy :one UPDATE orgs SET require_totp = $2, require_sso = $3, api_token_max_days = $4, updated_at = now() WHERE id = $1 -RETURNING id, slug, name, created_at, updated_at, require_totp, require_sso, api_token_max_days, disabled_check_types, suspended_at, suspended_reason, limit_monitors, limit_status_pages, limit_regions_per_monitor, limit_own_regions_count +RETURNING id, slug, name, created_at, updated_at, require_totp, require_sso, api_token_max_days, disabled_check_types, suspended_at, suspended_reason, limit_monitors, limit_status_pages, limit_regions_per_monitor, limit_own_regions_count, limit_monitors_per_page ` type UpdateOrgPolicyParams struct { @@ -202,6 +206,7 @@ func (q *Queries) UpdateOrgPolicy(ctx context.Context, arg UpdateOrgPolicyParams &i.LimitStatusPages, &i.LimitRegionsPerMonitor, &i.LimitOwnRegionsCount, + &i.LimitMonitorsPerPage, ) return i, err } diff --git a/internal/store/querier.go b/internal/store/querier.go index 08046f8..38cb0b3 100644 --- a/internal/store/querier.go +++ b/internal/store/querier.go @@ -56,6 +56,7 @@ type Querier interface { CountOwnedOrgs(ctx context.Context, userID uuid.UUID) (int64, error) CountOwners(ctx context.Context, orgID uuid.UUID) (int64, error) CountRoleAssignments(ctx context.Context, roleID uuid.UUID) (int64, error) + CountStatusPageMonitors(ctx context.Context, pageID uuid.UUID) (int64, error) CountStatusPages(ctx context.Context, orgID uuid.UUID) (int64, error) CountSupportTicketsSince(ctx context.Context, arg CountSupportTicketsSinceParams) (int64, error) CountUnusedRecoveryCodes(ctx context.Context, userID uuid.UUID) (int64, error) @@ -357,6 +358,7 @@ type Querier interface { ServablePages(ctx context.Context, agentOrg *uuid.UUID) ([]ServablePagesRow, error) SetAgentAllowPrivate(ctx context.Context, arg SetAgentAllowPrivateParams) (int64, error) SetIncidentTitle(ctx context.Context, arg SetIncidentTitleParams) (int64, error) + SetMonitorPosition(ctx context.Context, arg SetMonitorPositionParams) (int64, error) SetOrgDisabledCheckTypes(ctx context.Context, arg SetOrgDisabledCheckTypesParams) error SetOrgLimits(ctx context.Context, arg SetOrgLimitsParams) (SetOrgLimitsRow, error) SetOwner(ctx context.Context, arg SetOwnerParams) (int64, error) diff --git a/internal/store/queries/limits.sql b/internal/store/queries/limits.sql index 87669f9..13be9d4 100644 --- a/internal/store/queries/limits.sql +++ b/internal/store/queries/limits.sql @@ -9,9 +9,13 @@ SELECT count(*) FROM monitors WHERE org_id = $1; -- name: CountStatusPages :one SELECT count(*) FROM status_pages WHERE org_id = $1; +-- name: CountStatusPageMonitors :one +SELECT count(*) FROM status_page_monitors WHERE page_id = $1; + -- name: SetOrgLimits :one UPDATE orgs SET limit_monitors = sqlc.narg(monitors), limit_status_pages = sqlc.narg(status_pages), - limit_regions_per_monitor = sqlc.narg(regions_per_monitor), limit_own_regions_count = sqlc.narg(own_regions_count) + limit_regions_per_monitor = sqlc.narg(regions_per_monitor), limit_own_regions_count = sqlc.narg(own_regions_count), + limit_monitors_per_page = sqlc.narg(monitors_per_page) WHERE id = sqlc.arg(id) RETURNING id, slug; @@ -25,6 +29,7 @@ RETURNING id, email; -- keyset cursor. SELECT o.id, o.slug, o.name, o.created_at, o.suspended_at, o.suspended_reason, o.limit_monitors, o.limit_status_pages, o.limit_regions_per_monitor, o.limit_own_regions_count, + o.limit_monitors_per_page, (SELECT count(*) FROM monitors m WHERE m.org_id = o.id)::integer AS monitors, (SELECT count(*) FROM status_pages p WHERE p.org_id = o.id)::integer AS status_pages, coalesce(ow.id, '00000000-0000-0000-0000-000000000000'::uuid)::uuid AS owner_id, diff --git a/internal/store/queries/monitors.sql b/internal/store/queries/monitors.sql index 7590c87..c2e4b52 100644 --- a/internal/store/queries/monitors.sql +++ b/internal/store/queries/monitors.sql @@ -72,3 +72,6 @@ ORDER BY CASE WHEN sqlc.narg(before_s)::text IS NULL THEN id END, name DESC, id DESC LIMIT sqlc.arg(max_rows); + +-- name: SetMonitorPosition :execrows +UPDATE monitors SET position = sqlc.arg(position) WHERE id = sqlc.arg(id); diff --git a/internal/web/admin_orgs.templ b/internal/web/admin_orgs.templ index f038ea0..474a6bf 100644 --- a/internal/web/admin_orgs.templ +++ b/internal/web/admin_orgs.templ @@ -14,6 +14,7 @@ type LimitsView struct { RegionsPerMonitor int OwnRegionsCount bool OrgsPerAccount int + MonitorsPerPage int } // OrgsView lists organizations for platform admins. @@ -36,6 +37,7 @@ type OrgRow struct { StatusPagesOverride string RegionsOverride string OwnRegionsOverride string + PerPageOverride string Owner *ModeratedTarget OwnerOrgs int OwnerOrgLimit string @@ -62,6 +64,7 @@ templ limitsSection(d LimitsView) { @numberField(i18n.T(ctx, "limits.status_pages"), "status_pages", d.StatusPages, 0, 1000000, "") @numberField(i18n.T(ctx, "limits.regions_per_monitor"), "regions_per_monitor", d.RegionsPerMonitor, 0, 1000, "") @numberField(i18n.T(ctx, "limits.orgs_per_account"), "orgs_per_account", d.OrgsPerAccount, 0, 100000, "") + @numberField(i18n.T(ctx, "limits.monitors_per_page"), "monitors_per_page", d.MonitorsPerPage, 0, 200, "") @checkbox(i18n.T(ctx, "limits.own_regions_count"), "own_regions_count", d.OwnRegionsCount)

{ i18n.T(ctx, "limits.own_regions_count_hint") }

@@ -149,6 +152,7 @@ templ orgsSection(v OrgsView) { @overrideField(i18n.T(ctx, "limits.monitors"), "monitors", o.MonitorsOverride, v.Defaults.Monitors, 1000000) @overrideField(i18n.T(ctx, "limits.status_pages"), "status_pages", o.StatusPagesOverride, v.Defaults.StatusPages, 1000000) @overrideField(i18n.T(ctx, "limits.regions_per_monitor"), "regions_per_monitor", o.RegionsOverride, v.Defaults.RegionsPerMonitor, 1000) + @overrideField(i18n.T(ctx, "limits.monitors_per_page"), "monitors_per_page", o.PerPageOverride, v.Defaults.MonitorsPerPage, 200) ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -6173,85 +6503,85 @@ func groupSelect(name string, groups []GroupOption, selected string, allowNone b } ctx = templ.InitializeContext(ctx) ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 521, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 557, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -6294,7 +6624,7 @@ func GroupsPage(p Page, me Me, v GroupsView) templ.Component { } ctx = templ.InitializeContext(ctx) ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Var294 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_Var311 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { @@ -6306,20 +6636,20 @@ func GroupsPage(p Page, me Me, v GroupsView) templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 531, "

← ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 558, "

← ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var295 string - templ_7745c5c3_Var295, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.monitors.title")) + var templ_7745c5c3_Var312 string + templ_7745c5c3_Var312, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.monitors.title")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1274, Col: 115} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1351, Col: 115} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var295)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var312)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 532, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 559, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -6328,69 +6658,69 @@ func GroupsPage(p Page, me Me, v GroupsView) templ.Component { return templ_7745c5c3_Err } if len(v.Groups) > 0 { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 533, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 549, " ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 576, " ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if v.CanWrite { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 550, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 577, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -6498,7 +6828,7 @@ func GroupsPage(p Page, me Me, v GroupsView) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 551, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 578, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -6510,20 +6840,20 @@ func GroupsPage(p Page, me Me, v GroupsView) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 552, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 581, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -6539,14 +6869,14 @@ func GroupsPage(p Page, me Me, v GroupsView) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 555, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 582, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } return nil }) - templ_7745c5c3_Err = consoleShell(p, me).Render(templ.WithChildren(ctx, templ_7745c5c3_Var294), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = consoleShell(p, me).Render(templ.WithChildren(ctx, templ_7745c5c3_Var311), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -6578,7 +6908,7 @@ func pingSection(url string) templ.Component { } ctx = templ.InitializeContext(ctx) ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 556, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 583, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -6586,55 +6916,55 @@ func pingSection(url string) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 557, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 584, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var306 string - templ_7745c5c3_Var306, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "monitors.ping_intro")) + var templ_7745c5c3_Var323 string + templ_7745c5c3_Var323, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "monitors.ping_intro")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1329, Col: 83} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1406, Col: 83} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var306)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var323)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 558, "

")
+		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 585, "

")
 		if templ_7745c5c3_Err != nil {
 			return templ_7745c5c3_Err
 		}
-		var templ_7745c5c3_Var307 string
-		templ_7745c5c3_Var307, templ_7745c5c3_Err = templ.JoinStringErrs("curl -fsS -m 10 --retry 3 " + url + "\n")
+		var templ_7745c5c3_Var324 string
+		templ_7745c5c3_Var324, templ_7745c5c3_Err = templ.JoinStringErrs("curl -fsS -m 10 --retry 3 " + url + "\n")
 		if templ_7745c5c3_Err != nil {
-			return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1330, Col: 137}
+			return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1407, Col: 137}
 		}
-		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var307))
+		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var324))
 		if templ_7745c5c3_Err != nil {
 			return templ_7745c5c3_Err
 		}
-		var templ_7745c5c3_Var308 string
-		templ_7745c5c3_Var308, templ_7745c5c3_Err = templ.JoinStringErrs("curl -fsS -m 10 --retry 3 --data-raw \"$output\" " + url + "/fail")
+		var templ_7745c5c3_Var325 string
+		templ_7745c5c3_Var325, templ_7745c5c3_Err = templ.JoinStringErrs("curl -fsS -m 10 --retry 3 --data-raw \"$output\" " + url + "/fail")
 		if templ_7745c5c3_Err != nil {
-			return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1330, Col: 208}
+			return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1407, Col: 208}
 		}
-		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var308))
+		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var325))
 		if templ_7745c5c3_Err != nil {
 			return templ_7745c5c3_Err
 		}
-		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 559, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 586, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var309 string - templ_7745c5c3_Var309, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "monitors.ping_secret")) + var templ_7745c5c3_Var326 string + templ_7745c5c3_Var326, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "monitors.ping_secret")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1331, Col: 84} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1408, Col: 84} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var309)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var326)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 560, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 587, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -6680,20 +7010,20 @@ func dbFields(typ string, d DBForm) templ.Component { } ctx = templ.InitializeContext(ctx) ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 561, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 588, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var311 string - templ_7745c5c3_Var311, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "monitors.db_hint")) + var templ_7745c5c3_Var328 string + templ_7745c5c3_Var328, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "monitors.db_hint")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1357, Col: 69} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1434, Col: 69} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var311)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var328)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 562, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 589, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -6721,33 +7051,33 @@ func dbFields(typ string, d DBForm) templ.Component { return templ_7745c5c3_Err } if typ != "redis" && typ != "mongodb" { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 563, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -6779,56 +7109,56 @@ func secretField(label, name string, set bool) templ.Component { } ctx = templ.InitializeContext(ctx) ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 566, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -6854,66 +7184,66 @@ func tlsField(value string, modes ...string) templ.Component { } ctx = templ.InitializeContext(ctx) ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 572, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -6938,20 +7268,20 @@ func brokerFields(typ string, b BrokerForm) templ.Component { } ctx = templ.InitializeContext(ctx) ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 580, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 607, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var323 string - templ_7745c5c3_Var323, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "monitors.broker_hint_"+typ)) + var templ_7745c5c3_Var340 string + templ_7745c5c3_Var340, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "monitors.broker_hint_"+typ)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1405, Col: 78} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1482, Col: 78} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var323)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var340)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 581, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 608, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -6978,66 +7308,66 @@ func brokerFields(typ string, b BrokerForm) templ.Component { return templ_7745c5c3_Err } case "kafka": - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 582, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -7100,7 +7430,7 @@ func IncidentDetailPage(p Page, me Me, v IncidentDetailView) templ.Component { } ctx = templ.InitializeContext(ctx) ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Var328 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_Var345 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { @@ -7112,45 +7442,45 @@ func IncidentDetailPage(p Page, me Me, v IncidentDetailView) templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 590, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 617, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var329 string - templ_7745c5c3_Var329, templ_7745c5c3_Err = templ.JoinStringErrs("← " + i18n.T(ctx, "incidents.all")) + var templ_7745c5c3_Var346 string + templ_7745c5c3_Var346, templ_7745c5c3_Err = templ.JoinStringErrs("← " + i18n.T(ctx, "incidents.all")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1452, Col: 120} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1529, Col: 120} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var329)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var346)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 591, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 618, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if v.Row.Title != "" { - var templ_7745c5c3_Var330 string - templ_7745c5c3_Var330, templ_7745c5c3_Err = templ.JoinStringErrs(v.Row.Title) + var templ_7745c5c3_Var347 string + templ_7745c5c3_Var347, templ_7745c5c3_Err = templ.JoinStringErrs(v.Row.Title) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1455, Col: 17} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1532, Col: 17} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var330)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var347)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } else { - var templ_7745c5c3_Var331 string - templ_7745c5c3_Var331, templ_7745c5c3_Err = templ.JoinStringErrs(v.Row.Monitor) + var templ_7745c5c3_Var348 string + templ_7745c5c3_Var348, templ_7745c5c3_Err = templ.JoinStringErrs(v.Row.Monitor) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1457, Col: 19} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1534, Col: 19} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var331)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var348)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 592, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 619, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -7158,46 +7488,46 @@ func IncidentDetailPage(p Page, me Me, v IncidentDetailView) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 593, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 621, "\" class=\"hover:underline\">") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var333 string - templ_7745c5c3_Var333, templ_7745c5c3_Err = templ.JoinStringErrs(v.Row.Monitor) + var templ_7745c5c3_Var350 string + templ_7745c5c3_Var350, templ_7745c5c3_Err = templ.JoinStringErrs(v.Row.Monitor) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1462, Col: 100} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1539, Col: 100} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var333)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var350)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 595, " ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 622, " ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var334 string - templ_7745c5c3_Var334, templ_7745c5c3_Err = templ.JoinStringErrs(v.Row.Started + " · " + v.Row.Duration) + var templ_7745c5c3_Var351 string + templ_7745c5c3_Var351, templ_7745c5c3_Err = templ.JoinStringErrs(v.Row.Started + " · " + v.Row.Duration) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1463, Col: 87} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1540, Col: 87} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var334)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var351)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 596, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 623, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -7205,18 +7535,18 @@ func IncidentDetailPage(p Page, me Me, v IncidentDetailView) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 597, "
    ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 624, "
      ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } for _, e := range v.Timeline { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 598, "
    1. ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 625, "
    2. ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } switch e.Kind { case "update": - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 599, "

      ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 626, "

      ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -7224,107 +7554,107 @@ func IncidentDetailPage(p Page, me Me, v IncidentDetailView) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 600, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 627, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var335 string - templ_7745c5c3_Var335, templ_7745c5c3_Err = templ.JoinStringErrs(e.At) + var templ_7745c5c3_Var352 string + templ_7745c5c3_Var352, templ_7745c5c3_Err = templ.JoinStringErrs(e.At) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1475, Col: 51} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1552, Col: 51} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var335)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var352)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 601, " ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 628, " ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if e.Author != "" { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 602, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 629, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var336 string - templ_7745c5c3_Var336, templ_7745c5c3_Err = templ.JoinStringErrs(e.Author) + var templ_7745c5c3_Var353 string + templ_7745c5c3_Var353, templ_7745c5c3_Err = templ.JoinStringErrs(e.Author) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1477, Col: 46} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1554, Col: 46} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var336)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var353)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 603, " ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 630, " ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } if !e.Public { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 604, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 631, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var337 string - templ_7745c5c3_Var337, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "incident.internal")) + var templ_7745c5c3_Var354 string + templ_7745c5c3_Var354, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "incident.internal")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1480, Col: 94} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1557, Col: 94} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var337)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var354)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 605, " ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 632, " ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } if v.CanWrite { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 606, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 636, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 610, "

      ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 637, "

      ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -7332,103 +7662,103 @@ func IncidentDetailPage(p Page, me Me, v IncidentDetailView) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 611, "
      ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 638, "
      ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } case "resolved": - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 612, "

      ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 639, "

      ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var341 string - templ_7745c5c3_Var341, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "incident.recovered")) + var templ_7745c5c3_Var358 string + templ_7745c5c3_Var358, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "incident.recovered")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1490, Col: 85} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1567, Col: 85} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var341)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var358)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 613, " ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 640, " ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var342 string - templ_7745c5c3_Var342, templ_7745c5c3_Err = templ.JoinStringErrs(e.At) + var templ_7745c5c3_Var359 string + templ_7745c5c3_Var359, templ_7745c5c3_Err = templ.JoinStringErrs(e.At) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1490, Col: 136} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1567, Col: 136} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var342)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var359)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 614, "

      ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 641, "

      ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } default: - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 615, "

      ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 642, "

      ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var343 string - templ_7745c5c3_Var343, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "incident.began")) + var templ_7745c5c3_Var360 string + templ_7745c5c3_Var360, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "incident.began")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1492, Col: 83} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1569, Col: 83} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var343)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var360)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 616, " ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 643, " ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var344 string - templ_7745c5c3_Var344, templ_7745c5c3_Err = templ.JoinStringErrs(e.At) + var templ_7745c5c3_Var361 string + templ_7745c5c3_Var361, templ_7745c5c3_Err = templ.JoinStringErrs(e.At) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1492, Col: 134} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1569, Col: 134} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var344)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var361)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 617, "

      ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 644, "

      ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if len(v.Row.Cause) > 0 { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 618, "

      ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 645, "

      ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var345 string - templ_7745c5c3_Var345, templ_7745c5c3_Err = templ.JoinStringErrs(strings.Join(v.Row.Cause, " · ")) + var templ_7745c5c3_Var362 string + templ_7745c5c3_Var362, templ_7745c5c3_Err = templ.JoinStringErrs(strings.Join(v.Row.Cause, " · ")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1494, Col: 90} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1571, Col: 90} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var345)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var362)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 619, "

      ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 646, "

      ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 620, "
    3. ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 647, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 621, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 648, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if v.CanWrite { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 622, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 650, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 677, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) - templ_7745c5c3_Err = consoleShell(p, me).Render(templ.WithChildren(ctx, templ_7745c5c3_Var328), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = consoleShell(p, me).Render(templ.WithChildren(ctx, templ_7745c5c3_Var345), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -7726,7 +8056,7 @@ func IncidentStatusesPage(p Page, me Me, statuses []CustomIncidentStatus, canMan } ctx = templ.InitializeContext(ctx) ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Var359 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_Var376 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { @@ -7742,7 +8072,7 @@ func IncidentStatusesPage(p Page, me Me, statuses []CustomIncidentStatus, canMan if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 651, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 678, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -7750,12 +8080,12 @@ func IncidentStatusesPage(p Page, me Me, statuses []CustomIncidentStatus, canMan if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 652, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 682, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -7777,139 +8107,139 @@ func IncidentStatusesPage(p Page, me Me, statuses []CustomIncidentStatus, canMan return templ_7745c5c3_Err } if len(statuses) == 0 { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 656, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 683, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var360 string - templ_7745c5c3_Var360, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "incident_statuses.none")) + var templ_7745c5c3_Var377 string + templ_7745c5c3_Var377, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "incident_statuses.none")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1556, Col: 73} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1633, Col: 73} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var360)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var377)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 657, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 684, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 658, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if canManage { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 671, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 703, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) - templ_7745c5c3_Err = consoleShell(p, me).Render(templ.WithChildren(ctx, templ_7745c5c3_Var359), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = consoleShell(p, me).Render(templ.WithChildren(ctx, templ_7745c5c3_Var376), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -8000,4 +8330,264 @@ func IncidentStatusesPage(p Page, me Me, statuses []CustomIncidentStatus, canMan }) } +func filterTitle(ctx context.Context, f StatusFilter) string { + if f.Active { + return i18n.T(ctx, "monitors.filter_clear") + } + return i18n.T(ctx, "monitors.filter_show", "Status", i18n.T(ctx, "status."+string(f.Status)), "Count", f.Count) +} + +func sortSwitch(opts []SortOption) templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 704, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +// treeList is a group's own monitors, as links or, while arranging, as +// rows to put in order. +func treeList(ms []MonitorRow, arrange bool) templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + ctx = templ.ClearChildren(ctx) + if arrange { + templ_7745c5c3_Err = arrangeList(ms).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else { + templ_7745c5c3_Err = monitorList(ms).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + return nil + }) +} + +// arrangeList lets monitors be dragged or moved up and down; every change +// is saved at once. +func arrangeList(ms []MonitorRow) templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + ctx = templ.ClearChildren(ctx) + if len(ms) > 0 { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 712, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + return nil + }) +} + var _ = templruntime.GeneratedTemplate diff --git a/internal/web/statuspages.templ b/internal/web/statuspages.templ index d2d787a..ae6f416 100644 --- a/internal/web/statuspages.templ +++ b/internal/web/statuspages.templ @@ -118,6 +118,8 @@ type PageEditor struct { SwitchOffAt string // DomainChangesPerDay is how often the domain may be changed a day. DomainChangesPerDay int + // MonitorLimit is how many monitors the page may show; 0 is any. + MonitorLimit int RecordName string RecordValue string Suspended bool @@ -272,6 +274,14 @@ templ StatusPageEditor(p Page, me Me, e PageEditor) { @formError() if len(e.Monitors) == 0 {

{ i18n.T(ctx, "console.monitors.empty") }

+ } else { + if e.MonitorLimit > 0 { +

{ i18n.T(ctx, "pages.monitor_limit", "Max", e.MonitorLimit) }

+ } +

+ + +

}