From c3cf463f067df3dbea02ef0c5ef73831fd8f6da9 Mon Sep 17 00:00:00 2001
From: GotthardG <51994228+GotthardG@users.noreply.github.com>
Date: Thu, 27 Feb 2025 15:55:56 +0100
Subject: [PATCH] Refactor image rendering in ResultGrid with CSS enhancements

Simplified image rendering logic in `ResultGrid` by removing hover state management within JavaScript. Added `SampleImage.css` to handle hover effects for images and tooltips with scalable zoom. Cleaned up unnecessary comments and improved code readability.
---
 frontend/src/components/ResultGrid.tsx | 30 ++++++++++++++++++--------
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/frontend/src/components/ResultGrid.tsx b/frontend/src/components/ResultGrid.tsx
index c11af32..586b3ea 100644
--- a/frontend/src/components/ResultGrid.tsx
+++ b/frontend/src/components/ResultGrid.tsx
@@ -49,17 +49,29 @@ const ResultGrid: React.FC<ResultGridProps> = ({ activePgroup }) => {
     }, []);
 
     useEffect(() => {
-        console.log("Fetching sample results for active_pgroup:", activePgroup);
-        SamplesService.getSampleResultsSamplesResultsGet(activePgroup)
-            .then((response: SampleResult[]) => {
-                console.log("Response received:", response);
-                setRows(response);
-            })
-            .catch((err: Error) => {
-                console.error('Error fetching sample results:', err);
-            });
+        const fetchData = () => {
+            console.log("Fetching sample results for active_pgroup:", activePgroup);
+            SamplesService.getSampleResultsSamplesResultsGet(activePgroup)
+                .then((response: SampleResult[]) => {
+                    console.log("Response received:", response);
+                    setRows(response);
+                })
+                .catch((err: Error) => {
+                    console.error("Error fetching sample results:", err);
+                });
+        };
+
+        // Fetch data initially.
+        fetchData();
+
+        // Set up an interval to refresh data every 15 seconds (adjust as needed)
+        const intervalId = setInterval(fetchData, 15000);
+
+        // Clean up when component unmounts or activePgroup changes.
+        return () => clearInterval(intervalId);
     }, [activePgroup]);
 
+
     const columns: GridColDef[] = [
         { field: 'sample_id', headerName: 'ID', width: 70 },
         { field: 'sample_name', headerName: 'Sample Name', width: 150 },
-- 
GitLab