From bf09a54f35b0911a12cd082684b3f9a00ba73311 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 18 Sep 2021 18:16:27 +0200 Subject: [PATCH] web/user: optimise load, fix unread status for notifications Signed-off-by: Jens Langhammer --- web/src/interfaces/UserInterface.ts | 4 +- web/src/user/LibraryApplication.ts | 115 ++++++++++++++++++++++++++++ web/src/user/LibraryPage.ts | 110 +++----------------------- 3 files changed, 126 insertions(+), 103 deletions(-) create mode 100644 web/src/user/LibraryApplication.ts diff --git a/web/src/interfaces/UserInterface.ts b/web/src/interfaces/UserInterface.ts index a33e155c2..de7a3ea1b 100644 --- a/web/src/interfaces/UserInterface.ts +++ b/web/src/interfaces/UserInterface.ts @@ -154,8 +154,8 @@ export class UserInterface extends LitElement { `; + } + return html`
+
+ ${this.application.metaIcon + ? html`${t`Application Icon`}` + : html``} + ${until( + uiConfig().then((config) => { + if (!config.enabledFeatures.applicationEdit) { + return html``; + } + return me().then((u) => { + if (!u.user.isSuperuser) return html``; + return html` + + + + `; + }); + }), + )} +
+
+

+ ${this.application.name} +

+
+ ${this.application.metaPublisher} +
+
+
${truncate(this.application.metaDescription, 35)}
+
`; + } +} diff --git a/web/src/user/LibraryPage.ts b/web/src/user/LibraryPage.ts index cdd2fb68e..e41aa6731 100644 --- a/web/src/user/LibraryPage.ts +++ b/web/src/user/LibraryPage.ts @@ -8,116 +8,30 @@ import { property, TemplateResult, } from "lit-element"; -import { ifDefined } from "lit-html/directives/if-defined"; -import { until } from "lit-html/directives/until"; import { Application, CoreApi } from "@goauthentik/api"; import { AKResponse } from "../api/Client"; import { DEFAULT_CONFIG } from "../api/Config"; -import { me } from "../api/Users"; -import { loading, truncate } from "../utils"; +import { loading } from "../utils"; import AKGlobal from "../authentik.css"; -import PFAvatar from "@patternfly/patternfly/components/Avatar/avatar.css"; import PFBase from "@patternfly/patternfly/patternfly-base.css"; -import PFButton from "@patternfly/patternfly/components/Button/button.css"; -import PFCard from "@patternfly/patternfly/components/Card/card.css"; import PFContent from "@patternfly/patternfly/components/Content/content.css"; import PFEmptyState from "@patternfly/patternfly/components/EmptyState/empty-state.css"; import PFGallery from "@patternfly/patternfly/layouts/Gallery/gallery.css"; import PFPage from "@patternfly/patternfly/components/Page/page.css"; -import { uiConfig } from "./config"; - -@customElement("ak-library-app") -export class LibraryApplication extends LitElement { - @property({ attribute: false }) - application?: Application; - - static get styles(): CSSResult[] { - return [ - PFBase, - PFCard, - PFButton, - PFAvatar, - AKGlobal, - css` - .pf-c-card { - height: 100%; - } - i.pf-icon { - height: 36px; - display: flex; - flex-direction: column; - justify-content: center; - } - .pf-c-avatar { - --pf-c-avatar--BorderRadius: 0; - } - .pf-c-card__header { - min-height: 60px; - justify-content: space-between; - } - .pf-c-card__header a { - display: flex; - flex-direction: column; - justify-content: center; - margin-right: 0.25em; - } - `, - ]; - } - - render(): TemplateResult { - if (!this.application) { - return html``; - } - return html`
-
- ${this.application.metaIcon - ? html`Application Icon` - : html``} - ${until( - uiConfig().then((config) => { - if (!config.enabledFeatures.applicationEdit) { - return html``; - } - return me().then((u) => { - if (!u.user.isSuperuser) return html``; - return html` - - - - `; - }); - }), - )} -
-
-

- ${this.application.name} -

-
- ${this.application.metaPublisher} -
-
-
${truncate(this.application.metaDescription, 35)}
-
`; - } -} +import "./LibraryApplication"; @customElement("ak-library") export class LibraryPage extends LitElement { @property({ attribute: false }) apps?: AKResponse; + constructor() { + super(); + new CoreApi(DEFAULT_CONFIG).coreApplicationsList({}).then((apps) => { + this.apps = apps; + }); + } + pageTitle(): string { return t`My Applications`; } @@ -132,12 +46,6 @@ export class LibraryPage extends LitElement { `); } - firstUpdated(): void { - new CoreApi(DEFAULT_CONFIG).coreApplicationsList({}).then((apps) => { - this.apps = apps; - }); - } - renderEmptyState(): TemplateResult { return html`