import { t } from "@lingui/macro"; import { CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element"; import { EventsApi, EventTopPerUser } from "authentik-api"; import PFTable from "@patternfly/patternfly/components/Table/table.css"; import AKGlobal from "../../authentik.css"; 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 [PFTable, AKGlobal]; } firstUpdated(): void { new EventsApi(DEFAULT_CONFIG).eventsEventsTopPerUserList({ action: "authorize_application", topN: 11, }).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``}
${t`Application`} ${t`Logins`}
`; } }