2021-04-03 17:26:43 +00:00
|
|
|
import { t } from "@lingui/macro";
|
2021-09-21 09:31:37 +00:00
|
|
|
|
2021-09-21 09:19:26 +00:00
|
|
|
import { CSSResult, html, LitElement, TemplateResult } from "lit";
|
|
|
|
import { customElement, property } from "lit/decorators";
|
2021-03-20 15:37:31 +00:00
|
|
|
|
2021-09-21 09:31:37 +00:00
|
|
|
import AKGlobal from "../../authentik.css";
|
|
|
|
import PFButton from "@patternfly/patternfly/components/Button/button.css";
|
2021-03-20 15:37:31 +00:00
|
|
|
import PFCard from "@patternfly/patternfly/components/Card/card.css";
|
2021-09-21 09:31:37 +00:00
|
|
|
import PFContent from "@patternfly/patternfly/components/Content/content.css";
|
2021-03-20 15:37:31 +00:00
|
|
|
import PFDescriptionList from "@patternfly/patternfly/components/DescriptionList/description-list.css";
|
2021-09-21 09:31:37 +00:00
|
|
|
import PFPage from "@patternfly/patternfly/components/Page/page.css";
|
|
|
|
import PFGrid from "@patternfly/patternfly/layouts/Grid/grid.css";
|
2021-03-20 15:37:31 +00:00
|
|
|
import PFBase from "@patternfly/patternfly/patternfly-base.css";
|
2021-09-21 09:31:37 +00:00
|
|
|
import PFDisplay from "@patternfly/patternfly/utilities/Display/display.css";
|
|
|
|
import PFFlex from "@patternfly/patternfly/utilities/Flex/flex.css";
|
|
|
|
import PFSizing from "@patternfly/patternfly/utilities/Sizing/sizing.css";
|
|
|
|
|
|
|
|
import { CoreApi, User } from "@goauthentik/api";
|
2021-03-20 15:37:31 +00:00
|
|
|
|
2021-09-21 09:31:37 +00:00
|
|
|
import { DEFAULT_CONFIG } from "../../api/Config";
|
|
|
|
import { EVENT_REFRESH } from "../../constants";
|
|
|
|
import "../../elements/CodeMirror";
|
|
|
|
import { PFColor } from "../../elements/Label";
|
|
|
|
import "../../elements/PageHeader";
|
|
|
|
import "../../elements/Tabs";
|
2021-03-29 14:16:27 +00:00
|
|
|
import "../../elements/buttons/ActionButton";
|
2021-03-20 15:37:31 +00:00
|
|
|
import "../../elements/buttons/SpinnerButton";
|
2021-05-29 23:02:20 +00:00
|
|
|
import "../../elements/charts/UserChart";
|
2021-03-20 15:37:31 +00:00
|
|
|
import "../../elements/events/ObjectChangelog";
|
2021-05-29 23:02:20 +00:00
|
|
|
import "../../elements/events/UserEvents";
|
|
|
|
import "../../elements/forms/ModalForm";
|
2021-09-21 09:31:37 +00:00
|
|
|
import { MessageLevel } from "../../elements/messages/Message";
|
|
|
|
import { showMessage } from "../../elements/messages/MessageContainer";
|
2021-03-20 15:47:39 +00:00
|
|
|
import "../../elements/oauth/UserCodeList";
|
|
|
|
import "../../elements/oauth/UserRefreshList";
|
2021-05-29 23:02:20 +00:00
|
|
|
import "../../elements/user/SessionList";
|
|
|
|
import "../../elements/user/UserConsentList";
|
2021-04-11 16:42:30 +00:00
|
|
|
import "./UserForm";
|
2021-03-20 15:37:31 +00:00
|
|
|
|
|
|
|
@customElement("ak-user-view")
|
2021-04-10 15:06:54 +00:00
|
|
|
export class UserViewPage extends LitElement {
|
2021-03-20 15:37:31 +00:00
|
|
|
@property({ type: Number })
|
|
|
|
set userId(id: number) {
|
2021-08-03 15:52:21 +00:00
|
|
|
new CoreApi(DEFAULT_CONFIG)
|
|
|
|
.coreUsersRetrieve({
|
|
|
|
id: id,
|
|
|
|
})
|
|
|
|
.then((user) => {
|
|
|
|
this.user = user;
|
|
|
|
});
|
2021-03-20 15:37:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@property({ attribute: false })
|
|
|
|
user?: User;
|
|
|
|
|
|
|
|
static get styles(): CSSResult[] {
|
2021-08-03 15:52:21 +00:00
|
|
|
return [
|
|
|
|
PFBase,
|
|
|
|
PFPage,
|
|
|
|
PFFlex,
|
|
|
|
PFButton,
|
|
|
|
PFDisplay,
|
2021-08-05 21:13:55 +00:00
|
|
|
PFGrid,
|
2021-08-03 15:52:21 +00:00
|
|
|
PFContent,
|
|
|
|
PFCard,
|
|
|
|
PFDescriptionList,
|
|
|
|
PFSizing,
|
|
|
|
AKGlobal,
|
|
|
|
];
|
2021-03-20 15:37:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super();
|
2021-03-23 14:16:56 +00:00
|
|
|
this.addEventListener(EVENT_REFRESH, () => {
|
2021-03-20 15:37:31 +00:00
|
|
|
if (!this.user?.pk) return;
|
|
|
|
this.userId = this.user?.pk;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
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-user"
|
|
|
|
header=${t`User ${this.user?.username || ""}`}
|
|
|
|
description=${this.user?.name || ""}
|
|
|
|
>
|
|
|
|
</ak-page-header>
|
|
|
|
${this.renderBody()}`;
|
2021-04-10 15:06:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
renderBody(): TemplateResult {
|
2021-03-20 15:37:31 +00:00
|
|
|
if (!this.user) {
|
|
|
|
return html``;
|
|
|
|
}
|
|
|
|
return html`<ak-tabs>
|
2021-08-03 15:52:21 +00:00
|
|
|
<section
|
|
|
|
slot="page-overview"
|
|
|
|
data-tab-title="${t`Overview`}"
|
|
|
|
class="pf-c-page__main-section pf-m-no-padding-mobile"
|
|
|
|
>
|
2021-08-05 21:13:55 +00:00
|
|
|
<div class="pf-l-grid pf-m-gutter">
|
2021-08-05 22:11:24 +00:00
|
|
|
<div
|
2021-08-08 11:19:13 +00:00
|
|
|
class="pf-c-card pf-l-grid__item pf-m-12-col pf-m-2-col-on-xl pf-m-2-col-on-2xl"
|
2021-08-05 22:11:24 +00:00
|
|
|
>
|
2021-08-03 15:52:21 +00:00
|
|
|
<div class="pf-c-card__title">${t`User Info`}</div>
|
|
|
|
<div class="pf-c-card__body">
|
|
|
|
<dl class="pf-c-description-list">
|
|
|
|
<div class="pf-c-description-list__group">
|
|
|
|
<dt class="pf-c-description-list__term">
|
|
|
|
<span class="pf-c-description-list__text"
|
|
|
|
>${t`Username`}</span
|
|
|
|
>
|
|
|
|
</dt>
|
|
|
|
<dd class="pf-c-description-list__description">
|
|
|
|
<div class="pf-c-description-list__text">
|
|
|
|
${this.user.username}
|
|
|
|
</div>
|
|
|
|
</dd>
|
|
|
|
</div>
|
|
|
|
<div class="pf-c-description-list__group">
|
|
|
|
<dt class="pf-c-description-list__term">
|
|
|
|
<span class="pf-c-description-list__text">${t`Name`}</span>
|
|
|
|
</dt>
|
|
|
|
<dd class="pf-c-description-list__description">
|
|
|
|
<div class="pf-c-description-list__text">
|
|
|
|
${this.user.name}
|
|
|
|
</div>
|
|
|
|
</dd>
|
|
|
|
</div>
|
|
|
|
<div class="pf-c-description-list__group">
|
|
|
|
<dt class="pf-c-description-list__term">
|
|
|
|
<span class="pf-c-description-list__text">${t`Email`}</span>
|
|
|
|
</dt>
|
|
|
|
<dd class="pf-c-description-list__description">
|
|
|
|
<div class="pf-c-description-list__text">
|
|
|
|
${this.user.email}
|
|
|
|
</div>
|
|
|
|
</dd>
|
|
|
|
</div>
|
|
|
|
<div class="pf-c-description-list__group">
|
|
|
|
<dt class="pf-c-description-list__term">
|
|
|
|
<span class="pf-c-description-list__text"
|
|
|
|
>${t`Last login`}</span
|
|
|
|
>
|
|
|
|
</dt>
|
|
|
|
<dd class="pf-c-description-list__description">
|
|
|
|
<div class="pf-c-description-list__text">
|
|
|
|
${this.user.lastLogin?.toLocaleString()}
|
|
|
|
</div>
|
|
|
|
</dd>
|
|
|
|
</div>
|
|
|
|
<div class="pf-c-description-list__group">
|
|
|
|
<dt class="pf-c-description-list__term">
|
|
|
|
<span class="pf-c-description-list__text"
|
|
|
|
>${t`Active`}</span
|
|
|
|
>
|
|
|
|
</dt>
|
|
|
|
<dd class="pf-c-description-list__description">
|
|
|
|
<div class="pf-c-description-list__text">
|
|
|
|
<ak-label
|
|
|
|
color=${this.user.isActive
|
|
|
|
? PFColor.Green
|
|
|
|
: PFColor.Orange}
|
|
|
|
text=""
|
|
|
|
></ak-label>
|
|
|
|
</div>
|
|
|
|
</dd>
|
|
|
|
</div>
|
|
|
|
<div class="pf-c-description-list__group">
|
|
|
|
<dt class="pf-c-description-list__term">
|
|
|
|
<span class="pf-c-description-list__text"
|
|
|
|
>${t`Superuser`}</span
|
|
|
|
>
|
|
|
|
</dt>
|
|
|
|
<dd class="pf-c-description-list__description">
|
|
|
|
<div class="pf-c-description-list__text">
|
|
|
|
<ak-label
|
|
|
|
color=${this.user.isSuperuser
|
|
|
|
? PFColor.Green
|
|
|
|
: PFColor.Orange}
|
|
|
|
text=""
|
|
|
|
></ak-label>
|
|
|
|
</div>
|
|
|
|
</dd>
|
|
|
|
</div>
|
|
|
|
</dl>
|
|
|
|
</div>
|
|
|
|
<div class="pf-c-card__footer">
|
|
|
|
<ak-forms-modal>
|
|
|
|
<span slot="submit"> ${t`Update`} </span>
|
|
|
|
<span slot="header"> ${t`Update User`} </span>
|
|
|
|
<ak-user-form slot="form" .instancePk=${this.user.pk}>
|
|
|
|
</ak-user-form>
|
|
|
|
<button slot="trigger" class="pf-m-primary pf-c-button">
|
|
|
|
${t`Edit`}
|
|
|
|
</button>
|
|
|
|
</ak-forms-modal>
|
|
|
|
</div>
|
|
|
|
<div class="pf-c-card__footer">
|
|
|
|
<ak-action-button
|
|
|
|
.apiRequest=${() => {
|
|
|
|
return new CoreApi(DEFAULT_CONFIG)
|
|
|
|
.coreUsersRecoveryRetrieve({
|
2021-03-29 14:16:27 +00:00
|
|
|
id: this.user?.pk || 0,
|
2021-08-03 15:52:21 +00:00
|
|
|
})
|
|
|
|
.then((rec) => {
|
2021-03-29 14:16:27 +00:00
|
|
|
showMessage({
|
|
|
|
level: MessageLevel.success,
|
2021-04-03 17:26:43 +00:00
|
|
|
message: t`Successfully generated recovery link`,
|
2021-08-03 15:52:21 +00:00
|
|
|
description: rec.link,
|
2021-03-29 14:16:27 +00:00
|
|
|
});
|
|
|
|
});
|
2021-08-03 15:52:21 +00:00
|
|
|
}}
|
|
|
|
>
|
|
|
|
${t`Reset Password`}
|
|
|
|
</ak-action-button>
|
2021-03-20 15:37:31 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-08-03 15:52:21 +00:00
|
|
|
<div
|
2021-08-08 11:19:13 +00:00
|
|
|
class="pf-c-card pf-l-grid__item pf-m-12-col pf-m-10-col-on-xl pf-m-10-col-on-2xl"
|
2021-08-03 15:52:21 +00:00
|
|
|
>
|
2021-08-05 21:13:55 +00:00
|
|
|
<div class="pf-c-card__title">${t`Actions over the last 24 hours`}</div>
|
2021-05-29 23:02:20 +00:00
|
|
|
<div class="pf-c-card__body">
|
2021-08-03 15:52:21 +00:00
|
|
|
<ak-charts-user userId=${this.user.pk || 0}> </ak-charts-user>
|
2021-05-29 23:02:20 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-08-03 15:52:21 +00:00
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
<section
|
|
|
|
slot="page-sessions"
|
|
|
|
data-tab-title="${t`Sessions`}"
|
|
|
|
class="pf-c-page__main-section pf-m-no-padding-mobile"
|
|
|
|
>
|
|
|
|
<div class="pf-c-card">
|
|
|
|
<div class="pf-c-card__body">
|
|
|
|
<ak-user-session-list targetUser=${this.user.username}>
|
|
|
|
</ak-user-session-list>
|
2021-04-11 16:42:30 +00:00
|
|
|
</div>
|
2021-08-03 15:52:21 +00:00
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
<section
|
|
|
|
slot="page-events"
|
|
|
|
data-tab-title="${t`User events`}"
|
|
|
|
class="pf-c-page__main-section pf-m-no-padding-mobile"
|
|
|
|
>
|
|
|
|
<div class="pf-c-card">
|
|
|
|
<div class="pf-c-card__body">
|
|
|
|
<ak-events-user targetUser=${this.user.username}> </ak-events-user>
|
2021-03-20 15:37:31 +00:00
|
|
|
</div>
|
2021-08-03 15:52:21 +00:00
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
<section
|
|
|
|
slot="page-changelog"
|
|
|
|
data-tab-title="${t`Changelog`}"
|
|
|
|
class="pf-c-page__main-section pf-m-no-padding-mobile"
|
|
|
|
>
|
|
|
|
<div class="pf-c-card">
|
|
|
|
<div class="pf-c-card__body">
|
|
|
|
<ak-object-changelog
|
|
|
|
targetModelPk=${this.user.pk}
|
|
|
|
targetModelApp="authentik_core"
|
|
|
|
targetModelName="user"
|
|
|
|
>
|
|
|
|
</ak-object-changelog>
|
2021-03-20 15:37:31 +00:00
|
|
|
</div>
|
2021-08-03 15:52:21 +00:00
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
<section
|
|
|
|
slot="page-consent"
|
|
|
|
data-tab-title="${t`Explicit Consent`}"
|
|
|
|
class="pf-c-page__main-section pf-m-no-padding-mobile"
|
|
|
|
>
|
|
|
|
<div class="pf-c-card">
|
|
|
|
<div class="pf-c-card__body">
|
|
|
|
<ak-user-consent-list userId=${this.user.pk}> </ak-user-consent-list>
|
2021-03-20 15:47:39 +00:00
|
|
|
</div>
|
2021-08-03 15:52:21 +00:00
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
<section
|
|
|
|
slot="page-oauth-code"
|
|
|
|
data-tab-title="${t`OAuth Authorization Codes`}"
|
|
|
|
class="pf-c-page__main-section pf-m-no-padding-mobile"
|
|
|
|
>
|
|
|
|
<div class="pf-c-card">
|
|
|
|
<div class="pf-c-card__body">
|
|
|
|
<ak-user-oauth-code-list userId=${this.user.pk}> </ak-user-oauth-code-list>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
<section
|
|
|
|
slot="page-oauth-refresh"
|
|
|
|
data-tab-title="${t`OAuth Refresh Codes`}"
|
|
|
|
class="pf-c-page__main-section pf-m-no-padding-mobile"
|
|
|
|
>
|
|
|
|
<div class="pf-c-card">
|
|
|
|
<div class="pf-c-card__body">
|
|
|
|
<ak-user-oauth-refresh-list userId=${this.user.pk}>
|
|
|
|
</ak-user-oauth-refresh-list>
|
2021-03-20 15:47:39 +00:00
|
|
|
</div>
|
2021-08-03 15:52:21 +00:00
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</ak-tabs>`;
|
2021-03-20 15:37:31 +00:00
|
|
|
}
|
|
|
|
}
|