web/admin: show GeoIP information inline in events

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens Langhammer 2023-01-09 16:01:00 +01:00
parent a1be924fa4
commit d1aa1f46da
No known key found for this signature in database
2 changed files with 8 additions and 5 deletions

View File

@ -3,6 +3,7 @@ import { ActionToLabel } from "@goauthentik/admin/events/utils";
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
import { EventWithContext } from "@goauthentik/common/events";
import { uiConfig } from "@goauthentik/common/ui/config";
import { KeyUnknown } from "@goauthentik/elements/forms/Form";
import { PaginatedResponse } from "@goauthentik/elements/table/Table";
import { TableColumn } from "@goauthentik/elements/table/Table";
import { TablePage } from "@goauthentik/elements/table/TablePage";
@ -55,6 +56,10 @@ export class EventListPage extends TablePage<Event> {
}
row(item: EventWithContext): TemplateResult[] {
let geo: KeyUnknown | undefined = undefined;
if (Object.hasOwn(item.context, "geo")) {
geo = item.context.geo as KeyUnknown;
}
return [
html`<div>${ActionToLabel(item.action)}</div>
<small>${item.app}</small>`,
@ -67,7 +72,8 @@ export class EventListPage extends TablePage<Event> {
: html``}`
: html`-`,
html`<span>${item.created?.toLocaleString()}</span>`,
html`<span>${item.clientIp || t`-`}</span>`,
html` <div>${item.clientIp || t`-`}</div>
${geo ? html`<small>${geo.city}, ${geo.country}</small> ` : html``}`,
html`<span>${item.tenant?.name || t`-`}</span>`,
html`<a href="#/events/log/${item.pk}">
<i class="fas fa-share-square"></i>

View File

@ -1,4 +1,5 @@
import { AKElement } from "@goauthentik/elements/Base";
import { KeyUnknown } from "@goauthentik/elements/forms/Form";
import { TemplateResult, html } from "lit";
import { property } from "lit/decorators.js";
@ -25,10 +26,6 @@ export function readFileAsync(file: Blob) {
});
}
export type KeyUnknown = {
[key: string]: unknown;
};
export class BaseStage<Tin, Tout> extends AKElement {
host!: StageHost;