From d1aa1f46dabba1a1cf20d4ab91778a7f5d8e3a3b Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 9 Jan 2023 16:01:00 +0100 Subject: [PATCH] web/admin: show GeoIP information inline in events Signed-off-by: Jens Langhammer --- web/src/admin/events/EventListPage.ts | 8 +++++++- web/src/flow/stages/base.ts | 5 +---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/web/src/admin/events/EventListPage.ts b/web/src/admin/events/EventListPage.ts index 14c4d3fd8..3e8eea4e6 100644 --- a/web/src/admin/events/EventListPage.ts +++ b/web/src/admin/events/EventListPage.ts @@ -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 { } row(item: EventWithContext): TemplateResult[] { + let geo: KeyUnknown | undefined = undefined; + if (Object.hasOwn(item.context, "geo")) { + geo = item.context.geo as KeyUnknown; + } return [ html`
${ActionToLabel(item.action)}
${item.app}`, @@ -67,7 +72,8 @@ export class EventListPage extends TablePage { : html``}` : html`-`, html`${item.created?.toLocaleString()}`, - html`${item.clientIp || t`-`}`, + html`
${item.clientIp || t`-`}
+ ${geo ? html`${geo.city}, ${geo.country} ` : html``}`, html`${item.tenant?.name || t`-`}`, html` diff --git a/web/src/flow/stages/base.ts b/web/src/flow/stages/base.ts index 07998299d..d9e3865ea 100644 --- a/web/src/flow/stages/base.ts +++ b/web/src/flow/stages/base.ts @@ -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 extends AKElement { host!: StageHost;