From dc1fcc73054a0f73e94eac35f45a783050695974 Mon Sep 17 00:00:00 2001 From: John Rogers Date: Mon, 9 Dec 2024 09:52:28 +0000 Subject: [PATCH 1/6] staging API is off for now - Provide more grace to API to start up before showing API offline error --- .env.development | 2 +- src/components/AppBar.js | 12 ++++++++---- src/contexts/DataContext.js | 25 ++++++++++++++++++++----- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/.env.development b/.env.development index c017fb8..82490c4 100644 --- a/.env.development +++ b/.env.development @@ -1,4 +1,4 @@ -REACT_APP_API_URL=https://harmonystagingtmp.azurewebsites.net/ +REACT_APP_API_URL=https://api.harmonydata.ac.uk REACT_APP_API_EXAMPLES=$REACT_APP_API_URL/text/examples REACT_APP_API_PARSE=$REACT_APP_API_URL/text/parse REACT_APP_API_MATCH=$REACT_APP_API_URL/text/match diff --git a/src/components/AppBar.js b/src/components/AppBar.js index 2387de5..8f86ed6 100644 --- a/src/components/AppBar.js +++ b/src/components/AppBar.js @@ -127,8 +127,9 @@ function HarmonyAppBar() { - + ))} {!currentUser && [ - , -

+ , +

Signing in with one of the OAuth providers below allows you access to My Harmony where you can save and share your harmonisations. @@ -259,7 +263,7 @@ function HarmonyAppBar() { )} - + {apiVersion && ( Harmony API version: {apiVersion} diff --git a/src/contexts/DataContext.js b/src/contexts/DataContext.js index 01c3326..dd1714a 100644 --- a/src/contexts/DataContext.js +++ b/src/contexts/DataContext.js @@ -78,15 +78,30 @@ export function DataProvider({ children }) { signal: controller.signal, }); clearTimeout(id); + // If successful, resolve immediately + if (response.ok) { + resolve(response.json()); + return; // Exit the loop and promise + } } catch (e) { - console.log(e); - reject(e); + console.log("Get rejection", e); + // Only reject if there are no more retries + if (retries === 0) { + reject(e); + } } retries--; + if (retries > 0) { + await new Promise((resolve) => setTimeout(resolve, 1000)); // Wait 1 second + } + } + // If the loop completes without a successful response, reject + if (!(response && response.ok)) { + reject(new Error("Failed to fetch data after multiple retries")); } - resolve(response.json()); }); }; + const parse = (allFiles) => { return retryablePostData({ url: process.env.REACT_APP_API_PARSE, @@ -120,14 +135,14 @@ export function DataProvider({ children }) { const getVersion = useCallback(() => { return retryableGetData({ url: process.env.REACT_APP_API_VERSION, - timeout: 1500, + timeout: 2500, }).then((data) => data.harmony_version || "unknown"); }, []); const getModels = useCallback(() => { return retryableGetData({ url: process.env.REACT_APP_API_MODELS, - timeout: 1500, + timeout: 2500, }); }, []); From e033838d00c4a5c0a96737da63b6ef6142c0a59e Mon Sep 17 00:00:00 2001 From: Thomas Wood Date: Tue, 10 Dec 2024 18:21:31 +0000 Subject: [PATCH 2/6] Temporary hotfix as Prod server is down and we have a demo today --- .env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env b/.env index 82490c4..c017fb8 100644 --- a/.env +++ b/.env @@ -1,4 +1,4 @@ -REACT_APP_API_URL=https://api.harmonydata.ac.uk +REACT_APP_API_URL=https://harmonystagingtmp.azurewebsites.net/ REACT_APP_API_EXAMPLES=$REACT_APP_API_URL/text/examples REACT_APP_API_PARSE=$REACT_APP_API_URL/text/parse REACT_APP_API_MATCH=$REACT_APP_API_URL/text/match From 06ff7e091f4bcc01329f09cbbf4d9f564f0485cf Mon Sep 17 00:00:00 2001 From: Thomas Wood Date: Tue, 10 Dec 2024 18:34:13 +0000 Subject: [PATCH 3/6] Update .env - second hotfix for demo --- .env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env b/.env index c017fb8..01b69ad 100644 --- a/.env +++ b/.env @@ -1,4 +1,4 @@ -REACT_APP_API_URL=https://harmonystagingtmp.azurewebsites.net/ +REACT_APP_API_URL=http://localhost:8000/ REACT_APP_API_EXAMPLES=$REACT_APP_API_URL/text/examples REACT_APP_API_PARSE=$REACT_APP_API_URL/text/parse REACT_APP_API_MATCH=$REACT_APP_API_URL/text/match From 9cd96b6cca01101d64d01787c263a9cc1b87860f Mon Sep 17 00:00:00 2001 From: Thomas Wood Date: Tue, 10 Dec 2024 18:36:03 +0000 Subject: [PATCH 4/6] Update .env.development - hotfix --- .env.development | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.development b/.env.development index 82490c4..3a5b998 100644 --- a/.env.development +++ b/.env.development @@ -1,4 +1,4 @@ -REACT_APP_API_URL=https://api.harmonydata.ac.uk +REACT_APP_API_URL=http://localhost:8000 REACT_APP_API_EXAMPLES=$REACT_APP_API_URL/text/examples REACT_APP_API_PARSE=$REACT_APP_API_URL/text/parse REACT_APP_API_MATCH=$REACT_APP_API_URL/text/match From b3e156ed5db245869a06a4bbaa25e5be0d1b2f96 Mon Sep 17 00:00:00 2001 From: John Rogers Date: Tue, 10 Dec 2024 18:38:18 +0000 Subject: [PATCH 5/6] fix ts linting for Thomas --- src/conf/theme.ts | 50 +++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/conf/theme.ts b/src/conf/theme.ts index a61868d..c8a0f08 100644 --- a/src/conf/theme.ts +++ b/src/conf/theme.ts @@ -1,18 +1,18 @@ import "../css/Pragmatica.css"; -export const getDesignTokens = (mode) => ({ +export const getDesignTokens = (mode: string | undefined) => ({ typography: { body1: { fontFamily: "Pragmatica, sans-serif", fontWeight: 300, lineHeight: "150%", fontSize: "0.9rem", - "@media (min-width:600px)":{ + "@media (min-width:600px)": { fontSize: "1rem", }, - "@media (min-width:900px)":{ + "@media (min-width:900px)": { fontSize: "1.1rem", - } + }, }, caption: { fontFamily: "Pragmatica, sans-serif", @@ -26,8 +26,8 @@ export const getDesignTokens = (mode) => ({ }, palette: { mode, - ...(mode === 'light' - ?{ + ...(mode === "light" + ? { primary: { main: "#2b45ed", }, @@ -39,10 +39,10 @@ export const getDesignTokens = (mode) => ({ paper: "#FEFCFB", }, text: { - primary: "#131854" - } - }: - //Dark Mode + primary: "#131854", + }, + } + : //Dark Mode { primary: { main: "#0de5b2", @@ -55,10 +55,10 @@ export const getDesignTokens = (mode) => ({ paper: "#131854", }, text: { - primary: "#FEFCFB" - } - }) - } + primary: "#FEFCFB", + }, + }), + }, }); export const getThemedComponents = (mode) => ({ @@ -101,18 +101,18 @@ export const getThemedComponents = (mode) => ({ }, }, }), - // Both Modes - MuiInputBase: { - styleOverrides: { - root: { - "& input": { - "&:-webkit-autofill": { - transition: - "background-color 50000s ease-in-out 0s, color 50000s ease-in-out 0s", - }, - }, + // Both Modes + MuiInputBase: { + styleOverrides: { + root: { + "& input": { + "&:-webkit-autofill": { + transition: + "background-color 50000s ease-in-out 0s, color 50000s ease-in-out 0s", }, }, - } + }, + }, + }, }, }); From 180aef845322b5e4caab6d9710daf52dd0f9396c Mon Sep 17 00:00:00 2001 From: Thomas Wood Date: Fri, 13 Dec 2024 15:18:51 +0000 Subject: [PATCH 6/6] undo hotfix, point at https://api.harmonydata.ac.uk/ for both prod and dev --- .env | 2 +- .env.development | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.env b/.env index 01b69ad..895f64e 100644 --- a/.env +++ b/.env @@ -1,4 +1,4 @@ -REACT_APP_API_URL=http://localhost:8000/ +REACT_APP_API_URL=https://api.harmonydata.ac.uk/ REACT_APP_API_EXAMPLES=$REACT_APP_API_URL/text/examples REACT_APP_API_PARSE=$REACT_APP_API_URL/text/parse REACT_APP_API_MATCH=$REACT_APP_API_URL/text/match diff --git a/.env.development b/.env.development index 3a5b998..895f64e 100644 --- a/.env.development +++ b/.env.development @@ -1,4 +1,4 @@ -REACT_APP_API_URL=http://localhost:8000 +REACT_APP_API_URL=https://api.harmonydata.ac.uk/ REACT_APP_API_EXAMPLES=$REACT_APP_API_URL/text/examples REACT_APP_API_PARSE=$REACT_APP_API_URL/text/parse REACT_APP_API_MATCH=$REACT_APP_API_URL/text/match