import "@goauthentik/admin/events/EventInfo"; import "@goauthentik/admin/events/EventInfo"; import { ActionToLabel } 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 "@goauthentik/elements/Tabs"; import "@goauthentik/elements/buttons/Dropdown"; import "@goauthentik/elements/buttons/ModalButton"; import "@goauthentik/elements/buttons/SpinnerButton"; import { PaginatedResponse } from "@goauthentik/elements/table/Table"; import { Table, TableColumn } from "@goauthentik/elements/table/Table"; import { msg, str } from "@lit/localize"; import { TemplateResult, html } from "lit"; import { customElement, property } from "lit/decorators.js"; import { Event, EventsApi } from "@goauthentik/api"; @customElement("ak-events-user") export class UserEvents extends Table { expandable = true; @property() order = "-created"; @property() targetUser!: string; async apiEndpoint(page: number): Promise> { return new EventsApi(DEFAULT_CONFIG).eventsEventsList({ page: page, ordering: this.order, pageSize: (await uiConfig()).pagination.perPage, username: this.targetUser, }); } columns(): TableColumn[] { return [ new TableColumn(msg("Action"), "action"), new TableColumn(msg("User"), "enabled"), new TableColumn(msg("Creation Date"), "created"), new TableColumn(msg("Client IP"), "client_ip"), ]; } row(item: EventWithContext): TemplateResult[] { return [ html`${ActionToLabel(item.action)}`, html`
${item.user?.username}
${item.user.on_behalf_of ? html` ${msg(str`On behalf of ${item.user.on_behalf_of.username}`)} ` : html``}`, html`${item.created?.toLocaleString()}`, html`${item.clientIp || msg("-")}`, ]; } renderExpanded(item: Event): TemplateResult { return html`
`; } renderEmpty(): TemplateResult { return super.renderEmpty( html`
${msg("No matching events could be found.")}
`, ); } }