From 1184aa9ad5acf20c00c40f8879020bca4b3dacf8 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Wed, 3 Apr 2024 08:28:00 -0600 Subject: [PATCH] Render all items --- web/src/pages/Logs.tsx | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/web/src/pages/Logs.tsx b/web/src/pages/Logs.tsx index 7fab8bc46..9925c5f48 100644 --- a/web/src/pages/Logs.tsx +++ b/web/src/pages/Logs.tsx @@ -20,7 +20,7 @@ const frigateSection = /[\w.]*/; const goSeverity = /(DEB )|(INF )|(WARN )|(ERR )/; const goSection = /\[[\w]*]/; -const ngSeverity = /(GET)|(POST)|(PATCH)|(DELETE)/; +const ngSeverity = /(GET)|(POST)|(PUT)|(PATCH)|(DELETE)/; function Logs() { const [logService, setLogService] = useState("frigate"); @@ -246,6 +246,15 @@ function Logs() { return; } + if (logLines.length < 100) { + setAtBottom(true); + return; + } + + if (atBottom) { + return; + } + if (!contentRef.current) { return; } @@ -255,6 +264,8 @@ function Logs() { behavior: "instant", }); setTimeout(() => setAtBottom(true), 300); + // we need to listen on the current range of visible items + // eslint-disable-next-line react-hooks/exhaustive-deps }, [logLines, logService]); return ( @@ -328,15 +339,20 @@ function Logs() { Message - {logLines.length > 0 && logRange.start > 0 &&
} - {logLines.map((log, idx) => ( - - ))} + {logLines.length > 0 && + [...Array(logRange.end - 1).keys()].map((idx) => + idx >= logRange.start ? ( + + ) : ( +
+ ), + )} {logLines.length > 0 &&
}
@@ -344,11 +360,12 @@ function Logs() { } type LogLineDataProps = { + startRef?: (node: HTMLDivElement | null) => void; className: string; line: LogLine; offset: number; }; -function LogLineData({ className, line, offset }: LogLineDataProps) { +function LogLineData({ startRef, className, line, offset }: LogLineDataProps) { // long log message const contentRef = useRef(null); @@ -379,6 +396,7 @@ function LogLineData({ className, line, offset }: LogLineDataProps) { return (