From 4525a43e63fae05e70d6c639972c1d322f305e68 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 20 Mar 2021 16:37:31 +0100 Subject: [PATCH] web: add initial user view page with consent Signed-off-by: Jens Langhammer --- web/src/elements/user/UserConsentList.ts | 55 +++++++++++ web/src/interfaces/AdminInterface.ts | 2 +- .../pages/applications/ApplicationViewPage.ts | 4 +- web/src/pages/users/UserListPage.ts | 4 +- web/src/pages/users/UserViewPage.ts | 96 +++++++++++++++++++ web/src/routes.ts | 12 ++- 6 files changed, 164 insertions(+), 9 deletions(-) create mode 100644 web/src/elements/user/UserConsentList.ts create mode 100644 web/src/pages/users/UserViewPage.ts diff --git a/web/src/elements/user/UserConsentList.ts b/web/src/elements/user/UserConsentList.ts new file mode 100644 index 000000000..921bb43ef --- /dev/null +++ b/web/src/elements/user/UserConsentList.ts @@ -0,0 +1,55 @@ +import { gettext } from "django"; +import { customElement, html, property, TemplateResult } from "lit-element"; +import { AKResponse } from "../../api/Client"; +import { Table, TableColumn } from "../table/Table"; + +import "../forms/DeleteForm"; +import { PAGE_SIZE } from "../../constants"; +import { CoreApi, UserConsent } from "authentik-api"; +import { DEFAULT_CONFIG } from "../../api/Config"; + +@customElement("ak-user-consent-list") +export class UserConsentList extends Table { + @property() + userId?: string; + + apiEndpoint(page: number): Promise> { + return new CoreApi(DEFAULT_CONFIG).coreUserConsentList({ + user: this.userId, + ordering: "expires", + page: page, + pageSize: PAGE_SIZE, + }); + } + + order = "-expires"; + + columns(): TableColumn[] { + return [ + new TableColumn("Application", "application"), + new TableColumn("Expires", "expires"), + new TableColumn(""), + ]; + } + + row(item: UserConsent): TemplateResult[] { + return [ + html`${item.application.name}`, + html`${item.expires?.toLocaleString()}`, + html` + { + return new CoreApi(DEFAULT_CONFIG).coreUserConsentDelete({ + id: item.pk || 0, + }); + }}> + + `, + ]; + } + +} diff --git a/web/src/interfaces/AdminInterface.ts b/web/src/interfaces/AdminInterface.ts index 68322fba2..9a9821fdc 100644 --- a/web/src/interfaces/AdminInterface.ts +++ b/web/src/interfaces/AdminInterface.ts @@ -51,7 +51,7 @@ export const SIDEBAR_ITEMS: SidebarItem[] = [ return me().then(u => u.isSuperuser||false); }), new SidebarItem("Identity & Cryptography").children( - new SidebarItem("User", "/identity/users"), + new SidebarItem("User", "/identity/users").activeWhen(`^/identity/users/(?${ID_REGEX})$`), new SidebarItem("Groups", "/identity/groups"), new SidebarItem("Certificates", "/crypto/certificates"), new SidebarItem("Tokens", "/core/tokens"), diff --git a/web/src/pages/applications/ApplicationViewPage.ts b/web/src/pages/applications/ApplicationViewPage.ts index a3992f292..c4a663dcf 100644 --- a/web/src/pages/applications/ApplicationViewPage.ts +++ b/web/src/pages/applications/ApplicationViewPage.ts @@ -78,9 +78,9 @@ export class ApplicationViewPage extends LitElement {