From 303e6579cb33d506a8b12bb564325bb0addf3191 Mon Sep 17 00:00:00 2001 From: GotthardG <51994228+GotthardG@users.noreply.github.com> Date: Wed, 26 Feb 2025 15:25:15 +0100 Subject: [PATCH] Add Image models and clean up test code structure Introduced `ImageCreate` and `Image` models to handle image-related data in the backend. Improved the organization and readability of the testing notebook by consolidating and formatting code into distinct sections with markdown cells. --- frontend/src/components/ResultGrid.tsx | 28 +++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/ResultGrid.tsx b/frontend/src/components/ResultGrid.tsx index 1f0bdd3..695e1e2 100644 --- a/frontend/src/components/ResultGrid.tsx +++ b/frontend/src/components/ResultGrid.tsx @@ -21,7 +21,32 @@ interface ResultGridProps { } const ResultGrid: React.FC = ({ activePgroup }) => { - const [rows, setRows] = useState([]); + const [rows, setRows] = useState([]); + const [basePath, setBasePath] = React.useState(""); + + useEffect(() => { + // Detect the current environment + const mode = import.meta.env.MODE; + + // Dynamic resolution for OpenAPI.BASE + OpenAPI.BASE = + mode === 'test' + ? import.meta.env.VITE_OPENAPI_BASE_TEST + : mode === 'prod' + ? import.meta.env.VITE_OPENAPI_BASE_PROD + : import.meta.env.VITE_OPENAPI_BASE_DEV; + + if (!OpenAPI.BASE) { + console.error('OpenAPI.BASE is not set. Falling back to a default value.'); + OpenAPI.BASE = 'https://default-url.com'; + } + + console.log('Environment Mode:', mode); + console.log('Resolved OpenAPI.BASE:', OpenAPI.BASE); + + // Set the base path for images dynamically + setBasePath(`${OpenAPI.BASE}/images/`); + }, []); useEffect(() => { console.log("Fetching sample results for active_pgroup:", activePgroup); @@ -49,6 +74,7 @@ const ResultGrid: React.FC = ({ activePgroup }) => { if (imageList && imageList.length) { const primaryImage = imageList[0]; // Define the base path to your backend images directory + const basePath = "https://localhost:8000/"; const imageUrl = basePath + primaryImage.filepath;