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/TransportListPage.ts

97 lines
3.3 KiB
TypeScript
Raw Normal View History

2021-01-12 21:03:50 +00:00
import { gettext } from "django";
import { customElement, html, property, TemplateResult } from "lit-element";
import { AKResponse } from "../../api/Client";
2021-01-12 21:03:50 +00:00
import { TablePage } from "../../elements/table/TablePage";
2021-01-12 21:26:57 +00:00
import "../../elements/buttons/ActionButton";
2021-01-12 21:03:50 +00:00
import "../../elements/buttons/ModalButton";
import "../../elements/buttons/SpinnerButton";
import { TableColumn } from "../../elements/table/Table";
2021-03-02 14:12:26 +00:00
import { PAGE_SIZE } from "../../constants";
import { EventsApi, NotificationTransport } from "authentik-api";
import { DEFAULT_CONFIG } from "../../api/Config";
import { AdminURLManager } from "../../api/legacy";
import "../../elements/forms/DeleteForm";
2021-01-12 21:03:50 +00:00
@customElement("ak-event-transport-list")
export class TransportListPage extends TablePage<NotificationTransport> {
2021-01-12 21:03:50 +00:00
searchEnabled(): boolean {
return true;
}
pageTitle(): string {
return gettext("Notification Transports");
}
pageDescription(): string {
return gettext("Define how notifications are sent to users, like Email or Webhook.");
}
pageIcon(): string {
return gettext("pf-icon pf-icon-export");
}
@property()
order = "name";
apiEndpoint(page: number): Promise<AKResponse<NotificationTransport>> {
return new EventsApi(DEFAULT_CONFIG).eventsTransportsList({
2021-01-12 21:03:50 +00:00
ordering: this.order,
page: page,
pageSize: PAGE_SIZE,
2021-01-12 21:03:50 +00:00
search: this.search || "",
});
}
columns(): TableColumn[] {
return [
new TableColumn("Name", "name"),
new TableColumn("Mode", "mode"),
new TableColumn(""),
];
}
row(item: NotificationTransport): TemplateResult[] {
2021-01-12 21:03:50 +00:00
return [
html`${item.name}`,
html`${item.modeVerbose}`,
2021-01-12 21:03:50 +00:00
html`
<ak-action-button
.apiRequest=${() => {
return new EventsApi(DEFAULT_CONFIG).eventsTransportsTest({
uuid: item.pk || "",
});
}}>
2021-01-12 21:03:50 +00:00
${gettext("Test")}
</ak-action-button>
<ak-modal-button href="${AdminURLManager.eventTransports(`${item.pk}/update/`)}">
2021-01-12 21:03:50 +00:00
<ak-spinner-button slot="trigger" class="pf-m-secondary">
${gettext("Edit")}
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>
<ak-forms-delete
.obj=${item}
objectLabel=${gettext("Notifications Transport")}
.delete=${() => {
return new EventsApi(DEFAULT_CONFIG).eventsTransportsDelete({
uuid: item.pk || ""
});
}}>
<button slot="trigger" class="pf-c-button pf-m-danger">
2021-01-12 21:03:50 +00:00
${gettext("Delete")}
</button>
</ak-forms-delete>`,
2021-01-12 21:03:50 +00:00
];
}
renderToolbar(): TemplateResult {
return html`
<ak-modal-button href=${AdminURLManager.eventTransports("create/")}>
2021-01-12 21:03:50 +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()}
`;
}
}