package web import "git.zb-server.de/ZB-Server/uptimesebi/internal/i18n" // Me is the signed-in user as the console templates see it. type Me struct { // IsOwner refers to the active organization. IsOwner bool ActiveSlug string Email string DisplayName string TOTP bool ActiveOrg string Orgs []Org TOTPMissing bool // RecoveryCodesLeft counts unused TOTP recovery codes. RecoveryCodesLeft int } // Org is one entry of the organization switcher. type Org struct { ID string Name string Slug string IsOwner bool } templ consoleShell(p Page, me Me) { @Layout(p) {
uptimesebi if len(me.Orgs) > 1 { } else if len(me.Orgs) == 1 { { me.Orgs[0].Name } }
if me.TOTPMissing {

{ i18n.T(ctx, "console.totp_missing") } { i18n.T(ctx, "console.totp_missing_action") }

}
@flash(p) { children... }
} } templ Dashboard(p Page, me Me) { @consoleShell(p, me) {

{ i18n.T(ctx, "console.monitors.title") }

{ i18n.T(ctx, "console.monitors.empty") }

} } // Identity is an SSO sign-in linked to the user in the active organization. type Identity struct { Provider string Email string } templ Security(p Page, me Me, identities []Identity, canLink bool) { @consoleShell(p, me) {

{ i18n.T(ctx, "security.title") }

{ i18n.T(ctx, "security.totp.heading") }

if me.TOTP {

● { i18n.T(ctx, "security.totp.active") }

= 3) }> { i18n.T(ctx, "security.recovery.left", "Count", me.RecoveryCodesLeft) }

{ i18n.T(ctx, "security.recovery.regenerate") }
@formError() @field(i18n.T(ctx, "auth.field.password"), "password", "password", "current-password", true) @field(i18n.T(ctx, "security.totp.current_code"), "code", "text", "one-time-code", true) @submit(i18n.T(ctx, "security.recovery.regenerate")) @recoveryOutput()
{ i18n.T(ctx, "security.totp.disable") }
@formError() @field(i18n.T(ctx, "auth.field.password"), "password", "password", "current-password", true) @field(i18n.T(ctx, "security.totp.current_code"), "code", "text", "one-time-code", true) @submit(i18n.T(ctx, "security.totp.disable"))
} else {

● { i18n.T(ctx, "security.totp.inactive") }

}

{ i18n.T(ctx, "security.sso.heading") }

if len(identities) == 0 {

{ i18n.T(ctx, "security.sso.none") }

} else { } if canLink { { i18n.T(ctx, "security.sso.link") } }
} } // recoveryOutput is filled by app.js with codes returned by the API; they // are shown once and never rendered by the server. templ recoveryOutput() { }