Merge pull request 'feat: console pages for monitors, incidents and channels (M6)' (#54) from feat/m6-console into main
This commit was merged in pull request #54.
This commit is contained in:
commit
6b292ef0a8
21 files changed
+4335
-325
No files matched your search
@@ -0,0 +1,428 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/a-h/templ"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
"github.com/jackc/pgx/v5"
|
||||
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/auth"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/authz"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/check"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/store"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/web"
|
||||
)
|
||||
|
||||
const timeLayout = "2006-01-02 15:04 MST"
|
||||
|
||||
func (s *Server) registerConsole(r gin.IRouter) {
|
||||
r.GET("/", s.dashboard)
|
||||
r.GET("/monitors/new", s.orgPage("monitors.new", authz.MonitorsWrite, s.monitorEditor))
|
||||
r.GET("/monitors/:id", s.orgPage("console.monitors.title", authz.MonitorsRead, s.monitorDetail))
|
||||
r.GET("/monitors/:id/edit", s.orgPage("monitors.edit", authz.MonitorsWrite, s.monitorEditor))
|
||||
r.GET("/incidents", s.orgPage("incidents.title", authz.IncidentsRead, s.incidentsView))
|
||||
r.GET("/settings/channels", s.orgPage("channels.title", authz.NotificationsRead, s.channelsView))
|
||||
}
|
||||
|
||||
// dashboard is the landing page. Unlike other console pages it renders for
|
||||
// users without an organization or permission instead of redirecting, since
|
||||
// it is where those redirects lead.
|
||||
func (s *Server) dashboard(c *gin.Context) {
|
||||
sess := auth.Current(c)
|
||||
if sess == nil {
|
||||
c.Redirect(http.StatusSeeOther, "/login")
|
||||
return
|
||||
}
|
||||
me, p, err := s.consoleMe(c, sess)
|
||||
if err != nil {
|
||||
internalError(c, err)
|
||||
return
|
||||
}
|
||||
v := web.DashboardView{Counts: map[web.Status]int{}}
|
||||
if p != nil && me.Policy == "" && p.Grants.Can(authz.MonitorsRead) {
|
||||
data, err := s.loadMonitorData(c.Request.Context(), p)
|
||||
if err != nil {
|
||||
internalError(c, err)
|
||||
return
|
||||
}
|
||||
v.Monitors = data.rows
|
||||
v.CanWrite = p.Grants.Can(authz.MonitorsWrite)
|
||||
for _, m := range v.Monitors {
|
||||
v.Counts[m.Status]++
|
||||
}
|
||||
}
|
||||
web.Render(c, http.StatusOK, web.Dashboard(s.pageFor(c, "console.monitors.title"), me, v))
|
||||
}
|
||||
|
||||
type monitorData struct {
|
||||
rows []web.MonitorRow
|
||||
byID map[uuid.UUID]store.Monitor
|
||||
hourly map[uuid.UUID][]web.Bucket
|
||||
regionOf map[uuid.UUID]store.Region
|
||||
}
|
||||
|
||||
// loadMonitorData assembles everything the monitor list shows.
|
||||
func (s *Server) loadMonitorData(ctx context.Context, p *principal) (monitorData, error) {
|
||||
d := monitorData{byID: map[uuid.UUID]store.Monitor{}, hourly: map[uuid.UUID][]web.Bucket{}, regionOf: map[uuid.UUID]store.Region{}}
|
||||
now := time.Now()
|
||||
var (
|
||||
monitors []store.Monitor
|
||||
assigned []store.AllMonitorRegionsRow
|
||||
regions []store.Region
|
||||
latest []store.LatestResultsRow
|
||||
open []store.Incident
|
||||
hourly []store.HourlyBucketsRow
|
||||
)
|
||||
err := s.db.Tx(ctx, p.scope(), func(q *store.Queries) error {
|
||||
var err error
|
||||
if monitors, err = q.ListMonitors(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
if assigned, err = q.AllMonitorRegions(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
if regions, err = q.ListVisibleRegions(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
if latest, err = q.LatestResults(ctx, p.Org.ID); err != nil {
|
||||
return err
|
||||
}
|
||||
if open, err = q.OpenIncidents(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
hourly, err = q.HourlyBuckets(ctx, store.HourlyBucketsParams{OrgID: p.Org.ID, Bucket: now.Add(-24 * time.Hour).Truncate(time.Hour)})
|
||||
return err
|
||||
})
|
||||
if err != nil {
|
||||
return d, err
|
||||
}
|
||||
for _, r := range regions {
|
||||
d.regionOf[r.ID] = r
|
||||
}
|
||||
regionsOf := map[uuid.UUID][]uuid.UUID{}
|
||||
for _, a := range assigned {
|
||||
regionsOf[a.MonitorID] = append(regionsOf[a.MonitorID], a.RegionID)
|
||||
}
|
||||
latestOf := map[uuid.UUID]map[string]store.LatestResultsRow{}
|
||||
for _, l := range latest {
|
||||
if latestOf[l.MonitorID] == nil {
|
||||
latestOf[l.MonitorID] = map[string]store.LatestResultsRow{}
|
||||
}
|
||||
latestOf[l.MonitorID][l.Region] = l
|
||||
}
|
||||
down := map[uuid.UUID]bool{}
|
||||
for _, i := range open {
|
||||
down[i.MonitorID] = true
|
||||
}
|
||||
for _, h := range hourly {
|
||||
d.hourly[h.MonitorID] = append(d.hourly[h.MonitorID], web.Bucket{Start: h.Bucket, Total: h.Total, OK: h.OkCount, Latency: h.AvgLatencyMs})
|
||||
}
|
||||
for _, m := range monitors {
|
||||
d.byID[m.ID] = m
|
||||
row := web.MonitorRow{ID: m.ID.String(), Name: m.Name, Type: m.Type, Target: m.Target, Latency: "–", Uptime: "–"}
|
||||
var latencies []int32
|
||||
failing, reported := 0, 0
|
||||
for _, rid := range regionsOf[m.ID] {
|
||||
rs := web.RegionStatus{Name: d.regionName(rid), Status: web.StatusUnknown, Detail: "–"}
|
||||
if l, ok := latestOf[m.ID][rid.String()]; ok {
|
||||
reported++
|
||||
rs.Detail = l.Time.Format("15:04:05")
|
||||
if l.Ok {
|
||||
rs.Status = web.StatusUp
|
||||
if l.LatencyMs != nil {
|
||||
latencies = append(latencies, *l.LatencyMs)
|
||||
rs.Detail = fmt.Sprintf("%d ms", *l.LatencyMs)
|
||||
}
|
||||
} else {
|
||||
failing++
|
||||
rs.Status = web.StatusDown
|
||||
rs.Detail = deref(l.Error)
|
||||
}
|
||||
}
|
||||
row.Regions = append(row.Regions, rs)
|
||||
}
|
||||
switch {
|
||||
case !m.Enabled:
|
||||
row.Status = web.StatusPaused
|
||||
case down[m.ID]:
|
||||
row.Status = web.StatusDown
|
||||
case reported == 0:
|
||||
row.Status = web.StatusUnknown
|
||||
case failing > 0:
|
||||
row.Status = web.StatusDegraded
|
||||
default:
|
||||
row.Status = web.StatusUp
|
||||
}
|
||||
if len(latencies) > 0 {
|
||||
var sum int32
|
||||
for _, l := range latencies {
|
||||
sum += l
|
||||
}
|
||||
row.Latency = fmt.Sprintf("%d ms", sum/int32(len(latencies)))
|
||||
}
|
||||
if u := web.Uptime(d.hourly[m.ID]); u >= 0 {
|
||||
row.Uptime = web.Percent(u)
|
||||
}
|
||||
row.Bars = web.UptimeBars(d.hourly[m.ID], now, time.Hour, 24, "15:04")
|
||||
d.rows = append(d.rows, row)
|
||||
}
|
||||
// Problems first, then by name.
|
||||
rank := map[web.Status]int{web.StatusDown: 0, web.StatusDegraded: 1, web.StatusUnknown: 2, web.StatusUp: 3, web.StatusPaused: 4}
|
||||
slices.SortStableFunc(d.rows, func(a, b web.MonitorRow) int { return rank[a.Status] - rank[b.Status] })
|
||||
return d, nil
|
||||
}
|
||||
|
||||
func (d monitorData) regionName(id uuid.UUID) string {
|
||||
if r, ok := d.regionOf[id]; ok {
|
||||
return r.Name
|
||||
}
|
||||
return id.String()[:8]
|
||||
}
|
||||
|
||||
func (s *Server) monitorDetail(c *gin.Context, p *principal, page web.Page, me web.Me) (templ.Component, error) {
|
||||
id, err := uuid.Parse(c.Param("id"))
|
||||
if err != nil {
|
||||
return notFoundPage(c)
|
||||
}
|
||||
ctx := c.Request.Context()
|
||||
d, err := s.loadMonitorData(ctx, p)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
m, ok := d.byID[id]
|
||||
if !ok {
|
||||
return notFoundPage(c)
|
||||
}
|
||||
v := web.MonitorDetailView{
|
||||
Interval: (time.Duration(m.IntervalSeconds) * time.Second).String(),
|
||||
CanWrite: p.Grants.Can(authz.MonitorsWrite),
|
||||
Latency: web.Latency(d.hourly[id], 480, 96),
|
||||
Uptime90: "–",
|
||||
}
|
||||
for _, r := range d.rows {
|
||||
if r.ID == id.String() {
|
||||
v.Row = r
|
||||
}
|
||||
}
|
||||
var (
|
||||
daily []store.DailyBucketsRow
|
||||
recent []store.RecentResultsRow
|
||||
incidents []store.Incident
|
||||
)
|
||||
now := time.Now()
|
||||
err = s.db.Tx(ctx, p.scope(), func(q *store.Queries) error {
|
||||
var err error
|
||||
if daily, err = q.DailyBuckets(ctx, store.DailyBucketsParams{OrgID: p.Org.ID, MonitorID: id, Bucket: now.AddDate(0, 0, -90)}); err != nil {
|
||||
return err
|
||||
}
|
||||
if recent, err = q.RecentResults(ctx, store.RecentResultsParams{OrgID: p.Org.ID, MonitorID: id, Time: now.Add(-24 * time.Hour)}); err != nil {
|
||||
return err
|
||||
}
|
||||
incidents, err = q.MonitorIncidents(ctx, id)
|
||||
return err
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
buckets := make([]web.Bucket, len(daily))
|
||||
for i, b := range daily {
|
||||
buckets[i] = web.Bucket{Start: b.Bucket, Total: b.Total, OK: b.OkCount}
|
||||
}
|
||||
v.Daily = web.UptimeBars(buckets, now, 24*time.Hour, 90, "2006-01-02")
|
||||
if u := web.Uptime(buckets); u >= 0 {
|
||||
v.Uptime90 = web.Percent(u)
|
||||
}
|
||||
for _, r := range recent[:min(len(recent), 50)] {
|
||||
row := web.ResultRow{Time: r.Time.Format("01-02 15:04:05"), Region: d.regionNameString(r.Region), OK: r.Ok, Latency: "–", Detail: deref(r.Error)}
|
||||
if r.LatencyMs != nil {
|
||||
row.Latency = fmt.Sprintf("%d ms", *r.LatencyMs)
|
||||
}
|
||||
if r.StatusCode != nil && row.Detail == "" {
|
||||
row.Detail = fmt.Sprint(*r.StatusCode)
|
||||
}
|
||||
v.Recent = append(v.Recent, row)
|
||||
}
|
||||
for _, i := range incidents {
|
||||
v.Incidents = append(v.Incidents, d.incidentRow(i, m.Name))
|
||||
}
|
||||
page.TitleID = "console.monitors.title"
|
||||
return web.MonitorDetail(page, me, v), nil
|
||||
}
|
||||
|
||||
func (d monitorData) regionNameString(id string) string {
|
||||
if u, err := uuid.Parse(id); err == nil {
|
||||
return d.regionName(u)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
func (d monitorData) incidentRow(i store.Incident, monitor string) web.IncidentRow {
|
||||
row := web.IncidentRow{
|
||||
ID: i.ID.String(), MonitorID: i.MonitorID.String(), Monitor: monitor,
|
||||
Started: i.StartedAt.UTC().Format(timeLayout), Open: i.ResolvedAt == nil,
|
||||
}
|
||||
end := time.Now()
|
||||
if i.ResolvedAt != nil {
|
||||
end = *i.ResolvedAt
|
||||
}
|
||||
row.Duration = humanDuration(end.Sub(i.StartedAt))
|
||||
var cause map[string]string
|
||||
_ = json.Unmarshal(i.Cause, &cause)
|
||||
for region, msg := range cause {
|
||||
row.Cause = append(row.Cause, d.regionNameString(region)+": "+msg)
|
||||
}
|
||||
slices.Sort(row.Cause)
|
||||
return row
|
||||
}
|
||||
|
||||
// humanDuration prints the two most significant units, e.g. "2h 5m".
|
||||
func humanDuration(d time.Duration) string {
|
||||
d = d.Round(time.Second)
|
||||
days := int(d / (24 * time.Hour))
|
||||
h := int(d/time.Hour) % 24
|
||||
m := int(d/time.Minute) % 60
|
||||
sec := int(d/time.Second) % 60
|
||||
switch {
|
||||
case days > 0:
|
||||
return fmt.Sprintf("%dd %dh", days, h)
|
||||
case h > 0:
|
||||
return fmt.Sprintf("%dh %dm", h, m)
|
||||
case m > 0:
|
||||
return fmt.Sprintf("%dm %ds", m, sec)
|
||||
}
|
||||
return fmt.Sprintf("%ds", sec)
|
||||
}
|
||||
|
||||
func notFoundPage(c *gin.Context) (templ.Component, error) {
|
||||
c.Redirect(http.StatusSeeOther, "/")
|
||||
return nil, errAborted
|
||||
}
|
||||
|
||||
// errAborted tells orgPage that the view already wrote a response.
|
||||
var errAborted = errors.New("api: response already written")
|
||||
|
||||
func (s *Server) monitorEditor(c *gin.Context, p *principal, page web.Page, me web.Me) (templ.Component, error) {
|
||||
ctx := c.Request.Context()
|
||||
f := web.MonitorForm{
|
||||
Type: "http", IntervalSeconds: 60, TimeoutMS: 10000, Confirmations: 2, Enabled: true,
|
||||
MinInterval: s.minInterval(), Method: "GET", ExpectStatus: "2xx, 3xx",
|
||||
FollowRedirects: true, VerifyTLS: true, DNSRecord: "A", TLSMinDays: 14,
|
||||
}
|
||||
var (
|
||||
regions []store.Region
|
||||
assigned []uuid.UUID
|
||||
)
|
||||
idParam := c.Param("id")
|
||||
err := s.db.Tx(ctx, p.scope(), func(q *store.Queries) error {
|
||||
var err error
|
||||
if regions, err = q.ListVisibleRegions(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
if idParam == "" {
|
||||
return nil
|
||||
}
|
||||
id, err := uuid.Parse(idParam)
|
||||
if err != nil {
|
||||
return pgx.ErrNoRows
|
||||
}
|
||||
m, err := q.GetMonitor(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fillForm(&f, m)
|
||||
assigned, err = q.MonitorRegions(ctx, id)
|
||||
return err
|
||||
})
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return notFoundPage(c)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for i, r := range regions {
|
||||
live, err := s.sched.Instances(ctx, r.ID.String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
checked := slices.Contains(assigned, r.ID) || (idParam == "" && i == 0)
|
||||
f.Regions = append(f.Regions, web.RegionOption{ID: r.ID.String(), Name: r.Name, Own: r.OrgID != nil, Checked: checked, Live: live})
|
||||
}
|
||||
return web.MonitorEditor(page, me, f), nil
|
||||
}
|
||||
|
||||
func fillForm(f *web.MonitorForm, m store.Monitor) {
|
||||
f.ID, f.Name, f.Type, f.Target = m.ID.String(), m.Name, m.Type, m.Target
|
||||
f.IntervalSeconds, f.TimeoutMS = int(m.IntervalSeconds), int(m.TimeoutMs)
|
||||
f.Confirmations, f.Enabled = int(m.Confirmations), m.Enabled
|
||||
switch check.Type(m.Type) {
|
||||
case check.HTTP:
|
||||
var c check.HTTPConfig
|
||||
_ = json.Unmarshal(m.Config, &c)
|
||||
f.Method, f.ExpectStatus, f.Keyword, f.KeywordAbsent = c.Method, strings.Join(c.ExpectStatus, ", "), c.Keyword, c.KeywordAbsent
|
||||
f.FollowRedirects, f.VerifyTLS = c.FollowRedirects, c.VerifyTLS
|
||||
case check.DNS:
|
||||
var c check.DNSConfig
|
||||
_ = json.Unmarshal(m.Config, &c)
|
||||
f.DNSRecord, f.DNSResolver, f.DNSExpect = c.Record, c.Resolver, c.Expect
|
||||
case check.TLS:
|
||||
var c check.TLSConfig
|
||||
_ = json.Unmarshal(m.Config, &c)
|
||||
f.TLSMinDays, f.TLSServerName = c.MinDaysValid, c.ServerName
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) incidentsView(c *gin.Context, p *principal, page web.Page, me web.Me) (templ.Component, error) {
|
||||
ctx := c.Request.Context()
|
||||
var rows []store.ListIncidentsRow
|
||||
err := s.db.Tx(ctx, p.scope(), func(q *store.Queries) error {
|
||||
var err error
|
||||
rows, err = q.ListIncidents(ctx)
|
||||
return err
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
d, err := s.loadMonitorData(ctx, p)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out := make([]web.IncidentRow, len(rows))
|
||||
for i, r := range rows {
|
||||
out[i] = d.incidentRow(store.Incident{
|
||||
ID: r.ID, OrgID: r.OrgID, MonitorID: r.MonitorID, StartedAt: r.StartedAt, ResolvedAt: r.ResolvedAt, Cause: r.Cause,
|
||||
}, r.MonitorName)
|
||||
}
|
||||
return web.IncidentsPage(page, me, out), nil
|
||||
}
|
||||
|
||||
func (s *Server) channelsView(c *gin.Context, p *principal, page web.Page, me web.Me) (templ.Component, error) {
|
||||
ctx := c.Request.Context()
|
||||
var rows []store.NotificationChannel
|
||||
err := s.db.Tx(ctx, p.scope(), func(q *store.Queries) error {
|
||||
var err error
|
||||
rows, err = q.ListChannels(ctx)
|
||||
return err
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
v := web.ChannelsView{EmailAvailable: s.smtp != nil, CanWrite: p.Grants.Can(authz.NotificationsWrite), Languages: s.catalog.Supported()}
|
||||
for _, r := range rows {
|
||||
cv := viewChannel(r)
|
||||
target := cv.URL
|
||||
if cv.Type == "email" {
|
||||
target = strings.Join(cv.To, ", ")
|
||||
}
|
||||
v.Channels = append(v.Channels, web.ChannelRow{ID: r.ID.String(), Name: r.Name, Type: r.Type, Target: target, Enabled: r.Enabled})
|
||||
}
|
||||
return web.ChannelsPage(page, me, v), nil
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package api_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// page fetches path and returns the final status, path and body.
|
||||
func (b *browser) page(path string) (int, string, string) {
|
||||
b.t.Helper()
|
||||
resp, err := b.hc.Get(b.base + path)
|
||||
if err != nil {
|
||||
b.t.Fatalf("GET %s failed: %v", path, err)
|
||||
}
|
||||
defer func() { _ = resp.Body.Close() }()
|
||||
body, _ := io.ReadAll(resp.Body)
|
||||
return resp.StatusCode, resp.Request.URL.Path, string(body)
|
||||
}
|
||||
|
||||
func TestConsolePages(t *testing.T) {
|
||||
e := newEnv(t)
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
t.Cleanup(cancel)
|
||||
go e.api.RunScheduler(ctx)
|
||||
|
||||
target := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.WriteHeader(http.StatusBadGateway)
|
||||
}))
|
||||
defer target.Close()
|
||||
tok, region := e.platformChecker(t, uniq("eu-"))
|
||||
e.startChecker(t, tok)
|
||||
|
||||
owner := e.browser(t)
|
||||
owner.signup("o@"+uniq("p")+".test", uniq("pages-"))
|
||||
st, body := owner.do("POST", "/api/v1/org/monitors", map[string]any{
|
||||
"name": "Checkout API", "type": "http", "target": target.URL, "interval_seconds": 60,
|
||||
"confirmations": 1, "regions": []string{region}, "config": map[string]any{"keyword": "ok"},
|
||||
})
|
||||
if st != http.StatusCreated {
|
||||
t.Fatalf("create monitor = %d %v", st, body)
|
||||
}
|
||||
id := body["id"].(string)
|
||||
waitFor(t, 10*time.Second, "incident opened", func() bool {
|
||||
_, body := owner.do("GET", "/api/v1/org/incidents", nil)
|
||||
return len(body["incidents"].([]any)) == 1
|
||||
})
|
||||
owner.do("POST", "/api/v1/org/channels", map[string]any{"name": "Hook", "type": "webhook", "url": "https://hooks.example.test/x"})
|
||||
|
||||
pages := map[string][]string{
|
||||
"/": {"Checkout API", "<svg"},
|
||||
"/monitors/" + id: {"Checkout API", "unexpected status 502"},
|
||||
"/monitors/" + id + "/edit": {`value="Checkout API"`, `name="config.keyword"`, `value="ok"`},
|
||||
"/monitors/new": {`name="regions"`},
|
||||
"/incidents": {"Checkout API", "unexpected status 502"},
|
||||
"/settings/channels": {"hooks.example.test"},
|
||||
}
|
||||
for path, wants := range pages {
|
||||
st, final, html := owner.page(path)
|
||||
if st != http.StatusOK || final != path {
|
||||
t.Errorf("GET %s = %d at %s", path, st, final)
|
||||
continue
|
||||
}
|
||||
for _, w := range wants {
|
||||
if !strings.Contains(html, w) {
|
||||
t.Errorf("GET %s: page lacks %q", path, w)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
viewer := e.joinVia(t, owner.invite("v@"+uniq("v")+".test", owner.roleID("viewer")))
|
||||
for path, want := range map[string]string{"/monitors/new": "/", "/monitors/" + id + "/edit": "/", "/monitors/" + id: "/monitors/" + id} {
|
||||
if _, final, _ := viewer.page(path); final != want {
|
||||
t.Errorf("viewer GET %s ended at %s, want %s", path, final, want)
|
||||
}
|
||||
}
|
||||
if _, _, html := viewer.page("/"); strings.Contains(html, "/monitors/new") {
|
||||
t.Error("viewer dashboard offers creating monitors")
|
||||
}
|
||||
}
|
||||
+5
-17
@@ -2,6 +2,7 @@ package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"slices"
|
||||
"strings"
|
||||
@@ -23,7 +24,7 @@ func (s *Server) registerPages(r gin.IRouter) {
|
||||
r.GET("/login", s.loginPage)
|
||||
r.GET("/signup", s.signupPage)
|
||||
r.GET("/invite/:token", s.invitePage)
|
||||
r.GET("/", s.page("console.monitors.title", web.Dashboard))
|
||||
s.registerConsole(r)
|
||||
r.GET("/settings/security", s.securityPage)
|
||||
r.GET("/settings/sso", s.orgPage("sso.settings.title", authz.OrgManage, s.ssoSettingsView))
|
||||
r.GET("/settings/org", s.orgPage("org.title", authz.OrgManage, s.orgSettingsView))
|
||||
@@ -127,22 +128,6 @@ func (s *Server) consoleMe(c *gin.Context, sess *auth.Session) (web.Me, *princip
|
||||
return me, p, nil
|
||||
}
|
||||
|
||||
func (s *Server) page(titleID string, view func(web.Page, web.Me) templ.Component) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
sess := auth.Current(c)
|
||||
if sess == nil {
|
||||
c.Redirect(http.StatusSeeOther, "/login?next="+c.Request.URL.Path)
|
||||
return
|
||||
}
|
||||
me, _, err := s.consoleMe(c, sess)
|
||||
if err != nil {
|
||||
internalError(c, err)
|
||||
return
|
||||
}
|
||||
web.Render(c, http.StatusOK, view(s.pageFor(c, titleID), me))
|
||||
}
|
||||
}
|
||||
|
||||
type orgPageView func(c *gin.Context, p *principal, page web.Page, me web.Me) (templ.Component, error)
|
||||
|
||||
// orgPage renders an organization settings page. perm may be empty for
|
||||
@@ -171,6 +156,9 @@ func (s *Server) orgPage(titleID string, perm authz.Permission, view orgPageView
|
||||
return
|
||||
}
|
||||
comp, err := view(c, p, s.pageFor(c, titleID), me)
|
||||
if errors.Is(err, errAborted) {
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
internalError(c, err)
|
||||
return
|
||||
|
||||
@@ -145,6 +145,24 @@ func TestEveryMailEventHasTexts(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Templates build these IDs from a prefix and a value.
|
||||
func TestDynamicFamilies(t *testing.T) {
|
||||
en := catalogKeys(t)["en"]
|
||||
families := map[string][]string{
|
||||
"status.": {"up", "degraded", "down", "unknown", "paused"},
|
||||
"monitors.type_": {"http", "tcp", "tls", "dns", "icmp"},
|
||||
"channels.type_": {"webhook", "email"},
|
||||
"agents.kind_": {"checker", "statuspage"},
|
||||
}
|
||||
for prefix, values := range families {
|
||||
for _, v := range values {
|
||||
if !en[prefix+v] {
|
||||
t.Errorf("en.json is missing %q", prefix+v)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The language switcher builds "lang.<code>" dynamically.
|
||||
func TestEveryLanguageHasAName(t *testing.T) {
|
||||
c, err := Load()
|
||||
|
||||
@@ -29,6 +29,20 @@
|
||||
"auth.sso.heading": "Single Sign-on",
|
||||
"auth.sso.org_placeholder": "Kurzname der Organisation",
|
||||
"auth.sso.submit": "Weiter",
|
||||
"channels.create": "Kanal anlegen",
|
||||
"channels.delete_confirm": "Diesen Kanal löschen?",
|
||||
"channels.intro": "Jeder aktive Kanal wird benachrichtigt, wenn ein Monitor in allen seinen Regionen ausfällt und wenn er sich erholt.",
|
||||
"channels.language": "Sprache",
|
||||
"channels.new_email": "Neuer E-Mail-Kanal",
|
||||
"channels.new_webhook": "Neuer Webhook",
|
||||
"channels.secret_now": "Signatur-Secret: Prüfe damit den Header X-Uptimesebi-Signature. Es wird nicht erneut angezeigt.",
|
||||
"channels.test": "Test senden",
|
||||
"channels.test_ok": "Testbenachrichtigung zugestellt.",
|
||||
"channels.title": "Benachrichtigungen",
|
||||
"channels.to": "Empfänger",
|
||||
"channels.type_email": "E-Mail",
|
||||
"channels.type_webhook": "Webhook",
|
||||
"channels.url": "Webhook-URL",
|
||||
"common.no": "nein",
|
||||
"common.save": "Speichern",
|
||||
"common.yes": "ja",
|
||||
@@ -124,6 +138,10 @@
|
||||
"error.totp_setup_expired": "Einrichtung abgelaufen, bitte neu starten.",
|
||||
"error.unauthenticated": "Anmeldung erforderlich.",
|
||||
"error.unsupported_locale": "Sprache wird nicht unterstützt.",
|
||||
"incidents.none": "Bisher keine Incidents.",
|
||||
"incidents.ongoing": "laufend",
|
||||
"incidents.resolved": "behoben",
|
||||
"incidents.title": "Incidents",
|
||||
"invite.accept": "Einladung annehmen",
|
||||
"invite.create_account": "Konto anlegen und beitreten",
|
||||
"invite.sign_in": "Zum Annehmen anmelden",
|
||||
@@ -145,6 +163,41 @@
|
||||
"members.roles": "Rollen",
|
||||
"members.title": "Mitglieder",
|
||||
"members.unassign": "Rolle entfernen",
|
||||
"monitors.confirmations": "Fehlschläge bis zum Alarm",
|
||||
"monitors.confirmations_hint": "Aufeinanderfolgende Fehlschläge pro Region. Alarm gibt es erst, wenn alle gewählten Regionen ausfallen.",
|
||||
"monitors.delete": "Monitor löschen",
|
||||
"monitors.delete_confirm": "Diesen Monitor samt Verlauf löschen?",
|
||||
"monitors.dns_expect": "Erwartete Antwort (optional)",
|
||||
"monitors.dns_record": "Record-Typ",
|
||||
"monitors.dns_resolver": "Resolver (host:port, optional)",
|
||||
"monitors.edit": "Monitor bearbeiten",
|
||||
"monitors.expect_status": "Erwarteter Status (z. B. 2xx, 301)",
|
||||
"monitors.follow_redirects": "Weiterleitungen folgen",
|
||||
"monitors.interval": "Intervall (Sekunden)",
|
||||
"monitors.interval_hint": "Mindestens {{.Min}} Sekunden.",
|
||||
"monitors.keyword": "Keyword in der Antwort",
|
||||
"monitors.keyword_absent": "Fehler, wenn das Keyword vorkommt",
|
||||
"monitors.last_24h": "letzte 24 Stunden",
|
||||
"monitors.last_90d": "Letzte 90 Tage",
|
||||
"monitors.latency_24h": "Latenz, letzte 24 Stunden",
|
||||
"monitors.method": "Methode",
|
||||
"monitors.new": "Neuer Monitor",
|
||||
"monitors.recent": "Letzte Checks",
|
||||
"monitors.regions": "Regionen",
|
||||
"monitors.regions_hint": "Geprüft von einem zufälligen Checker jeder gewählten Region. Deine eigenen Regionen stehen oben.",
|
||||
"monitors.target": "Ziel",
|
||||
"monitors.target_hint": "URL für HTTP, host:port für TCP und TLS, Hostname für DNS und ICMP.",
|
||||
"monitors.timeout": "Timeout (ms)",
|
||||
"monitors.tls_min_days": "Mindestens Tage bis Ablauf",
|
||||
"monitors.tls_server_name": "Servername (optional)",
|
||||
"monitors.type": "Check-Typ",
|
||||
"monitors.type_dns": "DNS",
|
||||
"monitors.type_http": "HTTP(S)",
|
||||
"monitors.type_icmp": "Ping (ICMP)",
|
||||
"monitors.type_tcp": "TCP-Port",
|
||||
"monitors.type_tls": "TLS-Zertifikat",
|
||||
"monitors.uptime_chart": "Uptime pro Zeitraum",
|
||||
"monitors.verify_tls": "TLS-Zertifikat prüfen",
|
||||
"org.policy": "Anmelderichtlinie",
|
||||
"org.require_sso": "SSO verlangen",
|
||||
"org.require_sso_hint": "Mitglieder müssen sich über den Identity Provider dieser Organisation anmelden. Der Owner kann weiterhin ein Passwort nutzen, damit ein defekter IdP euch nicht aussperrt.",
|
||||
@@ -231,6 +284,11 @@
|
||||
"sso.settings.login_url": "Anmelde-URL",
|
||||
"sso.settings.redirect_url": "Redirect-URL",
|
||||
"sso.settings.title": "Single Sign-on",
|
||||
"status.degraded": "in einzelnen Regionen gestört",
|
||||
"status.down": "ausgefallen",
|
||||
"status.paused": "pausiert",
|
||||
"status.unknown": "keine Daten",
|
||||
"status.up": "erreichbar",
|
||||
"tokens.copy_now": "Kopiere den Token jetzt. Er wird nicht erneut angezeigt.",
|
||||
"tokens.create": "Token erstellen",
|
||||
"tokens.created": "Erstellt",
|
||||
|
||||
@@ -29,6 +29,20 @@
|
||||
"auth.sso.heading": "Single sign-on",
|
||||
"auth.sso.org_placeholder": "Organization short name",
|
||||
"auth.sso.submit": "Continue",
|
||||
"channels.create": "Create channel",
|
||||
"channels.delete_confirm": "Delete this channel?",
|
||||
"channels.intro": "Every enabled channel is notified when a monitor goes down in all of its regions and when it recovers.",
|
||||
"channels.language": "Language",
|
||||
"channels.new_email": "New email channel",
|
||||
"channels.new_webhook": "New webhook",
|
||||
"channels.secret_now": "Signing secret: verify the X-Uptimesebi-Signature header with it. It will not be shown again.",
|
||||
"channels.test": "Send test",
|
||||
"channels.test_ok": "Test notification delivered.",
|
||||
"channels.title": "Notifications",
|
||||
"channels.to": "Recipients",
|
||||
"channels.type_email": "Email",
|
||||
"channels.type_webhook": "Webhook",
|
||||
"channels.url": "Webhook URL",
|
||||
"common.no": "no",
|
||||
"common.save": "Save",
|
||||
"common.yes": "yes",
|
||||
@@ -124,6 +138,10 @@
|
||||
"error.totp_setup_expired": "Setup expired, please start again.",
|
||||
"error.unauthenticated": "Authentication required.",
|
||||
"error.unsupported_locale": "Unsupported language.",
|
||||
"incidents.none": "No incidents so far.",
|
||||
"incidents.ongoing": "ongoing",
|
||||
"incidents.resolved": "resolved",
|
||||
"incidents.title": "Incidents",
|
||||
"invite.accept": "Accept invitation",
|
||||
"invite.create_account": "Create account and join",
|
||||
"invite.sign_in": "Sign in to accept",
|
||||
@@ -145,6 +163,41 @@
|
||||
"members.roles": "Roles",
|
||||
"members.title": "Members",
|
||||
"members.unassign": "Remove role",
|
||||
"monitors.confirmations": "Failures before alerting",
|
||||
"monitors.confirmations_hint": "Consecutive failures per region. An alert needs every selected region to fail.",
|
||||
"monitors.delete": "Delete monitor",
|
||||
"monitors.delete_confirm": "Delete this monitor and its history?",
|
||||
"monitors.dns_expect": "Expected answer (optional)",
|
||||
"monitors.dns_record": "Record type",
|
||||
"monitors.dns_resolver": "Resolver (host:port, optional)",
|
||||
"monitors.edit": "Edit monitor",
|
||||
"monitors.expect_status": "Expected status (e.g. 2xx, 301)",
|
||||
"monitors.follow_redirects": "Follow redirects",
|
||||
"monitors.interval": "Interval (seconds)",
|
||||
"monitors.interval_hint": "At least {{.Min}} seconds.",
|
||||
"monitors.keyword": "Keyword in response",
|
||||
"monitors.keyword_absent": "Fail if the keyword is present",
|
||||
"monitors.last_24h": "last 24 hours",
|
||||
"monitors.last_90d": "Last 90 days",
|
||||
"monitors.latency_24h": "Latency, last 24 hours",
|
||||
"monitors.method": "Method",
|
||||
"monitors.new": "New monitor",
|
||||
"monitors.recent": "Recent checks",
|
||||
"monitors.regions": "Regions",
|
||||
"monitors.regions_hint": "Checked from a random checker in each selected region. Your own regions are listed first.",
|
||||
"monitors.target": "Target",
|
||||
"monitors.target_hint": "URL for HTTP, host:port for TCP and TLS, host name for DNS and ICMP.",
|
||||
"monitors.timeout": "Timeout (ms)",
|
||||
"monitors.tls_min_days": "Minimum days until expiry",
|
||||
"monitors.tls_server_name": "Server name (optional)",
|
||||
"monitors.type": "Check type",
|
||||
"monitors.type_dns": "DNS",
|
||||
"monitors.type_http": "HTTP(S)",
|
||||
"monitors.type_icmp": "Ping (ICMP)",
|
||||
"monitors.type_tcp": "TCP port",
|
||||
"monitors.type_tls": "TLS certificate",
|
||||
"monitors.uptime_chart": "Uptime per period",
|
||||
"monitors.verify_tls": "Verify TLS certificate",
|
||||
"org.policy": "Sign-in policy",
|
||||
"org.require_sso": "Require SSO",
|
||||
"org.require_sso_hint": "Members must sign in through this organization's identity provider. The owner can still use a password so a broken IdP cannot lock you out.",
|
||||
@@ -231,6 +284,11 @@
|
||||
"sso.settings.login_url": "Sign-in URL",
|
||||
"sso.settings.redirect_url": "Redirect URL",
|
||||
"sso.settings.title": "Single sign-on",
|
||||
"status.degraded": "failing in some regions",
|
||||
"status.down": "down",
|
||||
"status.paused": "paused",
|
||||
"status.unknown": "no data",
|
||||
"status.up": "up",
|
||||
"tokens.copy_now": "Copy the token now. It will not be shown again.",
|
||||
"tokens.create": "Create token",
|
||||
"tokens.created": "Created",
|
||||
|
||||
@@ -12,6 +12,95 @@ import (
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const dailyBuckets = `-- name: DailyBuckets :many
|
||||
SELECT bucket::timestamptz AS bucket, sum(total)::bigint AS total, sum(ok_count)::bigint AS ok_count
|
||||
FROM check_results_1d
|
||||
WHERE org_id = $1 AND monitor_id = $2 AND bucket >= $3
|
||||
GROUP BY bucket
|
||||
ORDER BY bucket
|
||||
`
|
||||
|
||||
type DailyBucketsParams struct {
|
||||
OrgID uuid.UUID
|
||||
MonitorID uuid.UUID
|
||||
Bucket interface{}
|
||||
}
|
||||
|
||||
type DailyBucketsRow struct {
|
||||
Bucket time.Time
|
||||
Total int64
|
||||
OkCount int64
|
||||
}
|
||||
|
||||
func (q *Queries) DailyBuckets(ctx context.Context, arg DailyBucketsParams) ([]DailyBucketsRow, error) {
|
||||
rows, err := q.db.Query(ctx, dailyBuckets, arg.OrgID, arg.MonitorID, arg.Bucket)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
items := []DailyBucketsRow{}
|
||||
for rows.Next() {
|
||||
var i DailyBucketsRow
|
||||
if err := rows.Scan(&i.Bucket, &i.Total, &i.OkCount); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const hourlyBuckets = `-- name: HourlyBuckets :many
|
||||
SELECT monitor_id, bucket::timestamptz AS bucket, sum(total)::bigint AS total, sum(ok_count)::bigint AS ok_count,
|
||||
(sum(avg_latency_ms * total) / nullif(sum(total), 0))::real AS avg_latency_ms
|
||||
FROM check_results_1h
|
||||
WHERE org_id = $1 AND bucket >= $2
|
||||
GROUP BY monitor_id, bucket
|
||||
ORDER BY monitor_id, bucket
|
||||
`
|
||||
|
||||
type HourlyBucketsParams struct {
|
||||
OrgID uuid.UUID
|
||||
Bucket interface{}
|
||||
}
|
||||
|
||||
type HourlyBucketsRow struct {
|
||||
MonitorID uuid.UUID
|
||||
Bucket time.Time
|
||||
Total int64
|
||||
OkCount int64
|
||||
AvgLatencyMs float32
|
||||
}
|
||||
|
||||
// Per monitor and hour since $2, across all regions.
|
||||
func (q *Queries) HourlyBuckets(ctx context.Context, arg HourlyBucketsParams) ([]HourlyBucketsRow, error) {
|
||||
rows, err := q.db.Query(ctx, hourlyBuckets, arg.OrgID, arg.Bucket)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
items := []HourlyBucketsRow{}
|
||||
for rows.Next() {
|
||||
var i HourlyBucketsRow
|
||||
if err := rows.Scan(
|
||||
&i.MonitorID,
|
||||
&i.Bucket,
|
||||
&i.Total,
|
||||
&i.OkCount,
|
||||
&i.AvgLatencyMs,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
type InsertCheckResultsParams struct {
|
||||
Time time.Time
|
||||
OrgID uuid.UUID
|
||||
|
||||
@@ -274,6 +274,37 @@ func (q *Queries) MarkNotificationSent(ctx context.Context, id uuid.UUID) error
|
||||
return err
|
||||
}
|
||||
|
||||
const monitorIncidents = `-- name: MonitorIncidents :many
|
||||
SELECT id, org_id, monitor_id, started_at, resolved_at, cause FROM incidents WHERE monitor_id = $1 ORDER BY started_at DESC LIMIT 20
|
||||
`
|
||||
|
||||
func (q *Queries) MonitorIncidents(ctx context.Context, monitorID uuid.UUID) ([]Incident, error) {
|
||||
rows, err := q.db.Query(ctx, monitorIncidents, monitorID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
items := []Incident{}
|
||||
for rows.Next() {
|
||||
var i Incident
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.OrgID,
|
||||
&i.MonitorID,
|
||||
&i.StartedAt,
|
||||
&i.ResolvedAt,
|
||||
&i.Cause,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const notificationDetails = `-- name: NotificationDetails :many
|
||||
SELECT n.id, n.org_id, n.event, n.attempts,
|
||||
c.type AS channel_type, c.config AS channel_config, c.id AS channel_id,
|
||||
@@ -374,6 +405,37 @@ func (q *Queries) OpenIncident(ctx context.Context, arg OpenIncidentParams) (Inc
|
||||
return i, err
|
||||
}
|
||||
|
||||
const openIncidents = `-- name: OpenIncidents :many
|
||||
SELECT id, org_id, monitor_id, started_at, resolved_at, cause FROM incidents WHERE resolved_at IS NULL
|
||||
`
|
||||
|
||||
func (q *Queries) OpenIncidents(ctx context.Context) ([]Incident, error) {
|
||||
rows, err := q.db.Query(ctx, openIncidents)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
items := []Incident{}
|
||||
for rows.Next() {
|
||||
var i Incident
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.OrgID,
|
||||
&i.MonitorID,
|
||||
&i.StartedAt,
|
||||
&i.ResolvedAt,
|
||||
&i.Cause,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const resolveIncident = `-- name: ResolveIncident :one
|
||||
UPDATE incidents SET resolved_at = $1
|
||||
WHERE monitor_id = $2 AND resolved_at IS NULL
|
||||
|
||||
@@ -35,6 +35,7 @@ type Querier interface {
|
||||
CreateRole(ctx context.Context, arg CreateRoleParams) (Role, error)
|
||||
CreateSSOProvider(ctx context.Context, arg CreateSSOProviderParams) (SsoProvider, error)
|
||||
CreateUser(ctx context.Context, arg CreateUserParams) (User, error)
|
||||
DailyBuckets(ctx context.Context, arg DailyBucketsParams) ([]DailyBucketsRow, error)
|
||||
DeleteAPIToken(ctx context.Context, id uuid.UUID) (int64, error)
|
||||
DeleteAgent(ctx context.Context, arg DeleteAgentParams) (int64, error)
|
||||
DeleteAssignment(ctx context.Context, id uuid.UUID) (int64, error)
|
||||
@@ -71,6 +72,8 @@ type Querier interface {
|
||||
GetSSOProvider(ctx context.Context, id uuid.UUID) (SsoProvider, error)
|
||||
GetUser(ctx context.Context, id uuid.UUID) (User, error)
|
||||
GetUserByEmail(ctx context.Context, email string) (User, error)
|
||||
// Per monitor and hour since $2, across all regions.
|
||||
HourlyBuckets(ctx context.Context, arg HourlyBucketsParams) ([]HourlyBucketsRow, error)
|
||||
// check_results and its aggregates have no row-level security (see
|
||||
// migration 00013). Every query here must filter by org_id.
|
||||
InsertCheckResults(ctx context.Context, arg []InsertCheckResultsParams) (int64, error)
|
||||
@@ -109,6 +112,7 @@ type Querier interface {
|
||||
MarkNotificationSent(ctx context.Context, id uuid.UUID) error
|
||||
// Every role a member holds, with the scope it applies to.
|
||||
MemberGrants(ctx context.Context, arg MemberGrantsParams) ([]MemberGrantsRow, error)
|
||||
MonitorIncidents(ctx context.Context, monitorID uuid.UUID) ([]Incident, error)
|
||||
MonitorRegions(ctx context.Context, monitorID uuid.UUID) ([]uuid.UUID, error)
|
||||
// System scope: monitors to hand to a checker of region, skipping ones that
|
||||
// were disabled, deleted or moved out of the region since dispatch. An
|
||||
@@ -120,6 +124,7 @@ type Querier interface {
|
||||
// System scope.
|
||||
NotificationDetails(ctx context.Context, ids []uuid.UUID) ([]NotificationDetailsRow, error)
|
||||
OpenIncident(ctx context.Context, arg OpenIncidentParams) (Incident, error)
|
||||
OpenIncidents(ctx context.Context) ([]Incident, error)
|
||||
OrgIDBySlug(ctx context.Context, slug string) (uuid.UUID, error)
|
||||
RecentResults(ctx context.Context, arg RecentResultsParams) ([]RecentResultsRow, error)
|
||||
RemoveMembership(ctx context.Context, arg RemoveMembershipParams) (int64, error)
|
||||
|
||||
@@ -32,3 +32,19 @@ SELECT DISTINCT ON (region) region, ok, error
|
||||
FROM check_results
|
||||
WHERE org_id = $1 AND monitor_id = $2 AND time > now() - interval '1 day'
|
||||
ORDER BY region, time DESC;
|
||||
|
||||
-- name: HourlyBuckets :many
|
||||
-- Per monitor and hour since $2, across all regions.
|
||||
SELECT monitor_id, bucket::timestamptz AS bucket, sum(total)::bigint AS total, sum(ok_count)::bigint AS ok_count,
|
||||
(sum(avg_latency_ms * total) / nullif(sum(total), 0))::real AS avg_latency_ms
|
||||
FROM check_results_1h
|
||||
WHERE org_id = $1 AND bucket >= $2
|
||||
GROUP BY monitor_id, bucket
|
||||
ORDER BY monitor_id, bucket;
|
||||
|
||||
-- name: DailyBuckets :many
|
||||
SELECT bucket::timestamptz AS bucket, sum(total)::bigint AS total, sum(ok_count)::bigint AS ok_count
|
||||
FROM check_results_1d
|
||||
WHERE org_id = $1 AND monitor_id = $2 AND bucket >= $3
|
||||
GROUP BY bucket
|
||||
ORDER BY bucket;
|
||||
@@ -77,3 +77,9 @@ SELECT * FROM notification_channels ORDER BY name;
|
||||
|
||||
-- name: DeleteChannel :execrows
|
||||
DELETE FROM notification_channels WHERE id = $1;
|
||||
|
||||
-- name: OpenIncidents :many
|
||||
SELECT * FROM incidents WHERE resolved_at IS NULL;
|
||||
|
||||
-- name: MonitorIncidents :many
|
||||
SELECT * FROM incidents WHERE monitor_id = $1 ORDER BY started_at DESC LIMIT 20;
|
||||
@@ -2,6 +2,46 @@
|
||||
|
||||
@source "../**/*.templ";
|
||||
|
||||
@font-face {
|
||||
font-family: "IBM Plex Sans";
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
font-display: swap;
|
||||
src: url("/static/dist/fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "IBM Plex Sans";
|
||||
font-style: normal;
|
||||
font-weight: 500;
|
||||
font-display: swap;
|
||||
src: url("/static/dist/fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "IBM Plex Sans";
|
||||
font-style: normal;
|
||||
font-weight: 600;
|
||||
font-display: swap;
|
||||
src: url("/static/dist/fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "IBM Plex Mono";
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
font-display: swap;
|
||||
src: url("/static/dist/fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "IBM Plex Mono";
|
||||
font-style: normal;
|
||||
font-weight: 500;
|
||||
font-display: swap;
|
||||
src: url("/static/dist/fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2");
|
||||
}
|
||||
|
||||
@theme {
|
||||
--font-sans: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
|
||||
--font-mono: "IBM Plex Mono", ui-monospace, monospace;
|
||||
|
||||
+45
-11
@@ -20,22 +20,30 @@
|
||||
// Inputs inside a hidden [data-step] are skipped. Checkboxes become
|
||||
// booleans, or arrays of values with [data-multi]; [data-list] inputs are
|
||||
// split on commas, [data-number] parsed and empty [data-nullable] sent as null.
|
||||
// Dotted names such as "config.keyword" build nested objects.
|
||||
const serialize = (form) => {
|
||||
const out = {};
|
||||
const set = (name, value) => {
|
||||
const path = name.split(".");
|
||||
let obj = out;
|
||||
for (const key of path.slice(0, -1)) obj = obj[key] ??= {};
|
||||
obj[path.at(-1)] = value;
|
||||
};
|
||||
const get = (name) => name.split(".").reduce((o, k) => o?.[k], out);
|
||||
for (const el of form.elements) {
|
||||
if (!el.name || el.closest("[data-step]")?.hidden) continue;
|
||||
if (!el.name || el.type === "fieldset" || el.closest("[data-step]")?.hidden) continue;
|
||||
if (el.dataset.multi !== undefined) {
|
||||
out[el.name] ??= [];
|
||||
if (el.checked && !el.disabled) out[el.name].push(el.value);
|
||||
if (get(el.name) === undefined) set(el.name, []);
|
||||
if (el.checked && !el.disabled) get(el.name).push(el.value);
|
||||
continue;
|
||||
}
|
||||
if (el.disabled) continue;
|
||||
if (el.type === "checkbox") out[el.name] = el.checked;
|
||||
else if (el.dataset.number !== undefined) out[el.name] = Number(el.value);
|
||||
else if (el.dataset.nullable !== undefined) out[el.name] = el.value || null;
|
||||
if (el.type === "checkbox") set(el.name, el.checked);
|
||||
else if (el.dataset.number !== undefined) set(el.name, Number(el.value));
|
||||
else if (el.dataset.nullable !== undefined) set(el.name, el.value || null);
|
||||
else if (el.dataset.list !== undefined)
|
||||
out[el.name] = el.value.split(",").map((v) => v.trim()).filter(Boolean);
|
||||
else out[el.name] = el.value;
|
||||
set(el.name, el.value.split(",").map((v) => v.trim()).filter(Boolean));
|
||||
else set(el.name, el.value);
|
||||
}
|
||||
return out;
|
||||
};
|
||||
@@ -63,10 +71,11 @@
|
||||
out.hidden = false;
|
||||
return;
|
||||
}
|
||||
if (form.dataset.showLink !== undefined && (res.data?.url || res.data?.token)) {
|
||||
const shown = res.data?.url || res.data?.token || res.data?.signing_secret;
|
||||
if (form.dataset.showLink !== undefined && shown) {
|
||||
const out = form.querySelector("[data-link-output]");
|
||||
const input = out.querySelector("[data-link]");
|
||||
input.value = res.data.url || res.data.token;
|
||||
input.value = shown;
|
||||
out.hidden = false;
|
||||
input.select();
|
||||
return;
|
||||
@@ -97,12 +106,26 @@
|
||||
if (del.dataset.confirm && !confirm(del.dataset.confirm)) return;
|
||||
try {
|
||||
await api.delete(del.dataset.delete);
|
||||
location.reload();
|
||||
if (del.dataset.next) location.assign(del.dataset.next);
|
||||
else location.reload();
|
||||
} catch (err) {
|
||||
alert(message(err));
|
||||
}
|
||||
return;
|
||||
}
|
||||
const post = ev.target.closest("[data-post]");
|
||||
if (post) {
|
||||
post.disabled = true;
|
||||
try {
|
||||
await api.post(post.dataset.post);
|
||||
alert(post.dataset.ok);
|
||||
} catch (err) {
|
||||
alert(message(err));
|
||||
} finally {
|
||||
post.disabled = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (ev.target.closest("[data-logout]")) {
|
||||
await api.post("/auth/logout").catch(() => {});
|
||||
location.assign("/login");
|
||||
@@ -121,6 +144,17 @@
|
||||
}
|
||||
});
|
||||
|
||||
// Only the settings of the selected check type are shown and submitted.
|
||||
document.addEventListener("change", (ev) => {
|
||||
const sel = ev.target.closest("[data-type-select]");
|
||||
if (!sel) return;
|
||||
for (const fs of sel.form.querySelectorAll("fieldset[data-type]")) {
|
||||
const active = fs.dataset.type === sel.value;
|
||||
fs.hidden = !active;
|
||||
fs.disabled = !active;
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener("change", async (ev) => {
|
||||
const sel = ev.target.closest("[data-switch-org]");
|
||||
if (!sel) return;
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Status is how a monitor, region or time bucket fared. The values double
|
||||
// as CSS class suffixes.
|
||||
type Status string
|
||||
|
||||
// Statuses.
|
||||
const (
|
||||
StatusUp Status = "up"
|
||||
StatusDegraded Status = "degraded"
|
||||
StatusDown Status = "down"
|
||||
StatusUnknown Status = "unknown"
|
||||
StatusPaused Status = "paused"
|
||||
)
|
||||
|
||||
// Bar is one bucket of an uptime bar chart.
|
||||
type Bar struct {
|
||||
Status Status
|
||||
Title string
|
||||
}
|
||||
|
||||
// Bucket is the raw data behind one bar.
|
||||
type Bucket struct {
|
||||
Start time.Time
|
||||
Total int64
|
||||
OK int64
|
||||
Latency float32
|
||||
}
|
||||
|
||||
// UptimeBars turns buckets into n bars of length step ending at end; gaps
|
||||
// become unknown bars. layout formats bar titles.
|
||||
func UptimeBars(buckets []Bucket, end time.Time, step time.Duration, n int, layout string) []Bar {
|
||||
byStart := make(map[int64]Bucket, len(buckets))
|
||||
for _, b := range buckets {
|
||||
byStart[b.Start.Truncate(step).Unix()] = b
|
||||
}
|
||||
start := end.Truncate(step).Add(-time.Duration(n-1) * step)
|
||||
bars := make([]Bar, n)
|
||||
for i := range bars {
|
||||
t := start.Add(time.Duration(i) * step)
|
||||
b, ok := byStart[t.Unix()]
|
||||
if !ok || b.Total == 0 {
|
||||
bars[i] = Bar{Status: StatusUnknown, Title: t.Format(layout) + " · –"}
|
||||
continue
|
||||
}
|
||||
ratio := float64(b.OK) / float64(b.Total)
|
||||
bars[i] = Bar{Status: ratioStatus(ratio), Title: t.Format(layout) + " · " + Percent(ratio)}
|
||||
}
|
||||
return bars
|
||||
}
|
||||
|
||||
func ratioStatus(r float64) Status {
|
||||
switch {
|
||||
case r >= 0.999:
|
||||
return StatusUp
|
||||
case r >= 0.95:
|
||||
return StatusDegraded
|
||||
}
|
||||
return StatusDown
|
||||
}
|
||||
|
||||
// Percent formats an uptime ratio with the precision people expect from
|
||||
// uptime figures.
|
||||
func Percent(r float64) string {
|
||||
switch {
|
||||
case r >= 1:
|
||||
return "100%"
|
||||
case r >= 0.99:
|
||||
return fmt.Sprintf("%.2f%%", r*100)
|
||||
}
|
||||
return fmt.Sprintf("%.1f%%", r*100)
|
||||
}
|
||||
|
||||
// Uptime returns the overall ratio of buckets, or -1 without data.
|
||||
func Uptime(buckets []Bucket) float64 {
|
||||
var total, ok int64
|
||||
for _, b := range buckets {
|
||||
total += b.Total
|
||||
ok += b.OK
|
||||
}
|
||||
if total == 0 {
|
||||
return -1
|
||||
}
|
||||
return float64(ok) / float64(total)
|
||||
}
|
||||
|
||||
// LatencyLine is a polyline for an SVG of the given size.
|
||||
type LatencyLine struct {
|
||||
Points string
|
||||
MaxMS int
|
||||
Width int
|
||||
Height int
|
||||
}
|
||||
|
||||
// Latency plots the average latency of buckets, oldest first.
|
||||
func Latency(buckets []Bucket, width, height int) LatencyLine {
|
||||
l := LatencyLine{Width: width, Height: height}
|
||||
var max float32
|
||||
for _, b := range buckets {
|
||||
max = maxf(max, b.Latency)
|
||||
}
|
||||
if len(buckets) < 2 || max == 0 {
|
||||
return l
|
||||
}
|
||||
l.MaxMS = int(max)
|
||||
var sb strings.Builder
|
||||
for i, b := range buckets {
|
||||
x := float64(i) * float64(width) / float64(len(buckets)-1)
|
||||
y := float64(height) - float64(b.Latency/max)*float64(height-2) - 1
|
||||
fmt.Fprintf(&sb, "%.1f,%.1f ", x, y)
|
||||
}
|
||||
l.Points = strings.TrimSpace(sb.String())
|
||||
return l
|
||||
}
|
||||
|
||||
func maxf(a, b float32) float32 {
|
||||
if a > b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestUptimeBars(t *testing.T) {
|
||||
end := time.Date(2026, 1, 2, 10, 30, 0, 0, time.UTC)
|
||||
hour := func(h int) time.Time { return time.Date(2026, 1, 2, h, 0, 0, 0, time.UTC) }
|
||||
bars := UptimeBars([]Bucket{
|
||||
{Start: hour(10), Total: 60, OK: 60},
|
||||
{Start: hour(9), Total: 60, OK: 58},
|
||||
{Start: hour(8), Total: 60, OK: 30},
|
||||
}, end, time.Hour, 4, "15:04")
|
||||
want := []Status{StatusUnknown, StatusDown, StatusDegraded, StatusUp}
|
||||
for i, b := range bars {
|
||||
if b.Status != want[i] {
|
||||
t.Errorf("bar %d = %s (%s), want %s", i, b.Status, b.Title, want[i])
|
||||
}
|
||||
}
|
||||
if bars[3].Title != "10:00 · 100%" {
|
||||
t.Errorf("last bar title = %q", bars[3].Title)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPercent(t *testing.T) {
|
||||
for r, want := range map[float64]string{1: "100%", 0.99951: "99.95%", 0.9: "90.0%"} {
|
||||
if got := Percent(r); got != want {
|
||||
t.Errorf("Percent(%v) = %q, want %q", r, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,6 +46,12 @@ templ consoleShell(p Page, me Me) {
|
||||
<span class="text-muted">{ me.Orgs[0].Name }</span>
|
||||
}
|
||||
<nav class="ml-auto flex items-center gap-5">
|
||||
if me.Can["incidents.read"] {
|
||||
<a href="/incidents" class="text-muted hover:text-ink">{ i18n.T(ctx, "incidents.title") }</a>
|
||||
}
|
||||
if me.Can["notifications.read"] {
|
||||
<a href="/settings/channels" class="text-muted hover:text-ink">{ i18n.T(ctx, "channels.title") }</a>
|
||||
}
|
||||
if me.Can["members.read"] {
|
||||
<a href="/settings/members" class="text-muted hover:text-ink">{ i18n.T(ctx, "console.nav.members") }</a>
|
||||
<a href="/settings/roles" class="text-muted hover:text-ink">{ i18n.T(ctx, "console.nav.roles") }</a>
|
||||
@@ -80,13 +86,6 @@ templ consoleShell(p Page, me Me) {
|
||||
}
|
||||
}
|
||||
|
||||
templ Dashboard(p Page, me Me) {
|
||||
@consoleShell(p, me) {
|
||||
<h1 class="text-lg font-semibold">{ i18n.T(ctx, "console.monitors.title") }</h1>
|
||||
<p class="mt-2 text-sm text-muted">{ i18n.T(ctx, "console.monitors.empty") }</p>
|
||||
}
|
||||
}
|
||||
|
||||
// Identity is an SSO sign-in linked to the user in the active organization.
|
||||
type Identity struct {
|
||||
Provider string
|
||||
|
||||
+257
-288
@@ -148,128 +148,130 @@ func consoleShell(p Page, me Me) templ.Component {
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if me.Can["members.read"] {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "<a href=\"/settings/members\" class=\"text-muted hover:text-ink\">")
|
||||
if me.Can["incidents.read"] {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "<a href=\"/incidents\" class=\"text-muted hover:text-ink\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var6 string
|
||||
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.nav.members"))
|
||||
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "incidents.title"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 50, Col: 104}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 50, Col: 93}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "</a> <a href=\"/settings/roles\" class=\"text-muted hover:text-ink\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "</a> ")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
if me.Can["notifications.read"] {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "<a href=\"/settings/channels\" class=\"text-muted hover:text-ink\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var7 string
|
||||
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.nav.roles"))
|
||||
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "channels.title"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 51, Col: 100}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 53, Col: 100}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "</a> ")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "</a> ")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
if len(me.Orgs) > 0 {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "<a href=\"/settings/tokens\" class=\"text-muted hover:text-ink\">")
|
||||
if me.Can["members.read"] {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "<a href=\"/settings/members\" class=\"text-muted hover:text-ink\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var8 string
|
||||
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.nav.tokens"))
|
||||
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.nav.members"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 54, Col: 102}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 56, Col: 104}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "</a> ")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
if me.Can["org.manage"] {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "<a href=\"/settings/regions\" class=\"text-muted hover:text-ink\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "</a> <a href=\"/settings/roles\" class=\"text-muted hover:text-ink\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var9 string
|
||||
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.nav.regions"))
|
||||
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.nav.roles"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 57, Col: 104}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 57, Col: 100}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "</a> <a href=\"/settings/org\" class=\"text-muted hover:text-ink\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "</a> ")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
if len(me.Orgs) > 0 {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "<a href=\"/settings/tokens\" class=\"text-muted hover:text-ink\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var10 string
|
||||
templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.nav.org"))
|
||||
templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.nav.tokens"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 58, Col: 96}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 60, Col: 102}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "</a> <a href=\"/settings/sso\" class=\"text-muted hover:text-ink\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var11 string
|
||||
templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.nav.sso"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 59, Col: 96}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "</a> ")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "<a href=\"/settings/security\" class=\"text-muted hover:text-ink\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var12 string
|
||||
templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.nav.security"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 61, Col: 105}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "</a> ")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if me.IsAdmin {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "<a href=\"/admin\" class=\"font-medium hover:underline\">")
|
||||
if me.Can["org.manage"] {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "<a href=\"/settings/regions\" class=\"text-muted hover:text-ink\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var11 string
|
||||
templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.nav.regions"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 63, Col: 104}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "</a> <a href=\"/settings/org\" class=\"text-muted hover:text-ink\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var12 string
|
||||
templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.nav.org"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 64, Col: 96}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "</a> <a href=\"/settings/sso\" class=\"text-muted hover:text-ink\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var13 string
|
||||
templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.nav.admin"))
|
||||
templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.nav.sso"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 63, Col: 93}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 65, Col: 96}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -280,20 +282,56 @@ func consoleShell(p Page, me Me) templ.Component {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "<button data-logout class=\"text-muted hover:text-ink\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "<a href=\"/settings/security\" class=\"text-muted hover:text-ink\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var14 string
|
||||
templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.nav.logout"))
|
||||
templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.nav.security"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 65, Col: 94}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 67, Col: 105}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "</button>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "</a> ")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if me.IsAdmin {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "<a href=\"/admin\" class=\"font-medium hover:underline\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var15 string
|
||||
templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.nav.admin"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 69, Col: 93}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "</a> ")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "<button data-logout class=\"text-muted hover:text-ink\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var16 string
|
||||
templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.nav.logout"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 71, Col: 94}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "</button>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -301,7 +339,7 @@ func consoleShell(p Page, me Me) templ.Component {
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "</nav></div></header>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "</nav></div></header>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -317,7 +355,7 @@ func consoleShell(p Page, me Me) templ.Component {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, " <main class=\"mx-auto max-w-5xl px-6 py-10\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, " <main class=\"mx-auto max-w-5xl px-6 py-10\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -329,7 +367,7 @@ func consoleShell(p Page, me Me) templ.Component {
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "</main>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "</main>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -343,75 +381,6 @@ func consoleShell(p Page, me Me) templ.Component {
|
||||
})
|
||||
}
|
||||
|
||||
func Dashboard(p Page, me Me) 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_Var16 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "<h1 class=\"text-lg font-semibold\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var17 string
|
||||
templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.monitors.title"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 85, Col: 75}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "</h1><p class=\"mt-2 text-sm text-muted\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var18 string
|
||||
templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.monitors.empty"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 86, Col: 76}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, "</p>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
templ_7745c5c3_Err = consoleShell(p, me).Render(templ.WithChildren(ctx, templ_7745c5c3_Var16), templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// Identity is an SSO sign-in linked to the user in the active organization.
|
||||
type Identity struct {
|
||||
Provider string
|
||||
@@ -435,7 +404,7 @@ func Security(p Page, me Me, identities []Identity, canLink bool) templ.Componen
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Var20 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_Var18 := 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 {
|
||||
@@ -447,51 +416,51 @@ func Security(p Page, me Me, identities []Identity, canLink bool) templ.Componen
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "<h1 class=\"mb-8 text-lg font-semibold\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "<h1 class=\"mb-8 text-lg font-semibold\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var21 string
|
||||
templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.title"))
|
||||
var templ_7745c5c3_Var19 string
|
||||
templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.title"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 98, Col: 72}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 97, Col: 72}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21))
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "</h1><section class=\"max-w-md\"><h2 class=\"mb-1 text-xs font-medium uppercase tracking-wider text-muted\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "</h1><section class=\"max-w-md\"><h2 class=\"mb-1 text-xs font-medium uppercase tracking-wider text-muted\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var22 string
|
||||
templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.totp.heading"))
|
||||
var templ_7745c5c3_Var20 string
|
||||
templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.totp.heading"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 100, Col: 114}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 99, Col: 114}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22))
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "</h2>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, "</h2>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if me.TOTP {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, "<p class=\"mb-1 text-sm\"><span class=\"text-up\">●</span> ")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, "<p class=\"mb-1 text-sm\"><span class=\"text-up\">●</span> ")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var23 string
|
||||
templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.totp.active"))
|
||||
var templ_7745c5c3_Var21 string
|
||||
templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.totp.active"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 102, Col: 98}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 101, Col: 98}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23))
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, "</p>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 38, "</p>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -499,25 +468,25 @@ func Security(p Page, me Me, identities []Identity, canLink bool) templ.Componen
|
||||
templ_7745c5c3_ElementWriter := templ_7745c5c3_Buffer
|
||||
templ_7745c5c3_Buffer := templ.GetBuffer()
|
||||
var templ_7745c5c3_ElementScripts []templ.ComponentScript
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 38, "<p class=\"")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "<p class=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var24 = []any{"mb-6 text-sm", templ.KV("text-down", me.RecoveryCodesLeft < 3), templ.KV("text-muted", me.RecoveryCodesLeft >= 3)}
|
||||
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_ElementWriter, templ_7745c5c3_Var24...)
|
||||
var templ_7745c5c3_Var22 = []any{"mb-6 text-sm", templ.KV("text-down", me.RecoveryCodesLeft < 3), templ.KV("text-muted", me.RecoveryCodesLeft >= 3)}
|
||||
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_ElementWriter, templ_7745c5c3_Var22...)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var25 string
|
||||
templ_7745c5c3_Var25, templ_7745c5c3_Err = templruntime.NewAttributeExpression(templ.CSSClasses(templ_7745c5c3_Var24).String()).Resolve(ctx)
|
||||
var templ_7745c5c3_Var23 string
|
||||
templ_7745c5c3_Var23, templ_7745c5c3_Err = templruntime.NewAttributeExpression(templ.CSSClasses(templ_7745c5c3_Var22).String()).Resolve(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 1, Col: 0}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var25)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var23)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "\"")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 40, "\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -531,33 +500,33 @@ func Security(p Page, me Me, identities []Identity, canLink bool) templ.Componen
|
||||
}
|
||||
templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 40, ">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 41, ">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var26 string
|
||||
templ_7745c5c3_Var26, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.recovery.left", "Count", me.RecoveryCodesLeft))
|
||||
var templ_7745c5c3_Var24 string
|
||||
templ_7745c5c3_Var24, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.recovery.left", "Count", me.RecoveryCodesLeft))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 104, Col: 75}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 103, Col: 75}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var26))
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var24))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 41, "</p><details class=\"mb-6\"><summary class=\"cursor-pointer text-sm text-muted hover:text-ink\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 42, "</p><details class=\"mb-6\"><summary class=\"cursor-pointer text-sm text-muted hover:text-ink\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var27 string
|
||||
templ_7745c5c3_Var27, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.recovery.regenerate"))
|
||||
var templ_7745c5c3_Var25 string
|
||||
templ_7745c5c3_Var25, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.recovery.regenerate"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 107, Col: 116}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 106, Col: 116}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var27))
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var25))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 42, "</summary><form data-api=\"/me/totp/recovery-codes\" data-show-codes class=\"mt-4\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 43, "</summary><form data-api=\"/me/totp/recovery-codes\" data-show-codes class=\"mt-4\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -581,20 +550,20 @@ func Security(p Page, me Me, identities []Identity, canLink bool) templ.Componen
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 43, "</form></details> <details><summary class=\"cursor-pointer text-sm text-muted hover:text-ink\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 44, "</form></details> <details><summary class=\"cursor-pointer text-sm text-muted hover:text-ink\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var28 string
|
||||
templ_7745c5c3_Var28, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.totp.disable"))
|
||||
var templ_7745c5c3_Var26 string
|
||||
templ_7745c5c3_Var26, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.totp.disable"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 117, Col: 109}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 116, Col: 109}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var28))
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var26))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 44, "</summary><form data-api=\"/me/totp/disable\" data-next=\"/settings/security\" class=\"mt-4\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 45, "</summary><form data-api=\"/me/totp/disable\" data-next=\"/settings/security\" class=\"mt-4\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -614,51 +583,51 @@ func Security(p Page, me Me, identities []Identity, canLink bool) templ.Componen
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 45, "</form></details>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 46, "</form></details>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
} else {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 46, "<p class=\"mb-6 text-sm\"><span class=\"text-unknown\">●</span> ")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 47, "<p class=\"mb-6 text-sm\"><span class=\"text-unknown\">●</span> ")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var27 string
|
||||
templ_7745c5c3_Var27, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.totp.inactive"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 125, Col: 105}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var27))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 48, "</p><div data-totp-setup><button data-totp-start class=\"border border-ink px-3 py-1.5 text-sm hover:bg-ink hover:text-paper\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var28 string
|
||||
templ_7745c5c3_Var28, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.totp.start"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 127, Col: 141}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var28))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 49, "</button><div data-totp-panel hidden><img data-totp-qr alt=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var29 string
|
||||
templ_7745c5c3_Var29, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.totp.inactive"))
|
||||
templ_7745c5c3_Var29, templ_7745c5c3_Err = templruntime.NewAttributeExpression(i18n.T(ctx, "security.totp.qr_alt")).Resolve(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 126, Col: 105}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 129, Col: 65}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var29))
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var29)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 47, "</p><div data-totp-setup><button data-totp-start class=\"border border-ink px-3 py-1.5 text-sm hover:bg-ink hover:text-paper\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var30 string
|
||||
templ_7745c5c3_Var30, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.totp.start"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 128, Col: 141}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var30))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 48, "</button><div data-totp-panel hidden><img data-totp-qr alt=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var31 string
|
||||
templ_7745c5c3_Var31, templ_7745c5c3_Err = templruntime.NewAttributeExpression(i18n.T(ctx, "security.totp.qr_alt")).Resolve(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 130, Col: 65}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var31)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 49, "\" class=\"mb-3 h-48 w-48 border border-rule bg-white p-2\"><p class=\"mb-6 break-all font-mono text-xs text-muted\" data-totp-secret></p><form data-api=\"/me/totp/enable\" data-show-codes>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 50, "\" class=\"mb-3 h-48 w-48 border border-rule bg-white p-2\"><p class=\"mb-6 break-all font-mono text-xs text-muted\" data-totp-secret></p><form data-api=\"/me/totp/enable\" data-show-codes>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -678,127 +647,127 @@ func Security(p Page, me Me, identities []Identity, canLink bool) templ.Componen
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 50, "</form></div></div>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 51, "</form></div></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 51, "</section><section class=\"mt-12 max-w-md\"><h2 class=\"mb-3 text-xs font-medium uppercase tracking-wider text-muted\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 52, "</section><section class=\"mt-12 max-w-md\"><h2 class=\"mb-3 text-xs font-medium uppercase tracking-wider text-muted\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var32 string
|
||||
templ_7745c5c3_Var32, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.sso.heading"))
|
||||
var templ_7745c5c3_Var30 string
|
||||
templ_7745c5c3_Var30, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.sso.heading"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 143, Col: 113}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 142, Col: 113}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var32))
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var30))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 52, "</h2>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 53, "</h2>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if len(identities) == 0 {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 53, "<p class=\"mb-4 text-sm text-muted\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 54, "<p class=\"mb-4 text-sm text-muted\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var33 string
|
||||
templ_7745c5c3_Var33, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.sso.none"))
|
||||
var templ_7745c5c3_Var31 string
|
||||
templ_7745c5c3_Var31, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.sso.none"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 145, Col: 73}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 144, Col: 73}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var33))
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var31))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 54, "</p>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 55, "</p>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
} else {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 55, "<ul class=\"mb-4 divide-y divide-rule border-y border-rule text-sm\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 56, "<ul class=\"mb-4 divide-y divide-rule border-y border-rule text-sm\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
for _, id := range identities {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 56, "<li class=\"flex justify-between gap-4 py-2\"><span>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 57, "<li class=\"flex justify-between gap-4 py-2\"><span>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var34 string
|
||||
templ_7745c5c3_Var34, templ_7745c5c3_Err = templ.JoinStringErrs(id.Provider)
|
||||
var templ_7745c5c3_Var32 string
|
||||
templ_7745c5c3_Var32, templ_7745c5c3_Err = templ.JoinStringErrs(id.Provider)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 149, Col: 69}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 148, Col: 69}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var34))
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var32))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 57, "</span><span class=\"font-mono text-xs text-muted\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 58, "</span><span class=\"font-mono text-xs text-muted\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var35 string
|
||||
templ_7745c5c3_Var35, templ_7745c5c3_Err = templ.JoinStringErrs(id.Email)
|
||||
var templ_7745c5c3_Var33 string
|
||||
templ_7745c5c3_Var33, templ_7745c5c3_Err = templ.JoinStringErrs(id.Email)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 149, Col: 131}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 148, Col: 131}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var35))
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var33))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 58, "</span></li>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 59, "</span></li>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 59, "</ul>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 60, "</ul>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
if canLink {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 60, "<a href=\"")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 61, "<a href=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var36 string
|
||||
templ_7745c5c3_Var36, templ_7745c5c3_Err = templruntime.NewAttributeExpression(templ.SafeURL("/sso/" + me.ActiveSlug + "?link=1")).ResolveURL(ctx)
|
||||
var templ_7745c5c3_Var34 string
|
||||
templ_7745c5c3_Var34, templ_7745c5c3_Err = templruntime.NewAttributeExpression(templ.SafeURL("/sso/" + me.ActiveSlug + "?link=1")).ResolveURL(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 154, Col: 64}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 153, Col: 64}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var36)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var34)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 61, "\" class=\"inline-block border border-ink px-3 py-1.5 text-sm hover:bg-ink hover:text-paper\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 62, "\" class=\"inline-block border border-ink px-3 py-1.5 text-sm hover:bg-ink hover:text-paper\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var37 string
|
||||
templ_7745c5c3_Var37, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.sso.link"))
|
||||
var templ_7745c5c3_Var35 string
|
||||
templ_7745c5c3_Var35, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.sso.link"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 154, Col: 190}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 153, Col: 190}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var37))
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var35))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 62, "</a>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 63, "</a>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 63, "</section>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 64, "</section>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
templ_7745c5c3_Err = consoleShell(p, me).Render(templ.WithChildren(ctx, templ_7745c5c3_Var20), templ_7745c5c3_Buffer)
|
||||
templ_7745c5c3_Err = consoleShell(p, me).Render(templ.WithChildren(ctx, templ_7745c5c3_Var18), templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -825,33 +794,33 @@ func recoveryOutput() templ.Component {
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 64, "<div data-recovery-output hidden class=\"mt-6 border border-ink p-4\"><p class=\"mb-3 text-sm\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 65, "<div data-recovery-output hidden class=\"mt-6 border border-ink p-4\"><p class=\"mb-3 text-sm\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var39 string
|
||||
templ_7745c5c3_Var39, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.recovery.save_now"))
|
||||
var templ_7745c5c3_Var37 string
|
||||
templ_7745c5c3_Var37, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.recovery.save_now"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 164, Col: 69}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 163, Col: 69}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var39))
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var37))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 65, "</p><ol data-recovery-list class=\"mb-4 grid grid-cols-2 gap-x-6 gap-y-1 font-mono text-sm\"></ol><a href=\"/settings/security\" class=\"text-sm underline underline-offset-2\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 66, "</p><ol data-recovery-list class=\"mb-4 grid grid-cols-2 gap-x-6 gap-y-1 font-mono text-sm\"></ol><a href=\"/settings/security\" class=\"text-sm underline underline-offset-2\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var40 string
|
||||
templ_7745c5c3_Var40, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.recovery.saved"))
|
||||
var templ_7745c5c3_Var38 string
|
||||
templ_7745c5c3_Var38, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.recovery.saved"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 166, Col: 116}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 165, Col: 116}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var40))
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var38))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 66, "</a></div>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 67, "</a></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -876,46 +845,46 @@ func policyBanner(msgID, actionID, href string) templ.Component {
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 67, "<div class=\"border-b border-degraded/40 bg-degraded/10\"><p class=\"mx-auto max-w-5xl px-6 py-2 text-sm\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 68, "<div class=\"border-b border-degraded/40 bg-degraded/10\"><p class=\"mx-auto max-w-5xl px-6 py-2 text-sm\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var40 string
|
||||
templ_7745c5c3_Var40, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, msgID))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 172, Col: 23}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var40))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 69, " <a href=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var41 string
|
||||
templ_7745c5c3_Var41, templ_7745c5c3_Err = templruntime.NewAttributeExpression(templ.SafeURL(href)).ResolveURL(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 173, Col: 32}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var41)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 70, "\" class=\"underline underline-offset-2\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var42 string
|
||||
templ_7745c5c3_Var42, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, msgID))
|
||||
templ_7745c5c3_Var42, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, actionID))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 173, Col: 23}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 173, Col: 95}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var42))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 68, " <a href=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var43 string
|
||||
templ_7745c5c3_Var43, templ_7745c5c3_Err = templruntime.NewAttributeExpression(templ.SafeURL(href)).ResolveURL(ctx)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 174, Col: 32}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var43)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 69, "\" class=\"underline underline-offset-2\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var44 string
|
||||
templ_7745c5c3_Var44, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, actionID))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 174, Col: 95}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var44))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 70, "</a></p></div>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 71, "</a></p></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
||||
@@ -0,0 +1,519 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/i18n"
|
||||
)
|
||||
|
||||
// RegionStatus is the latest result of one region.
|
||||
type RegionStatus struct {
|
||||
Name string
|
||||
Status Status
|
||||
Detail string
|
||||
}
|
||||
|
||||
// MonitorRow is a monitor on the dashboard.
|
||||
type MonitorRow struct {
|
||||
ID string
|
||||
Name string
|
||||
Type string
|
||||
Target string
|
||||
Status Status
|
||||
Regions []RegionStatus
|
||||
Latency string
|
||||
Uptime string
|
||||
Bars []Bar
|
||||
}
|
||||
|
||||
// DashboardView is the data of the monitor list.
|
||||
type DashboardView struct {
|
||||
Monitors []MonitorRow
|
||||
CanWrite bool
|
||||
Counts map[Status]int
|
||||
}
|
||||
|
||||
templ statusDot(s Status) {
|
||||
<span
|
||||
class={ "inline-block h-2 w-2 shrink-0 rounded-full",
|
||||
templ.KV("bg-up", s == StatusUp),
|
||||
templ.KV("bg-degraded", s == StatusDegraded),
|
||||
templ.KV("bg-down", s == StatusDown),
|
||||
templ.KV("bg-unknown", s == StatusUnknown),
|
||||
templ.KV("border border-unknown", s == StatusPaused) }
|
||||
title={ i18n.T(ctx, "status."+string(s)) }
|
||||
></span>
|
||||
}
|
||||
|
||||
templ bars(bs []Bar, height int) {
|
||||
<svg
|
||||
viewBox={ "0 0 " + strconv.Itoa(len(bs)*4) + " " + strconv.Itoa(height) }
|
||||
preserveAspectRatio="none"
|
||||
class="block w-full"
|
||||
style={ "height:" + strconv.Itoa(height) + "px" }
|
||||
role="img"
|
||||
aria-label={ i18n.T(ctx, "monitors.uptime_chart") }
|
||||
>
|
||||
for i, b := range bs {
|
||||
<rect
|
||||
x={ strconv.Itoa(i*4) }
|
||||
y="0"
|
||||
width="3"
|
||||
height={ strconv.Itoa(height) }
|
||||
class={ templ.KV("fill-up", b.Status == StatusUp),
|
||||
templ.KV("fill-degraded", b.Status == StatusDegraded),
|
||||
templ.KV("fill-down", b.Status == StatusDown),
|
||||
templ.KV("fill-rule", b.Status == StatusUnknown) }
|
||||
>
|
||||
<title>{ b.Title }</title>
|
||||
</rect>
|
||||
}
|
||||
</svg>
|
||||
}
|
||||
|
||||
templ Dashboard(p Page, me Me, v DashboardView) {
|
||||
@consoleShell(p, me) {
|
||||
<div class="mb-6 flex items-baseline justify-between gap-4">
|
||||
<h1 class="text-lg font-semibold">{ i18n.T(ctx, "console.monitors.title") }</h1>
|
||||
<div class="flex items-center gap-5 font-mono text-xs text-muted">
|
||||
for _, s := range []Status{StatusUp, StatusDegraded, StatusDown, StatusPaused} {
|
||||
if v.Counts[s] > 0 {
|
||||
<span class="flex items-center gap-1.5">
|
||||
@statusDot(s)
|
||||
<span>{ strconv.Itoa(v.Counts[s]) }</span>
|
||||
</span>
|
||||
}
|
||||
}
|
||||
if v.CanWrite {
|
||||
<a href="/monitors/new" class="bg-ink px-3 py-1.5 font-sans text-sm text-paper hover:opacity-90">{ i18n.T(ctx, "monitors.new") }</a>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
if len(v.Monitors) == 0 {
|
||||
<p class="border-y border-rule py-10 text-center text-sm text-muted">{ i18n.T(ctx, "console.monitors.empty") }</p>
|
||||
} else {
|
||||
<ul class="divide-y divide-rule border-y border-rule">
|
||||
for _, m := range v.Monitors {
|
||||
<li>
|
||||
<a href={ templ.SafeURL("/monitors/" + m.ID) } class="grid grid-cols-[1fr_auto] items-center gap-x-6 gap-y-2 py-3 hover:bg-rule/30 md:grid-cols-[minmax(0,2fr)_minmax(0,3fr)_6rem_5rem]">
|
||||
<span class="flex min-w-0 items-center gap-2.5">
|
||||
@statusDot(m.Status)
|
||||
<span class="min-w-0">
|
||||
<span class="block truncate">{ m.Name }</span>
|
||||
<span class="block truncate font-mono text-xs text-muted">{ m.Type } · { m.Target }</span>
|
||||
</span>
|
||||
</span>
|
||||
<span class="col-span-2 md:col-span-1">@bars(m.Bars, 18)</span>
|
||||
<span class="hidden text-right font-mono text-xs text-muted md:block">{ m.Latency }</span>
|
||||
<span class="row-start-1 text-right font-mono text-sm md:row-auto">{ m.Uptime }</span>
|
||||
</a>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
<p class="mt-3 text-right text-xs text-muted">{ i18n.T(ctx, "monitors.last_24h") }</p>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ResultRow is one check result on the detail page.
|
||||
type ResultRow struct {
|
||||
Time string
|
||||
Region string
|
||||
OK bool
|
||||
Latency string
|
||||
Detail string
|
||||
}
|
||||
|
||||
// IncidentRow is an incident in a list.
|
||||
type IncidentRow struct {
|
||||
ID string
|
||||
MonitorID string
|
||||
Monitor string
|
||||
Started string
|
||||
Duration string
|
||||
Open bool
|
||||
Cause []string
|
||||
}
|
||||
|
||||
// MonitorDetailView is the data of a monitor page.
|
||||
type MonitorDetailView struct {
|
||||
Row MonitorRow
|
||||
Interval string
|
||||
Daily []Bar
|
||||
Uptime90 string
|
||||
Latency LatencyLine
|
||||
Recent []ResultRow
|
||||
Incidents []IncidentRow
|
||||
CanWrite bool
|
||||
}
|
||||
|
||||
templ MonitorDetail(p Page, me Me, v MonitorDetailView) {
|
||||
@consoleShell(p, me) {
|
||||
<p class="mb-4 text-sm"><a href="/" class="text-muted hover:text-ink">← { i18n.T(ctx, "console.monitors.title") }</a></p>
|
||||
<div class="mb-8 flex flex-wrap items-start justify-between gap-4">
|
||||
<div>
|
||||
<h1 class="flex items-center gap-2.5 text-lg font-semibold">
|
||||
@statusDot(v.Row.Status)
|
||||
<span>{ v.Row.Name }</span>
|
||||
</h1>
|
||||
<p class="mt-1 font-mono text-xs text-muted">{ v.Row.Type } · { v.Row.Target } · { v.Interval }</p>
|
||||
</div>
|
||||
if v.CanWrite {
|
||||
<a href={ templ.SafeURL("/monitors/" + v.Row.ID + "/edit") } class="border border-ink px-3 py-1.5 text-sm hover:bg-ink hover:text-paper">{ i18n.T(ctx, "sso.action.edit") }</a>
|
||||
}
|
||||
</div>
|
||||
<section class="mb-10">
|
||||
<div class="mb-2 flex items-baseline justify-between">
|
||||
@sectionHeading("monitors.last_90d")
|
||||
<span class="font-mono text-sm">{ v.Uptime90 }</span>
|
||||
</div>
|
||||
@bars(v.Daily, 28)
|
||||
</section>
|
||||
<div class="mb-10 grid gap-10 md:grid-cols-2">
|
||||
<section>
|
||||
@sectionHeading("monitors.regions")
|
||||
<ul class="divide-y divide-rule border-y border-rule text-sm">
|
||||
for _, r := range v.Row.Regions {
|
||||
<li class="flex items-center gap-2.5 py-2">
|
||||
@statusDot(r.Status)
|
||||
<span>{ r.Name }</span>
|
||||
<span class="ml-auto truncate font-mono text-xs text-muted">{ r.Detail }</span>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
</section>
|
||||
<section>
|
||||
<div class="mb-4 flex items-baseline justify-between">
|
||||
@sectionHeading("monitors.latency_24h")
|
||||
if v.Latency.MaxMS > 0 {
|
||||
<span class="font-mono text-xs text-muted">max { strconv.Itoa(v.Latency.MaxMS) } ms</span>
|
||||
}
|
||||
</div>
|
||||
if v.Latency.Points != "" {
|
||||
<svg viewBox={ "0 0 " + strconv.Itoa(v.Latency.Width) + " " + strconv.Itoa(v.Latency.Height) } preserveAspectRatio="none" class="block h-24 w-full border-b border-rule">
|
||||
<polyline points={ v.Latency.Points } fill="none" class="stroke-ink" stroke-width="1.5" vector-effect="non-scaling-stroke"></polyline>
|
||||
</svg>
|
||||
} else {
|
||||
<p class="text-sm text-muted">–</p>
|
||||
}
|
||||
</section>
|
||||
</div>
|
||||
if len(v.Incidents) > 0 {
|
||||
<section class="mb-10">
|
||||
@sectionHeading("incidents.title")
|
||||
@incidentList(v.Incidents, false)
|
||||
</section>
|
||||
}
|
||||
<section>
|
||||
@sectionHeading("monitors.recent")
|
||||
<table class="w-full text-left text-sm">
|
||||
<tbody class="divide-y divide-rule border-y border-rule">
|
||||
for _, r := range v.Recent {
|
||||
<tr>
|
||||
<td class="py-1.5 pr-4 font-mono text-xs whitespace-nowrap text-muted">{ r.Time }</td>
|
||||
<td class="py-1.5 pr-4">{ r.Region }</td>
|
||||
<td class="py-1.5 pr-4">
|
||||
if r.OK {
|
||||
<span class="text-up">●</span>
|
||||
} else {
|
||||
<span class="text-down">●</span>
|
||||
}
|
||||
</td>
|
||||
<td class="py-1.5 pr-4 font-mono text-xs">{ r.Latency }</td>
|
||||
<td class="py-1.5 font-mono text-xs text-muted">{ r.Detail }</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
}
|
||||
}
|
||||
|
||||
templ incidentList(rows []IncidentRow, showMonitor bool) {
|
||||
<ul class="divide-y divide-rule border-y border-rule text-sm">
|
||||
for _, r := range rows {
|
||||
<li class="py-2.5">
|
||||
<div class="flex flex-wrap items-baseline gap-x-4 gap-y-1">
|
||||
if r.Open {
|
||||
<span class="font-medium text-down">{ i18n.T(ctx, "incidents.ongoing") }</span>
|
||||
} else {
|
||||
<span class="text-up">{ i18n.T(ctx, "incidents.resolved") }</span>
|
||||
}
|
||||
if showMonitor {
|
||||
<a href={ templ.SafeURL("/monitors/" + r.MonitorID) } class="hover:underline">{ r.Monitor }</a>
|
||||
}
|
||||
<span class="font-mono text-xs text-muted">{ r.Started }</span>
|
||||
<span class="ml-auto font-mono text-xs">{ r.Duration }</span>
|
||||
</div>
|
||||
if len(r.Cause) > 0 {
|
||||
<p class="mt-1 font-mono text-xs text-muted">{ strings.Join(r.Cause, " · ") }</p>
|
||||
}
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
|
||||
templ IncidentsPage(p Page, me Me, rows []IncidentRow) {
|
||||
@consoleShell(p, me) {
|
||||
@settingsHeading("incidents.title", "")
|
||||
if len(rows) == 0 {
|
||||
<p class="border-y border-rule py-10 text-center text-sm text-muted">{ i18n.T(ctx, "incidents.none") }</p>
|
||||
} else {
|
||||
@incidentList(rows, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// RegionOption is a selectable region in the monitor form.
|
||||
type RegionOption struct {
|
||||
ID string
|
||||
Name string
|
||||
Own bool
|
||||
Checked bool
|
||||
Live int64
|
||||
}
|
||||
|
||||
// MonitorForm is the data of the monitor editor; ID is empty for new ones.
|
||||
type MonitorForm struct {
|
||||
ID string
|
||||
Name string
|
||||
Type string
|
||||
Target string
|
||||
IntervalSeconds int
|
||||
TimeoutMS int
|
||||
Confirmations int
|
||||
Enabled bool
|
||||
Regions []RegionOption
|
||||
MinInterval int
|
||||
// Type-specific settings.
|
||||
Method string
|
||||
ExpectStatus string
|
||||
Keyword string
|
||||
KeywordAbsent bool
|
||||
FollowRedirects bool
|
||||
VerifyTLS bool
|
||||
DNSRecord string
|
||||
DNSResolver string
|
||||
DNSExpect string
|
||||
TLSMinDays int
|
||||
TLSServerName string
|
||||
}
|
||||
|
||||
templ typeFields(typ, current string) {
|
||||
<fieldset data-type={ typ } disabled?={ typ != current } hidden?={ typ != current } class="mb-2">
|
||||
{ children... }
|
||||
</fieldset>
|
||||
}
|
||||
|
||||
templ numberField(label, name string, value, min, max int, hint string) {
|
||||
<label class="mb-4 block">
|
||||
<span class="mb-1 block text-xs font-medium uppercase tracking-wider text-muted">{ label }</span>
|
||||
<input
|
||||
type="number"
|
||||
name={ name }
|
||||
data-number
|
||||
value={ strconv.Itoa(value) }
|
||||
min={ strconv.Itoa(min) }
|
||||
max={ strconv.Itoa(max) }
|
||||
class="w-40 border border-rule bg-transparent px-2.5 py-1.5 font-mono text-sm outline-none focus:border-ink"
|
||||
/>
|
||||
if hint != "" {
|
||||
<span class="mt-1 block text-xs text-muted">{ hint }</span>
|
||||
}
|
||||
</label>
|
||||
}
|
||||
|
||||
templ MonitorEditor(p Page, me Me, f MonitorForm) {
|
||||
@consoleShell(p, me) {
|
||||
<p class="mb-4 text-sm">
|
||||
if f.ID == "" {
|
||||
<a href="/" class="text-muted hover:text-ink">← { i18n.T(ctx, "console.monitors.title") }</a>
|
||||
} else {
|
||||
<a href={ templ.SafeURL("/monitors/" + f.ID) } class="text-muted hover:text-ink">← { f.Name }</a>
|
||||
}
|
||||
</p>
|
||||
<h1 class="mb-8 text-lg font-semibold">{ i18n.T(ctx, p.TitleID) }</h1>
|
||||
<form
|
||||
if f.ID == "" {
|
||||
data-api="/org/monitors"
|
||||
data-next="/"
|
||||
} else {
|
||||
data-api={ "/org/monitors/" + f.ID }
|
||||
data-method="put"
|
||||
data-next={ "/monitors/" + f.ID }
|
||||
}
|
||||
class="grid max-w-4xl gap-x-12 md:grid-cols-2"
|
||||
>
|
||||
<div>
|
||||
@formError()
|
||||
@valueField(i18n.T(ctx, "sso.field.name"), "name", f.Name, "", true)
|
||||
<label class="mb-4 block">
|
||||
<span class="mb-1 block text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "monitors.type") }</span>
|
||||
<select name="type" data-type-select class="w-full border border-rule bg-transparent px-2 py-1.5 text-sm">
|
||||
for _, t := range []string{"http", "tcp", "tls", "dns", "icmp"} {
|
||||
<option value={ t } selected?={ t == f.Type }>{ i18n.T(ctx, "monitors.type_"+t) }</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
@valueField(i18n.T(ctx, "monitors.target"), "target", f.Target, "https://example.com", true)
|
||||
<p class="-mt-3 mb-4 text-xs text-muted">{ i18n.T(ctx, "monitors.target_hint") }</p>
|
||||
@typeFields("http", f.Type) {
|
||||
<label class="mb-4 block">
|
||||
<span class="mb-1 block text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "monitors.method") }</span>
|
||||
<select name="config.method" class="w-40 border border-rule bg-transparent px-2 py-1.5 text-sm">
|
||||
<option value="GET" selected?={ f.Method != "HEAD" }>GET</option>
|
||||
<option value="HEAD" selected?={ f.Method == "HEAD" }>HEAD</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="mb-4 block">
|
||||
<span class="mb-1 block text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "monitors.expect_status") }</span>
|
||||
<input name="config.expect_status" data-list value={ f.ExpectStatus } class="w-full border border-rule bg-transparent px-2.5 py-1.5 font-mono text-sm outline-none focus:border-ink"/>
|
||||
</label>
|
||||
@valueField(i18n.T(ctx, "monitors.keyword"), "config.keyword", f.Keyword, "", false)
|
||||
@checkbox(i18n.T(ctx, "monitors.keyword_absent"), "config.keyword_absent", f.KeywordAbsent)
|
||||
@checkbox(i18n.T(ctx, "monitors.follow_redirects"), "config.follow_redirects", f.FollowRedirects)
|
||||
@checkbox(i18n.T(ctx, "monitors.verify_tls"), "config.verify_tls", f.VerifyTLS)
|
||||
}
|
||||
@typeFields("dns", f.Type) {
|
||||
<label class="mb-4 block">
|
||||
<span class="mb-1 block text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "monitors.dns_record") }</span>
|
||||
<select name="config.record" class="w-40 border border-rule bg-transparent px-2 py-1.5 text-sm">
|
||||
for _, r := range []string{"A", "AAAA", "CNAME", "MX", "NS", "TXT"} {
|
||||
<option value={ r } selected?={ r == f.DNSRecord }>{ r }</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
@valueField(i18n.T(ctx, "monitors.dns_resolver"), "config.resolver", f.DNSResolver, "1.1.1.1:53", false)
|
||||
@valueField(i18n.T(ctx, "monitors.dns_expect"), "config.expect", f.DNSExpect, "", false)
|
||||
}
|
||||
@typeFields("tls", f.Type) {
|
||||
@numberField(i18n.T(ctx, "monitors.tls_min_days"), "config.min_days_valid", f.TLSMinDays, 0, 365, "")
|
||||
@valueField(i18n.T(ctx, "monitors.tls_server_name"), "config.server_name", f.TLSServerName, "", false)
|
||||
}
|
||||
</div>
|
||||
<div>
|
||||
@numberField(i18n.T(ctx, "monitors.interval"), "interval_seconds", f.IntervalSeconds, f.MinInterval, 86400, i18n.T(ctx, "monitors.interval_hint", "Min", f.MinInterval))
|
||||
@numberField(i18n.T(ctx, "monitors.timeout"), "timeout_ms", f.TimeoutMS, 100, 60000, "")
|
||||
@numberField(i18n.T(ctx, "monitors.confirmations"), "confirmations", f.Confirmations, 1, 10, i18n.T(ctx, "monitors.confirmations_hint"))
|
||||
<fieldset class="mb-4">
|
||||
<legend class="mb-1 block text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "monitors.regions") }</legend>
|
||||
<p class="mb-2 text-xs text-muted">{ i18n.T(ctx, "monitors.regions_hint") }</p>
|
||||
for _, r := range f.Regions {
|
||||
<label class="mb-1.5 flex items-center gap-2 text-sm">
|
||||
<input type="checkbox" name="regions" value={ r.ID } data-multi checked?={ r.Checked } class="accent-ink"/>
|
||||
{ r.Name }
|
||||
<span class="font-mono text-xs text-muted">
|
||||
if r.Own {
|
||||
{ i18n.T(ctx, "regions.own") }
|
||||
} else {
|
||||
{ i18n.T(ctx, "regions.platform") }
|
||||
}
|
||||
· { i18n.T(ctx, "regions.live", "Count", int(r.Live)) }
|
||||
</span>
|
||||
</label>
|
||||
}
|
||||
</fieldset>
|
||||
@checkbox(i18n.T(ctx, "sso.field.enabled"), "enabled", f.Enabled)
|
||||
@submit(i18n.T(ctx, "common.save"))
|
||||
if f.ID != "" {
|
||||
<button
|
||||
type="button"
|
||||
data-delete={ "/org/monitors/" + f.ID }
|
||||
data-confirm={ i18n.T(ctx, "monitors.delete_confirm") }
|
||||
data-next="/"
|
||||
class="mt-6 text-sm text-down hover:underline"
|
||||
>{ i18n.T(ctx, "monitors.delete") }</button>
|
||||
}
|
||||
</div>
|
||||
</form>
|
||||
}
|
||||
}
|
||||
|
||||
// ChannelRow is a notification channel in the list.
|
||||
type ChannelRow struct {
|
||||
ID string
|
||||
Name string
|
||||
Type string
|
||||
Target string
|
||||
Enabled bool
|
||||
}
|
||||
|
||||
// ChannelsView is the data of the notification channels page.
|
||||
type ChannelsView struct {
|
||||
Channels []ChannelRow
|
||||
EmailAvailable bool
|
||||
CanWrite bool
|
||||
Languages []string
|
||||
}
|
||||
|
||||
templ ChannelsPage(p Page, me Me, v ChannelsView) {
|
||||
@consoleShell(p, me) {
|
||||
@settingsHeading("channels.title", "channels.intro")
|
||||
if len(v.Channels) > 0 {
|
||||
<ul class="mb-12 divide-y divide-rule border-y border-rule text-sm">
|
||||
for _, ch := range v.Channels {
|
||||
<li class="flex flex-wrap items-center gap-x-4 gap-y-1 py-2.5">
|
||||
if ch.Enabled {
|
||||
@statusDot(StatusUp)
|
||||
} else {
|
||||
@statusDot(StatusPaused)
|
||||
}
|
||||
<span>{ ch.Name }</span>
|
||||
<span class="text-muted">{ i18n.T(ctx, "channels.type_"+ch.Type) }</span>
|
||||
<span class="min-w-0 truncate font-mono text-xs text-muted">{ ch.Target }</span>
|
||||
if v.CanWrite {
|
||||
<span class="ml-auto flex gap-4">
|
||||
<button type="button" data-post={ "/org/channels/" + ch.ID + "/test" } data-ok={ i18n.T(ctx, "channels.test_ok") } class="text-muted hover:text-ink">{ i18n.T(ctx, "channels.test") }</button>
|
||||
<button type="button" data-delete={ "/org/channels/" + ch.ID } data-confirm={ i18n.T(ctx, "channels.delete_confirm") } class="text-muted hover:text-down">{ i18n.T(ctx, "regions.delete") }</button>
|
||||
</span>
|
||||
}
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
if v.CanWrite {
|
||||
<div class="grid gap-12 md:grid-cols-2">
|
||||
<section>
|
||||
@sectionHeading("channels.new_webhook")
|
||||
<form data-api="/org/channels" data-show-link>
|
||||
@formError()
|
||||
<input type="hidden" name="type" value="webhook"/>
|
||||
@valueField(i18n.T(ctx, "sso.field.name"), "name", "", "Ops", true)
|
||||
@valueField(i18n.T(ctx, "channels.url"), "url", "", "https://example.com/hooks/uptime", true)
|
||||
@submit(i18n.T(ctx, "channels.create"))
|
||||
<div data-link-output hidden class="mt-6 border border-ink p-4">
|
||||
<p class="mb-2 text-sm">{ i18n.T(ctx, "channels.secret_now") }</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>
|
||||
<section>
|
||||
@sectionHeading("channels.new_email")
|
||||
if v.EmailAvailable {
|
||||
<form data-api="/org/channels" data-next="/settings/channels">
|
||||
@formError()
|
||||
<input type="hidden" name="type" value="email"/>
|
||||
@valueField(i18n.T(ctx, "sso.field.name"), "name", "", "On-call", true)
|
||||
<label class="mb-4 block">
|
||||
<span class="mb-1 block text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "channels.to") }</span>
|
||||
<input name="to" data-list required class="w-full border border-rule bg-transparent px-2.5 py-1.5 font-mono text-sm outline-none focus:border-ink" placeholder="ops@example.com, oncall@example.com"/>
|
||||
</label>
|
||||
<label class="mb-4 block">
|
||||
<span class="mb-1 block text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "channels.language") }</span>
|
||||
<select name="locale" class="w-40 border border-rule bg-transparent px-2 py-1.5 text-sm">
|
||||
for _, l := range v.Languages {
|
||||
<option value={ l } selected?={ l == i18n.Lang(ctx) }>{ i18n.T(ctx, "lang."+l) }</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
@submit(i18n.T(ctx, "channels.create"))
|
||||
</form>
|
||||
} else {
|
||||
<p class="text-sm text-muted">{ i18n.T(ctx, "error.email_not_configured") }</p>
|
||||
}
|
||||
</section>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
Generated
+22
@@ -10,10 +10,32 @@
|
||||
"axios": "1.21.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@fontsource/ibm-plex-mono": "5.3.0",
|
||||
"@fontsource/ibm-plex-sans": "5.3.0",
|
||||
"@tailwindcss/cli": "4.3.5",
|
||||
"tailwindcss": "4.3.5"
|
||||
}
|
||||
},
|
||||
"node_modules/@fontsource/ibm-plex-mono": {
|
||||
"version": "5.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@fontsource/ibm-plex-mono/-/ibm-plex-mono-5.3.0.tgz",
|
||||
"integrity": "sha512-eTgnZjZEGk1QtD3ZstF+Vclo2HLAni8YMy34/DxllwZvyz1lR/1RF/xTiAquOBO7MvqBx8D2Ig2WCPMVfdZu7Q==",
|
||||
"dev": true,
|
||||
"license": "OFL-1.1",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ayuhito"
|
||||
}
|
||||
},
|
||||
"node_modules/@fontsource/ibm-plex-sans": {
|
||||
"version": "5.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@fontsource/ibm-plex-sans/-/ibm-plex-sans-5.3.0.tgz",
|
||||
"integrity": "sha512-CbE4CbbEEZJX860XyUiRpsksXIQR8Rp2XDva2VO53NJox9tVNtusrysd2x5YkUEY3ErQ66W1IiiQL8/wihhw5w==",
|
||||
"dev": true,
|
||||
"license": "OFL-1.1",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ayuhito"
|
||||
}
|
||||
},
|
||||
"node_modules/@jridgewell/gen-mapping": {
|
||||
"version": "0.3.13",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",
|
||||
|
||||
+5
-2
@@ -3,12 +3,15 @@
|
||||
"private": true,
|
||||
"license": "AGPL-3.0-only",
|
||||
"scripts": {
|
||||
"build": "npm run build:css && npm run build:js",
|
||||
"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",
|
||||
"watch:css": "tailwindcss -i internal/web/assets/app.css -o internal/web/static/dist/app.css --watch"
|
||||
"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/"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@fontsource/ibm-plex-mono": "5.3.0",
|
||||
"@fontsource/ibm-plex-sans": "5.3.0",
|
||||
"@tailwindcss/cli": "4.3.5",
|
||||
"tailwindcss": "4.3.5"
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user