import { gettext } from "django"; import { customElement, html, property, TemplateResult } from "lit-element"; import { PBResponse } from "../../api/Client"; import { Event } from "../../api/Events"; import { TableColumn } from "../../elements/table/Table"; import { TablePage } from "../../elements/table/TablePage"; import { time } from "../../utils"; import "./EventInfo"; @customElement("ak-event-list") export class EventListPage extends TablePage { expandable = true; pageTitle(): string { return "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 Event.list({ ordering: this.order, page: page, search: this.search || "", }); } columns(): TableColumn[] { return [ new TableColumn("Action", "action"), new TableColumn("User", "user"), new TableColumn("Creation Date", "created"), new TableColumn("Client IP", "client_ip"), ]; } row(item: Event): TemplateResult[] { return [ html`
${item.action}
${item.app}`, html`
${item.user.username}
${item.user.on_behalf_of ? html` ${gettext(`On behalf of ${item.user.on_behalf_of.username}`)} ` : html``}`, html`${time(item.created).toLocaleString()}`, html`${item.client_ip}`, ]; } renderExpanded(item: Event): TemplateResult { return html`
`; } }