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 { AKElement } from "@goauthentik/elements/Base"; import "@goauthentik/elements/PageHeader"; import { KeyUnknown } from "@goauthentik/elements/forms/Form"; import { t } from "@lingui/macro"; import { CSSResult, TemplateResult, html } from "lit"; import { customElement, property } from "lit/decorators.js"; import AKGlobal from "@goauthentik/common/styles/authentik.css"; import PFCard from "@patternfly/patternfly/components/Card/card.css"; import PFContent from "@patternfly/patternfly/components/Content/content.css"; import PFDescriptionList from "@patternfly/patternfly/components/DescriptionList/description-list.css"; import PFPage from "@patternfly/patternfly/components/Page/page.css"; import PFGrid from "@patternfly/patternfly/layouts/Grid/grid.css"; import PFBase from "@patternfly/patternfly/patternfly-base.css"; import { EventsApi } from "@goauthentik/api"; @customElement("ak-event-info-page") export class EventInfoPage extends AKElement { @property() set eventID(value: string) { new EventsApi(DEFAULT_CONFIG) .eventsEventsRetrieve({ eventUuid: value, }) .then((ev) => { this.event = ev as EventWithContext; }); } @property({ attribute: false }) event!: EventWithContext; static get styles(): CSSResult[] { return [PFBase, PFGrid, PFDescriptionList, PFPage, PFContent, PFCard, AKGlobal]; } render(): TemplateResult { if (!this.event) { return html` `; } let geo: KeyUnknown | undefined = undefined; if (Object.hasOwn(this.event.context, "geo")) { geo = this.event.context.geo as KeyUnknown; } return html`
${t`Event info`}
${t`Action`}
${ActionToLabel(this.event.action)}
${t`App`}
${this.event.app}
${t`User`}
${this.event.user?.username ? html` ${this.event.user.on_behalf_of ? html` ${t`On behalf of ${this.event.user.on_behalf_of.username}`} ` : html``}` : html`-`}
${t`Created`}
${this.event.created?.toLocaleString()}
${t`Client IP`}
${this.event.clientIp || t`-`}
${geo ? html`${[geo.city, geo.country].join(", ")}` : html``}
${t`Tenant`}
${this.event.tenant?.name || t`-`}
`; } }