From 53ff2a628d584db253463f937f75c0034646f873 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Untersch=C3=BCtz?= Date: Sun, 22 Nov 2026 12:54:56 +0100 Subject: [PATCH 1/3] feat(store): record agent instances and query results by checker Refs #82 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3 --- .../migrations/sql/00032_agent_instances.sql | 24 ++++ internal/store/agent_instances.sql.go | 130 ++++++++++++++++++ internal/store/check_results.sql.go | 82 ++++++++++- internal/store/models.go | 9 ++ internal/store/querier.go | 9 ++ internal/store/queries/agent_instances.sql | 20 +++ internal/store/queries/check_results.sql | 17 ++- 7 files changed, 289 insertions(+), 2 deletions(-) create mode 100644 internal/migrations/sql/00032_agent_instances.sql create mode 100644 internal/store/agent_instances.sql.go create mode 100644 internal/store/queries/agent_instances.sql diff --git a/internal/migrations/sql/00032_agent_instances.sql b/internal/migrations/sql/00032_agent_instances.sql new file mode 100644 index 0000000..388024b --- /dev/null +++ b/internal/migrations/sql/00032_agent_instances.sql @@ -0,0 +1,24 @@ +-- +goose Up +-- Processes running with an agent token. Several may share a token; check +-- results name the instance that ran them. +CREATE TABLE agent_instances ( + id uuid PRIMARY KEY, + agent_id uuid NOT NULL REFERENCES agents (id) ON DELETE CASCADE, + org_id uuid REFERENCES orgs (id) ON DELETE CASCADE, + release text NOT NULL DEFAULT '', + started_at timestamptz NOT NULL DEFAULT now(), + last_seen_at timestamptz NOT NULL DEFAULT now() +); +CREATE INDEX agent_instances_agent_idx ON agent_instances (agent_id, last_seen_at DESC); + +ALTER TABLE agent_instances ENABLE ROW LEVEL SECURITY; +ALTER TABLE agent_instances FORCE ROW LEVEL SECURITY; +-- Platform instances serve every organization and are visible to all, like +-- platform regions. +CREATE POLICY agent_instances_read ON agent_instances FOR SELECT + USING (app_scope_system() OR org_id IS NULL OR org_id = app_org_id()); +CREATE POLICY agent_instances_write ON agent_instances FOR ALL + USING (app_scope_system()) WITH CHECK (app_scope_system()); + +-- +goose Down +DROP TABLE agent_instances; diff --git a/internal/store/agent_instances.sql.go b/internal/store/agent_instances.sql.go new file mode 100644 index 0000000..ddcda64 --- /dev/null +++ b/internal/store/agent_instances.sql.go @@ -0,0 +1,130 @@ +// Code generated by sqlc. DO NOT EDIT. +// versions: +// sqlc v1.31.1 +// source: agent_instances.sql + +package store + +import ( + "context" + "time" + + "github.com/google/uuid" +) + +const agentInstancesByID = `-- name: AgentInstancesByID :many +SELECT i.id, i.agent_id, i.release, i.started_at, i.last_seen_at, i.org_id, + a.name AS agent_name, a.kind, r.id AS region_id, coalesce(r.name, '')::text AS region_name +FROM agent_instances i +JOIN agents a ON a.id = i.agent_id +LEFT JOIN regions r ON r.id = a.region_id +WHERE i.id = ANY ($1::uuid[]) +` + +type AgentInstancesByIDRow struct { + ID uuid.UUID + AgentID uuid.UUID + Release string + StartedAt time.Time + LastSeenAt time.Time + OrgID *uuid.UUID + AgentName string + Kind string + RegionID *uuid.UUID + RegionName string +} + +func (q *Queries) AgentInstancesByID(ctx context.Context, ids []uuid.UUID) ([]AgentInstancesByIDRow, error) { + rows, err := q.db.Query(ctx, agentInstancesByID, ids) + if err != nil { + return nil, err + } + defer rows.Close() + items := []AgentInstancesByIDRow{} + for rows.Next() { + var i AgentInstancesByIDRow + if err := rows.Scan( + &i.ID, + &i.AgentID, + &i.Release, + &i.StartedAt, + &i.LastSeenAt, + &i.OrgID, + &i.AgentName, + &i.Kind, + &i.RegionID, + &i.RegionName, + ); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} + +const siblingInstances = `-- name: SiblingInstances :many +SELECT id, release, started_at, last_seen_at FROM agent_instances +WHERE agent_id = $1 AND last_seen_at > now() - interval '1 day' +ORDER BY last_seen_at DESC +` + +type SiblingInstancesRow struct { + ID uuid.UUID + Release string + StartedAt time.Time + LastSeenAt time.Time +} + +// Other instances of the same agent seen in the last day. +func (q *Queries) SiblingInstances(ctx context.Context, agentID uuid.UUID) ([]SiblingInstancesRow, error) { + rows, err := q.db.Query(ctx, siblingInstances, agentID) + if err != nil { + return nil, err + } + defer rows.Close() + items := []SiblingInstancesRow{} + for rows.Next() { + var i SiblingInstancesRow + if err := rows.Scan( + &i.ID, + &i.Release, + &i.StartedAt, + &i.LastSeenAt, + ); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} + +const touchAgentInstance = `-- name: TouchAgentInstance :exec +INSERT INTO agent_instances (id, agent_id, org_id, release) +VALUES ($1, $2, $3, $4) +ON CONFLICT (id) DO UPDATE SET release = EXCLUDED.release, last_seen_at = now() +WHERE agent_instances.last_seen_at < now() - interval '1 minute' OR agent_instances.release <> EXCLUDED.release +` + +type TouchAgentInstanceParams struct { + ID uuid.UUID + AgentID uuid.UUID + OrgID *uuid.UUID + Release string +} + +// Writes at most once a minute per instance; agents poll far more often. +func (q *Queries) TouchAgentInstance(ctx context.Context, arg TouchAgentInstanceParams) error { + _, err := q.db.Exec(ctx, touchAgentInstance, + arg.ID, + arg.AgentID, + arg.OrgID, + arg.Release, + ) + return err +} diff --git a/internal/store/check_results.sql.go b/internal/store/check_results.sql.go index 3ddd50e..64b726e 100644 --- a/internal/store/check_results.sql.go +++ b/internal/store/check_results.sql.go @@ -12,6 +12,32 @@ import ( "github.com/google/uuid" ) +const checkerStats = `-- name: CheckerStats :one +SELECT count(*)::bigint AS total, count(*) FILTER (WHERE NOT ok)::bigint AS failed, + coalesce(avg(latency_ms), 0)::real AS avg_latency_ms +FROM check_results +WHERE org_id = $1 AND checker_id = $2 AND time > now() - interval '1 hour' +` + +type CheckerStatsParams struct { + OrgID uuid.UUID + CheckerID uuid.UUID +} + +type CheckerStatsRow struct { + Total int64 + Failed int64 + AvgLatencyMs float32 +} + +// How much one instance checked for the organization in the last hour. +func (q *Queries) CheckerStats(ctx context.Context, arg CheckerStatsParams) (CheckerStatsRow, error) { + row := q.db.QueryRow(ctx, checkerStats, arg.OrgID, arg.CheckerID) + var i CheckerStatsRow + err := row.Scan(&i.Total, &i.Failed, &i.AvgLatencyMs) + return i, err +} + const dailyBuckets = `-- name: DailyBuckets :many SELECT bucket::timestamptz AS bucket, sum(total)::bigint AS total, sum(ok_count)::bigint AS ok_count FROM check_results_1d @@ -492,7 +518,7 @@ func (q *Queries) RangeBucketsHourly(ctx context.Context, arg RangeBucketsHourly } const recentResults = `-- name: RecentResults :many -SELECT time, region, ok, latency_ms, status_code, error +SELECT time, region, ok, latency_ms, status_code, error, checker_id FROM check_results WHERE org_id = $1 AND monitor_id = $2 AND time > $3 ORDER BY time DESC @@ -512,6 +538,7 @@ type RecentResultsRow struct { LatencyMs *int32 StatusCode *int32 Error *string + CheckerID uuid.UUID } func (q *Queries) RecentResults(ctx context.Context, arg RecentResultsParams) ([]RecentResultsRow, error) { @@ -530,6 +557,7 @@ func (q *Queries) RecentResults(ctx context.Context, arg RecentResultsParams) ([ &i.LatencyMs, &i.StatusCode, &i.Error, + &i.CheckerID, ); err != nil { return nil, err } @@ -701,6 +729,58 @@ func (q *Queries) RegionBucketsHourly(ctx context.Context, arg RegionBucketsHour return items, nil } +const resultsByChecker = `-- name: ResultsByChecker :many +SELECT r.time, r.monitor_id, r.region, r.ok, r.latency_ms, r.status_code, r.error +FROM check_results r +WHERE r.org_id = $1 AND r.checker_id = $2 AND r.time > now() - interval '1 day' +ORDER BY r.time DESC +LIMIT 50 +` + +type ResultsByCheckerParams struct { + OrgID uuid.UUID + CheckerID uuid.UUID +} + +type ResultsByCheckerRow struct { + Time time.Time + MonitorID uuid.UUID + Region string + Ok bool + LatencyMs *int32 + StatusCode *int32 + Error *string +} + +// The organization's latest results run by one checker instance. +func (q *Queries) ResultsByChecker(ctx context.Context, arg ResultsByCheckerParams) ([]ResultsByCheckerRow, error) { + rows, err := q.db.Query(ctx, resultsByChecker, arg.OrgID, arg.CheckerID) + if err != nil { + return nil, err + } + defer rows.Close() + items := []ResultsByCheckerRow{} + for rows.Next() { + var i ResultsByCheckerRow + if err := rows.Scan( + &i.Time, + &i.MonitorID, + &i.Region, + &i.Ok, + &i.LatencyMs, + &i.StatusCode, + &i.Error, + ); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} + const uptimeSince = `-- name: UptimeSince :many SELECT monitor_id, sum(total)::bigint AS total, sum(ok_count)::bigint AS ok_count FROM check_results_1h diff --git a/internal/store/models.go b/internal/store/models.go index 6e27c11..b027dbb 100644 --- a/internal/store/models.go +++ b/internal/store/models.go @@ -24,6 +24,15 @@ type Agent struct { RegionID *uuid.UUID } +type AgentInstance struct { + ID uuid.UUID + AgentID uuid.UUID + OrgID *uuid.UUID + Release string + StartedAt time.Time + LastSeenAt time.Time +} + type AgentStorage struct { Owner string Key string diff --git a/internal/store/querier.go b/internal/store/querier.go index 68f1a5e..655fdeb 100644 --- a/internal/store/querier.go +++ b/internal/store/querier.go @@ -17,8 +17,11 @@ type Querier interface { AddMembership(ctx context.Context, arg AddMembershipParams) error AddMonitorRegion(ctx context.Context, arg AddMonitorRegionParams) error AddStatusPageMonitor(ctx context.Context, arg AddStatusPageMonitorParams) error + AgentInstancesByID(ctx context.Context, ids []uuid.UUID) ([]AgentInstancesByIDRow, error) AllMonitorRegions(ctx context.Context) ([]AllMonitorRegionsRow, error) AnyUserExists(ctx context.Context) (bool, error) + // How much one instance checked for the organization in the last hour. + CheckerStats(ctx context.Context, arg CheckerStatsParams) (CheckerStatsRow, error) // System scope. Leases due rows for five minutes so a crashed sender's rows // come back; SKIP LOCKED lets every API replica work the outbox. ClaimNotifications(ctx context.Context, max int32) ([]uuid.UUID, error) @@ -219,12 +222,16 @@ type Querier interface { // Moves the subgroups of a group that is about to be deleted. ReparentGroups(ctx context.Context, arg ReparentGroupsParams) error ResolveIncident(ctx context.Context, arg ResolveIncidentParams) (Incident, error) + // The organization's latest results run by one checker instance. + ResultsByChecker(ctx context.Context, arg ResultsByCheckerParams) ([]ResultsByCheckerRow, error) ScrubAuditEmail(ctx context.Context, email string) error SetPasswordHash(ctx context.Context, arg SetPasswordHashParams) error // Changing the domain drops a previous verification. SetStatusPageDomain(ctx context.Context, arg SetStatusPageDomainParams) (StatusPage, error) SetUserAdmin(ctx context.Context, arg SetUserAdminParams) (int64, error) SetUserLocale(ctx context.Context, arg SetUserLocaleParams) error + // Other instances of the same agent seen in the last day. + SiblingInstances(ctx context.Context, agentID uuid.UUID) ([]SiblingInstancesRow, error) StatusPageMonitors(ctx context.Context, pageID uuid.UUID) ([]StatusPageMonitorsRow, error) // Deletes key and, as certmagic expects, everything below it. StorageDelete(ctx context.Context, arg StorageDeleteParams) (int64, error) @@ -233,6 +240,8 @@ type Querier interface { StoragePut(ctx context.Context, arg StoragePutParams) error TouchAPIToken(ctx context.Context, id uuid.UUID) error TouchAgent(ctx context.Context, arg TouchAgentParams) error + // Writes at most once a minute per instance; agents poll far more often. + TouchAgentInstance(ctx context.Context, arg TouchAgentInstanceParams) error TouchIdentity(ctx context.Context, arg TouchIdentityParams) error UpdateChannel(ctx context.Context, arg UpdateChannelParams) (NotificationChannel, error) UpdateGroup(ctx context.Context, arg UpdateGroupParams) (MonitorGroup, error) diff --git a/internal/store/queries/agent_instances.sql b/internal/store/queries/agent_instances.sql new file mode 100644 index 0000000..63e3f76 --- /dev/null +++ b/internal/store/queries/agent_instances.sql @@ -0,0 +1,20 @@ +-- name: TouchAgentInstance :exec +-- Writes at most once a minute per instance; agents poll far more often. +INSERT INTO agent_instances (id, agent_id, org_id, release) +VALUES ($1, $2, $3, $4) +ON CONFLICT (id) DO UPDATE SET release = EXCLUDED.release, last_seen_at = now() +WHERE agent_instances.last_seen_at < now() - interval '1 minute' OR agent_instances.release <> EXCLUDED.release; + +-- name: AgentInstancesByID :many +SELECT i.id, i.agent_id, i.release, i.started_at, i.last_seen_at, i.org_id, + a.name AS agent_name, a.kind, r.id AS region_id, coalesce(r.name, '')::text AS region_name +FROM agent_instances i +JOIN agents a ON a.id = i.agent_id +LEFT JOIN regions r ON r.id = a.region_id +WHERE i.id = ANY (sqlc.arg(ids)::uuid[]); + +-- name: SiblingInstances :many +-- Other instances of the same agent seen in the last day. +SELECT id, release, started_at, last_seen_at FROM agent_instances +WHERE agent_id = $1 AND last_seen_at > now() - interval '1 day' +ORDER BY last_seen_at DESC; diff --git a/internal/store/queries/check_results.sql b/internal/store/queries/check_results.sql index e4b49e5..14c6a1b 100644 --- a/internal/store/queries/check_results.sql +++ b/internal/store/queries/check_results.sql @@ -13,7 +13,7 @@ WHERE org_id = $1 AND time > now() - interval '1 day' ORDER BY monitor_id, region, time DESC; -- name: RecentResults :many -SELECT time, region, ok, latency_ms, status_code, error +SELECT time, region, ok, latency_ms, status_code, error, checker_id FROM check_results WHERE org_id = $1 AND monitor_id = $2 AND time > $3 ORDER BY time DESC @@ -128,3 +128,18 @@ SELECT monitor_id, region, min(time)::timestamptz AS first FROM check_results WHERE org_id = $1 AND time >= $2 GROUP BY 1, 2; + +-- name: ResultsByChecker :many +-- The organization's latest results run by one checker instance. +SELECT r.time, r.monitor_id, r.region, r.ok, r.latency_ms, r.status_code, r.error +FROM check_results r +WHERE r.org_id = $1 AND r.checker_id = sqlc.arg(checker_id) AND r.time > now() - interval '1 day' +ORDER BY r.time DESC +LIMIT 50; + +-- name: CheckerStats :one +-- How much one instance checked for the organization in the last hour. +SELECT count(*)::bigint AS total, count(*) FILTER (WHERE NOT ok)::bigint AS failed, + coalesce(avg(latency_ms), 0)::real AS avg_latency_ms +FROM check_results +WHERE org_id = $1 AND checker_id = sqlc.arg(checker_id) AND time > now() - interval '1 hour'; -- 2.54.1 From 0c2155fdc2db8c005b72273dd38736e1ca2f416b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Untersch=C3=BCtz?= Date: Sun, 22 Nov 2026 12:54:57 +0100 Subject: [PATCH 2/3] feat: show which checker ran a check and what it is doing Every recent check on a monitor page names and links the checker instance that ran it. The checker page shows whether it is active, its version, the checks it runs right now and has queued, and the viewer's latest results on it, refreshing every five seconds. Platform checkers serve all organizations, so other organizations' work appears only as a count. Checks in progress are tracked in Redis between handing out a job and receiving its result. Closes #82 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3 --- internal/api/agent.go | 20 +- internal/api/checkers.go | 315 +++++++++++++ internal/api/checkers_test.go | 99 ++++ internal/api/console.go | 20 +- internal/api/server.go | 1 + internal/i18n/i18n_test.go | 1 + internal/i18n/locales/de.json | 22 + internal/i18n/locales/en.json | 22 + internal/schedule/schedule.go | 15 + internal/web/checkers.templ | 160 +++++++ internal/web/checkers_templ.go | 676 ++++++++++++++++++++++++++++ internal/web/layout.templ | 11 +- internal/web/layout_templ.go | 267 ++++++----- internal/web/monitors.templ | 5 + internal/web/monitors_templ.go | 798 +++++++++++++++++---------------- 15 files changed, 1909 insertions(+), 523 deletions(-) create mode 100644 internal/api/checkers.go create mode 100644 internal/api/checkers_test.go create mode 100644 internal/web/checkers.templ create mode 100644 internal/web/checkers_templ.go diff --git a/internal/api/agent.go b/internal/api/agent.go index 3eff643..88c13dc 100644 --- a/internal/api/agent.go +++ b/internal/api/agent.go @@ -75,7 +75,10 @@ func (s *Server) agentAuth() gin.HandlerFunc { if a, err = q.GetAgentByHash(ctx, HashToken(tok)); err != nil { return err } - return q.TouchAgent(ctx, store.TouchAgentParams{ID: a.ID, Release: &release}) + if err := q.TouchAgent(ctx, store.TouchAgentParams{ID: a.ID, Release: &release}); err != nil { + return err + } + return q.TouchAgentInstance(ctx, store.TouchAgentInstanceParams{ID: instance, AgentID: a.ID, OrgID: a.OrgID, Release: release}) }) if errors.Is(err, pgx.ErrNoRows) { fail(c, http.StatusUnauthorized, "unauthenticated") @@ -147,20 +150,23 @@ func (s *Server) agentJobs(c *gin.Context) { internalError(c, err) return } - jobs, err := s.resolveJobs(ctx, agentOf(c), entries) + jobs, orgs, err := s.resolveJobs(ctx, agentOf(c), entries) if err != nil { internalError(c, err) return } + s.trackRunning(ctx, instance, jobs, orgs) c.JSON(http.StatusOK, agentapi.JobsResponse{Jobs: jobs}) } // resolveJobs attaches the current monitor settings to dispatched runs. // Checking is cross-tenant work, hence the system scope. -func (s *Server) resolveJobs(ctx context.Context, a store.GetAgentByHashRow, entries []schedule.Entry) ([]agentapi.Job, error) { +// It also returns each monitor's organization. +func (s *Server) resolveJobs(ctx context.Context, a store.GetAgentByHashRow, entries []schedule.Entry) ([]agentapi.Job, map[uuid.UUID]uuid.UUID, error) { jobs := []agentapi.Job{} + orgs := map[uuid.UUID]uuid.UUID{} if len(entries) == 0 { - return jobs, nil + return jobs, orgs, nil } ids := make([]uuid.UUID, len(entries)) for i, e := range entries { @@ -173,7 +179,7 @@ func (s *Server) resolveJobs(ctx context.Context, a store.GetAgentByHashRow, ent return err }) if err != nil { - return nil, err + return nil, nil, err } byID := make(map[uuid.UUID]store.Monitor, len(rows)) for _, m := range rows { @@ -188,8 +194,9 @@ func (s *Server) resolveJobs(ctx context.Context, a store.GetAgentByHashRow, ent MonitorID: m.ID, ScheduledAt: e.ScheduledAt, Type: m.Type, Target: m.Target, TimeoutMS: int(m.TimeoutMs), Config: m.Config, AllowPrivate: s.allowPrivate(a), }) + orgs[m.ID] = m.OrgID } - return jobs, nil + return jobs, orgs, nil } func (s *Server) agentResults(c *gin.Context) { @@ -262,6 +269,7 @@ func (s *Server) agentResults(c *gin.Context) { } s.evaluateResults(ctx, region, accepted, monitors) s.storeEvidence(ctx, region, instance, accepted, monitors) + s.finishRunning(ctx, instance, accepted) c.Status(http.StatusNoContent) } diff --git a/internal/api/checkers.go b/internal/api/checkers.go new file mode 100644 index 0000000..f147ba4 --- /dev/null +++ b/internal/api/checkers.go @@ -0,0 +1,315 @@ +package api + +import ( + "context" + "errors" + "fmt" + "net/http" + "slices" + "strconv" + "strings" + "time" + + "github.com/a-h/templ" + "github.com/gin-gonic/gin" + "github.com/google/uuid" + "github.com/redis/go-redis/v9" + + "git.zb-server.de/ZB-Server/uptimesebi/internal/agentapi" + "git.zb-server.de/ZB-Server/uptimesebi/internal/authz" + "git.zb-server.de/ZB-Server/uptimesebi/internal/schedule" + "git.zb-server.de/ZB-Server/uptimesebi/internal/store" + "git.zb-server.de/ZB-Server/uptimesebi/internal/web" +) + +// running: maps monitor IDs to "||" +// for runs handed out and not yet reported. It shows what a checker is +// doing; entries of crashed instances are ignored once their checks would +// have timed out. +func runningKey(instance uuid.UUID) string { return "running:" + instance.String() } + +// runningGrace is how long past its timeout a run counts as in progress, +// covering the report delay. +const runningGrace = 30 * time.Second + +func (s *Server) trackRunning(ctx context.Context, instance uuid.UUID, jobs []agentapi.Job, orgs map[uuid.UUID]uuid.UUID) { + if len(jobs) == 0 { + return + } + now := time.Now().UnixMilli() + fields := make([]any, 0, 2*len(jobs)) + for _, j := range jobs { + fields = append(fields, j.MonitorID.String(), fmt.Sprintf("%s|%d|%d", orgs[j.MonitorID], now, j.TimeoutMS)) + } + key := runningKey(instance) + _, err := s.rdb.TxPipelined(ctx, func(p redis.Pipeliner) error { + p.HSet(ctx, key, fields...) + p.Expire(ctx, key, 15*time.Minute) + return nil + }) + if err != nil { + s.log.WarnContext(ctx, "tracking running checks failed", "error", err) + } +} + +func (s *Server) finishRunning(ctx context.Context, instance uuid.UUID, results []agentapi.Result) { + if len(results) == 0 { + return + } + ids := make([]string, len(results)) + for i, r := range results { + ids[i] = r.MonitorID.String() + } + if err := s.rdb.HDel(ctx, runningKey(instance), ids...).Err(); err != nil { + s.log.WarnContext(ctx, "clearing running checks failed", "error", err) + } +} + +// runningRun is a check an instance is working on. +type runningRun struct { + MonitorID uuid.UUID + Org uuid.UUID + Since time.Time +} + +func (s *Server) runningOn(ctx context.Context, instance uuid.UUID, now time.Time) ([]runningRun, error) { + all, err := s.rdb.HGetAll(ctx, runningKey(instance)).Result() + if err != nil { + return nil, err + } + var out []runningRun + for id, v := range all { + parts := strings.Split(v, "|") + if len(parts) != 3 { + continue + } + m, err1 := uuid.Parse(id) + org, err2 := uuid.Parse(parts[0]) + at, err3 := strconv.ParseInt(parts[1], 10, 64) + timeout, err4 := strconv.ParseInt(parts[2], 10, 64) + if err1 != nil || err2 != nil || err3 != nil || err4 != nil { + continue + } + since := time.UnixMilli(at) + if now.Sub(since) > time.Duration(timeout)*time.Millisecond+runningGrace { + continue + } + out = append(out, runningRun{MonitorID: m, Org: org, Since: since}) + } + slices.SortFunc(out, func(a, b runningRun) int { return a.Since.Compare(b.Since) }) + return out, nil +} + +// checkerActivity is what the console and API show of a checker instance. +// Platform checkers work for every organization: only the viewer's own +// monitors are named, the rest is counted. +type checkerActivity struct { + ID uuid.UUID `json:"id"` + Agent string `json:"agent"` + Region string `json:"region"` + Platform bool `json:"platform"` + Release string `json:"release"` + StartedAt time.Time `json:"started_at"` + LastSeenAt time.Time `json:"last_seen_at"` + Live bool `json:"live"` + Queued int64 `json:"queued"` + Running []runningView `json:"running"` + OtherOrgs int `json:"running_for_others"` + LastHour checkerHourStats `json:"last_hour"` + Recent []recentByCheck `json:"recent"` + Siblings []uuid.UUID `json:"other_instances"` + regionID string + monitorName map[uuid.UUID]string +} + +type runningView struct { + MonitorID uuid.UUID `json:"monitor_id"` + Monitor string `json:"monitor"` + Since time.Time `json:"since"` +} + +type checkerHourStats struct { + Checks int64 `json:"checks"` + Failed int64 `json:"failed"` + AvgLatencyMS float32 `json:"avg_latency_ms"` +} + +type recentByCheck struct { + Time time.Time `json:"time"` + MonitorID uuid.UUID `json:"monitor_id"` + Monitor string `json:"monitor"` + OK bool `json:"ok"` + LatencyMS *int32 `json:"latency_ms,omitempty"` + StatusCode *int32 `json:"status_code,omitempty"` + Error *string `json:"error,omitempty"` +} + +var errNoChecker = errors.New("api: checker not found") + +// loadCheckerActivity gathers the activity of a checker instance visible to +// p: platform instances and those of p's organization. +func (s *Server) loadCheckerActivity(ctx context.Context, p *principal, instance uuid.UUID) (checkerActivity, error) { + now := time.Now() + a := checkerActivity{ID: instance, Running: []runningView{}, Recent: []recentByCheck{}, Siblings: []uuid.UUID{}, monitorName: map[uuid.UUID]string{}} + t, err := s.loadGroupTree(ctx, p.scope()) + if err != nil { + return a, err + } + readable := map[uuid.UUID]bool{} + err = s.db.Tx(ctx, p.scope(), func(q *store.Queries) error { + rows, err := q.AgentInstancesByID(ctx, []uuid.UUID{instance}) + if err != nil { + return err + } + if len(rows) == 0 || rows[0].Kind != "checker" { + return errNoChecker + } + r := rows[0] + a.Agent, a.Region, a.Platform, a.Release = r.AgentName, r.RegionName, r.OrgID == nil, r.Release + a.StartedAt, a.LastSeenAt = r.StartedAt, r.LastSeenAt + if r.RegionID != nil { + a.regionID = r.RegionID.String() + } + siblings, err := q.SiblingInstances(ctx, r.AgentID) + if err != nil { + return err + } + for _, sb := range siblings { + if sb.ID != instance { + a.Siblings = append(a.Siblings, sb.ID) + } + } + monitors, err := q.ListMonitors(ctx) + if err != nil { + return err + } + for _, m := range monitors { + if canInGroup(p, authz.MonitorsRead, t, m.GroupID) { + readable[m.ID] = true + a.monitorName[m.ID] = m.Name + } + } + stats, err := q.CheckerStats(ctx, store.CheckerStatsParams{OrgID: p.Org.ID, CheckerID: instance}) + if err != nil { + return err + } + a.LastHour = checkerHourStats{Checks: stats.Total, Failed: stats.Failed, AvgLatencyMS: stats.AvgLatencyMs} + recent, err := q.ResultsByChecker(ctx, store.ResultsByCheckerParams{OrgID: p.Org.ID, CheckerID: instance}) + for _, r := range recent { + if readable[r.MonitorID] { + a.Recent = append(a.Recent, recentByCheck{ + Time: r.Time, MonitorID: r.MonitorID, Monitor: a.monitorName[r.MonitorID], OK: r.Ok, + LatencyMS: r.LatencyMs, StatusCode: r.StatusCode, Error: r.Error, + }) + } + } + return err + }) + if err != nil { + return a, err + } + if a.regionID != "" { + if seen, err := s.sched.LastSeen(ctx, a.regionID, instance); err == nil && !seen.IsZero() { + a.LastSeenAt = seen + a.Live = now.Sub(seen) < schedule.StaleAfter + } + } + if a.Queued, err = s.sched.QueueLen(ctx, instance); err != nil { + return a, err + } + running, err := s.runningOn(ctx, instance, now) + if err != nil { + return a, err + } + for _, r := range running { + if r.Org != p.Org.ID || !readable[r.MonitorID] { + a.OtherOrgs++ + continue + } + a.Running = append(a.Running, runningView{MonitorID: r.MonitorID, Monitor: a.monitorName[r.MonitorID], Since: r.Since}) + } + return a, nil +} + +func (s *Server) getChecker(c *gin.Context) { + id, err := uuid.Parse(c.Param("id")) + if err != nil { + fail(c, http.StatusNotFound, "not_found") + return + } + a, err := s.loadCheckerActivity(c.Request.Context(), current(c), id) + if errors.Is(err, errNoChecker) { + fail(c, http.StatusNotFound, "not_found") + return + } + if err != nil { + internalError(c, err) + return + } + c.JSON(http.StatusOK, a) +} + +func (s *Server) checkerPage(c *gin.Context, p *principal, page web.Page, me web.Me) (templ.Component, error) { + id, err := uuid.Parse(c.Param("id")) + if err != nil { + return notFoundPage(c) + } + a, err := s.loadCheckerActivity(c.Request.Context(), p, id) + if errors.Is(err, errNoChecker) { + return notFoundPage(c) + } + if err != nil { + return nil, err + } + const layout = "2006-01-02 15:04:05" + v := web.CheckerView{ + ID: a.ID.String(), Agent: a.Agent, Region: a.Region, Platform: a.Platform, Release: a.Release, + Started: a.StartedAt.Local().Format(layout), LastSeen: a.LastSeenAt.Local().Format(layout), Live: a.Live, + Queued: int(a.Queued), OtherOrgs: a.OtherOrgs, + Checks: int(a.LastHour.Checks), Failed: int(a.LastHour.Failed), AvgLatency: fmt.Sprintf("%.0f ms", a.LastHour.AvgLatencyMS), + } + now := time.Now() + for _, r := range a.Running { + v.Running = append(v.Running, web.CheckerRun{ + MonitorURL: "/monitors/" + r.MonitorID.String(), Monitor: r.Monitor, For: now.Sub(r.Since).Round(time.Second).String(), + }) + } + for _, r := range a.Recent { + row := web.CheckerResult{ + Time: r.Time.Local().Format("15:04:05"), MonitorURL: "/monitors/" + r.MonitorID.String(), Monitor: r.Monitor, + OK: r.OK, Latency: "–", Detail: deref(r.Error), + } + if r.LatencyMS != nil { + row.Latency = fmt.Sprintf("%d ms", *r.LatencyMS) + } + if row.Detail == "" && r.StatusCode != nil { + row.Detail = strconv.Itoa(int(*r.StatusCode)) + } + v.Recent = append(v.Recent, row) + } + for _, sb := range a.Siblings { + v.Siblings = append(v.Siblings, web.CheckerLink{URL: "/checkers/" + sb.String(), Label: shortID(sb)}) + } + page.RefreshSeconds = 5 + return web.CheckerPage(page, me, v), nil +} + +func shortID(id uuid.UUID) string { return id.String()[:8] } + +// checkerLinks names the checker instances in ids for result lists. +func (s *Server) checkerLinks(ctx context.Context, p *principal, ids []uuid.UUID) (map[uuid.UUID]web.CheckerLink, error) { + out := map[uuid.UUID]web.CheckerLink{} + if len(ids) == 0 { + return out, nil + } + var rows []store.AgentInstancesByIDRow + err := s.db.Tx(ctx, p.scope(), func(q *store.Queries) error { + var err error + rows, err = q.AgentInstancesByID(ctx, ids) + return err + }) + for _, r := range rows { + out[r.ID] = web.CheckerLink{URL: "/checkers/" + r.ID.String(), Label: r.AgentName + " · " + shortID(r.ID)} + } + return out, err +} diff --git a/internal/api/checkers_test.go b/internal/api/checkers_test.go new file mode 100644 index 0000000..00f4e51 --- /dev/null +++ b/internal/api/checkers_test.go @@ -0,0 +1,99 @@ +package api_test + +import ( + "context" + "net/http" + "net/http/httptest" + "strings" + "testing" + "time" + + "github.com/google/uuid" + + "git.zb-server.de/ZB-Server/uptimesebi/internal/api" + "git.zb-server.de/ZB-Server/uptimesebi/internal/store" + "git.zb-server.de/ZB-Server/uptimesebi/internal/tenant" +) + +func TestCheckerActivity(t *testing.T) { + e := newEnv(t) + ctx, cancel := context.WithCancel(context.Background()) + t.Cleanup(cancel) + go e.api.RunScheduler(ctx) + + slow := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + time.Sleep(3 * time.Second) + })) + defer slow.Close() + tok, region := e.platformChecker(t, uniq("eu-")) + instance, _ := e.startChecker(t, tok) + + alice, bob := e.browser(t), e.browser(t) + alice.signup("a@"+uniq("ca")+".test", uniq("ca-")) + bob.signup("b@"+uniq("cb")+".test", uniq("cb-")) + create := func(b *browser, name string) string { + t.Helper() + st, body := b.do("POST", "/api/v1/org/monitors", map[string]any{ + "name": name, "type": "http", "target": slow.URL, "interval_seconds": 3600, "timeout_ms": 5000, "regions": []string{region}, + }) + if st != http.StatusCreated { + t.Fatalf("create monitor = %d %v", st, body) + } + return body["id"].(string) + } + aliceMonitor := create(alice, "Alice shop") + create(bob, "Bob secret service") + + path := "/api/v1/org/checkers/" + instance.String() + var view map[string]any + waitFor(t, 10*time.Second, "both checks in progress", func() bool { + _, view = alice.do("GET", path, nil) + running, _ := view["running"].([]any) + return len(running) == 1 && view["running_for_others"] == float64(1) + }) + if raw := mustJSON(view); strings.Contains(raw, "Bob secret service") || view["live"] != true || view["platform"] != true { + t.Errorf("alice's view = %s", raw) + } + if _, bv := bob.do("GET", path, nil); strings.Contains(mustJSON(bv), "Alice shop") { + t.Error("bob sees alice's monitor") + } + + waitFor(t, 10*time.Second, "the finished check listed", func() bool { + _, view = alice.do("GET", path, nil) + recent, _ := view["recent"].([]any) + running, _ := view["running"].([]any) + return len(recent) == 1 && len(running) == 0 + }) + if _, _, page := alice.page("/monitors/" + aliceMonitor); !strings.Contains(page, `href="/checkers/`+instance.String()+`"`) { + t.Error("the monitor page does not link the checker that ran the check") + } + st, _, page := alice.page("/checkers/" + instance.String()) + if st != http.StatusOK || !strings.Contains(page, "Alice shop") || strings.Contains(page, "Bob secret service") || !strings.Contains(page, `http-equiv="refresh"`) { + t.Errorf("checker page = %d, lacks own monitor, shows others or does not refresh", st) + } + + // Checkers of another organization stay invisible. + bobOrg := uuid.MustParse(bob.orgID()) + var bobTok string + err := tenant.New(e.dbPool).Tx(context.Background(), tenant.System(), func(q *store.Queries) error { + r, err := q.CreateRegion(context.Background(), store.CreateRegionParams{OrgID: &bobOrg, Key: uniq("own-"), Name: "Bob DC"}) + if err != nil { + return err + } + var params store.CreateAgentParams + bobTok, params = api.NewAgentToken(&bobOrg, "checker", "bob-dc", &r.ID) + _, err = q.CreateAgent(context.Background(), params) + return err + }) + if err != nil { + t.Fatal(err) + } + bobInstance, _ := e.startChecker(t, bobTok) + waitFor(t, 5*time.Second, "bob's checker registered", func() bool { + st, _ := bob.do("GET", "/api/v1/org/checkers/"+bobInstance.String(), nil) + return st == http.StatusOK + }) + if st, _ := alice.do("GET", "/api/v1/org/checkers/"+bobInstance.String(), nil); st != http.StatusNotFound { + t.Errorf("alice sees bob's own checker: %d", st) + } +} diff --git a/internal/api/console.go b/internal/api/console.go index bb13445..79fc491 100644 --- a/internal/api/console.go +++ b/internal/api/console.go @@ -34,6 +34,7 @@ func (s *Server) registerConsole(r gin.IRouter) { r.GET("/monitors/:id", s.orgPage("console.monitors.title", "", s.monitorDetail)) r.GET("/monitors/:id/edit", s.orgPage("monitors.edit", "", s.monitorEditor)) r.GET("/monitors/:id/evidence/:evidence", s.orgPage("evidence.heading", "", s.evidencePage)) + r.GET("/checkers/:id", s.orgPage("checkers.title", "", s.checkerPage)) r.GET("/groups", s.orgPage("groups.title", "", s.groupsView)) r.GET("/settings", s.settingsIndex) r.GET("/incidents", s.orgPage("incidents.title", authz.IncidentsRead, s.incidentsView)) @@ -406,8 +407,25 @@ func (s *Server) monitorDetail(c *gin.Context, p *principal, page web.Page, me w return nil, err } } - for _, r := range recent[:min(len(recent), 50)] { + shown := recent[:min(len(recent), 50)] + var checkerIDs []uuid.UUID + for _, r := range shown { + if r.CheckerID != uuid.Nil && !slices.Contains(checkerIDs, r.CheckerID) { + checkerIDs = append(checkerIDs, r.CheckerID) + } + } + checkers, err := s.checkerLinks(ctx, p, checkerIDs) + if err != nil { + return nil, err + } + for _, r := range shown { row := web.ResultRow{Time: r.Time.Format("01-02 15:04:05"), Region: d.regionNameString(r.Region), OK: r.Ok, Latency: "–", Detail: deref(r.Error)} + row.Checker = checkers[r.CheckerID] + if row.Checker.Label == "" && r.CheckerID != uuid.Nil { + // Instances seen before names were recorded, or of a deleted + // agent. + row.Checker.Label = shortID(r.CheckerID) + } row.EvidenceURL = evidenceOf[evidenceKey(r.Region, r.Time)] if r.LatencyMs != nil { row.Latency = fmt.Sprintf("%d ms", *r.LatencyMs) diff --git a/internal/api/server.go b/internal/api/server.go index e666f49..5074f3b 100644 --- a/internal/api/server.go +++ b/internal/api/server.go @@ -126,6 +126,7 @@ func (s *Server) Mount(r gin.IRouter) { org.PUT("/monitors/:id", s.updateMonitor) org.DELETE("/monitors/:id", s.deleteMonitor) org.GET("/monitors/:id/evidence", s.listEvidence) + org.GET("/checkers/:id", s.getChecker) org.GET("/monitors/:id/evidence/:evidence", s.getEvidence) org.GET("/maintenance", s.listMaintenance) org.POST("/maintenance", s.createMaintenance) diff --git a/internal/i18n/i18n_test.go b/internal/i18n/i18n_test.go index c43aeec..a1fcf70 100644 --- a/internal/i18n/i18n_test.go +++ b/internal/i18n/i18n_test.go @@ -71,6 +71,7 @@ var usagePatterns = []struct { {re: regexp.MustCompile(`\binvalid\("([a-z_]+)"\)`), prefix: "error."}, {re: regexp.MustCompile(`NoticeID = "([a-z0-9_.]+)"`)}, {re: regexp.MustCompile(`@labeled\("([a-z0-9_.]+)"\)`)}, + {re: regexp.MustCompile(`@checkerFact\("([a-z0-9_.]+)"`)}, {re: regexp.MustCompile(`@(?:settingsHeading|sectionHeading)\("([a-z0-9_.]+)"`)}, {re: regexp.MustCompile(`@settingsHeading\("[a-z0-9_.]+", "([a-z0-9_.]+)"`)}, {re: regexp.MustCompile(`@policyBanner\("([a-z0-9_.]+)", "([a-z0-9_.]+)"`)}, diff --git a/internal/i18n/locales/de.json b/internal/i18n/locales/de.json index c2c3dc0..898e340 100644 --- a/internal/i18n/locales/de.json +++ b/internal/i18n/locales/de.json @@ -107,6 +107,28 @@ "channels.type_email": "E-Mail", "channels.type_webhook": "Webhook", "channels.url": "Webhook-URL", + "checkers.avg_latency": "Mittlere Latenz", + "checkers.for": "seit {{.Duration}}", + "checkers.gone": "länger nicht gesehen", + "checkers.idle": "Gerade nichts.", + "checkers.instance": "Instanz", + "checkers.last_hour": "Deine Checks, letzte Stunde", + "checkers.last_seen": "Letzter Kontakt", + "checkers.live": "aktiv", + "checkers.no_recent": "Keine Checks deiner Organisation am letzten Tag.", + "checkers.now": "Läuft gerade", + "checkers.others": { + "one": "und {{.Count}} Check anderer Organisationen", + "other": "und {{.Count}} Checks anderer Organisationen" + }, + "checkers.queued": "Wartend", + "checkers.recent": "Deine letzten Checks auf dieser Instanz", + "checkers.refresh_hint": "Diese Seite aktualisiert sich alle 5 Sekunden.", + "checkers.release": "Version", + "checkers.running": "Läuft", + "checkers.siblings": "Weitere Instanzen dieses Checkers", + "checkers.started": "Gestartet", + "checkers.title": "Checker", "common.delete": "Löschen", "common.edit": "Bearbeiten", "common.no": "nein", diff --git a/internal/i18n/locales/en.json b/internal/i18n/locales/en.json index 689eec8..33d61bd 100644 --- a/internal/i18n/locales/en.json +++ b/internal/i18n/locales/en.json @@ -107,6 +107,28 @@ "channels.type_email": "Email", "channels.type_webhook": "Webhook", "channels.url": "Webhook URL", + "checkers.avg_latency": "Average latency", + "checkers.for": "for {{.Duration}}", + "checkers.gone": "not seen for a while", + "checkers.idle": "Nothing right now.", + "checkers.instance": "Instance", + "checkers.last_hour": "Your checks, last hour", + "checkers.last_seen": "Last contact", + "checkers.live": "active", + "checkers.no_recent": "No checks of your organization in the last day.", + "checkers.now": "Running now", + "checkers.others": { + "one": "and {{.Count}} check of other organizations", + "other": "and {{.Count}} checks of other organizations" + }, + "checkers.queued": "Queued", + "checkers.recent": "Your latest checks on this instance", + "checkers.refresh_hint": "This page refreshes every 5 seconds.", + "checkers.release": "Version", + "checkers.running": "Running", + "checkers.siblings": "Other instances of this checker", + "checkers.started": "Started", + "checkers.title": "Checker", "common.delete": "Delete", "common.edit": "Edit", "common.no": "no", diff --git a/internal/schedule/schedule.go b/internal/schedule/schedule.go index 8e87c46..be11e75 100644 --- a/internal/schedule/schedule.go +++ b/internal/schedule/schedule.go @@ -247,6 +247,21 @@ func (s *Scheduler) Dispatch(ctx context.Context) (int, error) { return total, nil } +// QueueLen returns how many runs wait for instance. +func (s *Scheduler) QueueLen(ctx context.Context, instance uuid.UUID) (int64, error) { + return s.rdb.LLen(ctx, jobsPrefix+instance.String()).Result() +} + +// LastSeen returns when instance last polled in region, or zero if it is +// not registered. +func (s *Scheduler) LastSeen(ctx context.Context, region string, instance uuid.UUID) (time.Time, error) { + score, err := s.rdb.ZScore(ctx, keyInstances(region), instance.String()).Result() + if errors.Is(err, redis.Nil) || score == 0 { + return time.Time{}, nil + } + return time.UnixMilli(int64(score)), err +} + // Take pops up to max queued runs for instance, waiting up to wait for the // first one. It returns within about a second once ctx is done, so long polls // do not hold up shutdown or cancelled requests. diff --git a/internal/web/checkers.templ b/internal/web/checkers.templ new file mode 100644 index 0000000..6d2c524 --- /dev/null +++ b/internal/web/checkers.templ @@ -0,0 +1,160 @@ +package web + +import ( + "strconv" + + "git.zb-server.de/ZB-Server/uptimesebi/internal/i18n" +) + +// CheckerView shows what a checker instance is doing. +type CheckerView struct { + ID string + Agent string + Region string + Platform bool + Release string + Started string + LastSeen string + Live bool + Queued int + Running []CheckerRun + OtherOrgs int + Checks int + Failed int + AvgLatency string + Recent []CheckerResult + Siblings []CheckerLink +} + +// CheckerRun is a check in progress. +type CheckerRun struct { + MonitorURL string + Monitor string + For string +} + +// CheckerResult is a finished check of the instance. +type CheckerResult struct { + Time string + MonitorURL string + Monitor string + OK bool + Latency string + Detail string +} + +// CheckerLink points to a checker instance. +type CheckerLink struct { + URL string + Label string +} + +templ CheckerPage(p Page, me Me, v CheckerView) { + @consoleShell(p, me) { +
+

+ if v.Live { + @statusDot(StatusUp) + } else { + @statusDot(StatusUnknown) + } + { v.Agent } + { v.ID[:8] } +

+

+ { v.Region } · + if v.Platform { + { i18n.T(ctx, "regions.platform") } + } else { + { i18n.T(ctx, "regions.own") } + } + · + if v.Live { + { i18n.T(ctx, "checkers.live") } + } else { + { i18n.T(ctx, "checkers.gone") } + } +

+
+
+ @checkerFact("checkers.running", strconv.Itoa(len(v.Running)+v.OtherOrgs)) + @checkerFact("checkers.queued", strconv.Itoa(v.Queued)) + @checkerFact("checkers.last_hour", strconv.Itoa(v.Checks)+" / "+strconv.Itoa(v.Failed)+" ✕") + @checkerFact("checkers.avg_latency", v.AvgLatency) + @checkerFact("checkers.release", v.Release) + @checkerFact("checkers.started", v.Started) + @checkerFact("checkers.last_seen", v.LastSeen) + @checkerFact("checkers.instance", v.ID) +
+
+ @sectionHeading("checkers.now") + if len(v.Running) == 0 && v.OtherOrgs == 0 { +

{ i18n.T(ctx, "checkers.idle") }

+ } else { +
    + for _, r := range v.Running { +
  • + { r.Monitor } + { i18n.T(ctx, "checkers.for", "Duration", r.For) } +
  • + } + if v.OtherOrgs > 0 { +
  • { i18n.T(ctx, "checkers.others", "Count", v.OtherOrgs) }
  • + } +
+ } +

{ i18n.T(ctx, "checkers.refresh_hint") }

+
+
+ @sectionHeading("checkers.recent") + if len(v.Recent) == 0 { +

{ i18n.T(ctx, "checkers.no_recent") }

+ } else { + + + for _, r := range v.Recent { + + + + + + + + } + +
{ r.Time }{ r.Monitor } + if r.OK { + ● + } else { + ● + } + { r.Latency }{ r.Detail }
+ } +
+ if len(v.Siblings) > 0 { +
+ @sectionHeading("checkers.siblings") +

+ for _, sb := range v.Siblings { + { sb.Label } + } +

+
+ } + } +} + +templ checkerFact(labelID, value string) { +
+
{ i18n.T(ctx, labelID) }
+
{ value }
+
+} + +templ checkerCell(l CheckerLink) { + if l.URL != "" { + { l.Label } + } else { + { l.Label } + } +} diff --git a/internal/web/checkers_templ.go b/internal/web/checkers_templ.go new file mode 100644 index 0000000..9854498 --- /dev/null +++ b/internal/web/checkers_templ.go @@ -0,0 +1,676 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.3.1118 + +package web + +//lint:file-ignore SA4006 This context is only used if a nested component is present. + +import "github.com/a-h/templ" +import templruntime "github.com/a-h/templ/runtime" + +import ( + "strconv" + + "git.zb-server.de/ZB-Server/uptimesebi/internal/i18n" +) + +// CheckerView shows what a checker instance is doing. +type CheckerView struct { + ID string + Agent string + Region string + Platform bool + Release string + Started string + LastSeen string + Live bool + Queued int + Running []CheckerRun + OtherOrgs int + Checks int + Failed int + AvgLatency string + Recent []CheckerResult + Siblings []CheckerLink +} + +// CheckerRun is a check in progress. +type CheckerRun struct { + MonitorURL string + Monitor string + For string +} + +// CheckerResult is a finished check of the instance. +type CheckerResult struct { + Time string + MonitorURL string + Monitor string + OK bool + Latency string + Detail string +} + +// CheckerLink points to a checker instance. +type CheckerLink struct { + URL string + Label string +} + +func CheckerPage(p Page, me Me, v CheckerView) 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_Var2 := 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 { + 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) + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if v.Live { + templ_7745c5c3_Err = statusDot(StatusUp).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else { + templ_7745c5c3_Err = statusDot(StatusUnknown).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + var templ_7745c5c3_Var3 string + templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(v.Agent) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/checkers.templ`, Line: 61, Col: 13} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var4 string + templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(v.ID[:8]) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/checkers.templ`, Line: 62, Col: 69} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var5 string + templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(v.Region) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/checkers.templ`, Line: 65, Col: 14} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, " · ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if v.Platform { + var templ_7745c5c3_Var6 string + templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "regions.platform")) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/checkers.templ`, Line: 67, Col: 38} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else { + var templ_7745c5c3_Var7 string + templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "regions.own")) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/checkers.templ`, Line: 69, Col: 33} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "· ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if v.Live { + var templ_7745c5c3_Var8 string + templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "checkers.live")) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/checkers.templ`, Line: 73, Col: 35} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else { + var templ_7745c5c3_Var9 string + templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "checkers.gone")) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/checkers.templ`, Line: 75, Col: 35} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = checkerFact("checkers.running", strconv.Itoa(len(v.Running)+v.OtherOrgs)).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = checkerFact("checkers.queued", strconv.Itoa(v.Queued)).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = checkerFact("checkers.last_hour", strconv.Itoa(v.Checks)+" / "+strconv.Itoa(v.Failed)+" ✕").Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = checkerFact("checkers.avg_latency", v.AvgLatency).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = checkerFact("checkers.release", v.Release).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = checkerFact("checkers.started", v.Started).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = checkerFact("checkers.last_seen", v.LastSeen).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = checkerFact("checkers.instance", v.ID).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = sectionHeading("checkers.now").Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if len(v.Running) == 0 && v.OtherOrgs == 0 { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var10 string + templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "checkers.idle")) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/checkers.templ`, Line: 92, Col: 64} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var15 string + templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "checkers.refresh_hint")) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/checkers.templ`, Line: 106, Col: 76} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = sectionHeading("checkers.recent").Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if len(v.Recent) == 0 { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var16 string + templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "checkers.no_recent")) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/checkers.templ`, Line: 111, Col: 69} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + for _, r := range v.Recent { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var17 string + templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(r.Time) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/checkers.templ`, Line: 117, Col: 87} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var19 string + templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(r.Monitor) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/checkers.templ`, Line: 118, Col: 107} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if r.OK { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "●") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, "●") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var20 string + templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(r.Latency) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/checkers.templ`, Line: 126, Col: 61} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var21 string + templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(r.Detail) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/checkers.templ`, Line: 127, Col: 66} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if len(v.Siblings) > 0 { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 38, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = sectionHeading("checkers.siblings").Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + for _, sb := range v.Siblings { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 40, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var23 string + templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(sb.Label) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/checkers.templ`, Line: 139, Col: 87} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 42, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 43, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + return nil + }) + templ_7745c5c3_Err = consoleShell(p, me).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +func checkerFact(labelID, value string) 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, 44, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var25 string + templ_7745c5c3_Var25, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, labelID)) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/checkers.templ`, Line: 149, Col: 55} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var25)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 45, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var27 string + templ_7745c5c3_Var27, templ_7745c5c3_Err = templ.JoinStringErrs(value) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/checkers.templ`, Line: 150, Col: 64} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var27)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 47, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +func checkerCell(l CheckerLink) 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 l.URL != "" { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 48, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var30 string + templ_7745c5c3_Var30, templ_7745c5c3_Err = templ.JoinStringErrs(l.Label) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/checkers.templ`, Line: 156, Col: 68} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var30)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 50, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 51, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var31 string + templ_7745c5c3_Var31, templ_7745c5c3_Err = templ.JoinStringErrs(l.Label) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/checkers.templ`, Line: 158, Col: 36} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var31)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 52, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + return nil + }) +} + +var _ = templruntime.GeneratedTemplate diff --git a/internal/web/layout.templ b/internal/web/layout.templ index cc2a01d..bd0a458 100644 --- a/internal/web/layout.templ +++ b/internal/web/layout.templ @@ -1,6 +1,10 @@ package web -import "git.zb-server.de/ZB-Server/uptimesebi/internal/i18n" +import ( + "strconv" + + "git.zb-server.de/ZB-Server/uptimesebi/internal/i18n" +) // Page carries what every rendered page needs besides its own content. type Page struct { @@ -13,6 +17,8 @@ type Page struct { NoticeID string // Legal links the platform's legal notice and privacy policy. Legal []LegalLink + // RefreshSeconds reloads pages that show live state. + RefreshSeconds int } templ Layout(p Page) { @@ -24,6 +30,9 @@ templ Layout(p Page) { if p.CSRF != "" { } + if p.RefreshSeconds > 0 { + + } { i18n.T(ctx, p.TitleID) } · uptimesebi diff --git a/internal/web/layout_templ.go b/internal/web/layout_templ.go index 59b46b0..8a15b74 100644 --- a/internal/web/layout_templ.go +++ b/internal/web/layout_templ.go @@ -9,7 +9,11 @@ package web import "github.com/a-h/templ" import templruntime "github.com/a-h/templ/runtime" -import "git.zb-server.de/ZB-Server/uptimesebi/internal/i18n" +import ( + "strconv" + + "git.zb-server.de/ZB-Server/uptimesebi/internal/i18n" +) // Page carries what every rendered page needs besides its own content. type Page struct { @@ -22,6 +26,8 @@ type Page struct { NoticeID string // Legal links the platform's legal notice and privacy policy. Legal []LegalLink + // RefreshSeconds reloads pages that show live state. + RefreshSeconds int } func Layout(p Page) templ.Component { @@ -49,7 +55,7 @@ func Layout(p Page) templ.Component { var templ_7745c5c3_Var2 string templ_7745c5c3_Var2, templ_7745c5c3_Err = templruntime.NewAttributeExpression(i18n.Lang(ctx)).Resolve(ctx) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 20, Col: 28} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 26, Col: 28} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var2) if templ_7745c5c3_Err != nil { @@ -67,7 +73,7 @@ func Layout(p Page) templ.Component { var templ_7745c5c3_Var3 string templ_7745c5c3_Var3, templ_7745c5c3_Err = templruntime.NewAttributeExpression(p.CSRF).Resolve(ctx) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 25, Col: 44} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 31, Col: 44} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var3) if templ_7745c5c3_Err != nil { @@ -78,33 +84,52 @@ func Layout(p Page) templ.Component { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err + if p.RefreshSeconds > 0 { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "<meta http-equiv=\"refresh\" content=\"") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var4 string + templ_7745c5c3_Var4, templ_7745c5c3_Err = templruntime.NewAttributeExpression(strconv.Itoa(p.RefreshSeconds)).Resolve(ctx) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 34, Col: 71} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var4) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "\">") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } } - var templ_7745c5c3_Var4 string - templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, p.TitleID)) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 27, Col: 34} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, " · uptimesebi") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var5 string - templ_7745c5c3_Var5, templ_7745c5c3_Err = templruntime.NewAttributeExpression(i18n.T(ctx, "app.network_error")).Resolve(ctx) + templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, p.TitleID)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 32, Col: 94} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 36, Col: 34} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var5) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "\">
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, " · uptimesebi
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -112,7 +137,7 @@ func Layout(p Page) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -120,7 +145,7 @@ func Layout(p Page) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -145,76 +170,76 @@ func languageSwitch(langs []string) templ.Component { } ctx = templ.InitializeContext(ctx) ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } for _, l := range langs { if l == i18n.Lang(ctx) { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var7 string - templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(l) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 45, Col: 50} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - } else { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "\">") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var11 string + templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(l) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 56, Col: 114} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -238,9 +263,9 @@ func authShell(p Page) templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var11 := templ.GetChildren(ctx) + templ_7745c5c3_Var12 := templ.GetChildren(ctx) ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Var12 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_Var13 := 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 { @@ -252,7 +277,7 @@ func authShell(p Page) templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "

uptimesebi

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

uptimesebi

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -260,20 +285,20 @@ func authShell(p Page) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "

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

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var13 string - templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, p.TitleID)) + var templ_7745c5c3_Var14 string + templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, p.TitleID)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 60, Col: 66} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 69, Col: 66} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -281,17 +306,17 @@ func authShell(p Page) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templ_7745c5c3_Var11.Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = templ_7745c5c3_Var12.Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) - templ_7745c5c3_Err = Layout(p).Render(templ.WithChildren(ctx, templ_7745c5c3_Var12), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = Layout(p).Render(templ.WithChildren(ctx, templ_7745c5c3_Var13), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -316,69 +341,69 @@ func field(label, name, typ, autocomplete string, required bool) templ.Component } ctx = templ.InitializeContext(ctx) ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, ">") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -403,20 +428,20 @@ func submit(label string) templ.Component { } ctx = templ.InitializeContext(ctx) ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -442,33 +467,14 @@ func flash(p Page) templ.Component { ctx = templ.InitializeContext(ctx) ctx = templ.ClearChildren(ctx) if p.ErrorID != "" { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "

") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var22 string - templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, p.ErrorID)) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 88, Col: 88} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, "

") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - } - if p.NoticeID != "" { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "

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

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var23 string - templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, p.NoticeID)) + templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, p.ErrorID)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 91, Col: 77} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 97, Col: 88} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23)) if templ_7745c5c3_Err != nil { @@ -479,6 +485,25 @@ func flash(p Page) templ.Component { return templ_7745c5c3_Err } } + if p.NoticeID != "" { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var24 string + templ_7745c5c3_Var24, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, p.NoticeID)) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 100, Col: 77} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var24)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } return nil }) } @@ -500,7 +525,7 @@ func formError() templ.Component { } ctx = templ.InitializeContext(ctx) ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/internal/web/monitors.templ b/internal/web/monitors.templ index 5192087..5b5b330 100644 --- a/internal/web/monitors.templ +++ b/internal/web/monitors.templ @@ -219,6 +219,8 @@ type ResultRow struct { Detail string // EvidenceURL links to what the checker saw, for editors. EvidenceURL string + // Checker names the instance that ran the check. + Checker CheckerLink } // IncidentRow is an incident in a list. @@ -376,6 +378,9 @@ templ MonitorDetail(p Page, me Me, v MonitorDetailView) { { r.Time } { r.Region } + + @checkerCell(r.Checker) + if r.OK { ● diff --git a/internal/web/monitors_templ.go b/internal/web/monitors_templ.go index e5e670d..299306f 100644 --- a/internal/web/monitors_templ.go +++ b/internal/web/monitors_templ.go @@ -843,6 +843,8 @@ type ResultRow struct { Detail string // EvidenceURL links to what the checker saw, for editors. EvidenceURL string + // Checker names the instance that ran the check. + Checker CheckerLink } // IncidentRow is an incident in a list. @@ -922,7 +924,7 @@ func MonitorDetail(p Page, me Me, v MonitorDetailView) templ.Component { var templ_7745c5c3_Var41 string templ_7745c5c3_Var41, 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: 267, Col: 115} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 269, Col: 115} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var41)) if templ_7745c5c3_Err != nil { @@ -943,7 +945,7 @@ func MonitorDetail(p Page, me Me, v MonitorDetailView) templ.Component { var templ_7745c5c3_Var42 string templ_7745c5c3_Var42, templ_7745c5c3_Err = templ.JoinStringErrs(v.Row.Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 272, Col: 23} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 274, Col: 23} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var42)) if templ_7745c5c3_Err != nil { @@ -956,7 +958,7 @@ func MonitorDetail(p Page, me Me, v MonitorDetailView) templ.Component { var templ_7745c5c3_Var43 string templ_7745c5c3_Var43, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "monitors.type_"+v.Row.Type)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 275, Col: 47} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 277, Col: 47} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var43)) if templ_7745c5c3_Err != nil { @@ -970,7 +972,7 @@ func MonitorDetail(p Page, me Me, v MonitorDetailView) templ.Component { var templ_7745c5c3_Var44 string templ_7745c5c3_Var44, templ_7745c5c3_Err = templ.JoinStringErrs(" · " + v.Row.Target) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 277, Col: 29} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 279, Col: 29} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var44)) if templ_7745c5c3_Err != nil { @@ -984,7 +986,7 @@ func MonitorDetail(p Page, me Me, v MonitorDetailView) templ.Component { var templ_7745c5c3_Var45 string templ_7745c5c3_Var45, templ_7745c5c3_Err = templ.JoinStringErrs(" · " + v.Interval) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 279, Col: 26} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 281, Col: 26} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var45)) if templ_7745c5c3_Err != nil { @@ -1002,7 +1004,7 @@ func MonitorDetail(p Page, me Me, v MonitorDetailView) templ.Component { var templ_7745c5c3_Var46 string templ_7745c5c3_Var46, templ_7745c5c3_Err = templruntime.NewAttributeExpression(templ.SafeURL("/monitors/" + v.Row.ID + "/edit")).ResolveURL(ctx) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 283, Col: 62} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 285, Col: 62} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var46) if templ_7745c5c3_Err != nil { @@ -1015,7 +1017,7 @@ func MonitorDetail(p Page, me Me, v MonitorDetailView) templ.Component { var templ_7745c5c3_Var47 string templ_7745c5c3_Var47, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "sso.action.edit")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 283, Col: 173} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 285, Col: 173} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var47)) if templ_7745c5c3_Err != nil { @@ -1033,7 +1035,7 @@ func MonitorDetail(p Page, me Me, v MonitorDetailView) templ.Component { var templ_7745c5c3_Var48 string templ_7745c5c3_Var48, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "monitors.history", "Range", v.Range)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 288, Col: 123} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 290, Col: 123} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var48)) if templ_7745c5c3_Err != nil { @@ -1054,7 +1056,7 @@ func MonitorDetail(p Page, me Me, v MonitorDetailView) templ.Component { var templ_7745c5c3_Var49 string templ_7745c5c3_Var49, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "monitors.sla")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 292, Col: 39} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 294, Col: 39} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var49)) if templ_7745c5c3_Err != nil { @@ -1067,7 +1069,7 @@ func MonitorDetail(p Page, me Me, v MonitorDetailView) templ.Component { var templ_7745c5c3_Var50 string templ_7745c5c3_Var50, templ_7745c5c3_Err = templ.JoinStringErrs(v.Row.Uptime) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 293, Col: 49} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 295, Col: 49} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var50)) if templ_7745c5c3_Err != nil { @@ -1089,7 +1091,7 @@ func MonitorDetail(p Page, me Me, v MonitorDetailView) templ.Component { var templ_7745c5c3_Var51 string templ_7745c5c3_Var51, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "monitors.latency")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 298, Col: 44} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 300, Col: 44} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var51)) if templ_7745c5c3_Err != nil { @@ -1102,7 +1104,7 @@ func MonitorDetail(p Page, me Me, v MonitorDetailView) templ.Component { var templ_7745c5c3_Var52 string templ_7745c5c3_Var52, templ_7745c5c3_Err = templ.JoinStringErrs(strconv.Itoa(v.Latency.MaxMS)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 299, Col: 46} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 301, Col: 46} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var52)) if templ_7745c5c3_Err != nil { @@ -1115,7 +1117,7 @@ func MonitorDetail(p Page, me Me, v MonitorDetailView) templ.Component { var templ_7745c5c3_Var53 string templ_7745c5c3_Var53, templ_7745c5c3_Err = templruntime.NewAttributeExpression("0 0 " + strconv.Itoa(v.Latency.Width) + " " + strconv.Itoa(v.Latency.Height)).Resolve(ctx) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 301, Col: 96} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 303, Col: 96} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var53) if templ_7745c5c3_Err != nil { @@ -1128,7 +1130,7 @@ func MonitorDetail(p Page, me Me, v MonitorDetailView) templ.Component { var templ_7745c5c3_Var54 string templ_7745c5c3_Var54, templ_7745c5c3_Err = templruntime.NewAttributeExpression(v.Latency.Points).Resolve(ctx) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 302, Col: 40} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 304, Col: 40} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var54) if templ_7745c5c3_Err != nil { @@ -1164,7 +1166,7 @@ func MonitorDetail(p Page, me Me, v MonitorDetailView) templ.Component { var templ_7745c5c3_Var55 string templ_7745c5c3_Var55, templ_7745c5c3_Err = templ.JoinStringErrs(r.Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 312, Col: 38} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 314, Col: 38} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var55)) if templ_7745c5c3_Err != nil { @@ -1207,7 +1209,7 @@ func MonitorDetail(p Page, me Me, v MonitorDetailView) templ.Component { var templ_7745c5c3_Var58 string templ_7745c5c3_Var58, templ_7745c5c3_Err = templruntime.NewAttributeExpression(partialTitle(ctx, !r.Enough)).Resolve(ctx) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 314, Col: 127} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 316, Col: 127} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var58) if templ_7745c5c3_Err != nil { @@ -1234,7 +1236,7 @@ func MonitorDetail(p Page, me Me, v MonitorDetailView) templ.Component { var templ_7745c5c3_Var59 string templ_7745c5c3_Var59, templ_7745c5c3_Err = templ.JoinStringErrs(r.Uptime) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 314, Col: 140} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 316, Col: 140} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var59)) if templ_7745c5c3_Err != nil { @@ -1252,7 +1254,7 @@ func MonitorDetail(p Page, me Me, v MonitorDetailView) templ.Component { var templ_7745c5c3_Var60 string templ_7745c5c3_Var60, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "monitors.by_region_hint")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 318, Col: 79} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 320, Col: 79} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var60)) if templ_7745c5c3_Err != nil { @@ -1337,7 +1339,7 @@ func MonitorDetail(p Page, me Me, v MonitorDetailView) templ.Component { var templ_7745c5c3_Var63 string templ_7745c5c3_Var63, templ_7745c5c3_Err = templruntime.NewAttributeExpression(partialTitle(ctx, e.Partial)).Resolve(ctx) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 334, Col: 114} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 336, Col: 114} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var63) if templ_7745c5c3_Err != nil { @@ -1364,7 +1366,7 @@ func MonitorDetail(p Page, me Me, v MonitorDetailView) templ.Component { var templ_7745c5c3_Var64 string templ_7745c5c3_Var64, templ_7745c5c3_Err = templ.JoinStringErrs(e.Label) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 335, Col: 56} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 337, Col: 56} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var64)) if templ_7745c5c3_Err != nil { @@ -1377,7 +1379,7 @@ func MonitorDetail(p Page, me Me, v MonitorDetailView) templ.Component { var templ_7745c5c3_Var65 string templ_7745c5c3_Var65, templ_7745c5c3_Err = templ.JoinStringErrs(e.Value) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 336, Col: 45} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 338, Col: 45} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var65)) if templ_7745c5c3_Err != nil { @@ -1403,7 +1405,7 @@ func MonitorDetail(p Page, me Me, v MonitorDetailView) templ.Component { var templ_7745c5c3_Var66 string templ_7745c5c3_Var66, templ_7745c5c3_Err = templ.JoinStringErrs(v.Uptime90) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 344, Col: 48} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 346, Col: 48} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var66)) if templ_7745c5c3_Err != nil { @@ -1445,7 +1447,7 @@ func MonitorDetail(p Page, me Me, v MonitorDetailView) templ.Component { var templ_7745c5c3_Var67 string templ_7745c5c3_Var67, templ_7745c5c3_Err = templ.JoinStringErrs(r.Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 355, Col: 21} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 357, Col: 21} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var67)) if templ_7745c5c3_Err != nil { @@ -1458,7 +1460,7 @@ func MonitorDetail(p Page, me Me, v MonitorDetailView) templ.Component { var templ_7745c5c3_Var68 string templ_7745c5c3_Var68, templ_7745c5c3_Err = templ.JoinStringErrs(r.Detail) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 356, Col: 77} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 358, Col: 77} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var68)) if templ_7745c5c3_Err != nil { @@ -1521,7 +1523,7 @@ func MonitorDetail(p Page, me Me, v MonitorDetailView) templ.Component { var templ_7745c5c3_Var69 string templ_7745c5c3_Var69, templ_7745c5c3_Err = templ.JoinStringErrs(r.Time) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 377, Col: 86} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 379, Col: 86} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var69)) if templ_7745c5c3_Err != nil { @@ -1534,95 +1536,103 @@ func MonitorDetail(p Page, me Me, v MonitorDetailView) templ.Component { var templ_7745c5c3_Var70 string templ_7745c5c3_Var70, templ_7745c5c3_Err = templ.JoinStringErrs(r.Region) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 378, Col: 41} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 380, Col: 41} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var70)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 119, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 119, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = checkerCell(r.Checker).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 120, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if r.OK { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 120, "●") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 121, "●") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } else { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 121, "●") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 122, "●") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 122, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 123, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var71 string templ_7745c5c3_Var71, templ_7745c5c3_Err = templ.JoinStringErrs(r.Latency) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 386, Col: 60} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 391, Col: 60} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var71)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 123, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 124, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var72 string templ_7745c5c3_Var72, templ_7745c5c3_Err = templ.JoinStringErrs(r.Detail) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 388, Col: 18} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 393, Col: 18} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var72)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 124, " ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 125, " ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if r.EvidenceURL != "" { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 125, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 127, "\" class=\"ml-2 underline underline-offset-2 hover:text-ink\">") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var74 string templ_7745c5c3_Var74, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "evidence.show")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 390, Col: 137} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 395, Col: 137} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var74)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 127, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 128, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 128, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 129, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 129, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 130, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -1653,139 +1663,139 @@ func incidentList(rows []IncidentRow, showMonitor bool) templ.Component { } ctx = templ.InitializeContext(ctx) ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 130, "
    ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 131, "
      ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } for _, r := range rows { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 131, "
    • ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 132, "
    • ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if r.Open { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 132, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 133, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var76 string templ_7745c5c3_Var76, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "incidents.ongoing")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 407, Col: 76} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 412, Col: 76} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var76)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 133, " ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 134, " ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } else { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 134, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 135, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var77 string templ_7745c5c3_Var77, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "incidents.resolved")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 409, Col: 63} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 414, Col: 63} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var77)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 135, " ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 136, " ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } if showMonitor { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 136, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 138, "\" class=\"hover:underline\">") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var79 string templ_7745c5c3_Var79, templ_7745c5c3_Err = templ.JoinStringErrs(r.Monitor) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 412, Col: 95} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 417, Col: 95} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var79)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 138, " ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 139, " ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 139, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 140, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var80 string templ_7745c5c3_Var80, templ_7745c5c3_Err = templ.JoinStringErrs(r.Started) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 414, Col: 59} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 419, Col: 59} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var80)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 140, " ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 141, " ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var81 string templ_7745c5c3_Var81, templ_7745c5c3_Err = templ.JoinStringErrs(r.Duration) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 415, Col: 57} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 420, Col: 57} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var81)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 141, "
      ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 142, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if len(r.Cause) > 0 { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 142, "

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

      ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var82 string templ_7745c5c3_Var82, templ_7745c5c3_Err = templ.JoinStringErrs(strings.Join(r.Cause, " · ")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 418, Col: 81} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 423, Col: 81} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var82)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 143, "

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

      ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 144, "
    • ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 145, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 145, "
    ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 146, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -1827,20 +1837,20 @@ func IncidentsPage(p Page, me Me, rows []IncidentRow) templ.Component { return templ_7745c5c3_Err } if len(rows) == 0 { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 146, "

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

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var85 string templ_7745c5c3_Var85, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "incidents.none")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 429, Col: 103} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 434, Col: 103} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var85)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 147, "

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

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -1940,46 +1950,46 @@ func headersField(value string) templ.Component { } ctx = templ.InitializeContext(ctx) ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 148, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -2005,36 +2015,36 @@ func typeFields(typ, current string) templ.Component { ctx = templ.InitializeContext(ctx) templ_7745c5c3_Var90 := templ.GetChildren(ctx) ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 152, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 157, " class=\"mb-2\">") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -2042,7 +2052,7 @@ func typeFields(typ, current string) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 157, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 158, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -2067,95 +2077,95 @@ func numberField(label, name string, value, min, max int, hint string) templ.Com } ctx = templ.InitializeContext(ctx) ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 158, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -2192,115 +2202,115 @@ func MonitorEditor(p Page, me Me, f MonitorForm) templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 167, "

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

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if f.ID == "" { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 168, "← ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 169, "← ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var101 string templ_7745c5c3_Var101, 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: 535, Col: 93} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 540, Col: 93} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var101)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 169, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 170, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } else { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 170, "← ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 172, "\" class=\"text-muted hover:text-ink\">← ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var103 string templ_7745c5c3_Var103, templ_7745c5c3_Err = templ.JoinStringErrs(f.Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 537, Col: 97} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 542, Col: 97} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var103)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 172, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 173, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 173, "

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

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var104 string templ_7745c5c3_Var104, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, p.TitleID)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 540, Col: 65} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 545, Col: 65} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var104)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 174, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 180, " class=\"grid max-w-4xl gap-x-12 md:grid-cols-2\">
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -2312,20 +2322,20 @@ func MonitorEditor(p Page, me Me, f MonitorForm) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 180, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 192, ">") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -2410,20 +2420,20 @@ func MonitorEditor(p Page, me Me, f MonitorForm) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 192, "

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

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var111 string templ_7745c5c3_Var111, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "monitors.target_hint")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 569, Col: 83} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 574, Col: 83} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var111)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 193, "

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

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -2439,20 +2449,20 @@ func MonitorEditor(p Page, me Me, f MonitorForm) templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 194, "

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

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var113 string templ_7745c5c3_Var113, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "monitors.heartbeat_hint")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 572, Col: 80} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 577, Col: 80} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var113)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 195, "

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

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -2478,66 +2488,66 @@ func MonitorEditor(p Page, me Me, f MonitorForm) templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 196, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -2579,203 +2589,203 @@ func MonitorEditor(p Page, me Me, f MonitorForm) templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 204, "

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

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var119 string templ_7745c5c3_Var119, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "monitors.prom_hint")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 594, Col: 75} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 599, Col: 75} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var119)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 205, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -2809,92 +2819,92 @@ func MonitorEditor(p Page, me Me, f MonitorForm) templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 225, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -2906,193 +2916,193 @@ func MonitorEditor(p Page, me Me, f MonitorForm) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 235, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 236, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var137 string templ_7745c5c3_Var137, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "monitors.assertions")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 643, Col: 125} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 648, Col: 125} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var137)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 236, "

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

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var138 string templ_7745c5c3_Var138, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "monitors.assertions_hint")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 644, Col: 82} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 649, Col: 82} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var138)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 237, "

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

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } for i, a := range f.Assertions { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 238, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 244, "\" class=\"border border-rule bg-transparent px-1 py-1 font-mono text-xs\">") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } for _, op := range AssertionOps { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 244, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 249, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 249, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 253, "\" class=\"min-w-0 border border-rule bg-transparent px-2 py-1 font-mono text-xs outline-none focus:border-ink\">
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 253, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 254, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -3114,66 +3124,66 @@ func MonitorEditor(p Page, me Me, f MonitorForm) templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 254, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -3217,7 +3227,7 @@ func MonitorEditor(p Page, me Me, f MonitorForm) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 262, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 263, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -3225,17 +3235,17 @@ func MonitorEditor(p Page, me Me, f MonitorForm) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 263, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 266, ">") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -3243,7 +3253,7 @@ func MonitorEditor(p Page, me Me, f MonitorForm) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 266, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 267, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -3251,90 +3261,90 @@ func MonitorEditor(p Page, me Me, f MonitorForm) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 267, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 271, ">") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var154 string templ_7745c5c3_Var154, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "monitors.regions")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 682, Col: 121} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 687, Col: 121} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var154)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 271, "

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

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var155 string templ_7745c5c3_Var155, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "monitors.regions_hint")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 683, Col: 78} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 688, Col: 78} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var155)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 272, "

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

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } for _, r := range f.Regions { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 273, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 282, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 282, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 283, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -3398,51 +3408,51 @@ func MonitorEditor(p Page, me Me, f MonitorForm) templ.Component { return templ_7745c5c3_Err } if f.ID != "" { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 283, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 287, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 287, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 288, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -3507,12 +3517,12 @@ func ChannelsPage(p Page, me Me, v ChannelsView) templ.Component { return templ_7745c5c3_Err } if len(v.Channels) > 0 { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 288, "
    ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 289, "
      ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } for _, ch := range v.Channels { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 289, "
    • ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 290, "
    • ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -3527,149 +3537,149 @@ func ChannelsPage(p Page, me Me, v ChannelsView) templ.Component { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 290, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 291, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var166 string templ_7745c5c3_Var166, templ_7745c5c3_Err = templ.JoinStringErrs(ch.Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 744, Col: 21} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 749, Col: 21} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var166)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 291, " ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 292, " ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var167 string templ_7745c5c3_Var167, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "channels.type_"+ch.Type)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 745, Col: 70} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 750, Col: 70} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var167)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 292, " ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 293, " ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var168 string templ_7745c5c3_Var168, templ_7745c5c3_Err = templ.JoinStringErrs(ch.Target) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 746, Col: 77} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 751, Col: 77} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var168)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 293, " ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 294, " ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if v.CanWrite { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 294, " ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 301, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 301, "
    • ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 302, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 302, "
    ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 303, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 303, " ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 304, " ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if v.CanWrite { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 304, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 305, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -3677,7 +3687,7 @@ func ChannelsPage(p Page, me Me, v ChannelsView) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 305, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 306, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -3685,7 +3695,7 @@ func ChannelsPage(p Page, me Me, v ChannelsView) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 306, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 307, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -3701,20 +3711,20 @@ func ChannelsPage(p Page, me Me, v ChannelsView) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 307, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 309, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -3723,7 +3733,7 @@ func ChannelsPage(p Page, me Me, v ChannelsView) templ.Component { return templ_7745c5c3_Err } if v.EmailAvailable { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 309, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 310, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -3731,7 +3741,7 @@ func ChannelsPage(p Page, me Me, v ChannelsView) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 310, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 311, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -3739,79 +3749,79 @@ func ChannelsPage(p Page, me Me, v ChannelsView) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 311, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -3819,30 +3829,30 @@ func ChannelsPage(p Page, me Me, v ChannelsView) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 320, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 321, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } else { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 321, "

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

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var180 string templ_7745c5c3_Var180, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "error.email_not_configured")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 795, Col: 79} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 800, Col: 79} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var180)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 322, "

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

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 323, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 324, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -3874,85 +3884,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, 324, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 334, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -4007,20 +4017,20 @@ func GroupsPage(p Page, me Me, v GroupsView) templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 334, "

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

← ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var188 string templ_7745c5c3_Var188, 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: 834, Col: 115} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 839, Col: 115} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var188)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 335, "

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

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -4029,69 +4039,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, 336, "
    ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 337, "
      ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } for _, g := range v.Groups { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 337, "
    • ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 339, "\">
      ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var190 string templ_7745c5c3_Var190, templ_7745c5c3_Err = templ.JoinStringErrs(g.Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 841, Col: 21} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 846, Col: 21} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var190)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 339, " ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 340, " ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if g.CanWrite { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 340, "
      ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 341, "
      ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var191 string templ_7745c5c3_Var191, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "sso.action.edit")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 844, Col: 99} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 849, Col: 99} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var191)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 341, "
      ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 343, "\" data-method=\"put\" data-next=\"/groups\" class=\"mt-3 w-72\">") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -4103,20 +4113,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, 343, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 346, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -4132,66 +4142,66 @@ 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, 346, "
      ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 350, "
      ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 350, "
    • ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 351, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 351, "
    ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 352, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 352, " ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 353, " ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if v.CanWrite { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 353, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 354, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -4199,7 +4209,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, 354, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 355, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -4211,20 +4221,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, 355, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 358, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -4240,7 +4250,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, 358, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 359, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -4279,7 +4289,7 @@ func pingSection(url string) templ.Component { } ctx = templ.InitializeContext(ctx) ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 359, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 360, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -4287,27 +4297,27 @@ func pingSection(url string) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 360, "

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

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var199 string templ_7745c5c3_Var199, 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: 889, Col: 83} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 894, Col: 83} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var199)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 361, "

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

")
 		if templ_7745c5c3_Err != nil {
 			return templ_7745c5c3_Err
 		}
 		var templ_7745c5c3_Var200 string
 		templ_7745c5c3_Var200, 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: 890, Col: 137}
+			return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 895, Col: 137}
 		}
 		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var200))
 		if templ_7745c5c3_Err != nil {
@@ -4316,26 +4326,26 @@ func pingSection(url string) templ.Component {
 		var templ_7745c5c3_Var201 string
 		templ_7745c5c3_Var201, 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: 890, Col: 208}
+			return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 895, Col: 208}
 		}
 		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var201))
 		if templ_7745c5c3_Err != nil {
 			return templ_7745c5c3_Err
 		}
-		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 362, "

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

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var202 string templ_7745c5c3_Var202, 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: 891, Col: 84} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 896, Col: 84} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var202)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 363, "

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

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } -- 2.54.1 From 6d3b1dea5d328e0e9a6cd8f1bdb7b57a7906be2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Untersch=C3=BCtz?= Date: Sun, 22 Nov 2026 13:03:07 +0100 Subject: [PATCH 3/3] feat(api): OpenAPI documentation with Swagger UI /api/openapi.json is generated from a table of endpoints and the Go types the handlers bind and return, including the limits of their binding tags, so the document follows the code. A test fails for routes missing from the table or documented but not served. /api/docs shows it with Swagger UI from our own assets, usable without internet access; "Try it out" works with the browser session. Closes #84 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3 --- internal/api/apidocs.go | 207 ++++++++++++ internal/api/export_test.go | 12 + internal/api/invitations.go | 18 +- internal/api/openapi.go | 358 ++++++++++++++++++++ internal/api/openapi_test.go | 118 +++++++ internal/api/server.go | 3 + internal/i18n/locales/de.json | 3 + internal/i18n/locales/en.json | 3 + internal/web/apidocs.templ | 32 ++ internal/web/apidocs_templ.go | 103 ++++++ internal/web/assets/apidocs.js | 17 + internal/web/assets/app.css | 15 + internal/web/console.templ | 1 + internal/web/console_templ.go | 4 + internal/web/org.templ | 1 + internal/web/org_templ.go | 585 +++++++++++++++++---------------- package-lock.json | 19 +- package.json | 5 +- 18 files changed, 1207 insertions(+), 297 deletions(-) create mode 100644 internal/api/apidocs.go create mode 100644 internal/api/openapi.go create mode 100644 internal/api/openapi_test.go create mode 100644 internal/web/apidocs.templ create mode 100644 internal/web/apidocs_templ.go create mode 100644 internal/web/assets/apidocs.js diff --git a/internal/api/apidocs.go b/internal/api/apidocs.go new file mode 100644 index 0000000..28e9e96 --- /dev/null +++ b/internal/api/apidocs.go @@ -0,0 +1,207 @@ +package api + +import ( + "net/http" + "time" + + "github.com/google/uuid" + + "git.zb-server.de/ZB-Server/uptimesebi/internal/check" +) + +// sessionStarted is the answer of requests that sign in. +var sessionStarted = obj{"status": "", "csrf_token": ""} + +// endpoints documents every route under /api/v1, in the order the docs +// show them. +var endpoints = []endpoint{ + // Account + {method: "POST", path: "/api/v1/auth/signup", tag: "Account", summary: "Create an account and organization", public: true, + description: "Starts a session. Depending on the installation, sign-up is open, limited to the first user, or closed.", + req: signupRequest{}, resp: sessionStarted}, + {method: "POST", path: "/api/v1/auth/login", tag: "Account", summary: "Sign in with email and password", public: true, + description: "Answers `{\"status\": \"totp_required\"}` when the account has two-factor authentication; continue with /auth/login/totp.", + req: loginRequest{}, resp: sessionStarted}, + {method: "POST", path: "/api/v1/auth/login/totp", tag: "Account", summary: "Complete sign-in with a TOTP or recovery code", public: true, + req: secondFactorRequest{}, resp: sessionStarted}, + {method: "POST", path: "/api/v1/auth/logout", tag: "Account", summary: "Sign out", sessionOnly: true, status: http.StatusNoContent}, + {method: "GET", path: "/api/v1/me", tag: "Account", summary: "The signed-in user and their organizations", resp: meView{}}, + {method: "POST", path: "/api/v1/me/org", tag: "Account", summary: "Switch the active organization", sessionOnly: true, + req: switchOrgRequest{}, status: http.StatusNoContent}, + {method: "POST", path: "/api/v1/locale", tag: "Account", summary: "Set the interface language", public: true, + req: localeRequest{}, status: http.StatusNoContent}, + {method: "POST", path: "/api/v1/me/totp/setup", tag: "Account", summary: "Start setting up two-factor authentication", sessionOnly: true, + resp: obj{"secret": "", "otpauth_url": "", "qr": ""}}, + {method: "POST", path: "/api/v1/me/totp/enable", tag: "Account", summary: "Enable two-factor authentication", sessionOnly: true, + description: "Returns single-use recovery codes, shown only this once.", req: totpRequest{}, resp: obj{"recovery_codes": []string{}}}, + {method: "POST", path: "/api/v1/me/totp/disable", tag: "Account", summary: "Disable two-factor authentication", sessionOnly: true, + req: reauthRequest{}, status: http.StatusNoContent}, + {method: "POST", path: "/api/v1/me/totp/recovery-codes", tag: "Account", summary: "Replace the recovery codes", sessionOnly: true, + req: reauthRequest{}, resp: obj{"recovery_codes": []string{}}}, + {method: "GET", path: "/api/v1/me/audit", tag: "Account", summary: "Sign-ins and security changes of the account", + resp: obj{"events": []auditEventView{}}}, + {method: "GET", path: "/api/v1/me/export", tag: "Account", summary: "Export all personal data (GDPR Art. 15, 20)", + description: "`?format=pdf` returns a PDF instead of JSON.", resp: accountExport{}}, + {method: "POST", path: "/api/v1/me/delete", tag: "Account", summary: "Delete the account (GDPR Art. 17)", sessionOnly: true, + description: "Refused with `owns_shared_orgs` while the user owns organizations with other members. Organizations only the user belongs to are deleted with the account.", + req: deletionRequest{}, resp: obj{"status": ""}}, + {method: "POST", path: "/api/v1/markdown/preview", tag: "Account", summary: "Render Markdown as pages will show it", + req: previewRequest{}, resp: obj{"html": ""}}, + {method: "POST", path: "/api/v1/invitations/:token/accept", tag: "Account", summary: "Accept an invitation with the signed-in account", sessionOnly: true, + status: http.StatusNoContent}, + {method: "POST", path: "/api/v1/invitations/:token/signup", tag: "Account", summary: "Create an account through an invitation", public: true, + req: inviteSignupRequest{}, resp: sessionStarted}, + + // Monitors + {method: "GET", path: "/api/v1/org/monitors", tag: "Monitors", summary: "List monitors with their latest results", + description: "Only monitors the caller may read; header values and heartbeat tokens only for those who may change the monitor.", + perm: "monitors.read", resp: obj{"monitors": []monitorView{}}}, + {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 or heartbeat; `config` depends on it (see HTTPConfig, JSONConfig, PrometheusConfig, DNSConfig, TLSConfig, HeartbeatConfig). Heartbeat monitors take neither target nor regions and return their `ping_url`.", + perm: "monitors.write", req: monitorRequest{}, status: http.StatusCreated, resp: monitorView{}}, + {method: "PUT", path: "/api/v1/org/monitors/:id", tag: "Monitors", summary: "Change a monitor", perm: "monitors.write", + req: monitorRequest{}, resp: monitorView{}}, + {method: "DELETE", path: "/api/v1/org/monitors/:id", tag: "Monitors", summary: "Delete a monitor and its history", perm: "monitors.write", + status: http.StatusNoContent}, + {method: "GET", path: "/api/v1/org/monitors/:id/evidence", tag: "Monitors", summary: "What checkers saw: captured responses", + perm: "monitors.write", resp: obj{"evidence": []evidenceSummary{}}}, + {method: "GET", path: "/api/v1/org/monitors/:id/evidence/:evidence", tag: "Monitors", summary: "One captured response", + description: "Redirect chain with headers, timing, certificate and the first 32 KiB of the body.", + perm: "monitors.write", resp: obj{"id": uuid.UUID{}, "region": "", "checker_id": uuid.UUID{}, "time": time.Time{}, "ok": false, "status_code": new(int32), "error": new(string), "evidence": check.Evidence{}}}, + {method: "GET", path: "/api/v1/org/checkers/:id", tag: "Monitors", summary: "What a checker instance is doing", + description: "Platform checkers serve every organization; other organizations' work appears only as a count.", + resp: checkerActivity{}}, + {method: "GET", path: "/api/v1/org/groups", tag: "Monitors", summary: "List monitor groups", resp: obj{"groups": []groupView{}}}, + {method: "POST", path: "/api/v1/org/groups", tag: "Monitors", summary: "Create a group", perm: "monitors.write", + req: groupRequest{}, status: http.StatusCreated, resp: groupView{}}, + {method: "PUT", path: "/api/v1/org/groups/:id", tag: "Monitors", summary: "Rename or move a group", perm: "monitors.write", + req: groupRequest{}, resp: groupView{}}, + {method: "DELETE", path: "/api/v1/org/groups/:id", tag: "Monitors", summary: "Delete a group; its content moves up", perm: "monitors.write", + status: http.StatusNoContent}, + {method: "GET", path: "/api/v1/org/maintenance", tag: "Monitors", summary: "List maintenance windows", perm: "monitors.read", + resp: obj{"maintenance": []maintenanceView{}}}, + {method: "POST", path: "/api/v1/org/maintenance", tag: "Monitors", summary: "Plan maintenance", + description: "During maintenance, failures open no incidents and send no notifications.", + perm: "monitors.write", req: maintenanceRequest{}, status: http.StatusCreated, resp: maintenanceView{}}, + {method: "PUT", path: "/api/v1/org/maintenance/:id", tag: "Monitors", summary: "Change maintenance", perm: "monitors.write", + req: maintenanceRequest{}, resp: maintenanceView{}}, + {method: "DELETE", path: "/api/v1/org/maintenance/:id", tag: "Monitors", summary: "Delete maintenance", perm: "monitors.write", + status: http.StatusNoContent}, + {method: "GET", path: "/api/v1/org/incidents", tag: "Monitors", summary: "List incidents", perm: "incidents.read", + resp: obj{"incidents": []incidentView{}}}, + + // Status pages + {method: "GET", path: "/api/v1/org/statuspages", tag: "Status pages", summary: "List status pages", resp: obj{"pages": []statusPageView{}}}, + {method: "POST", path: "/api/v1/org/statuspages", tag: "Status pages", summary: "Create a status page", perm: "statuspages.write", + req: statusPageRequest{}, status: http.StatusCreated, resp: statusPageView{}}, + {method: "PUT", path: "/api/v1/org/statuspages/:id", tag: "Status pages", summary: "Change a status page", perm: "statuspages.write", + req: statusPageRequest{}, resp: statusPageView{}}, + {method: "DELETE", path: "/api/v1/org/statuspages/:id", tag: "Status pages", summary: "Delete a status page", perm: "statuspages.write", + status: http.StatusNoContent}, + {method: "PUT", path: "/api/v1/org/statuspages/:id/monitors", tag: "Status pages", summary: "Set the monitors shown", perm: "statuspages.write", + req: pageMonitorsRequest{}, status: http.StatusNoContent}, + {method: "PUT", path: "/api/v1/org/statuspages/:id/domain", tag: "Status pages", summary: "Set a custom domain", perm: "statuspages.write", + description: "Verify it with a TXT record before it is served.", req: domainRequest{}, resp: statusPageView{}}, + {method: "POST", path: "/api/v1/org/statuspages/:id/domain/verify", tag: "Status pages", summary: "Verify the custom domain", perm: "statuspages.write", + status: http.StatusNoContent}, + {method: "GET", path: "/api/v1/org/statuspages/:id/export", tag: "Status pages", summary: "Export the page as a single HTML file", perm: "statuspages.read", + media: "text/html"}, + + // Alerting + {method: "GET", path: "/api/v1/org/channels", tag: "Alerting", summary: "List notification channels", perm: "notifications.read", + resp: obj{"channels": []channelView{}, "email_available": false}}, + {method: "POST", path: "/api/v1/org/channels", tag: "Alerting", summary: "Create a channel", + description: "Webhook channels return their signing secret once.", perm: "notifications.write", + req: channelRequest{}, status: http.StatusCreated, resp: obj{"channel": channelView{}, "signing_secret": ""}}, + {method: "PUT", path: "/api/v1/org/channels/:id", tag: "Alerting", summary: "Change a channel", perm: "notifications.write", + req: channelRequest{}, resp: obj{"channel": channelView{}, "signing_secret": ""}}, + {method: "DELETE", path: "/api/v1/org/channels/:id", tag: "Alerting", summary: "Delete a channel", perm: "notifications.write", + status: http.StatusNoContent}, + {method: "POST", path: "/api/v1/org/channels/:id/test", tag: "Alerting", summary: "Send a test notification", perm: "notifications.write", + status: http.StatusNoContent}, + + // Organization + {method: "PUT", path: "/api/v1/org/policy", tag: "Organization", summary: "Set sign-in and token policies", perm: "org.manage", sessionOnly: true, + req: policyRequest{}, resp: obj{"require_totp": false, "require_sso": false, "api_token_max_days": new(int32)}}, + {method: "GET", path: "/api/v1/org/members", tag: "Organization", summary: "List members and their roles", perm: "members.read", + resp: obj{"members": []memberView{}}}, + {method: "DELETE", path: "/api/v1/org/members/:user", tag: "Organization", summary: "Remove a member", perm: "members.manage", sessionOnly: true, + status: http.StatusNoContent}, + {method: "POST", path: "/api/v1/org/members/:user/roles", tag: "Organization", summary: "Assign a role, optionally limited to a group or status page", + description: "Nobody can grant permissions they do not hold.", perm: "members.manage", sessionOnly: true, + req: assignRequest{}, status: http.StatusCreated, resp: obj{"id": uuid.UUID{}}}, + {method: "DELETE", path: "/api/v1/org/assignments/:id", tag: "Organization", summary: "Remove a role assignment", perm: "members.manage", sessionOnly: true, + status: http.StatusNoContent}, + {method: "GET", path: "/api/v1/org/invitations", tag: "Organization", summary: "List pending invitations", perm: "members.read", + resp: obj{"invitations": []invitationView{}}}, + {method: "POST", path: "/api/v1/org/invitations", tag: "Organization", summary: "Invite someone", perm: "members.manage", sessionOnly: true, + req: inviteRequest{}, status: http.StatusCreated, resp: obj{"url": ""}}, + {method: "DELETE", path: "/api/v1/org/invitations/:id", tag: "Organization", summary: "Withdraw an invitation", perm: "members.manage", sessionOnly: true, + status: http.StatusNoContent}, + {method: "GET", path: "/api/v1/org/roles", tag: "Organization", summary: "List roles and all permissions", perm: "members.read", + resp: obj{"roles": []roleView{}, "permissions": []string{}}}, + {method: "POST", path: "/api/v1/org/roles", tag: "Organization", summary: "Create a custom role", perm: "roles.manage", sessionOnly: true, + req: roleRequest{}, status: http.StatusCreated, resp: roleView{}}, + {method: "PUT", path: "/api/v1/org/roles/:id", tag: "Organization", summary: "Change a custom role", perm: "roles.manage", sessionOnly: true, + req: roleRequest{}, resp: roleView{}}, + {method: "DELETE", path: "/api/v1/org/roles/:id", tag: "Organization", summary: "Delete an unused custom role", perm: "roles.manage", sessionOnly: true, + status: http.StatusNoContent}, + {method: "GET", path: "/api/v1/org/tokens", tag: "Organization", summary: "List API tokens", + description: "Members see their own tokens; with tokens.manage, all of the organization.", resp: obj{"tokens": []tokenView{}}}, + {method: "POST", path: "/api/v1/org/tokens", tag: "Organization", summary: "Create an API token", sessionOnly: true, + description: "The token is returned only this once. Its permissions are capped by the creator's.", + req: createTokenRequest{}, status: http.StatusCreated, resp: obj{"id": uuid.UUID{}, "token": "", "prefix": "", "permissions": []string{}}}, + {method: "DELETE", path: "/api/v1/org/tokens/:id", tag: "Organization", summary: "Revoke an API token", status: http.StatusNoContent}, + {method: "GET", path: "/api/v1/org/sso", tag: "Organization", summary: "List single sign-on providers", perm: "org.manage", + resp: obj{"providers": []ssoProviderView{}, "redirect_url": ""}}, + {method: "POST", path: "/api/v1/org/sso", tag: "Organization", summary: "Add an OpenID Connect provider", perm: "org.manage", sessionOnly: true, + req: ssoProviderRequest{}, status: http.StatusCreated, resp: ssoProviderView{}}, + {method: "PUT", path: "/api/v1/org/sso/:id", tag: "Organization", summary: "Change a provider", perm: "org.manage", sessionOnly: true, + req: ssoProviderRequest{}, resp: ssoProviderView{}}, + {method: "DELETE", path: "/api/v1/org/sso/:id", tag: "Organization", summary: "Remove a provider", perm: "org.manage", sessionOnly: true, + status: http.StatusNoContent}, + {method: "GET", path: "/api/v1/org/regions", tag: "Organization", summary: "Regions available to the organization", resp: obj{"regions": []regionView{}}}, + {method: "POST", path: "/api/v1/org/regions", tag: "Organization", summary: "Create an own region", perm: "org.manage", sessionOnly: true, + req: regionRequest{}, status: http.StatusCreated, resp: regionView{}}, + {method: "DELETE", path: "/api/v1/org/regions/:id", tag: "Organization", summary: "Delete an own region", perm: "org.manage", sessionOnly: true, + status: http.StatusNoContent}, + {method: "GET", path: "/api/v1/org/agents", tag: "Organization", summary: "List own checkers and status page servers", perm: "org.manage", + resp: obj{"agents": []agentView{}}}, + {method: "POST", path: "/api/v1/org/agents", tag: "Organization", summary: "Create an agent token", perm: "org.manage", sessionOnly: true, + description: "The token is returned only this once.", req: agentRequest{}, status: http.StatusCreated, resp: obj{"id": uuid.UUID{}, "token": ""}}, + {method: "DELETE", path: "/api/v1/org/agents/:id", tag: "Organization", summary: "Revoke an agent", perm: "org.manage", sessionOnly: true, + status: http.StatusNoContent}, + {method: "GET", path: "/api/v1/org/legal", tag: "Organization", summary: "Legal notice and privacy policy of the status pages", perm: "org.manage", + resp: obj{"documents": []legalView{}}}, + {method: "PUT", path: "/api/v1/org/legal/:kind", tag: "Organization", summary: "Set the legal notice (imprint) or privacy policy", + description: "Markdown or a link; a link wins. Both empty removes the document.", perm: "org.manage", + req: legalRequest{}, status: http.StatusNoContent}, + {method: "GET", path: "/api/v1/org/audit", tag: "Organization", summary: "The organization's audit log", perm: "audit.read", + description: "Newest first; pass `next_before` of the answer as `?before=` for older entries.", + resp: obj{"events": []auditEventView{}}}, + {method: "GET", path: "/api/v1/org/export", tag: "Organization", summary: "Export the organization's data", perm: "org.manage", sessionOnly: true, + description: "`?format=pdf` returns a PDF instead of JSON.", resp: orgExport{}}, + {method: "POST", path: "/api/v1/org/delete", tag: "Organization", summary: "Delete the organization with all its data", sessionOnly: true, + description: "Owner only, confirmed with the organization's slug and the owner's password.", + req: orgDeletionRequest{}, resp: obj{"status": ""}}, + + // Platform + {method: "GET", path: "/api/v1/admin/audit", tag: "Platform", summary: "Platform audit log", perm: "platform admin", + resp: obj{"events": []auditEventView{}}}, + {method: "GET", path: "/api/v1/admin/legal", tag: "Platform", summary: "Platform legal notice and privacy policy", perm: "platform admin", + resp: obj{"documents": []legalView{}}}, + {method: "PUT", path: "/api/v1/admin/legal/:kind", tag: "Platform", summary: "Set a platform legal document", perm: "platform admin", + req: legalRequest{}, status: http.StatusNoContent}, + {method: "GET", path: "/api/v1/admin/regions", tag: "Platform", summary: "List platform regions", perm: "platform admin", + resp: obj{"regions": []regionView{}}}, + {method: "POST", path: "/api/v1/admin/regions", tag: "Platform", summary: "Create a platform region", perm: "platform admin", + req: regionRequest{}, status: http.StatusCreated, resp: regionView{}}, + {method: "DELETE", path: "/api/v1/admin/regions/:id", tag: "Platform", summary: "Delete a platform region", perm: "platform admin", + status: http.StatusNoContent}, + {method: "GET", path: "/api/v1/admin/agents", tag: "Platform", summary: "List platform agents", perm: "platform admin", + resp: obj{"agents": []agentView{}}}, + {method: "POST", path: "/api/v1/admin/agents", tag: "Platform", summary: "Create a platform agent token", perm: "platform admin", + req: agentRequest{}, status: http.StatusCreated, resp: obj{"id": uuid.UUID{}, "token": ""}}, + {method: "DELETE", path: "/api/v1/admin/agents/:id", tag: "Platform", summary: "Revoke a platform agent", perm: "platform admin", + status: http.StatusNoContent}, +} diff --git a/internal/api/export_test.go b/internal/api/export_test.go index 346f427..9be0a0a 100644 --- a/internal/api/export_test.go +++ b/internal/api/export_test.go @@ -5,3 +5,15 @@ var LookupTXT = &lookupTXT // AuditActions exposes the audited routes to tests. var AuditActions = auditActions + +// DocumentedRoutes lists the routes in the OpenAPI table. +func DocumentedRoutes() []string { + out := make([]string, len(endpoints)) + for i, e := range endpoints { + out[i] = e.method + " " + e.path + } + return out +} + +// OpenAPI builds the OpenAPI document. +func OpenAPI() map[string]any { return buildOpenAPI("https://uptime.example") } diff --git a/internal/api/invitations.go b/internal/api/invitations.go index 690eaaf..16142ef 100644 --- a/internal/api/invitations.go +++ b/internal/api/invitations.go @@ -85,6 +85,14 @@ func (s *Server) createInvitation(c *gin.Context) { } } +// invitationView is a pending invitation. +type invitationView struct { + ID uuid.UUID `json:"id"` + Email string `json:"email"` + RoleName string `json:"role_name"` + ExpiresAt time.Time `json:"expires_at"` +} + func (s *Server) listInvitations(c *gin.Context) { p := current(c) ctx := c.Request.Context() @@ -98,15 +106,9 @@ func (s *Server) listInvitations(c *gin.Context) { internalError(c, err) return } - type view struct { - ID uuid.UUID `json:"id"` - Email string `json:"email"` - RoleName string `json:"role_name"` - ExpiresAt time.Time `json:"expires_at"` - } - out := make([]view, len(rows)) + out := make([]invitationView, len(rows)) for i, r := range rows { - out[i] = view{ID: r.ID, Email: r.Email, RoleName: r.RoleName, ExpiresAt: r.ExpiresAt} + out[i] = invitationView{ID: r.ID, Email: r.Email, RoleName: r.RoleName, ExpiresAt: r.ExpiresAt} } c.JSON(http.StatusOK, gin.H{"invitations": out}) } diff --git a/internal/api/openapi.go b/internal/api/openapi.go new file mode 100644 index 0000000..c7cfee7 --- /dev/null +++ b/internal/api/openapi.go @@ -0,0 +1,358 @@ +package api + +import ( + "encoding/json" + "net/http" + "reflect" + "slices" + "strconv" + "strings" + "sync" + "unicode" + + "github.com/gin-gonic/gin" + + "git.zb-server.de/ZB-Server/uptimesebi/internal/auth" + "git.zb-server.de/ZB-Server/uptimesebi/internal/buildinfo" + "git.zb-server.de/ZB-Server/uptimesebi/internal/check" + "git.zb-server.de/ZB-Server/uptimesebi/internal/web" +) + +// The OpenAPI document is generated from the endpoint table in apidocs.go +// and the Go types the handlers bind and return, so field names, types and +// validation limits cannot drift from the code. A test fails for routes +// missing from the table. + +// obj describes an inline JSON object, e.g. obj{"monitors": []monitorView{}}. +type obj map[string]any + +// endpoint documents one route. +type endpoint struct { + method, path string + tag, summary string + // description adds detail beyond the summary. + description string + // perm is the permission required, in the words of the API. + perm string + // sessionOnly marks routes API tokens may not use. + sessionOnly bool + public bool + // req is the request body; nil for none. + req any + // status and resp describe the success response; resp nil means no + // body. media overrides application/json. + status int + resp any + media string +} + +// schemaBuilder turns Go types into JSON Schema, collecting named structs as +// components. +type schemaBuilder struct { + components map[string]any +} + +func (b *schemaBuilder) schema(t reflect.Type) map[string]any { + switch t { + case uuidType: + return map[string]any{"type": "string", "format": "uuid"} + case timeType: + return map[string]any{"type": "string", "format": "date-time"} + case rawType: + return map[string]any{"description": "Any JSON value."} + } + switch t.Kind() { + case reflect.Pointer: + s := b.schema(t.Elem()) + if typ, ok := s["type"].(string); ok { + s["type"] = []string{typ, "null"} + return s + } + return map[string]any{"oneOf": []any{s, map[string]any{"type": "null"}}} + case reflect.String: + return map[string]any{"type": "string"} + case reflect.Bool: + return map[string]any{"type": "boolean"} + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, + reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + return map[string]any{"type": "integer"} + case reflect.Float32, reflect.Float64: + return map[string]any{"type": "number"} + case reflect.Slice, reflect.Array: + if t.Elem().Kind() == reflect.Uint8 { + return map[string]any{"type": "string", "contentEncoding": "base64"} + } + return map[string]any{"type": "array", "items": b.schema(t.Elem())} + case reflect.Map: + return map[string]any{"type": "object", "additionalProperties": b.schema(t.Elem())} + case reflect.Interface: + return map[string]any{} + case reflect.Struct: + name := componentName(t) + if name == "" { + return b.object(t) + } + if _, done := b.components[name]; !done { + b.components[name] = nil // breaks recursion + b.components[name] = b.object(t) + } + return map[string]any{"$ref": "#/components/schemas/" + name} + } + return map[string]any{} +} + +// object builds the schema of a struct from its json and binding tags. +func (b *schemaBuilder) object(t reflect.Type) map[string]any { + props := map[string]any{} + var required []string + var walk func(t reflect.Type) + walk = func(t reflect.Type) { + for i := range t.NumField() { + f := t.Field(i) + if !f.IsExported() { + continue + } + tag := f.Tag.Get("json") + name, opts, _ := strings.Cut(tag, ",") + if name == "-" { + continue + } + if f.Anonymous && name == "" { + walk(f.Type) + continue + } + if name == "" { + name = f.Name + } + s := b.schema(f.Type) + binding := strings.Split(f.Tag.Get("binding"), ",") + applyBinding(s, f.Type, binding) + props[name] = s + if slices.Contains(binding, "required") && !strings.Contains(opts, "omitempty") { + required = append(required, name) + } + } + } + walk(t) + s := map[string]any{"type": "object", "properties": props} + if len(required) > 0 { + slices.Sort(required) + s["required"] = required + } + return s +} + +// applyBinding carries validator limits over to the schema. +func applyBinding(s map[string]any, t reflect.Type, rules []string) { + for t.Kind() == reflect.Pointer { + t = t.Elem() + } + for _, r := range rules { + key, val, ok := strings.Cut(r, "=") + if r == "email" { + s["format"] = "email" + } + if !ok { + continue + } + n, err := strconv.Atoi(val) + if err != nil { + continue + } + var bound string + switch t.Kind() { + case reflect.String: + bound = map[string]string{"max": "maxLength", "min": "minLength"}[key] + case reflect.Slice, reflect.Map: + bound = map[string]string{"max": "maxItems", "min": "minItems"}[key] + default: + bound = map[string]string{"max": "maximum", "min": "minimum"}[key] + } + if bound != "" { + s[bound] = n + } + } +} + +// componentName derives a schema name from a Go type: monitorView becomes +// Monitor, monitorRequest MonitorRequest. Types of other packages keep their +// package as prefix to stay unique. +func componentName(t reflect.Type) string { + name := t.Name() + if name == "" { + return "" + } + name = strings.TrimSuffix(name, "View") + r := []rune(name) + r[0] = unicode.ToUpper(r[0]) + name = string(r) + if pkg := t.PkgPath(); !strings.HasSuffix(pkg, "/internal/api") { + p := []rune(pkg[strings.LastIndex(pkg, "/")+1:]) + p[0] = unicode.ToUpper(p[0]) + name = string(p) + name + } + return name +} + +// bodySchema describes a request or response value. +func (b *schemaBuilder) bodySchema(v any) map[string]any { + if o, ok := v.(obj); ok { + props := map[string]any{} + keys := make([]string, 0, len(o)) + for k, val := range o { + props[k] = b.schema(reflect.TypeOf(val)) + keys = append(keys, k) + } + slices.Sort(keys) + return map[string]any{"type": "object", "properties": props, "required": keys} + } + return b.schema(reflect.TypeOf(v)) +} + +// openAPIPath turns gin's ":id" parameters into "{id}". +func openAPIPath(p string) (string, []string) { + var params []string + parts := strings.Split(p, "/") + for i, part := range parts { + if strings.HasPrefix(part, ":") { + params = append(params, part[1:]) + parts[i] = "{" + part[1:] + "}" + } + } + return strings.Join(parts, "/"), params +} + +// buildOpenAPI assembles the document for publicURL. +func buildOpenAPI(publicURL string) map[string]any { + b := &schemaBuilder{components: map[string]any{}} + errorRef := map[string]any{"$ref": "#/components/schemas/Error"} + b.components["Error"] = map[string]any{ + "type": "object", + "required": []string{"error", "message"}, + "properties": map[string]any{ + "error": map[string]any{"type": "string", "description": "Stable code for programs, e.g. invalid_target."}, + "message": map[string]any{"type": "string", "description": "Explanation in the request's language."}, + "request_id": map[string]any{"type": "string", "description": "Quote it when reporting a problem."}, + }, + } + // Monitor settings travel as untyped config; their shapes per type. + for _, c := range []any{check.HTTPConfig{}, check.JSONConfig{}, check.PrometheusConfig{}, check.DNSConfig{}, check.TLSConfig{}, check.HeartbeatConfig{}} { + b.schema(reflect.TypeOf(c)) + } + paths := map[string]map[string]any{} + tags := []string{} + for _, e := range endpoints { + p, params := openAPIPath(e.path) + op := map[string]any{"summary": e.summary, "tags": []string{e.tag}, "operationId": operationID(e)} + desc := e.description + if e.perm != "" { + desc = strings.TrimSpace(desc + "\n\nRequires the permission `" + e.perm + "`.") + } + if e.sessionOnly { + desc = strings.TrimSpace(desc + "\n\nOnly in a browser session, not with an API token.") + } + if desc != "" { + op["description"] = desc + } + if e.public { + op["security"] = []any{} + } else if e.sessionOnly { + op["security"] = []any{map[string]any{"session": []string{}}} + } + var ps []any + for _, name := range params { + ps = append(ps, map[string]any{"name": name, "in": "path", "required": true, "schema": map[string]any{"type": "string"}}) + } + if ps != nil { + op["parameters"] = ps + } + if e.req != nil { + op["requestBody"] = map[string]any{"required": true, "content": map[string]any{ + "application/json": map[string]any{"schema": b.bodySchema(e.req)}, + }} + } + status := e.status + if status == 0 { + status = http.StatusOK + } + success := map[string]any{"description": http.StatusText(status)} + switch { + case e.media != "": + success["content"] = map[string]any{e.media: map[string]any{}} + case e.resp != nil: + success["content"] = map[string]any{"application/json": map[string]any{"schema": b.bodySchema(e.resp)}} + } + op["responses"] = map[string]any{ + strconv.Itoa(status): success, + "default": map[string]any{"description": "Error", "content": map[string]any{"application/json": map[string]any{"schema": errorRef}}}, + } + if paths[p] == nil { + paths[p] = map[string]any{} + } + paths[p][strings.ToLower(e.method)] = op + if !slices.Contains(tags, e.tag) { + tags = append(tags, e.tag) + } + } + tagObjs := make([]any, len(tags)) + for i, t := range tags { + tagObjs[i] = map[string]any{"name": t} + } + return map[string]any{ + "openapi": "3.1.0", + "info": map[string]any{ + "title": "uptimesebi API", + "version": buildinfo.Version, + "description": "Manage monitors, status pages, alerting and members of an organization.\n\n" + + "Authenticate with an API token as `Authorization: Bearer ust_…` (create one under Settings → API tokens; " + + "it never exceeds its owner's permissions), or use the browser session, which additionally needs the " + + "`" + auth.CSRFHeader + "` header on changes. Errors share one format with a stable `error` code.", + "license": map[string]any{"name": "AGPL-3.0-only", "identifier": "AGPL-3.0-only"}, + }, + "servers": []any{map[string]any{"url": strings.TrimSuffix(publicURL, "/")}}, + "security": []any{ + map[string]any{"token": []string{}}, + map[string]any{"session": []string{}}, + }, + "tags": tagObjs, + "paths": paths, + "components": map[string]any{ + "schemas": b.components, + "securitySchemes": map[string]any{ + "token": map[string]any{"type": "http", "scheme": "bearer", "description": "API token, prefix ust_."}, + "session": map[string]any{"type": "apiKey", "in": "cookie", "name": auth.CookieName}, + }, + }, + } +} + +func operationID(e endpoint) string { + var b strings.Builder + b.WriteString(strings.ToLower(e.method)) + for _, part := range strings.Split(strings.TrimPrefix(e.path, "/api/v1/"), "/") { + part = strings.TrimPrefix(part, ":") + for _, w := range strings.FieldsFunc(part, func(r rune) bool { return r == '-' || r == '_' }) { + r := []rune(w) + r[0] = unicode.ToUpper(r[0]) + b.WriteString(string(r)) + } + } + return b.String() +} + +var ( + openAPIOnce sync.Once + openAPIDoc []byte +) + +func (s *Server) openAPIJSON(c *gin.Context) { + openAPIOnce.Do(func() { + openAPIDoc, _ = json.MarshalIndent(buildOpenAPI(s.cfg.PublicURL), "", " ") + }) + c.Header("Cache-Control", "public, max-age=300") + c.Data(http.StatusOK, "application/json", openAPIDoc) +} + +func (s *Server) apiDocsPage(c *gin.Context) { + web.Render(c, http.StatusOK, web.APIDocsPage(s.pageFor(c, "apidocs.title"))) +} diff --git a/internal/api/openapi_test.go b/internal/api/openapi_test.go new file mode 100644 index 0000000..453903a --- /dev/null +++ b/internal/api/openapi_test.go @@ -0,0 +1,118 @@ +package api_test + +import ( + "encoding/json" + "io" + "log/slog" + "net/http" + "slices" + "strings" + "testing" + + "github.com/gin-gonic/gin" + + "git.zb-server.de/ZB-Server/uptimesebi/internal/api" + "git.zb-server.de/ZB-Server/uptimesebi/internal/config" +) + +func TestEveryRouteIsDocumented(t *testing.T) { + r := gin.New() + api.New(config.API{}, api.Deps{Log: slog.New(slog.DiscardHandler)}).Mount(r) + documented := api.DocumentedRoutes() + var served []string + for _, rt := range r.Routes() { + if strings.HasPrefix(rt.Path, "/api/v1/") { + served = append(served, rt.Method+" "+rt.Path) + } + } + for _, s := range served { + if !slices.Contains(documented, s) { + t.Errorf("%s is not documented in apidocs.go", s) + } + } + for _, d := range documented { + if !slices.Contains(served, d) { + t.Errorf("%s is documented but not served", d) + } + } +} + +func TestOpenAPIDocument(t *testing.T) { + doc := api.OpenAPI() + raw, err := json.Marshal(doc) + if err != nil { + t.Fatal(err) + } + var generic map[string]any + _ = json.Unmarshal(raw, &generic) + schemas := generic["components"].(map[string]any)["schemas"].(map[string]any) + + // Every reference resolves and every required field exists. + var walk func(v any) + walk = func(v any) { + switch x := v.(type) { + case map[string]any: + if ref, ok := x["$ref"].(string); ok { + if _, ok := schemas[strings.TrimPrefix(ref, "#/components/schemas/")]; !ok { + t.Errorf("unresolved %s", ref) + } + } + if req, ok := x["required"].([]any); ok { + if props, ok := x["properties"].(map[string]any); ok { + for _, r := range req { + if _, ok := props[r.(string)]; !ok { + t.Errorf("required %v is not a property", r) + } + } + } + } + for _, child := range x { + walk(child) + } + case []any: + for _, child := range x { + walk(child) + } + } + } + walk(generic) + + // Limits come from the binding tags the API validates with. + mr := schemas["MonitorRequest"].(map[string]any) + name := mr["properties"].(map[string]any)["name"].(map[string]any) + if name["maxLength"] != float64(200) || !slices.Contains(mr["required"].([]any), any("name")) { + t.Errorf("MonitorRequest.name = %v, required %v", name, mr["required"]) + } + if _, ok := schemas["Monitor"].(map[string]any)["properties"].(map[string]any)["ping_url"]; !ok { + t.Error("Monitor lacks ping_url") + } + for _, s := range []string{"CheckHTTPConfig", "CheckJSONConfig", "CheckPrometheusConfig", "Error"} { + if _, ok := schemas[s]; !ok { + t.Errorf("schema %s missing", s) + } + } + paths := generic["paths"].(map[string]any) + put := paths["/api/v1/org/monitors/{id}"].(map[string]any)["put"].(map[string]any) + if params := put["parameters"].([]any); len(params) != 1 || params[0].(map[string]any)["name"] != "id" { + t.Errorf("path parameters = %v", put["parameters"]) + } + if login := paths["/api/v1/auth/login"].(map[string]any)["post"].(map[string]any); len(login["security"].([]any)) != 0 { + t.Error("login is not marked public") + } +} + +func TestAPIDocsServed(t *testing.T) { + e := newEnv(t) + resp, err := e.srv.Client().Get(e.srv.URL + "/api/openapi.json") + if err != nil { + t.Fatal(err) + } + body, _ := io.ReadAll(resp.Body) + _ = resp.Body.Close() + if resp.StatusCode != http.StatusOK || !strings.Contains(string(body), `"openapi": "3.1.0"`) || !strings.Contains(string(body), e.srv.URL) { + t.Errorf("openapi.json = %d %.200s", resp.StatusCode, body) + } + if st, _, page := e.browser(t).page("/api/docs"); st != http.StatusOK || !strings.Contains(page, "swagger-ui-bundle.js") { + t.Errorf("/api/docs = %d", st) + } +} diff --git a/internal/api/server.go b/internal/api/server.go index 5074f3b..78a7905 100644 --- a/internal/api/server.go +++ b/internal/api/server.go @@ -88,6 +88,9 @@ func (s *Server) Mount(r gin.IRouter) { g := r.Group("/", s.sessions.Load(), s.localize(), auth.CSRF(), s.audit()) + r.GET("/api/openapi.json", s.openAPIJSON) + g.GET("/api/docs", s.apiDocsPage) + v1 := g.Group("/api/v1") v1.POST("/locale", s.setLocale) v1.POST("/markdown/preview", auth.Require(), s.previewMarkdown) diff --git a/internal/i18n/locales/de.json b/internal/i18n/locales/de.json index 898e340..a0a6ee4 100644 --- a/internal/i18n/locales/de.json +++ b/internal/i18n/locales/de.json @@ -10,6 +10,8 @@ "agents.region": "Region", "agents.revoke_confirm": "Diesen Agent widerrufen? Seine Instanzen hören sofort auf zu arbeiten.", "agents.token_now": "Kopiere den Token jetzt und setze ihn als UPTIME_AGENT_TOKEN. Er wird nicht erneut angezeigt. Beliebig viele Instanzen können ihn teilen.", + "apidocs.hint": "„Try it out“ nutzt deine aktuelle Sitzung.", + "apidocs.title": "API-Dokumentation", "app.network_error": "Verbindung fehlgeschlagen.", "audit.action.account.delete": "Konto gelöscht", "audit.action.account.export": "Persönliche Daten exportiert", @@ -686,6 +688,7 @@ "security.totp.inactive": "nicht eingerichtet", "security.totp.qr_alt": "QR-Code für die Authenticator-App", "security.totp.start": "Einrichten", + "settings.apidocs": "Alle Endpunkte mit ihren Feldern, im OpenAPI-Format.", "settings.audit": "Wer wann was geändert hat.", "settings.channels": "Webhooks und E-Mail für Incidents", "settings.groups": "Monitore in verschachtelten Gruppen ordnen", diff --git a/internal/i18n/locales/en.json b/internal/i18n/locales/en.json index 33d61bd..2a7ad48 100644 --- a/internal/i18n/locales/en.json +++ b/internal/i18n/locales/en.json @@ -10,6 +10,8 @@ "agents.region": "Region", "agents.revoke_confirm": "Revoke this agent? Its instances stop working immediately.", "agents.token_now": "Copy the token now and set it as UPTIME_AGENT_TOKEN. It will not be shown again. Any number of instances may share it.", + "apidocs.hint": "\"Try it out\" uses your current session.", + "apidocs.title": "API documentation", "app.network_error": "Connection failed.", "audit.action.account.delete": "Account deleted", "audit.action.account.export": "Personal data exported", @@ -686,6 +688,7 @@ "security.totp.inactive": "not set up", "security.totp.qr_alt": "QR code for your authenticator app", "security.totp.start": "Set up", + "settings.apidocs": "Every endpoint with its fields, in OpenAPI format.", "settings.audit": "Who changed what and when.", "settings.channels": "Webhooks and email for incidents", "settings.groups": "Organize monitors in nested groups", diff --git a/internal/web/apidocs.templ b/internal/web/apidocs.templ new file mode 100644 index 0000000..8d2f010 --- /dev/null +++ b/internal/web/apidocs.templ @@ -0,0 +1,32 @@ +package web + +import "git.zb-server.de/ZB-Server/uptimesebi/internal/i18n" + +// APIDocsPage shows the OpenAPI document with Swagger UI, served from our +// own assets so it works without internet access. +templ APIDocsPage(p Page) { + + + + + + if p.CSRF != "" { + + } + { i18n.T(ctx, p.TitleID) } · uptimesebi + + + + +
+
+ uptimesebi + { i18n.T(ctx, "apidocs.hint") } +
+
+
+ + + + +} diff --git a/internal/web/apidocs_templ.go b/internal/web/apidocs_templ.go new file mode 100644 index 0000000..b57789f --- /dev/null +++ b/internal/web/apidocs_templ.go @@ -0,0 +1,103 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.3.1118 + +package web + +//lint:file-ignore SA4006 This context is only used if a nested component is present. + +import "github.com/a-h/templ" +import templruntime "github.com/a-h/templ/runtime" + +import "git.zb-server.de/ZB-Server/uptimesebi/internal/i18n" + +// APIDocsPage shows the OpenAPI document with Swagger UI, served from our +// own assets so it works without internet access. +func APIDocsPage(p Page) 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, 1, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if p.CSRF != "" { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var4 string + templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, p.TitleID)) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/apidocs.templ`, Line: 16, Col: 34} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, " · uptimesebi
uptimesebi ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var5 string + templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "apidocs.hint")) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/apidocs.templ`, Line: 24, Col: 67} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +var _ = templruntime.GeneratedTemplate diff --git a/internal/web/assets/apidocs.js b/internal/web/assets/apidocs.js new file mode 100644 index 0000000..936edd4 --- /dev/null +++ b/internal/web/assets/apidocs.js @@ -0,0 +1,17 @@ +// Swagger UI for /api/openapi.json. "Try it out" uses the browser session, +// which needs the CSRF token on changes. +(() => { + const csrf = document.querySelector('meta[name="csrf-token"]')?.content; + window.SwaggerUIBundle({ + url: "/api/openapi.json", + dom_id: "#swagger", + deepLinking: true, + tryItOutEnabled: false, + withCredentials: true, + defaultModelsExpandDepth: 0, + requestInterceptor: (req) => { + if (csrf && req.method !== "GET") req.headers["X-CSRF-Token"] = csrf; + return req; + }, + }); +})(); diff --git a/internal/web/assets/app.css b/internal/web/assets/app.css index cceb604..7d1c79f 100644 --- a/internal/web/assets/app.css +++ b/internal/web/assets/app.css @@ -93,3 +93,18 @@ .legal-text td { @apply border border-rule px-2 py-1 text-left; } .legal-text code { @apply font-mono text-xs; } } + +/* Swagger UI: keep its layout, use the console's fonts and colors. */ +.api-docs .swagger-ui, +.api-docs .swagger-ui .info .title, +.api-docs .swagger-ui .opblock-tag { + font-family: var(--font-sans); +} +.api-docs .swagger-ui .topbar { + display: none; +} +@media (prefers-color-scheme: dark) { + .api-docs .swagger-ui { + filter: invert(0.92) hue-rotate(180deg); + } +} diff --git a/internal/web/console.templ b/internal/web/console.templ index b340e80..c8bac86 100644 --- a/internal/web/console.templ +++ b/internal/web/console.templ @@ -197,6 +197,7 @@ templ SettingsIndex(p Page, me Me) { } if len(me.Orgs) > 0 { @settingsLink("/settings/tokens", "console.nav.tokens", "settings.tokens") + @settingsLink("/api/docs", "apidocs.title", "settings.apidocs") } if me.Can["org.manage"] { @settingsLink("/settings/regions", "console.nav.regions", "settings.regions") diff --git a/internal/web/console_templ.go b/internal/web/console_templ.go index f86420a..71ea05c 100644 --- a/internal/web/console_templ.go +++ b/internal/web/console_templ.go @@ -984,6 +984,10 @@ func SettingsIndex(p Page, me Me) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } + templ_7745c5c3_Err = settingsLink("/api/docs", "apidocs.title", "settings.apidocs").Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } } if me.Can["org.manage"] { templ_7745c5c3_Err = settingsLink("/settings/regions", "console.nav.regions", "settings.regions").Render(ctx, templ_7745c5c3_Buffer) diff --git a/internal/web/org.templ b/internal/web/org.templ index 0ffafa6..4687905 100644 --- a/internal/web/org.templ +++ b/internal/web/org.templ @@ -301,6 +301,7 @@ templ TokensPage(p Page, me Me, v TokensView) { } else { @settingsHeading("tokens.title", "tokens.intro") } +

{ i18n.T(ctx, "apidocs.title") }

if v.MaxDays > 0 {

{ i18n.T(ctx, "tokens.policy", "Count", v.MaxDays) }

} diff --git a/internal/web/org_templ.go b/internal/web/org_templ.go index 50966b5..0882db3 100644 --- a/internal/web/org_templ.go +++ b/internal/web/org_templ.go @@ -1194,91 +1194,91 @@ func TokensPage(p Page, me Me, v TokensView) templ.Component { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 98, " ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 98, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var52 string + templ_7745c5c3_Var52, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "apidocs.title")) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 304, Col: 119} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var52)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 99, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if v.MaxDays > 0 { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 99, "

") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var52 string - templ_7745c5c3_Var52, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "tokens.policy", "Count", v.MaxDays)) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 305, Col: 83} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var52)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 100, "

") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 101, " ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - if len(v.Tokens) > 0 { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 102, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 101, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 102, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if len(v.Tokens) > 0 { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 103, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 100, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var53 string - templ_7745c5c3_Var53, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "sso.field.name")) + templ_7745c5c3_Var53, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "tokens.policy", "Count", v.MaxDays)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 311, Col: 71} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 306, Col: 83} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var53)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 103, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if v.ShowOwner { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 104, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 106, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 106, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 110, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } for _, t := range v.Tokens { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 111, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 113, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var61 string + templ_7745c5c3_Var61, templ_7745c5c3_Err = templ.JoinStringErrs(t.Prefix) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 326, Col: 101} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var61)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 114, "…") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if v.ShowOwner { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 114, "") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 116, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 119, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 125, "\" class=\"text-muted hover:text-down\">") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var69 string + templ_7745c5c3_Var69, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "members.revoke")) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 346, Col: 40} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var69)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 126, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 126, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var54 string + templ_7745c5c3_Var54, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "sso.field.name")) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 312, Col: 71} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var54)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 104, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 105, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var54 string - templ_7745c5c3_Var54, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "tokens.owner")) + var templ_7745c5c3_Var55 string + templ_7745c5c3_Var55, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "tokens.owner")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 313, Col: 70} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 314, Col: 70} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var54)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var55)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 105, "") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var55 string - templ_7745c5c3_Var55, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "tokens.permissions")) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 315, Col: 75} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var55)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 107, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 107, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var56 string - templ_7745c5c3_Var56, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "tokens.created")) + templ_7745c5c3_Var56, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "tokens.permissions")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 316, Col: 71} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 316, Col: 75} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var56)) if templ_7745c5c3_Err != nil { @@ -1289,7 +1289,7 @@ func TokensPage(p Page, me Me, v TokensView) templ.Component { return templ_7745c5c3_Err } var templ_7745c5c3_Var57 string - templ_7745c5c3_Var57, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "tokens.expires")) + templ_7745c5c3_Var57, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "tokens.created")) if templ_7745c5c3_Err != nil { return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 317, Col: 71} } @@ -1302,110 +1302,110 @@ func TokensPage(p Page, me Me, v TokensView) templ.Component { return templ_7745c5c3_Err } var templ_7745c5c3_Var58 string - templ_7745c5c3_Var58, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "tokens.last_used")) + templ_7745c5c3_Var58, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "tokens.expires")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 318, Col: 73} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 318, Col: 71} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var58)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 110, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var59 string + templ_7745c5c3_Var59, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "tokens.last_used")) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 319, Col: 73} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var59)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 111, "
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var59 string - templ_7745c5c3_Var59, templ_7745c5c3_Err = templ.JoinStringErrs(t.Name) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 325, Col: 39} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var59)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 112, " ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 112, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var60 string - templ_7745c5c3_Var60, templ_7745c5c3_Err = templ.JoinStringErrs(t.Prefix) + templ_7745c5c3_Var60, templ_7745c5c3_Err = templ.JoinStringErrs(t.Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 325, Col: 101} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 326, Col: 39} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var60)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 113, "…") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var61 string - templ_7745c5c3_Var61, templ_7745c5c3_Err = templ.JoinStringErrs(t.UserEmail) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 327, Col: 45} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var61)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 115, "
    ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - for _, perm := range t.Permissions { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 117, "
  • ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 115, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var62 string - templ_7745c5c3_Var62, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "perm."+perm)) + templ_7745c5c3_Var62, templ_7745c5c3_Err = templ.JoinStringErrs(t.UserEmail) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 332, Col: 79} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 328, Col: 45} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var62)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 118, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 116, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 117, "
    ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var63 string - templ_7745c5c3_Var63, templ_7745c5c3_Err = templ.JoinStringErrs(t.CreatedAt) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 336, Col: 80} + for _, perm := range t.Permissions { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 118, "
  • ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var63 string + templ_7745c5c3_Var63, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "perm."+perm)) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 333, Col: 79} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var63)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 119, "
  • ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var63)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 120, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 120, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var64 string - templ_7745c5c3_Var64, templ_7745c5c3_Err = templ.JoinStringErrs(t.ExpiresAt) + templ_7745c5c3_Var64, templ_7745c5c3_Err = templ.JoinStringErrs(t.CreatedAt) if templ_7745c5c3_Err != nil { return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 337, Col: 80} } @@ -1418,64 +1418,77 @@ func TokensPage(p Page, me Me, v TokensView) templ.Component { return templ_7745c5c3_Err } var templ_7745c5c3_Var65 string - templ_7745c5c3_Var65, templ_7745c5c3_Err = templ.JoinStringErrs(t.LastUsedAt) + templ_7745c5c3_Var65, templ_7745c5c3_Err = templ.JoinStringErrs(t.ExpiresAt) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 338, Col: 81} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 338, Col: 80} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var65)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 122, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var66 string - templ_7745c5c3_Var66, templ_7745c5c3_Err = templruntime.NewAttributeExpression("/org/tokens/" + t.ID).Resolve(ctx) + templ_7745c5c3_Var66, templ_7745c5c3_Err = templ.JoinStringErrs(t.LastUsedAt) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 342, Col: 44} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 339, Col: 81} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var66) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var66)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 123, "\" data-confirm=\"") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 123, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 127, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 127, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 128, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -1483,7 +1496,7 @@ func TokensPage(p Page, me Me, v TokensView) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 128, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 129, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -1499,86 +1512,86 @@ func TokensPage(p Page, me Me, v TokensView) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 129, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -1586,20 +1599,20 @@ func TokensPage(p Page, me Me, v TokensView) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 139, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 141, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -1638,7 +1651,7 @@ func OrgSettingsPage(p Page, me Me, v OrgSettings) templ.Component { } ctx = templ.InitializeContext(ctx) ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Var75 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_Var76 := 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 { @@ -1654,7 +1667,7 @@ func OrgSettingsPage(p Page, me Me, v OrgSettings) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 141, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 142, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -1662,7 +1675,7 @@ func OrgSettingsPage(p Page, me Me, v OrgSettings) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 142, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 143, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -1674,20 +1687,20 @@ func OrgSettingsPage(p Page, me Me, v OrgSettings) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 143, "

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

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var76 string - templ_7745c5c3_Var76, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "org.require_totp_hint")) + var templ_7745c5c3_Var77 string + templ_7745c5c3_Var77, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "org.require_totp_hint")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 396, Col: 82} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 397, Col: 82} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var76)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var77)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 144, "

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

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -1695,72 +1708,72 @@ func OrgSettingsPage(p Page, me Me, v OrgSettings) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 145, "

") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var77 string - templ_7745c5c3_Var77, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "org.require_sso_hint")) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 398, Col: 81} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var77)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 146, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var82 string + templ_7745c5c3_Var82, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "org.token_max_days_hint")) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 413, Col: 79} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var82)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 151, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -1768,7 +1781,7 @@ func OrgSettingsPage(p Page, me Me, v OrgSettings) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 151, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 152, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -1778,7 +1791,7 @@ func OrgSettingsPage(p Page, me Me, v OrgSettings) templ.Component { } return nil }) - templ_7745c5c3_Err = consoleShell(p, me).Render(templ.WithChildren(ctx, templ_7745c5c3_Var75), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = consoleShell(p, me).Render(templ.WithChildren(ctx, templ_7745c5c3_Var76), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -1814,7 +1827,7 @@ func InvitationPage(p Page, v Invitation) templ.Component { } ctx = templ.InitializeContext(ctx) ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Var83 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_Var84 := 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 { @@ -1827,70 +1840,70 @@ func InvitationPage(p Page, v Invitation) templ.Component { } ctx = templ.InitializeContext(ctx) if !v.Valid { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 152, "

") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var84 string - templ_7745c5c3_Var84, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "error.invitation_invalid")) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 434, Col: 63} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var84)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 153, "

") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - } else { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 154, "

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

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var85 string - templ_7745c5c3_Var85, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "invite.summary", "Org", v.OrgName, "Role", v.RoleName)) + templ_7745c5c3_Var85, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "error.invitation_invalid")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 436, Col: 96} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 435, Col: 63} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var85)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 155, "

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

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 155, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var86 string - templ_7745c5c3_Var86, templ_7745c5c3_Err = templ.JoinStringErrs(v.Email) + templ_7745c5c3_Var86, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "invite.summary", "Org", v.OrgName, "Role", v.RoleName)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 437, Col: 46} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 437, Col: 96} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var86)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 156, "

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

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var87 string + templ_7745c5c3_Var87, templ_7745c5c3_Err = templ.JoinStringErrs(v.Email) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 438, Col: 46} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var87)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 157, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } switch { case v.SignedInAs == v.Email: - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 157, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 159, "\" data-next=\"/\">") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -1902,87 +1915,87 @@ func InvitationPage(p Page, v Invitation) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 159, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 160, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } case v.SignedInAs != "": - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 160, "

") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var88 string - templ_7745c5c3_Var88, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "error.invitation_email_mismatch")) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 445, Col: 82} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var88)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 161, "

") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - case v.AccountExists: - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 163, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + case v.AccountExists: + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 164, "") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - default: - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 166, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var92 string - templ_7745c5c3_Var92, templ_7745c5c3_Err = templruntime.NewAttributeExpression("/invitations/" + v.Token + "/signup").Resolve(ctx) + templ_7745c5c3_Var92, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "invite.sign_in")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 450, Col: 59} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 449, Col: 153} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var92) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var92)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 167, "\" data-next=\"/\">") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 166, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + default: + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 167, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -2002,7 +2015,7 @@ func InvitationPage(p Page, v Invitation) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 168, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 169, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -2010,7 +2023,7 @@ func InvitationPage(p Page, v Invitation) templ.Component { } return nil }) - templ_7745c5c3_Err = authShell(p).Render(templ.WithChildren(ctx, templ_7745c5c3_Var83), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = authShell(p).Render(templ.WithChildren(ctx, templ_7745c5c3_Var84), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/package-lock.json b/package-lock.json index 0dab48c..6b1fda7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,7 +7,8 @@ "name": "uptimesebi-web", "license": "AGPL-3.0-only", "dependencies": { - "axios": "1.21.1" + "axios": "1.21.1", + "swagger-ui-dist": "5.35.1" }, "devDependencies": { "@fontsource/ibm-plex-mono": "5.3.0", @@ -391,6 +392,13 @@ "url": "https://opencollective.com/parcel" } }, + "node_modules/@scarf/scarf": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@scarf/scarf/-/scarf-1.4.0.tgz", + "integrity": "sha512-xxeapPiUXdZAE3che6f3xogoJPeZgig6omHEy1rIY5WVsB3H2BHNnZH+gHG6x91SCWyQCzWGsuL2Hh3ClO5/qQ==", + "hasInstallScript": true, + "license": "Apache-2.0" + }, "node_modules/@tailwindcss/cli": { "version": "4.3.5", "resolved": "https://registry.npmjs.org/@tailwindcss/cli/-/cli-4.3.5.tgz", @@ -1470,6 +1478,15 @@ "node": ">=6.0.0" } }, + "node_modules/swagger-ui-dist": { + "version": "5.35.1", + "resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-5.35.1.tgz", + "integrity": "sha512-XPBzLiPyIvwg2KYyNZIxOVS77pD0SNMbiSIwvpPXbU5bC/F4zvXxGraK3Hpyxug1b89fH5T29gSsW6rBxMmPyg==", + "license": "Apache-2.0", + "dependencies": { + "@scarf/scarf": "=1.4.0" + } + }, "node_modules/tailwindcss": { "version": "4.3.5", "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.3.5.tgz", diff --git a/package.json b/package.json index 9425bc5..45259a3 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "scripts": { "build": "npm run build:css && npm run build:js && npm run build:fonts", "build:css": "tailwindcss -i internal/web/assets/app.css -o internal/web/static/dist/app.css --minify", - "build:js": "cp node_modules/axios/dist/axios.min.js internal/web/static/dist/axios.min.js && cp internal/web/assets/app.js internal/web/static/dist/app.js", + "build:js": "cp node_modules/axios/dist/axios.min.js internal/web/static/dist/axios.min.js && cp internal/web/assets/app.js internal/web/static/dist/app.js && cp node_modules/swagger-ui-dist/swagger-ui-bundle.js node_modules/swagger-ui-dist/swagger-ui.css internal/web/assets/apidocs.js internal/web/static/dist/", "watch:css": "tailwindcss -i internal/web/assets/app.css -o internal/web/static/dist/app.css --watch", "build:fonts": "mkdir -p internal/web/static/dist/fonts && cp node_modules/@fontsource/ibm-plex-sans/files/ibm-plex-sans-latin-400-normal.woff2 node_modules/@fontsource/ibm-plex-sans/files/ibm-plex-sans-latin-500-normal.woff2 node_modules/@fontsource/ibm-plex-sans/files/ibm-plex-sans-latin-600-normal.woff2 node_modules/@fontsource/ibm-plex-mono/files/ibm-plex-mono-latin-400-normal.woff2 node_modules/@fontsource/ibm-plex-mono/files/ibm-plex-mono-latin-500-normal.woff2 internal/web/static/dist/fonts/" }, @@ -16,6 +16,7 @@ "tailwindcss": "4.3.5" }, "dependencies": { - "axios": "1.21.1" + "axios": "1.21.1", + "swagger-ui-dist": "5.35.1" } } -- 2.54.1