import { t } from "@lingui/macro"; import { customElement, html, property, TemplateResult } from "lit-element"; import { Event, EventsApi } from "authentik-api"; import { AKResponse } from "../../api/Client"; import { DEFAULT_CONFIG } from "../../api/Config"; import { EventWithContext } from "../../api/Events"; import { PAGE_SIZE } from "../../constants"; import { TableColumn } from "../../elements/table/Table"; import { TablePage } from "../../elements/table/TablePage"; import "./EventInfo"; @customElement("ak-event-list") export class EventListPage extends TablePage { expandable = true; pageTitle(): string { return t`Event Log`; } pageDescription(): string | undefined { return; } pageIcon(): string { return "pf-icon pf-icon-catalog"; } searchEnabled(): boolean { return true; } @property() order = "-created"; apiEndpoint(page: number): Promise> { return new EventsApi(DEFAULT_CONFIG).eventsEventsList({ ordering: this.order, page: page, pageSize: PAGE_SIZE, search: this.search || "", }); } columns(): TableColumn[] { return [ new TableColumn(t`Action`, "action"), new TableColumn(t`User`, "user"), new TableColumn(t`Creation Date`, "created"), new TableColumn(t`Client IP`, "client_ip"), new TableColumn(""), ]; } row(item: EventWithContext): TemplateResult[] { return [ html`
${item.action}
${item.app}`, item.user?.username ? html` ${item.user?.username} ${item.user.on_behalf_of ? html` ${t`On behalf of ${item.user.on_behalf_of.username}`} ` : html``}` : html`-`, html`${item.created?.toLocaleString()}`, html`${item.clientIp || "-"}`, html` `, ]; } renderExpanded(item: Event): TemplateResult { return html`
`; } }