import { t } from "@lingui/macro"; import { CSSResult } from "lit"; import { TemplateResult, html } from "lit"; import { customElement, property } from "lit/decorators.js"; import { ifDefined } from "lit/directives/if-defined.js"; import { until } from "lit/directives/until.js"; import PFDescriptionList from "@patternfly/patternfly/components/DescriptionList/description-list.css"; import { Outpost, OutpostTypeEnum, OutpostsApi } from "@goauthentik/api"; import { AKResponse } from "../../api/Client"; import { DEFAULT_CONFIG } from "../../api/Config"; import { uiConfig } from "../../common/config"; import { PFSize } from "../../elements/Spinner"; import "../../elements/buttons/SpinnerButton"; import "../../elements/forms/DeleteBulkForm"; import "../../elements/forms/ModalForm"; import { TableColumn } from "../../elements/table/Table"; import { TablePage } from "../../elements/table/TablePage"; import "./OutpostDeploymentModal"; import "./OutpostForm"; import "./OutpostHealth"; import "./OutpostHealthSimple"; export function TypeToLabel(type?: OutpostTypeEnum): string { if (!type) return ""; switch (type) { case OutpostTypeEnum.Proxy: return t`Proxy`; case OutpostTypeEnum.Ldap: return t`LDAP`; } } @customElement("ak-outpost-list") export class OutpostListPage extends TablePage { expandable = true; pageTitle(): string { return t`Outposts`; } pageDescription(): string | undefined { return t`Outposts are deployments of authentik components to support different environments and protocols, like reverse proxies.`; } pageIcon(): string { return "pf-icon pf-icon-zone"; } searchEnabled(): boolean { return true; } async apiEndpoint(page: number): Promise> { return new OutpostsApi(DEFAULT_CONFIG).outpostsInstancesList({ ordering: this.order, page: page, pageSize: (await uiConfig()).pagination.perPage, search: this.search || "", }); } columns(): TableColumn[] { return [ new TableColumn(t`Name`, "name"), new TableColumn(t`Type`, "type"), new TableColumn(t`Providers`), new TableColumn(t`Integration`, "service_connection__name"), new TableColumn(t`Health and Version`), new TableColumn(t`Actions`), ]; } static get styles(): CSSResult[] { return super.styles.concat(PFDescriptionList); } checkbox = true; @property() order = "name"; row(item: Outpost): TemplateResult[] { return [ html`
${item.name}
${item.config.authentik_host === "" ? html` ${t`Warning: authentik Domain is not configured, authentication will not work.`}` : html` ${t`Logging in via ${item.config.authentik_host}.`} `}
`, html`${TypeToLabel(item.type)}`, html``, html`${item.serviceConnectionObj?.name || t`No integration active`}`, html``, html` ${t`Update`} ${t`Update Outpost`} ${item.managed !== "goauthentik.io/outposts/embedded" ? html` ` : html``}`, ]; } renderExpanded(item: Outpost): TemplateResult { return html`

${t`Detailed health (one instance per column, data is cached so may be out of data)`}

${until( new OutpostsApi(DEFAULT_CONFIG) .outpostsInstancesHealthList({ uuid: item.pk, }) .then((health) => { return health.map((h) => { return html`
`; }); }), )}
`; } renderToolbarSelected(): TemplateResult { const disabled = this.selectedElements.length < 1; return html` { return new OutpostsApi(DEFAULT_CONFIG).outpostsInstancesUsedByList({ uuid: item.pk, }); }} .delete=${(item: Outpost) => { return new OutpostsApi(DEFAULT_CONFIG).outpostsInstancesDestroy({ uuid: item.pk, }); }} > `; } renderToolbar(): TemplateResult { return html` ${t`Create`} ${t`Create Outpost`} ${super.renderToolbar()} `; } }