Skip to content
Snippets Groups Projects
Commit 037086b9 authored by Nico Vermaas's avatar Nico Vermaas
Browse files

Merge branch 'master' into 'dev-nico'

Don't provide default URLs for IDA services

See merge request astron-sdc/esap-gui!42
parents 593d056e eccb6f8e
No related branches found
No related tags found
2 merge requests!43Dev nico,!42Don't provide default URLs for IDA services
Pipeline #15741 passed
......@@ -3,27 +3,26 @@ import { Pagination } from "react-bootstrap";
export default function Paginate(props) {
const { currentPage, getNewPage, numAdjacent, numPages } = props;
console.log(props);
const numBelow = Math.min(numAdjacent, currentPage-1);
const belowAdjacent = [...Array(numBelow).keys()].map((key) => {
const itemKey = `page_below_${key}`;
return (<Pagination.Item key={itemKey}>{currentPage - numBelow + key}</Pagination.Item>)
});
const prefix = belowAdjacent.length >= numAdjacent ? (<><Pagination.Item>{1}</Pagination.Item><Pagination.Ellipsis disabled/>{belowAdjacent}</>) : (<>{belowAdjacent}</>);
const prefix = currentPage-1 > numAdjacent ? (<><Pagination.Item>{1}</Pagination.Item><Pagination.Ellipsis disabled/>{belowAdjacent}</>) : (<>{belowAdjacent}</>);
const numAbove = Math.min(numAdjacent, numPages-currentPage);
const aboveAdjacent = [...Array(numAbove).keys()].map((key) => {
const itemKey = `page_above_${key}`;
return (<Pagination.Item key={itemKey}>{currentPage + key + 1}</Pagination.Item>)
});
const suffix = aboveAdjacent.length >= numAdjacent ? (<>{aboveAdjacent}<Pagination.Ellipsis disabled/><Pagination.Item>{numPages}</Pagination.Item></>) : (<>{aboveAdjacent}</>);
const suffix = numPages-currentPage > numAdjacent ? (<>{aboveAdjacent}<Pagination.Ellipsis disabled/><Pagination.Item>{numPages}</Pagination.Item></>) : (<>{aboveAdjacent}</>);
return (
<Pagination onClick={getNewPage} size="lg">
{prefix}
<Pagination.Item active >{currentPage}</Pagination.Item>
<Pagination.Item active disabled style={{fontWeight:"bold"}}>{currentPage}</Pagination.Item>
{suffix}
</Pagination>
);
......
......@@ -5,7 +5,7 @@ import { GlobalContext } from "../../contexts/GlobalContext";
export default function Interactive() {
const { jhubURL, setJhubURL, jnotebookURL, setJnotebookURL, batchsystemsURL, setBatchsystemsURL, list_of_jnotebooks, setList_of_jnotebooks, list_of_jhubs, setList_of_jhubs} = useContext(IDAContext);
const { idaSystemURL, setIdaSystemURL, jnotebookURL, setJnotebookURL, batchsystemsURL, setBatchsystemsURL, list_of_jnotebooks, setList_of_jnotebooks, list_of_idaSystems, setList_of_idaSystems} = useContext(IDAContext);
const { api_host } = useContext(GlobalContext);
let list_of_batchsystems = [
......@@ -13,7 +13,7 @@ export default function Interactive() {
{"name" : "CTA DIRAC", "url" : "https://ccdcta-web.in2p3.fr/DIRAC/"},
]
if ((!list_of_jnotebooks) || (!list_of_jhubs) || (!list_of_batchsystems)) {
if ((!list_of_jnotebooks) || (!list_of_idaSystems) || (!list_of_batchsystems)) {
return null
}
......@@ -24,7 +24,7 @@ export default function Interactive() {
(event) => setJnotebookURL(list_of_jnotebooks.find((item) => item.name === event.target.value).url)
}>
<Form.Label>
<h3>Select ESCAPE ESFRI Jupyter Workflows (Notebooks)</h3>
<h3>Select an analysis workflow (Jupyter Notebook)</h3>
</Form.Label>
<Form.Control className="mt-1" as="select">
{list_of_jnotebooks.map((option) => <option>{option.name}</option>)}
......@@ -33,18 +33,18 @@ export default function Interactive() {
</Form>
<Form className="mt-5">
<Form.Group controlId="jhub" onChange={
(event) => setJhubURL(list_of_jhubs.find((item) => item.name === event.target.value).url)
(event) => setIdaSystemURL(list_of_idaSystems.find((item) => item.name === event.target.value).url)
}>
<Form.Label>
<h3>Select ESCAPE JupyterHub Services</h3>
<h3>Select an analysis service</h3>
</Form.Label>
<Form.Control className="mt-1" as="select">
{list_of_jhubs.map((option) => <option>{option.name}</option>)}
{list_of_idaSystems.map((option) => <option>{option.name}</option>)}
</Form.Control>
</Form.Group>
</Form>
<Button href={api_host + "ida/deploy?facility=" + jhubURL + "&workflow=" + jnotebookURL} target="_blank">Deploy</Button>
<Button href={api_host + "ida/deploy?facility=" + idaSystemURL + "&workflow=" + jnotebookURL} target="_blank">Deploy</Button>
</Container>
);
......
......@@ -340,10 +340,12 @@ export default function ZooniverseResults({ catalog }) {
const { queryMap, page } = useContext(QueryContext);
const { api_host } = useContext(GlobalContext);
useEffect(() => {
const usp = new URLSearchParams(queryMap.get(catalog).esapquery);
usp.set("page", page);
queryMap.set(catalog, {
catalog: catalog,
page: page,
esapquery: queryMap.get(catalog).esapquery + `&page=${page}`,
esapquery: usp.toString(),
});
const url = api_host + "query/query/?" + queryMap.get(catalog).esapquery;
axios
......
import React, { createContext, useState, useEffect, useContext } from "react";
import { Alert } from "react-bootstrap";
import axios from "axios";
import getCookie from "../utils/getCookie";
import { GlobalContext } from "./GlobalContext";
......@@ -9,11 +7,11 @@ export const IDAContext = createContext();
export function IDAContextProvider({ children }) {
const { api_host } = useContext(GlobalContext);
const [jhubURL, setJhubURL] = useState("https://srcdev.skatelescope.org/escape");
const [jnotebookURL, setJnotebookURL] = useState("https://github.com/AMIGA-IAA/hcg-16/master");
const [batchsystemsURL, setBatchsystemsURL] = useState("https://dirac.egi.eu");
const [idaSystemURL, setIdaSystemURL] = useState();
const [jnotebookURL, setJnotebookURL] = useState();
const [batchsystemsURL, setBatchsystemsURL] = useState();
const [list_of_jnotebooks, setList_of_jnotebooks] = useState();
const [list_of_jhubs, setList_of_jhubs] = useState();
const [list_of_idaSystems, setList_of_idaSystems] = useState();
// Fetch Notebooks
useEffect(() => {
......@@ -21,6 +19,7 @@ export function IDAContextProvider({ children }) {
.get(api_host + "ida/workflows/search")
.then((response) => {
setList_of_jnotebooks(response.data.results);
setJnotebookURL(response.data.results[0].url);
});
}, [api_host]);
......@@ -30,7 +29,8 @@ export function IDAContextProvider({ children }) {
axios
.get(api_host + "ida/facilities/search")
.then((response) => {
setList_of_jhubs(response.data.results);
setList_of_idaSystems(response.data.results);
setIdaSystemURL(response.data.results[0].url);
});
}, [api_host]);
......@@ -38,16 +38,16 @@ export function IDAContextProvider({ children }) {
return (
<IDAContext.Provider
value={{
jhubURL,
setJhubURL,
idaSystemURL,
setIdaSystemURL,
jnotebookURL,
setJnotebookURL,
batchsystemsURL,
setBatchsystemsURL,
list_of_jnotebooks,
setList_of_jnotebooks,
list_of_jhubs,
setList_of_jhubs
list_of_idaSystems,
setList_of_idaSystems
}}
>
{children}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment