2021-04-10 18:53:57 +00:00
|
|
|
import { customElement, html, LitElement, property, TemplateResult } from "lit-element";
|
2021-02-04 08:54:00 +00:00
|
|
|
|
|
|
|
import "../../elements/buttons/SpinnerButton";
|
2021-03-17 16:11:39 +00:00
|
|
|
import "../../elements/EmptyState";
|
2021-04-10 15:06:54 +00:00
|
|
|
import "../../elements/PageHeader";
|
2021-02-06 16:55:41 +00:00
|
|
|
|
2021-04-01 13:39:59 +00:00
|
|
|
import "./saml/SAMLProviderViewPage";
|
|
|
|
import "./oauth2/OAuth2ProviderViewPage";
|
|
|
|
import "./proxy/ProxyProviderViewPage";
|
2021-05-05 19:57:13 +00:00
|
|
|
import "./ldap/LDAPProviderViewPage";
|
2021-08-15 19:32:28 +00:00
|
|
|
import { Provider, ProvidersApi } from "@goauthentik/api";
|
2021-03-08 10:14:00 +00:00
|
|
|
import { DEFAULT_CONFIG } from "../../api/Config";
|
|
|
|
import { ifDefined } from "lit-html/directives/if-defined";
|
2021-02-04 08:54:00 +00:00
|
|
|
|
|
|
|
@customElement("ak-provider-view")
|
|
|
|
export class ProviderViewPage extends LitElement {
|
2021-08-03 15:52:21 +00:00
|
|
|
@property({ type: Number })
|
2021-02-04 08:54:00 +00:00
|
|
|
set providerID(value: number) {
|
2021-08-03 15:52:21 +00:00
|
|
|
new ProvidersApi(DEFAULT_CONFIG)
|
|
|
|
.providersAllRetrieve({
|
|
|
|
id: value,
|
|
|
|
})
|
|
|
|
.then((prov) => (this.provider = prov));
|
2021-02-04 08:54:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@property({ attribute: false })
|
|
|
|
provider?: Provider;
|
|
|
|
|
2021-04-10 15:06:54 +00:00
|
|
|
renderProvider(): TemplateResult {
|
2021-02-06 16:55:41 +00:00
|
|
|
if (!this.provider) {
|
2021-03-17 18:00:57 +00:00
|
|
|
return html`<ak-empty-state ?loading=${true} ?fullHeight=${true}></ak-empty-state>`;
|
2021-02-06 16:55:41 +00:00
|
|
|
}
|
2021-04-03 09:32:17 +00:00
|
|
|
switch (this.provider?.component) {
|
|
|
|
case "ak-provider-saml-form":
|
2021-08-03 15:52:21 +00:00
|
|
|
return html`<ak-provider-saml-view
|
|
|
|
providerID=${ifDefined(this.provider.pk)}
|
|
|
|
></ak-provider-saml-view>`;
|
2021-04-03 09:32:17 +00:00
|
|
|
case "ak-provider-oauth2-form":
|
2021-08-03 15:52:21 +00:00
|
|
|
return html`<ak-provider-oauth2-view
|
|
|
|
providerID=${ifDefined(this.provider.pk)}
|
|
|
|
></ak-provider-oauth2-view>`;
|
2021-04-03 09:32:17 +00:00
|
|
|
case "ak-provider-proxy-form":
|
2021-08-03 15:52:21 +00:00
|
|
|
return html`<ak-provider-proxy-view
|
|
|
|
providerID=${ifDefined(this.provider.pk)}
|
|
|
|
></ak-provider-proxy-view>`;
|
2021-05-05 19:57:13 +00:00
|
|
|
case "ak-provider-ldap-form":
|
2021-08-03 15:52:21 +00:00
|
|
|
return html`<ak-provider-ldap-view
|
|
|
|
providerID=${ifDefined(this.provider.pk)}
|
|
|
|
></ak-provider-ldap-view>`;
|
2021-02-06 16:55:41 +00:00
|
|
|
default:
|
2021-04-03 09:32:17 +00:00
|
|
|
return html`<p>Invalid provider type ${this.provider?.component}</p>`;
|
2021-02-06 16:55:41 +00:00
|
|
|
}
|
|
|
|
}
|
2021-04-10 15:06:54 +00:00
|
|
|
|
|
|
|
render(): TemplateResult {
|
|
|
|
return html`<ak-page-header
|
2021-08-03 15:52:21 +00:00
|
|
|
icon="pf-icon pf-icon-integration"
|
|
|
|
header=${ifDefined(this.provider?.name)}
|
|
|
|
description=${ifDefined(this.provider?.verboseName)}
|
|
|
|
>
|
|
|
|
</ak-page-header>
|
|
|
|
${this.renderProvider()}`;
|
2021-04-10 15:06:54 +00:00
|
|
|
}
|
2021-02-04 08:54:00 +00:00
|
|
|
}
|