2022-09-14 22:05:21 +00:00
|
|
|
import "@goauthentik/admin/sources/SourceWizard";
|
|
|
|
import "@goauthentik/admin/sources/ldap/LDAPSourceForm";
|
|
|
|
import "@goauthentik/admin/sources/oauth/OAuthSourceForm";
|
|
|
|
import "@goauthentik/admin/sources/plex/PlexSourceForm";
|
|
|
|
import "@goauthentik/admin/sources/saml/SAMLSourceForm";
|
|
|
|
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
|
|
|
import { uiConfig } from "@goauthentik/common/ui/config";
|
2022-12-25 13:06:29 +00:00
|
|
|
import { PFColor } from "@goauthentik/elements/Label";
|
2022-09-14 22:05:21 +00:00
|
|
|
import "@goauthentik/elements/forms/DeleteBulkForm";
|
|
|
|
import "@goauthentik/elements/forms/ModalForm";
|
|
|
|
import "@goauthentik/elements/forms/ProxyForm";
|
|
|
|
import { PaginatedResponse } from "@goauthentik/elements/table/Table";
|
|
|
|
import { TableColumn } from "@goauthentik/elements/table/Table";
|
|
|
|
import { TablePage } from "@goauthentik/elements/table/TablePage";
|
2022-06-25 15:44:17 +00:00
|
|
|
|
2021-04-03 17:26:43 +00:00
|
|
|
import { t } from "@lingui/macro";
|
2021-09-21 09:31:37 +00:00
|
|
|
|
2021-10-28 07:48:51 +00:00
|
|
|
import { TemplateResult, html } from "lit";
|
2021-11-04 21:34:48 +00:00
|
|
|
import { customElement, property } from "lit/decorators.js";
|
|
|
|
import { ifDefined } from "lit/directives/if-defined.js";
|
2021-02-09 09:22:49 +00:00
|
|
|
|
2021-09-21 09:31:37 +00:00
|
|
|
import { Source, SourcesApi } from "@goauthentik/api";
|
|
|
|
|
2021-02-09 09:22:49 +00:00
|
|
|
@customElement("ak-source-list")
|
|
|
|
export class SourceListPage extends TablePage<Source> {
|
|
|
|
pageTitle(): string {
|
2021-12-14 14:57:03 +00:00
|
|
|
return t`Federation & Social login`;
|
2021-02-09 09:22:49 +00:00
|
|
|
}
|
|
|
|
pageDescription(): string | undefined {
|
2021-08-29 11:49:57 +00:00
|
|
|
return t`Sources of identities, which can either be synced into authentik's database, or can be used by users to authenticate and enroll themselves.`;
|
2021-02-09 09:22:49 +00:00
|
|
|
}
|
|
|
|
pageIcon(): string {
|
|
|
|
return "pf-icon pf-icon-middleware";
|
|
|
|
}
|
|
|
|
searchEnabled(): boolean {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-08-05 10:30:43 +00:00
|
|
|
checkbox = true;
|
|
|
|
|
2021-02-09 09:22:49 +00:00
|
|
|
@property()
|
|
|
|
order = "name";
|
|
|
|
|
2022-09-14 22:05:21 +00:00
|
|
|
async apiEndpoint(page: number): Promise<PaginatedResponse<Source>> {
|
2021-03-08 10:14:00 +00:00
|
|
|
return new SourcesApi(DEFAULT_CONFIG).sourcesAllList({
|
2021-02-09 09:22:49 +00:00
|
|
|
ordering: this.order,
|
|
|
|
page: page,
|
2021-10-14 10:48:52 +00:00
|
|
|
pageSize: (await uiConfig()).pagination.perPage,
|
2021-02-09 09:22:49 +00:00
|
|
|
search: this.search || "",
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
columns(): TableColumn[] {
|
2021-08-03 15:52:21 +00:00
|
|
|
return [new TableColumn(t`Name`, "name"), new TableColumn(t`Type`), new TableColumn("")];
|
2021-02-09 09:22:49 +00:00
|
|
|
}
|
|
|
|
|
2021-08-05 10:30:43 +00:00
|
|
|
renderToolbarSelected(): TemplateResult {
|
2021-08-12 20:03:13 +00:00
|
|
|
const disabled = this.selectedElements.length < 1;
|
|
|
|
return html`<ak-forms-delete-bulk
|
|
|
|
objectLabel=${t`Source(s)`}
|
|
|
|
.objects=${this.selectedElements}
|
|
|
|
.usedBy=${(item: Source) => {
|
2021-08-05 10:30:43 +00:00
|
|
|
return new SourcesApi(DEFAULT_CONFIG).sourcesAllUsedByList({
|
|
|
|
slug: item.slug,
|
|
|
|
});
|
|
|
|
}}
|
2021-08-12 20:03:13 +00:00
|
|
|
.delete=${(item: Source) => {
|
2021-08-05 10:30:43 +00:00
|
|
|
return new SourcesApi(DEFAULT_CONFIG).sourcesAllDestroy({
|
|
|
|
slug: item.slug,
|
|
|
|
});
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger">
|
|
|
|
${t`Delete`}
|
|
|
|
</button>
|
2021-08-12 20:03:13 +00:00
|
|
|
</ak-forms-delete-bulk>`;
|
2021-08-05 10:30:43 +00:00
|
|
|
}
|
|
|
|
|
2021-02-09 09:22:49 +00:00
|
|
|
row(item: Source): TemplateResult[] {
|
2021-04-09 14:21:17 +00:00
|
|
|
if (item.component === "") {
|
|
|
|
return this.rowInbuilt(item);
|
|
|
|
}
|
2021-02-09 09:22:49 +00:00
|
|
|
return [
|
2021-02-19 18:29:17 +00:00
|
|
|
html`<a href="#/core/sources/${item.slug}">
|
2021-02-09 09:22:49 +00:00
|
|
|
<div>${item.name}</div>
|
2022-12-25 13:06:29 +00:00
|
|
|
${item.enabled
|
|
|
|
? html``
|
|
|
|
: html`<ak-label color=${PFColor.Orange} ?compact=${true}>
|
|
|
|
${t`Disabled`}</ak-label
|
|
|
|
>`}
|
2021-02-09 09:22:49 +00:00
|
|
|
</a>`,
|
2021-03-08 10:14:00 +00:00
|
|
|
html`${item.verboseName}`,
|
2021-08-03 15:52:21 +00:00
|
|
|
html` <ak-forms-modal>
|
2021-08-05 10:30:43 +00:00
|
|
|
<span slot="submit"> ${t`Update`} </span>
|
|
|
|
<span slot="header"> ${t`Update ${item.verboseName}`} </span>
|
|
|
|
<ak-proxy-form
|
|
|
|
slot="form"
|
|
|
|
.args=${{
|
|
|
|
instancePk: item.slug,
|
2021-08-03 15:52:21 +00:00
|
|
|
}}
|
2021-08-05 10:30:43 +00:00
|
|
|
type=${ifDefined(item.component)}
|
2021-08-03 15:52:21 +00:00
|
|
|
>
|
2021-08-05 10:30:43 +00:00
|
|
|
</ak-proxy-form>
|
|
|
|
<button slot="trigger" class="pf-c-button pf-m-plain">
|
|
|
|
<i class="fas fa-edit"></i>
|
|
|
|
</button>
|
|
|
|
</ak-forms-modal>`,
|
2021-02-09 09:22:49 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2021-04-09 14:21:17 +00:00
|
|
|
rowInbuilt(item: Source): TemplateResult[] {
|
|
|
|
return [
|
2022-12-25 13:06:29 +00:00
|
|
|
html`<div>
|
2021-04-09 14:21:17 +00:00
|
|
|
<div>${item.name}</div>
|
2022-12-25 13:06:29 +00:00
|
|
|
<ak-label color=${PFColor.Grey} ?compact=${true}> ${t`Built-in`}</ak-label>
|
|
|
|
</div>`,
|
2021-04-09 14:21:17 +00:00
|
|
|
html`${t`Built-in`}`,
|
|
|
|
html``,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2022-04-18 15:11:44 +00:00
|
|
|
renderObjectCreate(): TemplateResult {
|
|
|
|
return html`<ak-source-wizard> </ak-source-wizard> `;
|
2021-02-10 19:12:15 +00:00
|
|
|
}
|
2021-02-09 09:22:49 +00:00
|
|
|
}
|