package web import ( "strconv" "git.zb-server.de/ZB-Server/uptimesebi/internal/i18n" ) // AlertGroupOption is a selectable group or channel in an alert routing form. type AlertGroupOption struct { ID string Name string Default bool Checked bool } // AlertGroupQuietRow is one quiet-hours window rendered in an alert group form. type AlertGroupQuietRow struct { Start string End string TimeZone string Weekdays map[int]bool } // AlertGroupRow describes a group, its channels and its quiet hours. type AlertGroupRow struct { ID string Name string Default bool QuietNow bool Channels []AlertGroupOption QuietHours []AlertGroupQuietRow } func quietEndInput(end string) string { if end == "24:00" { return "00:00" } return end } templ alertGroupOptions(name string, options []AlertGroupOption) { for _, opt := range options { } } templ alertGroupQuietRow(prefix string, q AlertGroupQuietRow, canWrite bool) {
for _, d := range []int{1, 2, 3, 4, 5, 6, 0} { }
if canWrite { }
} templ alertGroupQuietHours(rows []AlertGroupQuietRow, canWrite bool) {

{ i18n.T(ctx, "alert_groups.quiet_title") }

{ i18n.T(ctx, "alert_groups.quiet_hint") }

for i, q := range rows { @alertGroupQuietRow("quiet_hours."+strconv.Itoa(i), q, canWrite) }
if canWrite { }
} templ alertGroupsSettings(v ChannelsView) {
@sectionHeading("alert_groups.title")

{ i18n.T(ctx, "alert_groups.intro") }

for _, tz := range commonTimeZones { }
for _, g := range v.AlertGroups {
@formError() if g.Default || g.QuietNow {
if g.Default { { i18n.T(ctx, "alert_groups.default") } } if g.QuietNow { { i18n.T(ctx, "alert_groups.quiet_active") } }
}
@valueField(i18n.T(ctx, "sso.field.name"), "name", g.Name, "", true) @alertGroupOptions("channel_ids", g.Channels) if len(g.Channels) == 0 {

{ i18n.T(ctx, "alert_groups.no_channels") }

} @alertGroupQuietHours(g.QuietHours, v.CanWrite) if v.CanWrite { @submit(i18n.T(ctx, "alert_groups.save")) }
if v.CanWrite && !g.Default { }
} if v.CanWrite {
@sectionHeading("alert_groups.new") @formError() @valueField(i18n.T(ctx, "sso.field.name"), "name", "", "", true) for _, ch := range v.Channels { } @alertGroupQuietHours(nil, true) @submit(i18n.T(ctx, "alert_groups.create"))
}
}