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) { } templ bars(bs []Bar, height int) { } templ Dashboard(p Page, me Me, v DashboardView) { @consoleShell(p, me) {
{ i18n.T(ctx, "console.monitors.empty") }
} else {{ i18n.T(ctx, "monitors.last_24h") }
} } } // 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) {← { i18n.T(ctx, "console.monitors.title") }
{ v.Row.Type } · { v.Row.Target } · { v.Interval }
–
}| { r.Time } | { r.Region } | if r.OK { ● } else { ● } | { r.Latency } | { r.Detail } |
{ strings.Join(r.Cause, " · ") }
}{ i18n.T(ctx, "incidents.none") }
} 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) { } templ numberField(label, name string, value, min, max int, hint string) { } templ MonitorEditor(p Page, me Me, f MonitorForm) { @consoleShell(p, me) {if f.ID == "" { ← { i18n.T(ctx, "console.monitors.title") } } else { ← { f.Name } }
{ i18n.T(ctx, "error.email_not_configured") }
}