2024-06-05 21:13:58 +02:00
|
|
|
import type { Key } from "react";
|
|
|
|
import { useGetClassName } from "keycloakify/account/lib/useGetClassName";
|
2024-02-21 13:44:33 +02:00
|
|
|
import type { PageProps } from "keycloakify/account/pages/PageProps";
|
2024-06-05 21:13:58 +02:00
|
|
|
import type { KcContext } from "../KcContext";
|
2024-06-09 04:43:18 +02:00
|
|
|
import { useI18n } from "../i18n";
|
2024-02-21 13:44:33 +02:00
|
|
|
|
2024-06-09 04:43:18 +02:00
|
|
|
export default function Log(props: PageProps<Extract<KcContext, { pageId: "log.ftl" }>>) {
|
|
|
|
const { kcContext, doUseDefaultCss, classes, Template } = props;
|
2024-02-21 13:44:33 +02:00
|
|
|
|
|
|
|
const { getClassName } = useGetClassName({
|
|
|
|
doUseDefaultCss,
|
|
|
|
classes
|
|
|
|
});
|
|
|
|
|
|
|
|
const { log } = kcContext;
|
|
|
|
|
2024-06-09 04:43:18 +02:00
|
|
|
const { msg } = useI18n({ kcContext });
|
2024-02-21 13:44:33 +02:00
|
|
|
|
|
|
|
return (
|
2024-06-09 04:43:18 +02:00
|
|
|
<Template {...{ kcContext, doUseDefaultCss, classes }} active="log">
|
2024-02-21 13:44:33 +02:00
|
|
|
<div className={getClassName("kcContentWrapperClass")}>
|
|
|
|
<div className="col-md-10">
|
|
|
|
<h2>{msg("accountLogHtmlTitle")}</h2>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<table className="table table-striped table-bordered">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<td>{msg("date")}</td>
|
|
|
|
<td>{msg("event")}</td>
|
|
|
|
<td>{msg("ip")}</td>
|
|
|
|
<td>{msg("client")}</td>
|
|
|
|
<td>{msg("details")}</td>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
|
|
|
|
<tbody>
|
|
|
|
{log.events.map(
|
|
|
|
(
|
|
|
|
event: {
|
|
|
|
date: string | number | Date;
|
|
|
|
event: string;
|
|
|
|
ipAddress: string;
|
|
|
|
client: any;
|
|
|
|
details: any[];
|
|
|
|
},
|
|
|
|
index: Key | null | undefined
|
|
|
|
) => (
|
|
|
|
<tr key={index}>
|
|
|
|
<td>{event.date ? new Date(event.date).toLocaleString() : ""}</td>
|
|
|
|
<td>{event.event}</td>
|
|
|
|
<td>{event.ipAddress}</td>
|
|
|
|
<td>{event.client || ""}</td>
|
|
|
|
<td>
|
|
|
|
{event.details.map((detail, detailIndex) => (
|
|
|
|
<span key={detailIndex}>
|
|
|
|
{`${detail.key} = ${detail.value}`}
|
|
|
|
{detailIndex < event.details.length - 1 && ", "}
|
|
|
|
</span>
|
|
|
|
))}
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
)
|
|
|
|
)}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</Template>
|
|
|
|
);
|
|
|
|
}
|