2021-04-03 17:26:43 +00:00
|
|
|
import { t } from "@lingui/macro";
|
2021-02-19 16:49:34 +00:00
|
|
|
import { customElement, property } from "lit-element";
|
|
|
|
import { html, TemplateResult } from "lit-html";
|
|
|
|
import { AKResponse } from "../../api/Client";
|
|
|
|
import { TableColumn } from "../../elements/table/Table";
|
|
|
|
import { TablePage } from "../../elements/table/TablePage";
|
|
|
|
|
|
|
|
import "./OutpostHealth";
|
|
|
|
import "../../elements/buttons/SpinnerButton";
|
|
|
|
import "../../elements/buttons/Dropdown";
|
2021-03-18 11:14:27 +00:00
|
|
|
import "../../elements/forms/DeleteForm";
|
2021-03-31 20:40:48 +00:00
|
|
|
import "../../elements/forms/ModalForm";
|
|
|
|
import "./ServiceConnectionKubernetesForm";
|
|
|
|
import "./ServiceConnectionDockerForm";
|
2021-02-19 16:49:34 +00:00
|
|
|
import { until } from "lit-html/directives/until";
|
2021-03-02 14:12:26 +00:00
|
|
|
import { PAGE_SIZE } from "../../constants";
|
2021-03-16 20:32:39 +00:00
|
|
|
import { OutpostsApi, ServiceConnection } from "authentik-api";
|
2021-03-08 10:14:00 +00:00
|
|
|
import { DEFAULT_CONFIG } from "../../api/Config";
|
2021-03-31 20:40:48 +00:00
|
|
|
import "../../elements/forms/ProxyForm";
|
|
|
|
import { ifDefined } from "lit-html/directives/if-defined";
|
2021-02-19 16:49:34 +00:00
|
|
|
|
|
|
|
@customElement("ak-outpost-service-connection-list")
|
2021-03-08 10:14:00 +00:00
|
|
|
export class OutpostServiceConnectionListPage extends TablePage<ServiceConnection> {
|
2021-02-19 16:49:34 +00:00
|
|
|
pageTitle(): string {
|
|
|
|
return "Outpost Service-Connections";
|
|
|
|
}
|
|
|
|
pageDescription(): string | undefined {
|
|
|
|
return "Outpost Service-Connections define how authentik connects to external platforms to manage and deploy Outposts.";
|
|
|
|
}
|
|
|
|
pageIcon(): string {
|
|
|
|
return "pf-icon pf-icon-integration";
|
|
|
|
}
|
|
|
|
searchEnabled(): boolean {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-03-08 10:14:00 +00:00
|
|
|
apiEndpoint(page: number): Promise<AKResponse<ServiceConnection>> {
|
|
|
|
return new OutpostsApi(DEFAULT_CONFIG).outpostsServiceConnectionsAllList({
|
2021-02-19 16:49:34 +00:00
|
|
|
ordering: this.order,
|
|
|
|
page: page,
|
2021-03-08 10:14:00 +00:00
|
|
|
pageSize: PAGE_SIZE,
|
2021-02-19 16:49:34 +00:00
|
|
|
search: this.search || "",
|
|
|
|
});
|
|
|
|
}
|
2021-03-08 10:14:00 +00:00
|
|
|
|
2021-02-19 16:49:34 +00:00
|
|
|
columns(): TableColumn[] {
|
|
|
|
return [
|
2021-04-03 17:26:43 +00:00
|
|
|
new TableColumn(t`Name`, t`name`),
|
2021-02-19 16:49:34 +00:00
|
|
|
new TableColumn("Type"),
|
2021-04-03 17:26:43 +00:00
|
|
|
new TableColumn(t`Local`, t`local`),
|
2021-02-19 16:49:34 +00:00
|
|
|
new TableColumn("State"),
|
|
|
|
new TableColumn(""),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
@property()
|
|
|
|
order = "name";
|
|
|
|
|
2021-03-08 10:14:00 +00:00
|
|
|
row(item: ServiceConnection): TemplateResult[] {
|
2021-02-19 16:49:34 +00:00
|
|
|
return [
|
|
|
|
html`${item.name}`,
|
2021-03-08 10:14:00 +00:00
|
|
|
html`${item.verboseName}`,
|
2021-04-03 17:59:22 +00:00
|
|
|
html`${item.local ? t`Yes` : t`No`}`,
|
2021-03-08 10:14:00 +00:00
|
|
|
html`${until(
|
|
|
|
new OutpostsApi(DEFAULT_CONFIG).outpostsServiceConnectionsAllState({
|
|
|
|
uuid: item.pk || ""
|
|
|
|
}).then((state) => {
|
|
|
|
if (state.healthy) {
|
|
|
|
return html`<i class="fas fa-check pf-m-success"></i> ${state.version}`;
|
|
|
|
}
|
2021-04-03 17:26:43 +00:00
|
|
|
return html`<i class="fas fa-times pf-m-danger"></i> ${t`Unhealthy`}`;
|
2021-03-08 10:14:00 +00:00
|
|
|
}), html`<ak-spinner></ak-spinner>`)}`,
|
2021-02-19 16:49:34 +00:00
|
|
|
html`
|
2021-03-31 20:40:48 +00:00
|
|
|
<ak-forms-modal>
|
|
|
|
<span slot="submit">
|
2021-04-03 17:26:43 +00:00
|
|
|
${t`Update`}
|
2021-03-31 20:40:48 +00:00
|
|
|
</span>
|
|
|
|
<span slot="header">
|
2021-04-03 17:26:43 +00:00
|
|
|
${t`Update ${item.verboseName}`}
|
2021-03-31 20:40:48 +00:00
|
|
|
</span>
|
|
|
|
<ak-proxy-form
|
|
|
|
slot="form"
|
|
|
|
.args=${{
|
|
|
|
"scUUID": item.pk
|
|
|
|
}}
|
2021-04-03 09:32:17 +00:00
|
|
|
type=${ifDefined(item.component)}>
|
2021-03-31 20:40:48 +00:00
|
|
|
</ak-proxy-form>
|
|
|
|
<button slot="trigger" class="pf-c-button pf-m-secondary">
|
2021-04-03 17:26:43 +00:00
|
|
|
${t`Edit`}
|
2021-03-31 20:40:48 +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 Service-connection`}
|
2021-03-18 11:14:27 +00:00
|
|
|
.delete=${() => {
|
|
|
|
return new OutpostsApi(DEFAULT_CONFIG).outpostsServiceConnectionsAllDelete({
|
|
|
|
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-02-19 16:49:34 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
renderToolbar(): TemplateResult {
|
|
|
|
return html`
|
|
|
|
<ak-dropdown class="pf-c-dropdown">
|
|
|
|
<button class="pf-m-primary pf-c-dropdown__toggle" type="button">
|
2021-04-03 17:26:43 +00:00
|
|
|
<span class="pf-c-dropdown__toggle-text">${t`Create`}</span>
|
2021-02-19 16:49:34 +00:00
|
|
|
<i class="fas fa-caret-down pf-c-dropdown__toggle-icon" aria-hidden="true"></i>
|
|
|
|
</button>
|
|
|
|
<ul class="pf-c-dropdown__menu" hidden>
|
2021-04-02 11:27:18 +00:00
|
|
|
${until(new OutpostsApi(DEFAULT_CONFIG).outpostsServiceConnectionsAllTypes().then((types) => {
|
2021-02-19 16:49:34 +00:00
|
|
|
return types.map((type) => {
|
|
|
|
return html`<li>
|
2021-03-31 20:40:48 +00:00
|
|
|
<ak-forms-modal>
|
|
|
|
<span slot="submit">
|
2021-04-03 17:26:43 +00:00
|
|
|
${t`Create`}
|
2021-03-31 20:40:48 +00:00
|
|
|
</span>
|
|
|
|
<span slot="header">
|
2021-04-03 17:26:43 +00:00
|
|
|
${t`Create ${type.name}`}
|
2021-03-31 20:40:48 +00:00
|
|
|
</span>
|
|
|
|
<ak-proxy-form
|
|
|
|
slot="form"
|
2021-04-02 21:12:17 +00:00
|
|
|
type=${type.component}>
|
2021-03-31 20:40:48 +00:00
|
|
|
</ak-proxy-form>
|
|
|
|
<button slot="trigger" class="pf-c-dropdown__menu-item">
|
|
|
|
${type.name}<br>
|
2021-02-19 16:49:34 +00:00
|
|
|
<small>${type.description}</small>
|
|
|
|
</button>
|
2021-03-31 20:40:48 +00:00
|
|
|
</ak-forms-modal>
|
2021-02-19 16:49:34 +00:00
|
|
|
</li>`;
|
|
|
|
});
|
|
|
|
}), html`<ak-spinner></ak-spinner>`)}
|
|
|
|
</ul>
|
|
|
|
</ak-dropdown>
|
|
|
|
${super.renderToolbar()}`;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|