web/admin: refactor event geo display

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens Langhammer
2023-02-13 11:14:40 +01:00
parent eb8181daa0
commit 3740b45e1a
4 changed files with 26 additions and 22 deletions

View File

@ -1,7 +1,24 @@
import { EventWithContext } from "@goauthentik/common/events";
import { KeyUnknown } from "@goauthentik/elements/forms/Form";
import { t } from "@lingui/macro";
import { TemplateResult, html } from "lit";
import { EventActions } from "@goauthentik/api";
export function EventGeo(event: EventWithContext): TemplateResult {
let geo: KeyUnknown | undefined = undefined;
if (Object.hasOwn(event.context, "geo")) {
geo = event.context.geo as KeyUnknown;
const parts = [geo.city, geo.country, geo.continent].filter(
(v) => v !== "" && v !== undefined,
);
return html`${parts.join(", ")}`;
}
return html``;
}
export function ActionToLabel(action?: EventActions): string {
if (!action) return "";
switch (action) {