2021-04-03 17:26:43 +00:00
|
|
|
import { t } from "@lingui/macro";
|
2021-02-08 18:04:19 +00:00
|
|
|
import { customElement, property } from "lit-element";
|
|
|
|
import { html, TemplateResult } from "lit-html";
|
2021-02-09 16:04:55 +00:00
|
|
|
import { AKResponse } from "../../api/Client";
|
2021-02-08 18:04:19 +00:00
|
|
|
import { TableColumn } from "../../elements/table/Table";
|
|
|
|
import { TablePage } from "../../elements/table/TablePage";
|
|
|
|
|
|
|
|
import "./OutpostHealth";
|
2021-03-29 21:12:31 +00:00
|
|
|
import "./OutpostForm";
|
2021-04-10 10:19:32 +00:00
|
|
|
import "./OutpostDeploymentModal";
|
2021-02-08 18:04:19 +00:00
|
|
|
import "../../elements/buttons/SpinnerButton";
|
2021-03-30 15:33:11 +00:00
|
|
|
import "../../elements/forms/ModalForm";
|
2021-04-10 21:27:57 +00:00
|
|
|
import "../../elements/forms/DeleteForm";
|
2021-03-02 14:12:26 +00:00
|
|
|
import { PAGE_SIZE } from "../../constants";
|
2021-03-16 20:32:39 +00:00
|
|
|
import { Outpost, OutpostsApi } from "authentik-api";
|
2021-03-08 10:14:00 +00:00
|
|
|
import { DEFAULT_CONFIG } from "../../api/Config";
|
|
|
|
import { ifDefined } from "lit-html/directives/if-defined";
|
2021-04-10 21:27:57 +00:00
|
|
|
import { PFSize } from "../../elements/Spinner";
|
2021-02-08 18:04:19 +00:00
|
|
|
|
|
|
|
@customElement("ak-outpost-list")
|
|
|
|
export class OutpostListPage extends TablePage<Outpost> {
|
|
|
|
pageTitle(): string {
|
2021-04-03 22:10:56 +00:00
|
|
|
return t`Outposts`;
|
2021-02-08 18:04:19 +00:00
|
|
|
}
|
|
|
|
pageDescription(): string | undefined {
|
2021-04-03 22:10:56 +00:00
|
|
|
return t`Outposts are deployments of authentik components to support different environments and protocols, like reverse proxies.`;
|
2021-02-08 18:04:19 +00:00
|
|
|
}
|
|
|
|
pageIcon(): string {
|
|
|
|
return "pf-icon pf-icon-zone";
|
|
|
|
}
|
|
|
|
searchEnabled(): boolean {
|
|
|
|
return true;
|
|
|
|
}
|
2021-02-09 16:04:55 +00:00
|
|
|
apiEndpoint(page: number): Promise<AKResponse<Outpost>> {
|
2021-03-08 10:14:00 +00:00
|
|
|
return new OutpostsApi(DEFAULT_CONFIG).outpostsOutpostsList({
|
2021-02-08 18:04:19 +00:00
|
|
|
ordering: this.order,
|
|
|
|
page: page,
|
2021-03-08 10:14:00 +00:00
|
|
|
pageSize: PAGE_SIZE,
|
2021-02-08 18:04:19 +00:00
|
|
|
search: this.search || "",
|
|
|
|
});
|
|
|
|
}
|
|
|
|
columns(): TableColumn[] {
|
|
|
|
return [
|
2021-04-04 14:56:16 +00:00
|
|
|
new TableColumn(t`Name`, "name"),
|
2021-04-04 14:22:29 +00:00
|
|
|
new TableColumn(t`Providers`),
|
|
|
|
new TableColumn(t`Health and Version`),
|
2021-02-08 18:04:19 +00:00
|
|
|
new TableColumn(""),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
@property()
|
|
|
|
order = "name";
|
|
|
|
|
|
|
|
row(item: Outpost): TemplateResult[] {
|
|
|
|
return [
|
|
|
|
html`${item.name}`,
|
2021-03-08 10:14:00 +00:00
|
|
|
html`<ul>${item.providersObj?.map((p) => {
|
2021-02-19 18:29:17 +00:00
|
|
|
return html`<li><a href="#/core/providers/${p.pk}">${p.name}</a></li>`;
|
2021-02-08 18:04:19 +00:00
|
|
|
})}</ul>`,
|
2021-03-08 10:14:00 +00:00
|
|
|
html`<ak-outpost-health outpostId=${ifDefined(item.pk)}></ak-outpost-health>`,
|
2021-02-08 18:04:19 +00:00
|
|
|
html`
|
2021-03-29 21:12:31 +00:00
|
|
|
<ak-forms-modal>
|
|
|
|
<span slot="submit">
|
2021-04-03 17:26:43 +00:00
|
|
|
${t`Update`}
|
2021-03-29 21:12:31 +00:00
|
|
|
</span>
|
|
|
|
<span slot="header">
|
2021-04-03 17:26:43 +00:00
|
|
|
${t`Update Outpost`}
|
2021-03-29 21:12:31 +00:00
|
|
|
</span>
|
2021-05-11 09:48:34 +00:00
|
|
|
<ak-outpost-form slot="form" .instancePk=${item.pk}>
|
2021-03-29 21:12:31 +00:00
|
|
|
</ak-outpost-form>
|
|
|
|
<button slot="trigger" class="pf-c-button pf-m-secondary">
|
2021-04-03 17:26:43 +00:00
|
|
|
${t`Edit`}
|
2021-03-29 21:12:31 +00:00
|
|
|
</button>
|
|
|
|
</ak-forms-modal>
|
2021-03-18 11:14:27 +00:00
|
|
|
<ak-forms-delete
|
|
|
|
.obj=${item}
|
2021-04-03 17:26:43 +00:00
|
|
|
objectLabel=${t`Outpost`}
|
2021-03-18 11:14:27 +00:00
|
|
|
.delete=${() => {
|
|
|
|
return new OutpostsApi(DEFAULT_CONFIG).outpostsOutpostsDelete({
|
|
|
|
uuid: item.pk || ""
|
|
|
|
});
|
|
|
|
}}>
|
|
|
|
<button slot="trigger" class="pf-c-button pf-m-danger">
|
2021-04-03 17:26:43 +00:00
|
|
|
${t`Delete`}
|
2021-03-18 11:14:27 +00:00
|
|
|
</button>
|
|
|
|
</ak-forms-delete>
|
2021-04-10 21:27:57 +00:00
|
|
|
<ak-outpost-deployment-modal .outpost=${item} size=${PFSize.Medium}>
|
2021-02-08 18:04:19 +00:00
|
|
|
<button slot="trigger" class="pf-c-button pf-m-tertiary">
|
2021-04-03 17:26:43 +00:00
|
|
|
${t`View Deployment Info`}
|
2021-02-08 18:04:19 +00:00
|
|
|
</button>
|
2021-04-10 21:27:57 +00:00
|
|
|
</ak-outpost-deployment-modal>`,
|
2021-02-08 18:04:19 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
renderToolbar(): TemplateResult {
|
|
|
|
return html`
|
2021-03-29 21:12:31 +00:00
|
|
|
<ak-forms-modal>
|
|
|
|
<span slot="submit">
|
2021-04-03 17:26:43 +00:00
|
|
|
${t`Create`}
|
2021-03-29 21:12:31 +00:00
|
|
|
</span>
|
|
|
|
<span slot="header">
|
2021-04-03 17:26:43 +00:00
|
|
|
${t`Create Outpost`}
|
2021-03-29 21:12:31 +00:00
|
|
|
</span>
|
|
|
|
<ak-outpost-form slot="form">
|
|
|
|
</ak-outpost-form>
|
|
|
|
<button slot="trigger" class="pf-c-button pf-m-primary">
|
2021-04-03 17:26:43 +00:00
|
|
|
${t`Create`}
|
2021-03-29 21:12:31 +00:00
|
|
|
</button>
|
|
|
|
</ak-forms-modal>
|
2021-02-08 18:04:19 +00:00
|
|
|
${super.renderToolbar()}
|
|
|
|
`;
|
|
|
|
}
|
|
|
|
}
|