2021-04-03 17:26:43 +00:00
|
|
|
import { t } from "@lingui/macro";
|
2021-03-20 15:37:31 +00:00
|
|
|
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";
|
2021-03-20 16:50:48 +00:00
|
|
|
import AKGlobal from "../../authentik.css";
|
2021-03-20 15:37:31 +00:00
|
|
|
|
2021-03-29 14:16:27 +00:00
|
|
|
import "../../elements/forms/ModalForm";
|
|
|
|
import "./UserForm";
|
|
|
|
import "../../elements/buttons/ActionButton";
|
2021-03-20 15:37:31 +00:00
|
|
|
import "../../elements/buttons/SpinnerButton";
|
|
|
|
import "../../elements/CodeMirror";
|
|
|
|
import "../../elements/Tabs";
|
|
|
|
import "../../elements/events/ObjectChangelog";
|
|
|
|
import "../../elements/user/UserConsentList";
|
2021-03-20 15:47:39 +00:00
|
|
|
import "../../elements/oauth/UserCodeList";
|
|
|
|
import "../../elements/oauth/UserRefreshList";
|
2021-03-20 16:30:10 +00:00
|
|
|
import "../../elements/charts/UserChart";
|
2021-03-20 15:37:31 +00:00
|
|
|
import { Page } from "../../elements/Page";
|
|
|
|
import { CoreApi, User } from "authentik-api";
|
|
|
|
import { DEFAULT_CONFIG } from "../../api/Config";
|
2021-03-23 14:16:56 +00:00
|
|
|
import { EVENT_REFRESH } from "../../constants";
|
2021-03-29 14:16:27 +00:00
|
|
|
import { showMessage } from "../../elements/messages/MessageContainer";
|
|
|
|
import { MessageLevel } from "../../elements/messages/Message";
|
2021-03-20 15:37:31 +00:00
|
|
|
|
|
|
|
@customElement("ak-user-view")
|
|
|
|
export class UserViewPage extends Page {
|
|
|
|
pageTitle(): string {
|
2021-04-03 17:26:43 +00:00
|
|
|
return t`User ${this.user?.username || ""}`;
|
2021-03-20 15:37:31 +00:00
|
|
|
}
|
|
|
|
pageDescription(): string | undefined {
|
2021-03-20 16:50:48 +00:00
|
|
|
return this.user?.name || "";
|
2021-03-20 15:37:31 +00:00
|
|
|
}
|
|
|
|
pageIcon(): string {
|
2021-03-20 16:50:48 +00:00
|
|
|
return "pf-icon pf-icon-user";
|
2021-03-20 15:37:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@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();
|
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;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
renderContent(): TemplateResult {
|
|
|
|
if (!this.user) {
|
|
|
|
return html``;
|
|
|
|
}
|
|
|
|
return html`<ak-tabs>
|
2021-04-03 17:26:43 +00:00
|
|
|
<section slot="page-1" data-tab-title="${t`Overview`}" class="pf-c-page__main-section pf-m-no-padding-mobile">
|
2021-03-20 15:37:31 +00:00
|
|
|
<div class="pf-l-gallery pf-m-gutter">
|
2021-03-23 15:05:37 +00:00
|
|
|
<div class="pf-c-card pf-l-gallery__item pf-m-4-col">
|
2021-03-20 16:50:48 +00:00
|
|
|
<div class="pf-c-card__title">
|
2021-04-03 17:26:43 +00:00
|
|
|
${t`User Info`}
|
2021-03-20 16:50:48 +00:00
|
|
|
</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">
|
2021-04-03 17:26:43 +00:00
|
|
|
<span class="pf-c-description-list__text">${t`Username`}</span>
|
2021-03-20 16:50:48 +00:00
|
|
|
</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">
|
2021-04-03 17:26:43 +00:00
|
|
|
<span class="pf-c-description-list__text">${t`Name`}</span>
|
2021-03-20 16:50:48 +00:00
|
|
|
</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">
|
2021-04-03 17:26:43 +00:00
|
|
|
<span class="pf-c-description-list__text">${t`Email`}</span>
|
2021-03-20 16:50:48 +00:00
|
|
|
</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">
|
2021-04-03 17:26:43 +00:00
|
|
|
<span class="pf-c-description-list__text">${t`Last login`}</span>
|
2021-03-20 16:50:48 +00:00
|
|
|
</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">
|
2021-04-03 17:26:43 +00:00
|
|
|
<span class="pf-c-description-list__text">${t`Active`}</span>
|
2021-03-20 16:50:48 +00:00
|
|
|
</dt>
|
|
|
|
<dd class="pf-c-description-list__description">
|
|
|
|
<div class="pf-c-description-list__text">
|
|
|
|
<i class="fa ${this.user.isActive ? "fa-check-circle pf-m-success" : "fa-exclamation-triangle pf-m-warning"}"></i>
|
|
|
|
</div>
|
|
|
|
</dd>
|
|
|
|
</div>
|
|
|
|
<div class="pf-c-description-list__group">
|
|
|
|
<dt class="pf-c-description-list__term">
|
2021-04-03 17:26:43 +00:00
|
|
|
<span class="pf-c-description-list__text">${t`Superuser`}</span>
|
2021-03-20 16:50:48 +00:00
|
|
|
</dt>
|
|
|
|
<dd class="pf-c-description-list__description">
|
|
|
|
<div class="pf-c-description-list__text">
|
|
|
|
<i class="fa ${this.user.isSuperuser ? "fa-check-circle pf-m-success" : "fa-exclamation-triangle pf-m-warning"}"></i>
|
|
|
|
</div>
|
|
|
|
</dd>
|
|
|
|
</div>
|
|
|
|
</dl>
|
|
|
|
</div>
|
|
|
|
<div class="pf-c-card__footer">
|
2021-03-29 14:16:27 +00:00
|
|
|
<ak-forms-modal>
|
|
|
|
<span slot="submit">
|
2021-04-03 17:26:43 +00:00
|
|
|
${t`Update`}
|
2021-03-29 14:16:27 +00:00
|
|
|
</span>
|
|
|
|
<span slot="header">
|
2021-04-03 17:26:43 +00:00
|
|
|
${t`Update User`}
|
2021-03-29 14:16:27 +00:00
|
|
|
</span>
|
|
|
|
<ak-user-form slot="form" .user=${this.user}>
|
|
|
|
</ak-user-form>
|
|
|
|
<button slot="trigger" class="pf-m-primary pf-c-button">
|
2021-04-03 17:26:43 +00:00
|
|
|
${t`Edit`}
|
2021-03-29 14:16:27 +00:00
|
|
|
</button>
|
|
|
|
</ak-forms-modal>
|
2021-03-20 16:50:48 +00:00
|
|
|
</div>
|
|
|
|
<div class="pf-c-card__footer">
|
2021-03-29 14:16:27 +00:00
|
|
|
<ak-action-button
|
|
|
|
.apiRequest=${() => {
|
|
|
|
return new CoreApi(DEFAULT_CONFIG).coreUsersRecovery({
|
|
|
|
id: this.user?.pk || 0,
|
|
|
|
}).then(rec => {
|
|
|
|
showMessage({
|
|
|
|
level: MessageLevel.success,
|
2021-04-03 17:26:43 +00:00
|
|
|
message: t`Successfully generated recovery link`,
|
2021-03-29 14:16:27 +00:00
|
|
|
description: rec.link
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}}>
|
2021-04-03 17:26:43 +00:00
|
|
|
${t`Reset Password`}
|
2021-03-29 14:16:27 +00:00
|
|
|
</ak-action-button>
|
2021-03-20 16:50:48 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-03-23 15:05:37 +00:00
|
|
|
<div class="pf-c-card pf-l-gallery__item pf-m-4-col" style="grid-column-end: span 4;grid-row-end: span 2;">
|
2021-03-20 15:37:31 +00:00
|
|
|
<div class="pf-c-card__body">
|
2021-04-03 18:33:59 +00:00
|
|
|
<ak-charts-user userId=${this.user.pk}>
|
2021-03-20 16:30:10 +00:00
|
|
|
</ak-charts-user>
|
2021-03-20 15:37:31 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</section>
|
2021-04-03 17:26:43 +00:00
|
|
|
<section slot="page-2" data-tab-title="${t`Changelog`}" class="pf-c-page__main-section pf-m-no-padding-mobile">
|
2021-03-20 15:37:31 +00:00
|
|
|
<div class="pf-c-card">
|
|
|
|
<div class="pf-c-card__body">
|
|
|
|
<ak-object-changelog
|
2021-04-03 18:33:59 +00:00
|
|
|
targetModelPk=${this.user.pk || 0}
|
2021-03-20 15:37:31 +00:00
|
|
|
targetModelApp="authentik_core"
|
|
|
|
targetModelName="user">
|
|
|
|
</ak-object-changelog>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</section>
|
2021-04-03 17:26:43 +00:00
|
|
|
<section slot="page-3" data-tab-title="${t`Explicit Consent`}" class="pf-c-page__main-section pf-m-no-padding-mobile">
|
2021-03-20 15:37:31 +00:00
|
|
|
<div class="pf-c-card">
|
|
|
|
<div class="pf-c-card__body">
|
|
|
|
<ak-user-consent-list .userId="${(this.user.pk || 0).toString()}">
|
|
|
|
</ak-user-consent-list>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</section>
|
2021-04-03 17:26:43 +00:00
|
|
|
<section slot="page-4" data-tab-title="${t`OAuth Authorization Codes`}" class="pf-c-page__main-section pf-m-no-padding-mobile">
|
2021-03-20 15:47:39 +00:00
|
|
|
<div class="pf-c-card">
|
|
|
|
<div class="pf-c-card__body">
|
|
|
|
<ak-user-oauth-code-list .userId="${(this.user.pk || 0).toString()}">
|
|
|
|
</ak-user-oauth-code-list>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</section>
|
2021-04-03 17:26:43 +00:00
|
|
|
<section slot="page-5" data-tab-title="${t`OAuth Refresh Codes`}" class="pf-c-page__main-section pf-m-no-padding-mobile">
|
2021-03-20 15:47:39 +00:00
|
|
|
<div class="pf-c-card">
|
|
|
|
<div class="pf-c-card__body">
|
|
|
|
<ak-user-oauth-refresh-list .userId="${(this.user.pk || 0).toString()}">
|
|
|
|
</ak-user-oauth-refresh-list>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</section>
|
2021-03-20 15:37:31 +00:00
|
|
|
</ak-tabs>`;
|
|
|
|
}
|
|
|
|
}
|