Compare commits

..
18 changed files with 284 additions and 1194 deletions

No files matched your search

-207
View File
@@ -1,207 +0,0 @@
package api
import (
"net/http"
"time"
"github.com/google/uuid"
"git.zb-server.de/ZB-Server/uptimesebi/internal/check"
)
// sessionStarted is the answer of requests that sign in.
var sessionStarted = obj{"status": "", "csrf_token": ""}
// endpoints documents every route under /api/v1, in the order the docs
// show them.
var endpoints = []endpoint{
// Account
{method: "POST", path: "/api/v1/auth/signup", tag: "Account", summary: "Create an account and organization", public: true,
description: "Starts a session. Depending on the installation, sign-up is open, limited to the first user, or closed.",
req: signupRequest{}, resp: sessionStarted},
{method: "POST", path: "/api/v1/auth/login", tag: "Account", summary: "Sign in with email and password", public: true,
description: "Answers `{\"status\": \"totp_required\"}` when the account has two-factor authentication; continue with /auth/login/totp.",
req: loginRequest{}, resp: sessionStarted},
{method: "POST", path: "/api/v1/auth/login/totp", tag: "Account", summary: "Complete sign-in with a TOTP or recovery code", public: true,
req: secondFactorRequest{}, resp: sessionStarted},
{method: "POST", path: "/api/v1/auth/logout", tag: "Account", summary: "Sign out", sessionOnly: true, status: http.StatusNoContent},
{method: "GET", path: "/api/v1/me", tag: "Account", summary: "The signed-in user and their organizations", resp: meView{}},
{method: "POST", path: "/api/v1/me/org", tag: "Account", summary: "Switch the active organization", sessionOnly: true,
req: switchOrgRequest{}, status: http.StatusNoContent},
{method: "POST", path: "/api/v1/locale", tag: "Account", summary: "Set the interface language", public: true,
req: localeRequest{}, status: http.StatusNoContent},
{method: "POST", path: "/api/v1/me/totp/setup", tag: "Account", summary: "Start setting up two-factor authentication", sessionOnly: true,
resp: obj{"secret": "", "otpauth_url": "", "qr": ""}},
{method: "POST", path: "/api/v1/me/totp/enable", tag: "Account", summary: "Enable two-factor authentication", sessionOnly: true,
description: "Returns single-use recovery codes, shown only this once.", req: totpRequest{}, resp: obj{"recovery_codes": []string{}}},
{method: "POST", path: "/api/v1/me/totp/disable", tag: "Account", summary: "Disable two-factor authentication", sessionOnly: true,
req: reauthRequest{}, status: http.StatusNoContent},
{method: "POST", path: "/api/v1/me/totp/recovery-codes", tag: "Account", summary: "Replace the recovery codes", sessionOnly: true,
req: reauthRequest{}, resp: obj{"recovery_codes": []string{}}},
{method: "GET", path: "/api/v1/me/audit", tag: "Account", summary: "Sign-ins and security changes of the account",
resp: obj{"events": []auditEventView{}}},
{method: "GET", path: "/api/v1/me/export", tag: "Account", summary: "Export all personal data (GDPR Art. 15, 20)",
description: "`?format=pdf` returns a PDF instead of JSON.", resp: accountExport{}},
{method: "POST", path: "/api/v1/me/delete", tag: "Account", summary: "Delete the account (GDPR Art. 17)", sessionOnly: true,
description: "Refused with `owns_shared_orgs` while the user owns organizations with other members. Organizations only the user belongs to are deleted with the account.",
req: deletionRequest{}, resp: obj{"status": ""}},
{method: "POST", path: "/api/v1/markdown/preview", tag: "Account", summary: "Render Markdown as pages will show it",
req: previewRequest{}, resp: obj{"html": ""}},
{method: "POST", path: "/api/v1/invitations/:token/accept", tag: "Account", summary: "Accept an invitation with the signed-in account", sessionOnly: true,
status: http.StatusNoContent},
{method: "POST", path: "/api/v1/invitations/:token/signup", tag: "Account", summary: "Create an account through an invitation", public: true,
req: inviteSignupRequest{}, resp: sessionStarted},
// Monitors
{method: "GET", path: "/api/v1/org/monitors", tag: "Monitors", summary: "List monitors with their latest results",
description: "Only monitors the caller may read; header values and heartbeat tokens only for those who may change the monitor.",
perm: "monitors.read", resp: obj{"monitors": []monitorView{}}},
{method: "POST", path: "/api/v1/org/monitors", tag: "Monitors", summary: "Create a monitor",
description: "`type` is one of http, json, prometheus, tcp, tls, dns, icmp or heartbeat; `config` depends on it (see HTTPConfig, JSONConfig, PrometheusConfig, DNSConfig, TLSConfig, HeartbeatConfig). Heartbeat monitors take neither target nor regions and return their `ping_url`.",
perm: "monitors.write", req: monitorRequest{}, status: http.StatusCreated, resp: monitorView{}},
{method: "PUT", path: "/api/v1/org/monitors/:id", tag: "Monitors", summary: "Change a monitor", perm: "monitors.write",
req: monitorRequest{}, resp: monitorView{}},
{method: "DELETE", path: "/api/v1/org/monitors/:id", tag: "Monitors", summary: "Delete a monitor and its history", perm: "monitors.write",
status: http.StatusNoContent},
{method: "GET", path: "/api/v1/org/monitors/:id/evidence", tag: "Monitors", summary: "What checkers saw: captured responses",
perm: "monitors.write", resp: obj{"evidence": []evidenceSummary{}}},
{method: "GET", path: "/api/v1/org/monitors/:id/evidence/:evidence", tag: "Monitors", summary: "One captured response",
description: "Redirect chain with headers, timing, certificate and the first 32 KiB of the body.",
perm: "monitors.write", resp: obj{"id": uuid.UUID{}, "region": "", "checker_id": uuid.UUID{}, "time": time.Time{}, "ok": false, "status_code": new(int32), "error": new(string), "evidence": check.Evidence{}}},
{method: "GET", path: "/api/v1/org/checkers/:id", tag: "Monitors", summary: "What a checker instance is doing",
description: "Platform checkers serve every organization; other organizations' work appears only as a count.",
resp: checkerActivity{}},
{method: "GET", path: "/api/v1/org/groups", tag: "Monitors", summary: "List monitor groups", resp: obj{"groups": []groupView{}}},
{method: "POST", path: "/api/v1/org/groups", tag: "Monitors", summary: "Create a group", perm: "monitors.write",
req: groupRequest{}, status: http.StatusCreated, resp: groupView{}},
{method: "PUT", path: "/api/v1/org/groups/:id", tag: "Monitors", summary: "Rename or move a group", perm: "monitors.write",
req: groupRequest{}, resp: groupView{}},
{method: "DELETE", path: "/api/v1/org/groups/:id", tag: "Monitors", summary: "Delete a group; its content moves up", perm: "monitors.write",
status: http.StatusNoContent},
{method: "GET", path: "/api/v1/org/maintenance", tag: "Monitors", summary: "List maintenance windows", perm: "monitors.read",
resp: obj{"maintenance": []maintenanceView{}}},
{method: "POST", path: "/api/v1/org/maintenance", tag: "Monitors", summary: "Plan maintenance",
description: "During maintenance, failures open no incidents and send no notifications.",
perm: "monitors.write", req: maintenanceRequest{}, status: http.StatusCreated, resp: maintenanceView{}},
{method: "PUT", path: "/api/v1/org/maintenance/:id", tag: "Monitors", summary: "Change maintenance", perm: "monitors.write",
req: maintenanceRequest{}, resp: maintenanceView{}},
{method: "DELETE", path: "/api/v1/org/maintenance/:id", tag: "Monitors", summary: "Delete maintenance", perm: "monitors.write",
status: http.StatusNoContent},
{method: "GET", path: "/api/v1/org/incidents", tag: "Monitors", summary: "List incidents", perm: "incidents.read",
resp: obj{"incidents": []incidentView{}}},
// Status pages
{method: "GET", path: "/api/v1/org/statuspages", tag: "Status pages", summary: "List status pages", resp: obj{"pages": []statusPageView{}}},
{method: "POST", path: "/api/v1/org/statuspages", tag: "Status pages", summary: "Create a status page", perm: "statuspages.write",
req: statusPageRequest{}, status: http.StatusCreated, resp: statusPageView{}},
{method: "PUT", path: "/api/v1/org/statuspages/:id", tag: "Status pages", summary: "Change a status page", perm: "statuspages.write",
req: statusPageRequest{}, resp: statusPageView{}},
{method: "DELETE", path: "/api/v1/org/statuspages/:id", tag: "Status pages", summary: "Delete a status page", perm: "statuspages.write",
status: http.StatusNoContent},
{method: "PUT", path: "/api/v1/org/statuspages/:id/monitors", tag: "Status pages", summary: "Set the monitors shown", perm: "statuspages.write",
req: pageMonitorsRequest{}, status: http.StatusNoContent},
{method: "PUT", path: "/api/v1/org/statuspages/:id/domain", tag: "Status pages", summary: "Set a custom domain", perm: "statuspages.write",
description: "Verify it with a TXT record before it is served.", req: domainRequest{}, resp: statusPageView{}},
{method: "POST", path: "/api/v1/org/statuspages/:id/domain/verify", tag: "Status pages", summary: "Verify the custom domain", perm: "statuspages.write",
status: http.StatusNoContent},
{method: "GET", path: "/api/v1/org/statuspages/:id/export", tag: "Status pages", summary: "Export the page as a single HTML file", perm: "statuspages.read",
media: "text/html"},
// Alerting
{method: "GET", path: "/api/v1/org/channels", tag: "Alerting", summary: "List notification channels", perm: "notifications.read",
resp: obj{"channels": []channelView{}, "email_available": false}},
{method: "POST", path: "/api/v1/org/channels", tag: "Alerting", summary: "Create a channel",
description: "Webhook channels return their signing secret once.", perm: "notifications.write",
req: channelRequest{}, status: http.StatusCreated, resp: obj{"channel": channelView{}, "signing_secret": ""}},
{method: "PUT", path: "/api/v1/org/channels/:id", tag: "Alerting", summary: "Change a channel", perm: "notifications.write",
req: channelRequest{}, resp: obj{"channel": channelView{}, "signing_secret": ""}},
{method: "DELETE", path: "/api/v1/org/channels/:id", tag: "Alerting", summary: "Delete a channel", perm: "notifications.write",
status: http.StatusNoContent},
{method: "POST", path: "/api/v1/org/channels/:id/test", tag: "Alerting", summary: "Send a test notification", perm: "notifications.write",
status: http.StatusNoContent},
// Organization
{method: "PUT", path: "/api/v1/org/policy", tag: "Organization", summary: "Set sign-in and token policies", perm: "org.manage", sessionOnly: true,
req: policyRequest{}, resp: obj{"require_totp": false, "require_sso": false, "api_token_max_days": new(int32)}},
{method: "GET", path: "/api/v1/org/members", tag: "Organization", summary: "List members and their roles", perm: "members.read",
resp: obj{"members": []memberView{}}},
{method: "DELETE", path: "/api/v1/org/members/:user", tag: "Organization", summary: "Remove a member", perm: "members.manage", sessionOnly: true,
status: http.StatusNoContent},
{method: "POST", path: "/api/v1/org/members/:user/roles", tag: "Organization", summary: "Assign a role, optionally limited to a group or status page",
description: "Nobody can grant permissions they do not hold.", perm: "members.manage", sessionOnly: true,
req: assignRequest{}, status: http.StatusCreated, resp: obj{"id": uuid.UUID{}}},
{method: "DELETE", path: "/api/v1/org/assignments/:id", tag: "Organization", summary: "Remove a role assignment", perm: "members.manage", sessionOnly: true,
status: http.StatusNoContent},
{method: "GET", path: "/api/v1/org/invitations", tag: "Organization", summary: "List pending invitations", perm: "members.read",
resp: obj{"invitations": []invitationView{}}},
{method: "POST", path: "/api/v1/org/invitations", tag: "Organization", summary: "Invite someone", perm: "members.manage", sessionOnly: true,
req: inviteRequest{}, status: http.StatusCreated, resp: obj{"url": ""}},
{method: "DELETE", path: "/api/v1/org/invitations/:id", tag: "Organization", summary: "Withdraw an invitation", perm: "members.manage", sessionOnly: true,
status: http.StatusNoContent},
{method: "GET", path: "/api/v1/org/roles", tag: "Organization", summary: "List roles and all permissions", perm: "members.read",
resp: obj{"roles": []roleView{}, "permissions": []string{}}},
{method: "POST", path: "/api/v1/org/roles", tag: "Organization", summary: "Create a custom role", perm: "roles.manage", sessionOnly: true,
req: roleRequest{}, status: http.StatusCreated, resp: roleView{}},
{method: "PUT", path: "/api/v1/org/roles/:id", tag: "Organization", summary: "Change a custom role", perm: "roles.manage", sessionOnly: true,
req: roleRequest{}, resp: roleView{}},
{method: "DELETE", path: "/api/v1/org/roles/:id", tag: "Organization", summary: "Delete an unused custom role", perm: "roles.manage", sessionOnly: true,
status: http.StatusNoContent},
{method: "GET", path: "/api/v1/org/tokens", tag: "Organization", summary: "List API tokens",
description: "Members see their own tokens; with tokens.manage, all of the organization.", resp: obj{"tokens": []tokenView{}}},
{method: "POST", path: "/api/v1/org/tokens", tag: "Organization", summary: "Create an API token", sessionOnly: true,
description: "The token is returned only this once. Its permissions are capped by the creator's.",
req: createTokenRequest{}, status: http.StatusCreated, resp: obj{"id": uuid.UUID{}, "token": "", "prefix": "", "permissions": []string{}}},
{method: "DELETE", path: "/api/v1/org/tokens/:id", tag: "Organization", summary: "Revoke an API token", status: http.StatusNoContent},
{method: "GET", path: "/api/v1/org/sso", tag: "Organization", summary: "List single sign-on providers", perm: "org.manage",
resp: obj{"providers": []ssoProviderView{}, "redirect_url": ""}},
{method: "POST", path: "/api/v1/org/sso", tag: "Organization", summary: "Add an OpenID Connect provider", perm: "org.manage", sessionOnly: true,
req: ssoProviderRequest{}, status: http.StatusCreated, resp: ssoProviderView{}},
{method: "PUT", path: "/api/v1/org/sso/:id", tag: "Organization", summary: "Change a provider", perm: "org.manage", sessionOnly: true,
req: ssoProviderRequest{}, resp: ssoProviderView{}},
{method: "DELETE", path: "/api/v1/org/sso/:id", tag: "Organization", summary: "Remove a provider", perm: "org.manage", sessionOnly: true,
status: http.StatusNoContent},
{method: "GET", path: "/api/v1/org/regions", tag: "Organization", summary: "Regions available to the organization", resp: obj{"regions": []regionView{}}},
{method: "POST", path: "/api/v1/org/regions", tag: "Organization", summary: "Create an own region", perm: "org.manage", sessionOnly: true,
req: regionRequest{}, status: http.StatusCreated, resp: regionView{}},
{method: "DELETE", path: "/api/v1/org/regions/:id", tag: "Organization", summary: "Delete an own region", perm: "org.manage", sessionOnly: true,
status: http.StatusNoContent},
{method: "GET", path: "/api/v1/org/agents", tag: "Organization", summary: "List own checkers and status page servers", perm: "org.manage",
resp: obj{"agents": []agentView{}}},
{method: "POST", path: "/api/v1/org/agents", tag: "Organization", summary: "Create an agent token", perm: "org.manage", sessionOnly: true,
description: "The token is returned only this once.", req: agentRequest{}, status: http.StatusCreated, resp: obj{"id": uuid.UUID{}, "token": ""}},
{method: "DELETE", path: "/api/v1/org/agents/:id", tag: "Organization", summary: "Revoke an agent", perm: "org.manage", sessionOnly: true,
status: http.StatusNoContent},
{method: "GET", path: "/api/v1/org/legal", tag: "Organization", summary: "Legal notice and privacy policy of the status pages", perm: "org.manage",
resp: obj{"documents": []legalView{}}},
{method: "PUT", path: "/api/v1/org/legal/:kind", tag: "Organization", summary: "Set the legal notice (imprint) or privacy policy",
description: "Markdown or a link; a link wins. Both empty removes the document.", perm: "org.manage",
req: legalRequest{}, status: http.StatusNoContent},
{method: "GET", path: "/api/v1/org/audit", tag: "Organization", summary: "The organization's audit log", perm: "audit.read",
description: "Newest first; pass `next_before` of the answer as `?before=` for older entries.",
resp: obj{"events": []auditEventView{}}},
{method: "GET", path: "/api/v1/org/export", tag: "Organization", summary: "Export the organization's data", perm: "org.manage", sessionOnly: true,
description: "`?format=pdf` returns a PDF instead of JSON.", resp: orgExport{}},
{method: "POST", path: "/api/v1/org/delete", tag: "Organization", summary: "Delete the organization with all its data", sessionOnly: true,
description: "Owner only, confirmed with the organization's slug and the owner's password.",
req: orgDeletionRequest{}, resp: obj{"status": ""}},
// Platform
{method: "GET", path: "/api/v1/admin/audit", tag: "Platform", summary: "Platform audit log", perm: "platform admin",
resp: obj{"events": []auditEventView{}}},
{method: "GET", path: "/api/v1/admin/legal", tag: "Platform", summary: "Platform legal notice and privacy policy", perm: "platform admin",
resp: obj{"documents": []legalView{}}},
{method: "PUT", path: "/api/v1/admin/legal/:kind", tag: "Platform", summary: "Set a platform legal document", perm: "platform admin",
req: legalRequest{}, status: http.StatusNoContent},
{method: "GET", path: "/api/v1/admin/regions", tag: "Platform", summary: "List platform regions", perm: "platform admin",
resp: obj{"regions": []regionView{}}},
{method: "POST", path: "/api/v1/admin/regions", tag: "Platform", summary: "Create a platform region", perm: "platform admin",
req: regionRequest{}, status: http.StatusCreated, resp: regionView{}},
{method: "DELETE", path: "/api/v1/admin/regions/:id", tag: "Platform", summary: "Delete a platform region", perm: "platform admin",
status: http.StatusNoContent},
{method: "GET", path: "/api/v1/admin/agents", tag: "Platform", summary: "List platform agents", perm: "platform admin",
resp: obj{"agents": []agentView{}}},
{method: "POST", path: "/api/v1/admin/agents", tag: "Platform", summary: "Create a platform agent token", perm: "platform admin",
req: agentRequest{}, status: http.StatusCreated, resp: obj{"id": uuid.UUID{}, "token": ""}},
{method: "DELETE", path: "/api/v1/admin/agents/:id", tag: "Platform", summary: "Revoke a platform agent", perm: "platform admin",
status: http.StatusNoContent},
}
-12
View File
@@ -5,15 +5,3 @@ var LookupTXT = &lookupTXT
// AuditActions exposes the audited routes to tests.
var AuditActions = auditActions
// DocumentedRoutes lists the routes in the OpenAPI table.
func DocumentedRoutes() []string {
out := make([]string, len(endpoints))
for i, e := range endpoints {
out[i] = e.method + " " + e.path
}
return out
}
// OpenAPI builds the OpenAPI document.
func OpenAPI() map[string]any { return buildOpenAPI("https://uptime.example") }
+8 -10
View File
@@ -85,14 +85,6 @@ func (s *Server) createInvitation(c *gin.Context) {
}
}
// invitationView is a pending invitation.
type invitationView struct {
ID uuid.UUID `json:"id"`
Email string `json:"email"`
RoleName string `json:"role_name"`
ExpiresAt time.Time `json:"expires_at"`
}
func (s *Server) listInvitations(c *gin.Context) {
p := current(c)
ctx := c.Request.Context()
@@ -106,9 +98,15 @@ func (s *Server) listInvitations(c *gin.Context) {
internalError(c, err)
return
}
out := make([]invitationView, len(rows))
type view struct {
ID uuid.UUID `json:"id"`
Email string `json:"email"`
RoleName string `json:"role_name"`
ExpiresAt time.Time `json:"expires_at"`
}
out := make([]view, len(rows))
for i, r := range rows {
out[i] = invitationView{ID: r.ID, Email: r.Email, RoleName: r.RoleName, ExpiresAt: r.ExpiresAt}
out[i] = view{ID: r.ID, Email: r.Email, RoleName: r.RoleName, ExpiresAt: r.ExpiresAt}
}
c.JSON(http.StatusOK, gin.H{"invitations": out})
}
-358
View File
@@ -1,358 +0,0 @@
package api
import (
"encoding/json"
"net/http"
"reflect"
"slices"
"strconv"
"strings"
"sync"
"unicode"
"github.com/gin-gonic/gin"
"git.zb-server.de/ZB-Server/uptimesebi/internal/auth"
"git.zb-server.de/ZB-Server/uptimesebi/internal/buildinfo"
"git.zb-server.de/ZB-Server/uptimesebi/internal/check"
"git.zb-server.de/ZB-Server/uptimesebi/internal/web"
)
// The OpenAPI document is generated from the endpoint table in apidocs.go
// and the Go types the handlers bind and return, so field names, types and
// validation limits cannot drift from the code. A test fails for routes
// missing from the table.
// obj describes an inline JSON object, e.g. obj{"monitors": []monitorView{}}.
type obj map[string]any
// endpoint documents one route.
type endpoint struct {
method, path string
tag, summary string
// description adds detail beyond the summary.
description string
// perm is the permission required, in the words of the API.
perm string
// sessionOnly marks routes API tokens may not use.
sessionOnly bool
public bool
// req is the request body; nil for none.
req any
// status and resp describe the success response; resp nil means no
// body. media overrides application/json.
status int
resp any
media string
}
// schemaBuilder turns Go types into JSON Schema, collecting named structs as
// components.
type schemaBuilder struct {
components map[string]any
}
func (b *schemaBuilder) schema(t reflect.Type) map[string]any {
switch t {
case uuidType:
return map[string]any{"type": "string", "format": "uuid"}
case timeType:
return map[string]any{"type": "string", "format": "date-time"}
case rawType:
return map[string]any{"description": "Any JSON value."}
}
switch t.Kind() {
case reflect.Pointer:
s := b.schema(t.Elem())
if typ, ok := s["type"].(string); ok {
s["type"] = []string{typ, "null"}
return s
}
return map[string]any{"oneOf": []any{s, map[string]any{"type": "null"}}}
case reflect.String:
return map[string]any{"type": "string"}
case reflect.Bool:
return map[string]any{"type": "boolean"}
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
return map[string]any{"type": "integer"}
case reflect.Float32, reflect.Float64:
return map[string]any{"type": "number"}
case reflect.Slice, reflect.Array:
if t.Elem().Kind() == reflect.Uint8 {
return map[string]any{"type": "string", "contentEncoding": "base64"}
}
return map[string]any{"type": "array", "items": b.schema(t.Elem())}
case reflect.Map:
return map[string]any{"type": "object", "additionalProperties": b.schema(t.Elem())}
case reflect.Interface:
return map[string]any{}
case reflect.Struct:
name := componentName(t)
if name == "" {
return b.object(t)
}
if _, done := b.components[name]; !done {
b.components[name] = nil // breaks recursion
b.components[name] = b.object(t)
}
return map[string]any{"$ref": "#/components/schemas/" + name}
}
return map[string]any{}
}
// object builds the schema of a struct from its json and binding tags.
func (b *schemaBuilder) object(t reflect.Type) map[string]any {
props := map[string]any{}
var required []string
var walk func(t reflect.Type)
walk = func(t reflect.Type) {
for i := range t.NumField() {
f := t.Field(i)
if !f.IsExported() {
continue
}
tag := f.Tag.Get("json")
name, opts, _ := strings.Cut(tag, ",")
if name == "-" {
continue
}
if f.Anonymous && name == "" {
walk(f.Type)
continue
}
if name == "" {
name = f.Name
}
s := b.schema(f.Type)
binding := strings.Split(f.Tag.Get("binding"), ",")
applyBinding(s, f.Type, binding)
props[name] = s
if slices.Contains(binding, "required") && !strings.Contains(opts, "omitempty") {
required = append(required, name)
}
}
}
walk(t)
s := map[string]any{"type": "object", "properties": props}
if len(required) > 0 {
slices.Sort(required)
s["required"] = required
}
return s
}
// applyBinding carries validator limits over to the schema.
func applyBinding(s map[string]any, t reflect.Type, rules []string) {
for t.Kind() == reflect.Pointer {
t = t.Elem()
}
for _, r := range rules {
key, val, ok := strings.Cut(r, "=")
if r == "email" {
s["format"] = "email"
}
if !ok {
continue
}
n, err := strconv.Atoi(val)
if err != nil {
continue
}
var bound string
switch t.Kind() {
case reflect.String:
bound = map[string]string{"max": "maxLength", "min": "minLength"}[key]
case reflect.Slice, reflect.Map:
bound = map[string]string{"max": "maxItems", "min": "minItems"}[key]
default:
bound = map[string]string{"max": "maximum", "min": "minimum"}[key]
}
if bound != "" {
s[bound] = n
}
}
}
// componentName derives a schema name from a Go type: monitorView becomes
// Monitor, monitorRequest MonitorRequest. Types of other packages keep their
// package as prefix to stay unique.
func componentName(t reflect.Type) string {
name := t.Name()
if name == "" {
return ""
}
name = strings.TrimSuffix(name, "View")
r := []rune(name)
r[0] = unicode.ToUpper(r[0])
name = string(r)
if pkg := t.PkgPath(); !strings.HasSuffix(pkg, "/internal/api") {
p := []rune(pkg[strings.LastIndex(pkg, "/")+1:])
p[0] = unicode.ToUpper(p[0])
name = string(p) + name
}
return name
}
// bodySchema describes a request or response value.
func (b *schemaBuilder) bodySchema(v any) map[string]any {
if o, ok := v.(obj); ok {
props := map[string]any{}
keys := make([]string, 0, len(o))
for k, val := range o {
props[k] = b.schema(reflect.TypeOf(val))
keys = append(keys, k)
}
slices.Sort(keys)
return map[string]any{"type": "object", "properties": props, "required": keys}
}
return b.schema(reflect.TypeOf(v))
}
// openAPIPath turns gin's ":id" parameters into "{id}".
func openAPIPath(p string) (string, []string) {
var params []string
parts := strings.Split(p, "/")
for i, part := range parts {
if strings.HasPrefix(part, ":") {
params = append(params, part[1:])
parts[i] = "{" + part[1:] + "}"
}
}
return strings.Join(parts, "/"), params
}
// buildOpenAPI assembles the document for publicURL.
func buildOpenAPI(publicURL string) map[string]any {
b := &schemaBuilder{components: map[string]any{}}
errorRef := map[string]any{"$ref": "#/components/schemas/Error"}
b.components["Error"] = map[string]any{
"type": "object",
"required": []string{"error", "message"},
"properties": map[string]any{
"error": map[string]any{"type": "string", "description": "Stable code for programs, e.g. invalid_target."},
"message": map[string]any{"type": "string", "description": "Explanation in the request's language."},
"request_id": map[string]any{"type": "string", "description": "Quote it when reporting a problem."},
},
}
// Monitor settings travel as untyped config; their shapes per type.
for _, c := range []any{check.HTTPConfig{}, check.JSONConfig{}, check.PrometheusConfig{}, check.DNSConfig{}, check.TLSConfig{}, check.HeartbeatConfig{}} {
b.schema(reflect.TypeOf(c))
}
paths := map[string]map[string]any{}
tags := []string{}
for _, e := range endpoints {
p, params := openAPIPath(e.path)
op := map[string]any{"summary": e.summary, "tags": []string{e.tag}, "operationId": operationID(e)}
desc := e.description
if e.perm != "" {
desc = strings.TrimSpace(desc + "\n\nRequires the permission `" + e.perm + "`.")
}
if e.sessionOnly {
desc = strings.TrimSpace(desc + "\n\nOnly in a browser session, not with an API token.")
}
if desc != "" {
op["description"] = desc
}
if e.public {
op["security"] = []any{}
} else if e.sessionOnly {
op["security"] = []any{map[string]any{"session": []string{}}}
}
var ps []any
for _, name := range params {
ps = append(ps, map[string]any{"name": name, "in": "path", "required": true, "schema": map[string]any{"type": "string"}})
}
if ps != nil {
op["parameters"] = ps
}
if e.req != nil {
op["requestBody"] = map[string]any{"required": true, "content": map[string]any{
"application/json": map[string]any{"schema": b.bodySchema(e.req)},
}}
}
status := e.status
if status == 0 {
status = http.StatusOK
}
success := map[string]any{"description": http.StatusText(status)}
switch {
case e.media != "":
success["content"] = map[string]any{e.media: map[string]any{}}
case e.resp != nil:
success["content"] = map[string]any{"application/json": map[string]any{"schema": b.bodySchema(e.resp)}}
}
op["responses"] = map[string]any{
strconv.Itoa(status): success,
"default": map[string]any{"description": "Error", "content": map[string]any{"application/json": map[string]any{"schema": errorRef}}},
}
if paths[p] == nil {
paths[p] = map[string]any{}
}
paths[p][strings.ToLower(e.method)] = op
if !slices.Contains(tags, e.tag) {
tags = append(tags, e.tag)
}
}
tagObjs := make([]any, len(tags))
for i, t := range tags {
tagObjs[i] = map[string]any{"name": t}
}
return map[string]any{
"openapi": "3.1.0",
"info": map[string]any{
"title": "uptimesebi API",
"version": buildinfo.Version,
"description": "Manage monitors, status pages, alerting and members of an organization.\n\n" +
"Authenticate with an API token as `Authorization: Bearer ust_…` (create one under Settings → API tokens; " +
"it never exceeds its owner's permissions), or use the browser session, which additionally needs the " +
"`" + auth.CSRFHeader + "` header on changes. Errors share one format with a stable `error` code.",
"license": map[string]any{"name": "AGPL-3.0-only", "identifier": "AGPL-3.0-only"},
},
"servers": []any{map[string]any{"url": strings.TrimSuffix(publicURL, "/")}},
"security": []any{
map[string]any{"token": []string{}},
map[string]any{"session": []string{}},
},
"tags": tagObjs,
"paths": paths,
"components": map[string]any{
"schemas": b.components,
"securitySchemes": map[string]any{
"token": map[string]any{"type": "http", "scheme": "bearer", "description": "API token, prefix ust_."},
"session": map[string]any{"type": "apiKey", "in": "cookie", "name": auth.CookieName},
},
},
}
}
func operationID(e endpoint) string {
var b strings.Builder
b.WriteString(strings.ToLower(e.method))
for _, part := range strings.Split(strings.TrimPrefix(e.path, "/api/v1/"), "/") {
part = strings.TrimPrefix(part, ":")
for _, w := range strings.FieldsFunc(part, func(r rune) bool { return r == '-' || r == '_' }) {
r := []rune(w)
r[0] = unicode.ToUpper(r[0])
b.WriteString(string(r))
}
}
return b.String()
}
var (
openAPIOnce sync.Once
openAPIDoc []byte
)
func (s *Server) openAPIJSON(c *gin.Context) {
openAPIOnce.Do(func() {
openAPIDoc, _ = json.MarshalIndent(buildOpenAPI(s.cfg.PublicURL), "", " ")
})
c.Header("Cache-Control", "public, max-age=300")
c.Data(http.StatusOK, "application/json", openAPIDoc)
}
func (s *Server) apiDocsPage(c *gin.Context) {
web.Render(c, http.StatusOK, web.APIDocsPage(s.pageFor(c, "apidocs.title")))
}
-118
View File
@@ -1,118 +0,0 @@
package api_test
import (
"encoding/json"
"io"
"log/slog"
"net/http"
"slices"
"strings"
"testing"
"github.com/gin-gonic/gin"
"git.zb-server.de/ZB-Server/uptimesebi/internal/api"
"git.zb-server.de/ZB-Server/uptimesebi/internal/config"
)
func TestEveryRouteIsDocumented(t *testing.T) {
r := gin.New()
api.New(config.API{}, api.Deps{Log: slog.New(slog.DiscardHandler)}).Mount(r)
documented := api.DocumentedRoutes()
var served []string
for _, rt := range r.Routes() {
if strings.HasPrefix(rt.Path, "/api/v1/") {
served = append(served, rt.Method+" "+rt.Path)
}
}
for _, s := range served {
if !slices.Contains(documented, s) {
t.Errorf("%s is not documented in apidocs.go", s)
}
}
for _, d := range documented {
if !slices.Contains(served, d) {
t.Errorf("%s is documented but not served", d)
}
}
}
func TestOpenAPIDocument(t *testing.T) {
doc := api.OpenAPI()
raw, err := json.Marshal(doc)
if err != nil {
t.Fatal(err)
}
var generic map[string]any
_ = json.Unmarshal(raw, &generic)
schemas := generic["components"].(map[string]any)["schemas"].(map[string]any)
// Every reference resolves and every required field exists.
var walk func(v any)
walk = func(v any) {
switch x := v.(type) {
case map[string]any:
if ref, ok := x["$ref"].(string); ok {
if _, ok := schemas[strings.TrimPrefix(ref, "#/components/schemas/")]; !ok {
t.Errorf("unresolved %s", ref)
}
}
if req, ok := x["required"].([]any); ok {
if props, ok := x["properties"].(map[string]any); ok {
for _, r := range req {
if _, ok := props[r.(string)]; !ok {
t.Errorf("required %v is not a property", r)
}
}
}
}
for _, child := range x {
walk(child)
}
case []any:
for _, child := range x {
walk(child)
}
}
}
walk(generic)
// Limits come from the binding tags the API validates with.
mr := schemas["MonitorRequest"].(map[string]any)
name := mr["properties"].(map[string]any)["name"].(map[string]any)
if name["maxLength"] != float64(200) || !slices.Contains(mr["required"].([]any), any("name")) {
t.Errorf("MonitorRequest.name = %v, required %v", name, mr["required"])
}
if _, ok := schemas["Monitor"].(map[string]any)["properties"].(map[string]any)["ping_url"]; !ok {
t.Error("Monitor lacks ping_url")
}
for _, s := range []string{"CheckHTTPConfig", "CheckJSONConfig", "CheckPrometheusConfig", "Error"} {
if _, ok := schemas[s]; !ok {
t.Errorf("schema %s missing", s)
}
}
paths := generic["paths"].(map[string]any)
put := paths["/api/v1/org/monitors/{id}"].(map[string]any)["put"].(map[string]any)
if params := put["parameters"].([]any); len(params) != 1 || params[0].(map[string]any)["name"] != "id" {
t.Errorf("path parameters = %v", put["parameters"])
}
if login := paths["/api/v1/auth/login"].(map[string]any)["post"].(map[string]any); len(login["security"].([]any)) != 0 {
t.Error("login is not marked public")
}
}
func TestAPIDocsServed(t *testing.T) {
e := newEnv(t)
resp, err := e.srv.Client().Get(e.srv.URL + "/api/openapi.json")
if err != nil {
t.Fatal(err)
}
body, _ := io.ReadAll(resp.Body)
_ = resp.Body.Close()
if resp.StatusCode != http.StatusOK || !strings.Contains(string(body), `"openapi": "3.1.0"`) || !strings.Contains(string(body), e.srv.URL) {
t.Errorf("openapi.json = %d %.200s", resp.StatusCode, body)
}
if st, _, page := e.browser(t).page("/api/docs"); st != http.StatusOK || !strings.Contains(page, "swagger-ui-bundle.js") {
t.Errorf("/api/docs = %d", st)
}
}
-3
View File
@@ -88,9 +88,6 @@ func (s *Server) Mount(r gin.IRouter) {
g := r.Group("/", s.sessions.Load(), s.localize(), auth.CSRF(), s.audit())
r.GET("/api/openapi.json", s.openAPIJSON)
g.GET("/api/docs", s.apiDocsPage)
v1 := g.Group("/api/v1")
v1.POST("/locale", s.setLocale)
v1.POST("/markdown/preview", auth.Require(), s.previewMarkdown)
-3
View File
@@ -10,8 +10,6 @@
"agents.region": "Region",
"agents.revoke_confirm": "Diesen Agent widerrufen? Seine Instanzen hören sofort auf zu arbeiten.",
"agents.token_now": "Kopiere den Token jetzt und setze ihn als UPTIME_AGENT_TOKEN. Er wird nicht erneut angezeigt. Beliebig viele Instanzen können ihn teilen.",
"apidocs.hint": "„Try it out“ nutzt deine aktuelle Sitzung.",
"apidocs.title": "API-Dokumentation",
"app.network_error": "Verbindung fehlgeschlagen.",
"audit.action.account.delete": "Konto gelöscht",
"audit.action.account.export": "Persönliche Daten exportiert",
@@ -688,7 +686,6 @@
"security.totp.inactive": "nicht eingerichtet",
"security.totp.qr_alt": "QR-Code für die Authenticator-App",
"security.totp.start": "Einrichten",
"settings.apidocs": "Alle Endpunkte mit ihren Feldern, im OpenAPI-Format.",
"settings.audit": "Wer wann was geändert hat.",
"settings.channels": "Webhooks und E-Mail für Incidents",
"settings.groups": "Monitore in verschachtelten Gruppen ordnen",
-3
View File
@@ -10,8 +10,6 @@
"agents.region": "Region",
"agents.revoke_confirm": "Revoke this agent? Its instances stop working immediately.",
"agents.token_now": "Copy the token now and set it as UPTIME_AGENT_TOKEN. It will not be shown again. Any number of instances may share it.",
"apidocs.hint": "\"Try it out\" uses your current session.",
"apidocs.title": "API documentation",
"app.network_error": "Connection failed.",
"audit.action.account.delete": "Account deleted",
"audit.action.account.export": "Personal data exported",
@@ -688,7 +686,6 @@
"security.totp.inactive": "not set up",
"security.totp.qr_alt": "QR code for your authenticator app",
"security.totp.start": "Set up",
"settings.apidocs": "Every endpoint with its fields, in OpenAPI format.",
"settings.audit": "Who changed what and when.",
"settings.channels": "Webhooks and email for incidents",
"settings.groups": "Organize monitors in nested groups",
-32
View File
@@ -1,32 +0,0 @@
package web
import "git.zb-server.de/ZB-Server/uptimesebi/internal/i18n"
// APIDocsPage shows the OpenAPI document with Swagger UI, served from our
// own assets so it works without internet access.
templ APIDocsPage(p Page) {
<!DOCTYPE html>
<html lang={ i18n.Lang(ctx) }>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
if p.CSRF != "" {
<meta name="csrf-token" content={ p.CSRF }/>
}
<title>{ i18n.T(ctx, p.TitleID) } · uptimesebi</title>
<link rel="stylesheet" href="/static/dist/app.css"/>
<link rel="stylesheet" href="/static/dist/swagger-ui.css"/>
</head>
<body class="min-h-screen">
<header class="border-b border-rule">
<div class="mx-auto flex max-w-5xl items-baseline justify-between px-6 py-3">
<a href="/" class="font-mono text-sm">uptimesebi</a>
<span class="text-sm text-muted">{ i18n.T(ctx, "apidocs.hint") }</span>
</div>
</header>
<div id="swagger" class="api-docs mx-auto max-w-5xl"></div>
<script src="/static/dist/swagger-ui-bundle.js"></script>
<script src="/static/dist/apidocs.js"></script>
</body>
</html>
}
-103
View File
@@ -1,103 +0,0 @@
// Code generated by templ - DO NOT EDIT.
// templ: version: v0.3.1118
package web
//lint:file-ignore SA4006 This context is only used if a nested component is present.
import "github.com/a-h/templ"
import templruntime "github.com/a-h/templ/runtime"
import "git.zb-server.de/ZB-Server/uptimesebi/internal/i18n"
// APIDocsPage shows the OpenAPI document with Swagger UI, served from our
// own assets so it works without internet access.
func APIDocsPage(p Page) templ.Component {
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
return templ_7745c5c3_CtxErr
}
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
ctx = templ.ClearChildren(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<!doctype html><html lang=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var2 string
templ_7745c5c3_Var2, templ_7745c5c3_Err = templruntime.NewAttributeExpression(i18n.Lang(ctx)).Resolve(ctx)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/apidocs.templ`, Line: 9, Col: 28}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var2)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if p.CSRF != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "<meta name=\"csrf-token\" content=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var3 string
templ_7745c5c3_Var3, templ_7745c5c3_Err = templruntime.NewAttributeExpression(p.CSRF).Resolve(ctx)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/apidocs.templ`, Line: 14, Col: 44}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var3)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "<title>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var4 string
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, p.TitleID))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/apidocs.templ`, Line: 16, Col: 34}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, " · uptimesebi</title><link rel=\"stylesheet\" href=\"/static/dist/app.css\"><link rel=\"stylesheet\" href=\"/static/dist/swagger-ui.css\"></head><body class=\"min-h-screen\"><header class=\"border-b border-rule\"><div class=\"mx-auto flex max-w-5xl items-baseline justify-between px-6 py-3\"><a href=\"/\" class=\"font-mono text-sm\">uptimesebi</a> <span class=\"text-sm text-muted\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var5 string
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "apidocs.hint"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/apidocs.templ`, Line: 24, Col: 67}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "</span></div></header><div id=\"swagger\" class=\"api-docs mx-auto max-w-5xl\"></div><script src=\"/static/dist/swagger-ui-bundle.js\"></script><script src=\"/static/dist/apidocs.js\"></script></body></html>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
var _ = templruntime.GeneratedTemplate
-17
View File
@@ -1,17 +0,0 @@
// Swagger UI for /api/openapi.json. "Try it out" uses the browser session,
// which needs the CSRF token on changes.
(() => {
const csrf = document.querySelector('meta[name="csrf-token"]')?.content;
window.SwaggerUIBundle({
url: "/api/openapi.json",
dom_id: "#swagger",
deepLinking: true,
tryItOutEnabled: false,
withCredentials: true,
defaultModelsExpandDepth: 0,
requestInterceptor: (req) => {
if (csrf && req.method !== "GET") req.headers["X-CSRF-Token"] = csrf;
return req;
},
});
})();
-15
View File
@@ -93,18 +93,3 @@
.legal-text td { @apply border border-rule px-2 py-1 text-left; }
.legal-text code { @apply font-mono text-xs; }
}
/* Swagger UI: keep its layout, use the console's fonts and colors. */
.api-docs .swagger-ui,
.api-docs .swagger-ui .info .title,
.api-docs .swagger-ui .opblock-tag {
font-family: var(--font-sans);
}
.api-docs .swagger-ui .topbar {
display: none;
}
@media (prefers-color-scheme: dark) {
.api-docs .swagger-ui {
filter: invert(0.92) hue-rotate(180deg);
}
}
-1
View File
@@ -197,7 +197,6 @@ templ SettingsIndex(p Page, me Me) {
}
if len(me.Orgs) > 0 {
@settingsLink("/settings/tokens", "console.nav.tokens", "settings.tokens")
@settingsLink("/api/docs", "apidocs.title", "settings.apidocs")
}
if me.Can["org.manage"] {
@settingsLink("/settings/regions", "console.nav.regions", "settings.regions")
-4
View File
@@ -984,10 +984,6 @@ func SettingsIndex(p Page, me Me) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = settingsLink("/api/docs", "apidocs.title", "settings.apidocs").Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if me.Can["org.manage"] {
templ_7745c5c3_Err = settingsLink("/settings/regions", "console.nav.regions", "settings.regions").Render(ctx, templ_7745c5c3_Buffer)
-1
View File
@@ -301,7 +301,6 @@ templ TokensPage(p Page, me Me, v TokensView) {
} else {
@settingsHeading("tokens.title", "tokens.intro")
}
<p class="-mt-4 mb-8 text-sm"><a href="/api/docs" class="underline underline-offset-2">{ i18n.T(ctx, "apidocs.title") }</a></p>
if v.MaxDays > 0 {
<p class="-mt-4 mb-8 text-sm">{ i18n.T(ctx, "tokens.policy", "Count", v.MaxDays) }</p>
}
+273 -286
View File
@@ -1194,91 +1194,91 @@ func TokensPage(p Page, me Me, v TokensView) templ.Component {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 98, " <p class=\"-mt-4 mb-8 text-sm\"><a href=\"/api/docs\" class=\"underline underline-offset-2\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var52 string
templ_7745c5c3_Var52, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "apidocs.title"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 304, Col: 119}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var52))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 99, "</a></p>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 98, " ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if v.MaxDays > 0 {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 100, "<p class=\"-mt-4 mb-8 text-sm\">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 99, "<p class=\"-mt-4 mb-8 text-sm\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var52 string
templ_7745c5c3_Var52, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "tokens.policy", "Count", v.MaxDays))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 305, Col: 83}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var52))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 100, "</p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 101, " ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if len(v.Tokens) > 0 {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 102, "<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, "tokens.policy", "Count", v.MaxDays))
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: 306, Col: 83}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 311, Col: 71}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var53))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 101, "</p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 102, " ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if len(v.Tokens) > 0 {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 103, "<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_Var54 string
templ_7745c5c3_Var54, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "sso.field.name"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 312, Col: 71}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var54))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 104, "</th>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 103, "</th>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if v.ShowOwner {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 105, "<th class=\"py-2 pr-4 font-medium\">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 104, "<th class=\"py-2 pr-4 font-medium\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var55 string
templ_7745c5c3_Var55, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "tokens.owner"))
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: 314, Col: 70}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 313, Col: 70}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var55))
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var54))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 106, "</th>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 105, "</th>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 107, "<th class=\"py-2 pr-4 font-medium\">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 106, "<th class=\"py-2 pr-4 font-medium\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var55 string
templ_7745c5c3_Var55, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "tokens.permissions"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 315, Col: 75}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var55))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 107, "</th><th class=\"py-2 pr-4 font-medium\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var56 string
templ_7745c5c3_Var56, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "tokens.permissions"))
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: 316, Col: 75}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 316, Col: 71}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var56))
if templ_7745c5c3_Err != nil {
@@ -1289,7 +1289,7 @@ func TokensPage(p Page, me Me, v TokensView) templ.Component {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var57 string
templ_7745c5c3_Var57, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "tokens.created"))
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: 317, Col: 71}
}
@@ -1302,110 +1302,110 @@ func TokensPage(p Page, me Me, v TokensView) templ.Component {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var58 string
templ_7745c5c3_Var58, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "tokens.expires"))
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: 318, Col: 71}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 318, Col: 73}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var58))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 110, "</th><th class=\"py-2 pr-4 font-medium\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var59 string
templ_7745c5c3_Var59, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "tokens.last_used"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 319, Col: 73}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var59))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 111, "</th><th class=\"py-2\"></th></tr></thead> <tbody class=\"divide-y divide-rule\">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 110, "</th><th class=\"py-2\"></th></tr></thead> <tbody class=\"divide-y divide-rule\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
for _, t := range v.Tokens {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 112, "<tr class=\"align-top\"><td class=\"py-2.5 pr-4\">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 111, "<tr class=\"align-top\"><td class=\"py-2.5 pr-4\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var59 string
templ_7745c5c3_Var59, templ_7745c5c3_Err = templ.JoinStringErrs(t.Name)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 325, Col: 39}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var59))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 112, " <span class=\"block font-mono text-xs text-muted\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var60 string
templ_7745c5c3_Var60, templ_7745c5c3_Err = templ.JoinStringErrs(t.Name)
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: 326, Col: 39}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 325, Col: 101}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var60))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 113, " <span class=\"block font-mono text-xs text-muted\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var61 string
templ_7745c5c3_Var61, templ_7745c5c3_Err = templ.JoinStringErrs(t.Prefix)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 326, Col: 101}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var61))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 114, "…</span></td>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 113, "…</span></td>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if v.ShowOwner {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 115, "<td class=\"py-2.5 pr-4\">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 114, "<td class=\"py-2.5 pr-4\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var61 string
templ_7745c5c3_Var61, templ_7745c5c3_Err = templ.JoinStringErrs(t.UserEmail)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 327, Col: 45}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var61))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 115, "</td>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 116, "<td class=\"py-2.5 pr-4\"><ul class=\"flex max-w-xs flex-wrap gap-1 text-xs\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
for _, perm := range t.Permissions {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 117, "<li class=\"border border-rule px-1 py-px\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var62 string
templ_7745c5c3_Var62, templ_7745c5c3_Err = templ.JoinStringErrs(t.UserEmail)
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: 328, Col: 45}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 332, Col: 79}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var62))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 116, "</td>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 118, "</li>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 117, "<td class=\"py-2.5 pr-4\"><ul class=\"flex max-w-xs flex-wrap gap-1 text-xs\">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 119, "</ul></td><td class=\"py-2.5 pr-4 whitespace-nowrap font-mono text-xs\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
for _, perm := range t.Permissions {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 118, "<li class=\"border border-rule px-1 py-px\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var63 string
templ_7745c5c3_Var63, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "perm."+perm))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 333, Col: 79}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var63))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 119, "</li>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var63 string
templ_7745c5c3_Var63, templ_7745c5c3_Err = templ.JoinStringErrs(t.CreatedAt)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 336, Col: 80}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 120, "</ul></td><td class=\"py-2.5 pr-4 whitespace-nowrap font-mono text-xs\">")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var63))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 120, "</td><td class=\"py-2.5 pr-4 whitespace-nowrap font-mono text-xs\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var64 string
templ_7745c5c3_Var64, templ_7745c5c3_Err = templ.JoinStringErrs(t.CreatedAt)
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: 337, Col: 80}
}
@@ -1418,77 +1418,64 @@ func TokensPage(p Page, me Me, v TokensView) templ.Component {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var65 string
templ_7745c5c3_Var65, templ_7745c5c3_Err = templ.JoinStringErrs(t.ExpiresAt)
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: 338, Col: 80}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 338, Col: 81}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var65))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 122, "</td><td class=\"py-2.5 pr-4 whitespace-nowrap font-mono text-xs\">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 122, "</td><td class=\"py-2.5 text-right\"><button type=\"button\" data-delete=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var66 string
templ_7745c5c3_Var66, templ_7745c5c3_Err = templ.JoinStringErrs(t.LastUsedAt)
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: 339, Col: 81}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 342, Col: 44}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var66))
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var66)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 123, "</td><td class=\"py-2.5 text-right\"><button type=\"button\" data-delete=\"")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 123, "\" data-confirm=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var67 string
templ_7745c5c3_Var67, templ_7745c5c3_Err = templruntime.NewAttributeExpression("/org/tokens/" + t.ID).Resolve(ctx)
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: 343, Col: 44}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 343, Col: 60}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var67)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 124, "\" data-confirm=\"")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 124, "\" class=\"text-muted hover:text-down\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var68 string
templ_7745c5c3_Var68, templ_7745c5c3_Err = templruntime.NewAttributeExpression(i18n.T(ctx, "tokens.revoke_confirm")).Resolve(ctx)
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: 344, Col: 60}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 345, Col: 40}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var68)
_, 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, 125, "\" class=\"text-muted hover:text-down\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var69 string
templ_7745c5c3_Var69, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "members.revoke"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 346, Col: 40}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var69))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 126, "</button></td></tr>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 125, "</button></td></tr>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 127, "</tbody></table>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 126, "</tbody></table>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 128, " <section class=\"max-w-xl\">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 127, " <section class=\"max-w-xl\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -1496,7 +1483,7 @@ func TokensPage(p Page, me Me, v TokensView) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 129, "<form data-api=\"/org/tokens\" data-show-link>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 128, "<form data-api=\"/org/tokens\" data-show-link>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -1512,86 +1499,86 @@ func TokensPage(p Page, me Me, v TokensView) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 130, "<label class=\"mb-4 block\"><span class=\"mb-1 block text-xs font-medium uppercase tracking-wider text-muted\">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 129, "<label class=\"mb-4 block\"><span class=\"mb-1 block text-xs font-medium uppercase tracking-wider text-muted\">")
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, "tokens.expires"))
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: 360, Col: 117}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 359, Col: 117}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var70))
_, 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, 131, "</span> <select name=\"expires_in_days\" data-number class=\"w-full border border-rule bg-transparent px-2 py-1.5 text-sm\">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 130, "</span> <select name=\"expires_in_days\" data-number class=\"w-full border border-rule bg-transparent px-2 py-1.5 text-sm\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
for i, d := range v.ExpiryDays {
if d == 0 {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 132, "<option value=\"0\">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 131, "<option value=\"0\">")
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, "tokens.never"))
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: 364, Col: 55}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 363, Col: 55}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var71))
_, 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, 133, "</option>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 132, "</option>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
} else {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 134, "<option value=\"")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 133, "<option value=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var72 string
templ_7745c5c3_Var72, templ_7745c5c3_Err = templruntime.NewAttributeExpression(strconv.Itoa(d)).Resolve(ctx)
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: 366, Col: 39}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 365, Col: 39}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var72)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var71)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 135, "\"")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 134, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if i == 0 {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 136, " selected")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 135, " selected")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 137, ">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 136, ">")
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, "tokens.days", "Count", d))
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: 366, Col: 103}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 365, Col: 103}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var73))
_, 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, 138, "</option>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 137, "</option>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 139, "</select></label>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 138, "</select></label>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -1599,20 +1586,20 @@ func TokensPage(p Page, me Me, v TokensView) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 140, "<div data-link-output hidden class=\"mt-6 border border-ink p-4\"><p class=\"mb-2 text-sm\">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 139, "<div data-link-output hidden class=\"mt-6 border border-ink p-4\"><p class=\"mb-2 text-sm\">")
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, "tokens.copy_now"))
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: 373, Col: 61}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 372, Col: 61}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var74))
_, 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, 141, "</p><input data-link readonly class=\"w-full border border-rule bg-transparent px-2 py-1.5 font-mono text-xs\"></div></form></section>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 140, "</p><input data-link readonly class=\"w-full border border-rule bg-transparent px-2 py-1.5 font-mono text-xs\"></div></form></section>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -1651,7 +1638,7 @@ func OrgSettingsPage(p Page, me Me, v OrgSettings) templ.Component {
}
ctx = templ.InitializeContext(ctx)
ctx = templ.ClearChildren(ctx)
templ_7745c5c3_Var76 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_Var75 := 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 {
@@ -1667,7 +1654,7 @@ func OrgSettingsPage(p Page, me Me, v OrgSettings) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 142, "<section class=\"max-w-xl\">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 141, "<section class=\"max-w-xl\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -1675,7 +1662,7 @@ func OrgSettingsPage(p Page, me Me, v OrgSettings) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 143, "<form data-api=\"/org/policy\" data-method=\"put\" data-next=\"/settings/org\">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 142, "<form data-api=\"/org/policy\" data-method=\"put\" data-next=\"/settings/org\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -1687,20 +1674,20 @@ func OrgSettingsPage(p Page, me Me, v OrgSettings) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 144, "<p class=\"mb-4 ml-6 text-xs text-muted\">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 143, "<p class=\"mb-4 ml-6 text-xs text-muted\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var77 string
templ_7745c5c3_Var77, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "org.require_totp_hint"))
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: 397, Col: 82}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 396, Col: 82}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var77))
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var76))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 145, "</p>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 144, "</p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -1708,72 +1695,72 @@ func OrgSettingsPage(p Page, me Me, v OrgSettings) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 146, "<p class=\"mb-6 ml-6 text-xs text-muted\">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 145, "<p class=\"mb-6 ml-6 text-xs text-muted\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var77 string
templ_7745c5c3_Var77, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "org.require_sso_hint"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 398, Col: 81}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var77))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 146, "</p><label class=\"mb-1 block\"><span class=\"mb-1 block text-xs font-medium uppercase tracking-wider text-muted\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var78 string
templ_7745c5c3_Var78, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "org.require_sso_hint"))
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: 399, Col: 81}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 400, Col: 121}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var78))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 147, "</p><label class=\"mb-1 block\"><span class=\"mb-1 block text-xs font-medium uppercase tracking-wider text-muted\">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 147, "</span> <input type=\"number\" name=\"api_token_max_days\" data-number min=\"0\" max=\"3650\" value=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var79 string
templ_7745c5c3_Var79, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "org.token_max_days"))
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: 401, Col: 121}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 407, Col: 42}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var79))
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var79)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 148, "</span> <input type=\"number\" name=\"api_token_max_days\" data-number min=\"0\" max=\"3650\" value=\"")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 148, "\" placeholder=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var80 string
templ_7745c5c3_Var80, templ_7745c5c3_Err = templruntime.NewAttributeExpression(maxDaysValue(v.TokenMaxDays)).Resolve(ctx)
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: 408, Col: 42}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 408, Col: 58}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var80)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 149, "\" placeholder=\"")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 149, "\" class=\"w-40 border border-rule bg-transparent px-2.5 py-1.5 font-mono text-sm outline-none focus:border-ink\"></label><p class=\"mb-6 text-xs text-muted\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var81 string
templ_7745c5c3_Var81, templ_7745c5c3_Err = templruntime.NewAttributeExpression(i18n.T(ctx, "org.token_max_days_none")).Resolve(ctx)
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: 409, Col: 58}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 412, Col: 79}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var81)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var81))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 150, "\" class=\"w-40 border border-rule bg-transparent px-2.5 py-1.5 font-mono text-sm outline-none focus:border-ink\"></label><p class=\"mb-6 text-xs text-muted\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var82 string
templ_7745c5c3_Var82, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "org.token_max_days_hint"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 413, Col: 79}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var82))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 151, "</p>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 150, "</p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -1781,7 +1768,7 @@ func OrgSettingsPage(p Page, me Me, v OrgSettings) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 152, "</form></section>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 151, "</form></section>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -1791,7 +1778,7 @@ func OrgSettingsPage(p Page, me Me, v OrgSettings) templ.Component {
}
return nil
})
templ_7745c5c3_Err = consoleShell(p, me).Render(templ.WithChildren(ctx, templ_7745c5c3_Var76), templ_7745c5c3_Buffer)
templ_7745c5c3_Err = consoleShell(p, me).Render(templ.WithChildren(ctx, templ_7745c5c3_Var75), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -1827,7 +1814,7 @@ func InvitationPage(p Page, v Invitation) templ.Component {
}
ctx = templ.InitializeContext(ctx)
ctx = templ.ClearChildren(ctx)
templ_7745c5c3_Var84 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_Var83 := 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 {
@@ -1840,70 +1827,70 @@ func InvitationPage(p Page, v Invitation) templ.Component {
}
ctx = templ.InitializeContext(ctx)
if !v.Valid {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 153, "<p class=\"text-sm\">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 152, "<p class=\"text-sm\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var84 string
templ_7745c5c3_Var84, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "error.invitation_invalid"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 434, Col: 63}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var84))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 153, "</p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
} else {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 154, "<p class=\"mb-6 text-sm\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var85 string
templ_7745c5c3_Var85, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "error.invitation_invalid"))
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: 435, Col: 63}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 436, Col: 96}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var85))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 154, "</p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
} else {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 155, "<p class=\"mb-6 text-sm\">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 155, "</p><p class=\"mb-6 font-mono text-sm\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var86 string
templ_7745c5c3_Var86, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "invite.summary", "Org", v.OrgName, "Role", v.RoleName))
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: 437, Col: 96}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 437, Col: 46}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var86))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 156, "</p><p class=\"mb-6 font-mono text-sm\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var87 string
templ_7745c5c3_Var87, templ_7745c5c3_Err = templ.JoinStringErrs(v.Email)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 438, Col: 46}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var87))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 157, "</p>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 156, "</p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
switch {
case v.SignedInAs == v.Email:
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 158, "<form data-api=\"")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 157, "<form data-api=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var88 string
templ_7745c5c3_Var88, templ_7745c5c3_Err = templruntime.NewAttributeExpression("/invitations/" + v.Token + "/accept").Resolve(ctx)
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: 441, Col: 59}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 440, Col: 59}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var88)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var87)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 159, "\" data-next=\"/\">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 158, "\" data-next=\"/\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -1915,87 +1902,87 @@ func InvitationPage(p Page, v Invitation) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 160, "</form>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 159, "</form>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
case v.SignedInAs != "":
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 161, "<p class=\"text-sm text-down\">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 160, "<p class=\"text-sm text-down\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var88 string
templ_7745c5c3_Var88, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "error.invitation_email_mismatch"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 445, Col: 82}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var88))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 161, "</p><button data-logout class=\"mt-4 text-sm underline underline-offset-2\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var89 string
templ_7745c5c3_Var89, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "error.invitation_email_mismatch"))
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: 446, Col: 82}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 446, Col: 110}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var89))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 162, "</p><button data-logout class=\"mt-4 text-sm underline underline-offset-2\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var90 string
templ_7745c5c3_Var90, 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: 447, Col: 110}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var90))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 163, "</button>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 162, "</button>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
case v.AccountExists:
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 164, "<a href=\"")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 163, "<a href=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
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: 448, Col: 62}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var90)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 164, "\" class=\"inline-block bg-ink px-3 py-2 text-sm text-paper\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var91 string
templ_7745c5c3_Var91, templ_7745c5c3_Err = templruntime.NewAttributeExpression(templ.SafeURL("/login?next=/invite/" + v.Token)).ResolveURL(ctx)
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: 449, Col: 62}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 448, Col: 153}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var91)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var91))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 165, "\" class=\"inline-block bg-ink px-3 py-2 text-sm text-paper\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var92 string
templ_7745c5c3_Var92, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "invite.sign_in"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 449, Col: 153}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var92))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 166, "</a>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 165, "</a>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
default:
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 167, "<form data-api=\"")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 166, "<form data-api=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var93 string
templ_7745c5c3_Var93, templ_7745c5c3_Err = templruntime.NewAttributeExpression("/invitations/" + v.Token + "/signup").Resolve(ctx)
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: 451, Col: 59}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/org.templ`, Line: 450, Col: 59}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var93)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var92)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 168, "\" data-next=\"/\">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 167, "\" data-next=\"/\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -2015,7 +2002,7 @@ func InvitationPage(p Page, v Invitation) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 169, "</form>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 168, "</form>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -2023,7 +2010,7 @@ func InvitationPage(p Page, v Invitation) templ.Component {
}
return nil
})
templ_7745c5c3_Err = authShell(p).Render(templ.WithChildren(ctx, templ_7745c5c3_Var84), templ_7745c5c3_Buffer)
templ_7745c5c3_Err = authShell(p).Render(templ.WithChildren(ctx, templ_7745c5c3_Var83), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
+1 -18
View File
@@ -7,8 +7,7 @@
"name": "uptimesebi-web",
"license": "AGPL-3.0-only",
"dependencies": {
"axios": "1.21.1",
"swagger-ui-dist": "5.35.1"
"axios": "1.21.1"
},
"devDependencies": {
"@fontsource/ibm-plex-mono": "5.3.0",
@@ -392,13 +391,6 @@
"url": "https://opencollective.com/parcel"
}
},
"node_modules/@scarf/scarf": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/@scarf/scarf/-/scarf-1.4.0.tgz",
"integrity": "sha512-xxeapPiUXdZAE3che6f3xogoJPeZgig6omHEy1rIY5WVsB3H2BHNnZH+gHG6x91SCWyQCzWGsuL2Hh3ClO5/qQ==",
"hasInstallScript": true,
"license": "Apache-2.0"
},
"node_modules/@tailwindcss/cli": {
"version": "4.3.5",
"resolved": "https://registry.npmjs.org/@tailwindcss/cli/-/cli-4.3.5.tgz",
@@ -1478,15 +1470,6 @@
"node": ">=6.0.0"
}
},
"node_modules/swagger-ui-dist": {
"version": "5.35.1",
"resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-5.35.1.tgz",
"integrity": "sha512-XPBzLiPyIvwg2KYyNZIxOVS77pD0SNMbiSIwvpPXbU5bC/F4zvXxGraK3Hpyxug1b89fH5T29gSsW6rBxMmPyg==",
"license": "Apache-2.0",
"dependencies": {
"@scarf/scarf": "=1.4.0"
}
},
"node_modules/tailwindcss": {
"version": "4.3.5",
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.3.5.tgz",
+2 -3
View File
@@ -5,7 +5,7 @@
"scripts": {
"build": "npm run build:css && npm run build:js && npm run build:fonts",
"build:css": "tailwindcss -i internal/web/assets/app.css -o internal/web/static/dist/app.css --minify",
"build:js": "cp node_modules/axios/dist/axios.min.js internal/web/static/dist/axios.min.js && cp internal/web/assets/app.js internal/web/static/dist/app.js && cp node_modules/swagger-ui-dist/swagger-ui-bundle.js node_modules/swagger-ui-dist/swagger-ui.css internal/web/assets/apidocs.js internal/web/static/dist/",
"build:js": "cp node_modules/axios/dist/axios.min.js internal/web/static/dist/axios.min.js && cp internal/web/assets/app.js internal/web/static/dist/app.js",
"watch:css": "tailwindcss -i internal/web/assets/app.css -o internal/web/static/dist/app.css --watch",
"build:fonts": "mkdir -p internal/web/static/dist/fonts && cp node_modules/@fontsource/ibm-plex-sans/files/ibm-plex-sans-latin-400-normal.woff2 node_modules/@fontsource/ibm-plex-sans/files/ibm-plex-sans-latin-500-normal.woff2 node_modules/@fontsource/ibm-plex-sans/files/ibm-plex-sans-latin-600-normal.woff2 node_modules/@fontsource/ibm-plex-mono/files/ibm-plex-mono-latin-400-normal.woff2 node_modules/@fontsource/ibm-plex-mono/files/ibm-plex-mono-latin-500-normal.woff2 internal/web/static/dist/fonts/"
},
@@ -16,7 +16,6 @@
"tailwindcss": "4.3.5"
},
"dependencies": {
"axios": "1.21.1",
"swagger-ui-dist": "5.35.1"
"axios": "1.21.1"
}
}