import "@goauthentik/admin/events/EventInfo"; import { ActionToLabel, EventGeo } from "@goauthentik/admin/events/utils"; import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; import { EventWithContext } from "@goauthentik/common/events"; import { uiConfig } from "@goauthentik/common/ui/config"; import { PaginatedResponse } from "@goauthentik/elements/table/Table"; import { TableColumn } from "@goauthentik/elements/table/Table"; import { TablePage } from "@goauthentik/elements/table/TablePage"; import { t } from "@lingui/macro"; import { TemplateResult, html } from "lit"; import { customElement, property } from "lit/decorators.js"; import { Event, EventsApi } from "@goauthentik/api"; @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"; async apiEndpoint(page: number): Promise> { return new EventsApi(DEFAULT_CONFIG).eventsEventsList({ ordering: this.order, page: page, pageSize: (await uiConfig()).pagination.perPage, 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(t`Tenant`, "tenant_name"), new TableColumn(t`Actions`), ]; } row(item: EventWithContext): TemplateResult[] { return [ html`
${ActionToLabel(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 || t`-`}
${EventGeo(item)}`, html`${item.tenant?.name || t`-`}`, html` `, ]; } renderExpanded(item: Event): TemplateResult { return html`
`; } }