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

116 lines
3.8 KiB
TypeScript
Raw Normal View History

import { t } from "@lingui/macro";
2021-01-12 21:03:50 +00:00
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";
import "../../elements/forms/ModalForm";
2021-01-12 21:03:50 +00:00
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 "../../elements/forms/DeleteForm";
import "./TransportForm";
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 t`Notification Transports`;
2021-01-12 21:03:50 +00:00
}
pageDescription(): string {
return t`Define how notifications are sent to users, like Email or Webhook.`;
2021-01-12 21:03:50 +00:00
}
pageIcon(): string {
return "pf-icon pf-icon-export";
2021-01-12 21:03:50 +00:00
}
@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(t`Name`, "name"),
new TableColumn(t`Mode`, "mode"),
2021-01-12 21:03:50 +00:00
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).eventsTransportsTestCreate({
uuid: item.pk || "",
});
}}>
${t`Test`}
</ak-action-button>
<ak-forms-modal>
<span slot="submit">
${t`Update`}
</span>
<span slot="header">
${t`Update Notification Transport`}
</span>
<ak-event-transport-form slot="form" .instancePk=${item.pk}>
</ak-event-transport-form>
<button slot="trigger" class="pf-c-button pf-m-secondary">
${t`Edit`}
</button>
</ak-forms-modal>
<ak-forms-delete
.obj=${item}
objectLabel=${t`Notifications Transport`}
.usedBy=${() => {
return new EventsApi(DEFAULT_CONFIG).eventsTransportsUsedByList({
uuid: item.pk
});
}}
.delete=${() => {
return new EventsApi(DEFAULT_CONFIG).eventsTransportsDestroy({
uuid: item.pk
});
}}>
<button slot="trigger" class="pf-c-button pf-m-danger">
${t`Delete`}
</button>
</ak-forms-delete>`,
2021-01-12 21:03:50 +00:00
];
}
renderToolbar(): TemplateResult {
return html`
<ak-forms-modal>
<span slot="submit">
${t`Create`}
</span>
<span slot="header">
${t`Create Notification Transport`}
</span>
<ak-event-transport-form slot="form">
</ak-event-transport-form>
<button slot="trigger" class="pf-c-button pf-m-primary">
${t`Create`}
</button>
</ak-forms-modal>
2021-01-12 21:03:50 +00:00
${super.renderToolbar()}
`;
}
}