import { gettext } from "django"; import { css, CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element"; import { ifDefined } from "lit-html/directives/if-defined"; import { Application } from "../api/Applications"; import { PBResponse } from "../api/Client"; import { COMMON_STYLES } from "../common/styles"; import { loading, truncate } from "../utils"; @customElement("ak-library-app") export class LibraryApplication extends LitElement { @property({attribute: false}) application?: Application; static get styles(): CSSResult[] { return COMMON_STYLES.concat( css` a { height: 100%; } i.pf-icon { height: 36px; } .pf-c-avatar { --pf-c-avatar--BorderRadius: 0; } ` ); } render(): TemplateResult { if (!this.application) { return html``; } return html` ${this.application.meta_icon ? html`` : html``} ${this.application.name} ${this.application.meta_publisher} ${truncate(this.application.meta_description, 35)} `; } } @customElement("ak-library") export class LibraryPage extends LitElement { @property({attribute: false}) apps?: PBResponse; static get styles(): CSSResult[] { return COMMON_STYLES; } firstUpdated(): void { Application.list().then((r) => (this.apps = r)); } renderEmptyState(): TemplateResult { return html` ${gettext("No Applications available.")} ${gettext("Either no applications are defined, or you don't have access to any.")} `; } renderApps(): TemplateResult { return html` ${this.apps?.results.map((app) => html``)} `; } render(): TemplateResult { return html` ${gettext("Applications")} ${loading(this.apps, html`${(this.apps?.results.length || 0) > 0 ? this.renderApps() : this.renderEmptyState()}`)} `; } }
${this.application.name}