This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
authentik/web/src/pages/events/RuleListPage.ts

95 lines
2.9 KiB
TypeScript
Raw Normal View History

2021-01-12 21:26:57 +00:00
import { gettext } from "django";
import { customElement, html, property, TemplateResult } from "lit-element";
2021-02-09 16:04:55 +00:00
import { AKResponse } from "../../api/Client";
2021-01-12 21:26:57 +00:00
import { TablePage } from "../../elements/table/TablePage";
import "../../elements/policies/BoundPoliciesList";
import "../../elements/buttons/ModalButton";
import "../../elements/buttons/SpinnerButton";
import { TableColumn } from "../../elements/table/Table";
2021-01-15 15:23:27 +00:00
import { Rule } from "../../api/EventRules";
2021-01-12 21:26:57 +00:00
2021-01-15 15:23:27 +00:00
@customElement("ak-event-rule-list")
export class RuleListPage extends TablePage<Rule> {
2021-01-12 21:26:57 +00:00
expandable = true;
searchEnabled(): boolean {
return true;
}
pageTitle(): string {
2021-01-15 15:23:27 +00:00
return gettext("Notification Rules");
2021-01-12 21:26:57 +00:00
}
pageDescription(): string {
2021-01-15 15:23:27 +00:00
return gettext("Send notifications whenever a specific Event is created and matched by policies.");
2021-01-12 21:26:57 +00:00
}
pageIcon(): string {
return gettext("pf-icon pf-icon-attention-bell");
}
@property()
order = "name";
2021-02-09 16:04:55 +00:00
apiEndpoint(page: number): Promise<AKResponse<Rule>> {
2021-01-15 15:23:27 +00:00
return Rule.list({
2021-01-12 21:26:57 +00:00
ordering: this.order,
page: page,
search: this.search || "",
});
}
columns(): TableColumn[] {
return [
new TableColumn("Name", "name"),
new TableColumn("Severity", "severity"),
new TableColumn("Sent to group", "group"),
new TableColumn(""),
];
}
2021-01-15 15:23:27 +00:00
row(item: Rule): TemplateResult[] {
2021-01-12 21:26:57 +00:00
return [
html`${item.name}`,
html`${item.severity}`,
2021-01-15 15:23:27 +00:00
html`${item.group?.name || gettext("None (rule disabled)")}`,
2021-01-12 21:26:57 +00:00
html`
2021-01-15 15:23:27 +00:00
<ak-modal-button href="${Rule.adminUrl(`${item.pk}/update/`)}">
2021-01-12 21:26:57 +00:00
<ak-spinner-button slot="trigger" class="pf-m-secondary">
${gettext("Edit")}
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>
2021-01-15 15:23:27 +00:00
<ak-modal-button href="${Rule.adminUrl(`${item.pk}/delete/`)}">
2021-01-12 21:26:57 +00:00
<ak-spinner-button slot="trigger" class="pf-m-danger">
${gettext("Delete")}
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>
`,
];
}
renderToolbar(): TemplateResult {
return html`
2021-01-15 15:23:27 +00:00
<ak-modal-button href=${Rule.adminUrl("create/")}>
2021-01-12 21:26:57 +00:00
<ak-spinner-button slot="trigger" class="pf-m-primary">
${gettext("Create")}
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>
${super.renderToolbar()}
`;
}
2021-01-15 15:23:27 +00:00
renderExpanded(item: Rule): TemplateResult {
2021-01-12 21:26:57 +00:00
return html`
<td role="cell" colspan="4">
<div class="pf-c-table__expandable-row-content">
<ak-bound-policies-list .target=${item.pk}>
</ak-bound-policies-list>
</div>
</td>
<td></td>
<td></td>`;
}
}