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
1.8 KiB
TypeScript
Raw Normal View History

import { css, CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element";
2021-02-04 08:54:00 +00:00
import "../../elements/buttons/ModalButton";
import "../../elements/buttons/SpinnerButton";
import "../../elements/EmptyState";
2021-02-06 16:55:41 +00:00
import "./SAMLProviderViewPage";
2021-02-06 17:35:55 +00:00
import "./OAuth2ProviderViewPage";
2021-02-06 17:57:25 +00:00
import "./ProxyProviderViewPage";
import { Provider, ProvidersApi } from "authentik-api";
import { DEFAULT_CONFIG } from "../../api/Config";
import { ifDefined } from "lit-html/directives/if-defined";
import { gettext } from "django";
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).providersAllRead({
id: value,
}).then((prov) => (this.provider = prov));
2021-02-04 08:54:00 +00:00
}
@property({ attribute: false })
provider?: Provider;
2021-02-06 16:55:41 +00:00
static get styles(): CSSResult[] {
return [css`
* {
height: 100%;
}
`];
2021-02-06 16:55:41 +00:00
}
render(): TemplateResult {
if (!this.provider) {
return html`<ak-empty-state
?loading="${true}"
header=${gettext("Loading")}>
</ak-empty-state>`;
2021-02-06 16:55:41 +00:00
}
switch (this.provider?.objectType) {
2021-02-06 16:55:41 +00:00
case "saml":
return html`<ak-provider-saml-view providerID=${ifDefined(this.provider.pk)}></ak-provider-saml-view>`;
2021-02-06 17:35:55 +00:00
case "oauth2":
return html`<ak-provider-oauth2-view providerID=${ifDefined(this.provider.pk)}></ak-provider-oauth2-view>`;
2021-02-06 17:57:25 +00:00
case "proxy":
return html`<ak-provider-proxy-view providerID=${ifDefined(this.provider.pk)}></ak-provider-proxy-view>`;
2021-02-06 16:55:41 +00:00
default:
return html`<p>Invalid provider type ${this.provider?.objectType}</p>`;
2021-02-06 16:55:41 +00:00
}
}
2021-02-04 08:54:00 +00:00
}