import { t } from "@lingui/macro"; import { CSSResult, customElement, html, property, TemplateResult } from "lit-element"; import PFPage from "@patternfly/patternfly/components/Page/page.css"; import PFContent from "@patternfly/patternfly/components/Content/content.css"; import PFGallery from "@patternfly/patternfly/layouts/Gallery/gallery.css"; import PFCard from "@patternfly/patternfly/components/Card/card.css"; import PFDescriptionList from "@patternfly/patternfly/components/DescriptionList/description-list.css"; import PFSizing from "@patternfly/patternfly/utilities/Sizing/sizing.css"; import PFFlex from "@patternfly/patternfly/utilities/Flex/flex.css"; import PFDisplay from "@patternfly/patternfly/utilities/Display/display.css"; import PFBase from "@patternfly/patternfly/patternfly-base.css"; import AKGlobal from "../../authentik.css"; import "../../elements/forms/ModalForm"; import "./UserForm"; import "../../elements/buttons/ActionButton"; import "../../elements/buttons/SpinnerButton"; import "../../elements/CodeMirror"; import "../../elements/Tabs"; import "../../elements/events/ObjectChangelog"; import "../../elements/user/UserConsentList"; import "../../elements/oauth/UserCodeList"; import "../../elements/oauth/UserRefreshList"; import "../../elements/charts/UserChart"; import { Page } from "../../elements/Page"; import { CoreApi, User } from "authentik-api"; import { DEFAULT_CONFIG } from "../../api/Config"; import { EVENT_REFRESH } from "../../constants"; import { showMessage } from "../../elements/messages/MessageContainer"; import { MessageLevel } from "../../elements/messages/Message"; @customElement("ak-user-view") export class UserViewPage extends Page { pageTitle(): string { return t`User ${this.user?.username || ""}`; } pageDescription(): string | undefined { return this.user?.name || ""; } pageIcon(): string { return "pf-icon pf-icon-user"; } @property({ type: Number }) set userId(id: number) { new CoreApi(DEFAULT_CONFIG).coreUsersRead({ id: id, }).then((user) => { this.user = user; }); } @property({ attribute: false }) user?: User; static get styles(): CSSResult[] { return [PFBase, PFPage, PFFlex, PFDisplay, PFGallery, PFContent, PFCard, PFDescriptionList, PFSizing, AKGlobal]; } constructor() { super(); this.addEventListener(EVENT_REFRESH, () => { if (!this.user?.pk) return; this.userId = this.user?.pk; }); } renderContent(): TemplateResult { if (!this.user) { return html``; } return html`
`; } }