2020-12-28 13:26:41 +00:00
|
|
|
import { gettext } from "django";
|
|
|
|
import { customElement, html, property, TemplateResult } from "lit-element";
|
2021-02-09 16:04:55 +00:00
|
|
|
import { AKResponse } from "../../api/Client";
|
2020-12-28 13:26:41 +00:00
|
|
|
import { Event } from "../../api/Events";
|
2021-03-02 14:12:26 +00:00
|
|
|
import { PAGE_SIZE } from "../../constants";
|
2020-12-28 13:26:41 +00:00
|
|
|
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<Event> {
|
|
|
|
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";
|
|
|
|
|
2021-02-09 16:04:55 +00:00
|
|
|
apiEndpoint(page: number): Promise<AKResponse<Event>> {
|
2020-12-28 13:26:41 +00:00
|
|
|
return Event.list({
|
|
|
|
ordering: this.order,
|
|
|
|
page: page,
|
2021-03-02 14:12:26 +00:00
|
|
|
page_size: PAGE_SIZE * 3,
|
2020-12-28 13:26:41 +00:00
|
|
|
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`<div>${item.action}</div>
|
|
|
|
<small>${item.app}</small>`,
|
|
|
|
html`<div>${item.user.username}</div>
|
|
|
|
${item.user.on_behalf_of ? html`<small>
|
|
|
|
${gettext(`On behalf of ${item.user.on_behalf_of.username}`)}
|
|
|
|
</small>` : html``}`,
|
|
|
|
html`<span>${time(item.created).toLocaleString()}</span>`,
|
|
|
|
html`<span>${item.client_ip}</span>`,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
renderExpanded(item: Event): TemplateResult {
|
|
|
|
return html`
|
|
|
|
<td role="cell" colspan="4">
|
|
|
|
<div class="pf-c-table__expandable-row-content">
|
|
|
|
<ak-event-info .event=${item}></ak-event-info>
|
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
<td></td>
|
|
|
|
<td></td>
|
|
|
|
<td></td>`;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|