From 098d0ac99b20a6066eff5bc4acc15ad03cf8209d Mon Sep 17 00:00:00 2001 From: stvoutsin <steliosvoutsinas@yahoo.com> Date: Mon, 19 Jul 2021 13:36:08 +0100 Subject: [PATCH] Fixes to the IVOA TAP Query --- src/App.js | 5 ++++- src/components/query/QueryCatalogs.js | 16 +++++++++++++++- .../services/query_results/VORegListResults.js | 8 ++++---- src/contexts/IVOAContext.js | 11 +++-------- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/App.js b/src/App.js index e18a247..2d8335e 100644 --- a/src/App.js +++ b/src/App.js @@ -4,6 +4,7 @@ import Routes from "./routes/Routes"; import { GlobalContextProvider } from "./contexts/GlobalContext"; import { BasketContextProvider } from "./contexts/BasketContext"; import { QueryContextProvider } from "./contexts/QueryContext"; +import { IVOAContextProvider } from "./contexts/IVOAContext"; import { IDAContextProvider } from "./contexts/IDAContext"; // This is the App, only application global stuff goes here, like the global state provider. @@ -15,7 +16,9 @@ export default function App() { <BasketContextProvider> <QueryContextProvider> <IDAContextProvider> - <Routes /> + <IVOAContextProvider> + <Routes /> + </IVOAContextProvider> </IDAContextProvider> </QueryContextProvider> </BasketContextProvider> diff --git a/src/components/query/QueryCatalogs.js b/src/components/query/QueryCatalogs.js index 6aad437..6311d7b 100644 --- a/src/components/query/QueryCatalogs.js +++ b/src/components/query/QueryCatalogs.js @@ -84,7 +84,11 @@ export default function QueryCatalogs() { status: "fetching", results: null, }); - const url = api_host + "query/query/?" + query.esapquery; + + + const url = renderQueryURL(uri, query) + + axios .get(url) .then((queryResponse) => { @@ -139,6 +143,16 @@ export default function QueryCatalogs() { return config.ui_schema ? { uiSchema: config.ui_schema } : {} } } + + function renderQueryURL(uri, query) { + switch(uri) { + case 'ivoa': + return api_host + "query/" + query.esapquery + default: + return api_host + "query/query/?" + query.esapquery + } + } + const uiSchemaProp = renderUIschema(config); return ( <Container fluid> diff --git a/src/components/services/query_results/VORegListResults.js b/src/components/services/query_results/VORegListResults.js index 77e439f..9f9c31e 100644 --- a/src/components/services/query_results/VORegListResults.js +++ b/src/components/services/query_results/VORegListResults.js @@ -6,7 +6,7 @@ import Paginate from "../../Paginate"; import { IVOAContext } from "../../../contexts/IVOAContext"; export default function VORegListResults({ catalog }) { - const { queryMap } = useContext(QueryContext); + const { queryMap, url } = useContext(QueryContext); const { selectedRegistry, addRegistry, @@ -18,9 +18,9 @@ export default function VORegListResults({ catalog }) { } = useContext(IVOAContext); // const [checkAll, setCheckAll] = useState(""); - useEffect(() => { - console.log("Selected Registry:", selectedRegistry); - }, [selectedRegistry]); +// useEffect(() => { +// console.log("Selected Registry:", selectedRegistry); +// }, [selectedRegistry]); // useEffect(() => { // console.log("checkAll:", checkAll); diff --git a/src/contexts/IVOAContext.js b/src/contexts/IVOAContext.js index 0e3bdb7..370cc77 100644 --- a/src/contexts/IVOAContext.js +++ b/src/contexts/IVOAContext.js @@ -1,10 +1,10 @@ -import React, { createContext, useState } from "react"; +import React, { createContext, useState, useEffect, useContext } from "react"; export const IVOAContext = createContext(); export function IVOAContextProvider({ children }) { const [registryList, setRegistryList] = useState([]); - const [selectedRegistry, setSelectedRegistry] = useState([]); + // const [selectedRegistry, setSelectedRegistry] = useState([]); const [queryStep, setQueryStep] = useState("get-services"); const [regPage, setRegPage] = useState(1); @@ -17,12 +17,7 @@ export function IVOAContextProvider({ children }) { // For testing purpose // start manual setup block //const [queryStep, setQueryStep] = useState("run-query"); - // const [selectedRegistry, setSelectedRegistry] = useState([ - // // "http://astron.nl/tap", - // // "http://aip.gavo.org/tap", - // // "http://archive.stsci.edu/caomtap", - // "http://vao.stsci.edu/CAOMTAP/TapService.aspx", - // ]); + const [selectedRegistry, setSelectedRegistry] = useState("http://astron.nl/tap"); // end block function handleAddRegistry(access_url) { -- GitLab