package web import "git.zb-server.de/ZB-Server/uptimesebi/internal/i18n" // Region is a row in a region list. type Region struct { ID string Key string Name string // Platform regions are shared by all organizations. Platform bool // Manageable regions can be deleted on the current page. Manageable bool Instances int64 } // Agent is a checker or status page server. type Agent struct { ID string Kind string Name string Region string Prefix string LastSeen string } // RegionsView is the data of the org regions page and the admin panel. type RegionsView struct { Regions []Region Agents []Agent // APIBase is the prefix of the endpoints the forms post to, either // /org or /admin. APIBase string // Next is the page to reload after a change. Next string // OwnRegions are the regions agents can be created in. OwnRegions []Region } templ regionsBody(v RegionsView) {
@sectionHeading("regions.list") for _, r := range v.Regions { }
{ i18n.T(ctx, "sso.field.name") } { i18n.T(ctx, "regions.key") } { i18n.T(ctx, "regions.owner") } { i18n.T(ctx, "regions.instances") }
{ r.Name } { r.Key } if r.Platform { { i18n.T(ctx, "regions.platform") } } else { { i18n.T(ctx, "regions.own") } } 0), templ.KV("text-unknown", r.Instances == 0) }>● { i18n.T(ctx, "regions.live", "Count", int(r.Instances)) } if r.Manageable { }
@sectionHeading("regions.create")
@formError() @valueField(i18n.T(ctx, "regions.key"), "key", "", "office-berlin", true) @valueField(i18n.T(ctx, "sso.field.name"), "name", "", "Office Berlin", false) @submit(i18n.T(ctx, "regions.create"))
@sectionHeading("agents.create")
@formError() @valueField(i18n.T(ctx, "sso.field.name"), "name", "", "checker-1", true) @submit(i18n.T(ctx, "agents.create"))
if len(v.Agents) > 0 {
@sectionHeading("agents.list")
} } templ RegionsPage(p Page, me Me, v RegionsView) { @consoleShell(p, me) { @settingsHeading("regions.title", "regions.intro") @regionsBody(v) } } templ AdminPage(p Page, me Me, v RegionsView, storage StorageView) { @consoleShell(p, me) { @settingsHeading("admin.title", "admin.intro") @regionsBody(v) @storageSection(storage) } }