Skip to content

Commit

Permalink
Added &ann param to the query once a file is been uploaded
Browse files Browse the repository at this point in the history
  • Loading branch information
sergesoroka committed Jul 9, 2024
1 parent 4f74997 commit bd352d6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
13 changes: 5 additions & 8 deletions components/Chart/Chart.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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]);
Expand Down Expand Up @@ -78,16 +75,16 @@ 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();
};
}, [data, valuesX, valuesY, imageSelected, dataset]);

return (
<>
<div>
<div className="datasetsTabs">
{imageSelected && <span className="fileName">Datasets</span>}
{data &&
Expand All @@ -105,6 +102,6 @@ export default function Chart({ imageSelected }) {
</div>
<div ref={containerRefOne} />
<div ref={containerRefTwo} />
</>
</div>
);
}
10 changes: 9 additions & 1 deletion components/ImageSelect/ImageSelect.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,13 @@ export default function ImageSelect({ data, imageSelected, setImageSelected }) {
/>
</div>
));
return <div className="imageSelectWrap">{renderImageSelect}</div>;
return (
<div className="imageSelectWrap">
{data && data.length > 0 ? (
renderImageSelect
) : (
<p style={{ color: "darkred" }}>Sorry, no data avaible</p>
)}
</div>
);
}
10 changes: 7 additions & 3 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div className="main">
<div className="toggleSidebar" onClick={() => setOpen(!open)}>
Expand Down Expand Up @@ -86,7 +90,7 @@ function App() {
setImageSelected={setImageSelected}
/>
</Expander>
<Chart imageSelected={imageSelected} />
{!error ? <Chart imageSelected={imageSelected} /> : <p>Sorry</p>}
</div>
</div>
);
Expand Down

0 comments on commit bd352d6

Please sign in to comment.