web/admin: improve display of rule severity

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens Langhammer
2023-01-19 12:09:53 +01:00
parent 9701907b82
commit 89c4a7b4a4
12 changed files with 246 additions and 77 deletions

View File

@ -14,7 +14,20 @@ import { t } from "@lingui/macro";
import { TemplateResult, html } from "lit";
import { customElement, property } from "lit/decorators.js";
import { EventsApi, NotificationRule } from "@goauthentik/api";
import { EventsApi, NotificationRule, SeverityEnum } from "@goauthentik/api";
export function SeverityToLabel(severity: SeverityEnum | null | undefined): string {
if (!severity) return t`Unknown severity`;
switch (severity) {
case SeverityEnum.Alert:
return t`Alert`;
case SeverityEnum.Notice:
return t`Notice`;
case SeverityEnum.Warning:
return t`Warning`;
}
return t`Unknown severity`;
}
@customElement("ak-event-rule-list")
export class RuleListPage extends TablePage<NotificationRule> {
@ -80,7 +93,7 @@ export class RuleListPage extends TablePage<NotificationRule> {
row(item: NotificationRule): TemplateResult[] {
return [
html`${item.name}`,
html`${item.severity}`,
html`${SeverityToLabel(item.severity)}`,
html`${item.groupObj?.name || t`None (rule disabled)`}`,
html`<ak-forms-modal>
<span slot="submit"> ${t`Update`} </span>