From ccf9267440444aec1023678d4f50f344a680df2c Mon Sep 17 00:00:00 2001 From: ds Date: Sun, 28 Jun 2026 18:40:43 +0000 Subject: [PATCH] =?UTF-8?q?src/components/LogViewer.tsx=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/LogViewer.tsx | 60 ++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/components/LogViewer.tsx diff --git a/src/components/LogViewer.tsx b/src/components/LogViewer.tsx new file mode 100644 index 0000000..be4b53d --- /dev/null +++ b/src/components/LogViewer.tsx @@ -0,0 +1,60 @@ +import React, { useEffect, useState } from "react"; +import { fetchLogs } from "../api"; +import { matchesRegex, highlight } from "../utils"; + +export default function LogViewer({ + namespace, + selection, + regex, + live +}) { + const [logs, setLogs] = useState(""); + + useEffect(() => { + if (!selection) return; + + let interval; + + async function load() { + const text = await fetchLogs({ + namespace, + pod: selection.pod, + container: selection.container + }); + + const filtered = text + .split("\n") + .filter((l) => matchesRegex(l, regex)) + .map(highlight) + .join("\n"); + + setLogs(filtered); + } + + load(); + + if (live) { + interval = setInterval(load, 3000); + } + + return () => clearInterval(interval); + }, [selection, regex, live]); + + if (!selection) { + return
Select container
; + } + + return ( +
+      {logs}
+    
+ ); +} \ No newline at end of file