import { t } from "@lingui/macro"; import { customElement, html, property, TemplateResult } from "lit-element"; import { AKResponse } from "../../api/Client"; import { Table, TableColumn } from "../table/Table"; import { Event, EventsApi } from "authentik-api"; import "../forms/DeleteForm"; import "../Tabs"; import "../buttons/ModalButton"; import "../buttons/SpinnerButton"; import "../buttons/Dropdown"; import "../../pages/events/EventInfo"; import { PAGE_SIZE } from "../../constants"; import { DEFAULT_CONFIG } from "../../api/Config"; import { EventWithContext } from "../../api/Events"; @customElement("ak-events-user") export class ObjectChangelog extends Table { expandable = true; @property() order = "-created"; @property() targetUser!: string; apiEndpoint(page: number): Promise> { return new EventsApi(DEFAULT_CONFIG).eventsEventsList({ page: page, ordering: this.order, pageSize: PAGE_SIZE / 2, username: this.targetUser }); } columns(): TableColumn[] { return [ new TableColumn(t`Action`, "action"), new TableColumn(t`User`, "enabled"), new TableColumn(t`Creation Date`, "created"), new TableColumn(t`Client IP`, "client_ip"), ]; } row(item: EventWithContext): TemplateResult[] { return [ html`${item.action}`, html`
${item.user?.username}
${item.user.on_behalf_of ? html` ${t`On behalf of ${item.user.on_behalf_of.username}`} ` : html``}`, html`${item.created?.toLocaleString()}`, html`${item.clientIp || "-"}`, ]; } renderExpanded(item: Event): TemplateResult { return html`
`; } renderEmpty(): TemplateResult { return super.renderEmpty(html`
${t`No matching events could be found.`}
`); } }