ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 6m4s
ci / test (pull_request) Successful in 11m52s
ci / build (pull_request) Successful in 17m48s
ci / image (pull_request) Successful in 5m28s
- The console header folds its navigation into a menu below 1024px. - Pages use narrower gutters on phones. - Monitor rows keep name and uptime in place on narrow screens. - Toolbars and the range switch wrap. - Tables scroll sideways instead of squeezing their columns. - Form fields keep 16px text on touch screens so iOS does not zoom in. - The status page footer wraps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
170 lines
6.4 KiB
Templ
170 lines
6.4 KiB
Templ
package web
|
|
|
|
import "git.zb-server.de/ZB-Server/uptimesebi/internal/i18n"
|
|
|
|
// SSOOption is one provider on the chooser page.
|
|
type SSOOption struct {
|
|
Name string
|
|
URL string
|
|
}
|
|
|
|
templ SSOChooser(p Page, opts []SSOOption) {
|
|
@authShell(p) {
|
|
<ul class="divide-y divide-rule border-y border-rule">
|
|
for _, o := range opts {
|
|
<li><a href={ templ.SafeURL(o.URL) } class="block py-2.5 hover:underline">{ o.Name }</a></li>
|
|
}
|
|
</ul>
|
|
<p class="mt-8 text-sm text-muted"><a class="text-ink underline underline-offset-2" href="/login">{ i18n.T(ctx, "auth.signup.to_login") }</a></p>
|
|
}
|
|
}
|
|
|
|
// SSOProvider is a provider row on the settings page.
|
|
type SSOProvider struct {
|
|
ID string
|
|
Name string
|
|
Issuer string
|
|
ClientID string
|
|
HasSecret bool
|
|
AllowedDomains string
|
|
AutoProvision bool
|
|
DefaultRoleID string
|
|
Enabled bool
|
|
}
|
|
|
|
// SSOSettings is the data of the organization SSO page.
|
|
type SSOSettings struct {
|
|
Providers []SSOProvider
|
|
RedirectURL string
|
|
LoginURL string
|
|
Roles []Role
|
|
}
|
|
|
|
templ SSOSettingsPage(p Page, me Me, s SSOSettings) {
|
|
@consoleShell(p, me) {
|
|
<h1 class="mb-2 text-lg font-semibold">{ i18n.T(ctx, "sso.settings.title") }</h1>
|
|
<p class="mb-8 max-w-2xl text-sm text-muted">{ i18n.T(ctx, "sso.settings.intro") }</p>
|
|
<dl class="mb-10 grid max-w-2xl grid-cols-[max-content_1fr] gap-x-6 gap-y-2 text-sm">
|
|
<dt class="text-muted">{ i18n.T(ctx, "sso.settings.redirect_url") }</dt>
|
|
<dd class="break-all font-mono text-xs leading-5">{ s.RedirectURL }</dd>
|
|
<dt class="text-muted">{ i18n.T(ctx, "sso.settings.login_url") }</dt>
|
|
<dd class="break-all font-mono text-xs leading-5">{ s.LoginURL }</dd>
|
|
</dl>
|
|
if len(s.Providers) > 0 {
|
|
<div class="overflow-x-auto">
|
|
<table class="mb-12 w-full max-w-4xl text-left text-sm">
|
|
<thead class="border-b border-rule text-xs uppercase tracking-wider text-muted">
|
|
<tr>
|
|
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "sso.field.name") }</th>
|
|
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "sso.field.issuer") }</th>
|
|
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "sso.field.auto_provision") }</th>
|
|
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "sso.field.enabled") }</th>
|
|
<th class="py-2"></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-rule">
|
|
for _, pr := range s.Providers {
|
|
<tr class="align-top">
|
|
<td class="py-2.5 pr-4">{ pr.Name }</td>
|
|
<td class="py-2.5 pr-4 break-all font-mono text-xs">{ pr.Issuer }</td>
|
|
<td class="py-2.5 pr-4">@yesNo(pr.AutoProvision)</td>
|
|
<td class="py-2.5 pr-4">@yesNo(pr.Enabled)</td>
|
|
<td class="py-2.5 text-right">
|
|
<details class="inline-block text-left">
|
|
<summary class="cursor-pointer text-muted hover:text-ink">{ i18n.T(ctx, "sso.action.edit") }</summary>
|
|
<div class="mt-4 w-80">
|
|
@ssoForm(pr, s.Roles, "put", "/org/sso/"+pr.ID)
|
|
<button
|
|
type="button"
|
|
data-delete={ "/org/sso/" + pr.ID }
|
|
data-confirm={ i18n.T(ctx, "sso.action.delete_confirm") }
|
|
class="mt-4 text-sm text-down hover:underline"
|
|
>{ i18n.T(ctx, "sso.action.delete") }</button>
|
|
</div>
|
|
</details>
|
|
</td>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
}
|
|
<section class="max-w-md">
|
|
<h2 class="mb-4 text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "sso.settings.add") }</h2>
|
|
@ssoForm(SSOProvider{Enabled: true}, s.Roles, "post", "/org/sso")
|
|
</section>
|
|
}
|
|
}
|
|
|
|
templ yesNo(v bool) {
|
|
if v {
|
|
<span class="text-up">●</span> { i18n.T(ctx, "common.yes") }
|
|
} else {
|
|
<span class="text-unknown">●</span> { i18n.T(ctx, "common.no") }
|
|
}
|
|
}
|
|
|
|
templ ssoForm(pr SSOProvider, roles []Role, method, action string) {
|
|
<form data-api={ action } data-method={ method } data-next="/settings/sso">
|
|
@formError()
|
|
@valueField(i18n.T(ctx, "sso.field.name"), "name", pr.Name, "", true)
|
|
@valueField(i18n.T(ctx, "sso.field.issuer"), "issuer", pr.Issuer, "https://login.example.com/realms/acme", true)
|
|
@valueField(i18n.T(ctx, "sso.field.client_id"), "client_id", pr.ClientID, "", true)
|
|
<label class="mb-4 block">
|
|
<span class="mb-1 block text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "sso.field.client_secret") }</span>
|
|
<input
|
|
class="w-full border border-rule bg-transparent px-2.5 py-1.5 outline-none focus:border-ink"
|
|
type="password"
|
|
name="client_secret"
|
|
autocomplete="off"
|
|
if pr.HasSecret {
|
|
placeholder={ i18n.T(ctx, "sso.field.client_secret_keep") }
|
|
}
|
|
/>
|
|
</label>
|
|
<label class="mb-4 block">
|
|
<span class="mb-1 block text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "sso.field.allowed_domains") }</span>
|
|
<input
|
|
class="w-full border border-rule bg-transparent px-2.5 py-1.5 font-mono text-sm outline-none focus:border-ink"
|
|
name="allowed_domains"
|
|
data-list
|
|
value={ pr.AllowedDomains }
|
|
placeholder="example.com, example.org"
|
|
/>
|
|
<span class="mt-1 block text-xs text-muted">{ i18n.T(ctx, "sso.field.allowed_domains_hint") }</span>
|
|
</label>
|
|
@checkbox(i18n.T(ctx, "sso.field.auto_provision"), "auto_provision", pr.AutoProvision)
|
|
<label class="mb-4 block">
|
|
<span class="mb-1 block text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "sso.field.default_role") }</span>
|
|
<select name="default_role_id" data-nullable class="w-full border border-rule bg-transparent px-2 py-1.5 text-sm">
|
|
<option value="">{ i18n.T(ctx, "sso.field.default_role_viewer") }</option>
|
|
for _, r := range roles {
|
|
<option value={ r.ID } selected?={ r.ID == pr.DefaultRoleID }>{ r.Name }</option>
|
|
}
|
|
</select>
|
|
</label>
|
|
@checkbox(i18n.T(ctx, "sso.field.enabled"), "enabled", pr.Enabled)
|
|
@submit(i18n.T(ctx, "common.save"))
|
|
</form>
|
|
}
|
|
|
|
templ valueField(label, name, value, placeholder string, required bool) {
|
|
<label class="mb-4 block">
|
|
<span class="mb-1 block text-xs font-medium uppercase tracking-wider text-muted">{ label }</span>
|
|
<input
|
|
class="w-full border border-rule bg-transparent px-2.5 py-1.5 outline-none focus:border-ink"
|
|
name={ name }
|
|
value={ value }
|
|
placeholder={ placeholder }
|
|
required?={ required }
|
|
/>
|
|
</label>
|
|
}
|
|
|
|
templ checkbox(label, name string, checked bool) {
|
|
<label class="mb-3 flex items-center gap-2 text-sm">
|
|
<input type="checkbox" name={ name } checked?={ checked } class="accent-ink"/>
|
|
{ label }
|
|
</label>
|
|
}
|