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/outposts/OutpostListPage.ts

149 lines
6.1 KiB
TypeScript
Raw Normal View History

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";
import "./OutpostForm";
2021-02-08 18:04:19 +00:00
import "../../elements/buttons/SpinnerButton";
import "../../elements/buttons/TokenCopyButton";
import "../../elements/forms/DeleteForm";
import "../../elements/forms/ModalForm";
2021-03-02 14:12:26 +00:00
import { PAGE_SIZE } from "../../constants";
import { Outpost, OutpostsApi } from "authentik-api";
import { DEFAULT_CONFIG } from "../../api/Config";
import { ifDefined } from "lit-html/directives/if-defined";
2021-02-08 18:04:19 +00:00
@customElement("ak-outpost-list")
export class OutpostListPage extends TablePage<Outpost> {
pageTitle(): string {
return t`Outposts`;
2021-02-08 18:04:19 +00:00
}
pageDescription(): string | undefined {
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>> {
return new OutpostsApi(DEFAULT_CONFIG).outpostsOutpostsList({
2021-02-08 18:04:19 +00:00
ordering: this.order,
page: page,
pageSize: PAGE_SIZE,
2021-02-08 18:04:19 +00:00
search: this.search || "",
});
}
columns(): TableColumn[] {
return [
new TableColumn(t`Name`, t`name`),
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}`,
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>`,
html`<ak-outpost-health outpostId=${ifDefined(item.pk)}></ak-outpost-health>`,
2021-02-08 18:04:19 +00:00
html`
<ak-forms-modal>
<span slot="submit">
${t`Update`}
</span>
<span slot="header">
${t`Update Outpost`}
</span>
<ak-outpost-form slot="form" .outpost=${item}>
</ak-outpost-form>
<button slot="trigger" class="pf-c-button pf-m-secondary">
${t`Edit`}
</button>
</ak-forms-modal>
<ak-forms-delete
.obj=${item}
objectLabel=${t`Outpost`}
.delete=${() => {
return new OutpostsApi(DEFAULT_CONFIG).outpostsOutpostsDelete({
uuid: item.pk || ""
});
}}>
<button slot="trigger" class="pf-c-button pf-m-danger">
${t`Delete`}
</button>
</ak-forms-delete>
2021-02-08 18:04:19 +00:00
<ak-modal-button>
<button slot="trigger" class="pf-c-button pf-m-tertiary">
${t`View Deployment Info`}
2021-02-08 18:04:19 +00:00
</button>
<div slot="modal">
<div class="pf-c-modal-box__header">
<h1 class="pf-c-title pf-m-2xl" id="modal-title">${t`Outpost Deployment Info`}</h1>
2021-02-08 18:04:19 +00:00
</div>
<div class="pf-c-modal-box__body" id="modal-description">
<p><a href="https://goauthentik.io/docs/outposts/outposts/#deploy">${t`View deployment documentation`}</a></p>
2021-02-08 18:04:19 +00:00
<form class="pf-c-form">
<div class="pf-c-form__group">
<label class="pf-c-form__label" for="help-text-simple-form-name">
<span class="pf-c-form__label-text">AUTHENTIK_HOST</span>
</label>
<input class="pf-c-form-control" readonly type="text" value="${document.location.toString()}" />
</div>
<div class="pf-c-form__group">
<label class="pf-c-form__label" for="help-text-simple-form-name">
<span class="pf-c-form__label-text">AUTHENTIK_TOKEN</span>
</label>
<div>
<ak-token-copy-button identifier="${ifDefined(item.tokenIdentifier)}">
${t`Click to copy token`}
2021-02-08 18:04:19 +00:00
</ak-token-copy-button>
</div>
</div>
<h3>${t`If your authentik Instance is using a self-signed certificate, set this value.`}</h3>
2021-02-08 18:04:19 +00:00
<div class="pf-c-form__group">
<label class="pf-c-form__label" for="help-text-simple-form-name">
<span class="pf-c-form__label-text">AUTHENTIK_INSECURE</span>
</label>
<input class="pf-c-form-control" readonly type="text" value="true" />
</div>
</form>
</div>
<footer class="pf-c-modal-box__footer pf-m-align-left">
<a class="pf-c-button pf-m-primary">${t`Close`}</a>
2021-02-08 18:04:19 +00:00
</footer>
</div>
</ak-modal-button>`,
];
}
renderToolbar(): TemplateResult {
return html`
<ak-forms-modal>
<span slot="submit">
${t`Create`}
</span>
<span slot="header">
${t`Create Outpost`}
</span>
<ak-outpost-form slot="form">
</ak-outpost-form>
<button slot="trigger" class="pf-c-button pf-m-primary">
${t`Create`}
</button>
</ak-forms-modal>
2021-02-08 18:04:19 +00:00
${super.renderToolbar()}
`;
}
}