Compare commits
No files matched your search
@@ -44,6 +44,11 @@ UPTIME_TEST_REDIS_URL=redis://localhost:6379/15
|
||||
# Reverse proxies allowed to set X-Forwarded-For (comma-separated IPs/CIDRs).
|
||||
# UPTIME_TRUSTED_PROXIES=10.0.0.0/8
|
||||
|
||||
# How long a region with monitors may have no live checker before the
|
||||
# platform's admins (platform regions) or the organization's owners (own
|
||||
# regions) get an email; 0 switches it off.
|
||||
# UPTIME_REGION_ALERT_AFTER=5m
|
||||
|
||||
# Data retention (0 keeps forever). Raw results feed charts up to 24h, the
|
||||
# hourly aggregate 7d and 30d, the daily aggregate up to a year; resolved
|
||||
# incidents follow the daily aggregate.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
[](https://git.zb-server.de/ZB-Server/uptimesebi/actions?workflow=ci.yaml) · License: AGPL-3.0-only
|
||||
|
||||
UptimeSebi monitors websites, APIs and services from several regions and tells you when they are down, without false alarms from a single checker losing its network: a monitor only counts as down when **every** region it is checked from fails. It publishes status pages that stay online even while UptimeSebi itself is not, and it can run entirely on your own infrastructure.
|
||||
UptimeSebi monitors websites, APIs and services from several regions and tells you when they are down, without false alarms from a single checker losing its network: a monitor only counts as down when **every** region it is checked from fails. A region whose checkers are gone is left out rather than holding the monitor up, and its admins are told. It publishes status pages that stay online even while UptimeSebi itself is not, and it can run entirely on your own infrastructure.
|
||||
|
||||
It is built for teams and hosting providers: organizations with members, roles and SSO, run either as a shared cloud service or self-hosted.
|
||||
|
||||
@@ -159,7 +159,7 @@ Run as many API, checker and status page instances as you need; they share no lo
|
||||
| Hybrid | hosted | at the customer | at the customer |
|
||||
| Self-hosted | at the customer | at the customer | at the customer |
|
||||
|
||||
Checkers and status page servers reach the API over HTTPS and never the database, so they can run in other networks.
|
||||
Checkers and status page servers reach the API over HTTPS and never the database, so they can run in other networks. Status page servers fetch every page they serve every five minutes, so each one is cached before its first visit and keeps being served while the API is unreachable. Once one of an organization's own status page servers has connected, only its own servers serve its pages; the platform's no longer do.
|
||||
|
||||
## Usage
|
||||
|
||||
|
||||
@@ -92,6 +92,7 @@ func run(log *slog.Logger, level *slog.LevelVar, args []string) error {
|
||||
go srv.RunScheduler(ctx)
|
||||
go srv.RunNotifier(ctx)
|
||||
go srv.RunHousekeeping(ctx)
|
||||
go srv.RunRegionWatch(ctx)
|
||||
go srv.RunHeartbeats(ctx)
|
||||
|
||||
return platform.Serve(ctx, log, platform.NewHTTPServer(cfg.Listen, r), health, 5*time.Second, cfg.ShutdownTimeout)
|
||||
|
||||
@@ -125,6 +125,11 @@ func (c *Client) WithHTTPClient(hc *http.Client) *Client {
|
||||
func (c *Client) Instance() uuid.UUID { return c.instance }
|
||||
|
||||
func (c *Client) do(ctx context.Context, method, path string, in, out any) error {
|
||||
return c.doWith(ctx, method, path, nil, in, out)
|
||||
}
|
||||
|
||||
// doWith is do with extra request headers.
|
||||
func (c *Client) doWith(ctx context.Context, method, path string, header http.Header, in, out any) error {
|
||||
var body io.Reader
|
||||
if in != nil {
|
||||
b, err := json.Marshal(in)
|
||||
@@ -142,6 +147,9 @@ func (c *Client) do(ctx context.Context, method, path string, in, out any) error
|
||||
req.Header.Set(VersionHeader, fmt.Sprint(Version))
|
||||
req.Header.Set(InstanceHeader, c.instance.String())
|
||||
req.Header.Set(ReleaseHeader, c.release)
|
||||
for k, v := range header {
|
||||
req.Header[k] = v
|
||||
}
|
||||
resp, err := c.hc.Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -152,6 +160,8 @@ func (c *Client) do(ctx context.Context, method, path string, in, out any) error
|
||||
return ErrUnauthorized
|
||||
case resp.StatusCode == http.StatusNotFound:
|
||||
return ErrNotFound
|
||||
case resp.StatusCode == http.StatusNotModified:
|
||||
return ErrNotModified
|
||||
case resp.StatusCode >= 300:
|
||||
msg, _ := io.ReadAll(io.LimitReader(resp.Body, 1024))
|
||||
return fmt.Errorf("agentapi: %s %s: %d %s", method, path, resp.StatusCode, bytes.TrimSpace(msg))
|
||||
|
||||
@@ -2,6 +2,9 @@ package agentapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@@ -348,19 +351,57 @@ func (s PageSnapshot) LegalDocByKind(kind string) (LegalDoc, bool) {
|
||||
return LegalDoc{}, false
|
||||
}
|
||||
|
||||
// PageRef names a page a status page server serves: by Slug on its own
|
||||
// hosts and, when Host is set, by that verified custom domain.
|
||||
type PageRef struct {
|
||||
Slug string `json:"slug"`
|
||||
Host string `json:"host,omitempty"`
|
||||
}
|
||||
|
||||
// Pages lists every page this status page server serves, so it can keep
|
||||
// them all cached before anyone visits.
|
||||
func (c *Client) Pages(ctx context.Context) ([]PageRef, error) {
|
||||
var out struct {
|
||||
Pages []PageRef `json:"pages"`
|
||||
}
|
||||
err := c.do(ctx, http.MethodGet, "/pages/index", nil, &out)
|
||||
return out.Pages, err
|
||||
}
|
||||
|
||||
// ErrNotFound means no published page matches.
|
||||
var ErrNotFound = errors.New("agentapi: not found")
|
||||
|
||||
// ErrNotModified means the page still matches the checksum sent.
|
||||
var ErrNotModified = errors.New("agentapi: not modified")
|
||||
|
||||
// Checksum identifies the content of s, leaving out when it was generated.
|
||||
func (s PageSnapshot) Checksum() string {
|
||||
s.GeneratedAt = time.Time{}
|
||||
raw, _ := json.Marshal(s)
|
||||
sum := sha256.Sum256(raw)
|
||||
return hex.EncodeToString(sum[:])
|
||||
}
|
||||
|
||||
// Page fetches the published page for a custom domain host, or for slug if
|
||||
// host is empty.
|
||||
func (c *Client) Page(ctx context.Context, host, slug string) (PageSnapshot, error) {
|
||||
return c.PageIfChanged(ctx, host, slug, "")
|
||||
}
|
||||
|
||||
// PageIfChanged is Page, but answers ErrNotModified instead of sending the
|
||||
// page again when it still has the checksum given.
|
||||
func (c *Client) PageIfChanged(ctx context.Context, host, slug, checksum string) (PageSnapshot, error) {
|
||||
q := url.Values{}
|
||||
if host != "" {
|
||||
q.Set("host", host)
|
||||
} else {
|
||||
q.Set("slug", slug)
|
||||
}
|
||||
var h http.Header
|
||||
if checksum != "" {
|
||||
h = http.Header{"If-None-Match": {`"` + checksum + `"`}}
|
||||
}
|
||||
var p PageSnapshot
|
||||
err := c.do(ctx, http.MethodGet, "/pages?"+q.Encode(), nil, &p)
|
||||
err := c.doWith(ctx, http.MethodGet, "/pages?"+q.Encode(), h, nil, &p)
|
||||
return p, err
|
||||
}
|
||||
@@ -41,6 +41,7 @@ func (s *Server) mountAgentAPI(r gin.IRouter) {
|
||||
g.GET("/update", s.agentUpdate)
|
||||
sp := g.Group("", requireAgentKind("statuspage"))
|
||||
sp.GET("/pages", s.agentPage)
|
||||
sp.GET("/pages/index", s.agentPageIndex)
|
||||
sp.GET("/storage", s.storageGet)
|
||||
sp.PUT("/storage", s.storagePut)
|
||||
sp.DELETE("/storage", s.storageDelete)
|
||||
|
||||
+29
-5
@@ -65,6 +65,17 @@ var endpoints = []endpoint{
|
||||
{method: "POST", path: "/api/v1/consent", tag: "Account", summary: "Accept the platform's privacy policy and terms", sessionOnly: true,
|
||||
description: "`versions` are the versions shown, e.g. `privacy:12,terms:14`; `409 consent_outdated` when a document changed meanwhile. Until an account accepted the current versions, other requests of its sessions get `403 consent_required`.",
|
||||
req: consentRequest{}, resp: obj{"redirect": ""}},
|
||||
{method: "GET", path: "/api/v1/support/tickets", tag: "Support", summary: "The account's support tickets", sessionOnly: true,
|
||||
description: "Newest activity first. Open to suspended accounts and to those that have not accepted the terms.", resp: obj{"tickets": []supportTicketView{}}},
|
||||
{method: "POST", path: "/api/v1/support/tickets", tag: "Support", summary: "Ask the platform's admins for help", sessionOnly: true,
|
||||
description: "`message` is Markdown; the admins are mailed. `attach_org` names the active organization; `monitor_id`, `channel_id`, `alert_group_id`, `status_page_id` and `incident_id` point at things in it the account can read, and name it too. `409 too_many_tickets` beyond the platform's limit of open tickets per account, `409 suspended_ticket_limit` for a second ticket of a suspended account; `403 support_disabled` while the admins switched support off.",
|
||||
req: supportTicketRequest{}, resp: supportTicketView{}, status: http.StatusCreated},
|
||||
{method: "GET", path: "/api/v1/support/tickets/:id", tag: "Support", summary: "A support ticket with its messages", sessionOnly: true,
|
||||
resp: supportTicketView{}},
|
||||
{method: "POST", path: "/api/v1/support/tickets/:id/messages", tag: "Support", summary: "Reply to a support ticket", sessionOnly: true,
|
||||
description: "Moves the ticket to `open`, also out of `closed`.", req: supportMessageRequest{}, resp: obj{"status": ""}, status: http.StatusCreated},
|
||||
{method: "PUT", path: "/api/v1/support/tickets/:id/status", tag: "Support", summary: "Close or reopen a support ticket", sessionOnly: true,
|
||||
description: "`status` is `closed` or `open`.", req: supportStatusRequest{}, status: http.StatusNoContent},
|
||||
{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,
|
||||
@@ -97,10 +108,11 @@ var endpoints = []endpoint{
|
||||
{method: "GET", path: "/api/v1/org/limits", tag: "Organization", summary: "Limits in effect for the organization and its usage",
|
||||
description: "0 means unlimited. Creating beyond a limit gives 422 monitor_limit, status_page_limit, region_limit or platform_region_limit.",
|
||||
resp: usageView{}},
|
||||
{method: "GET", path: "/api/v1/org/check-types", tag: "Monitors", summary: "Monitor types this installation offers",
|
||||
resp: obj{"types": []string{}}},
|
||||
{method: "GET", path: "/api/v1/org/check-types", tag: "Monitors", summary: "Monitor types members can create",
|
||||
description: "`own_checkers_only` are the types the platform's checkers do not run: monitors of them use the organization's own regions only, or 422 check_type_own_checkers_only.",
|
||||
resp: obj{"types": []string{}, "own_checkers_only": []string{}}},
|
||||
{method: "PUT", path: "/api/v1/org/check-types", tag: "Monitors", summary: "Choose the monitor types offered to members",
|
||||
description: "Out of the types the platform offers; types left out are not offered for new monitors or type changes, existing monitors keep running.",
|
||||
description: "Independent of the types the platform's checkers run; types left out are not offered for new monitors or type changes, existing monitors keep running.",
|
||||
perm: "org.manage", sessionOnly: true, req: checkTypesRequest{}, status: http.StatusNoContent},
|
||||
{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",
|
||||
@@ -273,14 +285,26 @@ var endpoints = []endpoint{
|
||||
// Platform
|
||||
{method: "GET", path: "/api/v1/admin/audit", tag: "Platform", summary: "Platform audit log", perm: "platform admin",
|
||||
description: "Paged, newest first.", resp: paged(obj{"events": []auditEventView{}})},
|
||||
{method: "GET", path: "/api/v1/admin/support/settings", tag: "Platform", summary: "How the platform runs support tickets", perm: "platform admin",
|
||||
resp: supportSettings{}},
|
||||
{method: "PUT", path: "/api/v1/admin/support/settings", tag: "Platform", summary: "Switch support tickets on or off and limit open tickets per account", perm: "platform admin",
|
||||
description: "`max_open_tickets` of 0 means unlimited.", req: supportSettings{}, status: http.StatusNoContent},
|
||||
{method: "GET", path: "/api/v1/admin/support/tickets", tag: "Platform", summary: "Support tickets of every account", perm: "platform admin",
|
||||
description: "`?status=open` (default), `answered`, `closed` or `all`; the latest 200, those waiting for the admins first.", resp: obj{"tickets": []supportTicketView{}}},
|
||||
{method: "GET", path: "/api/v1/admin/support/tickets/:id", tag: "Platform", summary: "A support ticket with its messages", perm: "platform admin",
|
||||
resp: supportTicketView{}},
|
||||
{method: "POST", path: "/api/v1/admin/support/tickets/:id/messages", tag: "Platform", summary: "Answer a support ticket", perm: "platform admin",
|
||||
description: "Moves the ticket to `answered` and mails the account.", req: supportMessageRequest{}, resp: obj{"status": ""}, status: http.StatusCreated},
|
||||
{method: "PUT", path: "/api/v1/admin/support/tickets/:id/status", tag: "Platform", summary: "Set a support ticket's status", perm: "platform admin",
|
||||
req: supportStatusRequest{}, status: http.StatusNoContent},
|
||||
{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/check-types", tag: "Platform", summary: "Check types and whether they are offered", perm: "platform admin",
|
||||
resp: obj{"types": []checkTypeView{}}},
|
||||
{method: "PUT", path: "/api/v1/admin/check-types", tag: "Platform", summary: "Choose the check types offered for new monitors",
|
||||
description: "Types left out are switched off: not offered for new monitors or type changes; existing monitors keep running.",
|
||||
{method: "PUT", path: "/api/v1/admin/check-types", tag: "Platform", summary: "Choose the check types the platform's checkers run",
|
||||
description: "Types left out are switched off for the platform's regions: new monitors and type changes may use them on the organizations' own regions only (passive types not at all); existing monitors keep running.",
|
||||
perm: "platform admin", req: checkTypesRequest{}, status: http.StatusNoContent},
|
||||
{method: "GET", path: "/api/v1/admin/checker-network", tag: "Platform", summary: "Whether platform checkers may check private addresses", perm: "platform admin",
|
||||
resp: checkerNetwork{}},
|
||||
|
||||
@@ -38,6 +38,12 @@ var auditActions = map[string]string{
|
||||
"POST /api/v1/auth/login/totp": "auth.login",
|
||||
"POST /api/v1/auth/logout": "auth.logout",
|
||||
"POST /api/v1/consent": "account.consent",
|
||||
"POST /api/v1/support/tickets": "support.create",
|
||||
"POST /api/v1/support/tickets/:id/messages": "support.reply",
|
||||
"PUT /api/v1/support/tickets/:id/status": "support.status",
|
||||
"POST /api/v1/admin/support/tickets/:id/messages": "support.answer",
|
||||
"PUT /api/v1/admin/support/tickets/:id/status": "support.status",
|
||||
"PUT /api/v1/admin/support/settings": "support.settings",
|
||||
"PUT /api/v1/org/members/:user/owner": "member.owner",
|
||||
"PATCH /api/v1/org/incidents/:id": "incident.title",
|
||||
"POST /api/v1/org/incidents/:id/updates": "incident.update",
|
||||
|
||||
+115
-27
@@ -8,6 +8,7 @@ import (
|
||||
"slices"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
"github.com/jackc/pgx/v5"
|
||||
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/check"
|
||||
@@ -15,10 +16,12 @@ import (
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/tenant"
|
||||
)
|
||||
|
||||
// Platform admins can switch off check types the installation cannot
|
||||
// offer, such as Docker on shared cloud checkers. Switched-off types are
|
||||
// not offered for new monitors; existing ones keep running and stay
|
||||
// editable.
|
||||
// Platform admins can switch off check types the platform's checkers
|
||||
// cannot offer, such as Docker on shared cloud checkers. That only binds
|
||||
// the platform's checkers: organizations keep such types for their own.
|
||||
// Organizations separately choose the types they offer their members.
|
||||
// Switched-off types are not offered for new monitors; existing ones keep
|
||||
// running and stay editable.
|
||||
|
||||
const settingDisabledChecks = "disabled_check_types"
|
||||
|
||||
@@ -48,34 +51,87 @@ func (s *Server) disabledChecks(ctx context.Context) map[string]bool {
|
||||
return set
|
||||
}
|
||||
|
||||
// offered reports whether org may create monitors of type t: neither the
|
||||
// platform nor the organization switched it off.
|
||||
func (s *Server) offered(ctx context.Context, org store.Org, t string) bool {
|
||||
return slices.Contains(s.enabledCheckTypes(ctx, org, ""), t)
|
||||
// checkTypeChoice is a type an organization can pick for a monitor.
|
||||
type checkTypeChoice struct {
|
||||
Type string
|
||||
// OwnOnly is set when the platform switched the type off for its
|
||||
// checkers, leaving the organization's own.
|
||||
OwnOnly bool
|
||||
}
|
||||
|
||||
// enabledCheckTypes lists the types offered to org for new monitors, plus
|
||||
// keep when a monitor of a switched-off type is being edited. The
|
||||
// organization's choice is ignored if it would leave nothing, which can
|
||||
// happen when the platform later switches off what it kept.
|
||||
func (s *Server) enabledCheckTypes(ctx context.Context, org store.Org, keep string) []string {
|
||||
// checkTypeChoices lists the types offered to org, plus keep when a
|
||||
// monitor of a switched-off type is being edited. Types the platform
|
||||
// switched off for its checkers are offered only to organizations with
|
||||
// regions of their own; passive ones, which no checker runs, not at all.
|
||||
func (s *Server) checkTypeChoices(ctx context.Context, org store.Org, keep string, ownRegions bool) []checkTypeChoice {
|
||||
off := s.disabledChecks(ctx)
|
||||
var platform, out []string
|
||||
for _, t := range check.Types {
|
||||
if off[string(t)] && string(t) != keep {
|
||||
var out, platform []checkTypeChoice
|
||||
for _, ty := range check.Types {
|
||||
t := string(ty)
|
||||
passive := check.Passive(ty)
|
||||
if off[t] && t != keep && (passive || !ownRegions) {
|
||||
continue
|
||||
}
|
||||
platform = append(platform, string(t))
|
||||
if !slices.Contains(org.DisabledCheckTypes, string(t)) || string(t) == keep {
|
||||
out = append(out, string(t))
|
||||
choice := checkTypeChoice{Type: t, OwnOnly: off[t] && !passive}
|
||||
if !off[t] || t == keep {
|
||||
platform = append(platform, choice)
|
||||
}
|
||||
if !slices.Contains(org.DisabledCheckTypes, t) || t == keep {
|
||||
out = append(out, choice)
|
||||
}
|
||||
}
|
||||
// The organization's choice can leave nothing usable when it only
|
||||
// kept types the platform's checkers no longer run.
|
||||
if len(out) == 0 {
|
||||
return platform
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
var (
|
||||
errCheckTypeDisabled = errors.New("api: check type switched off")
|
||||
errOwnCheckersOnly = errors.New("api: check type switched off for platform checkers")
|
||||
)
|
||||
|
||||
// checkTypeAllowed fails unless org may give a monitor, previously of
|
||||
// type keep in the regions previous, type t in regions; platform marks
|
||||
// the platform's regions. Monitors of a type the platform switched off
|
||||
// keep the platform regions they had but gain none.
|
||||
func (s *Server) checkTypeAllowed(ctx context.Context, org store.Org, t, keep string, regions, previous []uuid.UUID, platform map[uuid.UUID]bool) error {
|
||||
own := false
|
||||
for _, p := range platform {
|
||||
own = own || !p
|
||||
}
|
||||
choices := s.checkTypeChoices(ctx, org, keep, own)
|
||||
i := slices.IndexFunc(choices, func(c checkTypeChoice) bool { return c.Type == t })
|
||||
if i < 0 {
|
||||
return errCheckTypeDisabled
|
||||
}
|
||||
if !s.disabledChecks(ctx)[t] || check.Passive(check.Type(t)) {
|
||||
return nil
|
||||
}
|
||||
for _, r := range regions {
|
||||
if platform[r] && (t != keep || !slices.Contains(previous, r)) {
|
||||
return errOwnCheckersOnly
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// failCheckType answers a checkTypeAllowed error and reports whether it
|
||||
// did.
|
||||
func failCheckType(c *gin.Context, err error) bool {
|
||||
switch {
|
||||
case errors.Is(err, errCheckTypeDisabled):
|
||||
fail(c, http.StatusUnprocessableEntity, "check_type_disabled")
|
||||
case errors.Is(err, errOwnCheckersOnly):
|
||||
fail(c, http.StatusUnprocessableEntity, "check_type_own_checkers_only")
|
||||
default:
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
type checkTypeView struct {
|
||||
Type string `json:"type"`
|
||||
Enabled bool `json:"enabled"`
|
||||
@@ -132,13 +188,40 @@ func (s *Server) adminSetCheckTypes(c *gin.Context) {
|
||||
c.Status(http.StatusNoContent)
|
||||
}
|
||||
|
||||
// orgCheckTypes tells API clients which monitor types they can create.
|
||||
// orgCheckTypes tells API clients which monitor types they can create;
|
||||
// own_checkers_only are those the platform's checkers do not run.
|
||||
func (s *Server) orgCheckTypes(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"types": s.enabledCheckTypes(c.Request.Context(), current(c).Org, "")})
|
||||
p := current(c)
|
||||
ctx := c.Request.Context()
|
||||
own, err := s.hasOwnRegions(ctx, p)
|
||||
if err != nil {
|
||||
internalError(c, err)
|
||||
return
|
||||
}
|
||||
types, ownOnly := []string{}, []string{}
|
||||
for _, ch := range s.checkTypeChoices(ctx, p.Org, "", own) {
|
||||
types = append(types, ch.Type)
|
||||
if ch.OwnOnly {
|
||||
ownOnly = append(ownOnly, ch.Type)
|
||||
}
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"types": types, "own_checkers_only": ownOnly})
|
||||
}
|
||||
|
||||
// orgSetCheckTypes chooses which of the platform's types the organization
|
||||
// offers its members.
|
||||
func (s *Server) hasOwnRegions(ctx context.Context, p *principal) (bool, error) {
|
||||
var own bool
|
||||
err := s.db.Tx(ctx, p.scope(), func(q *store.Queries) error {
|
||||
regions, err := q.ListVisibleRegions(ctx)
|
||||
own = slices.ContainsFunc(regions, func(r store.Region) bool { return r.OrgID != nil })
|
||||
return err
|
||||
})
|
||||
return own, err
|
||||
}
|
||||
|
||||
// orgSetCheckTypes chooses which types the organization offers its
|
||||
// members, independently of what the platform's checkers run. Passive
|
||||
// types the platform switched off cannot be chosen and keep their
|
||||
// setting.
|
||||
func (s *Server) orgSetCheckTypes(c *gin.Context) {
|
||||
var req checkTypesRequest
|
||||
if !bind(c, &req) {
|
||||
@@ -149,12 +232,17 @@ func (s *Server) orgSetCheckTypes(c *gin.Context) {
|
||||
off := s.disabledChecks(ctx)
|
||||
disabled := []string{}
|
||||
enabled := 0
|
||||
for _, t := range check.Types {
|
||||
for _, ty := range check.Types {
|
||||
t := string(ty)
|
||||
switch {
|
||||
case slices.Contains(req.Enabled, string(t)):
|
||||
case off[t] && check.Passive(ty):
|
||||
if slices.Contains(p.Org.DisabledCheckTypes, t) {
|
||||
disabled = append(disabled, t)
|
||||
}
|
||||
case slices.Contains(req.Enabled, t):
|
||||
enabled++
|
||||
case !off[string(t)]:
|
||||
disabled = append(disabled, string(t))
|
||||
default:
|
||||
disabled = append(disabled, t)
|
||||
}
|
||||
}
|
||||
for _, t := range req.Enabled {
|
||||
|
||||
@@ -74,4 +74,29 @@ func TestCheckTypesCanBeSwitchedOff(t *testing.T) {
|
||||
if _, _, page := admin.page("/monitors/" + hb["id"].(string) + "/edit"); !strings.Contains(page, `value="heartbeat" selected`) {
|
||||
t.Error("editing a monitor of a switched-off type does not keep its type")
|
||||
}
|
||||
|
||||
// The switch binds the platform's checkers only: with a region of its
|
||||
// own the organization keeps the type there.
|
||||
st, own := member.do("POST", "/api/v1/org/regions", map[string]any{"key": uniq("own-"), "name": "Own"})
|
||||
if st != http.StatusCreated {
|
||||
t.Fatalf("own region = %d %v", st, own)
|
||||
}
|
||||
ownID := own["id"].(string)
|
||||
if _, types := member.do("GET", "/api/v1/org/check-types", nil); !strings.Contains(mustJSON(types["types"]), `"icmp"`) || mustJSON(types["own_checkers_only"]) != `["icmp"]` {
|
||||
t.Errorf("offered types with an own region = %v", types)
|
||||
}
|
||||
if _, _, page := member.page("/monitors/new"); !strings.Contains(page, `value="icmp"`) || !strings.Contains(page, "own checkers only") {
|
||||
t.Error("the editor does not offer the type for own checkers")
|
||||
}
|
||||
st, body = member.do("POST", "/api/v1/org/monitors", map[string]any{"name": "Ping", "type": "icmp", "target": "example.com", "interval_seconds": 60, "regions": []string{ownID, region}})
|
||||
expect(t, "switched-off type on a platform region", st, body, http.StatusUnprocessableEntity, "check_type_own_checkers_only")
|
||||
st, ping := member.do("POST", "/api/v1/org/monitors", map[string]any{"name": "Ping", "type": "icmp", "target": "example.com", "interval_seconds": 60, "regions": []string{ownID}})
|
||||
expect(t, "switched-off type on an own region", st, ping, http.StatusCreated, "")
|
||||
st, body = member.do("PUT", "/api/v1/org/monitors/"+ping["id"].(string), map[string]any{"name": "Ping", "type": "icmp", "target": "example.com", "interval_seconds": 60, "regions": []string{ownID, region}})
|
||||
expect(t, "adding a platform region", st, body, http.StatusUnprocessableEntity, "check_type_own_checkers_only")
|
||||
st, body = member.do("POST", "/api/v1/org/monitors", map[string]any{"name": "Cron", "type": "heartbeat", "interval_seconds": 3600})
|
||||
expect(t, "switched-off passive type", st, body, http.StatusUnprocessableEntity, "check_type_disabled")
|
||||
if _, _, page := member.page("/settings/org"); !strings.Contains(page, `value="icmp"`) || strings.Contains(page, `value="heartbeat"`) {
|
||||
t.Error("the organization settings do not offer the types for own checkers")
|
||||
}
|
||||
}
|
||||
@@ -132,11 +132,13 @@ func (s *Server) accessOf(ctx context.Context, user uuid.UUID) (access, error) {
|
||||
}
|
||||
|
||||
// restrictedPaths stay open to accounts that are suspended or have yet to
|
||||
// accept the documents. Admins keep editing the documents, which they may
|
||||
// be publishing one after the other; the handlers still check they are.
|
||||
// accept the documents, support included: a suspended account may want to
|
||||
// ask why. Admins keep editing the documents, which they may be publishing
|
||||
// one after the other; the handlers still check they are.
|
||||
var restrictedPaths = []string{
|
||||
"/consent", "/account/suspended", "/legal/",
|
||||
"/api/v1/auth/", "/api/v1/consent", "/api/v1/me/export", "/api/v1/me/delete", "/api/v1/locale",
|
||||
"/support", "/support/", "/api/v1/support/",
|
||||
"/admin/legal", "/api/v1/admin/legal/",
|
||||
}
|
||||
|
||||
@@ -249,6 +251,7 @@ func (s *Server) restrictedMe(c *gin.Context, sess *auth.Session) (web.Me, error
|
||||
return web.Me{}, err
|
||||
}
|
||||
me := toWebMe(m)
|
||||
me.Support = s.supportSettings(c.Request.Context()).Enabled
|
||||
me.DeletesOrgs, err = s.lastOwnedOrgs(c.Request.Context(), sess.UserID)
|
||||
return me, err
|
||||
}
|
||||
|
||||
@@ -48,6 +48,9 @@ func TestConsent(t *testing.T) {
|
||||
if !strings.Contains(versions, "privacy:") || !strings.Contains(versions, "terms:") || !strings.Contains(form, `name="consent" required`) {
|
||||
t.Fatalf("sign-up form lacks the consent box: versions %q", versions)
|
||||
}
|
||||
if !strings.Contains(form, "</a> and the <a") {
|
||||
t.Error("the consent text runs the documents' names into the words between them")
|
||||
}
|
||||
signup := func(consent bool, versions string) (int, map[string]any) {
|
||||
return e.browser(t).do("POST", "/api/v1/auth/signup", map[string]any{
|
||||
"email": uniq("n") + "@example.test", "password": password, "consent": consent, "consent_versions": versions,
|
||||
|
||||
+61
-10
@@ -21,6 +21,7 @@ import (
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/auth"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/authz"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/check"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/evaluate"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/i18n"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/maintenance"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/notify"
|
||||
@@ -91,7 +92,14 @@ func (s *Server) dashboard(c *gin.Context) {
|
||||
v.Ranges = rangeOptions(c, data.rng, earliest, data.now)
|
||||
for _, m := range data.rows {
|
||||
v.Counts[m.Status]++
|
||||
if m.Unchecked {
|
||||
v.Unchecked++
|
||||
}
|
||||
}
|
||||
for id, since := range s.regionsWithoutChecker(c.Request.Context(), data.usedRegions) {
|
||||
v.DeadRegions = append(v.DeadRegions, web.DeadRegion{Name: data.regionOf[id].Name, Since: since.Local().Format("2006-01-02 15:04")})
|
||||
}
|
||||
slices.SortFunc(v.DeadRegions, func(a, b web.DeadRegion) int { return strings.Compare(a.Name, b.Name) })
|
||||
}
|
||||
web.Render(c, http.StatusOK, web.Dashboard(s.pageFor(c, "console.monitors.title"), me, v))
|
||||
}
|
||||
@@ -214,6 +222,8 @@ type monitorData struct {
|
||||
firstRegion map[uuid.UUID]map[string]time.Time
|
||||
// statuses are the organization's own incident statuses.
|
||||
statuses customStatuses
|
||||
// usedRegions are the regions the enabled monitors are checked from.
|
||||
usedRegions []uuid.UUID
|
||||
}
|
||||
|
||||
// loadFirstData finds when monitors and their regions first reported. The
|
||||
@@ -366,6 +376,13 @@ func (s *Server) loadMonitorData(ctx context.Context, p *principal, rng web.Time
|
||||
for _, a := range assigned {
|
||||
regionsOf[a.MonitorID] = append(regionsOf[a.MonitorID], a.RegionID)
|
||||
}
|
||||
for _, m := range monitors {
|
||||
if m.Enabled {
|
||||
d.usedRegions = append(d.usedRegions, regionsOf[m.ID]...)
|
||||
}
|
||||
}
|
||||
slices.SortFunc(d.usedRegions, func(a, b uuid.UUID) int { return strings.Compare(a.String(), b.String()) })
|
||||
d.usedRegions = slices.Compact(d.usedRegions)
|
||||
latestOf := map[uuid.UUID]map[string]store.LatestResultsRow{}
|
||||
for _, l := range latest {
|
||||
if latestOf[l.MonitorID] == nil {
|
||||
@@ -393,9 +410,18 @@ func (s *Server) loadMonitorData(ctx context.Context, p *principal, rng web.Time
|
||||
}
|
||||
var latencies []int32
|
||||
failing, reported := 0, 0
|
||||
// A region that has not reported for longer than the evaluator
|
||||
// waits is unknown, whatever its last result said; passive monitors
|
||||
// judge their own lateness.
|
||||
staleBefore := now.Add(-evaluate.StaleAfter(time.Duration(m.IntervalSeconds) * time.Second))
|
||||
for _, key := range keys {
|
||||
rs := web.RegionStatus{Name: d.regionNameString(key), Status: web.StatusUnknown, Detail: "–"}
|
||||
if l, ok := latestOf[m.ID][key]; ok {
|
||||
l, ok := latestOf[m.ID][key]
|
||||
if ok && !check.Passive(check.Type(m.Type)) && l.Time.Before(staleBefore) {
|
||||
rs.Detail = i18n.T(ctx, "monitors.no_data_since", "Time", l.Time.Format("15:04"))
|
||||
ok = false
|
||||
}
|
||||
if ok {
|
||||
reported++
|
||||
rs.Detail = l.Time.Format("15:04:05")
|
||||
if l.Ok {
|
||||
@@ -421,6 +447,8 @@ func (s *Server) loadMonitorData(ctx context.Context, p *principal, rng web.Time
|
||||
row.Status = web.StatusDown
|
||||
case reported == 0:
|
||||
row.Status = web.StatusUnknown
|
||||
// Nobody is checking it, unless it is too new to have results.
|
||||
row.Unchecked = !check.Passive(check.Type(m.Type)) && m.CreatedAt.Before(staleBefore)
|
||||
case failing > 0:
|
||||
row.Status = web.StatusDegraded
|
||||
default:
|
||||
@@ -674,9 +702,16 @@ func (s *Server) monitorEditor(c *gin.Context, p *principal, page web.Page, me w
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
f.Types = s.enabledCheckTypes(ctx, p.Org, f.Type)
|
||||
if !slices.Contains(f.Types, f.Type) {
|
||||
f.Type = f.Types[0]
|
||||
keep := ""
|
||||
if idParam != "" {
|
||||
keep = f.Type
|
||||
}
|
||||
own := slices.ContainsFunc(regions, func(r store.Region) bool { return r.OrgID != nil })
|
||||
for _, ch := range s.checkTypeChoices(ctx, p.Org, keep, own) {
|
||||
f.Types = append(f.Types, web.TypeOption{Type: ch.Type, OwnOnly: ch.OwnOnly})
|
||||
}
|
||||
if !slices.ContainsFunc(f.Types, func(t web.TypeOption) bool { return t.Type == f.Type }) {
|
||||
f.Type = f.Types[0].Type
|
||||
}
|
||||
for i, r := range regions {
|
||||
live, err := s.sched.Instances(ctx, r.ID.String())
|
||||
@@ -1009,19 +1044,31 @@ func (s *Server) channelsView(c *gin.Context, p *principal, page web.Page, me we
|
||||
return web.ChannelsPage(page, me, v), nil
|
||||
}
|
||||
|
||||
func (s *Server) pageURL(p store.StatusPage) string {
|
||||
// pageURL is where p is reachable, or empty when only the organization's
|
||||
// own status page servers serve it, at an address the platform does not
|
||||
// know.
|
||||
func (s *Server) pageURL(p store.StatusPage, ownServers bool) string {
|
||||
if p.CustomDomain != nil && p.DomainVerifiedAt != nil {
|
||||
return "https://" + *p.CustomDomain + "/"
|
||||
}
|
||||
if ownServers {
|
||||
return ""
|
||||
}
|
||||
return strings.TrimSuffix(s.cfg.StatusPageURL, "/") + "/" + p.Slug
|
||||
}
|
||||
|
||||
func (s *Server) statusPagesView(c *gin.Context, p *principal, page web.Page, me web.Me) (templ.Component, error) {
|
||||
ctx := c.Request.Context()
|
||||
var rows []store.StatusPage
|
||||
var (
|
||||
rows []store.StatusPage
|
||||
own bool
|
||||
)
|
||||
err := s.db.Tx(ctx, p.scope(), func(q *store.Queries) error {
|
||||
var err error
|
||||
rows, err = q.ListStatusPages(ctx)
|
||||
if rows, err = q.ListStatusPages(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
own, err = q.OrgServesOwnPages(ctx, &p.Org.ID)
|
||||
return err
|
||||
})
|
||||
if err != nil {
|
||||
@@ -1034,7 +1081,7 @@ func (s *Server) statusPagesView(c *gin.Context, p *principal, page web.Page, me
|
||||
}
|
||||
v.Pages = append(v.Pages, web.PageRow{
|
||||
ID: r.ID.String(), Title: r.Title, Slug: r.Slug, Published: r.Published,
|
||||
URL: s.pageURL(r), Domain: deref(r.CustomDomain), Suspended: r.SuspendedAt != nil,
|
||||
URL: s.pageURL(r, own), Domain: deref(r.CustomDomain), Suspended: r.SuspendedAt != nil,
|
||||
})
|
||||
}
|
||||
return web.StatusPagesPage(page, me, v), nil
|
||||
@@ -1052,6 +1099,7 @@ func (s *Server) statusPageEditor(c *gin.Context, p *principal, page web.Page, m
|
||||
pageGroups []store.StatusPageGroup
|
||||
orgGroups []store.MonitorGroup
|
||||
monitors []store.Monitor
|
||||
own bool
|
||||
)
|
||||
err = s.db.Tx(ctx, p.scope(), func(q *store.Queries) error {
|
||||
var err error
|
||||
@@ -1067,7 +1115,10 @@ func (s *Server) statusPageEditor(c *gin.Context, p *principal, page web.Page, m
|
||||
if orgGroups, err = q.ListGroups(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
monitors, err = q.ListMonitors(ctx)
|
||||
if monitors, err = q.ListMonitors(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
own, err = q.OrgServesOwnPages(ctx, &p.Org.ID)
|
||||
return err
|
||||
})
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
@@ -1082,7 +1133,7 @@ func (s *Server) statusPageEditor(c *gin.Context, p *principal, page web.Page, m
|
||||
Published: row.Published, ShowDetails: row.ShowComponentDetails,
|
||||
Suspended: row.SuspendedAt != nil, SuspendedReason: row.SuspendedReason,
|
||||
Accent: v.Theme.Accent, LogoURL: v.Theme.LogoURL, CSS: v.Theme.CSS,
|
||||
URL: s.pageURL(row), Domain: deref(row.CustomDomain), DomainVerified: v.DomainVerified,
|
||||
URL: s.pageURL(row, own), OwnServers: own, Domain: deref(row.CustomDomain), DomainVerified: v.DomainVerified,
|
||||
HasOrgGroups: len(orgGroups) > 0,
|
||||
}
|
||||
if v.DomainRecord != nil {
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// LookupTXT lets tests replace DNS lookups for domain verification.
|
||||
var LookupTXT = &lookupTXT
|
||||
|
||||
@@ -17,3 +24,9 @@ func DocumentedRoutes() []string {
|
||||
|
||||
// OpenAPI builds the OpenAPI document.
|
||||
func OpenAPI() map[string]any { return buildOpenAPI("https://uptime.example") }
|
||||
|
||||
// WatchRegionsOf runs the region watch for the regions given only, so
|
||||
// tests are not slowed down by the regions other tests left behind.
|
||||
func (s *Server) WatchRegionsOf(ctx context.Context, now time.Time, ids ...uuid.UUID) error {
|
||||
return s.watchRegions(ctx, now, ids)
|
||||
}
|
||||
@@ -32,9 +32,24 @@ type accountExport struct {
|
||||
Identities []exportIdentity `json:"sso_identities"`
|
||||
Tokens []exportToken `json:"api_tokens"`
|
||||
Consents []exportConsent `json:"consents"`
|
||||
Support []exportTicket `json:"support_tickets"`
|
||||
Activity []exportActivity `json:"activity"`
|
||||
}
|
||||
|
||||
type exportTicket struct {
|
||||
Subject string `json:"subject"`
|
||||
Status string `json:"status"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Messages []exportTicketMessage `json:"messages"`
|
||||
}
|
||||
|
||||
// exportTicketMessage leaves out which admin answered: that is about them.
|
||||
type exportTicketMessage struct {
|
||||
Time time.Time `json:"time"`
|
||||
FromStaff bool `json:"from_staff"`
|
||||
Body string `json:"body"`
|
||||
}
|
||||
|
||||
// exportConsent is an accepted version of the privacy policy or terms.
|
||||
type exportConsent struct {
|
||||
Kind string `json:"kind"`
|
||||
@@ -156,6 +171,22 @@ func (s *Server) buildAccountExport(ctx context.Context, userID uuid.UUID) (acco
|
||||
ExpiresAt: t.ExpiresAt, LastUsedAt: t.LastUsedAt, CreatedAt: t.CreatedAt,
|
||||
})
|
||||
}
|
||||
tickets, err := q.ListUserSupportTickets(ctx, userID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
x.Support = []exportTicket{}
|
||||
for _, t := range tickets {
|
||||
msgs, err := q.SupportMessages(ctx, t.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
et := exportTicket{Subject: t.Subject, Status: t.Status, CreatedAt: t.CreatedAt, Messages: []exportTicketMessage{}}
|
||||
for _, m := range msgs {
|
||||
et.Messages = append(et.Messages, exportTicketMessage{Time: m.CreatedAt, FromStaff: m.FromStaff, Body: m.Body})
|
||||
}
|
||||
x.Support = append(x.Support, et)
|
||||
}
|
||||
events, err := q.UserAuditEvents(ctx, &userID)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -280,8 +280,7 @@ func (s *Server) createMonitor(c *gin.Context) {
|
||||
if !s.validateMonitor(c, &req, t) {
|
||||
return
|
||||
}
|
||||
if !s.offered(ctx, p.Org, req.Type) {
|
||||
fail(c, http.StatusUnprocessableEntity, "check_type_disabled")
|
||||
if failCheckType(c, s.checkTypeAllowed(ctx, p.Org, req.Type, "", req.Regions, nil, req.platform)) {
|
||||
return
|
||||
}
|
||||
req.Target = passiveTarget(check.Type(req.Type), req.Target)
|
||||
@@ -403,8 +402,8 @@ func (s *Server) updateMonitor(c *gin.Context) {
|
||||
if previous, err = q.MonitorRegions(ctx, id); err != nil {
|
||||
return err
|
||||
}
|
||||
if old.Type != req.Type && !s.offered(ctx, p.Org, req.Type) {
|
||||
return errCheckTypeDisabled
|
||||
if err := s.checkTypeAllowed(ctx, p.Org, req.Type, old.Type, req.Regions, previous, req.platform); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := checkRegions(s.orgLimits(ctx, p.Org), req.Regions, previous, req.platform); err != nil {
|
||||
return err
|
||||
@@ -443,8 +442,7 @@ func (s *Server) updateMonitor(c *gin.Context) {
|
||||
fail(c, http.StatusUnprocessableEntity, "invalid_alert_group")
|
||||
return
|
||||
}
|
||||
if errors.Is(err, errCheckTypeDisabled) {
|
||||
fail(c, http.StatusUnprocessableEntity, "check_type_disabled")
|
||||
if failCheckType(c, err) {
|
||||
return
|
||||
}
|
||||
if failLimit(c, err) {
|
||||
@@ -611,5 +609,3 @@ func passiveRegion(t check.Type) string {
|
||||
}
|
||||
return heartbeatRegion
|
||||
}
|
||||
|
||||
var errCheckTypeDisabled = errors.New("api: check type switched off")
|
||||
+12
-2
@@ -46,6 +46,10 @@ func (s *Server) registerPages(r gin.IRouter) {
|
||||
r.GET("/admin/status-pages", s.adminStatusPagesPage)
|
||||
r.GET("/admin/orgs", s.adminOrgsPage)
|
||||
r.GET("/admin/legal", s.adminLegalPage)
|
||||
r.GET("/admin/support", s.adminSupportPage)
|
||||
r.GET("/admin/support/:id", s.adminSupportTicketPage)
|
||||
r.GET("/support", s.supportPage)
|
||||
r.GET("/support/:id", s.supportTicketPage)
|
||||
r.GET("/settings/legal", s.orgPage("legal.org_title", authz.OrgManage, s.orgLegalView))
|
||||
r.GET("/incidents/:id", s.orgPage("incidents.title", authz.IncidentsRead, s.incidentDetailView))
|
||||
r.GET("/settings/incident-statuses", s.orgPage("incident_statuses.title", authz.IncidentsRead, s.incidentStatusesView))
|
||||
@@ -176,6 +180,7 @@ func (s *Server) consoleMe(c *gin.Context, sess *auth.Session) (web.Me, *princip
|
||||
}
|
||||
me := toWebMe(m)
|
||||
me.Can = map[string]bool{}
|
||||
me.Support = s.supportSettings(ctx).Enabled
|
||||
if sess.OrgID == uuid.Nil {
|
||||
return me, nil, nil
|
||||
}
|
||||
@@ -378,9 +383,14 @@ func (s *Server) orgSettingsView(c *gin.Context, p *principal, page web.Page, me
|
||||
v.Usage = web.UsageView{Limits: webLimits(u.Limits), Monitors: u.Usage.Monitors, StatusPages: u.Usage.StatusPages}
|
||||
off := s.disabledChecks(c.Request.Context())
|
||||
for _, t := range check.Types {
|
||||
if !off[string(t)] {
|
||||
v.CheckTypes = append(v.CheckTypes, web.CheckTypeOption{Type: string(t), Enabled: !slices.Contains(p.Org.DisabledCheckTypes, string(t))})
|
||||
o := web.CheckTypeOption{Type: string(t), Enabled: !slices.Contains(p.Org.DisabledCheckTypes, string(t))}
|
||||
if off[string(t)] {
|
||||
if check.Passive(t) {
|
||||
continue
|
||||
}
|
||||
o.Note = "org.check_type_own_only"
|
||||
}
|
||||
v.CheckTypes = append(v.CheckTypes, o)
|
||||
}
|
||||
if p.Org.ApiTokenMaxDays != nil {
|
||||
v.TokenMaxDays = int(*p.Org.ApiTokenMaxDays)
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"slices"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/redis/go-redis/v9"
|
||||
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/notify"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/store"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/tenant"
|
||||
)
|
||||
|
||||
// A region whose checkers have all gone leaves its monitors unchecked:
|
||||
// they neither go down nor alert. The region watch tells those who run the
|
||||
// region, the platform's admins for platform regions and the owners for an
|
||||
// organization's own, once it has had no live checker for
|
||||
// UPTIME_REGION_ALERT_AFTER, and again when one is back. Every replica runs
|
||||
// it; Redis decides which one sends.
|
||||
|
||||
const (
|
||||
regionWatchEvery = 30 * time.Second
|
||||
// regionWatchTTL bounds the state of a region; one dead for longer is
|
||||
// announced again.
|
||||
regionWatchTTL = 30 * 24 * time.Hour
|
||||
)
|
||||
|
||||
func keyRegionDeadSince(id uuid.UUID) string { return "regionwatch:since:" + id.String() }
|
||||
func keyRegionAlerted(id uuid.UUID) string { return "regionwatch:alerted:" + id.String() }
|
||||
|
||||
// RunRegionWatch watches the regions until ctx ends.
|
||||
func (s *Server) RunRegionWatch(ctx context.Context) {
|
||||
if s.cfg.RegionAlertAfter <= 0 {
|
||||
return
|
||||
}
|
||||
tick := time.NewTicker(regionWatchEvery)
|
||||
defer tick.Stop()
|
||||
for {
|
||||
if err := s.WatchRegions(ctx, time.Now()); err != nil && ctx.Err() == nil {
|
||||
s.log.WarnContext(ctx, "watching regions failed", "error", err)
|
||||
}
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-tick.C:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WatchRegions checks every region with checkers and enabled monitors once.
|
||||
func (s *Server) WatchRegions(ctx context.Context, now time.Time) error {
|
||||
return s.watchRegions(ctx, now, nil)
|
||||
}
|
||||
|
||||
// watchRegions is WatchRegions limited to only, unless only is nil.
|
||||
func (s *Server) watchRegions(ctx context.Context, now time.Time, only []uuid.UUID) error {
|
||||
var regions []store.RegionsToWatchRow
|
||||
if err := s.db.Tx(ctx, tenant.System(), func(q *store.Queries) error {
|
||||
var err error
|
||||
regions, err = q.RegionsToWatch(ctx)
|
||||
return err
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, r := range regions {
|
||||
if only != nil && !slices.Contains(only, r.ID) {
|
||||
continue
|
||||
}
|
||||
live, err := s.sched.Instances(ctx, r.ID.String())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if live > 0 {
|
||||
since, _ := s.rdb.GetDel(ctx, keyRegionDeadSince(r.ID)).Time()
|
||||
// Only the replica that clears the alert announces the return.
|
||||
if n, err := s.rdb.Del(ctx, keyRegionAlerted(r.ID)).Result(); err == nil && n > 0 {
|
||||
s.mailRegion(ctx, r, since, now, false)
|
||||
}
|
||||
continue
|
||||
}
|
||||
if err := s.rdb.SetNX(ctx, keyRegionDeadSince(r.ID), now, regionWatchTTL).Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
since, err := s.rdb.Get(ctx, keyRegionDeadSince(r.ID)).Time()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if now.Sub(since) < s.cfg.RegionAlertAfter {
|
||||
continue
|
||||
}
|
||||
if first, err := s.rdb.SetNX(ctx, keyRegionAlerted(r.ID), 1, regionWatchTTL).Result(); err == nil && first {
|
||||
if !s.mailRegion(ctx, r, since, now, true) {
|
||||
// Tried again on the next round.
|
||||
s.rdb.Del(ctx, keyRegionAlerted(r.ID))
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// regionsWithoutChecker returns since when each of ids has had no live
|
||||
// checker, for those the watch found without one.
|
||||
func (s *Server) regionsWithoutChecker(ctx context.Context, ids []uuid.UUID) map[uuid.UUID]time.Time {
|
||||
out := map[uuid.UUID]time.Time{}
|
||||
for _, id := range ids {
|
||||
since, err := s.rdb.Get(ctx, keyRegionDeadSince(id)).Time()
|
||||
if err == nil {
|
||||
out[id] = since
|
||||
} else if !errors.Is(err, redis.Nil) {
|
||||
s.log.WarnContext(ctx, "reading region watch failed", "region", id, "error", err)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// mailRegion tells the admins or the owners that r has no live checker
|
||||
// since since, or, when down is false, that it has one again. It reports
|
||||
// false if the mail could not be sent and should be tried again.
|
||||
func (s *Server) mailRegion(ctx context.Context, r store.RegionsToWatchRow, since, now time.Time, down bool) bool {
|
||||
if s.smtp == nil {
|
||||
return true
|
||||
}
|
||||
var to []string
|
||||
link := "/admin"
|
||||
err := s.db.Tx(ctx, tenant.System(), func(q *store.Queries) error {
|
||||
var err error
|
||||
if r.OrgID == nil {
|
||||
to, err = q.AdminEmails(ctx)
|
||||
} else {
|
||||
link = "/settings/regions"
|
||||
to, err = q.OrgOwnerEmails(ctx, *r.OrgID)
|
||||
}
|
||||
return err
|
||||
})
|
||||
if err != nil || len(to) == 0 {
|
||||
if err != nil {
|
||||
s.log.WarnContext(ctx, "finding whom to tell about a region failed", "region", r.ID, "error", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
l := s.catalog.Match("")
|
||||
data := map[string]any{
|
||||
"Region": r.Name, "Org": deref(r.OrgName), "Link": s.ticketLink(link),
|
||||
"Since": since.UTC().Format("2006-01-02 15:04 MST"),
|
||||
"Minutes": int(now.Sub(since).Minutes()),
|
||||
}
|
||||
kind := "email.region_back"
|
||||
if down {
|
||||
kind = "email.region_down"
|
||||
}
|
||||
if since.IsZero() {
|
||||
data["Since"], data["Minutes"] = "–", 0
|
||||
}
|
||||
if err := s.smtp.Send(ctx, notify.Mail{To: to, Subject: l.T(kind+".subject", data), Body: l.T(kind+".body", data)}); err != nil {
|
||||
s.log.WarnContext(ctx, "mail about a region failed", "region", r.ID, "error", err)
|
||||
return false
|
||||
}
|
||||
s.log.InfoContext(ctx, "told about a region", "region", r.ID, "down", down, "recipients", len(to))
|
||||
return true
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
package api_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/jackc/pgx/v5"
|
||||
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/agentapi"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/config"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/notify/notifytest"
|
||||
)
|
||||
|
||||
func TestUncheckedMonitorsAndRegionsWithoutChecker(t *testing.T) {
|
||||
mail := notifytest.NewSMTP(t)
|
||||
e := newEnvWith(t, func(c *config.API) {
|
||||
c.SMTPURL, c.SignupVerify, c.RegionAlertAfter = mail.URL(), "off", 3*time.Minute
|
||||
})
|
||||
ctx := context.Background()
|
||||
owner := e.browser(t)
|
||||
ownerEmail := "o@" + uniq("rw") + ".test"
|
||||
owner.signup(ownerEmail, uniq("rw-"))
|
||||
// An organization's own region: its owners hear about it.
|
||||
regionName := uniq("Office ")
|
||||
_, reg := owner.do("POST", "/api/v1/org/regions", map[string]any{"key": uniq("office-"), "name": regionName})
|
||||
region := reg["id"].(string)
|
||||
regionID := uuid.MustParse(region)
|
||||
st, agent := owner.do("POST", "/api/v1/org/agents", map[string]any{"kind": "checker", "name": "office-1", "region_id": region})
|
||||
if st != http.StatusCreated {
|
||||
t.Fatalf("create agent = %d %v", st, agent)
|
||||
}
|
||||
tok := agent["token"].(string)
|
||||
mailed := func(to, want string) {
|
||||
t.Helper()
|
||||
waitFor(t, 5*time.Second, "a mail saying "+want, func() bool {
|
||||
for _, m := range mail.Messages() {
|
||||
if strings.Contains(strings.Join(m.To, ","), to) && strings.Contains(m.Data, want) && strings.Contains(m.Data, regionName) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
// A monitor whose only region last reported ten minutes ago is not
|
||||
// up: nobody is checking it.
|
||||
_, mon := owner.do("POST", "/api/v1/org/monitors", map[string]any{"name": "Shop", "type": "http", "target": "https://example.test", "interval_seconds": 60, "regions": []string{region}})
|
||||
id := mon["id"].(string)
|
||||
org := uuid.MustParse(owner.orgID())
|
||||
if err := e.asSystem(t, func(tx pgx.Tx) error {
|
||||
if _, err := tx.Exec(ctx, `UPDATE monitors SET created_at = now() - interval '1 hour' WHERE id = $1`, id); err != nil {
|
||||
return err
|
||||
}
|
||||
_, err := tx.Exec(ctx, `INSERT INTO check_results (time, org_id, monitor_id, region, checker_id, ok, latency_ms) VALUES (now() - interval '10 minutes', $1, $2, $3, $4, true, 10)`,
|
||||
org, id, region, uuid.New())
|
||||
return err
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_, _, dash := owner.page("/")
|
||||
for _, want := range []string{"not being checked", "1 monitor is not being checked"} {
|
||||
if !strings.Contains(dash, want) {
|
||||
t.Errorf("dashboard lacks %q", want)
|
||||
}
|
||||
}
|
||||
if _, _, detail := owner.page("/monitors/" + id); !strings.Contains(detail, "no data since") || !strings.Contains(detail, "1 monitor is not being checked") {
|
||||
t.Error("the monitor page does not say the region has no recent data")
|
||||
}
|
||||
|
||||
// On a status page it shows as unknown, not as operational.
|
||||
slug := uniq("rw-")
|
||||
_, page := owner.do("POST", "/api/v1/org/statuspages", map[string]any{"slug": slug, "title": "Shop status"})
|
||||
owner.do("PUT", "/api/v1/org/statuspages/"+page["id"].(string)+"/monitors", map[string]any{"monitors": []map[string]any{{"monitor_id": id}}})
|
||||
owner.do("PUT", "/api/v1/org/statuspages/"+page["id"].(string), map[string]any{"slug": slug, "title": "Shop status", "published": true})
|
||||
snap, err := e.statuspageClient(t, &org).Page(ctx, "", slug)
|
||||
if err != nil || len(snap.Sections) != 1 || snap.Sections[0].Components[0].Status != agentapi.PageUnknown {
|
||||
t.Errorf("status page = %+v, %v; want the component unknown", snap.Sections, err)
|
||||
}
|
||||
|
||||
// The region has a checker but no live instance: the watch notes it at
|
||||
// once and tells the owners once it has lasted.
|
||||
now := time.Now()
|
||||
if err := e.api.WatchRegionsOf(ctx, now, regionID); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, _, dash := owner.page("/"); !strings.Contains(dash, "Region "+regionName+" has had no active checker since") {
|
||||
t.Error("the dashboard does not name the region without a checker")
|
||||
}
|
||||
if err := e.api.WatchRegionsOf(ctx, now.Add(5*time.Minute), regionID); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
mailed(ownerEmail, "has no active checker")
|
||||
sent := len(mail.Messages())
|
||||
if err := e.api.WatchRegionsOf(ctx, now.Add(10*time.Minute), regionID); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
if n := countMails(mail.Messages()[sent:], regionName); n != 0 {
|
||||
t.Errorf("the region was announced %d more times", n)
|
||||
}
|
||||
|
||||
// A checker coming back is announced too.
|
||||
e.startChecker(t, tok)
|
||||
waitFor(t, 15*time.Second, "the checker to count as live", func() bool {
|
||||
_ = e.api.WatchRegionsOf(ctx, time.Now(), regionID)
|
||||
for _, m := range mail.Messages() {
|
||||
if strings.Contains(m.Data, "is checking again") && strings.Contains(m.Data, regionName) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
})
|
||||
if _, _, dash := owner.page("/"); strings.Contains(dash, "Region "+regionName+" has had no active checker") {
|
||||
t.Error("the dashboard still names the region")
|
||||
}
|
||||
}
|
||||
|
||||
func countMails(ms []notifytest.Message, about string) int {
|
||||
n := 0
|
||||
for _, m := range ms {
|
||||
if strings.Contains(m.Data, about) {
|
||||
n++
|
||||
}
|
||||
}
|
||||
return n
|
||||
}
|
||||
@@ -53,6 +53,8 @@ type Server struct {
|
||||
checkerNet *versioned[bool]
|
||||
// limits caches the platform's default limits.
|
||||
limits *versioned[Limits]
|
||||
// support caches how the platform runs support tickets.
|
||||
support *versioned[supportSettings]
|
||||
}
|
||||
|
||||
// Deps are the external resources a Server needs.
|
||||
@@ -88,6 +90,7 @@ func New(cfg config.API, d Deps) *Server {
|
||||
checkTypes: newVersioned[map[string]bool]("check-types"),
|
||||
checkerNet: newVersioned[bool]("checker-network"),
|
||||
limits: newVersioned[Limits]("limits"),
|
||||
support: newVersioned[supportSettings]("support"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,6 +135,13 @@ func (s *Server) Mount(r gin.IRouter) {
|
||||
me.GET("/export", s.exportAccount)
|
||||
me.POST("/delete", s.deleteAccount)
|
||||
|
||||
support := v1.Group("/support", auth.Require(), s.requireSupport())
|
||||
support.GET("/tickets", s.listMyTickets)
|
||||
support.POST("/tickets", s.createTicket)
|
||||
support.GET("/tickets/:id", s.getMyTicket)
|
||||
support.POST("/tickets/:id/messages", s.replyMyTicket)
|
||||
support.PUT("/tickets/:id/status", s.setMyTicketStatus)
|
||||
|
||||
v1.POST("/invitations/:token/accept", auth.Require(), s.acceptInvitation)
|
||||
v1.POST("/invitations/:token/signup", s.inviteSignup)
|
||||
|
||||
@@ -203,6 +213,12 @@ func (s *Server) Mount(r gin.IRouter) {
|
||||
admin.GET("/regions", s.adminListRegions)
|
||||
admin.POST("/regions", s.adminCreateRegion)
|
||||
admin.DELETE("/regions/:id", s.adminDeleteRegion)
|
||||
admin.GET("/support/settings", s.adminGetSupportSettings)
|
||||
admin.PUT("/support/settings", s.adminSetSupportSettings)
|
||||
admin.GET("/support/tickets", s.adminListTickets)
|
||||
admin.GET("/support/tickets/:id", s.adminGetTicket)
|
||||
admin.POST("/support/tickets/:id/messages", s.adminReplyTicket)
|
||||
admin.PUT("/support/tickets/:id/status", s.adminSetTicketStatus)
|
||||
admin.GET("/agents", s.adminListAgents)
|
||||
admin.POST("/agents", s.adminCreateAgent)
|
||||
admin.DELETE("/agents/:id", s.adminDeleteAgent)
|
||||
|
||||
@@ -22,6 +22,8 @@ import (
|
||||
|
||||
"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/check"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/evaluate"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/store"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/tenant"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/web"
|
||||
@@ -127,7 +129,18 @@ func (s *Server) buildSnapshot(ctx context.Context, page store.StatusPage) (agen
|
||||
failing := map[uuid.UUID]int{}
|
||||
reported := map[uuid.UUID]int{}
|
||||
latestByMonitor := map[uuid.UUID][]store.LatestResultsRow{}
|
||||
// A region that has not reported for longer than the evaluator waits
|
||||
// is unknown, whatever its last result said.
|
||||
staleBefore := map[uuid.UUID]time.Time{}
|
||||
for _, m := range listed {
|
||||
if !check.Passive(check.Type(m.MonitorType)) {
|
||||
staleBefore[m.MonitorID] = now.Add(-evaluate.StaleAfter(time.Duration(m.IntervalSeconds) * time.Second))
|
||||
}
|
||||
}
|
||||
for _, l := range latest {
|
||||
if cut, ok := staleBefore[l.MonitorID]; ok && l.Time.Before(cut) {
|
||||
continue
|
||||
}
|
||||
reported[l.MonitorID]++
|
||||
if !l.Ok {
|
||||
failing[l.MonitorID]++
|
||||
@@ -346,14 +359,22 @@ func (s *Server) agentPage(c *gin.Context) {
|
||||
fail(c, http.StatusBadRequest, "invalid_input")
|
||||
return
|
||||
}
|
||||
var page store.StatusPage
|
||||
var (
|
||||
page store.StatusPage
|
||||
own bool
|
||||
)
|
||||
a := agentOf(c)
|
||||
err := s.db.Tx(ctx, tenant.System(), func(q *store.Queries) error {
|
||||
var err error
|
||||
page, err = q.FindPublishedPage(ctx, store.FindPublishedPageParams{Host: host, Slug: slug})
|
||||
if page, err = q.FindPublishedPage(ctx, store.FindPublishedPageParams{Host: host, Slug: slug}); err != nil || a.OrgID != nil {
|
||||
return err
|
||||
}
|
||||
own, err = q.OrgServesOwnPages(ctx, &page.OrgID)
|
||||
return err
|
||||
})
|
||||
a := agentOf(c)
|
||||
if errors.Is(err, pgx.ErrNoRows) || (err == nil && a.OrgID != nil && *a.OrgID != page.OrgID) {
|
||||
// The platform's servers leave the pages of organizations that serve
|
||||
// them on their own servers to those.
|
||||
if errors.Is(err, pgx.ErrNoRows) || (err == nil && (own || a.OrgID != nil && *a.OrgID != page.OrgID)) {
|
||||
fail(c, http.StatusNotFound, "not_found")
|
||||
return
|
||||
}
|
||||
@@ -366,9 +387,37 @@ func (s *Server) agentPage(c *gin.Context) {
|
||||
internalError(c, err)
|
||||
return
|
||||
}
|
||||
// The server sends the checksum of its copy; an unchanged page is not
|
||||
// sent again.
|
||||
etag := `"` + snap.Checksum() + `"`
|
||||
c.Header("ETag", etag)
|
||||
if c.GetHeader("If-None-Match") == etag {
|
||||
c.Status(http.StatusNotModified)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, snap)
|
||||
}
|
||||
|
||||
// agentPageIndex lists the pages the status page server serves.
|
||||
func (s *Server) agentPageIndex(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
var rows []store.ServablePagesRow
|
||||
err := s.db.Tx(ctx, tenant.System(), func(q *store.Queries) error {
|
||||
var err error
|
||||
rows, err = q.ServablePages(ctx, agentOf(c).OrgID)
|
||||
return err
|
||||
})
|
||||
if err != nil {
|
||||
internalError(c, err)
|
||||
return
|
||||
}
|
||||
out := make([]agentapi.PageRef, len(rows))
|
||||
for i, r := range rows {
|
||||
out[i] = agentapi.PageRef{Slug: r.Slug, Host: r.Host}
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"pages": out})
|
||||
}
|
||||
|
||||
type statusPageRequest struct {
|
||||
Slug string `json:"slug" binding:"required,max=63"`
|
||||
Title string `json:"title" binding:"required,max=200"`
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -95,6 +96,12 @@ func TestStatusPages(t *testing.T) {
|
||||
snap.Sections[1].Components[0].Name != "Public API" {
|
||||
t.Errorf("snapshot = %+v, want degraded page with the Public API in outage", snap)
|
||||
}
|
||||
if _, err := platform.PageIfChanged(context.Background(), "", slug, snap.Checksum()); !errors.Is(err, agentapi.ErrNotModified) {
|
||||
t.Errorf("PageIfChanged(current checksum) error = %v, want not modified", err)
|
||||
}
|
||||
if again, err := platform.PageIfChanged(context.Background(), "", slug, "stale"); err != nil || again.Title != "Acme Status" {
|
||||
t.Errorf("PageIfChanged(stale checksum) = %v, %v", again.Title, err)
|
||||
}
|
||||
raw, _ := json.Marshal(snap)
|
||||
for _, secret := range []string{up.URL, down.URL, "unexpected status"} {
|
||||
if strings.Contains(string(raw), secret) {
|
||||
@@ -192,6 +199,37 @@ func TestStatusPages(t *testing.T) {
|
||||
st, body = editor.do("PUT", "/api/v1/org/statuspages/"+second, map[string]any{"slug": "x-second", "title": "x"})
|
||||
expect(t, "edit page out of scope", st, body, http.StatusNotFound, "not_found")
|
||||
})
|
||||
|
||||
t.Run("own servers replace the platform's", func(t *testing.T) {
|
||||
org := uuid.MustParse(owner.orgID())
|
||||
own := e.statuspageClient(t, &org)
|
||||
lists := func(c *agentapi.Client) bool {
|
||||
t.Helper()
|
||||
refs, err := c.Pages(context.Background())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return slices.ContainsFunc(refs, func(r agentapi.PageRef) bool { return r.Slug == slug && r.Host != "" })
|
||||
}
|
||||
if _, err := platform.Page(context.Background(), "", slug); err != nil || !lists(platform) {
|
||||
t.Fatalf("platform server before the own one connected: %v", err)
|
||||
}
|
||||
if _, err := own.Hello(context.Background()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := platform.Page(context.Background(), "", slug); !errors.Is(err, agentapi.ErrNotFound) {
|
||||
t.Errorf("platform server still gets the page: %v", err)
|
||||
}
|
||||
if snap, err := own.Page(context.Background(), "", slug); err != nil || snap.Title != "Acme Status" {
|
||||
t.Errorf("own server Page() = %v, %v", snap.Title, err)
|
||||
}
|
||||
if lists(platform) || !lists(own) {
|
||||
t.Error("the page lists do not follow who serves the page")
|
||||
}
|
||||
if _, _, html := owner.page("/statuspages/" + pageID); !strings.Contains(html, "own status page servers serve its pages") {
|
||||
t.Error("the editor does not say who serves the pages")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func editorEmail(b *browser) string {
|
||||
|
||||
@@ -0,0 +1,860 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
"github.com/jackc/pgx/v5"
|
||||
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/auth"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/authz"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/notify"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/store"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/tenant"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/web"
|
||||
)
|
||||
|
||||
// Support tickets: an account asks the platform's admins for help, also
|
||||
// while it is suspended or has yet to accept the terms. A ticket is open
|
||||
// while it waits for the admins and answered while it waits for the
|
||||
// account; a reply from either side moves it accordingly, also out of
|
||||
// closed.
|
||||
|
||||
const (
|
||||
ticketOpen = "open"
|
||||
ticketAnswered = "answered"
|
||||
ticketClosed = "closed"
|
||||
)
|
||||
|
||||
type supportTicketRequest struct {
|
||||
Subject string `json:"subject" binding:"required,max=200"`
|
||||
Message string `json:"message" binding:"required,max=10000"`
|
||||
// AttachOrg names the active organization in the ticket. Anything else
|
||||
// attached comes from it and names it too.
|
||||
AttachOrg bool `json:"attach_org"`
|
||||
Monitor string `json:"monitor_id" binding:"max=36"`
|
||||
Channel string `json:"channel_id" binding:"max=36"`
|
||||
AlertGroup string `json:"alert_group_id" binding:"max=36"`
|
||||
StatusPage string `json:"status_page_id" binding:"max=36"`
|
||||
Incident string `json:"incident_id" binding:"max=36"`
|
||||
}
|
||||
|
||||
// supportReference is something a ticket points at, by kind: org,
|
||||
// monitor, channel, alert_group, status_page or incident.
|
||||
type supportReference struct {
|
||||
Kind string `json:"kind"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type supportMessageRequest struct {
|
||||
Message string `json:"message" binding:"required,max=10000"`
|
||||
}
|
||||
|
||||
type supportStatusRequest struct {
|
||||
Status string `json:"status" binding:"required,oneof=open answered closed"`
|
||||
}
|
||||
|
||||
type supportMessageView struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
FromStaff bool `json:"from_staff"`
|
||||
// Author is the admin who answered, shown to admins only.
|
||||
Author string `json:"author,omitempty"`
|
||||
Body string `json:"body"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
type supportTicketView struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
Subject string `json:"subject"`
|
||||
Status string `json:"status"`
|
||||
// Org is the organization the account was in when it opened the ticket.
|
||||
Org *string `json:"org,omitempty"`
|
||||
// User is the account's email, shown to admins only.
|
||||
User string `json:"user,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
References []supportReference `json:"references,omitempty"`
|
||||
Messages []supportMessageView `json:"messages,omitempty"`
|
||||
}
|
||||
|
||||
// cleanSupportText trims text and reports whether anything is left.
|
||||
func cleanSupportText(c *gin.Context, texts ...*string) bool {
|
||||
for _, t := range texts {
|
||||
*t = strings.TrimSpace(*t)
|
||||
if *t == "" {
|
||||
fail(c, http.StatusUnprocessableEntity, "invalid_input")
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// loadTicket reads a ticket with its messages in scope, which decides
|
||||
// whose tickets are visible.
|
||||
func (s *Server) loadTicket(ctx context.Context, scope tenant.Scope, id uuid.UUID, staff bool) (supportTicketView, error) {
|
||||
var v supportTicketView
|
||||
err := s.db.Tx(ctx, scope, func(q *store.Queries) error {
|
||||
t, err := q.GetSupportTicket(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
v = supportTicketView{ID: t.ID, Subject: t.Subject, Status: t.Status, Org: t.OrgName, CreatedAt: t.CreatedAt, UpdatedAt: t.UpdatedAt}
|
||||
if staff {
|
||||
v.User = t.UserEmail
|
||||
}
|
||||
msgs, err := q.SupportMessages(ctx, id)
|
||||
for _, m := range msgs {
|
||||
mv := supportMessageView{ID: m.ID, FromStaff: m.FromStaff, Body: m.Body, CreatedAt: m.CreatedAt}
|
||||
if staff && m.FromStaff {
|
||||
mv.Author = m.AuthorEmail
|
||||
}
|
||||
v.Messages = append(v.Messages, mv)
|
||||
}
|
||||
return err
|
||||
})
|
||||
if err != nil {
|
||||
return v, err
|
||||
}
|
||||
v.References, err = s.ticketReferences(ctx, id)
|
||||
return v, err
|
||||
}
|
||||
|
||||
// ticketReferences names what a ticket points at. The account may no
|
||||
// longer see those things, so this reads past row-level security, after
|
||||
// the caller saw the ticket itself.
|
||||
func (s *Server) ticketReferences(ctx context.Context, id uuid.UUID) ([]supportReference, error) {
|
||||
var out []supportReference
|
||||
err := s.db.Tx(ctx, tenant.System(), func(q *store.Queries) error {
|
||||
r, err := q.SupportTicketReferences(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
add := func(kind string, name *string, extra ...*string) {
|
||||
if name == nil {
|
||||
return
|
||||
}
|
||||
n := *name
|
||||
for _, e := range extra {
|
||||
if e != nil && *e != "" {
|
||||
n += " (" + *e + ")"
|
||||
}
|
||||
}
|
||||
out = append(out, supportReference{Kind: kind, Name: n})
|
||||
}
|
||||
add("org", r.OrgName, r.OrgSlug)
|
||||
add("monitor", r.MonitorName, r.MonitorType)
|
||||
add("channel", r.ChannelName, r.ChannelType)
|
||||
add("alert_group", r.AlertGroupName)
|
||||
add("status_page", r.StatusPageTitle, r.StatusPageSlug)
|
||||
if r.IncidentStartedAt != nil {
|
||||
name := deref(r.IncidentMonitor)
|
||||
if t := deref(r.IncidentTitle); t != "" {
|
||||
name = t + " · " + name
|
||||
}
|
||||
name += " · " + r.IncidentStartedAt.UTC().Format(timeLayout)
|
||||
add("incident", &name)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
return out, err
|
||||
}
|
||||
|
||||
func ticketID(c *gin.Context) (uuid.UUID, bool) {
|
||||
id, err := uuid.Parse(c.Param("id"))
|
||||
if err != nil {
|
||||
fail(c, http.StatusNotFound, "not_found")
|
||||
}
|
||||
return id, err == nil
|
||||
}
|
||||
|
||||
func (s *Server) listMyTickets(c *gin.Context) {
|
||||
sess := auth.Current(c)
|
||||
ctx := c.Request.Context()
|
||||
var rows []store.SupportTicket
|
||||
if err := s.db.Tx(ctx, tenant.User(sess.UserID), func(q *store.Queries) error {
|
||||
var err error
|
||||
rows, err = q.ListUserSupportTickets(ctx, sess.UserID)
|
||||
return err
|
||||
}); err != nil {
|
||||
internalError(c, err)
|
||||
return
|
||||
}
|
||||
out := make([]supportTicketView, len(rows))
|
||||
for i, t := range rows {
|
||||
out[i] = supportTicketView{ID: t.ID, Subject: t.Subject, Status: t.Status, CreatedAt: t.CreatedAt, UpdatedAt: t.UpdatedAt}
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"tickets": out})
|
||||
}
|
||||
|
||||
// optionalID parses a form's optional reference; empty is none.
|
||||
func optionalID(v string) (*uuid.UUID, bool) {
|
||||
if v = strings.TrimSpace(v); v == "" {
|
||||
return nil, true
|
||||
}
|
||||
id, err := uuid.Parse(v)
|
||||
return &id, err == nil
|
||||
}
|
||||
|
||||
// ticketRefs resolves what a new ticket points at. Everything comes from
|
||||
// the active organization, which the account has to be able to read.
|
||||
func (s *Server) ticketRefs(c *gin.Context, req supportTicketRequest) (store.CreateSupportTicketParams, bool) {
|
||||
var p store.CreateSupportTicketParams
|
||||
ids := []struct {
|
||||
raw string
|
||||
dst **uuid.UUID
|
||||
perm authz.Permission
|
||||
}{
|
||||
{req.Monitor, &p.MonitorID, authz.MonitorsRead},
|
||||
{req.Channel, &p.ChannelID, authz.NotificationsRead},
|
||||
{req.AlertGroup, &p.AlertGroupID, authz.NotificationsRead},
|
||||
{req.StatusPage, &p.StatusPageID, authz.StatusPagesRead},
|
||||
{req.Incident, &p.IncidentID, authz.IncidentsRead},
|
||||
}
|
||||
any := req.AttachOrg
|
||||
for _, r := range ids {
|
||||
id, ok := optionalID(r.raw)
|
||||
if !ok {
|
||||
fail(c, http.StatusUnprocessableEntity, "invalid_input")
|
||||
return p, false
|
||||
}
|
||||
*r.dst = id
|
||||
any = any || id != nil
|
||||
}
|
||||
if !any {
|
||||
return p, true
|
||||
}
|
||||
sess := auth.Current(c)
|
||||
_, principal, err := s.consoleMe(c, sess)
|
||||
if err != nil {
|
||||
internalError(c, err)
|
||||
return p, false
|
||||
}
|
||||
if principal == nil {
|
||||
fail(c, http.StatusUnprocessableEntity, "invalid_input")
|
||||
return p, false
|
||||
}
|
||||
for _, r := range ids {
|
||||
if *r.dst != nil && !principal.Grants.Can(r.perm) {
|
||||
fail(c, http.StatusUnprocessableEntity, "invalid_input")
|
||||
return p, false
|
||||
}
|
||||
}
|
||||
ctx := c.Request.Context()
|
||||
var exists *bool
|
||||
if err := s.db.Tx(ctx, principal.scope(), func(q *store.Queries) error {
|
||||
var err error
|
||||
exists, err = q.SupportReferencesExist(ctx, store.SupportReferencesExistParams{
|
||||
OrgID: principal.Org.ID, MonitorID: p.MonitorID, ChannelID: p.ChannelID,
|
||||
AlertGroupID: p.AlertGroupID, StatusPageID: p.StatusPageID, IncidentID: p.IncidentID,
|
||||
})
|
||||
return err
|
||||
}); err != nil {
|
||||
internalError(c, err)
|
||||
return p, false
|
||||
}
|
||||
if exists == nil || !*exists {
|
||||
fail(c, http.StatusUnprocessableEntity, "invalid_input")
|
||||
return p, false
|
||||
}
|
||||
p.OrgID = &principal.Org.ID
|
||||
return p, true
|
||||
}
|
||||
|
||||
// errTicketLimit and errSuspendedTicket refuse tickets beyond what the
|
||||
// platform allows; the error code says which.
|
||||
var (
|
||||
errTicketLimit = errors.New("api: too many open tickets")
|
||||
errSuspendedTicket = errors.New("api: suspended accounts open one ticket")
|
||||
)
|
||||
|
||||
// checkTicketLimits refuses another open ticket for user: more than the
|
||||
// platform allows at the same time, or a second since a suspension.
|
||||
func checkTicketLimits(ctx context.Context, q *store.Queries, user uuid.UUID, maxOpen int, newTicket bool) error {
|
||||
if newTicket {
|
||||
u, err := q.GetUser(ctx, user)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if u.DisabledAt != nil {
|
||||
n, err := q.CountSupportTicketsSince(ctx, store.CountSupportTicketsSinceParams{UserID: user, CreatedAt: *u.DisabledAt})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if n > 0 {
|
||||
return errSuspendedTicket
|
||||
}
|
||||
}
|
||||
}
|
||||
if maxOpen <= 0 {
|
||||
return nil
|
||||
}
|
||||
n, err := q.CountOpenSupportTickets(ctx, user)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if n >= int64(maxOpen) {
|
||||
return errTicketLimit
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// failTicketLimit answers err if it is one of the ticket limits.
|
||||
func failTicketLimit(c *gin.Context, err error, maxOpen int) bool {
|
||||
switch {
|
||||
case errors.Is(err, errSuspendedTicket):
|
||||
fail(c, http.StatusConflict, "suspended_ticket_limit")
|
||||
case errors.Is(err, errTicketLimit):
|
||||
fail(c, http.StatusConflict, "too_many_tickets", "Count", maxOpen)
|
||||
default:
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (s *Server) createTicket(c *gin.Context) {
|
||||
var req supportTicketRequest
|
||||
if !bind(c, &req) || !cleanSupportText(c, &req.Subject, &req.Message) {
|
||||
return
|
||||
}
|
||||
sess := auth.Current(c)
|
||||
if !s.limit(c, "support:user:"+sess.UserID.String(), 10, time.Hour) {
|
||||
return
|
||||
}
|
||||
params, ok := s.ticketRefs(c, req)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
params.UserID, params.Subject = sess.UserID, req.Subject
|
||||
ctx := c.Request.Context()
|
||||
maxOpen := s.supportSettings(ctx).MaxOpen
|
||||
var t store.SupportTicket
|
||||
err := s.db.Tx(ctx, tenant.User(sess.UserID), func(q *store.Queries) error {
|
||||
if err := checkTicketLimits(ctx, q, sess.UserID, maxOpen, true); err != nil {
|
||||
return err
|
||||
}
|
||||
var err error
|
||||
if t, err = q.CreateSupportTicket(ctx, params); err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = q.AddSupportMessage(ctx, store.AddSupportMessageParams{TicketID: t.ID, AuthorID: &sess.UserID, Body: req.Message})
|
||||
return err
|
||||
})
|
||||
if failTicketLimit(c, err, maxOpen) {
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
internalError(c, err)
|
||||
return
|
||||
}
|
||||
auditDetail(c, "ticket", t.ID.String())
|
||||
s.mailAdmins(ctx, t.ID, t.Subject)
|
||||
c.JSON(http.StatusCreated, supportTicketView{ID: t.ID, Subject: t.Subject, Status: t.Status, CreatedAt: t.CreatedAt, UpdatedAt: t.UpdatedAt})
|
||||
}
|
||||
|
||||
func (s *Server) getMyTicket(c *gin.Context) {
|
||||
id, ok := ticketID(c)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
v, err := s.loadTicket(c.Request.Context(), tenant.User(auth.Current(c).UserID), id, false)
|
||||
s.respondTicket(c, v, err)
|
||||
}
|
||||
|
||||
func (s *Server) respondTicket(c *gin.Context, v supportTicketView, err error) {
|
||||
switch {
|
||||
case errors.Is(err, pgx.ErrNoRows):
|
||||
fail(c, http.StatusNotFound, "not_found")
|
||||
case err != nil:
|
||||
internalError(c, err)
|
||||
default:
|
||||
c.JSON(http.StatusOK, v)
|
||||
}
|
||||
}
|
||||
|
||||
// replyTicket adds a message and moves the ticket to the side that has to
|
||||
// answer next.
|
||||
func (s *Server) replyTicket(c *gin.Context, scope tenant.Scope, author uuid.UUID, staff bool) (store.GetSupportTicketRow, bool) {
|
||||
maxOpen := 0
|
||||
if !staff {
|
||||
maxOpen = s.supportSettings(c.Request.Context()).MaxOpen
|
||||
}
|
||||
id, ok := ticketID(c)
|
||||
if !ok {
|
||||
return store.GetSupportTicketRow{}, false
|
||||
}
|
||||
var req supportMessageRequest
|
||||
if !bind(c, &req) || !cleanSupportText(c, &req.Message) {
|
||||
return store.GetSupportTicketRow{}, false
|
||||
}
|
||||
status := ticketOpen
|
||||
if staff {
|
||||
status = ticketAnswered
|
||||
}
|
||||
ctx := c.Request.Context()
|
||||
var t store.GetSupportTicketRow
|
||||
err := s.db.Tx(ctx, scope, func(q *store.Queries) error {
|
||||
var err error
|
||||
if t, err = q.GetSupportTicket(ctx, id); err != nil {
|
||||
return err
|
||||
}
|
||||
if !staff && t.Status == ticketClosed {
|
||||
if err := checkTicketLimits(ctx, q, t.UserID, maxOpen, false); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if _, err = q.AddSupportMessage(ctx, store.AddSupportMessageParams{TicketID: id, AuthorID: &author, FromStaff: staff, Body: req.Message}); err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = q.SetSupportTicketStatus(ctx, store.SetSupportTicketStatusParams{ID: id, Status: status})
|
||||
return err
|
||||
})
|
||||
switch {
|
||||
case errors.Is(err, pgx.ErrNoRows):
|
||||
fail(c, http.StatusNotFound, "not_found")
|
||||
return t, false
|
||||
case failTicketLimit(c, err, maxOpen):
|
||||
return t, false
|
||||
case err != nil:
|
||||
internalError(c, err)
|
||||
return t, false
|
||||
}
|
||||
auditDetail(c, "ticket", id.String())
|
||||
c.JSON(http.StatusCreated, gin.H{"status": status})
|
||||
return t, true
|
||||
}
|
||||
|
||||
func (s *Server) replyMyTicket(c *gin.Context) {
|
||||
sess := auth.Current(c)
|
||||
if !s.limit(c, "support:reply:"+sess.UserID.String(), 60, time.Hour) {
|
||||
return
|
||||
}
|
||||
if t, ok := s.replyTicket(c, tenant.User(sess.UserID), sess.UserID, false); ok {
|
||||
s.mailAdmins(c.Request.Context(), t.ID, t.Subject)
|
||||
}
|
||||
}
|
||||
|
||||
// setTicketStatus closes or reopens a ticket in scope; accounts can only
|
||||
// close theirs or reopen them for the admins.
|
||||
func (s *Server) setTicketStatus(c *gin.Context, scope tenant.Scope, maxOpen int, allowed ...string) {
|
||||
id, ok := ticketID(c)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
var req supportStatusRequest
|
||||
if !bind(c, &req) {
|
||||
return
|
||||
}
|
||||
if len(allowed) > 0 && !slices.Contains(allowed, req.Status) {
|
||||
fail(c, http.StatusUnprocessableEntity, "invalid_input")
|
||||
return
|
||||
}
|
||||
ctx := c.Request.Context()
|
||||
var n int64
|
||||
err := s.db.Tx(ctx, scope, func(q *store.Queries) error {
|
||||
if req.Status != ticketClosed && maxOpen > 0 {
|
||||
cur, err := q.SupportTicketStatus(ctx, id)
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return nil
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if cur == ticketClosed {
|
||||
if err := checkTicketLimits(ctx, q, auth.Current(c).UserID, maxOpen, false); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
var err error
|
||||
n, err = q.SetSupportTicketStatus(ctx, store.SetSupportTicketStatusParams{ID: id, Status: req.Status})
|
||||
return err
|
||||
})
|
||||
switch {
|
||||
case failTicketLimit(c, err, maxOpen):
|
||||
case err != nil:
|
||||
internalError(c, err)
|
||||
case n == 0:
|
||||
fail(c, http.StatusNotFound, "not_found")
|
||||
default:
|
||||
auditDetail(c, "status", req.Status)
|
||||
c.Status(http.StatusNoContent)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) setMyTicketStatus(c *gin.Context) {
|
||||
s.setTicketStatus(c, tenant.User(auth.Current(c).UserID), s.supportSettings(c.Request.Context()).MaxOpen, ticketOpen, ticketClosed)
|
||||
}
|
||||
|
||||
// supportStatusFilter reads the status filter of the admins' list; empty
|
||||
// lists every ticket.
|
||||
func supportStatusFilter(c *gin.Context) *string {
|
||||
switch st := c.Query("status"); st {
|
||||
case ticketOpen, ticketAnswered, ticketClosed:
|
||||
return &st
|
||||
case "all":
|
||||
return nil
|
||||
default:
|
||||
open := ticketOpen
|
||||
return &open
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) adminListTickets(c *gin.Context) {
|
||||
rows, err := s.supportTickets(c.Request.Context(), supportStatusFilter(c))
|
||||
if err != nil {
|
||||
internalError(c, err)
|
||||
return
|
||||
}
|
||||
out := make([]supportTicketView, len(rows))
|
||||
for i, t := range rows {
|
||||
out[i] = supportTicketView{ID: t.ID, Subject: t.Subject, Status: t.Status, Org: t.OrgName, User: t.UserEmail, CreatedAt: t.CreatedAt, UpdatedAt: t.UpdatedAt}
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"tickets": out})
|
||||
}
|
||||
|
||||
// supportTickets lists the latest 200 tickets with status, or all.
|
||||
func (s *Server) supportTickets(ctx context.Context, status *string) ([]store.ListSupportTicketsRow, error) {
|
||||
var rows []store.ListSupportTicketsRow
|
||||
err := s.db.Tx(ctx, tenant.System(), func(q *store.Queries) error {
|
||||
var err error
|
||||
rows, err = q.ListSupportTickets(ctx, status)
|
||||
return err
|
||||
})
|
||||
return rows, err
|
||||
}
|
||||
|
||||
func (s *Server) adminGetTicket(c *gin.Context) {
|
||||
id, ok := ticketID(c)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
v, err := s.loadTicket(c.Request.Context(), tenant.System(), id, true)
|
||||
s.respondTicket(c, v, err)
|
||||
}
|
||||
|
||||
func (s *Server) adminReplyTicket(c *gin.Context) {
|
||||
sess := auth.Current(c)
|
||||
if t, ok := s.replyTicket(c, tenant.System(), sess.UserID, true); ok {
|
||||
s.mailTicketOwner(c.Request.Context(), t)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) adminSetTicketStatus(c *gin.Context) {
|
||||
s.setTicketStatus(c, tenant.System(), 0)
|
||||
}
|
||||
|
||||
func (s *Server) ticketLink(path string) string {
|
||||
return strings.TrimSuffix(s.cfg.PublicURL, "/") + path
|
||||
}
|
||||
|
||||
// mailAdmins tells the platform's admins that a ticket waits for them.
|
||||
// Mail is a courtesy: the ticket stands without it.
|
||||
func (s *Server) mailAdmins(ctx context.Context, id uuid.UUID, subject string) {
|
||||
if s.smtp == nil {
|
||||
return
|
||||
}
|
||||
var to []string
|
||||
if err := s.db.Tx(ctx, tenant.Global(), func(q *store.Queries) error {
|
||||
var err error
|
||||
to, err = q.AdminEmails(ctx)
|
||||
return err
|
||||
}); err != nil || len(to) == 0 {
|
||||
return
|
||||
}
|
||||
l := s.catalog.Match("")
|
||||
data := map[string]any{"Subject": subject, "Link": s.ticketLink("/admin/support/" + id.String())}
|
||||
if err := s.smtp.Send(ctx, notify.Mail{To: to, Subject: l.T("email.support_admin.subject", data), Body: l.T("email.support_admin.body", data)}); err != nil {
|
||||
slog.WarnContext(ctx, "support: mail to admins failed", "ticket", id, "err", err)
|
||||
}
|
||||
}
|
||||
|
||||
// mailTicketOwner tells the account that its ticket was answered.
|
||||
func (s *Server) mailTicketOwner(ctx context.Context, t store.GetSupportTicketRow) {
|
||||
if s.smtp == nil {
|
||||
return
|
||||
}
|
||||
var locale string
|
||||
_ = s.db.Tx(ctx, tenant.Global(), func(q *store.Queries) error {
|
||||
u, err := q.GetUser(ctx, t.UserID)
|
||||
locale = deref(u.Locale)
|
||||
return err
|
||||
})
|
||||
l := s.catalog.Match(locale)
|
||||
data := map[string]any{"Subject": t.Subject, "Link": s.ticketLink("/support/" + t.ID.String())}
|
||||
if err := s.smtp.Send(ctx, notify.Mail{To: []string{t.UserEmail}, Subject: l.T("email.support_reply.subject", data), Body: l.T("email.support_reply.body", data)}); err != nil {
|
||||
slog.WarnContext(ctx, "support: mail to account failed", "ticket", t.ID, "err", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Pages.
|
||||
|
||||
func toWebTicket(v supportTicketView) web.SupportTicket {
|
||||
t := web.SupportTicket{ID: v.ID.String(), Subject: v.Subject, Status: v.Status, User: v.User, Updated: v.UpdatedAt.UTC().Format(timeLayout)}
|
||||
if v.Org != nil {
|
||||
t.Org = *v.Org
|
||||
}
|
||||
for _, r := range v.References {
|
||||
t.References = append(t.References, web.SupportReference{Kind: r.Kind, Name: r.Name})
|
||||
}
|
||||
for _, m := range v.Messages {
|
||||
html, err := web.RenderMarkdown(m.Body)
|
||||
if err != nil {
|
||||
html = ""
|
||||
}
|
||||
t.Messages = append(t.Messages, web.SupportMessage{FromStaff: m.FromStaff, Author: m.Author, HTML: html, At: m.CreatedAt.UTC().Format(timeLayout)})
|
||||
}
|
||||
return t
|
||||
}
|
||||
|
||||
// supportMe is the console frame of the support pages, which accounts
|
||||
// reach also while restricted.
|
||||
func (s *Server) supportMe(c *gin.Context) (*auth.Session, web.Me, *principal, bool) {
|
||||
sess := auth.Current(c)
|
||||
if sess == nil {
|
||||
c.Redirect(http.StatusSeeOther, "/login?next="+c.Request.URL.Path)
|
||||
return nil, web.Me{}, nil, false
|
||||
}
|
||||
me, p, err := s.consoleMe(c, sess)
|
||||
if err != nil {
|
||||
internalError(c, err)
|
||||
return nil, web.Me{}, nil, false
|
||||
}
|
||||
if !me.Support {
|
||||
web.Render(c, http.StatusOK, web.SupportDisabledPage(s.pageFor(c, "support.title"), me))
|
||||
return nil, web.Me{}, nil, false
|
||||
}
|
||||
return sess, me, p, true
|
||||
}
|
||||
|
||||
// supportOptions lists what of the active organization a new ticket can
|
||||
// point at, as far as the account may read it.
|
||||
func (s *Server) supportOptions(ctx context.Context, p *principal) (web.SupportOptions, error) {
|
||||
var o web.SupportOptions
|
||||
if p == nil {
|
||||
return o, nil
|
||||
}
|
||||
o.Org = p.Org.Name
|
||||
err := s.db.Tx(ctx, p.scope(), func(q *store.Queries) error {
|
||||
if p.Grants.Can(authz.MonitorsRead) {
|
||||
rows, err := q.SupportOptionsMonitors(ctx, p.Org.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, r := range rows {
|
||||
o.Monitors = append(o.Monitors, web.SupportOption{ID: r.ID.String(), Name: r.Name})
|
||||
}
|
||||
}
|
||||
if p.Grants.Can(authz.NotificationsRead) {
|
||||
chans, err := q.SupportOptionsChannels(ctx, p.Org.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, r := range chans {
|
||||
o.Channels = append(o.Channels, web.SupportOption{ID: r.ID.String(), Name: r.Name + " (" + r.Type + ")"})
|
||||
}
|
||||
groups, err := q.SupportOptionsAlertGroups(ctx, p.Org.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, r := range groups {
|
||||
o.AlertGroups = append(o.AlertGroups, web.SupportOption{ID: r.ID.String(), Name: r.Name})
|
||||
}
|
||||
}
|
||||
if p.Grants.Can(authz.StatusPagesRead) {
|
||||
rows, err := q.SupportOptionsStatusPages(ctx, p.Org.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, r := range rows {
|
||||
o.StatusPages = append(o.StatusPages, web.SupportOption{ID: r.ID.String(), Name: r.Title})
|
||||
}
|
||||
}
|
||||
if p.Grants.Can(authz.IncidentsRead) {
|
||||
rows, err := q.SupportOptionsIncidents(ctx, p.Org.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, r := range rows {
|
||||
name := r.MonitorName
|
||||
if r.Title != "" {
|
||||
name = r.Title + " · " + name
|
||||
}
|
||||
o.Incidents = append(o.Incidents, web.SupportOption{ID: r.ID.String(), Name: name + " · " + r.StartedAt.UTC().Format(timeLayout)})
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
return o, err
|
||||
}
|
||||
|
||||
func (s *Server) supportPage(c *gin.Context) {
|
||||
sess, me, p, ok := s.supportMe(c)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
ctx := c.Request.Context()
|
||||
opts, err := s.supportOptions(ctx, p)
|
||||
if err != nil {
|
||||
internalError(c, err)
|
||||
return
|
||||
}
|
||||
var rows []store.SupportTicket
|
||||
if err := s.db.Tx(ctx, tenant.User(sess.UserID), func(q *store.Queries) error {
|
||||
var err error
|
||||
rows, err = q.ListUserSupportTickets(ctx, sess.UserID)
|
||||
return err
|
||||
}); err != nil {
|
||||
internalError(c, err)
|
||||
return
|
||||
}
|
||||
tickets := make([]web.SupportTicket, len(rows))
|
||||
for i, t := range rows {
|
||||
tickets[i] = toWebTicket(supportTicketView{ID: t.ID, Subject: t.Subject, Status: t.Status, UpdatedAt: t.UpdatedAt})
|
||||
}
|
||||
web.Render(c, http.StatusOK, web.SupportPage(s.pageFor(c, "support.title"), me, tickets, opts))
|
||||
}
|
||||
|
||||
func (s *Server) supportTicketPage(c *gin.Context) {
|
||||
sess, me, _, ok := s.supportMe(c)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
s.renderTicket(c, me, tenant.User(sess.UserID), false)
|
||||
}
|
||||
|
||||
func (s *Server) renderTicket(c *gin.Context, me web.Me, scope tenant.Scope, staff bool) {
|
||||
id, err := uuid.Parse(c.Param("id"))
|
||||
var v supportTicketView
|
||||
if err == nil {
|
||||
v, err = s.loadTicket(c.Request.Context(), scope, id, staff)
|
||||
}
|
||||
if err != nil && !errors.Is(err, pgx.ErrNoRows) {
|
||||
internalError(c, err)
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
back := "/support"
|
||||
if staff {
|
||||
back = "/admin/support"
|
||||
}
|
||||
c.Redirect(http.StatusSeeOther, back)
|
||||
return
|
||||
}
|
||||
var account *web.SupportAccount
|
||||
if staff {
|
||||
a, err := s.ticketAccount(c.Request.Context(), id)
|
||||
if err != nil {
|
||||
internalError(c, err)
|
||||
return
|
||||
}
|
||||
account = &a
|
||||
}
|
||||
web.Render(c, http.StatusOK, web.SupportTicketPage(s.pageFor(c, "support.title"), me, toWebTicket(v), account))
|
||||
}
|
||||
|
||||
func (s *Server) adminSupportPage(c *gin.Context) {
|
||||
me, ok := s.adminMe(c)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
status := supportStatusFilter(c)
|
||||
rows, err := s.supportTickets(c.Request.Context(), status)
|
||||
if err != nil {
|
||||
internalError(c, err)
|
||||
return
|
||||
}
|
||||
tickets := make([]web.SupportTicket, len(rows))
|
||||
for i, t := range rows {
|
||||
tickets[i] = toWebTicket(supportTicketView{ID: t.ID, Subject: t.Subject, Status: t.Status, Org: t.OrgName, User: t.UserEmail, UpdatedAt: t.UpdatedAt})
|
||||
}
|
||||
filter := "all"
|
||||
if status != nil {
|
||||
filter = *status
|
||||
}
|
||||
settings := s.supportSettings(c.Request.Context())
|
||||
web.Render(c, http.StatusOK, web.AdminSupportPage(s.pageFor(c, "support.admin_title"), me, tickets, filter, web.SupportSettings{Enabled: settings.Enabled, MaxOpen: settings.MaxOpen}))
|
||||
}
|
||||
|
||||
func (s *Server) adminSupportTicketPage(c *gin.Context) {
|
||||
me, ok := s.adminMe(c)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
s.renderTicket(c, me, tenant.System(), true)
|
||||
}
|
||||
|
||||
// ticketAccount gathers what admins need to answer a ticket: the account,
|
||||
// its organizations with their limits and usage, and its other tickets.
|
||||
func (s *Server) ticketAccount(ctx context.Context, ticket uuid.UUID) (web.SupportAccount, error) {
|
||||
var a web.SupportAccount
|
||||
platform := s.platformLimits(ctx)
|
||||
err := s.db.Tx(ctx, tenant.System(), func(q *store.Queries) error {
|
||||
t, err := q.GetSupportTicket(ctx, ticket)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
u, err := q.GetUser(ctx, t.UserID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a = web.SupportAccount{
|
||||
ID: u.ID.String(), Email: u.Email, Name: u.DisplayName, Created: u.CreatedAt.UTC().Format(timeLayout),
|
||||
Verified: u.EmailVerifiedAt != nil, TOTP: u.TotpEnabledAt != nil, Password: u.PasswordHash != nil,
|
||||
Admin: u.IsAdmin, Locale: deref(u.Locale),
|
||||
}
|
||||
if u.DisabledAt != nil {
|
||||
a.Suspended = true
|
||||
a.SuspendedReason = u.DisabledReason
|
||||
}
|
||||
a.OrgLimit = platform.OrgsPerAccount
|
||||
if u.LimitOrgs != nil {
|
||||
a.OrgLimit = int(*u.LimitOrgs)
|
||||
}
|
||||
owned, err := q.CountOwnedOrgs(ctx, u.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.OrgsOwned = int(owned)
|
||||
if a.OpenTickets, err = q.CountOpenSupportTickets(ctx, u.ID); err != nil {
|
||||
return err
|
||||
}
|
||||
ms, err := q.UserMemberships(ctx, u.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, m := range ms {
|
||||
o, err := q.GetOrg(ctx, m.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
mon, err := q.CountMonitors(ctx, o.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
pages, err := q.CountStatusPages(ctx, o.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
l := s.orgLimits(ctx, o)
|
||||
org := web.SupportOrg{
|
||||
Name: o.Name, Slug: o.Slug, Owner: m.IsOwner, Current: t.OrgID != nil && *t.OrgID == o.ID,
|
||||
Monitors: int(mon), MonitorLimit: l.Monitors, StatusPages: int(pages), StatusPageLimit: l.StatusPages,
|
||||
RegionsPerMonitor: l.RegionsPerMonitor,
|
||||
}
|
||||
if o.SuspendedAt != nil {
|
||||
org.Suspended = true
|
||||
org.SuspendedReason = o.SuspendedReason
|
||||
}
|
||||
a.Orgs = append(a.Orgs, org)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
return a, err
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/jackc/pgx/v5"
|
||||
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/store"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/tenant"
|
||||
)
|
||||
|
||||
const settingSupport = "support"
|
||||
|
||||
// supportSettings are how the platform runs its support tickets.
|
||||
type supportSettings struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
// MaxOpen limits the tickets an account has open, answered ones
|
||||
// included, at the same time; 0 means unlimited.
|
||||
MaxOpen int `json:"max_open_tickets" binding:"min=0,max=1000"`
|
||||
}
|
||||
|
||||
func defaultSupportSettings() supportSettings { return supportSettings{Enabled: true, MaxOpen: 3} }
|
||||
|
||||
func (s *Server) supportSettings(ctx context.Context) supportSettings {
|
||||
v, err := s.support.get(ctx, s.rdb, func(ctx context.Context) (supportSettings, error) {
|
||||
v := defaultSupportSettings()
|
||||
err := s.db.Tx(ctx, tenant.System(), func(q *store.Queries) error {
|
||||
raw, err := q.GetPlatformSetting(ctx, settingSupport)
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return nil
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return json.Unmarshal(raw, &v)
|
||||
})
|
||||
return v, err
|
||||
})
|
||||
if err != nil {
|
||||
s.log.WarnContext(ctx, "loading support settings failed", "error", err)
|
||||
return defaultSupportSettings()
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// requireSupport answers for accounts only while support is enabled; the
|
||||
// admins keep their tickets either way.
|
||||
func (s *Server) requireSupport() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
if !s.supportSettings(c.Request.Context()).Enabled {
|
||||
fail(c, http.StatusForbidden, "support_disabled")
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
c.Next()
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) adminGetSupportSettings(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, s.supportSettings(c.Request.Context()))
|
||||
}
|
||||
|
||||
func (s *Server) adminSetSupportSettings(c *gin.Context) {
|
||||
var req supportSettings
|
||||
if !bind(c, &req) {
|
||||
return
|
||||
}
|
||||
ctx := c.Request.Context()
|
||||
raw, _ := json.Marshal(req)
|
||||
auditDetail(c, "settings", req)
|
||||
if err := s.db.Tx(ctx, tenant.System(), func(q *store.Queries) error {
|
||||
return q.SetPlatformSetting(ctx, store.SetPlatformSettingParams{Key: settingSupport, Value: raw})
|
||||
}); err != nil {
|
||||
internalError(c, err)
|
||||
return
|
||||
}
|
||||
if err := s.support.bump(ctx, s.rdb); err != nil {
|
||||
s.log.ErrorContext(ctx, "announcing support settings failed", "error", err)
|
||||
}
|
||||
c.Status(http.StatusNoContent)
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
package api_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/config"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/notify/notifytest"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/store"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/tenant"
|
||||
)
|
||||
|
||||
func TestSupportTickets(t *testing.T) {
|
||||
mail := notifytest.NewSMTP(t)
|
||||
e := newEnvWith(t, func(c *config.API) { c.SMTPURL, c.SignupVerify = mail.URL(), "off" })
|
||||
ctx := context.Background()
|
||||
admin := e.browser(t)
|
||||
admin.signup("a@"+uniq("sup")+".test", uniq("sup-"))
|
||||
if err := tenant.New(e.dbPool).Tx(ctx, tenant.Global(), func(q *store.Queries) error {
|
||||
return q.MakeAdmin(ctx, admin.userIDSelf())
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
userEmail := "u@" + uniq("sup") + ".test"
|
||||
user := e.browser(t)
|
||||
user.signup(userEmail, uniq("sup-"))
|
||||
userID := user.userIDSelf()
|
||||
mailed := func(to, link string) {
|
||||
t.Helper()
|
||||
waitFor(t, 5*time.Second, "a mail with "+link, func() bool {
|
||||
for _, m := range mail.Messages() {
|
||||
if strings.Contains(strings.Join(m.To, ","), to) && strings.Contains(m.Data, link) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
st, body := user.do("POST", "/api/v1/support/tickets", map[string]any{"subject": " ", "message": "x"})
|
||||
expect(t, "ticket without subject", st, body, http.StatusUnprocessableEntity, "invalid_input")
|
||||
st, created := user.do("POST", "/api/v1/support/tickets", map[string]any{"subject": "Checks are late", "message": "Since **Monday**."})
|
||||
if st != http.StatusCreated || created["status"] != "open" {
|
||||
t.Fatalf("open ticket = %d %v", st, created)
|
||||
}
|
||||
id := created["id"].(string)
|
||||
mailed(adminEmailOf(t, admin), "/admin/support/"+id)
|
||||
|
||||
// Only the account and the admins see it.
|
||||
other := e.browser(t)
|
||||
other.signup("o@"+uniq("sup")+".test", uniq("sup-"))
|
||||
if st, _ := other.do("GET", "/api/v1/support/tickets/"+id, nil); st != http.StatusNotFound {
|
||||
t.Errorf("another account reads the ticket = %d", st)
|
||||
}
|
||||
if st, _ := other.do("POST", "/api/v1/support/tickets/"+id+"/messages", map[string]any{"message": "me too"}); st != http.StatusNotFound {
|
||||
t.Errorf("another account replies = %d", st)
|
||||
}
|
||||
if st, _ := user.do("GET", "/api/v1/admin/support/tickets", nil); st != http.StatusForbidden && st != http.StatusNotFound {
|
||||
t.Errorf("an account lists every ticket = %d", st)
|
||||
}
|
||||
_, list := admin.do("GET", "/api/v1/admin/support/tickets", nil)
|
||||
if !strings.Contains(mustJSON(list), id) || !strings.Contains(mustJSON(list), userEmail) {
|
||||
t.Errorf("open tickets for the admins lack it: %v", list)
|
||||
}
|
||||
|
||||
// Answering moves it to the account and mails it; its reply moves it back.
|
||||
if st, body := admin.do("POST", "/api/v1/admin/support/tickets/"+id+"/messages", map[string]any{"message": "Fixed, sorry!"}); st != http.StatusCreated || body["status"] != "answered" {
|
||||
t.Fatalf("answer = %d %v", st, body)
|
||||
}
|
||||
mailed(userEmail, "/support/"+id)
|
||||
_, ticket := user.do("GET", "/api/v1/support/tickets/"+id, nil)
|
||||
msgs, _ := ticket["messages"].([]any)
|
||||
if ticket["status"] != "answered" || len(msgs) != 2 || msgs[1].(map[string]any)["from_staff"] != true || msgs[1].(map[string]any)["author"] != nil {
|
||||
t.Errorf("ticket for the account = %v", ticket)
|
||||
}
|
||||
_, _, html := user.page("/support/" + id)
|
||||
for _, want := range []string{"Checks are late", "<strong>Monday</strong>", "Fixed, sorry!", "Close ticket"} {
|
||||
if !strings.Contains(html, want) {
|
||||
t.Errorf("ticket page lacks %q", want)
|
||||
}
|
||||
}
|
||||
if _, _, html := admin.page("/admin/support/" + id); !strings.Contains(html, userEmail) {
|
||||
t.Error("the admins' ticket page does not name the account")
|
||||
}
|
||||
user.do("POST", "/api/v1/support/tickets/"+id+"/messages", map[string]any{"message": "Thanks!"})
|
||||
if _, tk := user.do("GET", "/api/v1/support/tickets/"+id, nil); tk["status"] != "open" {
|
||||
t.Errorf("after the account's reply status = %v", tk["status"])
|
||||
}
|
||||
|
||||
// Accounts close and reopen theirs, nothing else.
|
||||
st, body = user.do("PUT", "/api/v1/support/tickets/"+id+"/status", map[string]any{"status": "answered"})
|
||||
expect(t, "account marks answered", st, body, http.StatusUnprocessableEntity, "invalid_input")
|
||||
if st, _ := user.do("PUT", "/api/v1/support/tickets/"+id+"/status", map[string]any{"status": "closed"}); st != http.StatusNoContent {
|
||||
t.Errorf("close = %d", st)
|
||||
}
|
||||
_, closed := admin.do("GET", "/api/v1/admin/support/tickets?status=closed", nil)
|
||||
if !strings.Contains(mustJSON(closed), id) {
|
||||
t.Error("the closed filter lacks the ticket")
|
||||
}
|
||||
if _, _, html := user.page("/support"); !strings.Contains(html, "Checks are late") || !strings.Contains(html, "closed") {
|
||||
t.Error("the support page lacks the closed ticket")
|
||||
}
|
||||
|
||||
// Tickets point at things of the active organization the account can
|
||||
// read, never at another's; the admins see the account at a glance.
|
||||
_, mon := user.do("POST", "/api/v1/org/monitors", map[string]any{"name": "Checkout API", "type": "heartbeat", "interval_seconds": 3600})
|
||||
_, foreign := other.do("POST", "/api/v1/org/monitors", map[string]any{"name": "Theirs", "type": "heartbeat", "interval_seconds": 3600})
|
||||
st, body = user.do("POST", "/api/v1/support/tickets", map[string]any{"subject": "Peek", "message": "x", "monitor_id": foreign["id"]})
|
||||
expect(t, "ticket about another organization's monitor", st, body, http.StatusUnprocessableEntity, "invalid_input")
|
||||
if _, _, page := user.page("/support"); !strings.Contains(page, `name="monitor_id"`) || !strings.Contains(page, "Checkout API") {
|
||||
t.Error("the new ticket form does not offer the monitors")
|
||||
}
|
||||
st, withRef := user.do("POST", "/api/v1/support/tickets", map[string]any{"subject": "Heartbeat missing", "message": "x", "monitor_id": mon["id"], "channel_id": ""})
|
||||
if st != http.StatusCreated {
|
||||
t.Fatalf("ticket about a monitor = %d %v", st, withRef)
|
||||
}
|
||||
refID := withRef["id"].(string)
|
||||
_, got := user.do("GET", "/api/v1/support/tickets/"+refID, nil)
|
||||
if refs := mustJSON(got["references"]); !strings.Contains(refs, "Checkout API") || !strings.Contains(refs, `"org"`) {
|
||||
t.Errorf("references = %s", refs)
|
||||
}
|
||||
if _, _, page := admin.page("/admin/support/" + refID); !strings.Contains(page, "Checkout API") || !strings.Contains(page, "Organizations owned") || !strings.Contains(page, "1 / ") {
|
||||
t.Error("the admins' ticket page lacks the references or the account's details")
|
||||
}
|
||||
|
||||
// The admins limit open tickets per account and can switch support off.
|
||||
t.Cleanup(func() {
|
||||
admin.do("PUT", "/api/v1/admin/support/settings", map[string]any{"enabled": true, "max_open_tickets": 3})
|
||||
})
|
||||
if st, body := admin.do("PUT", "/api/v1/admin/support/settings", map[string]any{"enabled": true, "max_open_tickets": 2}); st != http.StatusNoContent {
|
||||
t.Fatalf("set support settings = %d %v", st, body)
|
||||
}
|
||||
if st, body := user.do("POST", "/api/v1/support/tickets", map[string]any{"subject": "Second", "message": "x"}); st != http.StatusCreated {
|
||||
t.Fatalf("second open ticket = %d %v", st, body)
|
||||
}
|
||||
st, body = user.do("POST", "/api/v1/support/tickets", map[string]any{"subject": "Third", "message": "x"})
|
||||
expect(t, "third open ticket", st, body, http.StatusConflict, "too_many_tickets")
|
||||
st, body = user.do("PUT", "/api/v1/support/tickets/"+id+"/status", map[string]any{"status": "open"})
|
||||
expect(t, "reopen beyond the limit", st, body, http.StatusConflict, "too_many_tickets")
|
||||
st, body = user.do("POST", "/api/v1/support/tickets/"+id+"/messages", map[string]any{"message": "again"})
|
||||
expect(t, "reply to a closed ticket beyond the limit", st, body, http.StatusConflict, "too_many_tickets")
|
||||
admin.do("PUT", "/api/v1/admin/support/settings", map[string]any{"enabled": false, "max_open_tickets": 0})
|
||||
st, body = user.do("POST", "/api/v1/support/tickets", map[string]any{"subject": "Off", "message": "x"})
|
||||
expect(t, "ticket while support is off", st, body, http.StatusForbidden, "support_disabled")
|
||||
if _, _, page := user.page("/support"); !strings.Contains(page, "switched off") || strings.Contains(page, `href="/support"`) {
|
||||
t.Error("the support page or the menu still offers support while it is off")
|
||||
}
|
||||
if st, _, _ := admin.page("/admin/support/" + refID); st != http.StatusOK {
|
||||
t.Errorf("admins read tickets while support is off = %d", st)
|
||||
}
|
||||
admin.do("PUT", "/api/v1/admin/support/settings", map[string]any{"enabled": true, "max_open_tickets": 0})
|
||||
|
||||
// A suspended account can still ask why, and its export holds the
|
||||
// conversation.
|
||||
if st, body := admin.do("PUT", "/api/v1/admin/users/"+userID.String()+"/suspension", map[string]any{"suspended": true, "reason": "Abuse"}); st != http.StatusNoContent {
|
||||
t.Fatalf("suspend = %d %v", st, body)
|
||||
}
|
||||
user = e.browser(t)
|
||||
if st, body := user.do("POST", "/api/v1/auth/login", map[string]any{"email": userEmail, "password": password}); st != http.StatusOK {
|
||||
t.Fatalf("suspended account signs in = %d %v", st, body)
|
||||
}
|
||||
if _, _, page := user.page("/account/suspended"); !strings.Contains(page, `href="/support"`) {
|
||||
t.Error("the suspension page does not lead to support")
|
||||
}
|
||||
if st, body := user.do("POST", "/api/v1/support/tickets", map[string]any{"subject": "Why?", "message": "I did nothing."}); st != http.StatusCreated {
|
||||
t.Errorf("suspended account opens a ticket = %d %v", st, body)
|
||||
}
|
||||
st, body = user.do("POST", "/api/v1/support/tickets", map[string]any{"subject": "Why, again?", "message": "Hello?"})
|
||||
expect(t, "second ticket of a suspended account", st, body, http.StatusConflict, "suspended_ticket_limit")
|
||||
if st, _, _ := user.page("/support"); st != http.StatusOK {
|
||||
t.Errorf("support page of a suspended account = %d", st)
|
||||
}
|
||||
_, _, export := user.download("/api/v1/me/export")
|
||||
if !strings.Contains(string(export), "Checks are late") || !strings.Contains(string(export), "Fixed, sorry!") {
|
||||
t.Error("the account export lacks the tickets")
|
||||
}
|
||||
}
|
||||
|
||||
func adminEmailOf(t *testing.T, b *browser) string {
|
||||
t.Helper()
|
||||
_, me := b.do("GET", "/api/v1/me", nil)
|
||||
email, _ := me["email"].(string)
|
||||
if email == "" {
|
||||
t.Fatalf("no email in %v", me)
|
||||
}
|
||||
return email
|
||||
}
|
||||
@@ -101,7 +101,10 @@ type API struct {
|
||||
// AgentImage is the image name agents are installed and updated from;
|
||||
// "-checker" or "-statuspage" is appended. Change it for a mirror.
|
||||
AgentImage string `env:"UPTIME_AGENT_IMAGE" envDefault:"git.zb-server.de/zb-server/uptimesebi"`
|
||||
Retention Retention
|
||||
// RegionAlertAfter is how long a region with monitors may have no live
|
||||
// checker before its admins or owners are told; 0 disables it.
|
||||
RegionAlertAfter time.Duration `env:"UPTIME_REGION_ALERT_AFTER" envDefault:"5m"`
|
||||
Retention Retention
|
||||
}
|
||||
|
||||
// Retention sets how long data is kept. Zero keeps it forever.
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
// Package evaluate turns per-region check results into a monitor state.
|
||||
//
|
||||
// A monitor goes down only when every region it is assigned to has failed
|
||||
// the configured number of times in a row and reported recently. A region
|
||||
// without recent results counts as unknown and keeps the monitor up: one
|
||||
// checker losing its network must not page anyone. Any successful region
|
||||
// A monitor goes down when every region it is assigned to that reported
|
||||
// recently has failed the configured number of times in a row: one region
|
||||
// failing while another succeeds is the checker's problem, not the
|
||||
// target's. A region without recent results counts as unknown and is left
|
||||
// out, so a dead region neither keeps a monitor up nor takes it down; with
|
||||
// every region unknown nothing is judged at all. Any successful region
|
||||
// brings the monitor back up.
|
||||
//
|
||||
// The state lives in Redis and each observation is applied by one Lua
|
||||
@@ -53,9 +55,9 @@ type Observation struct {
|
||||
Regions []string
|
||||
}
|
||||
|
||||
// staleAfter is how old a region's last result may be before the region
|
||||
// StaleAfter is how old a region's last result may be before the region
|
||||
// counts as unknown.
|
||||
func staleAfter(interval time.Duration) time.Duration {
|
||||
func StaleAfter(interval time.Duration) time.Duration {
|
||||
return max(3*interval, 2*time.Minute)
|
||||
}
|
||||
|
||||
@@ -86,12 +88,17 @@ if state == 'down' then
|
||||
end
|
||||
return 'none'
|
||||
end
|
||||
local reporting = 0
|
||||
for i = 7, #ARGV do
|
||||
local r = ARGV[i]
|
||||
local fails = tonumber(redis.call('HGET', key, 'f:' .. r) or '0')
|
||||
local seen = tonumber(redis.call('HGET', key, 'a:' .. r) or '0')
|
||||
if fails < need or seen < stale then return 'none' end
|
||||
if seen >= stale then
|
||||
local fails = tonumber(redis.call('HGET', key, 'f:' .. r) or '0')
|
||||
if fails < need then return 'none' end
|
||||
reporting = reporting + 1
|
||||
end
|
||||
end
|
||||
if reporting == 0 then return 'none' end
|
||||
redis.call('HSET', key, 'state', 'down')
|
||||
return 'down'
|
||||
`)
|
||||
@@ -113,7 +120,7 @@ func (e *Evaluator) Observe(ctx context.Context, o Observation) (Transition, err
|
||||
if o.OK {
|
||||
ok = "1"
|
||||
}
|
||||
stale := e.now().Add(-staleAfter(o.Interval)).UnixMilli()
|
||||
stale := e.now().Add(-StaleAfter(o.Interval)).UnixMilli()
|
||||
args := []any{o.Region, ok, o.At.UnixMilli(), max(o.Confirmations, 1), stale, int(stateTTL.Seconds())}
|
||||
for _, r := range o.Regions {
|
||||
args = append(args, r)
|
||||
|
||||
@@ -55,9 +55,9 @@ func play(t *testing.T, e *Evaluator, now *time.Time, regions []string, confirma
|
||||
func TestDownOnlyWhenAllRegionsFail(t *testing.T) {
|
||||
e, now := newTest(t)
|
||||
play(t, e, now, []string{"eu", "us"}, 2, []step{
|
||||
{"eu", false, None},
|
||||
{"eu", false, None}, // eu confirmed down, us has not reported
|
||||
{"us", true, None},
|
||||
{"eu", false, None},
|
||||
{"eu", false, None}, // eu confirmed down, us still fine
|
||||
{"us", false, None},
|
||||
{"eu", false, None},
|
||||
{"us", false, Down}, // both regions failed twice in a row
|
||||
@@ -79,7 +79,7 @@ func TestSingleRegionWithConfirmations(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestSilentRegionBlocksAlert(t *testing.T) {
|
||||
func TestSilentRegionIsLeftOut(t *testing.T) {
|
||||
e, now := newTest(t)
|
||||
id := uuid.New()
|
||||
obs := func(region string, ok bool) Transition {
|
||||
@@ -92,12 +92,27 @@ func TestSilentRegionBlocksAlert(t *testing.T) {
|
||||
}
|
||||
return got
|
||||
}
|
||||
obs("us", false)
|
||||
// us stops reporting for longer than three intervals.
|
||||
obs("us", true)
|
||||
// us stops reporting for longer than three intervals: the failures of
|
||||
// eu alone decide.
|
||||
*now = now.Add(5 * time.Minute)
|
||||
if got := obs("eu", false); got != None {
|
||||
t.Errorf("eu failure with us silent = %v, want none", got)
|
||||
if got := obs("eu", false); got != Down {
|
||||
t.Errorf("eu failure with us silent = %v, want down", got)
|
||||
}
|
||||
// us reporting a success again brings the monitor back up.
|
||||
*now = now.Add(time.Second)
|
||||
if got := obs("us", true); got != Up {
|
||||
t.Errorf("us success after the outage = %v, want up", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestReportingRegionStillVetoes(t *testing.T) {
|
||||
e, now := newTest(t)
|
||||
play(t, e, now, []string{"eu", "us"}, 1, []step{
|
||||
{"us", true, None},
|
||||
{"eu", false, None}, // us reported recently and was fine
|
||||
{"eu", false, None},
|
||||
})
|
||||
}
|
||||
|
||||
func TestOutOfOrderResultIgnored(t *testing.T) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"admin.check_types": "Check-Typen",
|
||||
"admin.check_types_intro": "Schalte Typen ab, die diese Installation nicht anbieten kann, etwa Docker auf geteilten Cloud-Checkern oder ICMP ohne die nötigen Rechte. Sie verschwinden für neue Monitore; bestehende laufen weiter.",
|
||||
"admin.check_types_intro": "Schalte Typen ab, die die Checker der Plattform nicht anbieten können, etwa Docker auf geteilten Cloud-Checkern oder ICMP ohne die nötigen Rechte. Organisationen behalten sie für ihre eigenen Checker; bestehende Monitore laufen weiter.",
|
||||
"admin.checker_network": "Checker-Netzwerk",
|
||||
"admin.intro": "Hier angelegte Regionen, Checker und Statuspage-Server stehen allen Organisationen zur Verfügung. Organisationen legen ihre eigenen unter Regionen & Checker an.",
|
||||
"admin.platform_private": "Plattform-Checker dürfen private Adressen prüfen",
|
||||
@@ -151,6 +151,11 @@
|
||||
"audit.action.statuspage.groups_import": "Statusseiten-Gruppen aus Monitor-Gruppen übernommen",
|
||||
"audit.action.statuspage.monitors_update": "Monitore der Statusseite geändert",
|
||||
"audit.action.statuspage.update": "Statusseite geändert",
|
||||
"audit.action.support.answer": "Support-Ticket beantwortet",
|
||||
"audit.action.support.create": "Support-Ticket eröffnet",
|
||||
"audit.action.support.reply": "Auf Support-Ticket geantwortet",
|
||||
"audit.action.support.settings": "Support-Einstellungen geändert",
|
||||
"audit.action.support.status": "Status eines Support-Tickets geändert",
|
||||
"audit.action.token.create": "API-Token erstellt",
|
||||
"audit.action.token.delete": "API-Token widerrufen",
|
||||
"audit.deleted_user": "Gelöschter Benutzer",
|
||||
@@ -497,6 +502,7 @@
|
||||
"console.nav.admin": "Admin",
|
||||
"console.nav.logout": "Abmelden",
|
||||
"console.nav.members": "Mitglieder",
|
||||
"console.nav.menu": "Menü",
|
||||
"console.nav.org": "Organisation",
|
||||
"console.nav.regions": "Regionen & Checker",
|
||||
"console.nav.roles": "Rollen",
|
||||
@@ -510,8 +516,16 @@
|
||||
"console.totp_missing_action": "Jetzt einrichten",
|
||||
"email.opened.body": "{{.Monitor}} ({{.Target}}) ist in allen Regionen nicht erreichbar seit {{.Since}}.\n\nLetzte Fehler:\n{{.Cause}}\n\nDu erhältst diese Nachricht, weil ein Benachrichtigungskanal deiner Organisation diese Adresse nutzt.",
|
||||
"email.opened.subject": "[DOWN] {{.Monitor}}",
|
||||
"email.region_back.body": "Region {{.Region}} hat wieder einen aktiven Checker; seit {{.Since}} hatte sie keinen. Überfällige Prüfungen laufen sofort.\n\n{{.Link}}",
|
||||
"email.region_back.subject": "Region {{.Region}} prüft wieder",
|
||||
"email.region_down.body": "Region {{.Region}} hat seit {{.Minutes}} Minuten keinen aktiven Checker, seit {{.Since}}.\n\nMonitore, die nur von dort geprüft werden, werden gerade nicht geprüft: Sie fallen weder aus noch alarmieren sie. Monitore mit weiteren Regionen werden nur nach diesen beurteilt, bis diese Region wieder meldet.\n\nStarte einen Checker der Region oder sieh dir seine Logs an:\n{{.Link}}",
|
||||
"email.region_down.subject": "Region {{.Region}} hat keinen aktiven Checker",
|
||||
"email.resolved.body": "{{.Monitor}} ({{.Target}}) ist nach {{.Duration}} wieder erreichbar.",
|
||||
"email.resolved.subject": "[UP] {{.Monitor}}",
|
||||
"email.support_admin.body": "Hallo,\n\nein Support-Ticket wartet auf eine Antwort:\n\n{{.Subject}}\n\n{{.Link}}",
|
||||
"email.support_admin.subject": "Support-Ticket: {{.Subject}}",
|
||||
"email.support_reply.body": "Hallo,\n\nder Support hat dein Ticket „{{.Subject}}“ beantwortet:\n\n{{.Link}}\n\nWenn du weitere Fragen hast, antworte einfach dort.",
|
||||
"email.support_reply.subject": "Antwort auf dein Support-Ticket: {{.Subject}}",
|
||||
"email.test.body": "Dies ist ein Test. Wenn du ihn lesen kannst, funktioniert der Kanal.",
|
||||
"email.test.subject": "Testbenachrichtigung von UptimeSebi",
|
||||
"email.verify.body": "Hallo,\n\nbitte bestätige deine E-Mail-Adresse, um die Registrierung abzuschließen:\n\n{{.Link}}\n\nDer Link ist {{.Hours}} Stunden gültig. Wenn du dich nicht registriert hast, ignoriere diese E-Mail; das Konto wird nach einer Woche gelöscht.",
|
||||
@@ -525,6 +539,7 @@
|
||||
"error.channel_test_failed": "Die Testbenachrichtigung konnte nicht zugestellt werden.",
|
||||
"error.channel_type_immutable": "Der Typ eines Kanals kann nicht geändert werden.",
|
||||
"error.check_type_disabled": "Dieser Check-Typ ist für diese Organisation oder Installation abgeschaltet.",
|
||||
"error.check_type_own_checkers_only": "Die Checker der Plattform führen diesen Check-Typ nicht aus. Wähle nur eigene Regionen deiner Organisation.",
|
||||
"error.confirmation_failed": "Die Bestätigung stimmt nicht.",
|
||||
"error.consent_outdated": "Die Dokumente haben sich inzwischen geändert. Lade die Seite neu und stimme der aktuellen Fassung zu.",
|
||||
"error.consent_required": "Bitte stimme zuerst Datenschutz und AGB zu.",
|
||||
@@ -632,11 +647,14 @@
|
||||
"error.status_in_use": "Updates benutzen diesen Status; er bleibt, damit ihr Verlauf verständlich bleibt. Benenne ihn um oder ändere die Farbe.",
|
||||
"error.status_name_taken": "Einen Status mit diesem Namen gibt es schon.",
|
||||
"error.status_page_limit": "Deine Organisation hat ihr Limit von {{.Max}} Statusseiten erreicht.",
|
||||
"error.support_disabled": "Support-Tickets sind auf dieser Plattform abgeschaltet.",
|
||||
"error.suspended_ticket_limit": "Solange dein Konto gesperrt ist, kannst du ein Ticket eröffnen. Antworte stattdessen darauf.",
|
||||
"error.target_is_admin": "Plattform-Admins können hier nicht gesperrt oder gelöscht werden.",
|
||||
"error.token_lifetime_exceeds_policy": {
|
||||
"one": "Tokens in dieser Organisation müssen innerhalb von {{.Count}} Tag ablaufen.",
|
||||
"other": "Tokens in dieser Organisation müssen innerhalb von {{.Count}} Tagen ablaufen."
|
||||
},
|
||||
"error.too_many_tickets": "Du kannst {{.Count}} offene Tickets gleichzeitig haben. Schließe eins oder antworte stattdessen darauf.",
|
||||
"error.totp_already_enabled": "TOTP ist bereits aktiv.",
|
||||
"error.totp_required_by_org": "Eine deiner Organisationen verlangt TOTP.",
|
||||
"error.totp_setup_expired": "Einrichtung abgelaufen, bitte neu starten.",
|
||||
@@ -695,6 +713,7 @@
|
||||
"export.field.api_tokens": "API-Tokens",
|
||||
"export.field.audit_log": "Audit-Log",
|
||||
"export.field.avg_latency_ms": "Mittlere Latenz (ms)",
|
||||
"export.field.body": "Text",
|
||||
"export.field.cause": "Ursache",
|
||||
"export.field.client_id": "Client-ID",
|
||||
"export.field.config": "Konfiguration",
|
||||
@@ -711,6 +730,7 @@
|
||||
"export.field.email": "E-Mail",
|
||||
"export.field.enabled": "Aktiv",
|
||||
"export.field.expires_at": "Läuft ab",
|
||||
"export.field.from_staff": "Vom Support",
|
||||
"export.field.generated_at": "Erstellt am",
|
||||
"export.field.group_id": "Gruppe",
|
||||
"export.field.has_password": "Passwort gesetzt",
|
||||
@@ -727,6 +747,7 @@
|
||||
"export.field.member_since": "Mitglied seit",
|
||||
"export.field.members": "Mitglieder",
|
||||
"export.field.message": "Nachricht",
|
||||
"export.field.messages": "Nachrichten",
|
||||
"export.field.monitor": "Monitor",
|
||||
"export.field.monitor_groups": "Monitorgruppen",
|
||||
"export.field.monitor_id": "Monitor-ID",
|
||||
@@ -762,6 +783,7 @@
|
||||
"export.field.status": "Status",
|
||||
"export.field.status_pages": "Statusseiten",
|
||||
"export.field.subject": "Subjekt",
|
||||
"export.field.support_tickets": "Support-Tickets",
|
||||
"export.field.target": "Ziel",
|
||||
"export.field.target_id": "Ziel",
|
||||
"export.field.time": "Zeit",
|
||||
@@ -1027,6 +1049,7 @@
|
||||
"monitors.db_tls_verify": "TLS mit geprüftem Zertifikat",
|
||||
"monitors.db_user": "Benutzer",
|
||||
"monitors.db_user_redis": "Benutzer (ACL, optional)",
|
||||
"monitors.dead_region": "Region {{.Region}} hat seit {{.Since}} keinen aktiven Checker.",
|
||||
"monitors.delete": "Monitor löschen",
|
||||
"monitors.delete_confirm": "Diesen Monitor samt Verlauf löschen?",
|
||||
"monitors.dns_expect": "Erwartete Antwort (optional)",
|
||||
@@ -1063,6 +1086,7 @@
|
||||
"monitors.minecraft_hint": "Ziel ist host:port (Java meist 25565, Bedrock 19132). Pingt den Server wie die Serverliste im Spiel.",
|
||||
"monitors.minecraft_java": "Java Edition",
|
||||
"monitors.new": "Neuer Monitor",
|
||||
"monitors.no_data_since": "keine Daten seit {{.Time}}",
|
||||
"monitors.no_match": "Kein Monitor gefunden.",
|
||||
"monitors.no_results": "Noch keine Ergebnisse.",
|
||||
"monitors.op_absent": "fehlt",
|
||||
@@ -1138,6 +1162,7 @@
|
||||
"monitors.type_mqtt": "MQTT",
|
||||
"monitors.type_mssql": "Microsoft SQL Server",
|
||||
"monitors.type_mysql": "MySQL / MariaDB",
|
||||
"monitors.type_own_only": "nur eigene Checker",
|
||||
"monitors.type_postgres": "PostgreSQL",
|
||||
"monitors.type_prometheus": "Prometheus",
|
||||
"monitors.type_rabbitmq": "RabbitMQ",
|
||||
@@ -1148,6 +1173,11 @@
|
||||
"monitors.type_steam": "Steam-Spieleserver",
|
||||
"monitors.type_tcp": "TCP-Port",
|
||||
"monitors.type_tls": "TLS-Zertifikat",
|
||||
"monitors.unchecked": "wird nicht geprüft",
|
||||
"monitors.unchecked_banner": {
|
||||
"one": "1 Monitor wird gerade nicht geprüft: Keine Region hat für ihn in letzter Zeit gemeldet. Er fällt weder aus noch alarmiert er, bis wieder ein Checker meldet.",
|
||||
"other": "{{.Count}} Monitore werden gerade nicht geprüft: Keine Region hat für sie in letzter Zeit gemeldet. Sie fallen weder aus noch alarmieren sie, bis wieder ein Checker meldet."
|
||||
},
|
||||
"monitors.ungrouped": "Ohne Gruppe",
|
||||
"monitors.uptime_chart": "Uptime pro Zeitraum",
|
||||
"monitors.verify_tls": "TLS-Zertifikat prüfen",
|
||||
@@ -1156,7 +1186,8 @@
|
||||
"notify.title_opened": "{{.Monitor}} ist ausgefallen",
|
||||
"notify.title_resolved": "{{.Monitor}} ist wieder erreichbar",
|
||||
"notify.title_test": "Test von UptimeSebi",
|
||||
"org.check_types_intro": "Monitor-Typen, die den Mitgliedern dieser Organisation angeboten werden, aus denen, die diese Installation anbietet. Bestehende Monitore eines abgeschalteten Typs laufen weiter.",
|
||||
"org.check_type_own_only": "nur eigene Checker",
|
||||
"org.check_types_intro": "Monitor-Typen, die den Mitgliedern dieser Organisation angeboten werden. Typen, die die Checker der Plattform nicht ausführen, laufen nur auf euren eigenen Checkern. Bestehende Monitore eines abgeschalteten Typs laufen weiter.",
|
||||
"org.policy": "Anmelderichtlinie",
|
||||
"org.require_sso": "SSO verlangen",
|
||||
"org.require_sso_hint": "Mitglieder müssen sich über den Identity Provider dieser Organisation anmelden. Der Owner kann weiterhin ein Passwort nutzen, damit ein defekter IdP euch nicht aussperrt.",
|
||||
@@ -1236,6 +1267,8 @@
|
||||
"pages.logo": "Logo-URL (https)",
|
||||
"pages.no_group": "Ohne Gruppe",
|
||||
"pages.open": "Öffnen",
|
||||
"pages.own_servers": "Die Statusseiten dieser Organisation liefern nur ihre eigenen Statusseiten-Server aus, nicht die der Plattform. Ruf sie über die Adresse deiner Server auf oder verbinde eine eigene Domain, die auf sie zeigt.",
|
||||
"pages.own_servers_short": "eigene Server",
|
||||
"pages.page_title": "Titel",
|
||||
"pages.published": "Veröffentlicht",
|
||||
"pages.section": "Abschnitt",
|
||||
@@ -1379,6 +1412,76 @@
|
||||
"storage.retention": "Löschen nach",
|
||||
"storage.size": "Größe",
|
||||
"storage.title": "Datenspeicher",
|
||||
"support.account": "Konto",
|
||||
"support.account.active": "aktiv",
|
||||
"support.account.created": "Erstellt",
|
||||
"support.account.email": "E-Mail",
|
||||
"support.account.email_verified": "E-Mail bestätigt",
|
||||
"support.account.locale": "Sprache",
|
||||
"support.account.monitors": "Monitore",
|
||||
"support.account.name": "Name",
|
||||
"support.account.open_tickets": "Offene Tickets",
|
||||
"support.account.org_suspended": "Organisation gesperrt",
|
||||
"support.account.orgs": "Organisationen",
|
||||
"support.account.orgs_owned": "Eigene Organisationen",
|
||||
"support.account.owner": "Owner",
|
||||
"support.account.password": "Passwort",
|
||||
"support.account.regions": "Regionen pro Monitor",
|
||||
"support.account.role": "Rolle",
|
||||
"support.account.sign_in": "Anmeldung",
|
||||
"support.account.sso_only": "nur SSO",
|
||||
"support.account.state": "Zustand",
|
||||
"support.account.status_pages": "Statusseiten",
|
||||
"support.account.suspended": "gesperrt",
|
||||
"support.account.this_ticket": "im Ticket genannt",
|
||||
"support.admin_intro": "Tickets aller Konten. Eine Antwort wird dem Konto per E-Mail angekündigt; schreibt es zurück, ist das Ticket wieder offen.",
|
||||
"support.admin_title": "Support-Tickets",
|
||||
"support.all": "Alle Tickets",
|
||||
"support.attach": "Details anhängen (optional)",
|
||||
"support.attach_hint": "Zeig dem Support, worum es geht – aus der aktiven Organisation.",
|
||||
"support.attach_none": "keine Auswahl",
|
||||
"support.attach_org": "Organisation {{.Org}}",
|
||||
"support.close": "Ticket schließen",
|
||||
"support.closed_hint": "Dieses Ticket ist geschlossen. Mit einer Antwort öffnest du es wieder.",
|
||||
"support.contact": "Support kontaktieren",
|
||||
"support.disabled": "Support-Tickets sind gerade abgeschaltet.",
|
||||
"support.filter": "Tickets filtern",
|
||||
"support.filter.all": "Alle",
|
||||
"support.filter.answered": "Beantwortet",
|
||||
"support.filter.closed": "Geschlossen",
|
||||
"support.filter.open": "Offen",
|
||||
"support.from_staff": "Support",
|
||||
"support.from_you": "Du",
|
||||
"support.intro": "Fragen, Probleme oder Feedback? Schreib dem Support der Plattform. Sobald er antwortet, bekommst du eine E-Mail.",
|
||||
"support.message": "Nachricht",
|
||||
"support.mine": "Deine Tickets",
|
||||
"support.new": "Neues Ticket",
|
||||
"support.no": "nein",
|
||||
"support.none": "Du hast noch keine Tickets eröffnet.",
|
||||
"support.none_admin": "Hier gibt es keine Tickets.",
|
||||
"support.ref.alert_group": "Alertgruppe",
|
||||
"support.ref.channel": "Alert-Typ (Benachrichtigungskanal)",
|
||||
"support.ref.incident": "Incident",
|
||||
"support.ref.monitor": "Monitor",
|
||||
"support.ref.org": "Organisation",
|
||||
"support.ref.status_page": "Statusseite",
|
||||
"support.reopen": "Ticket wieder öffnen",
|
||||
"support.reply": "Antworten",
|
||||
"support.send": "Senden",
|
||||
"support.settings": "Einstellungen",
|
||||
"support.settings.enabled": "Konten können Support-Tickets eröffnen",
|
||||
"support.settings.enabled_hint": "Abgeschaltet verschwinden die Support-Seiten für Konten; die bestehenden Tickets bleiben hier erhalten.",
|
||||
"support.settings.max_open": "Offene Tickets pro Konto",
|
||||
"support.settings.max_open_hint": "Offene und beantwortete Tickets zählen; 0 heißt unbegrenzt. Gesperrte Konten können ein Ticket eröffnen.",
|
||||
"support.settings.off": "aus",
|
||||
"support.settings.on": "an",
|
||||
"support.settings.save": "Speichern",
|
||||
"support.status.answered": "beantwortet",
|
||||
"support.status.closed": "geschlossen",
|
||||
"support.status.open": "offen",
|
||||
"support.subject": "Betreff",
|
||||
"support.title": "Support",
|
||||
"support.yes": "ja",
|
||||
"suspended.intro": "Die Administratoren der Plattform haben dein Konto gesperrt.",
|
||||
"suspended.options": "Du kannst deine Daten weiterhin herunterladen oder dein Konto löschen.",
|
||||
"suspended.title": "Konto gesperrt",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"admin.check_types": "Check types",
|
||||
"admin.check_types_intro": "Switch off types this installation cannot offer, such as Docker on shared cloud checkers or ICMP without the needed privileges. They disappear for new monitors; existing monitors keep running.",
|
||||
"admin.check_types_intro": "Switch off types the platform's checkers cannot offer, such as Docker on shared cloud checkers or ICMP without the needed privileges. Organizations keep them for their own checkers; existing monitors keep running.",
|
||||
"admin.checker_network": "Checker network",
|
||||
"admin.intro": "Regions, checkers and status page servers created here are shared by every organization. Organizations add their own under Regions & checkers.",
|
||||
"admin.platform_private": "Platform checkers may check private addresses",
|
||||
@@ -151,6 +151,11 @@
|
||||
"audit.action.statuspage.groups_import": "Status page groups imported from monitor groups",
|
||||
"audit.action.statuspage.monitors_update": "Status page monitors changed",
|
||||
"audit.action.statuspage.update": "Status page changed",
|
||||
"audit.action.support.answer": "Support ticket answered",
|
||||
"audit.action.support.create": "Support ticket opened",
|
||||
"audit.action.support.reply": "Support ticket replied to",
|
||||
"audit.action.support.settings": "Support settings changed",
|
||||
"audit.action.support.status": "Support ticket status changed",
|
||||
"audit.action.token.create": "API token created",
|
||||
"audit.action.token.delete": "API token revoked",
|
||||
"audit.deleted_user": "Deleted user",
|
||||
@@ -497,6 +502,7 @@
|
||||
"console.nav.admin": "Admin",
|
||||
"console.nav.logout": "Sign out",
|
||||
"console.nav.members": "Members",
|
||||
"console.nav.menu": "Menu",
|
||||
"console.nav.org": "Organization",
|
||||
"console.nav.regions": "Regions & checkers",
|
||||
"console.nav.roles": "Roles",
|
||||
@@ -510,8 +516,16 @@
|
||||
"console.totp_missing_action": "Set up now",
|
||||
"email.opened.body": "{{.Monitor}} ({{.Target}}) is down in all of its regions since {{.Since}}.\n\nLast errors:\n{{.Cause}}\n\nYou receive this because a notification channel of your organization is set up for this address.",
|
||||
"email.opened.subject": "[DOWN] {{.Monitor}}",
|
||||
"email.region_back.body": "Region {{.Region}} has an active checker again; it had none since {{.Since}}. Overdue checks run right away.\n\n{{.Link}}",
|
||||
"email.region_back.subject": "Region {{.Region}} is checking again",
|
||||
"email.region_down.body": "Region {{.Region}} has had no active checker for {{.Minutes}} minutes, since {{.Since}}.\n\nMonitors checked only from there are not being checked right now: they neither go down nor alert. Monitors with other regions as well are judged by those alone until this one reports again.\n\nStart a checker of the region or look at its logs:\n{{.Link}}",
|
||||
"email.region_down.subject": "Region {{.Region}} has no active checker",
|
||||
"email.resolved.body": "{{.Monitor}} ({{.Target}}) is reachable again after {{.Duration}}.",
|
||||
"email.resolved.subject": "[UP] {{.Monitor}}",
|
||||
"email.support_admin.body": "Hello,\n\na support ticket waits for an answer:\n\n{{.Subject}}\n\n{{.Link}}",
|
||||
"email.support_admin.subject": "Support ticket: {{.Subject}}",
|
||||
"email.support_reply.body": "Hello,\n\nthe support team answered your ticket \"{{.Subject}}\":\n\n{{.Link}}\n\nReply there if you have further questions.",
|
||||
"email.support_reply.subject": "Answer to your support ticket: {{.Subject}}",
|
||||
"email.test.body": "This is a test. If you can read it, the channel works.",
|
||||
"email.test.subject": "Test notification from UptimeSebi",
|
||||
"email.verify.body": "Hello,\n\nplease confirm your email address to finish signing up:\n\n{{.Link}}\n\nThe link is valid for {{.Hours}} hours. If you did not sign up, ignore this email; the account is deleted after a week.",
|
||||
@@ -525,6 +539,7 @@
|
||||
"error.channel_test_failed": "The test notification could not be delivered.",
|
||||
"error.channel_type_immutable": "The type of a channel cannot be changed.",
|
||||
"error.check_type_disabled": "This check type is switched off for this organization or installation.",
|
||||
"error.check_type_own_checkers_only": "The platform's checkers do not run this check type. Choose only your organization's own regions.",
|
||||
"error.confirmation_failed": "The confirmation does not match.",
|
||||
"error.consent_outdated": "The documents changed in the meantime. Reload the page and accept the current version.",
|
||||
"error.consent_required": "Please accept the privacy policy and terms first.",
|
||||
@@ -632,11 +647,14 @@
|
||||
"error.status_in_use": "Updates use this status; it stays so their history keeps its meaning. Rename or recolor it instead.",
|
||||
"error.status_name_taken": "A status with this name exists already.",
|
||||
"error.status_page_limit": "Your organization has reached its limit of {{.Max}} status pages.",
|
||||
"error.support_disabled": "Support tickets are switched off on this platform.",
|
||||
"error.suspended_ticket_limit": "While your account is suspended you can open one ticket. Reply to it instead.",
|
||||
"error.target_is_admin": "Platform admins cannot be suspended or deleted here.",
|
||||
"error.token_lifetime_exceeds_policy": {
|
||||
"one": "Tokens in this organization must expire within {{.Count}} day.",
|
||||
"other": "Tokens in this organization must expire within {{.Count}} days."
|
||||
},
|
||||
"error.too_many_tickets": "You can have {{.Count}} open tickets at the same time. Close one or reply to it instead.",
|
||||
"error.totp_already_enabled": "TOTP is already active.",
|
||||
"error.totp_required_by_org": "One of your organizations requires TOTP.",
|
||||
"error.totp_setup_expired": "Setup expired, please start again.",
|
||||
@@ -695,6 +713,7 @@
|
||||
"export.field.api_tokens": "API tokens",
|
||||
"export.field.audit_log": "Audit log",
|
||||
"export.field.avg_latency_ms": "Average latency (ms)",
|
||||
"export.field.body": "Text",
|
||||
"export.field.cause": "Cause",
|
||||
"export.field.client_id": "Client ID",
|
||||
"export.field.config": "Configuration",
|
||||
@@ -711,6 +730,7 @@
|
||||
"export.field.email": "Email",
|
||||
"export.field.enabled": "Enabled",
|
||||
"export.field.expires_at": "Expires",
|
||||
"export.field.from_staff": "From support",
|
||||
"export.field.generated_at": "Generated",
|
||||
"export.field.group_id": "Group",
|
||||
"export.field.has_password": "Password set",
|
||||
@@ -727,6 +747,7 @@
|
||||
"export.field.member_since": "Member since",
|
||||
"export.field.members": "Members",
|
||||
"export.field.message": "Message",
|
||||
"export.field.messages": "Messages",
|
||||
"export.field.monitor": "Monitor",
|
||||
"export.field.monitor_groups": "Monitor groups",
|
||||
"export.field.monitor_id": "Monitor ID",
|
||||
@@ -762,6 +783,7 @@
|
||||
"export.field.status": "Status",
|
||||
"export.field.status_pages": "Status pages",
|
||||
"export.field.subject": "Subject",
|
||||
"export.field.support_tickets": "Support tickets",
|
||||
"export.field.target": "Target",
|
||||
"export.field.target_id": "Target",
|
||||
"export.field.time": "Time",
|
||||
@@ -1027,6 +1049,7 @@
|
||||
"monitors.db_tls_verify": "TLS with verified certificate",
|
||||
"monitors.db_user": "User",
|
||||
"monitors.db_user_redis": "User (ACL, optional)",
|
||||
"monitors.dead_region": "Region {{.Region}} has had no active checker since {{.Since}}.",
|
||||
"monitors.delete": "Delete monitor",
|
||||
"monitors.delete_confirm": "Delete this monitor and its history?",
|
||||
"monitors.dns_expect": "Expected answer (optional)",
|
||||
@@ -1063,6 +1086,7 @@
|
||||
"monitors.minecraft_hint": "Target is host:port (Java usually 25565, Bedrock 19132). Pings the server like the in-game server list.",
|
||||
"monitors.minecraft_java": "Java Edition",
|
||||
"monitors.new": "New monitor",
|
||||
"monitors.no_data_since": "no data since {{.Time}}",
|
||||
"monitors.no_match": "No monitor matches.",
|
||||
"monitors.no_results": "No results yet.",
|
||||
"monitors.op_absent": "is absent",
|
||||
@@ -1138,6 +1162,7 @@
|
||||
"monitors.type_mqtt": "MQTT",
|
||||
"monitors.type_mssql": "Microsoft SQL Server",
|
||||
"monitors.type_mysql": "MySQL / MariaDB",
|
||||
"monitors.type_own_only": "own checkers only",
|
||||
"monitors.type_postgres": "PostgreSQL",
|
||||
"monitors.type_prometheus": "Prometheus",
|
||||
"monitors.type_rabbitmq": "RabbitMQ",
|
||||
@@ -1148,6 +1173,11 @@
|
||||
"monitors.type_steam": "Steam game server",
|
||||
"monitors.type_tcp": "TCP port",
|
||||
"monitors.type_tls": "TLS certificate",
|
||||
"monitors.unchecked": "not being checked",
|
||||
"monitors.unchecked_banner": {
|
||||
"one": "1 monitor is not being checked: no region has reported for it recently. It neither goes down nor alerts until a checker reports again.",
|
||||
"other": "{{.Count}} monitors are not being checked: no region has reported for them recently. They neither go down nor alert until a checker reports again."
|
||||
},
|
||||
"monitors.ungrouped": "Without group",
|
||||
"monitors.uptime_chart": "Uptime per period",
|
||||
"monitors.verify_tls": "Verify TLS certificate",
|
||||
@@ -1156,7 +1186,8 @@
|
||||
"notify.title_opened": "{{.Monitor}} is down",
|
||||
"notify.title_resolved": "{{.Monitor}} is up again",
|
||||
"notify.title_test": "Test from UptimeSebi",
|
||||
"org.check_types_intro": "Monitor types offered to the members of this organization, out of those this installation offers. Existing monitors of a switched-off type keep running.",
|
||||
"org.check_type_own_only": "own checkers only",
|
||||
"org.check_types_intro": "Monitor types offered to the members of this organization. Types the platform's checkers do not run work on your own checkers only. Existing monitors of a switched-off type keep running.",
|
||||
"org.policy": "Sign-in policy",
|
||||
"org.require_sso": "Require SSO",
|
||||
"org.require_sso_hint": "Members must sign in through this organization's identity provider. The owner can still use a password so a broken IdP cannot lock you out.",
|
||||
@@ -1236,6 +1267,8 @@
|
||||
"pages.logo": "Logo URL (https)",
|
||||
"pages.no_group": "No group",
|
||||
"pages.open": "Open",
|
||||
"pages.own_servers": "Your organization's own status page servers serve its pages; the platform's do not. Open them at the address of your servers or connect a custom domain pointing at them.",
|
||||
"pages.own_servers_short": "own servers",
|
||||
"pages.page_title": "Title",
|
||||
"pages.published": "Published",
|
||||
"pages.section": "Section",
|
||||
@@ -1379,6 +1412,76 @@
|
||||
"storage.retention": "Delete after",
|
||||
"storage.size": "Size",
|
||||
"storage.title": "Data storage",
|
||||
"support.account": "Account",
|
||||
"support.account.active": "active",
|
||||
"support.account.created": "Created",
|
||||
"support.account.email": "Email",
|
||||
"support.account.email_verified": "Email verified",
|
||||
"support.account.locale": "Language",
|
||||
"support.account.monitors": "Monitors",
|
||||
"support.account.name": "Name",
|
||||
"support.account.open_tickets": "Open tickets",
|
||||
"support.account.org_suspended": "Organization suspended",
|
||||
"support.account.orgs": "Organizations",
|
||||
"support.account.orgs_owned": "Organizations owned",
|
||||
"support.account.owner": "Owner",
|
||||
"support.account.password": "Password",
|
||||
"support.account.regions": "Regions per monitor",
|
||||
"support.account.role": "Role",
|
||||
"support.account.sign_in": "Sign-in",
|
||||
"support.account.sso_only": "SSO only",
|
||||
"support.account.state": "State",
|
||||
"support.account.status_pages": "Status pages",
|
||||
"support.account.suspended": "suspended",
|
||||
"support.account.this_ticket": "named in the ticket",
|
||||
"support.admin_intro": "Tickets of every account. Answering mails the account; its reply puts the ticket back among the open ones.",
|
||||
"support.admin_title": "Support tickets",
|
||||
"support.all": "All tickets",
|
||||
"support.attach": "Attach details (optional)",
|
||||
"support.attach_hint": "Point the support team at what your question is about, from the active organization.",
|
||||
"support.attach_none": "none",
|
||||
"support.attach_org": "Organization {{.Org}}",
|
||||
"support.close": "Close ticket",
|
||||
"support.closed_hint": "This ticket is closed. Replying opens it again.",
|
||||
"support.contact": "Contact support",
|
||||
"support.disabled": "Support tickets are switched off at the moment.",
|
||||
"support.filter": "Filter tickets",
|
||||
"support.filter.all": "All",
|
||||
"support.filter.answered": "Answered",
|
||||
"support.filter.closed": "Closed",
|
||||
"support.filter.open": "Open",
|
||||
"support.from_staff": "Support",
|
||||
"support.from_you": "You",
|
||||
"support.intro": "Questions, problems or feedback? Write to the platform's support team. You get an email as soon as they answer.",
|
||||
"support.message": "Message",
|
||||
"support.mine": "Your tickets",
|
||||
"support.new": "New ticket",
|
||||
"support.no": "no",
|
||||
"support.none": "You have not opened any tickets yet.",
|
||||
"support.none_admin": "No tickets here.",
|
||||
"support.ref.alert_group": "Alert group",
|
||||
"support.ref.channel": "Alert type (notification channel)",
|
||||
"support.ref.incident": "Incident",
|
||||
"support.ref.monitor": "Monitor",
|
||||
"support.ref.org": "Organization",
|
||||
"support.ref.status_page": "Status page",
|
||||
"support.reopen": "Reopen ticket",
|
||||
"support.reply": "Reply",
|
||||
"support.send": "Send",
|
||||
"support.settings": "Settings",
|
||||
"support.settings.enabled": "Accounts can open support tickets",
|
||||
"support.settings.enabled_hint": "Switched off, the support pages disappear for accounts; you keep the existing tickets here.",
|
||||
"support.settings.max_open": "Open tickets per account",
|
||||
"support.settings.max_open_hint": "Open and answered tickets count; 0 means unlimited. Suspended accounts can open one ticket.",
|
||||
"support.settings.off": "off",
|
||||
"support.settings.on": "on",
|
||||
"support.settings.save": "Save",
|
||||
"support.status.answered": "answered",
|
||||
"support.status.closed": "closed",
|
||||
"support.status.open": "open",
|
||||
"support.subject": "Subject",
|
||||
"support.title": "Support",
|
||||
"support.yes": "yes",
|
||||
"suspended.intro": "The platform's administrators have suspended your account.",
|
||||
"suspended.options": "You can still download your data or delete your account.",
|
||||
"suspended.title": "Account suspended",
|
||||
|
||||
@@ -34,6 +34,15 @@ func TestAlertGroupsBackfill(t *testing.T) {
|
||||
if _, err := tx.Exec(ctx, "SET LOCAL app.scope = 'system'"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// Support tickets point at alert groups; take them back first.
|
||||
later, err := files.ReadFile("sql/00051_support_tickets.sql")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_, laterDown, _ := strings.Cut(string(later), "-- +goose Down")
|
||||
if _, err := tx.Exec(ctx, laterDown); err != nil {
|
||||
t.Fatalf("down 00051: %v", err)
|
||||
}
|
||||
raw, err := files.ReadFile("sql/00039_alert_groups.sql")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
-- +goose Up
|
||||
-- Accounts ask the platform's admins for help. A ticket belongs to the
|
||||
-- account that opened it, even a suspended one; deleting the account
|
||||
-- deletes its tickets. It may point at an organization and things in it
|
||||
-- the question is about; deleting those leaves the ticket.
|
||||
CREATE TABLE support_tickets (
|
||||
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
user_id uuid NOT NULL REFERENCES users (id) ON DELETE CASCADE,
|
||||
org_id uuid REFERENCES orgs (id) ON DELETE SET NULL,
|
||||
monitor_id uuid REFERENCES monitors (id) ON DELETE SET NULL,
|
||||
channel_id uuid REFERENCES notification_channels (id) ON DELETE SET NULL,
|
||||
alert_group_id uuid REFERENCES alert_groups (id) ON DELETE SET NULL,
|
||||
status_page_id uuid REFERENCES status_pages (id) ON DELETE SET NULL,
|
||||
incident_id uuid REFERENCES incidents (id) ON DELETE SET NULL,
|
||||
subject text NOT NULL CHECK (length(subject) BETWEEN 1 AND 200),
|
||||
-- open waits for the admins, answered for the account.
|
||||
status text NOT NULL DEFAULT 'open' CHECK (status IN ('open', 'answered', 'closed')),
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
updated_at timestamptz NOT NULL DEFAULT now()
|
||||
);
|
||||
CREATE INDEX support_tickets_user_idx ON support_tickets (user_id, updated_at DESC);
|
||||
CREATE INDEX support_tickets_status_idx ON support_tickets (status, updated_at DESC);
|
||||
|
||||
CREATE TABLE support_messages (
|
||||
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
ticket_id uuid NOT NULL REFERENCES support_tickets (id) ON DELETE CASCADE,
|
||||
-- author_id is empty once the admin who wrote it is deleted.
|
||||
author_id uuid REFERENCES users (id) ON DELETE SET NULL,
|
||||
from_staff boolean NOT NULL,
|
||||
body text NOT NULL CHECK (length(body) BETWEEN 1 AND 10000),
|
||||
created_at timestamptz NOT NULL DEFAULT now()
|
||||
);
|
||||
CREATE INDEX support_messages_ticket_idx ON support_messages (ticket_id, created_at);
|
||||
|
||||
ALTER TABLE support_tickets ENABLE ROW LEVEL SECURITY;
|
||||
ALTER TABLE support_tickets FORCE ROW LEVEL SECURITY;
|
||||
CREATE POLICY support_tickets_own ON support_tickets FOR ALL
|
||||
USING (app_scope_system() OR user_id = app_user_id())
|
||||
WITH CHECK (app_scope_system() OR user_id = app_user_id());
|
||||
|
||||
ALTER TABLE support_messages ENABLE ROW LEVEL SECURITY;
|
||||
ALTER TABLE support_messages FORCE ROW LEVEL SECURITY;
|
||||
CREATE POLICY support_messages_own ON support_messages FOR ALL
|
||||
USING (app_scope_system() OR EXISTS (
|
||||
SELECT 1 FROM support_tickets t WHERE t.id = ticket_id AND t.user_id = app_user_id()))
|
||||
WITH CHECK (app_scope_system() OR (NOT from_staff AND EXISTS (
|
||||
SELECT 1 FROM support_tickets t WHERE t.id = ticket_id AND t.user_id = app_user_id())));
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE support_messages;
|
||||
DROP TABLE support_tickets;
|
||||
@@ -35,14 +35,24 @@ import (
|
||||
const (
|
||||
// freshFor is how long a snapshot is used without asking the API.
|
||||
freshFor = 30 * time.Second
|
||||
// staleNoticeAfter is when visitors are told the state may be outdated.
|
||||
staleNoticeAfter = 5 * time.Minute
|
||||
refreshInterval = 30 * time.Second
|
||||
// refreshInterval is how often pages visited within recentFor are
|
||||
// refreshed.
|
||||
refreshInterval = 30 * time.Second
|
||||
recentFor = 10 * time.Minute
|
||||
// syncInterval is how often every page the API lists is fetched, so
|
||||
// each one is cached before its first visit.
|
||||
syncInterval = 5 * time.Minute
|
||||
// staleNoticeAfter is when visitors are told the state may be outdated;
|
||||
// a page nobody visited is up to syncInterval old.
|
||||
staleNoticeAfter = 2 * syncInterval
|
||||
)
|
||||
|
||||
// Source fetches snapshots; *agentapi.Client implements it.
|
||||
type Source interface {
|
||||
Page(ctx context.Context, host, slug string) (agentapi.PageSnapshot, error)
|
||||
// PageIfChanged answers agentapi.ErrNotModified when the page still
|
||||
// has checksum.
|
||||
PageIfChanged(ctx context.Context, host, slug, checksum string) (agentapi.PageSnapshot, error)
|
||||
Pages(ctx context.Context) ([]agentapi.PageRef, error)
|
||||
}
|
||||
|
||||
// Server renders pages for one status page agent.
|
||||
@@ -60,6 +70,8 @@ type Server struct {
|
||||
mu sync.Mutex
|
||||
cache map[string]entry
|
||||
refreshing map[string]bool
|
||||
// visited holds when each page was last visited.
|
||||
visited map[string]time.Time
|
||||
// background tracks refreshes started by visits.
|
||||
background sync.WaitGroup
|
||||
}
|
||||
@@ -71,6 +83,9 @@ type entry struct {
|
||||
Slug string `json:"slug,omitempty"`
|
||||
Snap agentapi.PageSnapshot `json:"snapshot"`
|
||||
Fetched time.Time `json:"fetched"`
|
||||
// Checksum is the snapshot's, sent so the API can answer that nothing
|
||||
// changed instead of sending it again.
|
||||
Checksum string `json:"checksum,omitempty"`
|
||||
}
|
||||
|
||||
// Options configure a Server.
|
||||
@@ -88,7 +103,7 @@ type Options struct {
|
||||
func New(src Source, catalog *i18n.Catalog, log *slog.Logger, o Options) (*Server, error) {
|
||||
s := &Server{
|
||||
src: src, catalog: catalog, log: log, ownHosts: map[string]bool{}, dir: o.CacheDir,
|
||||
now: time.Now, cache: map[string]entry{}, refreshing: map[string]bool{},
|
||||
now: time.Now, cache: map[string]entry{}, refreshing: map[string]bool{}, visited: map[string]time.Time{},
|
||||
}
|
||||
for _, h := range o.Hosts {
|
||||
s.ownHosts[strings.ToLower(h)] = true
|
||||
@@ -308,6 +323,7 @@ func (s *Server) localizeRequest(c *gin.Context) {
|
||||
func (s *Server) lookup(ctx context.Context, key, host, slug string) (entry, bool) {
|
||||
s.mu.Lock()
|
||||
e, cached := s.cache[key]
|
||||
s.visited[key] = s.now()
|
||||
s.mu.Unlock()
|
||||
if cached {
|
||||
if s.now().Sub(e.Fetched) >= freshFor {
|
||||
@@ -319,8 +335,20 @@ func (s *Server) lookup(ctx context.Context, key, host, slug string) (entry, boo
|
||||
}
|
||||
|
||||
func (s *Server) fetch(ctx context.Context, key, host, slug string) (entry, bool) {
|
||||
snap, err := s.src.Page(ctx, host, slug)
|
||||
s.mu.Lock()
|
||||
old, known := s.cache[key]
|
||||
s.mu.Unlock()
|
||||
snap, err := s.src.PageIfChanged(ctx, host, slug, old.Checksum)
|
||||
switch {
|
||||
case errors.Is(err, agentapi.ErrNotModified) && known:
|
||||
// Unchanged: the copy is current as of now.
|
||||
old.Fetched = s.now()
|
||||
old.Snap.GeneratedAt = old.Fetched
|
||||
s.mu.Lock()
|
||||
s.cache[key] = old
|
||||
s.mu.Unlock()
|
||||
s.persist(old)
|
||||
return old, true
|
||||
case errors.Is(err, agentapi.ErrNotFound):
|
||||
s.forget(key)
|
||||
return entry{}, false
|
||||
@@ -331,7 +359,7 @@ func (s *Server) fetch(ctx context.Context, key, host, slug string) (entry, bool
|
||||
s.mu.Unlock()
|
||||
return e, ok
|
||||
}
|
||||
e := entry{Key: key, Host: host, Slug: slug, Snap: snap, Fetched: s.now()}
|
||||
e := entry{Key: key, Host: host, Slug: slug, Snap: snap, Fetched: s.now(), Checksum: snap.Checksum()}
|
||||
s.mu.Lock()
|
||||
s.cache[key] = e
|
||||
s.mu.Unlock()
|
||||
@@ -361,25 +389,64 @@ func (s *Server) refresh(ctx context.Context, key, host, slug string) {
|
||||
// Wait returns once the background refreshes started by visits are done.
|
||||
func (s *Server) Wait() { s.background.Wait() }
|
||||
|
||||
// Run keeps every known page fresh until ctx ends, so pages stay current
|
||||
// even without visitors and the cache is warm when the API goes away.
|
||||
// Run keeps pages fresh until ctx ends: every page the API lists every
|
||||
// syncInterval, so all are cached before their first visit and survive an
|
||||
// outage of the API, and recently visited ones every refreshInterval.
|
||||
func (s *Server) Run(ctx context.Context) {
|
||||
tick := time.NewTicker(refreshInterval)
|
||||
defer tick.Stop()
|
||||
refresh := time.NewTicker(refreshInterval)
|
||||
defer refresh.Stop()
|
||||
listAll := time.NewTicker(syncInterval)
|
||||
defer listAll.Stop()
|
||||
s.Sync(ctx)
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-tick.C:
|
||||
case <-listAll.C:
|
||||
s.Sync(ctx)
|
||||
case <-refresh.C:
|
||||
s.mu.Lock()
|
||||
entries := make([]entry, 0, len(s.cache))
|
||||
for _, e := range s.cache {
|
||||
entries = append(entries, e)
|
||||
var recent []entry
|
||||
for key, e := range s.cache {
|
||||
if s.now().Sub(s.visited[key]) < recentFor {
|
||||
recent = append(recent, e)
|
||||
}
|
||||
}
|
||||
s.mu.Unlock()
|
||||
for _, e := range entries {
|
||||
for _, e := range recent {
|
||||
s.refresh(ctx, e.Key, e.Host, e.Slug)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sync fetches every page the API lists and every cached one, which drops
|
||||
// those the API no longer serves. While the API is unreachable the cache
|
||||
// stays as it is.
|
||||
func (s *Server) Sync(ctx context.Context) {
|
||||
ctx, cancel := context.WithTimeout(ctx, syncInterval)
|
||||
defer cancel()
|
||||
refs, err := s.src.Pages(ctx)
|
||||
if err != nil {
|
||||
s.log.WarnContext(ctx, "listing status pages failed", "error", err)
|
||||
return
|
||||
}
|
||||
todo := map[string]entry{}
|
||||
s.mu.Lock()
|
||||
for key, e := range s.cache {
|
||||
todo[key] = e
|
||||
}
|
||||
s.mu.Unlock()
|
||||
for _, r := range refs {
|
||||
todo["slug:"+r.Slug] = entry{Key: "slug:" + r.Slug, Slug: r.Slug}
|
||||
if r.Host != "" {
|
||||
todo["host:"+r.Host] = entry{Key: "host:" + r.Host, Host: r.Host}
|
||||
}
|
||||
}
|
||||
for _, e := range todo {
|
||||
if ctx.Err() != nil {
|
||||
return
|
||||
}
|
||||
s.refresh(ctx, e.Key, e.Host, e.Slug)
|
||||
}
|
||||
}
|
||||
@@ -20,12 +20,27 @@ import (
|
||||
type fakeSource struct {
|
||||
mu sync.Mutex
|
||||
calls int
|
||||
err error
|
||||
delay time.Duration
|
||||
pages map[string]agentapi.PageSnapshot
|
||||
// unchanged counts the answers that the page had not changed.
|
||||
unchanged int
|
||||
err error
|
||||
delay time.Duration
|
||||
pages map[string]agentapi.PageSnapshot
|
||||
}
|
||||
|
||||
func (f *fakeSource) Page(ctx context.Context, host, slug string) (agentapi.PageSnapshot, error) {
|
||||
// PageIfChanged counts calls and answers like the API, sending pages
|
||||
// only when their checksum changed.
|
||||
func (f *fakeSource) PageIfChanged(ctx context.Context, host, slug, checksum string) (agentapi.PageSnapshot, error) {
|
||||
p, err := f.page(ctx, host, slug)
|
||||
if err == nil && checksum != "" && p.Checksum() == checksum {
|
||||
f.mu.Lock()
|
||||
f.unchanged++
|
||||
f.mu.Unlock()
|
||||
return agentapi.PageSnapshot{}, agentapi.ErrNotModified
|
||||
}
|
||||
return p, err
|
||||
}
|
||||
|
||||
func (f *fakeSource) page(ctx context.Context, host, slug string) (agentapi.PageSnapshot, error) {
|
||||
f.mu.Lock()
|
||||
f.calls++
|
||||
err, delay, p, ok := f.err, f.delay, f.pages[host+"|"+slug], false
|
||||
@@ -49,6 +64,21 @@ func (f *fakeSource) Page(ctx context.Context, host, slug string) (agentapi.Page
|
||||
return p, nil
|
||||
}
|
||||
|
||||
// Pages lists the fake's pages by their keys: "host|" or "|slug".
|
||||
func (f *fakeSource) Pages(context.Context) ([]agentapi.PageRef, error) {
|
||||
f.mu.Lock()
|
||||
defer f.mu.Unlock()
|
||||
if f.err != nil {
|
||||
return nil, f.err
|
||||
}
|
||||
var out []agentapi.PageRef
|
||||
for k := range f.pages {
|
||||
host, slug, _ := strings.Cut(k, "|")
|
||||
out = append(out, agentapi.PageRef{Host: host, Slug: slug})
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (f *fakeSource) set(fn func(*fakeSource)) {
|
||||
f.mu.Lock()
|
||||
defer f.mu.Unlock()
|
||||
@@ -464,3 +494,64 @@ func TestNestedGroupsAndComponentDetails(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestSyncCachesPagesBeforeTheirFirstVisit(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
now := time.Now()
|
||||
src := newSource()
|
||||
h := newHarness(t, src, dir, &now)
|
||||
h.srv.Sync(context.Background())
|
||||
|
||||
// Nobody visited them, yet both survive an outage and a restart.
|
||||
now = now.Add(syncInterval)
|
||||
restarted := newHarness(t, &fakeSource{err: errors.New("down")}, dir, &now)
|
||||
if code, body := restarted.get("status.example.test", "/acme"); code != 200 || !strings.Contains(body, "Acme status") || strings.Contains(body, "Live-Aktualisierung") {
|
||||
t.Errorf("GET of a synced page with the API down = %d, want it without stale notice", code)
|
||||
}
|
||||
if code, body := restarted.get("status.acme.test", "/"); code != 200 || !strings.Contains(body, "Acme on own domain") {
|
||||
t.Errorf("GET of a synced custom domain with the API down = %d", code)
|
||||
}
|
||||
restarted.srv.Sync(context.Background())
|
||||
if code, _ := restarted.get("status.example.test", "/acme"); code != 200 {
|
||||
t.Errorf("a failed sync dropped the cache: %d", code)
|
||||
}
|
||||
|
||||
// A page the API no longer lists is dropped by the next sync.
|
||||
src.set(func(f *fakeSource) { delete(f.pages, "|acme") })
|
||||
h.srv.Sync(context.Background())
|
||||
if code, _ := h.get("status.example.test", "/acme"); code != 404 {
|
||||
t.Errorf("GET after the page left the list = %d, want 404", code)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRefreshSkipsUnchangedPages(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
now := time.Now()
|
||||
src := newSource()
|
||||
h := newHarness(t, src, dir, &now)
|
||||
h.srv.Sync(context.Background())
|
||||
now = now.Add(syncInterval)
|
||||
h.srv.Sync(context.Background())
|
||||
src.mu.Lock()
|
||||
unchanged := src.unchanged
|
||||
src.mu.Unlock()
|
||||
if unchanged != 2 {
|
||||
t.Errorf("unchanged answers on the second sync = %d, want 2", unchanged)
|
||||
}
|
||||
if _, body := h.get("status.example.test", "/acme"); !strings.Contains(body, "Acme status") || strings.Contains(body, "Live-Aktualisierung") {
|
||||
t.Error("an unchanged page is not served as current")
|
||||
}
|
||||
|
||||
// A changed page is sent again, and the checksum survives a restart.
|
||||
src.set(func(f *fakeSource) {
|
||||
f.pages["|acme"] = agentapi.PageSnapshot{Title: "Renamed", Status: agentapi.PageOperational}
|
||||
})
|
||||
restarted := newHarness(t, src, dir, &now)
|
||||
restarted.srv.Sync(context.Background())
|
||||
src.mu.Lock()
|
||||
unchanged = src.unchanged
|
||||
src.mu.Unlock()
|
||||
if _, body := restarted.get("status.example.test", "/acme"); !strings.Contains(body, "Renamed") || unchanged != 3 {
|
||||
t.Errorf("after a change: renamed %t, unchanged answers %d, want 3", strings.Contains(body, "Renamed"), unchanged)
|
||||
}
|
||||
}
|
||||
@@ -318,6 +318,92 @@ func (q *Queries) ListVisibleRegions(ctx context.Context) ([]Region, error) {
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const orgOwnerEmails = `-- name: OrgOwnerEmails :many
|
||||
SELECT u.email FROM memberships m JOIN users u ON u.id = m.user_id
|
||||
WHERE m.org_id = $1 AND m.is_owner AND u.disabled_at IS NULL
|
||||
`
|
||||
|
||||
// System scope.
|
||||
func (q *Queries) OrgOwnerEmails(ctx context.Context, orgID uuid.UUID) ([]string, error) {
|
||||
rows, err := q.db.Query(ctx, orgOwnerEmails, orgID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
items := []string{}
|
||||
for rows.Next() {
|
||||
var email string
|
||||
if err := rows.Scan(&email); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, email)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const orgServesOwnPages = `-- name: OrgServesOwnPages :one
|
||||
SELECT EXISTS (
|
||||
SELECT 1 FROM agents
|
||||
WHERE org_id = $1 AND kind = 'statuspage' AND last_seen_at IS NOT NULL
|
||||
)
|
||||
`
|
||||
|
||||
// An organization serves its status pages itself once one of its own
|
||||
// status page servers has connected.
|
||||
func (q *Queries) OrgServesOwnPages(ctx context.Context, orgID *uuid.UUID) (bool, error) {
|
||||
row := q.db.QueryRow(ctx, orgServesOwnPages, orgID)
|
||||
var exists bool
|
||||
err := row.Scan(&exists)
|
||||
return exists, err
|
||||
}
|
||||
|
||||
const regionsToWatch = `-- name: RegionsToWatch :many
|
||||
SELECT r.id, r.name, r.org_id, o.name AS org_name
|
||||
FROM regions r
|
||||
LEFT JOIN orgs o ON o.id = r.org_id
|
||||
WHERE EXISTS (SELECT 1 FROM agents a WHERE a.kind = 'checker' AND a.region_id = r.id)
|
||||
AND EXISTS (SELECT 1 FROM monitor_regions mr JOIN monitors m ON m.id = mr.monitor_id
|
||||
WHERE mr.region_id = r.id AND m.enabled)
|
||||
ORDER BY r.name
|
||||
`
|
||||
|
||||
type RegionsToWatchRow struct {
|
||||
ID uuid.UUID
|
||||
Name string
|
||||
OrgID *uuid.UUID
|
||||
OrgName *string
|
||||
}
|
||||
|
||||
// System scope: regions that have checkers and enabled monitors, so a
|
||||
// region without a live checker leaves monitors unchecked.
|
||||
func (q *Queries) RegionsToWatch(ctx context.Context) ([]RegionsToWatchRow, error) {
|
||||
rows, err := q.db.Query(ctx, regionsToWatch)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
items := []RegionsToWatchRow{}
|
||||
for rows.Next() {
|
||||
var i RegionsToWatchRow
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.Name,
|
||||
&i.OrgID,
|
||||
&i.OrgName,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const setAgentAllowPrivate = `-- name: SetAgentAllowPrivate :execrows
|
||||
UPDATE agents SET allow_private = $1
|
||||
WHERE id = $2 AND kind = 'checker' AND org_id = $3
|
||||
|
||||
@@ -441,6 +441,30 @@ type StatusPageMonitor struct {
|
||||
GroupID *uuid.UUID
|
||||
}
|
||||
|
||||
type SupportMessage struct {
|
||||
ID uuid.UUID
|
||||
TicketID uuid.UUID
|
||||
AuthorID *uuid.UUID
|
||||
FromStaff bool
|
||||
Body string
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type SupportTicket struct {
|
||||
ID uuid.UUID
|
||||
UserID uuid.UUID
|
||||
OrgID *uuid.UUID
|
||||
MonitorID *uuid.UUID
|
||||
ChannelID *uuid.UUID
|
||||
AlertGroupID *uuid.UUID
|
||||
StatusPageID *uuid.UUID
|
||||
IncidentID *uuid.UUID
|
||||
Subject string
|
||||
Status string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
type User struct {
|
||||
ID uuid.UUID
|
||||
Email string
|
||||
|
||||
@@ -22,6 +22,8 @@ type Querier interface {
|
||||
AddMonitorAlertGroup(ctx context.Context, arg AddMonitorAlertGroupParams) (int64, error)
|
||||
AddMonitorRegion(ctx context.Context, arg AddMonitorRegionParams) error
|
||||
AddStatusPageMonitor(ctx context.Context, arg AddStatusPageMonitorParams) error
|
||||
AddSupportMessage(ctx context.Context, arg AddSupportMessageParams) (SupportMessage, error)
|
||||
AdminEmails(ctx context.Context) ([]string, error)
|
||||
// System scope: organizations with their usage, limit overrides and owner,
|
||||
// matching search in name, slug or owner email; newest first, a page from a
|
||||
// keyset cursor.
|
||||
@@ -50,10 +52,12 @@ type Querier interface {
|
||||
ClearStatusPageGroups(ctx context.Context, pageID uuid.UUID) error
|
||||
ClearStatusPageMonitors(ctx context.Context, pageID uuid.UUID) error
|
||||
CountMonitors(ctx context.Context, orgID uuid.UUID) (int64, error)
|
||||
CountOpenSupportTickets(ctx context.Context, userID uuid.UUID) (int64, error)
|
||||
CountOwnedOrgs(ctx context.Context, userID uuid.UUID) (int64, error)
|
||||
CountOwners(ctx context.Context, orgID uuid.UUID) (int64, error)
|
||||
CountRoleAssignments(ctx context.Context, roleID uuid.UUID) (int64, error)
|
||||
CountStatusPages(ctx context.Context, orgID uuid.UUID) (int64, error)
|
||||
CountSupportTicketsSince(ctx context.Context, arg CountSupportTicketsSinceParams) (int64, error)
|
||||
CountUnusedRecoveryCodes(ctx context.Context, userID uuid.UUID) (int64, error)
|
||||
// Ways the account can sign in besides platform identities.
|
||||
CountUserSignIns(ctx context.Context, id uuid.UUID) (int32, error)
|
||||
@@ -77,6 +81,7 @@ type Querier interface {
|
||||
CreateSSOProvider(ctx context.Context, arg CreateSSOProviderParams) (SsoProvider, error)
|
||||
CreateStatusPage(ctx context.Context, arg CreateStatusPageParams) (StatusPage, error)
|
||||
CreateStatusPageGroup(ctx context.Context, arg CreateStatusPageGroupParams) (StatusPageGroup, error)
|
||||
CreateSupportTicket(ctx context.Context, arg CreateSupportTicketParams) (SupportTicket, error)
|
||||
CreateUser(ctx context.Context, arg CreateUserParams) (User, error)
|
||||
DailyBuckets(ctx context.Context, arg DailyBucketsParams) ([]DailyBucketsRow, error)
|
||||
DailyBucketsForMonitors(ctx context.Context, arg DailyBucketsForMonitorsParams) ([]DailyBucketsForMonitorsRow, error)
|
||||
@@ -160,6 +165,7 @@ type Querier interface {
|
||||
GetRole(ctx context.Context, id uuid.UUID) (Role, error)
|
||||
GetSSOProvider(ctx context.Context, id uuid.UUID) (SsoProvider, error)
|
||||
GetStatusPage(ctx context.Context, id uuid.UUID) (StatusPage, error)
|
||||
GetSupportTicket(ctx context.Context, id uuid.UUID) (GetSupportTicketRow, error)
|
||||
GetUser(ctx context.Context, id uuid.UUID) (User, error)
|
||||
GetUserByEmail(ctx context.Context, email string) (User, error)
|
||||
// System scope: the monitor a ping token belongs to.
|
||||
@@ -234,9 +240,14 @@ type Querier interface {
|
||||
ListSSOProviders(ctx context.Context) ([]SsoProvider, error)
|
||||
ListStatusPageGroups(ctx context.Context, pageID uuid.UUID) ([]StatusPageGroup, error)
|
||||
ListStatusPages(ctx context.Context) ([]StatusPage, error)
|
||||
// Every account's tickets for the admins, those waiting for them first.
|
||||
ListSupportTickets(ctx context.Context, status *string) ([]ListSupportTicketsRow, error)
|
||||
ListUserIdentitiesInOrg(ctx context.Context, userID uuid.UUID) ([]ListUserIdentitiesInOrgRow, error)
|
||||
ListUserOrgs(ctx context.Context, userID uuid.UUID) ([]ListUserOrgsRow, error)
|
||||
ListUserPlatformIdentities(ctx context.Context, userID uuid.UUID) ([]ListUserPlatformIdentitiesRow, error)
|
||||
// The tickets row-level security lets the account see, newest activity
|
||||
// first.
|
||||
ListUserSupportTickets(ctx context.Context, userID uuid.UUID) ([]SupportTicket, error)
|
||||
// Row-level security limits this to platform regions and the scope's org;
|
||||
// the org's own regions come first.
|
||||
ListVisibleRegions(ctx context.Context) ([]Region, error)
|
||||
@@ -278,6 +289,11 @@ type Querier interface {
|
||||
OrgIncidentUpdatesExport(ctx context.Context, orgID uuid.UUID) ([]OrgIncidentUpdatesExportRow, error)
|
||||
OrgIncidentsExport(ctx context.Context, orgID uuid.UUID) ([]OrgIncidentsExportRow, error)
|
||||
OrgMembersExport(ctx context.Context, orgID uuid.UUID) ([]OrgMembersExportRow, error)
|
||||
// System scope.
|
||||
OrgOwnerEmails(ctx context.Context, orgID uuid.UUID) ([]string, error)
|
||||
// An organization serves its status pages itself once one of its own
|
||||
// status page servers has connected.
|
||||
OrgServesOwnPages(ctx context.Context, orgID *uuid.UUID) (bool, error)
|
||||
// Organizations user owns, with their member and owner counts.
|
||||
OwnedOrgs(ctx context.Context, userID uuid.UUID) ([]OwnedOrgsRow, error)
|
||||
// The public updates of incidents shown on a status page, newest first.
|
||||
@@ -307,6 +323,9 @@ type Querier interface {
|
||||
RegionBuckets(ctx context.Context, arg RegionBucketsParams) ([]RegionBucketsRow, error)
|
||||
RegionBucketsDaily(ctx context.Context, arg RegionBucketsDailyParams) ([]RegionBucketsDailyRow, error)
|
||||
RegionBucketsHourly(ctx context.Context, arg RegionBucketsHourlyParams) ([]RegionBucketsHourlyRow, error)
|
||||
// System scope: regions that have checkers and enabled monitors, so a
|
||||
// region without a live checker leaves monitors unchecked.
|
||||
RegionsToWatch(ctx context.Context) ([]RegionsToWatchRow, error)
|
||||
RegroupMonitors(ctx context.Context, arg RegroupMonitorsParams) error
|
||||
RemoveMembership(ctx context.Context, arg RemoveMembershipParams) (int64, error)
|
||||
// Moves the subgroups of a group that is about to be deleted.
|
||||
@@ -323,6 +342,10 @@ type Querier interface {
|
||||
// page from a keyset cursor whose string key is monitor and region.
|
||||
ResultsByChecker(ctx context.Context, arg ResultsByCheckerParams) ([]ResultsByCheckerRow, error)
|
||||
ScrubAuditEmail(ctx context.Context, email string) error
|
||||
// System scope: the published pages a status page server serves, those
|
||||
// of agent_org for an organization's server; the platform's leave the
|
||||
// pages of organizations serving their own.
|
||||
ServablePages(ctx context.Context, agentOrg *uuid.UUID) ([]ServablePagesRow, error)
|
||||
SetAgentAllowPrivate(ctx context.Context, arg SetAgentAllowPrivateParams) (int64, error)
|
||||
SetIncidentTitle(ctx context.Context, arg SetIncidentTitleParams) (int64, error)
|
||||
SetOrgDisabledCheckTypes(ctx context.Context, arg SetOrgDisabledCheckTypesParams) error
|
||||
@@ -333,6 +356,7 @@ type Querier interface {
|
||||
// Changing the domain drops a previous verification.
|
||||
SetStatusPageDomain(ctx context.Context, arg SetStatusPageDomainParams) (StatusPage, error)
|
||||
SetStatusPageMonitorGroup(ctx context.Context, arg SetStatusPageMonitorGroupParams) error
|
||||
SetSupportTicketStatus(ctx context.Context, arg SetSupportTicketStatusParams) (int64, error)
|
||||
SetUserAdmin(ctx context.Context, arg SetUserAdminParams) (int64, error)
|
||||
SetUserLocale(ctx context.Context, arg SetUserLocaleParams) error
|
||||
SetUserOrgLimit(ctx context.Context, arg SetUserOrgLimitParams) (SetUserOrgLimitRow, error)
|
||||
@@ -346,6 +370,18 @@ type Querier interface {
|
||||
StorageGet(ctx context.Context, arg StorageGetParams) (StorageGetRow, error)
|
||||
StorageList(ctx context.Context, arg StorageListParams) ([]StorageListRow, error)
|
||||
StoragePut(ctx context.Context, arg StoragePutParams) error
|
||||
SupportMessages(ctx context.Context, ticketID uuid.UUID) ([]SupportMessagesRow, error)
|
||||
SupportOptionsAlertGroups(ctx context.Context, orgID uuid.UUID) ([]SupportOptionsAlertGroupsRow, error)
|
||||
SupportOptionsChannels(ctx context.Context, orgID uuid.UUID) ([]SupportOptionsChannelsRow, error)
|
||||
SupportOptionsIncidents(ctx context.Context, orgID uuid.UUID) ([]SupportOptionsIncidentsRow, error)
|
||||
SupportOptionsMonitors(ctx context.Context, orgID uuid.UUID) ([]SupportOptionsMonitorsRow, error)
|
||||
SupportOptionsStatusPages(ctx context.Context, orgID uuid.UUID) ([]SupportOptionsStatusPagesRow, error)
|
||||
// Whether everything a new ticket points at belongs to org; run in the
|
||||
// organization's scope so only what the account may see counts.
|
||||
SupportReferencesExist(ctx context.Context, arg SupportReferencesExistParams) (*bool, error)
|
||||
// The names of what a ticket points at, for showing it.
|
||||
SupportTicketReferences(ctx context.Context, id uuid.UUID) (SupportTicketReferencesRow, error)
|
||||
SupportTicketStatus(ctx context.Context, id uuid.UUID) (string, error)
|
||||
SuspendOrg(ctx context.Context, arg SuspendOrgParams) (SuspendOrgRow, error)
|
||||
SuspendStatusPage(ctx context.Context, arg SuspendStatusPageParams) (SuspendStatusPageRow, error)
|
||||
SuspendUser(ctx context.Context, arg SuspendUserParams) (SuspendUserRow, error)
|
||||
|
||||
@@ -54,3 +54,27 @@ WHERE id = $1 AND (last_seen_at IS NULL OR last_seen_at < now() - interval '30 s
|
||||
-- name: SetAgentAllowPrivate :execrows
|
||||
UPDATE agents SET allow_private = sqlc.arg(allow_private)
|
||||
WHERE id = sqlc.arg(id) AND kind = 'checker' AND org_id = sqlc.arg(org_id);
|
||||
|
||||
-- name: OrgServesOwnPages :one
|
||||
-- An organization serves its status pages itself once one of its own
|
||||
-- status page servers has connected.
|
||||
SELECT EXISTS (
|
||||
SELECT 1 FROM agents
|
||||
WHERE org_id = $1 AND kind = 'statuspage' AND last_seen_at IS NOT NULL
|
||||
);
|
||||
|
||||
-- name: RegionsToWatch :many
|
||||
-- System scope: regions that have checkers and enabled monitors, so a
|
||||
-- region without a live checker leaves monitors unchecked.
|
||||
SELECT r.id, r.name, r.org_id, o.name AS org_name
|
||||
FROM regions r
|
||||
LEFT JOIN orgs o ON o.id = r.org_id
|
||||
WHERE EXISTS (SELECT 1 FROM agents a WHERE a.kind = 'checker' AND a.region_id = r.id)
|
||||
AND EXISTS (SELECT 1 FROM monitor_regions mr JOIN monitors m ON m.id = mr.monitor_id
|
||||
WHERE mr.region_id = r.id AND m.enabled)
|
||||
ORDER BY r.name;
|
||||
|
||||
-- name: OrgOwnerEmails :many
|
||||
-- System scope.
|
||||
SELECT u.email FROM memberships m JOIN users u ON u.id = m.user_id
|
||||
WHERE m.org_id = $1 AND m.is_owner AND u.disabled_at IS NULL;
|
||||
@@ -38,7 +38,8 @@ DELETE FROM status_pages WHERE id = $1;
|
||||
|
||||
-- name: StatusPageMonitors :many
|
||||
SELECT spm.monitor_id, spm.section, spm.group_id, spm.label, spm.position,
|
||||
m.name AS monitor_name, m.enabled, m.group_id AS monitor_group_id
|
||||
m.name AS monitor_name, m.enabled, m.group_id AS monitor_group_id,
|
||||
m.type AS monitor_type, m.interval_seconds
|
||||
FROM status_page_monitors spm
|
||||
JOIN monitors m ON m.id = spm.monitor_id
|
||||
WHERE spm.page_id = $1
|
||||
@@ -93,3 +94,17 @@ WHERE published AND suspended_at IS NULL
|
||||
AND NOT EXISTS (SELECT 1 FROM orgs o WHERE o.id = status_pages.org_id AND o.suspended_at IS NOT NULL)
|
||||
AND ((sqlc.narg(host)::citext IS NOT NULL AND custom_domain = sqlc.narg(host) AND domain_verified_at IS NOT NULL)
|
||||
OR (sqlc.narg(slug)::citext IS NOT NULL AND slug = sqlc.narg(slug)));
|
||||
|
||||
-- name: ServablePages :many
|
||||
-- System scope: the published pages a status page server serves, those
|
||||
-- of agent_org for an organization's server; the platform's leave the
|
||||
-- pages of organizations serving their own.
|
||||
SELECT p.slug, COALESCE(CASE WHEN p.domain_verified_at IS NOT NULL THEN p.custom_domain END, '')::text AS host
|
||||
FROM status_pages p
|
||||
JOIN orgs o ON o.id = p.org_id
|
||||
WHERE p.published AND p.suspended_at IS NULL AND o.suspended_at IS NULL
|
||||
AND CASE WHEN sqlc.narg(agent_org)::uuid IS NULL
|
||||
THEN NOT EXISTS (SELECT 1 FROM agents a WHERE a.org_id = p.org_id AND a.kind = 'statuspage' AND a.last_seen_at IS NOT NULL)
|
||||
ELSE p.org_id = sqlc.narg(agent_org)::uuid
|
||||
END
|
||||
ORDER BY p.slug;
|
||||
@@ -0,0 +1,97 @@
|
||||
-- name: CreateSupportTicket :one
|
||||
INSERT INTO support_tickets (user_id, org_id, subject, monitor_id, channel_id, alert_group_id, status_page_id, incident_id)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
||||
RETURNING *;
|
||||
|
||||
-- name: SupportReferencesExist :one
|
||||
-- Whether everything a new ticket points at belongs to org; run in the
|
||||
-- organization's scope so only what the account may see counts.
|
||||
SELECT (sqlc.narg(monitor_id)::uuid IS NULL OR EXISTS (SELECT 1 FROM monitors m WHERE m.id = sqlc.narg(monitor_id) AND m.org_id = sqlc.arg(org_id)::uuid))
|
||||
AND (sqlc.narg(channel_id)::uuid IS NULL OR EXISTS (SELECT 1 FROM notification_channels c WHERE c.id = sqlc.narg(channel_id) AND c.org_id = sqlc.arg(org_id)::uuid))
|
||||
AND (sqlc.narg(alert_group_id)::uuid IS NULL OR EXISTS (SELECT 1 FROM alert_groups g WHERE g.id = sqlc.narg(alert_group_id) AND g.org_id = sqlc.arg(org_id)::uuid))
|
||||
AND (sqlc.narg(status_page_id)::uuid IS NULL OR EXISTS (SELECT 1 FROM status_pages p WHERE p.id = sqlc.narg(status_page_id) AND p.org_id = sqlc.arg(org_id)::uuid))
|
||||
AND (sqlc.narg(incident_id)::uuid IS NULL OR EXISTS (SELECT 1 FROM incidents i WHERE i.id = sqlc.narg(incident_id) AND i.org_id = sqlc.arg(org_id)::uuid))
|
||||
AS ok;
|
||||
|
||||
-- name: SupportTicketReferences :one
|
||||
-- The names of what a ticket points at, for showing it.
|
||||
SELECT o.name AS org_name, o.slug AS org_slug,
|
||||
m.name AS monitor_name, m.type AS monitor_type,
|
||||
ch.name AS channel_name, ch.type AS channel_type,
|
||||
ag.name AS alert_group_name,
|
||||
sp.title AS status_page_title, sp.slug AS status_page_slug,
|
||||
i.title AS incident_title, i.started_at AS incident_started_at, im.name AS incident_monitor
|
||||
FROM support_tickets t
|
||||
LEFT JOIN orgs o ON o.id = t.org_id
|
||||
LEFT JOIN monitors m ON m.id = t.monitor_id
|
||||
LEFT JOIN notification_channels ch ON ch.id = t.channel_id
|
||||
LEFT JOIN alert_groups ag ON ag.id = t.alert_group_id
|
||||
LEFT JOIN status_pages sp ON sp.id = t.status_page_id
|
||||
LEFT JOIN incidents i ON i.id = t.incident_id
|
||||
LEFT JOIN monitors im ON im.id = i.monitor_id
|
||||
WHERE t.id = $1;
|
||||
|
||||
-- name: SupportOptionsMonitors :many
|
||||
SELECT id, name FROM monitors WHERE org_id = $1 ORDER BY lower(name) LIMIT 500;
|
||||
|
||||
-- name: SupportOptionsChannels :many
|
||||
SELECT id, name, type FROM notification_channels WHERE org_id = $1 ORDER BY lower(name) LIMIT 500;
|
||||
|
||||
-- name: SupportOptionsAlertGroups :many
|
||||
SELECT id, name FROM alert_groups WHERE org_id = $1 ORDER BY lower(name) LIMIT 500;
|
||||
|
||||
-- name: SupportOptionsStatusPages :many
|
||||
SELECT id, title FROM status_pages WHERE org_id = $1 ORDER BY lower(title) LIMIT 500;
|
||||
|
||||
-- name: SupportOptionsIncidents :many
|
||||
SELECT i.id, i.title, i.started_at, m.name AS monitor_name
|
||||
FROM incidents i JOIN monitors m ON m.id = i.monitor_id
|
||||
WHERE i.org_id = $1 ORDER BY i.started_at DESC LIMIT 50;
|
||||
|
||||
-- name: AddSupportMessage :one
|
||||
INSERT INTO support_messages (ticket_id, author_id, from_staff, body) VALUES ($1, $2, $3, $4)
|
||||
RETURNING *;
|
||||
|
||||
-- name: SetSupportTicketStatus :execrows
|
||||
UPDATE support_tickets SET status = $2, updated_at = now() WHERE id = $1;
|
||||
|
||||
-- name: GetSupportTicket :one
|
||||
SELECT t.*, u.email AS user_email, o.name AS org_name
|
||||
FROM support_tickets t
|
||||
JOIN users u ON u.id = t.user_id
|
||||
LEFT JOIN orgs o ON o.id = t.org_id
|
||||
WHERE t.id = $1;
|
||||
|
||||
-- name: ListUserSupportTickets :many
|
||||
-- The tickets row-level security lets the account see, newest activity
|
||||
-- first.
|
||||
SELECT * FROM support_tickets WHERE user_id = $1 ORDER BY updated_at DESC LIMIT 200;
|
||||
|
||||
-- name: ListSupportTickets :many
|
||||
-- Every account's tickets for the admins, those waiting for them first.
|
||||
SELECT t.*, u.email AS user_email, o.name AS org_name
|
||||
FROM support_tickets t
|
||||
JOIN users u ON u.id = t.user_id
|
||||
LEFT JOIN orgs o ON o.id = t.org_id
|
||||
WHERE sqlc.narg(status)::text IS NULL OR t.status = sqlc.narg(status)::text
|
||||
ORDER BY t.status = 'open' DESC, t.updated_at DESC
|
||||
LIMIT 200;
|
||||
|
||||
-- name: SupportMessages :many
|
||||
SELECT m.*, coalesce(u.email, '')::text AS author_email
|
||||
FROM support_messages m
|
||||
LEFT JOIN users u ON u.id = m.author_id
|
||||
WHERE m.ticket_id = $1
|
||||
ORDER BY m.created_at, m.id;
|
||||
|
||||
-- name: AdminEmails :many
|
||||
SELECT email FROM users WHERE is_admin AND disabled_at IS NULL ORDER BY email;
|
||||
|
||||
-- name: CountOpenSupportTickets :one
|
||||
SELECT count(*) FROM support_tickets WHERE user_id = $1 AND status <> 'closed';
|
||||
|
||||
-- name: CountSupportTicketsSince :one
|
||||
SELECT count(*) FROM support_tickets WHERE user_id = $1 AND created_at >= $2;
|
||||
|
||||
-- name: SupportTicketStatus :one
|
||||
SELECT status FROM support_tickets WHERE id = $1;
|
||||
@@ -352,6 +352,46 @@ func (q *Queries) ReparentStatusPageGroupMonitors(ctx context.Context, arg Repar
|
||||
return err
|
||||
}
|
||||
|
||||
const servablePages = `-- name: ServablePages :many
|
||||
SELECT p.slug, COALESCE(CASE WHEN p.domain_verified_at IS NOT NULL THEN p.custom_domain END, '')::text AS host
|
||||
FROM status_pages p
|
||||
JOIN orgs o ON o.id = p.org_id
|
||||
WHERE p.published AND p.suspended_at IS NULL AND o.suspended_at IS NULL
|
||||
AND CASE WHEN $1::uuid IS NULL
|
||||
THEN NOT EXISTS (SELECT 1 FROM agents a WHERE a.org_id = p.org_id AND a.kind = 'statuspage' AND a.last_seen_at IS NOT NULL)
|
||||
ELSE p.org_id = $1::uuid
|
||||
END
|
||||
ORDER BY p.slug
|
||||
`
|
||||
|
||||
type ServablePagesRow struct {
|
||||
Slug string
|
||||
Host string
|
||||
}
|
||||
|
||||
// System scope: the published pages a status page server serves, those
|
||||
// of agent_org for an organization's server; the platform's leave the
|
||||
// pages of organizations serving their own.
|
||||
func (q *Queries) ServablePages(ctx context.Context, agentOrg *uuid.UUID) ([]ServablePagesRow, error) {
|
||||
rows, err := q.db.Query(ctx, servablePages, agentOrg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
items := []ServablePagesRow{}
|
||||
for rows.Next() {
|
||||
var i ServablePagesRow
|
||||
if err := rows.Scan(&i.Slug, &i.Host); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const setStatusPageDomain = `-- name: SetStatusPageDomain :one
|
||||
UPDATE status_pages SET
|
||||
custom_domain = $1,
|
||||
@@ -414,7 +454,8 @@ func (q *Queries) SetStatusPageMonitorGroup(ctx context.Context, arg SetStatusPa
|
||||
|
||||
const statusPageMonitors = `-- name: StatusPageMonitors :many
|
||||
SELECT spm.monitor_id, spm.section, spm.group_id, spm.label, spm.position,
|
||||
m.name AS monitor_name, m.enabled, m.group_id AS monitor_group_id
|
||||
m.name AS monitor_name, m.enabled, m.group_id AS monitor_group_id,
|
||||
m.type AS monitor_type, m.interval_seconds
|
||||
FROM status_page_monitors spm
|
||||
JOIN monitors m ON m.id = spm.monitor_id
|
||||
WHERE spm.page_id = $1
|
||||
@@ -422,14 +463,16 @@ ORDER BY spm.position, m.name
|
||||
`
|
||||
|
||||
type StatusPageMonitorsRow struct {
|
||||
MonitorID uuid.UUID
|
||||
Section string
|
||||
GroupID *uuid.UUID
|
||||
Label string
|
||||
Position int32
|
||||
MonitorName string
|
||||
Enabled bool
|
||||
MonitorGroupID *uuid.UUID
|
||||
MonitorID uuid.UUID
|
||||
Section string
|
||||
GroupID *uuid.UUID
|
||||
Label string
|
||||
Position int32
|
||||
MonitorName string
|
||||
Enabled bool
|
||||
MonitorGroupID *uuid.UUID
|
||||
MonitorType string
|
||||
IntervalSeconds int32
|
||||
}
|
||||
|
||||
func (q *Queries) StatusPageMonitors(ctx context.Context, pageID uuid.UUID) ([]StatusPageMonitorsRow, error) {
|
||||
@@ -450,6 +493,8 @@ func (q *Queries) StatusPageMonitors(ctx context.Context, pageID uuid.UUID) ([]S
|
||||
&i.MonitorName,
|
||||
&i.Enabled,
|
||||
&i.MonitorGroupID,
|
||||
&i.MonitorType,
|
||||
&i.IntervalSeconds,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -0,0 +1,607 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: support.sql
|
||||
|
||||
package store
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const addSupportMessage = `-- name: AddSupportMessage :one
|
||||
INSERT INTO support_messages (ticket_id, author_id, from_staff, body) VALUES ($1, $2, $3, $4)
|
||||
RETURNING id, ticket_id, author_id, from_staff, body, created_at
|
||||
`
|
||||
|
||||
type AddSupportMessageParams struct {
|
||||
TicketID uuid.UUID
|
||||
AuthorID *uuid.UUID
|
||||
FromStaff bool
|
||||
Body string
|
||||
}
|
||||
|
||||
func (q *Queries) AddSupportMessage(ctx context.Context, arg AddSupportMessageParams) (SupportMessage, error) {
|
||||
row := q.db.QueryRow(ctx, addSupportMessage,
|
||||
arg.TicketID,
|
||||
arg.AuthorID,
|
||||
arg.FromStaff,
|
||||
arg.Body,
|
||||
)
|
||||
var i SupportMessage
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.TicketID,
|
||||
&i.AuthorID,
|
||||
&i.FromStaff,
|
||||
&i.Body,
|
||||
&i.CreatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const adminEmails = `-- name: AdminEmails :many
|
||||
SELECT email FROM users WHERE is_admin AND disabled_at IS NULL ORDER BY email
|
||||
`
|
||||
|
||||
func (q *Queries) AdminEmails(ctx context.Context) ([]string, error) {
|
||||
rows, err := q.db.Query(ctx, adminEmails)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
items := []string{}
|
||||
for rows.Next() {
|
||||
var email string
|
||||
if err := rows.Scan(&email); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, email)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const countOpenSupportTickets = `-- name: CountOpenSupportTickets :one
|
||||
SELECT count(*) FROM support_tickets WHERE user_id = $1 AND status <> 'closed'
|
||||
`
|
||||
|
||||
func (q *Queries) CountOpenSupportTickets(ctx context.Context, userID uuid.UUID) (int64, error) {
|
||||
row := q.db.QueryRow(ctx, countOpenSupportTickets, userID)
|
||||
var count int64
|
||||
err := row.Scan(&count)
|
||||
return count, err
|
||||
}
|
||||
|
||||
const countSupportTicketsSince = `-- name: CountSupportTicketsSince :one
|
||||
SELECT count(*) FROM support_tickets WHERE user_id = $1 AND created_at >= $2
|
||||
`
|
||||
|
||||
type CountSupportTicketsSinceParams struct {
|
||||
UserID uuid.UUID
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
func (q *Queries) CountSupportTicketsSince(ctx context.Context, arg CountSupportTicketsSinceParams) (int64, error) {
|
||||
row := q.db.QueryRow(ctx, countSupportTicketsSince, arg.UserID, arg.CreatedAt)
|
||||
var count int64
|
||||
err := row.Scan(&count)
|
||||
return count, err
|
||||
}
|
||||
|
||||
const createSupportTicket = `-- name: CreateSupportTicket :one
|
||||
INSERT INTO support_tickets (user_id, org_id, subject, monitor_id, channel_id, alert_group_id, status_page_id, incident_id)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
||||
RETURNING id, user_id, org_id, monitor_id, channel_id, alert_group_id, status_page_id, incident_id, subject, status, created_at, updated_at
|
||||
`
|
||||
|
||||
type CreateSupportTicketParams struct {
|
||||
UserID uuid.UUID
|
||||
OrgID *uuid.UUID
|
||||
Subject string
|
||||
MonitorID *uuid.UUID
|
||||
ChannelID *uuid.UUID
|
||||
AlertGroupID *uuid.UUID
|
||||
StatusPageID *uuid.UUID
|
||||
IncidentID *uuid.UUID
|
||||
}
|
||||
|
||||
func (q *Queries) CreateSupportTicket(ctx context.Context, arg CreateSupportTicketParams) (SupportTicket, error) {
|
||||
row := q.db.QueryRow(ctx, createSupportTicket,
|
||||
arg.UserID,
|
||||
arg.OrgID,
|
||||
arg.Subject,
|
||||
arg.MonitorID,
|
||||
arg.ChannelID,
|
||||
arg.AlertGroupID,
|
||||
arg.StatusPageID,
|
||||
arg.IncidentID,
|
||||
)
|
||||
var i SupportTicket
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.UserID,
|
||||
&i.OrgID,
|
||||
&i.MonitorID,
|
||||
&i.ChannelID,
|
||||
&i.AlertGroupID,
|
||||
&i.StatusPageID,
|
||||
&i.IncidentID,
|
||||
&i.Subject,
|
||||
&i.Status,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getSupportTicket = `-- name: GetSupportTicket :one
|
||||
SELECT t.id, t.user_id, t.org_id, t.monitor_id, t.channel_id, t.alert_group_id, t.status_page_id, t.incident_id, t.subject, t.status, t.created_at, t.updated_at, u.email AS user_email, o.name AS org_name
|
||||
FROM support_tickets t
|
||||
JOIN users u ON u.id = t.user_id
|
||||
LEFT JOIN orgs o ON o.id = t.org_id
|
||||
WHERE t.id = $1
|
||||
`
|
||||
|
||||
type GetSupportTicketRow struct {
|
||||
ID uuid.UUID
|
||||
UserID uuid.UUID
|
||||
OrgID *uuid.UUID
|
||||
MonitorID *uuid.UUID
|
||||
ChannelID *uuid.UUID
|
||||
AlertGroupID *uuid.UUID
|
||||
StatusPageID *uuid.UUID
|
||||
IncidentID *uuid.UUID
|
||||
Subject string
|
||||
Status string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
UserEmail string
|
||||
OrgName *string
|
||||
}
|
||||
|
||||
func (q *Queries) GetSupportTicket(ctx context.Context, id uuid.UUID) (GetSupportTicketRow, error) {
|
||||
row := q.db.QueryRow(ctx, getSupportTicket, id)
|
||||
var i GetSupportTicketRow
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.UserID,
|
||||
&i.OrgID,
|
||||
&i.MonitorID,
|
||||
&i.ChannelID,
|
||||
&i.AlertGroupID,
|
||||
&i.StatusPageID,
|
||||
&i.IncidentID,
|
||||
&i.Subject,
|
||||
&i.Status,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.UserEmail,
|
||||
&i.OrgName,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const listSupportTickets = `-- name: ListSupportTickets :many
|
||||
SELECT t.id, t.user_id, t.org_id, t.monitor_id, t.channel_id, t.alert_group_id, t.status_page_id, t.incident_id, t.subject, t.status, t.created_at, t.updated_at, u.email AS user_email, o.name AS org_name
|
||||
FROM support_tickets t
|
||||
JOIN users u ON u.id = t.user_id
|
||||
LEFT JOIN orgs o ON o.id = t.org_id
|
||||
WHERE $1::text IS NULL OR t.status = $1::text
|
||||
ORDER BY t.status = 'open' DESC, t.updated_at DESC
|
||||
LIMIT 200
|
||||
`
|
||||
|
||||
type ListSupportTicketsRow struct {
|
||||
ID uuid.UUID
|
||||
UserID uuid.UUID
|
||||
OrgID *uuid.UUID
|
||||
MonitorID *uuid.UUID
|
||||
ChannelID *uuid.UUID
|
||||
AlertGroupID *uuid.UUID
|
||||
StatusPageID *uuid.UUID
|
||||
IncidentID *uuid.UUID
|
||||
Subject string
|
||||
Status string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
UserEmail string
|
||||
OrgName *string
|
||||
}
|
||||
|
||||
// Every account's tickets for the admins, those waiting for them first.
|
||||
func (q *Queries) ListSupportTickets(ctx context.Context, status *string) ([]ListSupportTicketsRow, error) {
|
||||
rows, err := q.db.Query(ctx, listSupportTickets, status)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
items := []ListSupportTicketsRow{}
|
||||
for rows.Next() {
|
||||
var i ListSupportTicketsRow
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.UserID,
|
||||
&i.OrgID,
|
||||
&i.MonitorID,
|
||||
&i.ChannelID,
|
||||
&i.AlertGroupID,
|
||||
&i.StatusPageID,
|
||||
&i.IncidentID,
|
||||
&i.Subject,
|
||||
&i.Status,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.UserEmail,
|
||||
&i.OrgName,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const listUserSupportTickets = `-- name: ListUserSupportTickets :many
|
||||
SELECT id, user_id, org_id, monitor_id, channel_id, alert_group_id, status_page_id, incident_id, subject, status, created_at, updated_at FROM support_tickets WHERE user_id = $1 ORDER BY updated_at DESC LIMIT 200
|
||||
`
|
||||
|
||||
// The tickets row-level security lets the account see, newest activity
|
||||
// first.
|
||||
func (q *Queries) ListUserSupportTickets(ctx context.Context, userID uuid.UUID) ([]SupportTicket, error) {
|
||||
rows, err := q.db.Query(ctx, listUserSupportTickets, userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
items := []SupportTicket{}
|
||||
for rows.Next() {
|
||||
var i SupportTicket
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.UserID,
|
||||
&i.OrgID,
|
||||
&i.MonitorID,
|
||||
&i.ChannelID,
|
||||
&i.AlertGroupID,
|
||||
&i.StatusPageID,
|
||||
&i.IncidentID,
|
||||
&i.Subject,
|
||||
&i.Status,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const setSupportTicketStatus = `-- name: SetSupportTicketStatus :execrows
|
||||
UPDATE support_tickets SET status = $2, updated_at = now() WHERE id = $1
|
||||
`
|
||||
|
||||
type SetSupportTicketStatusParams struct {
|
||||
ID uuid.UUID
|
||||
Status string
|
||||
}
|
||||
|
||||
func (q *Queries) SetSupportTicketStatus(ctx context.Context, arg SetSupportTicketStatusParams) (int64, error) {
|
||||
result, err := q.db.Exec(ctx, setSupportTicketStatus, arg.ID, arg.Status)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return result.RowsAffected(), nil
|
||||
}
|
||||
|
||||
const supportMessages = `-- name: SupportMessages :many
|
||||
SELECT m.id, m.ticket_id, m.author_id, m.from_staff, m.body, m.created_at, coalesce(u.email, '')::text AS author_email
|
||||
FROM support_messages m
|
||||
LEFT JOIN users u ON u.id = m.author_id
|
||||
WHERE m.ticket_id = $1
|
||||
ORDER BY m.created_at, m.id
|
||||
`
|
||||
|
||||
type SupportMessagesRow struct {
|
||||
ID uuid.UUID
|
||||
TicketID uuid.UUID
|
||||
AuthorID *uuid.UUID
|
||||
FromStaff bool
|
||||
Body string
|
||||
CreatedAt time.Time
|
||||
AuthorEmail string
|
||||
}
|
||||
|
||||
func (q *Queries) SupportMessages(ctx context.Context, ticketID uuid.UUID) ([]SupportMessagesRow, error) {
|
||||
rows, err := q.db.Query(ctx, supportMessages, ticketID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
items := []SupportMessagesRow{}
|
||||
for rows.Next() {
|
||||
var i SupportMessagesRow
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.TicketID,
|
||||
&i.AuthorID,
|
||||
&i.FromStaff,
|
||||
&i.Body,
|
||||
&i.CreatedAt,
|
||||
&i.AuthorEmail,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const supportOptionsAlertGroups = `-- name: SupportOptionsAlertGroups :many
|
||||
SELECT id, name FROM alert_groups WHERE org_id = $1 ORDER BY lower(name) LIMIT 500
|
||||
`
|
||||
|
||||
type SupportOptionsAlertGroupsRow struct {
|
||||
ID uuid.UUID
|
||||
Name string
|
||||
}
|
||||
|
||||
func (q *Queries) SupportOptionsAlertGroups(ctx context.Context, orgID uuid.UUID) ([]SupportOptionsAlertGroupsRow, error) {
|
||||
rows, err := q.db.Query(ctx, supportOptionsAlertGroups, orgID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
items := []SupportOptionsAlertGroupsRow{}
|
||||
for rows.Next() {
|
||||
var i SupportOptionsAlertGroupsRow
|
||||
if err := rows.Scan(&i.ID, &i.Name); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const supportOptionsChannels = `-- name: SupportOptionsChannels :many
|
||||
SELECT id, name, type FROM notification_channels WHERE org_id = $1 ORDER BY lower(name) LIMIT 500
|
||||
`
|
||||
|
||||
type SupportOptionsChannelsRow struct {
|
||||
ID uuid.UUID
|
||||
Name string
|
||||
Type string
|
||||
}
|
||||
|
||||
func (q *Queries) SupportOptionsChannels(ctx context.Context, orgID uuid.UUID) ([]SupportOptionsChannelsRow, error) {
|
||||
rows, err := q.db.Query(ctx, supportOptionsChannels, orgID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
items := []SupportOptionsChannelsRow{}
|
||||
for rows.Next() {
|
||||
var i SupportOptionsChannelsRow
|
||||
if err := rows.Scan(&i.ID, &i.Name, &i.Type); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const supportOptionsIncidents = `-- name: SupportOptionsIncidents :many
|
||||
SELECT i.id, i.title, i.started_at, m.name AS monitor_name
|
||||
FROM incidents i JOIN monitors m ON m.id = i.monitor_id
|
||||
WHERE i.org_id = $1 ORDER BY i.started_at DESC LIMIT 50
|
||||
`
|
||||
|
||||
type SupportOptionsIncidentsRow struct {
|
||||
ID uuid.UUID
|
||||
Title string
|
||||
StartedAt time.Time
|
||||
MonitorName string
|
||||
}
|
||||
|
||||
func (q *Queries) SupportOptionsIncidents(ctx context.Context, orgID uuid.UUID) ([]SupportOptionsIncidentsRow, error) {
|
||||
rows, err := q.db.Query(ctx, supportOptionsIncidents, orgID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
items := []SupportOptionsIncidentsRow{}
|
||||
for rows.Next() {
|
||||
var i SupportOptionsIncidentsRow
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.Title,
|
||||
&i.StartedAt,
|
||||
&i.MonitorName,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const supportOptionsMonitors = `-- name: SupportOptionsMonitors :many
|
||||
SELECT id, name FROM monitors WHERE org_id = $1 ORDER BY lower(name) LIMIT 500
|
||||
`
|
||||
|
||||
type SupportOptionsMonitorsRow struct {
|
||||
ID uuid.UUID
|
||||
Name string
|
||||
}
|
||||
|
||||
func (q *Queries) SupportOptionsMonitors(ctx context.Context, orgID uuid.UUID) ([]SupportOptionsMonitorsRow, error) {
|
||||
rows, err := q.db.Query(ctx, supportOptionsMonitors, orgID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
items := []SupportOptionsMonitorsRow{}
|
||||
for rows.Next() {
|
||||
var i SupportOptionsMonitorsRow
|
||||
if err := rows.Scan(&i.ID, &i.Name); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const supportOptionsStatusPages = `-- name: SupportOptionsStatusPages :many
|
||||
SELECT id, title FROM status_pages WHERE org_id = $1 ORDER BY lower(title) LIMIT 500
|
||||
`
|
||||
|
||||
type SupportOptionsStatusPagesRow struct {
|
||||
ID uuid.UUID
|
||||
Title string
|
||||
}
|
||||
|
||||
func (q *Queries) SupportOptionsStatusPages(ctx context.Context, orgID uuid.UUID) ([]SupportOptionsStatusPagesRow, error) {
|
||||
rows, err := q.db.Query(ctx, supportOptionsStatusPages, orgID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
items := []SupportOptionsStatusPagesRow{}
|
||||
for rows.Next() {
|
||||
var i SupportOptionsStatusPagesRow
|
||||
if err := rows.Scan(&i.ID, &i.Title); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const supportReferencesExist = `-- name: SupportReferencesExist :one
|
||||
SELECT ($1::uuid IS NULL OR EXISTS (SELECT 1 FROM monitors m WHERE m.id = $1 AND m.org_id = $2::uuid))
|
||||
AND ($3::uuid IS NULL OR EXISTS (SELECT 1 FROM notification_channels c WHERE c.id = $3 AND c.org_id = $2::uuid))
|
||||
AND ($4::uuid IS NULL OR EXISTS (SELECT 1 FROM alert_groups g WHERE g.id = $4 AND g.org_id = $2::uuid))
|
||||
AND ($5::uuid IS NULL OR EXISTS (SELECT 1 FROM status_pages p WHERE p.id = $5 AND p.org_id = $2::uuid))
|
||||
AND ($6::uuid IS NULL OR EXISTS (SELECT 1 FROM incidents i WHERE i.id = $6 AND i.org_id = $2::uuid))
|
||||
AS ok
|
||||
`
|
||||
|
||||
type SupportReferencesExistParams struct {
|
||||
MonitorID *uuid.UUID
|
||||
OrgID uuid.UUID
|
||||
ChannelID *uuid.UUID
|
||||
AlertGroupID *uuid.UUID
|
||||
StatusPageID *uuid.UUID
|
||||
IncidentID *uuid.UUID
|
||||
}
|
||||
|
||||
// Whether everything a new ticket points at belongs to org; run in the
|
||||
// organization's scope so only what the account may see counts.
|
||||
func (q *Queries) SupportReferencesExist(ctx context.Context, arg SupportReferencesExistParams) (*bool, error) {
|
||||
row := q.db.QueryRow(ctx, supportReferencesExist,
|
||||
arg.MonitorID,
|
||||
arg.OrgID,
|
||||
arg.ChannelID,
|
||||
arg.AlertGroupID,
|
||||
arg.StatusPageID,
|
||||
arg.IncidentID,
|
||||
)
|
||||
var ok *bool
|
||||
err := row.Scan(&ok)
|
||||
return ok, err
|
||||
}
|
||||
|
||||
const supportTicketReferences = `-- name: SupportTicketReferences :one
|
||||
SELECT o.name AS org_name, o.slug AS org_slug,
|
||||
m.name AS monitor_name, m.type AS monitor_type,
|
||||
ch.name AS channel_name, ch.type AS channel_type,
|
||||
ag.name AS alert_group_name,
|
||||
sp.title AS status_page_title, sp.slug AS status_page_slug,
|
||||
i.title AS incident_title, i.started_at AS incident_started_at, im.name AS incident_monitor
|
||||
FROM support_tickets t
|
||||
LEFT JOIN orgs o ON o.id = t.org_id
|
||||
LEFT JOIN monitors m ON m.id = t.monitor_id
|
||||
LEFT JOIN notification_channels ch ON ch.id = t.channel_id
|
||||
LEFT JOIN alert_groups ag ON ag.id = t.alert_group_id
|
||||
LEFT JOIN status_pages sp ON sp.id = t.status_page_id
|
||||
LEFT JOIN incidents i ON i.id = t.incident_id
|
||||
LEFT JOIN monitors im ON im.id = i.monitor_id
|
||||
WHERE t.id = $1
|
||||
`
|
||||
|
||||
type SupportTicketReferencesRow struct {
|
||||
OrgName *string
|
||||
OrgSlug *string
|
||||
MonitorName *string
|
||||
MonitorType *string
|
||||
ChannelName *string
|
||||
ChannelType *string
|
||||
AlertGroupName *string
|
||||
StatusPageTitle *string
|
||||
StatusPageSlug *string
|
||||
IncidentTitle *string
|
||||
IncidentStartedAt *time.Time
|
||||
IncidentMonitor *string
|
||||
}
|
||||
|
||||
// The names of what a ticket points at, for showing it.
|
||||
func (q *Queries) SupportTicketReferences(ctx context.Context, id uuid.UUID) (SupportTicketReferencesRow, error) {
|
||||
row := q.db.QueryRow(ctx, supportTicketReferences, id)
|
||||
var i SupportTicketReferencesRow
|
||||
err := row.Scan(
|
||||
&i.OrgName,
|
||||
&i.OrgSlug,
|
||||
&i.MonitorName,
|
||||
&i.MonitorType,
|
||||
&i.ChannelName,
|
||||
&i.ChannelType,
|
||||
&i.AlertGroupName,
|
||||
&i.StatusPageTitle,
|
||||
&i.StatusPageSlug,
|
||||
&i.IncidentTitle,
|
||||
&i.IncidentStartedAt,
|
||||
&i.IncidentMonitor,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const supportTicketStatus = `-- name: SupportTicketStatus :one
|
||||
SELECT status FROM support_tickets WHERE id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) SupportTicketStatus(ctx context.Context, id uuid.UUID) (string, error) {
|
||||
row := q.db.QueryRow(ctx, supportTicketStatus, id)
|
||||
var status string
|
||||
err := row.Scan(&status)
|
||||
return status, err
|
||||
}
|
||||
@@ -108,3 +108,13 @@
|
||||
filter: invert(0.92) hue-rotate(180deg);
|
||||
}
|
||||
}
|
||||
|
||||
/* Outside any layer so it wins over text-sm and text-xs: iOS zooms into
|
||||
form fields whose text is smaller than 16px. */
|
||||
@media (pointer: coarse) {
|
||||
input:not([type="checkbox"]):not([type="radio"]),
|
||||
select,
|
||||
textarea {
|
||||
font-size: max(16px, 1em);
|
||||
}
|
||||
}
|
||||
@@ -179,6 +179,13 @@
|
||||
});
|
||||
|
||||
document.addEventListener("click", async (ev) => {
|
||||
const navToggle = ev.target.closest("[data-nav-toggle]");
|
||||
if (navToggle) {
|
||||
const nav = document.getElementById(navToggle.dataset.navToggle);
|
||||
const open = nav?.classList.toggle("hidden") === false;
|
||||
navToggle.setAttribute("aria-expanded", String(open));
|
||||
return;
|
||||
}
|
||||
const locale = ev.target.closest("[data-locale]");
|
||||
if (locale) {
|
||||
await api.post("/locale", { locale: locale.dataset.locale }).catch(() => {});
|
||||
|
||||
+13
-3
@@ -78,7 +78,7 @@ type SignupConsent struct {
|
||||
templ consentLinks(docs []LegalLink) {
|
||||
for i, d := range docs {
|
||||
if i > 0 {
|
||||
{ i18n.T(ctx, "consent.and") }
|
||||
{ " " + i18n.T(ctx, "consent.and") }
|
||||
}
|
||||
<a href={ templ.SafeURL(d.Href) } target="_blank" rel="noopener" class="underline underline-offset-2">{ i18n.T(ctx, "consent.doc."+d.Kind) }</a>
|
||||
}
|
||||
@@ -222,7 +222,12 @@ templ ConsentPage(p Page, me Me, docs []LegalLink, versions, next string) {
|
||||
</label>
|
||||
@submit(i18n.T(ctx, "consent.submit"))
|
||||
</form>
|
||||
<p class="mt-6 text-sm"><button data-logout class="underline underline-offset-2">{ i18n.T(ctx, "console.nav.logout") }</button></p>
|
||||
<p class="mt-6 flex flex-wrap gap-x-4 text-sm">
|
||||
if me.Support {
|
||||
<a href="/support" class="underline underline-offset-2">{ i18n.T(ctx, "support.contact") }</a>
|
||||
}
|
||||
<button data-logout class="underline underline-offset-2">{ i18n.T(ctx, "console.nav.logout") }</button>
|
||||
</p>
|
||||
<div class="mt-12 border-t border-rule pt-6">
|
||||
<p class="mb-6 text-sm text-muted">{ i18n.T(ctx, "consent.decline") }</p>
|
||||
@accountDataBody(me)
|
||||
@@ -246,7 +251,12 @@ templ SuspendedPage(p Page, me Me, reason string) {
|
||||
<p class="mb-6 border-l-2 border-down pl-3 text-sm">{ reason }</p>
|
||||
}
|
||||
<p class="mb-6 text-sm text-muted">{ i18n.T(ctx, "suspended.options") }</p>
|
||||
<p class="mb-10 text-sm"><button data-logout class="underline underline-offset-2">{ i18n.T(ctx, "console.nav.logout") }</button></p>
|
||||
<p class="mb-10 flex flex-wrap gap-x-4 text-sm">
|
||||
if me.Support {
|
||||
<a href="/support" class="underline underline-offset-2">{ i18n.T(ctx, "support.contact") }</a>
|
||||
}
|
||||
<button data-logout class="underline underline-offset-2">{ i18n.T(ctx, "console.nav.logout") }</button>
|
||||
</p>
|
||||
@accountDataBody(me)
|
||||
</main>
|
||||
}
|
||||
|
||||
+106
-60
@@ -356,9 +356,9 @@ func consentLinks(docs []LegalLink) templ.Component {
|
||||
for i, d := range docs {
|
||||
if i > 0 {
|
||||
var templ_7745c5c3_Var17 string
|
||||
templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "consent.and"))
|
||||
templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(" " + i18n.T(ctx, "consent.and"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/auth.templ`, Line: 81, Col: 31}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/auth.templ`, Line: 81, Col: 37}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1292,33 +1292,56 @@ func ConsentPage(p Page, me Me, docs []LegalLink, versions, next string) templ.C
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 85, "</form><p class=\"mt-6 text-sm\"><button data-logout class=\"underline underline-offset-2\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 85, "</form><p class=\"mt-6 flex flex-wrap gap-x-4 text-sm\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var64 string
|
||||
templ_7745c5c3_Var64, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.nav.logout"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/auth.templ`, Line: 225, Col: 119}
|
||||
if me.Support {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 86, "<a href=\"/support\" class=\"underline underline-offset-2\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var64 string
|
||||
templ_7745c5c3_Var64, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "support.contact"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/auth.templ`, Line: 227, Col: 93}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var64))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 87, "</a> ")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var64))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 86, "</button></p><div class=\"mt-12 border-t border-rule pt-6\"><p class=\"mb-6 text-sm text-muted\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 88, "<button data-logout class=\"underline underline-offset-2\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var65 string
|
||||
templ_7745c5c3_Var65, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "consent.decline"))
|
||||
templ_7745c5c3_Var65, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.nav.logout"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/auth.templ`, Line: 227, Col: 71}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/auth.templ`, Line: 229, Col: 96}
|
||||
}
|
||||
_, 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, 87, "</p>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 89, "</button></p><div class=\"mt-12 border-t border-rule pt-6\"><p class=\"mb-6 text-sm text-muted\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var66 string
|
||||
templ_7745c5c3_Var66, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "consent.decline"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/auth.templ`, Line: 232, Col: 71}
|
||||
}
|
||||
_, 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, 90, "</p>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -1326,7 +1349,7 @@ func ConsentPage(p Page, me Me, docs []LegalLink, versions, next string) templ.C
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 88, "</div></main>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 91, "</div></main>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -1359,7 +1382,7 @@ func SuspendedPage(p Page, me Me, reason string) templ.Component {
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Var67 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_Var68 := 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 {
|
||||
@@ -1371,7 +1394,7 @@ func SuspendedPage(p Page, me Me, reason string) templ.Component {
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 89, "<main class=\"mx-auto mt-[8vh] w-full max-w-xl px-6 pb-16\"><div class=\"mb-10 flex items-center justify-between\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 92, "<main class=\"mx-auto mt-[8vh] w-full max-w-xl px-6 pb-16\"><div class=\"mb-10 flex items-center justify-between\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -1383,82 +1406,105 @@ func SuspendedPage(p Page, me Me, reason string) templ.Component {
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 90, "</div><h1 class=\"mb-4 text-xl font-semibold\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var68 string
|
||||
templ_7745c5c3_Var68, 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/auth.templ`, Line: 243, Col: 66}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var68))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 91, "</h1><p class=\"mb-2 text-sm\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 93, "</div><h1 class=\"mb-4 text-xl font-semibold\">")
|
||||
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, "suspended.intro"))
|
||||
templ_7745c5c3_Var69, 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/auth.templ`, Line: 244, Col: 59}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/auth.templ`, Line: 248, Col: 66}
|
||||
}
|
||||
_, 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, 92, "</p>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 94, "</h1><p class=\"mb-2 text-sm\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var70 string
|
||||
templ_7745c5c3_Var70, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "suspended.intro"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/auth.templ`, Line: 249, Col: 59}
|
||||
}
|
||||
_, 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, 95, "</p>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if reason != "" {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 93, "<p class=\"mb-6 border-l-2 border-down pl-3 text-sm\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 96, "<p class=\"mb-6 border-l-2 border-down pl-3 text-sm\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var70 string
|
||||
templ_7745c5c3_Var70, templ_7745c5c3_Err = templ.JoinStringErrs(reason)
|
||||
var templ_7745c5c3_Var71 string
|
||||
templ_7745c5c3_Var71, templ_7745c5c3_Err = templ.JoinStringErrs(reason)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/auth.templ`, Line: 246, Col: 64}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/auth.templ`, Line: 251, Col: 64}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var70))
|
||||
_, 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, 94, "</p>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 97, "</p>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 95, "<p class=\"mb-6 text-sm text-muted\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var71 string
|
||||
templ_7745c5c3_Var71, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "suspended.options"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/auth.templ`, Line: 248, Col: 72}
|
||||
}
|
||||
_, 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, 96, "</p><p class=\"mb-10 text-sm\"><button data-logout class=\"underline underline-offset-2\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 98, "<p class=\"mb-6 text-sm text-muted\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var72 string
|
||||
templ_7745c5c3_Var72, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.nav.logout"))
|
||||
templ_7745c5c3_Var72, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "suspended.options"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/auth.templ`, Line: 249, Col: 120}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/auth.templ`, Line: 253, Col: 72}
|
||||
}
|
||||
_, 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, 97, "</button></p>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 99, "</p><p class=\"mb-10 flex flex-wrap gap-x-4 text-sm\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if me.Support {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 100, "<a href=\"/support\" class=\"underline underline-offset-2\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var73 string
|
||||
templ_7745c5c3_Var73, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "support.contact"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/auth.templ`, Line: 256, Col: 93}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var73))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 101, "</a> ")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 102, "<button data-logout class=\"underline underline-offset-2\">")
|
||||
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, "console.nav.logout"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/auth.templ`, Line: 258, Col: 96}
|
||||
}
|
||||
_, 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, 103, "</button></p>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -1466,13 +1512,13 @@ func SuspendedPage(p Page, me Me, reason string) templ.Component {
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 98, "</main>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 104, "</main>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
templ_7745c5c3_Err = Layout(p).Render(templ.WithChildren(ctx, templ_7745c5c3_Var67), templ_7745c5c3_Buffer)
|
||||
templ_7745c5c3_Err = Layout(p).Render(templ.WithChildren(ctx, templ_7745c5c3_Var68), templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
||||
+21
-19
@@ -111,25 +111,27 @@ templ CheckerPage(p Page, me Me, v CheckerView) {
|
||||
if len(v.Recent) == 0 {
|
||||
<p class="text-sm text-muted">{ i18n.T(ctx, "checkers.no_recent") }</p>
|
||||
} else {
|
||||
<table class="w-full text-left text-sm">
|
||||
<tbody class="divide-y divide-rule border-y border-rule">
|
||||
for _, r := range v.Recent {
|
||||
<tr>
|
||||
<td class="py-1.5 pr-4 font-mono text-xs whitespace-nowrap text-muted">{ r.Time }</td>
|
||||
<td class="py-1.5 pr-4"><a href={ templ.SafeURL(r.MonitorURL) } class="hover:underline">{ r.Monitor }</a></td>
|
||||
<td class="py-1.5 pr-4">
|
||||
if r.OK {
|
||||
<span class="text-up">●</span>
|
||||
} else {
|
||||
<span class="text-down">●</span>
|
||||
}
|
||||
</td>
|
||||
<td class="py-1.5 pr-4 font-mono text-xs">{ r.Latency }</td>
|
||||
<td class="py-1.5 font-mono text-xs text-muted">{ r.Detail }</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full text-left text-sm">
|
||||
<tbody class="divide-y divide-rule border-y border-rule">
|
||||
for _, r := range v.Recent {
|
||||
<tr>
|
||||
<td class="py-1.5 pr-4 font-mono text-xs whitespace-nowrap text-muted">{ r.Time }</td>
|
||||
<td class="py-1.5 pr-4"><a href={ templ.SafeURL(r.MonitorURL) } class="hover:underline">{ r.Monitor }</a></td>
|
||||
<td class="py-1.5 pr-4">
|
||||
if r.OK {
|
||||
<span class="text-up">●</span>
|
||||
} else {
|
||||
<span class="text-down">●</span>
|
||||
}
|
||||
</td>
|
||||
<td class="py-1.5 pr-4 font-mono text-xs">{ r.Latency }</td>
|
||||
<td class="py-1.5 font-mono text-xs text-muted">{ r.Detail }</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
@pager(v.Pager, "newer", "older")
|
||||
</section>
|
||||
|
||||
@@ -380,7 +380,7 @@ func CheckerPage(p Page, me Me, v CheckerView) templ.Component {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
} else {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "<table class=\"w-full text-left text-sm\"><tbody class=\"divide-y divide-rule border-y border-rule\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "<div class=\"overflow-x-auto\"><table class=\"w-full text-left text-sm\"><tbody class=\"divide-y divide-rule border-y border-rule\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -392,7 +392,7 @@ func CheckerPage(p Page, me Me, v CheckerView) templ.Component {
|
||||
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: 118, Col: 87}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/checkers.templ`, Line: 119, Col: 88}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -405,7 +405,7 @@ func CheckerPage(p Page, me Me, v CheckerView) templ.Component {
|
||||
var templ_7745c5c3_Var18 string
|
||||
templ_7745c5c3_Var18, templ_7745c5c3_Err = templruntime.NewAttributeExpression(templ.SafeURL(r.MonitorURL)).ResolveURL(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/checkers.templ`, Line: 119, Col: 69}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/checkers.templ`, Line: 120, Col: 70}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var18)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -418,7 +418,7 @@ func CheckerPage(p Page, me Me, v CheckerView) templ.Component {
|
||||
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: 119, Col: 107}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/checkers.templ`, Line: 120, Col: 108}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -446,7 +446,7 @@ func CheckerPage(p Page, me Me, v CheckerView) templ.Component {
|
||||
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: 127, Col: 61}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/checkers.templ`, Line: 128, Col: 62}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -459,7 +459,7 @@ func CheckerPage(p Page, me Me, v CheckerView) templ.Component {
|
||||
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: 128, Col: 66}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/checkers.templ`, Line: 129, Col: 67}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -470,7 +470,7 @@ func CheckerPage(p Page, me Me, v CheckerView) templ.Component {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, "</tbody></table>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, "</tbody></table></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -504,7 +504,7 @@ func CheckerPage(p Page, me Me, v CheckerView) templ.Component {
|
||||
var templ_7745c5c3_Var22 string
|
||||
templ_7745c5c3_Var22, templ_7745c5c3_Err = templruntime.NewAttributeExpression(templ.SafeURL(sb.URL)).ResolveURL(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/checkers.templ`, Line: 141, Col: 37}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/checkers.templ`, Line: 143, Col: 37}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var22)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -517,7 +517,7 @@ func CheckerPage(p Page, me Me, v CheckerView) templ.Component {
|
||||
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: 141, Col: 87}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/checkers.templ`, Line: 143, Col: 87}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -567,7 +567,7 @@ func checkerFact(labelID, value string) templ.Component {
|
||||
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: 151, Col: 55}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/checkers.templ`, Line: 153, Col: 55}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var25))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -580,7 +580,7 @@ func checkerFact(labelID, value string) templ.Component {
|
||||
var templ_7745c5c3_Var26 string
|
||||
templ_7745c5c3_Var26, templ_7745c5c3_Err = templruntime.NewAttributeExpression(value).Resolve(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/checkers.templ`, Line: 152, Col: 54}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/checkers.templ`, Line: 154, Col: 54}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var26)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -593,7 +593,7 @@ func checkerFact(labelID, value string) templ.Component {
|
||||
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: 152, Col: 64}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/checkers.templ`, Line: 154, Col: 64}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var27))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -632,7 +632,7 @@ func checkerCell(l CheckerLink) templ.Component {
|
||||
var templ_7745c5c3_Var29 string
|
||||
templ_7745c5c3_Var29, templ_7745c5c3_Err = templruntime.NewAttributeExpression(templ.SafeURL(l.URL)).ResolveURL(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/checkers.templ`, Line: 158, Col: 32}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/checkers.templ`, Line: 160, Col: 32}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var29)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -645,7 +645,7 @@ func checkerCell(l CheckerLink) templ.Component {
|
||||
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: 158, Col: 68}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/checkers.templ`, Line: 160, Col: 68}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var30))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -663,7 +663,7 @@ func checkerCell(l CheckerLink) templ.Component {
|
||||
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: 160, Col: 36}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/checkers.templ`, Line: 162, Col: 36}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var31))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
|
||||
+50
-31
@@ -30,6 +30,8 @@ type Me struct {
|
||||
// DeletesOrgs names the organizations the account is the last owner
|
||||
// of; deleting it deletes them, with all their monitors.
|
||||
DeletesOrgs []string
|
||||
// Support is set while accounts can open support tickets.
|
||||
Support bool
|
||||
}
|
||||
|
||||
// Org is one entry of the organization switcher.
|
||||
@@ -43,41 +45,58 @@ type Org struct {
|
||||
templ consoleShell(p Page, me Me) {
|
||||
@Layout(p) {
|
||||
<header class="border-b border-rule">
|
||||
<div class="mx-auto flex max-w-5xl items-center gap-6 px-6 py-3 text-sm">
|
||||
<div class="mx-auto flex max-w-5xl flex-wrap items-center gap-x-4 gap-y-3 px-4 py-3 text-sm sm:gap-x-6 sm:px-6">
|
||||
@brandLockup("/")
|
||||
if len(me.Orgs) > 1 {
|
||||
<select data-switch-org class="border border-rule bg-transparent px-1.5 py-0.5 text-sm">
|
||||
for _, o := range me.Orgs {
|
||||
<option value={ o.ID } selected?={ o.ID == me.ActiveOrg }>{ o.Name }</option>
|
||||
<span class="flex min-w-0 items-center gap-2">
|
||||
if len(me.Orgs) > 1 {
|
||||
<select data-switch-org class="max-w-[10rem] min-w-0 border border-rule bg-transparent px-1.5 py-0.5 text-sm sm:max-w-none">
|
||||
for _, o := range me.Orgs {
|
||||
<option value={ o.ID } selected?={ o.ID == me.ActiveOrg }>{ o.Name }</option>
|
||||
}
|
||||
</select>
|
||||
} else if len(me.Orgs) == 1 {
|
||||
<span class="truncate text-muted">{ me.Orgs[0].Name }</span>
|
||||
}
|
||||
<a href="/orgs/new" class="px-1 text-muted hover:text-ink" title={ i18n.T(ctx, "orgs.new_title") } aria-label={ i18n.T(ctx, "orgs.new_title") }>+</a>
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
data-nav-toggle="console-nav"
|
||||
aria-controls="console-nav"
|
||||
aria-expanded="false"
|
||||
aria-label={ i18n.T(ctx, "console.nav.menu") }
|
||||
class="ml-auto -my-1 border border-rule px-2.5 py-1 text-muted hover:text-ink lg:hidden"
|
||||
>
|
||||
<span aria-hidden="true">☰</span> <span class="hidden sm:inline">{ i18n.T(ctx, "console.nav.menu") }</span>
|
||||
</button>
|
||||
<div id="console-nav" class="hidden w-full flex-col gap-4 border-t border-rule pt-3 lg:flex lg:w-auto lg:flex-1 lg:flex-row lg:items-center lg:gap-5 lg:border-0 lg:pt-0">
|
||||
<nav class="flex flex-col gap-3 lg:flex-row lg:items-center lg:gap-5 lg:whitespace-nowrap">
|
||||
<a href="/" class="text-muted hover:text-ink">{ i18n.T(ctx, "console.monitors.title") }</a>
|
||||
if me.Can["statuspages.read"] {
|
||||
<a href="/statuspages" class="text-muted hover:text-ink">{ i18n.T(ctx, "pages.title") }</a>
|
||||
}
|
||||
</select>
|
||||
} else if len(me.Orgs) == 1 {
|
||||
<span class="text-muted">{ me.Orgs[0].Name }</span>
|
||||
}
|
||||
<a href="/orgs/new" class="-ml-4 text-muted hover:text-ink" title={ i18n.T(ctx, "orgs.new_title") } aria-label={ i18n.T(ctx, "orgs.new_title") }>+</a>
|
||||
<nav class="flex items-center gap-5 whitespace-nowrap">
|
||||
<a href="/" class="text-muted hover:text-ink">{ i18n.T(ctx, "console.monitors.title") }</a>
|
||||
if me.Can["statuspages.read"] {
|
||||
<a href="/statuspages" class="text-muted hover:text-ink">{ i18n.T(ctx, "pages.title") }</a>
|
||||
}
|
||||
if me.Can["incidents.read"] {
|
||||
<a href="/incidents" class="text-muted hover:text-ink">{ i18n.T(ctx, "incidents.title") }</a>
|
||||
<a href="/maintenance" class="text-muted hover:text-ink">{ i18n.T(ctx, "maintenance.title") }</a>
|
||||
}
|
||||
</nav>
|
||||
<nav class="ml-auto flex items-center gap-5 whitespace-nowrap">
|
||||
<a href="/settings" class="text-muted hover:text-ink">{ i18n.T(ctx, "console.nav.settings") }</a>
|
||||
if me.IsAdmin {
|
||||
<a href="/admin" class="font-medium hover:underline">{ i18n.T(ctx, "console.nav.admin") }</a>
|
||||
}
|
||||
<button data-logout class="text-muted hover:text-ink">{ i18n.T(ctx, "console.nav.logout") }</button>
|
||||
@languageSwitch(p.Languages)
|
||||
</nav>
|
||||
if me.Can["incidents.read"] {
|
||||
<a href="/incidents" class="text-muted hover:text-ink">{ i18n.T(ctx, "incidents.title") }</a>
|
||||
<a href="/maintenance" class="text-muted hover:text-ink">{ i18n.T(ctx, "maintenance.title") }</a>
|
||||
}
|
||||
</nav>
|
||||
<nav class="flex flex-col gap-3 border-t border-rule pt-3 lg:ml-auto lg:flex-row lg:items-center lg:gap-5 lg:whitespace-nowrap lg:border-0 lg:pt-0">
|
||||
if me.Support {
|
||||
<a href="/support" class="text-muted hover:text-ink">{ i18n.T(ctx, "support.title") }</a>
|
||||
}
|
||||
<a href="/settings" class="text-muted hover:text-ink">{ i18n.T(ctx, "console.nav.settings") }</a>
|
||||
if me.IsAdmin {
|
||||
<a href="/admin" class="font-medium hover:underline">{ i18n.T(ctx, "console.nav.admin") }</a>
|
||||
}
|
||||
<button data-logout class="text-left text-muted hover:text-ink">{ i18n.T(ctx, "console.nav.logout") }</button>
|
||||
@languageSwitch(p.Languages)
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
if me.OrgSuspended {
|
||||
<div class="border-b border-down bg-down/10" role="alert">
|
||||
<p class="mx-auto max-w-5xl px-6 py-3 text-sm">
|
||||
<p class="mx-auto max-w-5xl px-4 sm:px-6 py-3 text-sm">
|
||||
<strong>{ i18n.T(ctx, "console.org_suspended") }</strong>
|
||||
if me.SuspendedReason != "" {
|
||||
{ " " + i18n.T(ctx, "console.suspended_reason", "Reason", me.SuspendedReason) }
|
||||
@@ -91,7 +110,7 @@ templ consoleShell(p Page, me Me) {
|
||||
case "sso_required_by_org":
|
||||
@policyBanner("error.sso_required_by_org", "console.sso_required_action", "/sso/"+me.ActiveSlug)
|
||||
}
|
||||
<main class="mx-auto max-w-5xl px-6 py-10">
|
||||
<main class="mx-auto max-w-5xl px-4 py-6 sm:px-6 sm:py-10">
|
||||
@flash(p)
|
||||
{ children... }
|
||||
</main>
|
||||
@@ -226,7 +245,7 @@ templ recoveryOutput() {
|
||||
|
||||
templ policyBanner(msgID, actionID, href string) {
|
||||
<div class="border-b border-degraded/40 bg-degraded/10">
|
||||
<p class="mx-auto max-w-5xl px-6 py-2 text-sm">
|
||||
<p class="mx-auto max-w-5xl px-4 sm:px-6 py-2 text-sm">
|
||||
{ i18n.T(ctx, msgID) }
|
||||
<a href={ templ.SafeURL(href) } class="underline underline-offset-2">{ i18n.T(ctx, actionID) }</a>
|
||||
</p>
|
||||
|
||||
+378
-323
File diff suppressed because it is too large.
Load diff
+12
-10
@@ -90,16 +90,18 @@ templ evidenceList(rows []EvidenceRow) {
|
||||
}
|
||||
|
||||
templ headerTable(rows [][2]string) {
|
||||
<table class="w-full text-left font-mono text-xs">
|
||||
<tbody>
|
||||
for _, h := range rows {
|
||||
<tr class="align-top">
|
||||
<td class="w-1/3 py-0.5 pr-3 text-muted">{ h[0] }</td>
|
||||
<td class="break-all py-0.5">{ h[1] }</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full text-left font-mono text-xs">
|
||||
<tbody>
|
||||
for _, h := range rows {
|
||||
<tr class="align-top">
|
||||
<td class="w-1/3 py-0.5 pr-3 text-muted">{ h[0] }</td>
|
||||
<td class="break-all py-0.5">{ h[1] }</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
|
||||
templ EvidencePage(p Page, me Me, v EvidenceView) {
|
||||
|
||||
@@ -215,7 +215,7 @@ func headerTable(rows [][2]string) templ.Component {
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "<table class=\"w-full text-left font-mono text-xs\"><tbody>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "<div class=\"overflow-x-auto\"><table class=\"w-full text-left font-mono text-xs\"><tbody>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -227,7 +227,7 @@ func headerTable(rows [][2]string) templ.Component {
|
||||
var templ_7745c5c3_Var8 string
|
||||
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(h[0])
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 97, Col: 52}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 98, Col: 53}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -240,7 +240,7 @@ func headerTable(rows [][2]string) templ.Component {
|
||||
var templ_7745c5c3_Var9 string
|
||||
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(h[1])
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 98, Col: 40}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 99, Col: 41}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -251,7 +251,7 @@ func headerTable(rows [][2]string) templ.Component {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "</tbody></table>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "</tbody></table></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -295,7 +295,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var12 string
|
||||
templ_7745c5c3_Var12, templ_7745c5c3_Err = templruntime.NewAttributeExpression(templ.SafeURL("/monitors/" + v.MonitorID)).ResolveURL(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 108, Col: 54}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 110, Col: 54}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var12)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -308,7 +308,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var13 string
|
||||
templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(v.MonitorName)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 108, Col: 110}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 110, Col: 110}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -340,7 +340,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var14 string
|
||||
templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "evidence.heading"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 116, Col: 36}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 118, Col: 36}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -353,7 +353,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var15 string
|
||||
templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(v.Time)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 119, Col: 11}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 121, Col: 11}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -366,7 +366,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var16 string
|
||||
templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(v.Region)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 119, Col: 27}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 121, Col: 27}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -380,7 +380,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var17 string
|
||||
templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(" · " + v.RemoteAddr)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 121, Col: 27}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 123, Col: 27}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -399,7 +399,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var18 string
|
||||
templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(v.Error)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 126, Col: 13}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 128, Col: 13}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -417,7 +417,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var19 string
|
||||
templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "evidence.failed_at", "Stage", i18n.T(ctx, "evidence.stage_"+v.FailedAt)))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 128, Col: 131}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 130, Col: 131}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -448,7 +448,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var20 string
|
||||
templ_7745c5c3_Var20, templ_7745c5c3_Err = templruntime.NewAttributeExpression(i18n.T(ctx, "evidence.timing")).Resolve(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 134, Col: 118}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 136, Col: 118}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var20)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -488,7 +488,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var23 string
|
||||
templ_7745c5c3_Var23, templ_7745c5c3_Err = templruntime.SanitizeStyleAttributeValues(widthStyle(ph.Percent))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 136, Col: 75}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 138, Col: 75}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -501,7 +501,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var24 string
|
||||
templ_7745c5c3_Var24, templ_7745c5c3_Err = templruntime.NewAttributeExpression(i18n.T(ctx, "evidence.phase_"+ph.Key) + " " + ph.Value).Resolve(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 136, Col: 140}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 138, Col: 140}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var24)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -578,7 +578,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var27 string
|
||||
templ_7745c5c3_Var27, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "evidence.phase_"+ph.Key))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 142, Col: 156}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 144, Col: 156}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var27))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -591,7 +591,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var28 string
|
||||
templ_7745c5c3_Var28, templ_7745c5c3_Err = templ.JoinStringErrs(ph.Value)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 143, Col: 20}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 145, Col: 20}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var28))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -609,7 +609,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var29 string
|
||||
templ_7745c5c3_Var29, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "evidence.total"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 147, Col: 59}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 149, Col: 59}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var29))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -622,7 +622,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var30 string
|
||||
templ_7745c5c3_Var30, templ_7745c5c3_Err = templ.JoinStringErrs(v.Total)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 148, Col: 18}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 150, Col: 18}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var30))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -648,7 +648,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var31 string
|
||||
templ_7745c5c3_Var31, templ_7745c5c3_Err = templ.JoinStringErrs(strconv.Itoa(i + 1))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 158, Col: 71}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 160, Col: 71}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var31))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -661,7 +661,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var32 string
|
||||
templ_7745c5c3_Var32, templ_7745c5c3_Err = templ.JoinStringErrs(st.Method)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 159, Col: 50}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 161, Col: 50}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var32))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -674,7 +674,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var33 string
|
||||
templ_7745c5c3_Var33, templ_7745c5c3_Err = templ.JoinStringErrs(st.URL)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 160, Col: 72}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 162, Col: 72}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var33))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -692,7 +692,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var34 string
|
||||
templ_7745c5c3_Var34, templ_7745c5c3_Err = templ.JoinStringErrs(st.Status)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 162, Col: 51}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 164, Col: 51}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var34))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -705,7 +705,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var35 string
|
||||
templ_7745c5c3_Var35, templ_7745c5c3_Err = templ.JoinStringErrs(st.Proto)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 162, Col: 89}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 164, Col: 89}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var35))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -723,7 +723,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var36 string
|
||||
templ_7745c5c3_Var36, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "evidence.no_response"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 164, Col: 87}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 166, Col: 87}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var36))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -741,7 +741,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var37 string
|
||||
templ_7745c5c3_Var37, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "evidence.headers"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 168, Col: 91}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 170, Col: 91}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var37))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -754,7 +754,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var38 string
|
||||
templ_7745c5c3_Var38, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "evidence.request"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 171, Col: 78}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 173, Col: 78}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var38))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -775,7 +775,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var39 string
|
||||
templ_7745c5c3_Var39, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "evidence.response"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 175, Col: 79}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 177, Col: 79}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var39))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -814,7 +814,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var40 string
|
||||
templ_7745c5c3_Var40, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "evidence.cert_subject"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 188, Col: 66}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 190, Col: 66}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var40))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -827,7 +827,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var41 string
|
||||
templ_7745c5c3_Var41, templ_7745c5c3_Err = templ.JoinStringErrs(v.TLS.Subject)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 189, Col: 60}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 191, Col: 60}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var41))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -840,7 +840,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var42 string
|
||||
templ_7745c5c3_Var42, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "evidence.cert_names"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 190, Col: 64}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 192, Col: 64}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var42))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -853,7 +853,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var43 string
|
||||
templ_7745c5c3_Var43, templ_7745c5c3_Err = templ.JoinStringErrs(v.TLS.Names)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 191, Col: 58}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 193, Col: 58}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var43))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -866,7 +866,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var44 string
|
||||
templ_7745c5c3_Var44, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "evidence.cert_issuer"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 192, Col: 65}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 194, Col: 65}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var44))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -879,7 +879,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var45 string
|
||||
templ_7745c5c3_Var45, templ_7745c5c3_Err = templ.JoinStringErrs(v.TLS.Issuer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 193, Col: 59}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 195, Col: 59}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var45))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -892,7 +892,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var46 string
|
||||
templ_7745c5c3_Var46, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "evidence.cert_valid"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 194, Col: 64}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 196, Col: 64}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var46))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -905,7 +905,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var47 string
|
||||
templ_7745c5c3_Var47, templ_7745c5c3_Err = templ.JoinStringErrs(v.TLS.NotBefore)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 196, Col: 23}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 198, Col: 23}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var47))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -918,7 +918,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var48 string
|
||||
templ_7745c5c3_Var48, templ_7745c5c3_Err = templ.JoinStringErrs(v.TLS.NotAfter)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 196, Col: 46}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 198, Col: 46}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var48))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -972,7 +972,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var51 string
|
||||
templ_7745c5c3_Var51, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "evidence.cert_expired"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 199, Col: 46}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 201, Col: 46}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var51))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -982,7 +982,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var52 string
|
||||
templ_7745c5c3_Var52, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "evidence.cert_days_left", "Count", v.TLS.DaysLeft))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 201, Col: 73}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 203, Col: 73}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var52))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -996,7 +996,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var53 string
|
||||
templ_7745c5c3_Var53, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "evidence.tls_version"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 205, Col: 65}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 207, Col: 65}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var53))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1009,7 +1009,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var54 string
|
||||
templ_7745c5c3_Var54, templ_7745c5c3_Err = templ.JoinStringErrs(v.TLS.Version)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 206, Col: 50}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 208, Col: 50}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var54))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1022,7 +1022,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var55 string
|
||||
templ_7745c5c3_Var55, templ_7745c5c3_Err = templ.JoinStringErrs(v.TLS.Cipher)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 206, Col: 70}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 208, Col: 70}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var55))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1049,7 +1049,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var56 string
|
||||
templ_7745c5c3_Var56, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "evidence.body_binary"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 213, Col: 71}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 215, Col: 71}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var56))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1067,7 +1067,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var57 string
|
||||
templ_7745c5c3_Var57, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "evidence.body_empty"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 215, Col: 70}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 217, Col: 70}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var57))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1085,7 +1085,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var58 string
|
||||
templ_7745c5c3_Var58, templ_7745c5c3_Err = templ.JoinStringErrs(v.ContentType)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 218, Col: 20}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 220, Col: 20}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var58))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1099,7 +1099,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var59 string
|
||||
templ_7745c5c3_Var59, templ_7745c5c3_Err = templ.JoinStringErrs(" · " + i18n.T(ctx, "evidence.body_truncated"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 220, Col: 55}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 222, Col: 55}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var59))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1113,7 +1113,7 @@ func EvidencePage(p Page, me Me, v EvidenceView) templ.Component {
|
||||
var templ_7745c5c3_Var60 string
|
||||
templ_7745c5c3_Var60, templ_7745c5c3_Err = templ.JoinStringErrs(v.Body)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 223, Col: 146}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/evidence.templ`, Line: 225, Col: 146}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var60))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
|
||||
@@ -50,7 +50,7 @@ templ LegalPage(p Page, me *Me, html string) {
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<main class="mx-auto max-w-5xl px-6 py-10">
|
||||
<main class="mx-auto max-w-5xl px-4 sm:px-6 py-10">
|
||||
@legalBody(html)
|
||||
</main>
|
||||
}
|
||||
|
||||
@@ -267,7 +267,7 @@ func LegalPage(p Page, me *Me, html string) templ.Component {
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "</div></div></header><main class=\"mx-auto max-w-5xl px-6 py-10\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "</div></div></header><main class=\"mx-auto max-w-5xl px-4 sm:px-6 py-10\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
||||
+105
-62
@@ -1,8 +1,8 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"context"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -28,6 +28,9 @@ type MonitorRow struct {
|
||||
Latency string
|
||||
Uptime string
|
||||
Bars []Bar
|
||||
// Unchecked is set when no region has reported recently: nobody is
|
||||
// checking the monitor.
|
||||
Unchecked bool
|
||||
}
|
||||
|
||||
// GroupNode is a monitor group with its monitors and subgroups.
|
||||
@@ -57,13 +60,22 @@ type DashboardView struct {
|
||||
Search string
|
||||
Results []MonitorRow
|
||||
// Focus, if set, names the one group Root holds, paged by Pager.
|
||||
Focus string
|
||||
Pager Pager
|
||||
Focus string
|
||||
Pager Pager
|
||||
Empty bool
|
||||
CanWrite bool
|
||||
Counts map[Status]int
|
||||
Range string
|
||||
Ranges []RangeOption
|
||||
// Unchecked counts the monitors no region has reported for recently.
|
||||
Unchecked int
|
||||
// DeadRegions are regions of the monitors without a live checker.
|
||||
DeadRegions []DeadRegion
|
||||
}
|
||||
|
||||
// DeadRegion is a region without a live checker since Since.
|
||||
type DeadRegion struct {
|
||||
Name, Since string
|
||||
}
|
||||
|
||||
// RangeOption is an entry of the range switcher. Disabled ranges are not
|
||||
@@ -93,7 +105,7 @@ type RegionHistory struct {
|
||||
}
|
||||
|
||||
templ rangeSwitch(opts []RangeOption) {
|
||||
<nav class="flex border border-rule font-mono text-xs" aria-label={ i18n.T(ctx, "monitors.range") }>
|
||||
<nav class="flex min-w-0 max-w-full overflow-x-auto border border-rule font-mono text-xs" aria-label={ i18n.T(ctx, "monitors.range") }>
|
||||
for _, o := range opts {
|
||||
if o.Active {
|
||||
<span class="bg-ink px-2 py-1 text-paper" aria-current="true">{ o.Key }</span>
|
||||
@@ -130,7 +142,7 @@ templ bars(bs []Bar, height int) {
|
||||
>
|
||||
for i, b := range bs {
|
||||
<rect
|
||||
x={ strconv.Itoa(i*4) }
|
||||
x={ strconv.Itoa(i * 4) }
|
||||
y="0"
|
||||
width="3"
|
||||
height={ strconv.Itoa(height) }
|
||||
@@ -147,11 +159,11 @@ templ bars(bs []Bar, height int) {
|
||||
|
||||
templ Dashboard(p Page, me Me, v DashboardView) {
|
||||
@consoleShell(p, me) {
|
||||
<div class="mb-6 flex items-baseline justify-between gap-4">
|
||||
<div class="mb-6 flex flex-wrap items-center justify-between gap-x-4 gap-y-3">
|
||||
<h1 class="text-lg font-semibold">{ i18n.T(ctx, "console.monitors.title") }</h1>
|
||||
<div class="flex items-center gap-5 font-mono text-xs text-muted">
|
||||
<div class="flex flex-wrap items-center gap-x-5 gap-y-3 font-mono text-xs text-muted">
|
||||
@rangeSwitch(v.Ranges)
|
||||
for _, s := range []Status{StatusUp, StatusDegraded, StatusDown, StatusMaintenance, StatusPaused} {
|
||||
for _, s := range []Status{StatusUp, StatusDegraded, StatusDown, StatusUnknown, StatusMaintenance, StatusPaused} {
|
||||
if v.Counts[s] > 0 {
|
||||
<span class="flex items-center gap-1.5">
|
||||
@statusDot(s)
|
||||
@@ -160,10 +172,20 @@ templ Dashboard(p Page, me Me, v DashboardView) {
|
||||
}
|
||||
}
|
||||
if v.CanWrite {
|
||||
<a href="/monitors/new" class="bg-ink px-3 py-1.5 font-sans text-sm text-paper hover:opacity-90">{ i18n.T(ctx, "monitors.new") }</a>
|
||||
<a href="/monitors/new" class="whitespace-nowrap bg-ink px-3 py-1.5 font-sans text-sm text-paper hover:opacity-90">{ i18n.T(ctx, "monitors.new") }</a>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
if v.Unchecked > 0 || len(v.DeadRegions) > 0 {
|
||||
<div class="mb-6 border-l-2 border-unknown pl-3 text-sm" role="status">
|
||||
for _, r := range v.DeadRegions {
|
||||
<p>{ i18n.T(ctx, "monitors.dead_region", "Region", r.Name, "Since", r.Since) }</p>
|
||||
}
|
||||
if v.Unchecked > 0 {
|
||||
<p>{ i18n.T(ctx, "monitors.unchecked_banner", "Count", v.Unchecked) }</p>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
if !v.Empty {
|
||||
<form method="get" action="/" class="mb-4 flex max-w-md gap-2">
|
||||
if v.Range != "" {
|
||||
@@ -180,7 +202,7 @@ templ Dashboard(p Page, me Me, v DashboardView) {
|
||||
<button type="submit" class="border border-ink px-3 py-1.5 text-sm hover:bg-ink hover:text-paper">{ i18n.T(ctx, "moderation.search_button") }</button>
|
||||
</form>
|
||||
}
|
||||
switch {
|
||||
switch {
|
||||
case v.Empty:
|
||||
<p class="border-y border-rule py-10 text-center text-sm text-muted">{ i18n.T(ctx, "console.monitors.empty") }</p>
|
||||
case v.Search != "":
|
||||
@@ -229,8 +251,12 @@ templ monitorList(ms []MonitorRow) {
|
||||
</span>
|
||||
</span>
|
||||
<span class="col-span-2 md:col-span-1">@bars(m.Bars, 18)</span>
|
||||
<span class="hidden text-right font-mono text-xs text-muted md:block">{ m.Latency }</span>
|
||||
<span class="row-start-1 text-right font-mono text-sm md:row-auto">{ m.Uptime }</span>
|
||||
if m.Unchecked {
|
||||
<span class="hidden text-right font-mono text-xs text-unknown md:block">{ i18n.T(ctx, "monitors.unchecked") }</span>
|
||||
} else {
|
||||
<span class="hidden text-right font-mono text-xs text-muted md:block">{ m.Latency }</span>
|
||||
}
|
||||
<span class="col-start-2 row-start-1 text-right font-mono text-sm md:col-auto md:row-auto">{ m.Uptime }</span>
|
||||
</a>
|
||||
</li>
|
||||
}
|
||||
@@ -312,7 +338,7 @@ type MonitorDetailView struct {
|
||||
MoreIncidents bool
|
||||
// MoreResults is set when the monitor has more results than shown.
|
||||
MoreResults bool
|
||||
CanWrite bool
|
||||
CanWrite bool
|
||||
// Maintenance lists current and upcoming maintenance.
|
||||
Maintenance []MaintenanceItem
|
||||
// PingURL is set for heartbeat monitors the viewer may change.
|
||||
@@ -333,12 +359,12 @@ templ MonitorDetail(p Page, me Me, v MonitorDetailView) {
|
||||
@consoleShell(p, me) {
|
||||
<p class="mb-4 text-sm"><a href="/" class="text-muted hover:text-ink">← { i18n.T(ctx, "console.monitors.title") }</a></p>
|
||||
<div class="mb-8 flex flex-wrap items-start justify-between gap-4">
|
||||
<div>
|
||||
<div class="min-w-0">
|
||||
<h1 class="flex items-center gap-2.5 text-lg font-semibold">
|
||||
@statusDot(v.Row.Status)
|
||||
<span>{ v.Row.Name }</span>
|
||||
<span class="break-words">{ v.Row.Name }</span>
|
||||
</h1>
|
||||
<p class="mt-1 font-mono text-xs text-muted">
|
||||
<p class="mt-1 font-mono text-xs break-all text-muted">
|
||||
{ i18n.T(ctx, "monitors.type_"+v.Row.Type) }
|
||||
if v.Row.Target != "" {
|
||||
{ " · " + v.Row.Target }
|
||||
@@ -350,8 +376,11 @@ templ MonitorDetail(p Page, me Me, v MonitorDetailView) {
|
||||
<a href={ templ.SafeURL("/monitors/" + v.Row.ID + "/edit") } class="border border-ink px-3 py-1.5 text-sm hover:bg-ink hover:text-paper">{ i18n.T(ctx, "sso.action.edit") }</a>
|
||||
}
|
||||
</div>
|
||||
if v.Row.Unchecked {
|
||||
<p class="mb-8 border-l-2 border-unknown pl-3 text-sm" role="status">{ i18n.T(ctx, "monitors.unchecked_banner", "Count", 1) }</p>
|
||||
}
|
||||
<section class="mb-10">
|
||||
<div class="mb-3 flex items-center justify-between gap-4">
|
||||
<div class="mb-3 flex flex-wrap items-center justify-between gap-x-4 gap-y-2">
|
||||
<h2 class="text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "monitors.history", "Range", v.Range) }</h2>
|
||||
@rangeSwitch(v.Ranges)
|
||||
</div>
|
||||
@@ -449,33 +478,35 @@ templ MonitorDetail(p Page, me Me, v MonitorDetailView) {
|
||||
}
|
||||
|
||||
templ resultTable(rows []ResultRow) {
|
||||
<table class="w-full text-left text-sm">
|
||||
<tbody class="divide-y divide-rule border-y border-rule">
|
||||
for _, r := range rows {
|
||||
<tr>
|
||||
<td class="py-1.5 pr-4 font-mono text-xs whitespace-nowrap text-muted">{ r.Time }</td>
|
||||
<td class="py-1.5 pr-4">{ r.Region }</td>
|
||||
<td class="py-1.5 pr-4 font-mono text-xs">
|
||||
@checkerCell(r.Checker)
|
||||
</td>
|
||||
<td class="py-1.5 pr-4">
|
||||
if r.OK {
|
||||
<span class="text-up">●</span>
|
||||
} else {
|
||||
<span class="text-down">●</span>
|
||||
}
|
||||
</td>
|
||||
<td class="py-1.5 pr-4 font-mono text-xs">{ r.Latency }</td>
|
||||
<td class="py-1.5 font-mono text-xs text-muted">
|
||||
{ r.Detail }
|
||||
if r.EvidenceURL != "" {
|
||||
<a href={ templ.SafeURL(r.EvidenceURL) } class="ml-2 underline underline-offset-2 hover:text-ink">{ i18n.T(ctx, "evidence.show") }</a>
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full min-w-[40rem] text-left text-sm">
|
||||
<tbody class="divide-y divide-rule border-y border-rule">
|
||||
for _, r := range rows {
|
||||
<tr>
|
||||
<td class="py-1.5 pr-4 font-mono text-xs whitespace-nowrap text-muted">{ r.Time }</td>
|
||||
<td class="py-1.5 pr-4">{ r.Region }</td>
|
||||
<td class="py-1.5 pr-4 font-mono text-xs">
|
||||
@checkerCell(r.Checker)
|
||||
</td>
|
||||
<td class="py-1.5 pr-4">
|
||||
if r.OK {
|
||||
<span class="text-up">●</span>
|
||||
} else {
|
||||
<span class="text-down">●</span>
|
||||
}
|
||||
</td>
|
||||
<td class="py-1.5 pr-4 font-mono text-xs">{ r.Latency }</td>
|
||||
<td class="py-1.5 font-mono text-xs text-muted">
|
||||
{ r.Detail }
|
||||
if r.EvidenceURL != "" {
|
||||
<a href={ templ.SafeURL(r.EvidenceURL) } class="ml-2 underline underline-offset-2 hover:text-ink">{ i18n.T(ctx, "evidence.show") }</a>
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
|
||||
// ResultsView is a page of a monitor's check results.
|
||||
@@ -527,7 +558,7 @@ templ incidentList(rows []IncidentRow, showMonitor bool, custom []CustomIncident
|
||||
// quickStatus sets an incident's status right in the list, with an
|
||||
// optional message.
|
||||
templ quickStatus(r IncidentRow, custom []CustomIncidentStatus) {
|
||||
<details class="group w-full sm:w-auto">
|
||||
<details class="group w-full sm:w-auto sm:open:w-full">
|
||||
<summary class="cursor-pointer list-none border border-ink px-2 py-0.5 text-xs hover:bg-ink hover:text-paper">{ i18n.T(ctx, "incident.set_status") }</summary>
|
||||
<form data-api={ "/org/incidents/" + r.ID + "/updates" } data-next="/incidents" class="mt-3 grid gap-2 border border-rule p-3 sm:w-80">
|
||||
@formError()
|
||||
@@ -577,6 +608,13 @@ templ IncidentsPage(p Page, me Me, v IncidentsView) {
|
||||
}
|
||||
}
|
||||
|
||||
// TypeOption is a check type offered in the monitor form. OwnOnly types
|
||||
// run on the organization's own checkers only.
|
||||
type TypeOption struct {
|
||||
Type string
|
||||
OwnOnly bool
|
||||
}
|
||||
|
||||
// RegionOption is a selectable region in the monitor form.
|
||||
type RegionOption struct {
|
||||
ID string
|
||||
@@ -600,9 +638,9 @@ type MonitorForm struct {
|
||||
GroupID string
|
||||
Groups []GroupOption
|
||||
// TopLevel is set when the monitor may live outside any group.
|
||||
TopLevel bool
|
||||
Regions []RegionOption
|
||||
MinInterval int
|
||||
TopLevel bool
|
||||
Regions []RegionOption
|
||||
MinInterval int
|
||||
// Type-specific settings.
|
||||
Method string
|
||||
ExpectStatus string
|
||||
@@ -617,12 +655,12 @@ type MonitorForm struct {
|
||||
TLSServerName string
|
||||
GraceSeconds int
|
||||
// Headers are "Name: value" lines, shared by HTTP and JSON checks.
|
||||
Headers string
|
||||
JSONMethod string
|
||||
JSONBody string
|
||||
JSONExpect string
|
||||
JSONVerify bool
|
||||
Assertions []AssertionRow
|
||||
Headers string
|
||||
JSONMethod string
|
||||
JSONBody string
|
||||
JSONExpect string
|
||||
JSONVerify bool
|
||||
Assertions []AssertionRow
|
||||
PromQuery string
|
||||
PromOp string
|
||||
PromThreshold string
|
||||
@@ -637,7 +675,7 @@ type MonitorForm struct {
|
||||
Game GameForm
|
||||
DockerHost string
|
||||
// Types are the check types to offer.
|
||||
Types []string
|
||||
Types []TypeOption
|
||||
}
|
||||
|
||||
// BrokerForm holds the settings of message broker checks.
|
||||
@@ -650,11 +688,11 @@ type BrokerForm struct {
|
||||
// Secrets are never filled in; the *Set fields tell the form one is
|
||||
// stored.
|
||||
type ProtocolForm struct {
|
||||
Service, TLS string
|
||||
ImplicitTLS bool
|
||||
User, NASIdentifier string
|
||||
SecretSet, PasswordSet, CommunitySet bool
|
||||
Version, OID, Condition, Value string
|
||||
Service, TLS string
|
||||
ImplicitTLS bool
|
||||
User, NASIdentifier string
|
||||
SecretSet, PasswordSet, CommunitySet bool
|
||||
Version, OID, Condition, Value string
|
||||
}
|
||||
|
||||
// GameForm holds the settings of game server checks.
|
||||
@@ -763,7 +801,12 @@ templ MonitorEditor(p Page, me Me, f MonitorForm) {
|
||||
<span class="mb-1 block text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "monitors.type") }</span>
|
||||
<select name="type" data-type-select class="w-full border border-rule bg-transparent px-2 py-1.5 text-sm">
|
||||
for _, t := range f.Types {
|
||||
<option value={ t } selected?={ t == f.Type }>{ i18n.T(ctx, "monitors.type_"+t) }</option>
|
||||
<option value={ t.Type } selected?={ t.Type == f.Type }>
|
||||
{ i18n.T(ctx, "monitors.type_"+t.Type) }
|
||||
if t.OwnOnly {
|
||||
({ i18n.T(ctx, "monitors.type_own_only") })
|
||||
}
|
||||
</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
@@ -1175,7 +1218,7 @@ templ providerField(f ProviderField) {
|
||||
<span class="normal-case tracking-normal">{ " · " + i18n.T(ctx, "channels.optional") }</span>
|
||||
}
|
||||
</span>
|
||||
switch {
|
||||
switch {
|
||||
case f.Kind == "select":
|
||||
<select name={ "settings." + f.Name } class="w-full border border-rule bg-transparent px-2 py-1.5 font-mono text-sm">
|
||||
for _, o := range f.Options {
|
||||
|
||||
+2639
-2494
File diff suppressed because it is too large.
Load diff
+117
-113
@@ -85,80 +85,82 @@ templ roleSelect(roles []Role, name string) {
|
||||
templ MembersPage(p Page, me Me, v MembersView) {
|
||||
@consoleShell(p, me) {
|
||||
@settingsHeading("members.title", "members.intro")
|
||||
<table class="mb-12 w-full text-left text-sm">
|
||||
<thead class="border-b border-rule text-xs uppercase tracking-wider text-muted">
|
||||
<tr>
|
||||
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "auth.field.email") }</th>
|
||||
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "members.roles") }</th>
|
||||
<th class="py-2"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-rule">
|
||||
for _, m := range v.Members {
|
||||
<tr class="align-top">
|
||||
<td class="py-2.5 pr-4">
|
||||
{ m.Email }
|
||||
if m.DisplayName != "" {
|
||||
<span class="block text-xs text-muted">{ m.DisplayName }</span>
|
||||
}
|
||||
</td>
|
||||
<td class="py-2.5 pr-4">
|
||||
if m.IsOwner {
|
||||
<span class="font-medium">{ i18n.T(ctx, "members.owner") }</span>
|
||||
}
|
||||
<ul class="flex flex-wrap gap-1.5">
|
||||
for _, a := range m.Assignments {
|
||||
<li class="inline-flex items-center gap-1.5 border border-rule px-1.5 py-0.5 text-xs">
|
||||
{ a.RoleName }
|
||||
if a.Scope != "" {
|
||||
<span class="text-muted">· { a.Scope }</span>
|
||||
}
|
||||
if v.CanManage {
|
||||
<div class="overflow-x-auto">
|
||||
<table class="mb-12 w-full text-left text-sm">
|
||||
<thead class="border-b border-rule text-xs uppercase tracking-wider text-muted">
|
||||
<tr>
|
||||
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "auth.field.email") }</th>
|
||||
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "members.roles") }</th>
|
||||
<th class="py-2"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-rule">
|
||||
for _, m := range v.Members {
|
||||
<tr class="align-top">
|
||||
<td class="py-2.5 pr-4">
|
||||
{ m.Email }
|
||||
if m.DisplayName != "" {
|
||||
<span class="block text-xs text-muted">{ m.DisplayName }</span>
|
||||
}
|
||||
</td>
|
||||
<td class="py-2.5 pr-4">
|
||||
if m.IsOwner {
|
||||
<span class="font-medium">{ i18n.T(ctx, "members.owner") }</span>
|
||||
}
|
||||
<ul class="flex flex-wrap gap-1.5">
|
||||
for _, a := range m.Assignments {
|
||||
<li class="inline-flex items-center gap-1.5 border border-rule px-1.5 py-0.5 text-xs">
|
||||
{ a.RoleName }
|
||||
if a.Scope != "" {
|
||||
<span class="text-muted">· { a.Scope }</span>
|
||||
}
|
||||
if v.CanManage {
|
||||
<button
|
||||
type="button"
|
||||
data-delete={ "/org/assignments/" + a.ID }
|
||||
class="text-muted hover:text-down"
|
||||
aria-label={ i18n.T(ctx, "members.unassign") }
|
||||
>×</button>
|
||||
}
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
</td>
|
||||
<td class="py-2.5 text-right">
|
||||
@ownerAction(v, m)
|
||||
if v.CanManage && !m.IsOwner {
|
||||
<details class="inline-block text-left">
|
||||
<summary class="cursor-pointer text-muted hover:text-ink">{ i18n.T(ctx, "sso.action.edit") }</summary>
|
||||
<div class="mt-3 w-64">
|
||||
<form data-api={ "/org/members/" + m.UserID + "/roles" } data-next="/settings/members">
|
||||
@formError()
|
||||
@roleSelect(v.Roles, "role_id")
|
||||
<label class="mt-3 block">
|
||||
<span class="mb-1 block text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "members.scope") }</span>
|
||||
<select name="scope" data-scope class="w-full border border-rule bg-transparent px-2 py-1.5 text-sm">
|
||||
<option value="">{ i18n.T(ctx, "members.scope_org") }</option>
|
||||
for _, sc := range v.Scopes {
|
||||
<option value={ sc.Value }>{ sc.Label }</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
@submit(i18n.T(ctx, "members.assign"))
|
||||
</form>
|
||||
<button
|
||||
type="button"
|
||||
data-delete={ "/org/assignments/" + a.ID }
|
||||
class="text-muted hover:text-down"
|
||||
aria-label={ i18n.T(ctx, "members.unassign") }
|
||||
>×</button>
|
||||
}
|
||||
</li>
|
||||
data-delete={ "/org/members/" + m.UserID }
|
||||
data-confirm={ i18n.T(ctx, "members.remove_confirm") }
|
||||
class="mt-4 text-sm text-down hover:underline"
|
||||
>{ i18n.T(ctx, "members.remove") }</button>
|
||||
</div>
|
||||
</details>
|
||||
}
|
||||
</ul>
|
||||
</td>
|
||||
<td class="py-2.5 text-right">
|
||||
@ownerAction(v, m)
|
||||
if v.CanManage && !m.IsOwner {
|
||||
<details class="inline-block text-left">
|
||||
<summary class="cursor-pointer text-muted hover:text-ink">{ i18n.T(ctx, "sso.action.edit") }</summary>
|
||||
<div class="mt-3 w-64">
|
||||
<form data-api={ "/org/members/" + m.UserID + "/roles" } data-next="/settings/members">
|
||||
@formError()
|
||||
@roleSelect(v.Roles, "role_id")
|
||||
<label class="mt-3 block">
|
||||
<span class="mb-1 block text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "members.scope") }</span>
|
||||
<select name="scope" data-scope class="w-full border border-rule bg-transparent px-2 py-1.5 text-sm">
|
||||
<option value="">{ i18n.T(ctx, "members.scope_org") }</option>
|
||||
for _, sc := range v.Scopes {
|
||||
<option value={ sc.Value }>{ sc.Label }</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
@submit(i18n.T(ctx, "members.assign"))
|
||||
</form>
|
||||
<button
|
||||
type="button"
|
||||
data-delete={ "/org/members/" + m.UserID }
|
||||
data-confirm={ i18n.T(ctx, "members.remove_confirm") }
|
||||
class="mt-4 text-sm text-down hover:underline"
|
||||
>{ i18n.T(ctx, "members.remove") }</button>
|
||||
</div>
|
||||
</details>
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@pager(v.Pager, "previous", "next")
|
||||
if v.CanManage {
|
||||
<div class="grid gap-12 md:grid-cols-2">
|
||||
@@ -313,49 +315,51 @@ templ TokensPage(p Page, me Me, v TokensView) {
|
||||
<p class="-mt-4 mb-8 text-sm">{ i18n.T(ctx, "tokens.policy", "Count", v.MaxDays) }</p>
|
||||
}
|
||||
if len(v.Tokens) > 0 {
|
||||
<table class="mb-12 w-full text-left text-sm">
|
||||
<thead class="border-b border-rule text-xs uppercase tracking-wider text-muted">
|
||||
<tr>
|
||||
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "sso.field.name") }</th>
|
||||
if v.ShowOwner {
|
||||
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "tokens.owner") }</th>
|
||||
}
|
||||
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "tokens.permissions") }</th>
|
||||
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "tokens.created") }</th>
|
||||
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "tokens.expires") }</th>
|
||||
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "tokens.last_used") }</th>
|
||||
<th class="py-2"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-rule">
|
||||
for _, t := range v.Tokens {
|
||||
<tr class="align-top">
|
||||
<td class="py-2.5 pr-4">{ t.Name } <span class="block font-mono text-xs text-muted">{ t.Prefix }…</span></td>
|
||||
<div class="overflow-x-auto">
|
||||
<table class="mb-12 w-full text-left text-sm">
|
||||
<thead class="border-b border-rule text-xs uppercase tracking-wider text-muted">
|
||||
<tr>
|
||||
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "sso.field.name") }</th>
|
||||
if v.ShowOwner {
|
||||
<td class="py-2.5 pr-4">{ t.UserEmail }</td>
|
||||
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "tokens.owner") }</th>
|
||||
}
|
||||
<td class="py-2.5 pr-4">
|
||||
<ul class="flex max-w-xs flex-wrap gap-1 text-xs">
|
||||
for _, perm := range t.Permissions {
|
||||
<li class="border border-rule px-1 py-px">{ i18n.T(ctx, "perm."+perm) }</li>
|
||||
}
|
||||
</ul>
|
||||
</td>
|
||||
<td class="py-2.5 pr-4 whitespace-nowrap font-mono text-xs">{ t.CreatedAt }</td>
|
||||
<td class="py-2.5 pr-4 whitespace-nowrap font-mono text-xs">{ t.ExpiresAt }</td>
|
||||
<td class="py-2.5 pr-4 whitespace-nowrap font-mono text-xs">{ t.LastUsedAt }</td>
|
||||
<td class="py-2.5 text-right">
|
||||
<button
|
||||
type="button"
|
||||
data-delete={ "/org/tokens/" + t.ID }
|
||||
data-confirm={ i18n.T(ctx, "tokens.revoke_confirm") }
|
||||
class="text-muted hover:text-down"
|
||||
>{ i18n.T(ctx, "members.revoke") }</button>
|
||||
</td>
|
||||
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "tokens.permissions") }</th>
|
||||
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "tokens.created") }</th>
|
||||
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "tokens.expires") }</th>
|
||||
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "tokens.last_used") }</th>
|
||||
<th class="py-2"></th>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-rule">
|
||||
for _, t := range v.Tokens {
|
||||
<tr class="align-top">
|
||||
<td class="py-2.5 pr-4">{ t.Name } <span class="block font-mono text-xs text-muted">{ t.Prefix }…</span></td>
|
||||
if v.ShowOwner {
|
||||
<td class="py-2.5 pr-4">{ t.UserEmail }</td>
|
||||
}
|
||||
<td class="py-2.5 pr-4">
|
||||
<ul class="flex max-w-xs flex-wrap gap-1 text-xs">
|
||||
for _, perm := range t.Permissions {
|
||||
<li class="border border-rule px-1 py-px">{ i18n.T(ctx, "perm."+perm) }</li>
|
||||
}
|
||||
</ul>
|
||||
</td>
|
||||
<td class="py-2.5 pr-4 whitespace-nowrap font-mono text-xs">{ t.CreatedAt }</td>
|
||||
<td class="py-2.5 pr-4 whitespace-nowrap font-mono text-xs">{ t.ExpiresAt }</td>
|
||||
<td class="py-2.5 pr-4 whitespace-nowrap font-mono text-xs">{ t.LastUsedAt }</td>
|
||||
<td class="py-2.5 text-right">
|
||||
<button
|
||||
type="button"
|
||||
data-delete={ "/org/tokens/" + t.ID }
|
||||
data-confirm={ i18n.T(ctx, "tokens.revoke_confirm") }
|
||||
class="text-muted hover:text-down"
|
||||
>{ i18n.T(ctx, "members.revoke") }</button>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
<section class="max-w-xl">
|
||||
@sectionHeading("tokens.create")
|
||||
@@ -454,7 +458,7 @@ templ InvitationPage(p Page, v Invitation) {
|
||||
} else {
|
||||
<p class="mb-6 text-sm">{ i18n.T(ctx, "invite.summary", "Org", v.OrgName, "Role", v.RoleName) }</p>
|
||||
<p class="mb-6 font-mono text-sm">{ v.Email }</p>
|
||||
switch {
|
||||
switch {
|
||||
case v.SignedInAs == v.Email:
|
||||
<form data-api={ "/invitations/" + v.Token + "/accept" } data-next="/">
|
||||
@formError()
|
||||
@@ -499,7 +503,7 @@ templ tokenUsage() {
|
||||
// own included, as long as another owner remains.
|
||||
templ ownerAction(v MembersView, m Member) {
|
||||
if v.IsOwner {
|
||||
switch {
|
||||
switch {
|
||||
case !m.IsOwner:
|
||||
@ownerForm(m.UserID, true, i18n.T(ctx, "members.make_owner"), i18n.T(ctx, "members.make_owner_confirm", "Email", m.Email))
|
||||
case v.Owners > 1 && m.UserID == v.Self:
|
||||
|
||||
+79
-79
@@ -274,14 +274,14 @@ func MembersPage(p Page, me Me, v MembersView) templ.Component {
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "<table class=\"mb-12 w-full text-left text-sm\"><thead class=\"border-b border-rule text-xs uppercase tracking-wider text-muted\"><tr><th class=\"py-2 pr-4 font-medium\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "<div class=\"overflow-x-auto\"><table class=\"mb-12 w-full text-left text-sm\"><thead class=\"border-b border-rule text-xs uppercase tracking-wider text-muted\"><tr><th class=\"py-2 pr-4 font-medium\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var12 string
|
||||
templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "auth.field.email"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 91, Col: 72}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 92, Col: 73}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -294,7 +294,7 @@ func MembersPage(p Page, me Me, v MembersView) templ.Component {
|
||||
var templ_7745c5c3_Var13 string
|
||||
templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "members.roles"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 92, Col: 69}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 93, Col: 70}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -312,7 +312,7 @@ func MembersPage(p Page, me Me, v MembersView) templ.Component {
|
||||
var templ_7745c5c3_Var14 string
|
||||
templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(m.Email)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 100, Col: 16}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 101, Col: 17}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -330,7 +330,7 @@ func MembersPage(p Page, me Me, v MembersView) templ.Component {
|
||||
var templ_7745c5c3_Var15 string
|
||||
templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(m.DisplayName)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 102, Col: 62}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 103, Col: 63}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -353,7 +353,7 @@ func MembersPage(p Page, me Me, v MembersView) templ.Component {
|
||||
var templ_7745c5c3_Var16 string
|
||||
templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "members.owner"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 107, Col: 64}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 108, Col: 65}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -376,7 +376,7 @@ func MembersPage(p Page, me Me, v MembersView) templ.Component {
|
||||
var templ_7745c5c3_Var17 string
|
||||
templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(a.RoleName)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 112, Col: 22}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 113, Col: 23}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -394,7 +394,7 @@ func MembersPage(p Page, me Me, v MembersView) templ.Component {
|
||||
var templ_7745c5c3_Var18 string
|
||||
templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(a.Scope)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 114, Col: 48}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 115, Col: 49}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -413,7 +413,7 @@ func MembersPage(p Page, me Me, v MembersView) templ.Component {
|
||||
var templ_7745c5c3_Var19 string
|
||||
templ_7745c5c3_Var19, templ_7745c5c3_Err = templruntime.NewAttributeExpression("/org/assignments/" + a.ID).Resolve(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 119, Col: 52}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 120, Col: 53}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var19)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -426,7 +426,7 @@ func MembersPage(p Page, me Me, v MembersView) templ.Component {
|
||||
var templ_7745c5c3_Var20 string
|
||||
templ_7745c5c3_Var20, templ_7745c5c3_Err = templruntime.NewAttributeExpression(i18n.T(ctx, "members.unassign")).Resolve(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 121, Col: 56}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 122, Col: 57}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var20)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -458,7 +458,7 @@ func MembersPage(p Page, me Me, v MembersView) templ.Component {
|
||||
var templ_7745c5c3_Var21 string
|
||||
templ_7745c5c3_Var21, 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/org.templ`, Line: 132, Col: 99}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 133, Col: 100}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -471,7 +471,7 @@ func MembersPage(p Page, me Me, v MembersView) templ.Component {
|
||||
var templ_7745c5c3_Var22 string
|
||||
templ_7745c5c3_Var22, templ_7745c5c3_Err = templruntime.NewAttributeExpression("/org/members/" + m.UserID + "/roles").Resolve(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 134, Col: 64}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 135, Col: 65}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var22)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -496,7 +496,7 @@ func MembersPage(p Page, me Me, v MembersView) templ.Component {
|
||||
var templ_7745c5c3_Var23 string
|
||||
templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "members.scope"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 138, Col: 123}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 139, Col: 124}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -509,7 +509,7 @@ func MembersPage(p Page, me Me, v MembersView) templ.Component {
|
||||
var templ_7745c5c3_Var24 string
|
||||
templ_7745c5c3_Var24, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "members.scope_org"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 140, Col: 64}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 141, Col: 65}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var24))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -527,7 +527,7 @@ func MembersPage(p Page, me Me, v MembersView) templ.Component {
|
||||
var templ_7745c5c3_Var25 string
|
||||
templ_7745c5c3_Var25, templ_7745c5c3_Err = templruntime.NewAttributeExpression(sc.Value).Resolve(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 142, Col: 38}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 143, Col: 39}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var25)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -540,7 +540,7 @@ func MembersPage(p Page, me Me, v MembersView) templ.Component {
|
||||
var templ_7745c5c3_Var26 string
|
||||
templ_7745c5c3_Var26, templ_7745c5c3_Err = templ.JoinStringErrs(sc.Label)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 142, Col: 51}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 143, Col: 52}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var26))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -566,7 +566,7 @@ func MembersPage(p Page, me Me, v MembersView) templ.Component {
|
||||
var templ_7745c5c3_Var27 string
|
||||
templ_7745c5c3_Var27, templ_7745c5c3_Err = templruntime.NewAttributeExpression("/org/members/" + m.UserID).Resolve(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 150, Col: 51}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 151, Col: 52}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var27)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -579,7 +579,7 @@ func MembersPage(p Page, me Me, v MembersView) templ.Component {
|
||||
var templ_7745c5c3_Var28 string
|
||||
templ_7745c5c3_Var28, templ_7745c5c3_Err = templruntime.NewAttributeExpression(i18n.T(ctx, "members.remove_confirm")).Resolve(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 151, Col: 63}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 152, Col: 64}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var28)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -592,7 +592,7 @@ func MembersPage(p Page, me Me, v MembersView) templ.Component {
|
||||
var templ_7745c5c3_Var29 string
|
||||
templ_7745c5c3_Var29, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "members.remove"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 153, Col: 42}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 154, Col: 43}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var29))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -608,7 +608,7 @@ func MembersPage(p Page, me Me, v MembersView) templ.Component {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 48, "</tbody></table>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 48, "</tbody></table></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -644,7 +644,7 @@ func MembersPage(p Page, me Me, v MembersView) templ.Component {
|
||||
var templ_7745c5c3_Var30 string
|
||||
templ_7745c5c3_Var30, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "members.role"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 171, Col: 117}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 173, Col: 117}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var30))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -673,7 +673,7 @@ func MembersPage(p Page, me Me, v MembersView) templ.Component {
|
||||
var templ_7745c5c3_Var31 string
|
||||
templ_7745c5c3_Var31, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "members.invite_link"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 176, Col: 67}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 178, Col: 67}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var31))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -704,7 +704,7 @@ func MembersPage(p Page, me Me, v MembersView) templ.Component {
|
||||
var templ_7745c5c3_Var32 string
|
||||
templ_7745c5c3_Var32, templ_7745c5c3_Err = templ.JoinStringErrs(inv.Email)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 187, Col: 26}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 189, Col: 26}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var32))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -717,7 +717,7 @@ func MembersPage(p Page, me Me, v MembersView) templ.Component {
|
||||
var templ_7745c5c3_Var33 string
|
||||
templ_7745c5c3_Var33, templ_7745c5c3_Err = templ.JoinStringErrs(inv.RoleName)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 187, Col: 71}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 189, Col: 71}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var33))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -730,7 +730,7 @@ func MembersPage(p Page, me Me, v MembersView) templ.Component {
|
||||
var templ_7745c5c3_Var34 string
|
||||
templ_7745c5c3_Var34, templ_7745c5c3_Err = templruntime.NewAttributeExpression("/org/invitations/" + inv.ID).Resolve(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 188, Col: 73}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 190, Col: 73}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var34)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -743,7 +743,7 @@ func MembersPage(p Page, me Me, v MembersView) templ.Component {
|
||||
var templ_7745c5c3_Var35 string
|
||||
templ_7745c5c3_Var35, 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: 188, Col: 142}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 190, Col: 142}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var35))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -848,7 +848,7 @@ func permissionChecks(all, grantable, checked []string) templ.Component {
|
||||
var templ_7745c5c3_Var39 string
|
||||
templ_7745c5c3_Var39, templ_7745c5c3_Err = templruntime.NewAttributeExpression(perm).Resolve(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 215, Col: 17}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 217, Col: 17}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var39)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -877,7 +877,7 @@ func permissionChecks(all, grantable, checked []string) templ.Component {
|
||||
var templ_7745c5c3_Var40 string
|
||||
templ_7745c5c3_Var40, 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: 221, Col: 31}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 223, Col: 31}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var40))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -941,7 +941,7 @@ func RolesPage(p Page, me Me, v RolesView) templ.Component {
|
||||
var templ_7745c5c3_Var43 string
|
||||
templ_7745c5c3_Var43, templ_7745c5c3_Err = templ.JoinStringErrs(r.Name)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 235, Col: 15}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 237, Col: 15}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var43))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -959,7 +959,7 @@ func RolesPage(p Page, me Me, v RolesView) templ.Component {
|
||||
var templ_7745c5c3_Var44 string
|
||||
templ_7745c5c3_Var44, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "roles.built_in"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 237, Col: 77}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 239, Col: 77}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var44))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -982,7 +982,7 @@ func RolesPage(p Page, me Me, v RolesView) templ.Component {
|
||||
var templ_7745c5c3_Var45 string
|
||||
templ_7745c5c3_Var45, templ_7745c5c3_Err = templruntime.NewAttributeExpression("/org/roles/" + r.ID).Resolve(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 243, Col: 42}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 245, Col: 42}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var45)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -995,7 +995,7 @@ func RolesPage(p Page, me Me, v RolesView) templ.Component {
|
||||
var templ_7745c5c3_Var46 string
|
||||
templ_7745c5c3_Var46, templ_7745c5c3_Err = templruntime.NewAttributeExpression(i18n.T(ctx, "roles.delete_confirm")).Resolve(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 244, Col: 58}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 246, Col: 58}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var46)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1008,7 +1008,7 @@ func RolesPage(p Page, me Me, v RolesView) templ.Component {
|
||||
var templ_7745c5c3_Var47 string
|
||||
templ_7745c5c3_Var47, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "roles.delete"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 246, Col: 37}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 248, Col: 37}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var47))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1031,7 +1031,7 @@ func RolesPage(p Page, me Me, v RolesView) templ.Component {
|
||||
var templ_7745c5c3_Var48 string
|
||||
templ_7745c5c3_Var48, templ_7745c5c3_Err = templruntime.NewAttributeExpression("/org/roles/" + r.ID).Resolve(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 250, Col: 43}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 252, Col: 43}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var48)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1074,7 +1074,7 @@ func RolesPage(p Page, me Me, v RolesView) templ.Component {
|
||||
var templ_7745c5c3_Var49 string
|
||||
templ_7745c5c3_Var49, 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: 259, Col: 80}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 261, Col: 80}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var49))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1220,7 +1220,7 @@ func TokensPage(p Page, me Me, v TokensView) templ.Component {
|
||||
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: 313, Col: 83}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 315, Col: 83}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var52))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1236,14 +1236,14 @@ func TokensPage(p Page, me Me, v TokensView) templ.Component {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if len(v.Tokens) > 0 {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 102, "<table class=\"mb-12 w-full text-left text-sm\"><thead class=\"border-b border-rule text-xs uppercase tracking-wider text-muted\"><tr><th class=\"py-2 pr-4 font-medium\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 102, "<div class=\"overflow-x-auto\"><table class=\"mb-12 w-full text-left text-sm\"><thead class=\"border-b border-rule text-xs uppercase tracking-wider text-muted\"><tr><th class=\"py-2 pr-4 font-medium\">")
|
||||
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"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 319, Col: 71}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 322, Col: 72}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var53))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1261,7 +1261,7 @@ func TokensPage(p Page, me Me, v TokensView) templ.Component {
|
||||
var templ_7745c5c3_Var54 string
|
||||
templ_7745c5c3_Var54, 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: 321, Col: 70}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 324, Col: 71}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var54))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1279,7 +1279,7 @@ func TokensPage(p Page, me Me, v TokensView) templ.Component {
|
||||
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: 323, Col: 75}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 326, Col: 76}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var55))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1292,7 +1292,7 @@ func TokensPage(p Page, me Me, v TokensView) templ.Component {
|
||||
var templ_7745c5c3_Var56 string
|
||||
templ_7745c5c3_Var56, 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: 324, Col: 71}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 327, Col: 72}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var56))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1305,7 +1305,7 @@ func TokensPage(p Page, me Me, v TokensView) templ.Component {
|
||||
var templ_7745c5c3_Var57 string
|
||||
templ_7745c5c3_Var57, 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: 325, Col: 71}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 328, Col: 72}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var57))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1318,7 +1318,7 @@ func TokensPage(p Page, me Me, v TokensView) templ.Component {
|
||||
var templ_7745c5c3_Var58 string
|
||||
templ_7745c5c3_Var58, 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: 326, Col: 73}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 329, Col: 74}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var58))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1336,7 +1336,7 @@ func TokensPage(p Page, me Me, v TokensView) templ.Component {
|
||||
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: 333, Col: 39}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 336, Col: 40}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var59))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1349,7 +1349,7 @@ func TokensPage(p Page, me Me, v TokensView) templ.Component {
|
||||
var templ_7745c5c3_Var60 string
|
||||
templ_7745c5c3_Var60, 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: 333, Col: 101}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 336, Col: 102}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var60))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1367,7 +1367,7 @@ func TokensPage(p Page, me Me, v TokensView) templ.Component {
|
||||
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: 335, Col: 45}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 338, Col: 46}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var61))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1390,7 +1390,7 @@ func TokensPage(p Page, me Me, v TokensView) templ.Component {
|
||||
var templ_7745c5c3_Var62 string
|
||||
templ_7745c5c3_Var62, 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: 340, Col: 79}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 343, Col: 80}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var62))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1408,7 +1408,7 @@ func TokensPage(p Page, me Me, v TokensView) templ.Component {
|
||||
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: 344, Col: 80}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 347, Col: 81}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var63))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1421,7 +1421,7 @@ func TokensPage(p Page, me Me, v TokensView) templ.Component {
|
||||
var templ_7745c5c3_Var64 string
|
||||
templ_7745c5c3_Var64, 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: 345, Col: 80}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 348, Col: 81}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var64))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1434,7 +1434,7 @@ func TokensPage(p Page, me Me, v TokensView) templ.Component {
|
||||
var templ_7745c5c3_Var65 string
|
||||
templ_7745c5c3_Var65, 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: 346, Col: 81}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 349, Col: 82}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var65))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1447,7 +1447,7 @@ func TokensPage(p Page, me Me, v TokensView) templ.Component {
|
||||
var templ_7745c5c3_Var66 string
|
||||
templ_7745c5c3_Var66, templ_7745c5c3_Err = templruntime.NewAttributeExpression("/org/tokens/" + t.ID).Resolve(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 350, Col: 44}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 353, Col: 45}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var66)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1460,7 +1460,7 @@ func TokensPage(p Page, me Me, v TokensView) templ.Component {
|
||||
var templ_7745c5c3_Var67 string
|
||||
templ_7745c5c3_Var67, templ_7745c5c3_Err = templruntime.NewAttributeExpression(i18n.T(ctx, "tokens.revoke_confirm")).Resolve(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 351, Col: 60}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 354, Col: 61}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var67)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1473,7 +1473,7 @@ func TokensPage(p Page, me Me, v TokensView) templ.Component {
|
||||
var templ_7745c5c3_Var68 string
|
||||
templ_7745c5c3_Var68, 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: 353, Col: 40}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 356, Col: 41}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var68))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1484,7 +1484,7 @@ func TokensPage(p Page, me Me, v TokensView) templ.Component {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 126, "</tbody></table>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 126, "</tbody></table></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -1524,7 +1524,7 @@ func TokensPage(p Page, me Me, v TokensView) templ.Component {
|
||||
var templ_7745c5c3_Var69 string
|
||||
templ_7745c5c3_Var69, 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: 368, Col: 117}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 372, Col: 117}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var69))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1543,7 +1543,7 @@ func TokensPage(p Page, me Me, v TokensView) templ.Component {
|
||||
var templ_7745c5c3_Var70 string
|
||||
templ_7745c5c3_Var70, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "tokens.never"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 372, Col: 55}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 376, Col: 55}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var70))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1561,7 +1561,7 @@ func TokensPage(p Page, me Me, v TokensView) templ.Component {
|
||||
var templ_7745c5c3_Var71 string
|
||||
templ_7745c5c3_Var71, templ_7745c5c3_Err = templruntime.NewAttributeExpression(strconv.Itoa(d)).Resolve(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 374, Col: 39}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 378, Col: 39}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var71)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1584,7 +1584,7 @@ func TokensPage(p Page, me Me, v TokensView) templ.Component {
|
||||
var templ_7745c5c3_Var72 string
|
||||
templ_7745c5c3_Var72, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "tokens.days", "Count", d))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 374, Col: 103}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 378, Col: 103}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var72))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1611,7 +1611,7 @@ func TokensPage(p Page, me Me, v TokensView) templ.Component {
|
||||
var templ_7745c5c3_Var73 string
|
||||
templ_7745c5c3_Var73, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "tokens.copy_now"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 381, Col: 61}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 385, Col: 61}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var73))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1711,7 +1711,7 @@ func OrgSettingsPage(p Page, me Me, v OrgSettings) templ.Component {
|
||||
var templ_7745c5c3_Var76 string
|
||||
templ_7745c5c3_Var76, 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: 412, Col: 82}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 416, Col: 82}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var76))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1732,7 +1732,7 @@ func OrgSettingsPage(p Page, me Me, v OrgSettings) templ.Component {
|
||||
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: 414, Col: 81}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 418, Col: 81}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var77))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1745,7 +1745,7 @@ func OrgSettingsPage(p Page, me Me, v OrgSettings) templ.Component {
|
||||
var templ_7745c5c3_Var78 string
|
||||
templ_7745c5c3_Var78, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "org.token_max_days"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 416, Col: 121}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 420, Col: 121}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var78))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1758,7 +1758,7 @@ func OrgSettingsPage(p Page, me Me, v OrgSettings) templ.Component {
|
||||
var templ_7745c5c3_Var79 string
|
||||
templ_7745c5c3_Var79, templ_7745c5c3_Err = templruntime.NewAttributeExpression(maxDaysValue(v.TokenMaxDays)).Resolve(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 423, Col: 42}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 427, Col: 42}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var79)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1771,7 +1771,7 @@ func OrgSettingsPage(p Page, me Me, v OrgSettings) templ.Component {
|
||||
var templ_7745c5c3_Var80 string
|
||||
templ_7745c5c3_Var80, templ_7745c5c3_Err = templruntime.NewAttributeExpression(i18n.T(ctx, "org.token_max_days_none")).Resolve(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 424, Col: 58}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 428, Col: 58}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var80)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1784,7 +1784,7 @@ func OrgSettingsPage(p Page, me Me, v OrgSettings) templ.Component {
|
||||
var templ_7745c5c3_Var81 string
|
||||
templ_7745c5c3_Var81, 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: 428, Col: 79}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 432, Col: 79}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var81))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1873,7 +1873,7 @@ func InvitationPage(p Page, v Invitation) templ.Component {
|
||||
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: 453, Col: 63}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 457, Col: 63}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var84))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1891,7 +1891,7 @@ func InvitationPage(p Page, v Invitation) templ.Component {
|
||||
var templ_7745c5c3_Var85 string
|
||||
templ_7745c5c3_Var85, 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: 455, Col: 96}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 459, Col: 96}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var85))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1904,7 +1904,7 @@ func InvitationPage(p Page, v Invitation) templ.Component {
|
||||
var templ_7745c5c3_Var86 string
|
||||
templ_7745c5c3_Var86, 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: 456, Col: 46}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 460, Col: 46}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var86))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1923,7 +1923,7 @@ func InvitationPage(p Page, v Invitation) templ.Component {
|
||||
var templ_7745c5c3_Var87 string
|
||||
templ_7745c5c3_Var87, templ_7745c5c3_Err = templruntime.NewAttributeExpression("/invitations/" + v.Token + "/accept").Resolve(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 459, Col: 59}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 463, Col: 59}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var87)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1953,7 +1953,7 @@ func InvitationPage(p Page, v Invitation) templ.Component {
|
||||
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: 464, Col: 82}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 468, Col: 82}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var88))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1966,7 +1966,7 @@ func InvitationPage(p Page, v Invitation) templ.Component {
|
||||
var templ_7745c5c3_Var89 string
|
||||
templ_7745c5c3_Var89, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.nav.logout"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 465, Col: 110}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 469, Col: 110}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var89))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1984,7 +1984,7 @@ func InvitationPage(p Page, v Invitation) templ.Component {
|
||||
var templ_7745c5c3_Var90 string
|
||||
templ_7745c5c3_Var90, templ_7745c5c3_Err = templruntime.NewAttributeExpression(templ.SafeURL("/login?next=/invite/" + v.Token)).ResolveURL(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 467, Col: 62}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 471, Col: 62}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var90)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -1997,7 +1997,7 @@ func InvitationPage(p Page, v Invitation) templ.Component {
|
||||
var templ_7745c5c3_Var91 string
|
||||
templ_7745c5c3_Var91, 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: 467, Col: 153}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 471, Col: 153}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var91))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -2015,7 +2015,7 @@ func InvitationPage(p Page, v Invitation) templ.Component {
|
||||
var templ_7745c5c3_Var92 string
|
||||
templ_7745c5c3_Var92, templ_7745c5c3_Err = templruntime.NewAttributeExpression("/invitations/" + v.Token + "/signup").Resolve(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 469, Col: 59}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 473, Col: 59}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var92)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -2093,7 +2093,7 @@ func tokenUsage() templ.Component {
|
||||
var templ_7745c5c3_Var94 string
|
||||
templ_7745c5c3_Var94, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "tokens.usage"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 491, Col: 31}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 495, Col: 31}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var94))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -2106,7 +2106,7 @@ func tokenUsage() templ.Component {
|
||||
var templ_7745c5c3_Var95 string
|
||||
templ_7745c5c3_Var95, 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: 494, Col: 98}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 498, Col: 98}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var95))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -2186,7 +2186,7 @@ func ownerForm(user string, owner bool, label, confirm string) templ.Component {
|
||||
var templ_7745c5c3_Var98 string
|
||||
templ_7745c5c3_Var98, templ_7745c5c3_Err = templruntime.NewAttributeExpression("/org/members/" + user + "/owner").Resolve(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 514, Col: 51}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 518, Col: 51}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var98)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -2199,7 +2199,7 @@ func ownerForm(user string, owner bool, label, confirm string) templ.Component {
|
||||
var templ_7745c5c3_Var99 string
|
||||
templ_7745c5c3_Var99, templ_7745c5c3_Err = templruntime.NewAttributeExpression(confirm).Resolve(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 514, Col: 124}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 518, Col: 124}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var99)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -2222,7 +2222,7 @@ func ownerForm(user string, owner bool, label, confirm string) templ.Component {
|
||||
var templ_7745c5c3_Var100 string
|
||||
templ_7745c5c3_Var100, templ_7745c5c3_Err = templ.JoinStringErrs(label)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 516, Col: 108}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 520, Col: 108}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var100))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
|
||||
@@ -33,11 +33,11 @@ templ publicShell(s agentapi.PageSnapshot, a PublicAssets, docTitle string) {
|
||||
}
|
||||
</head>
|
||||
<body class="min-h-screen">
|
||||
<main class="mx-auto max-w-3xl px-6 py-14">
|
||||
<main class="mx-auto max-w-3xl px-4 py-8 sm:px-6 sm:py-14">
|
||||
{ children... }
|
||||
<footer class="flex justify-between border-t border-rule pt-4 font-mono text-xs text-muted">
|
||||
<footer class="flex flex-wrap justify-between gap-x-4 gap-y-2 border-t border-rule pt-4 font-mono text-xs text-muted">
|
||||
<span>{ i18n.T(ctx, "page.updated", "Time", s.GeneratedAt.UTC().Format(time.DateTime)+" UTC") }</span>
|
||||
<span class="flex gap-4">
|
||||
<span class="flex flex-wrap justify-end gap-x-4 gap-y-1">
|
||||
for _, l := range PageLegalLinks(s, a.LegalBase) {
|
||||
@legalLink(l)
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ func publicShell(s agentapi.PageSnapshot, a PublicAssets, docTitle string) templ
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "</head><body class=\"min-h-screen\"><main class=\"mx-auto max-w-3xl px-6 py-14\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "</head><body class=\"min-h-screen\"><main class=\"mx-auto max-w-3xl px-4 py-8 sm:px-6 sm:py-14\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -116,7 +116,7 @@ func publicShell(s agentapi.PageSnapshot, a PublicAssets, docTitle string) templ
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "<footer class=\"flex justify-between border-t border-rule pt-4 font-mono text-xs text-muted\"><span>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "<footer class=\"flex flex-wrap justify-between gap-x-4 gap-y-2 border-t border-rule pt-4 font-mono text-xs text-muted\"><span>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -129,7 +129,7 @@ func publicShell(s agentapi.PageSnapshot, a PublicAssets, docTitle string) templ
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "</span> <span class=\"flex gap-4\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "</span> <span class=\"flex flex-wrap justify-end gap-x-4 gap-y-1\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
||||
+43
-35
@@ -4,9 +4,9 @@ import "git.zb-server.de/ZB-Server/uptimesebi/internal/i18n"
|
||||
|
||||
// Region is a row in a region list.
|
||||
type Region struct {
|
||||
ID string
|
||||
Key string
|
||||
Name string
|
||||
ID string
|
||||
Key string
|
||||
Name string
|
||||
// Platform regions are shared by all organizations.
|
||||
Platform bool
|
||||
// Manageable regions can be deleted on the current page.
|
||||
@@ -65,40 +65,42 @@ type RegionsView struct {
|
||||
templ regionsBody(v RegionsView) {
|
||||
<section class="mb-12">
|
||||
@sectionHeading("regions.list")
|
||||
<table class="w-full text-left text-sm">
|
||||
<thead class="border-b border-rule text-xs uppercase tracking-wider text-muted">
|
||||
<tr>
|
||||
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "sso.field.name") }</th>
|
||||
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "regions.key") }</th>
|
||||
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "regions.owner") }</th>
|
||||
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "regions.instances") }</th>
|
||||
<th class="py-2"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-rule">
|
||||
for _, r := range v.Regions {
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full text-left text-sm">
|
||||
<thead class="border-b border-rule text-xs uppercase tracking-wider text-muted">
|
||||
<tr>
|
||||
<td class="py-2.5 pr-4">{ r.Name }</td>
|
||||
<td class="py-2.5 pr-4 font-mono text-xs">{ r.Key }</td>
|
||||
<td class="py-2.5 pr-4">
|
||||
if r.Platform {
|
||||
<span class="text-muted">{ i18n.T(ctx, "regions.platform") }</span>
|
||||
} else {
|
||||
{ i18n.T(ctx, "regions.own") }
|
||||
}
|
||||
</td>
|
||||
<td class="py-2.5 pr-4 font-mono text-xs">
|
||||
<span class={ templ.KV("text-up", r.Instances > 0), templ.KV("text-unknown", r.Instances == 0) }>●</span> { i18n.T(ctx, "regions.live", "Count", int(r.Instances)) }
|
||||
</td>
|
||||
<td class="py-2.5 text-right">
|
||||
if r.Manageable {
|
||||
<button type="button" data-delete={ v.APIBase + "/regions/" + r.ID } data-confirm={ i18n.T(ctx, "regions.delete_confirm") } class="text-muted hover:text-down">{ i18n.T(ctx, "regions.delete") }</button>
|
||||
}
|
||||
</td>
|
||||
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "sso.field.name") }</th>
|
||||
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "regions.key") }</th>
|
||||
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "regions.owner") }</th>
|
||||
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "regions.instances") }</th>
|
||||
<th class="py-2"></th>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-rule">
|
||||
for _, r := range v.Regions {
|
||||
<tr>
|
||||
<td class="py-2.5 pr-4">{ r.Name }</td>
|
||||
<td class="py-2.5 pr-4 font-mono text-xs">{ r.Key }</td>
|
||||
<td class="py-2.5 pr-4">
|
||||
if r.Platform {
|
||||
<span class="text-muted">{ i18n.T(ctx, "regions.platform") }</span>
|
||||
} else {
|
||||
{ i18n.T(ctx, "regions.own") }
|
||||
}
|
||||
</td>
|
||||
<td class="py-2.5 pr-4 font-mono text-xs">
|
||||
<span class={ templ.KV("text-up", r.Instances > 0), templ.KV("text-unknown", r.Instances == 0) }>●</span> { i18n.T(ctx, "regions.live", "Count", int(r.Instances)) }
|
||||
</td>
|
||||
<td class="py-2.5 text-right">
|
||||
if r.Manageable {
|
||||
<button type="button" data-delete={ v.APIBase + "/regions/" + r.ID } data-confirm={ i18n.T(ctx, "regions.delete_confirm") } class="text-muted hover:text-down">{ i18n.T(ctx, "regions.delete") }</button>
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
<div class="mb-12 grid gap-12 md:grid-cols-2">
|
||||
<section>
|
||||
@@ -210,6 +212,8 @@ templ AdminPage(p Page, me Me, v RegionsView, storage StorageView, checkTypes []
|
||||
type CheckTypeOption struct {
|
||||
Type string
|
||||
Enabled bool
|
||||
// Note is the i18n key of a remark next to the type, if any.
|
||||
Note string
|
||||
}
|
||||
|
||||
templ checkerNetworkSection(allow bool) {
|
||||
@@ -237,6 +241,9 @@ templ checkTypesSection(types []CheckTypeOption, api, next, introID string) {
|
||||
<label class="flex items-center gap-2">
|
||||
<input type="checkbox" name="enabled" value={ t.Type } data-multi checked?={ t.Enabled } class="accent-ink"/>
|
||||
{ i18n.T(ctx, "monitors.type_"+t.Type) }
|
||||
if t.Note != "" {
|
||||
<span class="text-xs text-muted">{ i18n.T(ctx, t.Note) }</span>
|
||||
}
|
||||
</label>
|
||||
}
|
||||
</div>
|
||||
@@ -401,6 +408,7 @@ templ adminLinks() {
|
||||
<a href="/admin/orgs" class="underline underline-offset-2">{ i18n.T(ctx, "orgs.title") }</a>
|
||||
<a href="/admin/audit" class="underline underline-offset-2">{ i18n.T(ctx, "audit.platform_title") }</a>
|
||||
<a href="/admin/legal" class="underline underline-offset-2">{ i18n.T(ctx, "legal.platform_title") }</a>
|
||||
<a href="/admin/support" class="underline underline-offset-2">{ i18n.T(ctx, "support.admin_title") }</a>
|
||||
</p>
|
||||
}
|
||||
|
||||
|
||||
+443
-405
File diff suppressed because it is too large.
Load diff
+36
-34
@@ -51,41 +51,43 @@ templ SSOSettingsPage(p Page, me Me, s SSOSettings) {
|
||||
<dd class="break-all font-mono text-xs leading-5">{ s.LoginURL }</dd>
|
||||
</dl>
|
||||
if len(s.Providers) > 0 {
|
||||
<table class="mb-12 w-full max-w-4xl text-left text-sm">
|
||||
<thead class="border-b border-rule text-xs uppercase tracking-wider text-muted">
|
||||
<tr>
|
||||
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "sso.field.name") }</th>
|
||||
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "sso.field.issuer") }</th>
|
||||
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "sso.field.auto_provision") }</th>
|
||||
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "sso.field.enabled") }</th>
|
||||
<th class="py-2"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-rule">
|
||||
for _, pr := range s.Providers {
|
||||
<tr class="align-top">
|
||||
<td class="py-2.5 pr-4">{ pr.Name }</td>
|
||||
<td class="py-2.5 pr-4 break-all font-mono text-xs">{ pr.Issuer }</td>
|
||||
<td class="py-2.5 pr-4">@yesNo(pr.AutoProvision)</td>
|
||||
<td class="py-2.5 pr-4">@yesNo(pr.Enabled)</td>
|
||||
<td class="py-2.5 text-right">
|
||||
<details class="inline-block text-left">
|
||||
<summary class="cursor-pointer text-muted hover:text-ink">{ i18n.T(ctx, "sso.action.edit") }</summary>
|
||||
<div class="mt-4 w-80">
|
||||
@ssoForm(pr, s.Roles, "put", "/org/sso/"+pr.ID)
|
||||
<button
|
||||
type="button"
|
||||
data-delete={ "/org/sso/" + pr.ID }
|
||||
data-confirm={ i18n.T(ctx, "sso.action.delete_confirm") }
|
||||
class="mt-4 text-sm text-down hover:underline"
|
||||
>{ i18n.T(ctx, "sso.action.delete") }</button>
|
||||
</div>
|
||||
</details>
|
||||
</td>
|
||||
<div class="overflow-x-auto">
|
||||
<table class="mb-12 w-full max-w-4xl text-left text-sm">
|
||||
<thead class="border-b border-rule text-xs uppercase tracking-wider text-muted">
|
||||
<tr>
|
||||
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "sso.field.name") }</th>
|
||||
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "sso.field.issuer") }</th>
|
||||
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "sso.field.auto_provision") }</th>
|
||||
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "sso.field.enabled") }</th>
|
||||
<th class="py-2"></th>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-rule">
|
||||
for _, pr := range s.Providers {
|
||||
<tr class="align-top">
|
||||
<td class="py-2.5 pr-4">{ pr.Name }</td>
|
||||
<td class="py-2.5 pr-4 break-all font-mono text-xs">{ pr.Issuer }</td>
|
||||
<td class="py-2.5 pr-4">@yesNo(pr.AutoProvision)</td>
|
||||
<td class="py-2.5 pr-4">@yesNo(pr.Enabled)</td>
|
||||
<td class="py-2.5 text-right">
|
||||
<details class="inline-block text-left">
|
||||
<summary class="cursor-pointer text-muted hover:text-ink">{ i18n.T(ctx, "sso.action.edit") }</summary>
|
||||
<div class="mt-4 w-80">
|
||||
@ssoForm(pr, s.Roles, "put", "/org/sso/"+pr.ID)
|
||||
<button
|
||||
type="button"
|
||||
data-delete={ "/org/sso/" + pr.ID }
|
||||
data-confirm={ i18n.T(ctx, "sso.action.delete_confirm") }
|
||||
class="mt-4 text-sm text-down hover:underline"
|
||||
>{ i18n.T(ctx, "sso.action.delete") }</button>
|
||||
</div>
|
||||
</details>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
<section class="max-w-md">
|
||||
<h2 class="mb-4 text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "sso.settings.add") }</h2>
|
||||
|
||||
+32
-32
@@ -242,14 +242,14 @@ func SSOSettingsPage(p Page, me Me, s SSOSettings) templ.Component {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if len(s.Providers) > 0 {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "<table class=\"mb-12 w-full max-w-4xl text-left text-sm\"><thead class=\"border-b border-rule text-xs uppercase tracking-wider text-muted\"><tr><th class=\"py-2 pr-4 font-medium\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "<div class=\"overflow-x-auto\"><table class=\"mb-12 w-full max-w-4xl text-left text-sm\"><thead class=\"border-b border-rule text-xs uppercase tracking-wider text-muted\"><tr><th class=\"py-2 pr-4 font-medium\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var14 string
|
||||
templ_7745c5c3_Var14, 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/sso.templ`, Line: 57, Col: 71}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 58, Col: 72}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -262,7 +262,7 @@ func SSOSettingsPage(p Page, me Me, s SSOSettings) templ.Component {
|
||||
var templ_7745c5c3_Var15 string
|
||||
templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "sso.field.issuer"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 58, Col: 73}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 59, Col: 74}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -275,7 +275,7 @@ func SSOSettingsPage(p Page, me Me, s SSOSettings) templ.Component {
|
||||
var templ_7745c5c3_Var16 string
|
||||
templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "sso.field.auto_provision"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 59, Col: 81}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 60, Col: 82}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -288,7 +288,7 @@ func SSOSettingsPage(p Page, me Me, s SSOSettings) templ.Component {
|
||||
var templ_7745c5c3_Var17 string
|
||||
templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "sso.field.enabled"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 60, Col: 74}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 61, Col: 75}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -306,7 +306,7 @@ func SSOSettingsPage(p Page, me Me, s SSOSettings) templ.Component {
|
||||
var templ_7745c5c3_Var18 string
|
||||
templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(pr.Name)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 67, Col: 40}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 68, Col: 41}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -319,7 +319,7 @@ func SSOSettingsPage(p Page, me Me, s SSOSettings) templ.Component {
|
||||
var templ_7745c5c3_Var19 string
|
||||
templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(pr.Issuer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 68, Col: 70}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 69, Col: 71}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -348,7 +348,7 @@ func SSOSettingsPage(p Page, me Me, s SSOSettings) templ.Component {
|
||||
var templ_7745c5c3_Var20 string
|
||||
templ_7745c5c3_Var20, 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/sso.templ`, Line: 73, Col: 99}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 74, Col: 100}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -369,7 +369,7 @@ func SSOSettingsPage(p Page, me Me, s SSOSettings) templ.Component {
|
||||
var templ_7745c5c3_Var21 string
|
||||
templ_7745c5c3_Var21, templ_7745c5c3_Err = templruntime.NewAttributeExpression("/org/sso/" + pr.ID).Resolve(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 78, Col: 44}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 79, Col: 45}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var21)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -382,7 +382,7 @@ func SSOSettingsPage(p Page, me Me, s SSOSettings) templ.Component {
|
||||
var templ_7745c5c3_Var22 string
|
||||
templ_7745c5c3_Var22, templ_7745c5c3_Err = templruntime.NewAttributeExpression(i18n.T(ctx, "sso.action.delete_confirm")).Resolve(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 79, Col: 66}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 80, Col: 67}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var22)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -395,7 +395,7 @@ func SSOSettingsPage(p Page, me Me, s SSOSettings) templ.Component {
|
||||
var templ_7745c5c3_Var23 string
|
||||
templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "sso.action.delete"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 81, Col: 45}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 82, Col: 46}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -406,7 +406,7 @@ func SSOSettingsPage(p Page, me Me, s SSOSettings) templ.Component {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "</tbody></table>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "</tbody></table></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -418,7 +418,7 @@ func SSOSettingsPage(p Page, me Me, s SSOSettings) templ.Component {
|
||||
var templ_7745c5c3_Var24 string
|
||||
templ_7745c5c3_Var24, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "sso.settings.add"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 91, Col: 109}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 93, Col: 109}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var24))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -471,7 +471,7 @@ func yesNo(v bool) templ.Component {
|
||||
var templ_7745c5c3_Var26 string
|
||||
templ_7745c5c3_Var26, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "common.yes"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 99, Col: 62}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 101, Col: 62}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var26))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -485,7 +485,7 @@ func yesNo(v bool) templ.Component {
|
||||
var templ_7745c5c3_Var27 string
|
||||
templ_7745c5c3_Var27, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "common.no"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 101, Col: 66}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 103, Col: 66}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var27))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -520,7 +520,7 @@ func ssoForm(pr SSOProvider, roles []Role, method, action string) templ.Componen
|
||||
var templ_7745c5c3_Var29 string
|
||||
templ_7745c5c3_Var29, templ_7745c5c3_Err = templruntime.NewAttributeExpression(action).Resolve(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 106, Col: 24}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 108, Col: 24}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var29)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -533,7 +533,7 @@ func ssoForm(pr SSOProvider, roles []Role, method, action string) templ.Componen
|
||||
var templ_7745c5c3_Var30 string
|
||||
templ_7745c5c3_Var30, templ_7745c5c3_Err = templruntime.NewAttributeExpression(method).Resolve(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 106, Col: 47}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 108, Col: 47}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var30)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -566,7 +566,7 @@ func ssoForm(pr SSOProvider, roles []Role, method, action string) templ.Componen
|
||||
var templ_7745c5c3_Var31 string
|
||||
templ_7745c5c3_Var31, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "sso.field.client_secret"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 112, Col: 124}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 114, Col: 124}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var31))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -584,7 +584,7 @@ func ssoForm(pr SSOProvider, roles []Role, method, action string) templ.Componen
|
||||
var templ_7745c5c3_Var32 string
|
||||
templ_7745c5c3_Var32, templ_7745c5c3_Err = templruntime.NewAttributeExpression(i18n.T(ctx, "sso.field.client_secret_keep")).Resolve(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 119, Col: 62}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 121, Col: 62}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var32)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -602,7 +602,7 @@ func ssoForm(pr SSOProvider, roles []Role, method, action string) templ.Componen
|
||||
var templ_7745c5c3_Var33 string
|
||||
templ_7745c5c3_Var33, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "sso.field.allowed_domains"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 124, Col: 126}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 126, Col: 126}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var33))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -615,7 +615,7 @@ func ssoForm(pr SSOProvider, roles []Role, method, action string) templ.Componen
|
||||
var templ_7745c5c3_Var34 string
|
||||
templ_7745c5c3_Var34, templ_7745c5c3_Err = templruntime.NewAttributeExpression(pr.AllowedDomains).Resolve(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 129, Col: 29}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 131, Col: 29}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var34)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -628,7 +628,7 @@ func ssoForm(pr SSOProvider, roles []Role, method, action string) templ.Componen
|
||||
var templ_7745c5c3_Var35 string
|
||||
templ_7745c5c3_Var35, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "sso.field.allowed_domains_hint"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 132, Col: 94}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 134, Col: 94}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var35))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -649,7 +649,7 @@ func ssoForm(pr SSOProvider, roles []Role, method, action string) templ.Componen
|
||||
var templ_7745c5c3_Var36 string
|
||||
templ_7745c5c3_Var36, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "sso.field.default_role"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 136, Col: 123}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 138, Col: 123}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var36))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -662,7 +662,7 @@ func ssoForm(pr SSOProvider, roles []Role, method, action string) templ.Componen
|
||||
var templ_7745c5c3_Var37 string
|
||||
templ_7745c5c3_Var37, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "sso.field.default_role_viewer"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 138, Col: 67}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 140, Col: 67}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var37))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -680,7 +680,7 @@ func ssoForm(pr SSOProvider, roles []Role, method, action string) templ.Componen
|
||||
var templ_7745c5c3_Var38 string
|
||||
templ_7745c5c3_Var38, templ_7745c5c3_Err = templruntime.NewAttributeExpression(r.ID).Resolve(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 140, Col: 25}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 142, Col: 25}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var38)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -703,7 +703,7 @@ func ssoForm(pr SSOProvider, roles []Role, method, action string) templ.Componen
|
||||
var templ_7745c5c3_Var39 string
|
||||
templ_7745c5c3_Var39, templ_7745c5c3_Err = templ.JoinStringErrs(r.Name)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 140, Col: 75}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 142, Col: 75}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var39))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -758,7 +758,7 @@ func valueField(label, name, value, placeholder string, required bool) templ.Com
|
||||
var templ_7745c5c3_Var41 string
|
||||
templ_7745c5c3_Var41, templ_7745c5c3_Err = templ.JoinStringErrs(label)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 151, Col: 90}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 153, Col: 90}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var41))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -771,7 +771,7 @@ func valueField(label, name, value, placeholder string, required bool) templ.Com
|
||||
var templ_7745c5c3_Var42 string
|
||||
templ_7745c5c3_Var42, templ_7745c5c3_Err = templruntime.NewAttributeExpression(name).Resolve(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 154, Col: 14}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 156, Col: 14}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var42)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -784,7 +784,7 @@ func valueField(label, name, value, placeholder string, required bool) templ.Com
|
||||
var templ_7745c5c3_Var43 string
|
||||
templ_7745c5c3_Var43, templ_7745c5c3_Err = templruntime.NewAttributeExpression(value).Resolve(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 155, Col: 16}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 157, Col: 16}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var43)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -797,7 +797,7 @@ func valueField(label, name, value, placeholder string, required bool) templ.Com
|
||||
var templ_7745c5c3_Var44 string
|
||||
templ_7745c5c3_Var44, templ_7745c5c3_Err = templruntime.NewAttributeExpression(placeholder).Resolve(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 156, Col: 28}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 158, Col: 28}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var44)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -845,7 +845,7 @@ func checkbox(label, name string, checked bool) templ.Component {
|
||||
var templ_7745c5c3_Var46 string
|
||||
templ_7745c5c3_Var46, templ_7745c5c3_Err = templruntime.NewAttributeExpression(name).Resolve(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 164, Col: 36}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 166, Col: 36}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var46)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -868,7 +868,7 @@ func checkbox(label, name string, checked bool) templ.Component {
|
||||
var templ_7745c5c3_Var47 string
|
||||
templ_7745c5c3_Var47, templ_7745c5c3_Err = templ.JoinStringErrs(label)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 165, Col: 9}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/sso.templ`, Line: 167, Col: 9}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var47))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
|
||||
@@ -44,6 +44,8 @@ templ StatusPagesPage(p Page, me Me, v PagesView) {
|
||||
}
|
||||
if pg.Suspended {
|
||||
<span class="ml-auto text-xs text-down">{ i18n.T(ctx, "pages.suspended") }</span>
|
||||
} else if pg.Published && pg.URL == "" {
|
||||
<span class="ml-auto text-xs text-muted">{ i18n.T(ctx, "pages.own_servers_short") }</span>
|
||||
} else if pg.Published {
|
||||
<a href={ templ.SafeURL(pg.URL) } class="ml-auto text-muted hover:text-ink" target="_blank" rel="noopener">{ i18n.T(ctx, "pages.open") } ↗</a>
|
||||
} else {
|
||||
@@ -89,6 +91,9 @@ type PageMonitorOption struct {
|
||||
|
||||
// PageEditor is the data of the status page editor.
|
||||
type PageEditor struct {
|
||||
// OwnServers is set when the organization's own status page servers
|
||||
// serve its pages instead of the platform's.
|
||||
OwnServers bool
|
||||
ID string
|
||||
Title string
|
||||
Slug string
|
||||
@@ -124,12 +129,15 @@ templ StatusPageEditor(p Page, me Me, e PageEditor) {
|
||||
<div class="mb-8 flex flex-wrap items-baseline justify-between gap-4">
|
||||
<h1 class="text-lg font-semibold">{ e.Title }</h1>
|
||||
<span class="flex gap-5 text-sm">
|
||||
if e.Published {
|
||||
if e.Published && e.URL != "" {
|
||||
<a href={ templ.SafeURL(e.URL) } target="_blank" rel="noopener" class="text-muted hover:text-ink">{ i18n.T(ctx, "pages.open") } ↗</a>
|
||||
}
|
||||
<a href={ templ.SafeURL("/api/v1/org/statuspages/" + e.ID + "/export") } class="text-muted hover:text-ink">{ i18n.T(ctx, "pages.export") }</a>
|
||||
</span>
|
||||
</div>
|
||||
if e.OwnServers {
|
||||
<p class="mb-6 border-l-2 border-ink pl-3 text-sm">{ i18n.T(ctx, "pages.own_servers") }</p>
|
||||
}
|
||||
<div class="grid gap-12 md:grid-cols-2">
|
||||
<section>
|
||||
@sectionHeading("pages.settings")
|
||||
|
||||
+810
-766
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,413 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/i18n"
|
||||
)
|
||||
|
||||
// SupportTicket is a ticket as the support pages show it; User and Org
|
||||
// are filled for admins.
|
||||
type SupportTicket struct {
|
||||
ID, Subject, Status string
|
||||
User, Org string
|
||||
Updated string
|
||||
References []SupportReference
|
||||
Messages []SupportMessage
|
||||
}
|
||||
|
||||
// SupportReference is something a ticket points at; Kind is org, monitor,
|
||||
// channel, alert_group, status_page or incident.
|
||||
type SupportReference struct {
|
||||
Kind, Name string
|
||||
}
|
||||
|
||||
// SupportMessage is one message of a ticket, rendered from Markdown.
|
||||
type SupportMessage struct {
|
||||
FromStaff bool
|
||||
// Author is the admin who answered, for admins only.
|
||||
Author string
|
||||
HTML string
|
||||
At string
|
||||
}
|
||||
|
||||
// SupportOptions are what of the active organization a new ticket can
|
||||
// point at; Org is empty without one.
|
||||
type SupportOptions struct {
|
||||
Org string
|
||||
Monitors, Channels, AlertGroups, StatusPages, Incidents []SupportOption
|
||||
}
|
||||
|
||||
// SupportOption is one choice of SupportOptions.
|
||||
type SupportOption struct {
|
||||
ID, Name string
|
||||
}
|
||||
|
||||
// SupportSettings are how the platform runs support, for its admins.
|
||||
type SupportSettings struct {
|
||||
Enabled bool
|
||||
MaxOpen int
|
||||
}
|
||||
|
||||
// SupportAccount is what admins see about the account behind a ticket.
|
||||
type SupportAccount struct {
|
||||
ID, Email, Name, Created, Locale string
|
||||
Verified, TOTP, Password, Admin bool
|
||||
Suspended bool
|
||||
SuspendedReason string
|
||||
OrgsOwned, OrgLimit int
|
||||
OpenTickets int64
|
||||
Orgs []SupportOrg
|
||||
}
|
||||
|
||||
// SupportOrg is an organization of the account with its limits; Current
|
||||
// marks the one the ticket names. Limits of 0 are unlimited.
|
||||
type SupportOrg struct {
|
||||
Name, Slug string
|
||||
Owner, Current, Suspended bool
|
||||
SuspendedReason string
|
||||
Monitors, MonitorLimit int
|
||||
StatusPages, StatusPageLimit int
|
||||
RegionsPerMonitor int
|
||||
}
|
||||
|
||||
// SupportStatuses are the states of a ticket, in the order admins filter
|
||||
// them.
|
||||
var SupportStatuses = []string{"open", "answered", "closed"}
|
||||
|
||||
var supportFilters = append(append([]string{}, SupportStatuses...), "all")
|
||||
|
||||
// supportBase is where the support pages live for staff or the account.
|
||||
func supportBase(staff bool) string {
|
||||
if staff {
|
||||
return "/admin/support"
|
||||
}
|
||||
return "/support"
|
||||
}
|
||||
|
||||
func supportAPI(t SupportTicket, staff bool) string {
|
||||
return supportBase(staff) + "/tickets/" + t.ID
|
||||
}
|
||||
|
||||
// usageText shows used of limit, ∞ for no limit.
|
||||
func usageText(used, limit int) string {
|
||||
if limit <= 0 {
|
||||
return strconv.Itoa(used) + " / ∞"
|
||||
}
|
||||
return strconv.Itoa(used) + " / " + strconv.Itoa(limit)
|
||||
}
|
||||
|
||||
templ supportStatusLabel(status string) {
|
||||
<span
|
||||
class={ "whitespace-nowrap border px-1.5 py-0.5 font-mono text-xs",
|
||||
templ.KV("border-down text-down", status == "open"),
|
||||
templ.KV("border-up text-up", status == "answered"),
|
||||
templ.KV("border-rule text-muted", status == "closed") }
|
||||
>{ i18n.T(ctx, "support.status."+status) }</span>
|
||||
}
|
||||
|
||||
templ supportList(tickets []SupportTicket, base string, staff bool) {
|
||||
<ul class="divide-y divide-rule border-y border-rule text-sm">
|
||||
for _, t := range tickets {
|
||||
<li>
|
||||
<a href={ templ.SafeURL(base + t.ID) } class="flex flex-wrap items-center gap-x-4 gap-y-1 py-3 hover:bg-rule/30">
|
||||
@supportStatusLabel(t.Status)
|
||||
<span class="order-last min-w-0 basis-full truncate font-medium sm:order-none sm:flex-1 sm:basis-0">{ t.Subject }</span>
|
||||
if staff {
|
||||
<span class="order-last min-w-0 basis-full truncate text-muted sm:order-none sm:basis-auto">
|
||||
{ t.User }
|
||||
if t.Org != "" {
|
||||
{ " · " + t.Org }
|
||||
}
|
||||
</span>
|
||||
}
|
||||
<span class="ml-auto font-mono text-xs text-muted">{ t.Updated }</span>
|
||||
</a>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
|
||||
templ supportSelect(labelID, name string, opts []SupportOption) {
|
||||
if len(opts) > 0 {
|
||||
<label class="mb-3 block">
|
||||
<span class="mb-1 block text-xs text-muted">{ i18n.T(ctx, labelID) }</span>
|
||||
<select name={ name } class="w-full border border-rule bg-transparent px-2 py-1.5 text-sm">
|
||||
<option value="">{ "– " + i18n.T(ctx, "support.attach_none") }</option>
|
||||
for _, o := range opts {
|
||||
<option value={ o.ID }>{ o.Name }</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
}
|
||||
}
|
||||
|
||||
templ SupportPage(p Page, me Me, tickets []SupportTicket, opts SupportOptions) {
|
||||
@consoleShell(p, me) {
|
||||
@settingsHeading("support.title", "support.intro")
|
||||
<div class="grid gap-12 md:grid-cols-[1fr_22rem]">
|
||||
<section>
|
||||
@sectionHeading("support.mine")
|
||||
if len(tickets) == 0 {
|
||||
<p class="border-y border-rule py-10 text-center text-sm text-muted">{ i18n.T(ctx, "support.none") }</p>
|
||||
} else {
|
||||
@supportList(tickets, "/support/", false)
|
||||
}
|
||||
</section>
|
||||
<aside>
|
||||
@sectionHeading("support.new")
|
||||
<form data-api="/support/tickets" data-next="/support/" data-next-from="id">
|
||||
@formError()
|
||||
<label class="mb-4 block">
|
||||
<span class="mb-1 block text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "support.subject") }</span>
|
||||
<input name="subject" required maxlength="200" class="w-full border border-rule bg-transparent px-2.5 py-1.5 outline-none focus:border-ink"/>
|
||||
</label>
|
||||
<div class="mb-4">
|
||||
<span class="mb-1 block text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "support.message") }</span>
|
||||
@MarkdownEditor("message", "", 8, 10000, MarkdownInline)
|
||||
</div>
|
||||
if opts.Org != "" {
|
||||
<details class="mb-4 border border-rule p-3">
|
||||
<summary class="cursor-pointer text-sm">{ i18n.T(ctx, "support.attach") }</summary>
|
||||
<p class="mt-2 mb-3 text-xs text-muted">{ i18n.T(ctx, "support.attach_hint") }</p>
|
||||
@checkbox(i18n.T(ctx, "support.attach_org", "Org", opts.Org), "attach_org", false)
|
||||
@supportSelect("support.ref.monitor", "monitor_id", opts.Monitors)
|
||||
@supportSelect("support.ref.channel", "channel_id", opts.Channels)
|
||||
@supportSelect("support.ref.alert_group", "alert_group_id", opts.AlertGroups)
|
||||
@supportSelect("support.ref.status_page", "status_page_id", opts.StatusPages)
|
||||
@supportSelect("support.ref.incident", "incident_id", opts.Incidents)
|
||||
</details>
|
||||
}
|
||||
@submit(i18n.T(ctx, "support.send"))
|
||||
</form>
|
||||
</aside>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
templ SupportDisabledPage(p Page, me Me) {
|
||||
@consoleShell(p, me) {
|
||||
@settingsHeading("support.title", "")
|
||||
<p class="border-y border-rule py-10 text-center text-sm text-muted">{ i18n.T(ctx, "support.disabled") }</p>
|
||||
}
|
||||
}
|
||||
|
||||
templ supportReferences(refs []SupportReference) {
|
||||
if len(refs) > 0 {
|
||||
<dl class="mb-8 grid grid-cols-[auto_1fr] gap-x-4 gap-y-1 border-y border-rule py-3 text-sm">
|
||||
for _, r := range refs {
|
||||
<dt class="text-muted">{ i18n.T(ctx, "support.ref."+r.Kind) }</dt>
|
||||
<dd class="min-w-0 break-words">{ r.Name }</dd>
|
||||
}
|
||||
</dl>
|
||||
}
|
||||
}
|
||||
|
||||
templ supportFlag(on bool, yesID, noID string) {
|
||||
if on {
|
||||
<span class="text-up">{ i18n.T(ctx, yesID) }</span>
|
||||
} else {
|
||||
<span class="text-muted">{ i18n.T(ctx, noID) }</span>
|
||||
}
|
||||
}
|
||||
|
||||
// supportAccountBox gives admins the account behind a ticket at a glance.
|
||||
templ supportAccountBox(a SupportAccount) {
|
||||
<aside class="self-start border border-rule p-4 text-sm">
|
||||
@sectionHeading("support.account")
|
||||
<dl class="grid grid-cols-[auto_1fr] gap-x-4 gap-y-1">
|
||||
<dt class="text-muted">{ i18n.T(ctx, "support.account.email") }</dt>
|
||||
<dd class="min-w-0 break-all">{ a.Email }</dd>
|
||||
if a.Name != "" {
|
||||
<dt class="text-muted">{ i18n.T(ctx, "support.account.name") }</dt>
|
||||
<dd class="min-w-0 break-words">{ a.Name }</dd>
|
||||
}
|
||||
<dt class="text-muted">{ i18n.T(ctx, "support.account.created") }</dt>
|
||||
<dd class="font-mono text-xs">{ a.Created }</dd>
|
||||
<dt class="text-muted">{ i18n.T(ctx, "support.account.state") }</dt>
|
||||
<dd>
|
||||
if a.Suspended {
|
||||
<span class="text-down">{ i18n.T(ctx, "support.account.suspended") }</span>
|
||||
if a.SuspendedReason != "" {
|
||||
<span class="text-muted">{ " · " + a.SuspendedReason }</span>
|
||||
}
|
||||
} else {
|
||||
<span class="text-up">{ i18n.T(ctx, "support.account.active") }</span>
|
||||
}
|
||||
</dd>
|
||||
<dt class="text-muted">{ i18n.T(ctx, "support.account.email_verified") }</dt>
|
||||
<dd>
|
||||
@supportFlag(a.Verified, "support.yes", "support.no")
|
||||
</dd>
|
||||
<dt class="text-muted">{ i18n.T(ctx, "support.account.sign_in") }</dt>
|
||||
<dd>
|
||||
if a.Password {
|
||||
{ i18n.T(ctx, "support.account.password") }
|
||||
} else {
|
||||
{ i18n.T(ctx, "support.account.sso_only") }
|
||||
}
|
||||
if a.TOTP {
|
||||
{ " · 2FA" }
|
||||
}
|
||||
</dd>
|
||||
if a.Admin {
|
||||
<dt class="text-muted">{ i18n.T(ctx, "support.account.role") }</dt>
|
||||
<dd class="font-medium">{ i18n.T(ctx, "console.nav.admin") }</dd>
|
||||
}
|
||||
if a.Locale != "" {
|
||||
<dt class="text-muted">{ i18n.T(ctx, "support.account.locale") }</dt>
|
||||
<dd class="font-mono text-xs">{ a.Locale }</dd>
|
||||
}
|
||||
<dt class="text-muted">{ i18n.T(ctx, "support.account.orgs_owned") }</dt>
|
||||
<dd class="font-mono text-xs">{ usageText(a.OrgsOwned, a.OrgLimit) }</dd>
|
||||
<dt class="text-muted">{ i18n.T(ctx, "support.account.open_tickets") }</dt>
|
||||
<dd class="font-mono text-xs">{ strconv.FormatInt(a.OpenTickets, 10) }</dd>
|
||||
<dt class="text-muted">{ "ID" }</dt>
|
||||
<dd class="min-w-0 break-all font-mono text-xs text-muted">{ a.ID }</dd>
|
||||
</dl>
|
||||
if len(a.Orgs) > 0 {
|
||||
<h3 class="mt-6 mb-2 text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "support.account.orgs") }</h3>
|
||||
<ul class="space-y-3">
|
||||
for _, o := range a.Orgs {
|
||||
<li class={ "border-l-2 pl-3", templ.KV("border-ink", o.Current), templ.KV("border-rule", !o.Current) }>
|
||||
<p class="flex flex-wrap items-baseline gap-x-2">
|
||||
<span class="font-medium">{ o.Name }</span>
|
||||
<span class="font-mono text-xs text-muted">{ o.Slug }</span>
|
||||
if o.Owner {
|
||||
<span class="text-xs">{ i18n.T(ctx, "support.account.owner") }</span>
|
||||
}
|
||||
if o.Current {
|
||||
<span class="text-xs text-muted">{ i18n.T(ctx, "support.account.this_ticket") }</span>
|
||||
}
|
||||
</p>
|
||||
if o.Suspended {
|
||||
<p class="text-xs text-down">
|
||||
{ i18n.T(ctx, "support.account.org_suspended") }
|
||||
if o.SuspendedReason != "" {
|
||||
{ " · " + o.SuspendedReason }
|
||||
}
|
||||
</p>
|
||||
}
|
||||
<p class="mt-1 font-mono text-xs text-muted">
|
||||
{ i18n.T(ctx, "support.account.monitors") + " " + usageText(o.Monitors, o.MonitorLimit) }
|
||||
{ " · " + i18n.T(ctx, "support.account.status_pages") + " " + usageText(o.StatusPages, o.StatusPageLimit) }
|
||||
{ " · " + i18n.T(ctx, "support.account.regions") + " " + limitText(ctx, o.RegionsPerMonitor) }
|
||||
</p>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
</aside>
|
||||
}
|
||||
|
||||
// SupportTicketPage shows a ticket's conversation to its account or, with
|
||||
// the account's details, to the admins.
|
||||
templ SupportTicketPage(p Page, me Me, t SupportTicket, account *SupportAccount) {
|
||||
@consoleShell(p, me) {
|
||||
<p class="mb-2 text-sm"><a href={ templ.SafeURL(supportBase(account != nil)) } class="text-muted hover:text-ink">{ "← " + i18n.T(ctx, "support.all") }</a></p>
|
||||
<h1 class="mb-2 break-words text-xl font-semibold">{ t.Subject }</h1>
|
||||
<div class="mb-6 flex flex-wrap items-center gap-x-4 gap-y-1 text-sm">
|
||||
@supportStatusLabel(t.Status)
|
||||
if account != nil {
|
||||
<span>{ t.User }</span>
|
||||
}
|
||||
</div>
|
||||
<div class={ templ.KV("grid gap-10 lg:grid-cols-[1fr_20rem]", account != nil) }>
|
||||
<div class="min-w-0">
|
||||
@supportReferences(t.References)
|
||||
<ol class="mb-10 space-y-4">
|
||||
for _, m := range t.Messages {
|
||||
<li class={ "border p-4", templ.KV("border-rule", !m.FromStaff), templ.KV("border-ink bg-rule/20", m.FromStaff) }>
|
||||
<p class="mb-2 flex flex-wrap items-baseline gap-x-3 text-xs">
|
||||
<span class="font-medium">
|
||||
switch {
|
||||
case m.FromStaff && m.Author != "":
|
||||
{ i18n.T(ctx, "support.from_staff") + " · " + m.Author }
|
||||
case m.FromStaff:
|
||||
{ i18n.T(ctx, "support.from_staff") }
|
||||
case account != nil:
|
||||
{ t.User }
|
||||
default:
|
||||
{ i18n.T(ctx, "support.from_you") }
|
||||
}
|
||||
</span>
|
||||
<span class="font-mono text-muted">{ m.At }</span>
|
||||
</p>
|
||||
<div class="legal-text break-words text-sm">
|
||||
@templ.Raw(m.HTML)
|
||||
</div>
|
||||
</li>
|
||||
}
|
||||
</ol>
|
||||
<section class="max-w-2xl">
|
||||
@sectionHeading("support.reply")
|
||||
if t.Status == "closed" && account == nil {
|
||||
<p class="mb-4 text-sm text-muted">{ i18n.T(ctx, "support.closed_hint") }</p>
|
||||
}
|
||||
<form data-api={ supportAPI(t, account != nil) + "/messages" } data-next={ supportBase(account != nil) + "/" + t.ID }>
|
||||
@formError()
|
||||
<div class="mb-4">
|
||||
@MarkdownEditor("message", "", 6, 10000, MarkdownInline)
|
||||
</div>
|
||||
@submit(i18n.T(ctx, "support.send"))
|
||||
</form>
|
||||
<form data-api={ supportAPI(t, account != nil) + "/status" } data-method="put" data-next={ supportBase(account != nil) + "/" + t.ID } class="mt-6">
|
||||
@formError()
|
||||
if t.Status == "closed" {
|
||||
<input type="hidden" name="status" value="open"/>
|
||||
<button type="submit" class="text-sm text-muted underline underline-offset-2 hover:text-ink">{ i18n.T(ctx, "support.reopen") }</button>
|
||||
} else {
|
||||
<input type="hidden" name="status" value="closed"/>
|
||||
<button type="submit" class="text-sm text-muted underline underline-offset-2 hover:text-ink">{ i18n.T(ctx, "support.close") }</button>
|
||||
}
|
||||
</form>
|
||||
</section>
|
||||
</div>
|
||||
if account != nil {
|
||||
@supportAccountBox(*account)
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
templ AdminSupportPage(p Page, me Me, tickets []SupportTicket, filter string, settings SupportSettings) {
|
||||
@consoleShell(p, me) {
|
||||
@settingsHeading("support.admin_title", "support.admin_intro")
|
||||
@adminLinks()
|
||||
<details class="mb-8 border border-rule p-4" open?={ !settings.Enabled }>
|
||||
<summary class="cursor-pointer text-sm">
|
||||
{ i18n.T(ctx, "support.settings") }
|
||||
if settings.Enabled {
|
||||
<span class="ml-2 text-up">{ i18n.T(ctx, "support.settings.on") }</span>
|
||||
} else {
|
||||
<span class="ml-2 text-down">{ i18n.T(ctx, "support.settings.off") }</span>
|
||||
}
|
||||
</summary>
|
||||
<form data-api="/admin/support/settings" data-method="put" class="mt-4 max-w-md">
|
||||
@formError()
|
||||
@checkbox(i18n.T(ctx, "support.settings.enabled"), "enabled", settings.Enabled)
|
||||
<p class="-mt-2 mb-4 ml-6 text-xs text-muted">{ i18n.T(ctx, "support.settings.enabled_hint") }</p>
|
||||
<label class="mb-4 block">
|
||||
<span class="mb-1 block text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "support.settings.max_open") }</span>
|
||||
<input name="max_open_tickets" data-number type="number" min="0" max="1000" value={ strconv.Itoa(settings.MaxOpen) } class="w-32 border border-rule bg-transparent px-2.5 py-1.5 outline-none focus:border-ink"/>
|
||||
<span class="mt-1 block text-xs text-muted">{ i18n.T(ctx, "support.settings.max_open_hint") }</span>
|
||||
</label>
|
||||
@submit(i18n.T(ctx, "support.settings.save"))
|
||||
</form>
|
||||
</details>
|
||||
<nav class="mb-4 flex flex-wrap gap-x-4 gap-y-1 text-sm" aria-label={ i18n.T(ctx, "support.filter") }>
|
||||
for _, f := range supportFilters {
|
||||
if f == filter {
|
||||
<span class="font-medium" aria-current="true">{ i18n.T(ctx, "support.filter."+f) }</span>
|
||||
} else {
|
||||
<a href={ templ.SafeURL("/admin/support?status=" + f) } class="text-muted hover:text-ink">{ i18n.T(ctx, "support.filter."+f) }</a>
|
||||
}
|
||||
}
|
||||
</nav>
|
||||
if len(tickets) == 0 {
|
||||
<p class="border-y border-rule py-10 text-center text-sm text-muted">{ i18n.T(ctx, "support.none_admin") }</p>
|
||||
} else {
|
||||
@supportList(tickets, "/admin/support/", true)
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user