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/providers/ProviderViewPage.ts

55 lines
2.1 KiB
TypeScript
Raw Normal View History

import { customElement, html, LitElement, property, TemplateResult } from "lit-element";
2021-02-04 08:54:00 +00:00
import "../../elements/buttons/SpinnerButton";
import "../../elements/EmptyState";
import "../../elements/PageHeader";
2021-02-06 16:55:41 +00:00
import "./saml/SAMLProviderViewPage";
import "./oauth2/OAuth2ProviderViewPage";
import "./proxy/ProxyProviderViewPage";
import "./ldap/LDAPProviderViewPage";
import { Provider, ProvidersApi } from "authentik-api";
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-02-04 09:22:14 +00:00
@property({type: Number})
2021-02-04 08:54:00 +00:00
set providerID(value: number) {
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;
renderProvider(): TemplateResult {
2021-02-06 16:55:41 +00:00
if (!this.provider) {
return html`<ak-empty-state ?loading=${true} ?fullHeight=${true}></ak-empty-state>`;
2021-02-06 16:55:41 +00:00
}
switch (this.provider?.component) {
case "ak-provider-saml-form":
return html`<ak-provider-saml-view providerID=${ifDefined(this.provider.pk)}></ak-provider-saml-view>`;
case "ak-provider-oauth2-form":
return html`<ak-provider-oauth2-view providerID=${ifDefined(this.provider.pk)}></ak-provider-oauth2-view>`;
case "ak-provider-proxy-form":
return html`<ak-provider-proxy-view providerID=${ifDefined(this.provider.pk)}></ak-provider-proxy-view>`;
case "ak-provider-ldap-form":
return html`<ak-provider-ldap-view providerID=${ifDefined(this.provider.pk)}></ak-provider-ldap-view>`;
2021-02-06 16:55:41 +00:00
default:
return html`<p>Invalid provider type ${this.provider?.component}</p>`;
2021-02-06 16:55:41 +00:00
}
}
render(): TemplateResult {
return html`<ak-page-header
icon="pf-icon pf-icon-integration"
header=${ifDefined(this.provider?.name)}
description=${ifDefined(this.provider?.verboseName)}>
</ak-page-header>
${this.renderProvider()}`;
}
2021-02-04 08:54:00 +00:00
}