From bd352d6b55f420bc3246781843ab8f84b83e97ca Mon Sep 17 00:00:00 2001 From: Serge Date: Tue, 9 Jul 2024 11:57:04 +0300 Subject: [PATCH] Added &ann param to the query once a file is been uploaded --- components/Chart/Chart.jsx | 13 +++++-------- components/ImageSelect/ImageSelect.jsx | 10 +++++++++- src/App.jsx | 10 +++++++--- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/components/Chart/Chart.jsx b/components/Chart/Chart.jsx index c0108da..acf6a08 100644 --- a/components/Chart/Chart.jsx +++ b/components/Chart/Chart.jsx @@ -14,7 +14,7 @@ export default function Chart({ imageSelected }) { import.meta.env.VITE_BaseURL }dataset?domain=${imageSelected}&values=True`; - const { data } = useSWR(imageSelected && datasetQuery, fetcher, { + const { data, error } = useSWR(imageSelected && datasetQuery, fetcher, { revalidateIfStale: false, revalidateOnFocus: false, revalidateOnReconnect: false, @@ -24,9 +24,6 @@ export default function Chart({ imageSelected }) { const [valuesX, setValuesX] = useState([]); const [valuesY, setValuesY] = useState([]); - console.log(data); - console.log(dataset, data && data.datasets[0].key); - useEffect(() => { data && imageSelected && setDataset(data.datasets[0].key); }, [data, imageSelected]); @@ -78,8 +75,8 @@ export default function Chart({ imageSelected }) { }), ], }); - data && dataset & containerRefOne.current.append(plot); - data && dataset & containerRefTwo.current.append(plot2); + !error && data && dataset & containerRefOne.current.append(plot); + !error && data && dataset & containerRefTwo.current.append(plot2); return () => { plot.remove(); plot2.remove(); @@ -87,7 +84,7 @@ export default function Chart({ imageSelected }) { }, [data, valuesX, valuesY, imageSelected, dataset]); return ( - <> +
{imageSelected && Datasets} {data && @@ -105,6 +102,6 @@ export default function Chart({ imageSelected }) {
- +
); } diff --git a/components/ImageSelect/ImageSelect.jsx b/components/ImageSelect/ImageSelect.jsx index 8c554c1..a6b018a 100644 --- a/components/ImageSelect/ImageSelect.jsx +++ b/components/ImageSelect/ImageSelect.jsx @@ -17,5 +17,13 @@ export default function ImageSelect({ data, imageSelected, setImageSelected }) { />
)); - return
{renderImageSelect}
; + return ( +
+ {data && data.length > 0 ? ( + renderImageSelect + ) : ( +

Sorry, no data avaible

+ )} +
+ ); } diff --git a/src/App.jsx b/src/App.jsx index c42a9af..289ef0f 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -26,17 +26,21 @@ function App() { const metadataQuery = `${ import.meta.env.VITE_BaseURL - }query?q=${qQuery}&img=thumbnail&query_type=text&q_reference=${reference}&q_provider=${provider}&q_instrument=${instrument}&q_wavelength=${wavelengths}&page=${pages}&pagesize=${pagesize}`; + }query?q=${qQuery}&img=thumbnail&query_type=text&q_reference=${reference}&q_provider=${provider}&q_instrument=${instrument}&q_wavelength=${wavelengths}&page=${pages}&pagesize=${pagesize}&ann=${ + imageData?.cdf + }&query_type=knnquery`; const picturesQuery = "https://api.charisma.ideaconsult.net/download?what=thumbnail&domain=/SANDBOX/CSIC-ICV/BWTEK_iRaman/785/PST02_iRPlus785_Z020_020_1300ms.cha&extra="; - const { data } = useSWR(metadataQuery, fetcher, { + const { data, error } = useSWR(metadataQuery, fetcher, { revalidateIfStale: false, revalidateOnFocus: false, revalidateOnReconnect: false, }); + console.log(error); + return (
setOpen(!open)}> @@ -86,7 +90,7 @@ function App() { setImageSelected={setImageSelected} /> - + {!error ? :

Sorry

}
);