fix(api): platform check type switch binds the platform's checkers only #149
No files matched your search
@@ -108,10 +108,11 @@ var endpoints = []endpoint{
|
||||
{method: "GET", path: "/api/v1/org/limits", tag: "Organization", summary: "Limits in effect for the organization and its usage",
|
||||
description: "0 means unlimited. Creating beyond a limit gives 422 monitor_limit, status_page_limit, region_limit or platform_region_limit.",
|
||||
resp: usageView{}},
|
||||
{method: "GET", path: "/api/v1/org/check-types", tag: "Monitors", summary: "Monitor types this installation offers",
|
||||
resp: obj{"types": []string{}}},
|
||||
{method: "GET", path: "/api/v1/org/check-types", tag: "Monitors", summary: "Monitor types members can create",
|
||||
description: "`own_checkers_only` are the types the platform's checkers do not run: monitors of them use the organization's own regions only, or 422 check_type_own_checkers_only.",
|
||||
resp: obj{"types": []string{}, "own_checkers_only": []string{}}},
|
||||
{method: "PUT", path: "/api/v1/org/check-types", tag: "Monitors", summary: "Choose the monitor types offered to members",
|
||||
description: "Out of the types the platform offers; types left out are not offered for new monitors or type changes, existing monitors keep running.",
|
||||
description: "Independent of the types the platform's checkers run; types left out are not offered for new monitors or type changes, existing monitors keep running.",
|
||||
perm: "org.manage", sessionOnly: true, req: checkTypesRequest{}, status: http.StatusNoContent},
|
||||
{method: "GET", path: "/api/v1/org/groups", tag: "Monitors", summary: "List monitor groups", resp: obj{"groups": []groupView{}}},
|
||||
{method: "POST", path: "/api/v1/org/groups", tag: "Monitors", summary: "Create a group", perm: "monitors.write",
|
||||
@@ -302,8 +303,8 @@ var endpoints = []endpoint{
|
||||
req: legalRequest{}, status: http.StatusNoContent},
|
||||
{method: "GET", path: "/api/v1/admin/check-types", tag: "Platform", summary: "Check types and whether they are offered", perm: "platform admin",
|
||||
resp: obj{"types": []checkTypeView{}}},
|
||||
{method: "PUT", path: "/api/v1/admin/check-types", tag: "Platform", summary: "Choose the check types offered for new monitors",
|
||||
description: "Types left out are switched off: not offered for new monitors or type changes; existing monitors keep running.",
|
||||
{method: "PUT", path: "/api/v1/admin/check-types", tag: "Platform", summary: "Choose the check types the platform's checkers run",
|
||||
description: "Types left out are switched off for the platform's regions: new monitors and type changes may use them on the organizations' own regions only (passive types not at all); existing monitors keep running.",
|
||||
perm: "platform admin", req: checkTypesRequest{}, status: http.StatusNoContent},
|
||||
{method: "GET", path: "/api/v1/admin/checker-network", tag: "Platform", summary: "Whether platform checkers may check private addresses", perm: "platform admin",
|
||||
resp: checkerNetwork{}},
|
||||
|
||||
+115
-27
@@ -8,6 +8,7 @@ import (
|
||||
"slices"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
"github.com/jackc/pgx/v5"
|
||||
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/check"
|
||||
@@ -15,10 +16,12 @@ import (
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/tenant"
|
||||
)
|
||||
|
||||
// Platform admins can switch off check types the installation cannot
|
||||
// offer, such as Docker on shared cloud checkers. Switched-off types are
|
||||
// not offered for new monitors; existing ones keep running and stay
|
||||
// editable.
|
||||
// Platform admins can switch off check types the platform's checkers
|
||||
// cannot offer, such as Docker on shared cloud checkers. That only binds
|
||||
// the platform's checkers: organizations keep such types for their own.
|
||||
// Organizations separately choose the types they offer their members.
|
||||
// Switched-off types are not offered for new monitors; existing ones keep
|
||||
// running and stay editable.
|
||||
|
||||
const settingDisabledChecks = "disabled_check_types"
|
||||
|
||||
@@ -48,34 +51,87 @@ func (s *Server) disabledChecks(ctx context.Context) map[string]bool {
|
||||
return set
|
||||
}
|
||||
|
||||
// offered reports whether org may create monitors of type t: neither the
|
||||
// platform nor the organization switched it off.
|
||||
func (s *Server) offered(ctx context.Context, org store.Org, t string) bool {
|
||||
return slices.Contains(s.enabledCheckTypes(ctx, org, ""), t)
|
||||
// checkTypeChoice is a type an organization can pick for a monitor.
|
||||
type checkTypeChoice struct {
|
||||
Type string
|
||||
// OwnOnly is set when the platform switched the type off for its
|
||||
// checkers, leaving the organization's own.
|
||||
OwnOnly bool
|
||||
}
|
||||
|
||||
// enabledCheckTypes lists the types offered to org for new monitors, plus
|
||||
// keep when a monitor of a switched-off type is being edited. The
|
||||
// organization's choice is ignored if it would leave nothing, which can
|
||||
// happen when the platform later switches off what it kept.
|
||||
func (s *Server) enabledCheckTypes(ctx context.Context, org store.Org, keep string) []string {
|
||||
// checkTypeChoices lists the types offered to org, plus keep when a
|
||||
// monitor of a switched-off type is being edited. Types the platform
|
||||
// switched off for its checkers are offered only to organizations with
|
||||
// regions of their own; passive ones, which no checker runs, not at all.
|
||||
func (s *Server) checkTypeChoices(ctx context.Context, org store.Org, keep string, ownRegions bool) []checkTypeChoice {
|
||||
off := s.disabledChecks(ctx)
|
||||
var platform, out []string
|
||||
for _, t := range check.Types {
|
||||
if off[string(t)] && string(t) != keep {
|
||||
var out, platform []checkTypeChoice
|
||||
for _, ty := range check.Types {
|
||||
t := string(ty)
|
||||
passive := check.Passive(ty)
|
||||
if off[t] && t != keep && (passive || !ownRegions) {
|
||||
continue
|
||||
}
|
||||
platform = append(platform, string(t))
|
||||
if !slices.Contains(org.DisabledCheckTypes, string(t)) || string(t) == keep {
|
||||
out = append(out, string(t))
|
||||
choice := checkTypeChoice{Type: t, OwnOnly: off[t] && !passive}
|
||||
if !off[t] || t == keep {
|
||||
platform = append(platform, choice)
|
||||
}
|
||||
if !slices.Contains(org.DisabledCheckTypes, t) || t == keep {
|
||||
out = append(out, choice)
|
||||
}
|
||||
}
|
||||
// The organization's choice can leave nothing usable when it only
|
||||
// kept types the platform's checkers no longer run.
|
||||
if len(out) == 0 {
|
||||
return platform
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
var (
|
||||
errCheckTypeDisabled = errors.New("api: check type switched off")
|
||||
errOwnCheckersOnly = errors.New("api: check type switched off for platform checkers")
|
||||
)
|
||||
|
||||
// checkTypeAllowed fails unless org may give a monitor, previously of
|
||||
// type keep in the regions previous, type t in regions; platform marks
|
||||
// the platform's regions. Monitors of a type the platform switched off
|
||||
// keep the platform regions they had but gain none.
|
||||
func (s *Server) checkTypeAllowed(ctx context.Context, org store.Org, t, keep string, regions, previous []uuid.UUID, platform map[uuid.UUID]bool) error {
|
||||
own := false
|
||||
for _, p := range platform {
|
||||
own = own || !p
|
||||
}
|
||||
choices := s.checkTypeChoices(ctx, org, keep, own)
|
||||
i := slices.IndexFunc(choices, func(c checkTypeChoice) bool { return c.Type == t })
|
||||
if i < 0 {
|
||||
return errCheckTypeDisabled
|
||||
}
|
||||
if !s.disabledChecks(ctx)[t] || check.Passive(check.Type(t)) {
|
||||
return nil
|
||||
}
|
||||
for _, r := range regions {
|
||||
if platform[r] && (t != keep || !slices.Contains(previous, r)) {
|
||||
return errOwnCheckersOnly
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// failCheckType answers a checkTypeAllowed error and reports whether it
|
||||
// did.
|
||||
func failCheckType(c *gin.Context, err error) bool {
|
||||
switch {
|
||||
case errors.Is(err, errCheckTypeDisabled):
|
||||
fail(c, http.StatusUnprocessableEntity, "check_type_disabled")
|
||||
case errors.Is(err, errOwnCheckersOnly):
|
||||
fail(c, http.StatusUnprocessableEntity, "check_type_own_checkers_only")
|
||||
default:
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
type checkTypeView struct {
|
||||
Type string `json:"type"`
|
||||
Enabled bool `json:"enabled"`
|
||||
@@ -132,13 +188,40 @@ func (s *Server) adminSetCheckTypes(c *gin.Context) {
|
||||
c.Status(http.StatusNoContent)
|
||||
}
|
||||
|
||||
// orgCheckTypes tells API clients which monitor types they can create.
|
||||
// orgCheckTypes tells API clients which monitor types they can create;
|
||||
// own_checkers_only are those the platform's checkers do not run.
|
||||
func (s *Server) orgCheckTypes(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"types": s.enabledCheckTypes(c.Request.Context(), current(c).Org, "")})
|
||||
p := current(c)
|
||||
ctx := c.Request.Context()
|
||||
own, err := s.hasOwnRegions(ctx, p)
|
||||
if err != nil {
|
||||
internalError(c, err)
|
||||
return
|
||||
}
|
||||
types, ownOnly := []string{}, []string{}
|
||||
for _, ch := range s.checkTypeChoices(ctx, p.Org, "", own) {
|
||||
types = append(types, ch.Type)
|
||||
if ch.OwnOnly {
|
||||
ownOnly = append(ownOnly, ch.Type)
|
||||
}
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"types": types, "own_checkers_only": ownOnly})
|
||||
}
|
||||
|
||||
// orgSetCheckTypes chooses which of the platform's types the organization
|
||||
// offers its members.
|
||||
func (s *Server) hasOwnRegions(ctx context.Context, p *principal) (bool, error) {
|
||||
var own bool
|
||||
err := s.db.Tx(ctx, p.scope(), func(q *store.Queries) error {
|
||||
regions, err := q.ListVisibleRegions(ctx)
|
||||
own = slices.ContainsFunc(regions, func(r store.Region) bool { return r.OrgID != nil })
|
||||
return err
|
||||
})
|
||||
return own, err
|
||||
}
|
||||
|
||||
// orgSetCheckTypes chooses which types the organization offers its
|
||||
// members, independently of what the platform's checkers run. Passive
|
||||
// types the platform switched off cannot be chosen and keep their
|
||||
// setting.
|
||||
func (s *Server) orgSetCheckTypes(c *gin.Context) {
|
||||
var req checkTypesRequest
|
||||
if !bind(c, &req) {
|
||||
@@ -149,12 +232,17 @@ func (s *Server) orgSetCheckTypes(c *gin.Context) {
|
||||
off := s.disabledChecks(ctx)
|
||||
disabled := []string{}
|
||||
enabled := 0
|
||||
for _, t := range check.Types {
|
||||
for _, ty := range check.Types {
|
||||
t := string(ty)
|
||||
switch {
|
||||
case slices.Contains(req.Enabled, string(t)):
|
||||
case off[t] && check.Passive(ty):
|
||||
if slices.Contains(p.Org.DisabledCheckTypes, t) {
|
||||
disabled = append(disabled, t)
|
||||
}
|
||||
case slices.Contains(req.Enabled, t):
|
||||
enabled++
|
||||
case !off[string(t)]:
|
||||
disabled = append(disabled, string(t))
|
||||
default:
|
||||
disabled = append(disabled, t)
|
||||
}
|
||||
}
|
||||
for _, t := range req.Enabled {
|
||||
|
||||
@@ -74,4 +74,29 @@ func TestCheckTypesCanBeSwitchedOff(t *testing.T) {
|
||||
if _, _, page := admin.page("/monitors/" + hb["id"].(string) + "/edit"); !strings.Contains(page, `value="heartbeat" selected`) {
|
||||
t.Error("editing a monitor of a switched-off type does not keep its type")
|
||||
}
|
||||
|
||||
// The switch binds the platform's checkers only: with a region of its
|
||||
// own the organization keeps the type there.
|
||||
st, own := member.do("POST", "/api/v1/org/regions", map[string]any{"key": uniq("own-"), "name": "Own"})
|
||||
if st != http.StatusCreated {
|
||||
t.Fatalf("own region = %d %v", st, own)
|
||||
}
|
||||
ownID := own["id"].(string)
|
||||
if _, types := member.do("GET", "/api/v1/org/check-types", nil); !strings.Contains(mustJSON(types["types"]), `"icmp"`) || mustJSON(types["own_checkers_only"]) != `["icmp"]` {
|
||||
t.Errorf("offered types with an own region = %v", types)
|
||||
}
|
||||
if _, _, page := member.page("/monitors/new"); !strings.Contains(page, `value="icmp"`) || !strings.Contains(page, "own checkers only") {
|
||||
t.Error("the editor does not offer the type for own checkers")
|
||||
}
|
||||
st, body = member.do("POST", "/api/v1/org/monitors", map[string]any{"name": "Ping", "type": "icmp", "target": "example.com", "interval_seconds": 60, "regions": []string{ownID, region}})
|
||||
expect(t, "switched-off type on a platform region", st, body, http.StatusUnprocessableEntity, "check_type_own_checkers_only")
|
||||
st, ping := member.do("POST", "/api/v1/org/monitors", map[string]any{"name": "Ping", "type": "icmp", "target": "example.com", "interval_seconds": 60, "regions": []string{ownID}})
|
||||
expect(t, "switched-off type on an own region", st, ping, http.StatusCreated, "")
|
||||
st, body = member.do("PUT", "/api/v1/org/monitors/"+ping["id"].(string), map[string]any{"name": "Ping", "type": "icmp", "target": "example.com", "interval_seconds": 60, "regions": []string{ownID, region}})
|
||||
expect(t, "adding a platform region", st, body, http.StatusUnprocessableEntity, "check_type_own_checkers_only")
|
||||
st, body = member.do("POST", "/api/v1/org/monitors", map[string]any{"name": "Cron", "type": "heartbeat", "interval_seconds": 3600})
|
||||
expect(t, "switched-off passive type", st, body, http.StatusUnprocessableEntity, "check_type_disabled")
|
||||
if _, _, page := member.page("/settings/org"); !strings.Contains(page, `value="icmp"`) || strings.Contains(page, `value="heartbeat"`) {
|
||||
t.Error("the organization settings do not offer the types for own checkers")
|
||||
}
|
||||
}
|
||||
+10
-3
@@ -674,9 +674,16 @@ func (s *Server) monitorEditor(c *gin.Context, p *principal, page web.Page, me w
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
f.Types = s.enabledCheckTypes(ctx, p.Org, f.Type)
|
||||
if !slices.Contains(f.Types, f.Type) {
|
||||
f.Type = f.Types[0]
|
||||
keep := ""
|
||||
if idParam != "" {
|
||||
keep = f.Type
|
||||
}
|
||||
own := slices.ContainsFunc(regions, func(r store.Region) bool { return r.OrgID != nil })
|
||||
for _, ch := range s.checkTypeChoices(ctx, p.Org, keep, own) {
|
||||
f.Types = append(f.Types, web.TypeOption{Type: ch.Type, OwnOnly: ch.OwnOnly})
|
||||
}
|
||||
if !slices.ContainsFunc(f.Types, func(t web.TypeOption) bool { return t.Type == f.Type }) {
|
||||
f.Type = f.Types[0].Type
|
||||
}
|
||||
for i, r := range regions {
|
||||
live, err := s.sched.Instances(ctx, r.ID.String())
|
||||
|
||||
@@ -280,8 +280,7 @@ func (s *Server) createMonitor(c *gin.Context) {
|
||||
if !s.validateMonitor(c, &req, t) {
|
||||
return
|
||||
}
|
||||
if !s.offered(ctx, p.Org, req.Type) {
|
||||
fail(c, http.StatusUnprocessableEntity, "check_type_disabled")
|
||||
if failCheckType(c, s.checkTypeAllowed(ctx, p.Org, req.Type, "", req.Regions, nil, req.platform)) {
|
||||
return
|
||||
}
|
||||
req.Target = passiveTarget(check.Type(req.Type), req.Target)
|
||||
@@ -403,8 +402,8 @@ func (s *Server) updateMonitor(c *gin.Context) {
|
||||
if previous, err = q.MonitorRegions(ctx, id); err != nil {
|
||||
return err
|
||||
}
|
||||
if old.Type != req.Type && !s.offered(ctx, p.Org, req.Type) {
|
||||
return errCheckTypeDisabled
|
||||
if err := s.checkTypeAllowed(ctx, p.Org, req.Type, old.Type, req.Regions, previous, req.platform); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := checkRegions(s.orgLimits(ctx, p.Org), req.Regions, previous, req.platform); err != nil {
|
||||
return err
|
||||
@@ -443,8 +442,7 @@ func (s *Server) updateMonitor(c *gin.Context) {
|
||||
fail(c, http.StatusUnprocessableEntity, "invalid_alert_group")
|
||||
return
|
||||
}
|
||||
if errors.Is(err, errCheckTypeDisabled) {
|
||||
fail(c, http.StatusUnprocessableEntity, "check_type_disabled")
|
||||
if failCheckType(c, err) {
|
||||
return
|
||||
}
|
||||
if failLimit(c, err) {
|
||||
@@ -611,5 +609,3 @@ func passiveRegion(t check.Type) string {
|
||||
}
|
||||
return heartbeatRegion
|
||||
}
|
||||
|
||||
var errCheckTypeDisabled = errors.New("api: check type switched off")
|
||||
@@ -383,9 +383,14 @@ func (s *Server) orgSettingsView(c *gin.Context, p *principal, page web.Page, me
|
||||
v.Usage = web.UsageView{Limits: webLimits(u.Limits), Monitors: u.Usage.Monitors, StatusPages: u.Usage.StatusPages}
|
||||
off := s.disabledChecks(c.Request.Context())
|
||||
for _, t := range check.Types {
|
||||
if !off[string(t)] {
|
||||
v.CheckTypes = append(v.CheckTypes, web.CheckTypeOption{Type: string(t), Enabled: !slices.Contains(p.Org.DisabledCheckTypes, string(t))})
|
||||
o := web.CheckTypeOption{Type: string(t), Enabled: !slices.Contains(p.Org.DisabledCheckTypes, string(t))}
|
||||
if off[string(t)] {
|
||||
if check.Passive(t) {
|
||||
continue
|
||||
}
|
||||
o.Note = "org.check_type_own_only"
|
||||
}
|
||||
v.CheckTypes = append(v.CheckTypes, o)
|
||||
}
|
||||
if p.Org.ApiTokenMaxDays != nil {
|
||||
v.TokenMaxDays = int(*p.Org.ApiTokenMaxDays)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"admin.check_types": "Check-Typen",
|
||||
"admin.check_types_intro": "Schalte Typen ab, die diese Installation nicht anbieten kann, etwa Docker auf geteilten Cloud-Checkern oder ICMP ohne die nötigen Rechte. Sie verschwinden für neue Monitore; bestehende laufen weiter.",
|
||||
"admin.check_types_intro": "Schalte Typen ab, die die Checker der Plattform nicht anbieten können, etwa Docker auf geteilten Cloud-Checkern oder ICMP ohne die nötigen Rechte. Organisationen behalten sie für ihre eigenen Checker; bestehende Monitore laufen weiter.",
|
||||
"admin.checker_network": "Checker-Netzwerk",
|
||||
"admin.intro": "Hier angelegte Regionen, Checker und Statuspage-Server stehen allen Organisationen zur Verfügung. Organisationen legen ihre eigenen unter Regionen & Checker an.",
|
||||
"admin.platform_private": "Plattform-Checker dürfen private Adressen prüfen",
|
||||
@@ -535,6 +535,7 @@
|
||||
"error.channel_test_failed": "Die Testbenachrichtigung konnte nicht zugestellt werden.",
|
||||
"error.channel_type_immutable": "Der Typ eines Kanals kann nicht geändert werden.",
|
||||
"error.check_type_disabled": "Dieser Check-Typ ist für diese Organisation oder Installation abgeschaltet.",
|
||||
"error.check_type_own_checkers_only": "Die Checker der Plattform führen diesen Check-Typ nicht aus. Wähle nur eigene Regionen deiner Organisation.",
|
||||
"error.confirmation_failed": "Die Bestätigung stimmt nicht.",
|
||||
"error.consent_outdated": "Die Dokumente haben sich inzwischen geändert. Lade die Seite neu und stimme der aktuellen Fassung zu.",
|
||||
"error.consent_required": "Bitte stimme zuerst Datenschutz und AGB zu.",
|
||||
@@ -1155,6 +1156,7 @@
|
||||
"monitors.type_mqtt": "MQTT",
|
||||
"monitors.type_mssql": "Microsoft SQL Server",
|
||||
"monitors.type_mysql": "MySQL / MariaDB",
|
||||
"monitors.type_own_only": "nur eigene Checker",
|
||||
"monitors.type_postgres": "PostgreSQL",
|
||||
"monitors.type_prometheus": "Prometheus",
|
||||
"monitors.type_rabbitmq": "RabbitMQ",
|
||||
@@ -1173,7 +1175,8 @@
|
||||
"notify.title_opened": "{{.Monitor}} ist ausgefallen",
|
||||
"notify.title_resolved": "{{.Monitor}} ist wieder erreichbar",
|
||||
"notify.title_test": "Test von UptimeSebi",
|
||||
"org.check_types_intro": "Monitor-Typen, die den Mitgliedern dieser Organisation angeboten werden, aus denen, die diese Installation anbietet. Bestehende Monitore eines abgeschalteten Typs laufen weiter.",
|
||||
"org.check_type_own_only": "nur eigene Checker",
|
||||
"org.check_types_intro": "Monitor-Typen, die den Mitgliedern dieser Organisation angeboten werden. Typen, die die Checker der Plattform nicht ausführen, laufen nur auf euren eigenen Checkern. Bestehende Monitore eines abgeschalteten Typs laufen weiter.",
|
||||
"org.policy": "Anmelderichtlinie",
|
||||
"org.require_sso": "SSO verlangen",
|
||||
"org.require_sso_hint": "Mitglieder müssen sich über den Identity Provider dieser Organisation anmelden. Der Owner kann weiterhin ein Passwort nutzen, damit ein defekter IdP euch nicht aussperrt.",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"admin.check_types": "Check types",
|
||||
"admin.check_types_intro": "Switch off types this installation cannot offer, such as Docker on shared cloud checkers or ICMP without the needed privileges. They disappear for new monitors; existing monitors keep running.",
|
||||
"admin.check_types_intro": "Switch off types the platform's checkers cannot offer, such as Docker on shared cloud checkers or ICMP without the needed privileges. Organizations keep them for their own checkers; existing monitors keep running.",
|
||||
"admin.checker_network": "Checker network",
|
||||
"admin.intro": "Regions, checkers and status page servers created here are shared by every organization. Organizations add their own under Regions & checkers.",
|
||||
"admin.platform_private": "Platform checkers may check private addresses",
|
||||
@@ -535,6 +535,7 @@
|
||||
"error.channel_test_failed": "The test notification could not be delivered.",
|
||||
"error.channel_type_immutable": "The type of a channel cannot be changed.",
|
||||
"error.check_type_disabled": "This check type is switched off for this organization or installation.",
|
||||
"error.check_type_own_checkers_only": "The platform's checkers do not run this check type. Choose only your organization's own regions.",
|
||||
"error.confirmation_failed": "The confirmation does not match.",
|
||||
"error.consent_outdated": "The documents changed in the meantime. Reload the page and accept the current version.",
|
||||
"error.consent_required": "Please accept the privacy policy and terms first.",
|
||||
@@ -1155,6 +1156,7 @@
|
||||
"monitors.type_mqtt": "MQTT",
|
||||
"monitors.type_mssql": "Microsoft SQL Server",
|
||||
"monitors.type_mysql": "MySQL / MariaDB",
|
||||
"monitors.type_own_only": "own checkers only",
|
||||
"monitors.type_postgres": "PostgreSQL",
|
||||
"monitors.type_prometheus": "Prometheus",
|
||||
"monitors.type_rabbitmq": "RabbitMQ",
|
||||
@@ -1173,7 +1175,8 @@
|
||||
"notify.title_opened": "{{.Monitor}} is down",
|
||||
"notify.title_resolved": "{{.Monitor}} is up again",
|
||||
"notify.title_test": "Test from UptimeSebi",
|
||||
"org.check_types_intro": "Monitor types offered to the members of this organization, out of those this installation offers. Existing monitors of a switched-off type keep running.",
|
||||
"org.check_type_own_only": "own checkers only",
|
||||
"org.check_types_intro": "Monitor types offered to the members of this organization. Types the platform's checkers do not run work on your own checkers only. Existing monitors of a switched-off type keep running.",
|
||||
"org.policy": "Sign-in policy",
|
||||
"org.require_sso": "Require SSO",
|
||||
"org.require_sso_hint": "Members must sign in through this organization's identity provider. The owner can still use a password so a broken IdP cannot lock you out.",
|
||||
|
||||
@@ -579,6 +579,13 @@ templ IncidentsPage(p Page, me Me, v IncidentsView) {
|
||||
}
|
||||
}
|
||||
|
||||
// TypeOption is a check type offered in the monitor form. OwnOnly types
|
||||
// run on the organization's own checkers only.
|
||||
type TypeOption struct {
|
||||
Type string
|
||||
OwnOnly bool
|
||||
}
|
||||
|
||||
// RegionOption is a selectable region in the monitor form.
|
||||
type RegionOption struct {
|
||||
ID string
|
||||
@@ -639,7 +646,7 @@ type MonitorForm struct {
|
||||
Game GameForm
|
||||
DockerHost string
|
||||
// Types are the check types to offer.
|
||||
Types []string
|
||||
Types []TypeOption
|
||||
}
|
||||
|
||||
// BrokerForm holds the settings of message broker checks.
|
||||
@@ -765,7 +772,12 @@ templ MonitorEditor(p Page, me Me, f MonitorForm) {
|
||||
<span class="mb-1 block text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "monitors.type") }</span>
|
||||
<select name="type" data-type-select class="w-full border border-rule bg-transparent px-2 py-1.5 text-sm">
|
||||
for _, t := range f.Types {
|
||||
<option value={ t } selected?={ t == f.Type }>{ i18n.T(ctx, "monitors.type_"+t) }</option>
|
||||
<option value={ t.Type } selected?={ t.Type == f.Type }>
|
||||
{ i18n.T(ctx, "monitors.type_"+t.Type) }
|
||||
if t.OwnOnly {
|
||||
({ i18n.T(ctx, "monitors.type_own_only") })
|
||||
}
|
||||
</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
|
||||
+1724
-1694
File diff suppressed because it is too large.
Load diff
@@ -212,6 +212,8 @@ templ AdminPage(p Page, me Me, v RegionsView, storage StorageView, checkTypes []
|
||||
type CheckTypeOption struct {
|
||||
Type string
|
||||
Enabled bool
|
||||
// Note is the i18n key of a remark next to the type, if any.
|
||||
Note string
|
||||
}
|
||||
|
||||
templ checkerNetworkSection(allow bool) {
|
||||
@@ -239,6 +241,9 @@ templ checkTypesSection(types []CheckTypeOption, api, next, introID string) {
|
||||
<label class="flex items-center gap-2">
|
||||
<input type="checkbox" name="enabled" value={ t.Type } data-multi checked?={ t.Enabled } class="accent-ink"/>
|
||||
{ i18n.T(ctx, "monitors.type_"+t.Type) }
|
||||
if t.Note != "" {
|
||||
<span class="text-xs text-muted">{ i18n.T(ctx, t.Note) }</span>
|
||||
}
|
||||
</label>
|
||||
}
|
||||
</div>
|
||||
|
||||
+376
-351
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user