2021-04-11 16:42:30 +00:00
|
|
|
import { t } from "@lingui/macro";
|
2021-09-21 09:31:37 +00:00
|
|
|
|
2021-09-21 09:19:26 +00:00
|
|
|
import { html, TemplateResult } from "lit";
|
|
|
|
import { customElement, property } from "lit/decorators";
|
2021-09-21 09:31:37 +00:00
|
|
|
|
2021-08-15 19:32:28 +00:00
|
|
|
import { Event, EventsApi } from "@goauthentik/api";
|
2021-04-11 16:42:30 +00:00
|
|
|
|
2021-09-21 09:31:37 +00:00
|
|
|
import { AKResponse } from "../../api/Client";
|
|
|
|
import { DEFAULT_CONFIG } from "../../api/Config";
|
|
|
|
import { EventWithContext } from "../../api/Events";
|
2021-10-14 10:48:52 +00:00
|
|
|
import { uiConfig } from "../../common/config";
|
2021-09-21 09:31:37 +00:00
|
|
|
import "../../pages/events/EventInfo";
|
2021-04-11 16:42:30 +00:00
|
|
|
import "../Tabs";
|
2021-09-21 09:31:37 +00:00
|
|
|
import "../buttons/Dropdown";
|
2021-04-11 16:42:30 +00:00
|
|
|
import "../buttons/ModalButton";
|
|
|
|
import "../buttons/SpinnerButton";
|
2021-09-21 09:31:37 +00:00
|
|
|
import { Table, TableColumn } from "../table/Table";
|
2021-04-11 16:42:30 +00:00
|
|
|
|
|
|
|
@customElement("ak-events-user")
|
|
|
|
export class ObjectChangelog extends Table<Event> {
|
|
|
|
expandable = true;
|
|
|
|
|
|
|
|
@property()
|
|
|
|
order = "-created";
|
|
|
|
|
|
|
|
@property()
|
|
|
|
targetUser!: string;
|
|
|
|
|
2021-10-14 10:48:52 +00:00
|
|
|
async apiEndpoint(page: number): Promise<AKResponse<Event>> {
|
2021-04-11 16:42:30 +00:00
|
|
|
return new EventsApi(DEFAULT_CONFIG).eventsEventsList({
|
|
|
|
page: page,
|
|
|
|
ordering: this.order,
|
2021-10-14 10:48:52 +00:00
|
|
|
pageSize: (await uiConfig()).pagination.perPage / 2,
|
2021-08-03 15:52:21 +00:00
|
|
|
username: this.targetUser,
|
2021-04-11 16:42:30 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
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`<div>${item.user?.username}</div>
|
2021-08-03 15:52:21 +00:00
|
|
|
${item.user.on_behalf_of
|
|
|
|
? html`<small> ${t`On behalf of ${item.user.on_behalf_of.username}`} </small>`
|
|
|
|
: html``}`,
|
2021-04-11 16:42:30 +00:00
|
|
|
html`<span>${item.created?.toLocaleString()}</span>`,
|
2021-09-19 14:08:30 +00:00
|
|
|
html`<span>${item.clientIp || t`-`}</span>`,
|
2021-04-11 16:42:30 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
renderExpanded(item: Event): TemplateResult {
|
2021-08-03 15:52:21 +00:00
|
|
|
return html` <td role="cell" colspan="4">
|
|
|
|
<div class="pf-c-table__expandable-row-content">
|
|
|
|
<ak-event-info .event=${item as EventWithContext}></ak-event-info>
|
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
<td></td>
|
|
|
|
<td></td>
|
|
|
|
<td></td>`;
|
2021-04-11 16:42:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
renderEmpty(): TemplateResult {
|
|
|
|
return super.renderEmpty(html`<ak-empty-state header=${t`No Events found.`}>
|
2021-08-03 15:52:21 +00:00
|
|
|
<div slot="body">${t`No matching events could be found.`}</div>
|
2021-04-11 16:42:30 +00:00
|
|
|
</ak-empty-state>`);
|
|
|
|
}
|
|
|
|
}
|