From 204fce78d205c833fa8951cc132eb1d740d7fa25 Mon Sep 17 00:00:00 2001 From: meyer <meyer@astron.nl> Date: Thu, 12 Nov 2020 20:36:49 +0100 Subject: [PATCH] add console logs and get rid of some warnings --- src/components/FitsViewer.js | 6 +++--- src/components/Rucio.js | 6 +++--- src/components/archives/ArchiveDetails.js | 5 ++++- src/components/archives/DataProductCategories.js | 13 +++++++++++-- src/components/query/VOServiceResults.js | 5 ++--- src/contexts/GlobalContext.js | 13 +++++++++++-- src/contexts/QueryContext.js | 6 ++++++ src/routes/Routes.js | 5 +---- 8 files changed, 41 insertions(+), 18 deletions(-) diff --git a/src/components/FitsViewer.js b/src/components/FitsViewer.js index 75a69d8..239b20b 100644 --- a/src/components/FitsViewer.js +++ b/src/components/FitsViewer.js @@ -9,11 +9,11 @@ export default function FitsViewer() { console.log("fits url: ", url); return ( - <div class="embed-responsive embed-responsive-16by9"> + <div className="embed-responsive embed-responsive-16by9"> <iframe - class="embed-responsive-item" + className="embed-responsive-item" src={url} - allowfullscreen + allowFullScreen ></iframe> </div> ); diff --git a/src/components/Rucio.js b/src/components/Rucio.js index 5c774b3..6dc43e7 100644 --- a/src/components/Rucio.js +++ b/src/components/Rucio.js @@ -2,11 +2,11 @@ import React from "react"; export default function Rucio() { return ( - <div class="embed-responsive embed-responsive-16by9"> + <div className="embed-responsive embed-responsive-16by9"> <iframe - class="embed-responsive-item" + className="embed-responsive-item" src="https://escape-rucio.cern.ch" - allowfullscreen + allowFullScreen ></iframe> </div> ); diff --git a/src/components/archives/ArchiveDetails.js b/src/components/archives/ArchiveDetails.js index 9ac3f57..51af3a9 100644 --- a/src/components/archives/ArchiveDetails.js +++ b/src/components/archives/ArchiveDetails.js @@ -1,6 +1,7 @@ import React, { useContext } from "react"; import { useParams } from "react-router-dom"; import { GlobalContext } from "../../contexts/GlobalContext"; +import { QueryContextProvider } from "../../contexts/QueryContext"; import { Container, Row, @@ -76,7 +77,9 @@ export default function ArchiveDetails(props) { </Row> <Row className="pt-3"> <Col> - <DataProductCategories archive={archive} /> + <QueryContextProvider> + <DataProductCategories archive={archive} /> + </QueryContextProvider> </Col> </Row> </Col> diff --git a/src/components/archives/DataProductCategories.js b/src/components/archives/DataProductCategories.js index 8775333..5d80d8d 100644 --- a/src/components/archives/DataProductCategories.js +++ b/src/components/archives/DataProductCategories.js @@ -1,12 +1,15 @@ import React, { useState, useContext, useEffect } from "react"; -import { NavLink } from "react-router-dom"; +import { useHistory } from "react-router-dom"; import { ListGroup, Card, Button, Row, Col } from "react-bootstrap"; import { GlobalContext } from "../../contexts/GlobalContext"; +import { QueryContext } from "../../contexts/QueryContext"; import axios from "axios"; export default function DataProductCategories({ archive }) { const { api_host } = useContext(GlobalContext); + const { setDPLevel, setCategory } = useContext(QueryContext); const [categories, setCategories] = useState([]); + const history = useHistory(); useEffect(() => { axios @@ -41,9 +44,15 @@ export default function DataProductCategories({ archive }) { button = ( // need to add level (e.g raw) and category (e.g imaging) infomation to send to the form // probably need to define onSubmit instead of point to query_url - <Button as={NavLink} variant="outline-info" to={query_url}> + <Button + onClick={() => { + setDPLevel(category.level); + setCategory(category.category); + history.push(query_url);}} + > Browse Catalog & Run Queries </Button> + ); } else if (category.catalog_user_url_derived) { button = ( diff --git a/src/components/query/VOServiceResults.js b/src/components/query/VOServiceResults.js index 2aa93cc..9563337 100644 --- a/src/components/query/VOServiceResults.js +++ b/src/components/query/VOServiceResults.js @@ -53,9 +53,8 @@ export default function VORegistryResults({ catalog }) { display it with js9 */} {(result.result.endsWith('.fits')) && <Button - value={result.result} - onClick={(event) => { - setFits(event.target.value); + onClick={() => { + setFits(result.result); history.push('/fitsviewer'); }} >View fits</Button>} diff --git a/src/contexts/GlobalContext.js b/src/contexts/GlobalContext.js index e472dea..4eecb1a 100644 --- a/src/contexts/GlobalContext.js +++ b/src/contexts/GlobalContext.js @@ -12,7 +12,6 @@ export function GlobalContextProvider({ children }) { process.env.NODE_ENV === "development" ? "http://localhost:5555/esap-api/" : "/esap-api/"; - // "http://localhost:15671/esap-api/" // "http://sdc.astron.nl:5557/esap-api/" const [config, setConfig] = useState(); const [configName, setConfigName] = useState(defaultConf); @@ -24,7 +23,16 @@ export function GlobalContextProvider({ children }) { } axios .get(api_host + "query/configuration" + configNameString) - .then((response) => setConfig(response.data["configuration"])); + .then((response) => { + let config = response.data["configuration"]; + let props = config.query_schema.properties; + console.log("config props: ", props); + Object.keys(props).map((key) => { + if (key == "collection") + console.log("has key collection, default value is: ", props[key]["default"]); + }); + setConfig(config); + }); }, [api_host, configName]); console.log("config: ", { config }); @@ -35,6 +43,7 @@ export function GlobalContextProvider({ children }) { .then((response) => setArchives(response.data.results)); }, [api_host]); + // !!!!! Still need to look at sessionid and stuff const [sessionid, setSessionid] = useState(getCookie("sessionid")); console.log("waah", sessionid, getCookie("sessionid"), document.cookie); const [isAuthenticated, setIsAuthenticated] = useState( diff --git a/src/contexts/QueryContext.js b/src/contexts/QueryContext.js index a2a38ee..160a2c3 100644 --- a/src/contexts/QueryContext.js +++ b/src/contexts/QueryContext.js @@ -8,6 +8,8 @@ export function QueryContextProvider({ children }) { const [formData, setFormData] = useState(); const [page, setPage] = useState(1); const [fits, setFits] = useState("https://uilennest.net/astrobase/data/191231001/3836665.fits"); + const [dplevel, setDPLevel] = useState(); + const [category, setCategory] = useState(); // const [category, setCategory] = useState(); // const [level, setLevel] = useState(); @@ -21,6 +23,10 @@ export function QueryContextProvider({ children }) { setFormData, fits, setFits, + dplevel, + setDPLevel, + category, + setCategory, }} > {children} diff --git a/src/routes/Routes.js b/src/routes/Routes.js index ab5c04b..50a8e8c 100644 --- a/src/routes/Routes.js +++ b/src/routes/Routes.js @@ -21,10 +21,7 @@ export default function Routes() { <Router basename={config.frontend_basename}> <NavBar /> <Switch> - <Route exact path="/"> - <Archives /> - </Route> - <Route exact path="/archives"> + <Route exact path={["/", "/archives"]}> <Archives /> </Route> <Route exact path="/rucio"> -- GitLab