Add experiment logs to the monitoring page

This commit is contained in:
Twirre
2026-01-28 10:15:58 +00:00
committed by Björn Otgaar
parent 78901ee25b
commit 835de03a29
25 changed files with 619 additions and 124 deletions

48
src/components/Dialog.tsx Normal file
View File

@@ -0,0 +1,48 @@
import {type ReactNode, type RefObject, useEffect, useRef} from "react";
export default function Dialog({
open,
close,
classname,
children,
}: {
open: boolean;
close: () => void;
classname?: string;
children: ReactNode;
}) {
const ref: RefObject<HTMLDialogElement | null> = useRef(null);
useEffect(() => {
if (open) {
ref.current?.showModal();
} else {
ref.current?.close();
}
}, [open]);
function handleClickOutside(event: React.MouseEvent) {
if (!ref.current) return;
const dialogDimensions = ref.current.getBoundingClientRect()
if (
event.clientX < dialogDimensions.left ||
event.clientX > dialogDimensions.right ||
event.clientY < dialogDimensions.top ||
event.clientY > dialogDimensions.bottom
) {
close();
}
}
return (
<dialog
ref={ref}
onCancel={close}
onPointerDown={handleClickOutside}
className={classname}
>
{children}
</dialog>
);
}