import { gettext } from "django"; import { CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element"; import { COMMON_STYLES } from "../../common/styles"; import { EventsApi, EventTopPerUser } from "authentik-api"; import "../../elements/Spinner"; import { DEFAULT_CONFIG } from "../../api/Config"; @customElement("ak-top-applications-table") export class TopApplicationsTable extends LitElement { @property({attribute: false}) topN?: EventTopPerUser[]; static get styles(): CSSResult[] { return COMMON_STYLES; } firstUpdated(): void { new EventsApi(DEFAULT_CONFIG).eventsEventsTopPerUser({ action: "authorize_application", }).then((events) => { this.topN = events; }); } renderRow(event: EventTopPerUser): TemplateResult { return html` ${event.application.name} ${event.countedEvents} `; } render(): TemplateResult { return html` ${this.topN ? this.topN.map((e) => this.renderRow(e)) : html``}
${gettext("Application")} ${gettext("Logins")}
`; } }