import { css, CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element"; import { Application } from "../api/application"; import { PBResponse } from "../api/client"; import { COMMON_STYLES } from "../common/styles"; import { truncate } from "../utils"; @customElement("pb-library") export class ApplicationViewPage extends LitElement { @property({attribute: false}) apps?: PBResponse; static get styles(): CSSResult[] { return COMMON_STYLES.concat( css` img.pf-icon { max-height: 24px; } .pf-c-avatar { --pf-c-avatar--BorderRadius: 0; } ` ); } firstUpdated(): void { Application.list().then((r) => (this.apps = r)); } renderEmptyState(): TemplateResult { return html` No Applications available. Either no applications are defined, or you don't have access to any. {% if perms.passbook_core.add_application %} {% trans 'Create Application' %} {% endif %} `; } renderApp(app: Application): TemplateResult { return html` ${app.meta_icon ? html`` : html``} ${app.name} ${app.meta_publisher} ${truncate(app.meta_description, 35)} `; } renderLoading(): TemplateResult { return html` `; } render(): TemplateResult { return html` Applications ${this.apps ? html` ${this.apps.results.map((app) => this.renderApp(app))} ` : this.renderLoading()} `; } }
${app.name}