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 GroupID string Name string Type string Target string Status Status Regions []RegionStatus Latency string Uptime string Bars []Bar } // GroupNode is a monitor group with its monitors and subgroups. type GroupNode struct { ID string Name string Status Status Total int Monitors []MonitorRow Children []GroupNode } // GroupOption is a group in a select; Label is indented by depth. type GroupOption struct { ID string Label string } // DashboardView is the data of the monitor list. Root holds ungrouped // monitors and the top-level groups. type DashboardView struct { Root GroupNode Empty bool CanWrite bool Counts map[Status]int Range string Ranges []RangeOption } // RangeOption is an entry of the range switcher. type RangeOption struct { Key string Active bool URL string } // SLAEntry is one window of the SLA table. type SLAEntry struct { Label string Value string } templ rangeSwitch(opts []RangeOption) { } 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.range_note", "Range", v.Range) }
}{ i18n.T(ctx, "groups.manage") }
} } templ monitorList(ms []MonitorRow) { if len(ms) > 0 {← { 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 GroupID string Groups []GroupOption // TopLevel is set when the monitor may live outside any group. TopLevel 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") }
}← { i18n.T(ctx, "console.monitors.title") }
@settingsHeading("groups.title", "groups.intro") if len(v.Groups) > 0 {