feat(alerting): add monitor alert groups with default routing
This commit is contained in:
1 parent
52819e64bb
commit
8544e5a585
26 files changed
+2938
-1473
No files matched your search
@@ -0,0 +1,77 @@
|
||||
package web
|
||||
|
||||
import "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
|
||||
}
|
||||
|
||||
// AlertGroupRow describes a group and its available notification channels.
|
||||
type AlertGroupRow struct {
|
||||
ID string
|
||||
Name string
|
||||
Default bool
|
||||
Channels []AlertGroupOption
|
||||
}
|
||||
|
||||
templ alertGroupOptions(name string, options []AlertGroupOption) {
|
||||
<input type="hidden" name={ name } data-multi/>
|
||||
for _, opt := range options {
|
||||
<label class="mb-2 flex items-center gap-2 text-sm">
|
||||
<input type="checkbox" name={ name } value={ opt.ID } data-multi checked?={ opt.Checked }/>
|
||||
<span>{ opt.Name }</span>
|
||||
if opt.Default {
|
||||
<span class="text-xs text-muted">{ i18n.T(ctx, "alert_groups.default") }</span>
|
||||
}
|
||||
</label>
|
||||
}
|
||||
}
|
||||
|
||||
templ alertGroupsSettings(v ChannelsView) {
|
||||
<section class="mb-12">
|
||||
@sectionHeading("alert_groups.title")
|
||||
<p class="mb-6 max-w-2xl text-sm text-muted">{ i18n.T(ctx, "alert_groups.intro") }</p>
|
||||
<div class="grid gap-6 md:grid-cols-2">
|
||||
for _, g := range v.AlertGroups {
|
||||
<form data-api={ "/org/alert-groups/" + g.ID } data-method="put" data-next="/settings/channels" class="border border-rule p-4">
|
||||
@formError()
|
||||
if g.Default {
|
||||
<p class="mb-3 text-xs text-muted">{ i18n.T(ctx, "alert_groups.default") }</p>
|
||||
}
|
||||
<fieldset disabled?={ !v.CanWrite }>
|
||||
@valueField(i18n.T(ctx, "sso.field.name"), "name", g.Name, "", true)
|
||||
@alertGroupOptions("channel_ids", g.Channels)
|
||||
if len(g.Channels) == 0 {
|
||||
<p class="mb-4 text-sm text-muted">{ i18n.T(ctx, "alert_groups.no_channels") }</p>
|
||||
}
|
||||
if v.CanWrite {
|
||||
@submit(i18n.T(ctx, "alert_groups.save"))
|
||||
}
|
||||
</fieldset>
|
||||
if v.CanWrite && !g.Default {
|
||||
<button type="button" data-delete={ "/org/alert-groups/" + g.ID } data-confirm={ i18n.T(ctx, "alert_groups.delete_confirm") } class="mt-3 text-sm text-muted hover:text-down">{ i18n.T(ctx, "regions.delete") }</button>
|
||||
}
|
||||
</form>
|
||||
}
|
||||
if v.CanWrite {
|
||||
<form data-api="/org/alert-groups" data-next="/settings/channels" class="border border-rule p-4">
|
||||
@sectionHeading("alert_groups.new")
|
||||
@formError()
|
||||
@valueField(i18n.T(ctx, "sso.field.name"), "name", "", "", true)
|
||||
<input type="hidden" name="channel_ids" data-multi/>
|
||||
for _, ch := range v.Channels {
|
||||
<label class="mb-2 flex items-center gap-2 text-sm">
|
||||
<input type="checkbox" name="channel_ids" value={ ch.ID } data-multi/>
|
||||
<span>{ ch.Name }</span>
|
||||
</label>
|
||||
}
|
||||
@submit(i18n.T(ctx, "alert_groups.create"))
|
||||
</form>
|
||||
}
|
||||
</div>
|
||||
</section>
|
||||
}
|
||||
Reference in new issue
Block a user