import { html, TemplateResult } from "lit-html"; import { until } from "lit-html/directives/until"; import { EVENT_REFRESH } from "../../../constants"; import { AggregateCard } from "../../../elements/cards/AggregateCard"; import { PFSize } from "../../../elements/Spinner"; export interface AdminStatus { icon: string; message?: string; } export abstract class AdminStatusCard extends AggregateCard { abstract getPrimaryValue(): Promise; abstract getStatus(value: T): Promise; value?: T; constructor() { super(); this.addEventListener(EVENT_REFRESH, () => { this.requestUpdate(); }); } renderValue(): TemplateResult { return html`${this.value}`; } renderInner(): TemplateResult { return html`

${until(this.getPrimaryValue().then((v) => { this.value = v; return this.getStatus(v); }).then((status) => { return html`

 ${this.renderValue()}

${status.message ? html`

${status.message}

` : html``}`; }), html``)}

`; } }