web/admin: refactor event geo display
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user