From 87f26607a1e88b4e263e52d2aefee58fca1c6597 Mon Sep 17 00:00:00 2001 From: Nico Vermaas <vermaas@astron.nl> Date: Tue, 13 Jul 2021 08:52:36 +0200 Subject: [PATCH] give an alert when ESAP-API could not be reached --- src/contexts/GlobalContext.js | 2 +- src/contexts/QueryContext.js | 9 +++++++-- src/routes/Routes.js | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/contexts/GlobalContext.js b/src/contexts/GlobalContext.js index 719f703..3be75b9 100644 --- a/src/contexts/GlobalContext.js +++ b/src/contexts/GlobalContext.js @@ -23,7 +23,7 @@ function setProfileState(api_host, }) .catch((error) => { - + alert(error) // when the token is no longer valid, getting with credentials will fail // mark the user as being logged out localStorage.removeItem('esap_logged_in') diff --git a/src/contexts/QueryContext.js b/src/contexts/QueryContext.js index 9aa243a..911546d 100644 --- a/src/contexts/QueryContext.js +++ b/src/contexts/QueryContext.js @@ -1,4 +1,5 @@ import React, { createContext, useState, useEffect, useContext } from "react"; +import { Alert } from "react-bootstrap"; import axios from "axios"; import useMap from "../hooks/useMap"; import { GlobalContext } from "./GlobalContext"; @@ -10,7 +11,7 @@ export function QueryContextProvider({ children }) { const queryMap = useMap(); const [formData, setFormData] = useState(); const [page, setPage] = useState(1); - const [url, setURL] = useState("https://uilennest.net/astrobase/data/191231001/3836665.fits"); + const [url, setURL] = useState(""); const [dplevel, setDPLevel] = useState(); const [collection, setCollection] = useState(); const [config, setConfig] = useState(); @@ -45,7 +46,11 @@ export function QueryContextProvider({ children }) { return null; }); setConfig(config); - }); + }) + .catch((error) => { + let description = ". Configuration not loaded. Is ESAP-API online? " + api_host + alert(error.toString() + description) + }); }, [api_host, configName]); //}, [api_host, configName, dplevel, collection]); diff --git a/src/routes/Routes.js b/src/routes/Routes.js index 0ca92ea..d8e28aa 100644 --- a/src/routes/Routes.js +++ b/src/routes/Routes.js @@ -72,7 +72,7 @@ export default function Routes() { </Switch> - <footer><small>esap-gui version 12 jul 2021 - 11:00</small></footer> + <footer><small>esap-gui version 13 jul 2021 - 8:00</small></footer> </Router> ); } -- GitLab