From f5455d27e818401ab96a910d7030b7c4b1d3232f Mon Sep 17 00:00:00 2001
From: Phil Owen <19691521+PhillipsOwen@users.noreply.github.com>
Date: Wed, 23 Oct 2024 12:23:54 -0400
Subject: [PATCH 01/15] adding shortcut to the config component
---
webpack.config.js | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/webpack.config.js b/webpack.config.js
index 3724993..30d4cf9 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -124,7 +124,8 @@ module.exports = {
'@share': path.resolve(__dirname, 'src/components/trays/share/'),
'@utils': path.resolve(__dirname, 'src/utils/'),
'@side-by-side': path.resolve(__dirname, 'src/components/side-by-side/'),
- '@alert-user': path.resolve(__dirname, 'src/components/alert-user/')
+ '@alert-user': path.resolve(__dirname, 'src/components/alert-user/'),
+ '@config': path.resolve(__dirname, 'src/components/config/')
}
},
From 6c866979f5e1e007f1579ad46532c7198d75722c Mon Sep 17 00:00:00 2001
From: Phil Owen <19691521+PhillipsOwen@users.noreply.github.com>
Date: Wed, 23 Oct 2024 12:24:27 -0400
Subject: [PATCH 02/15] adding the config component
---
src/app.js | 2 ++
src/components/config/config.js | 26 ++++++++++++++++++++++++++
src/components/config/index.js | 1 +
3 files changed, 29 insertions(+)
create mode 100644 src/components/config/config.js
create mode 100644 src/components/config/index.js
diff --git a/src/app.js b/src/app.js
index 40f2a27..ec9fc5a 100644
--- a/src/app.js
+++ b/src/app.js
@@ -8,6 +8,7 @@ import { ControlPanel } from '@components/control-panel';
import { ComparePanel } from '@components/compare-panel';
import { MapLegend } from '@components/legend';
import { AlertUser } from '@components/alert-user';
+import { Config } from '@components/config';
/**
* renders the main content
@@ -32,6 +33,7 @@ const Content = () => {
return ;
})
}
+
diff --git a/src/components/config/config.js b/src/components/config/config.js
new file mode 100644
index 0000000..9cead2c
--- /dev/null
+++ b/src/components/config/config.js
@@ -0,0 +1,26 @@
+import React, { Fragment, useEffect } from "react";
+import { useLayers } from "@context";
+
+export const Config = () => {
+ // get the message alert details from state
+ const { setDefaultInstanceName } = useLayers();
+
+ useEffect (() => {
+ // get the instance name from UI data services
+ const instance_name = getDefaultInstanceName();
+
+ // if the retrieval successful
+ if (!instance_name.includes('Error')) {}
+ // set the default instance name
+ setDefaultInstanceName(instance_name);
+ }, []
+ );
+
+ const getDefaultInstanceName = () => {
+ return 'ec95d_dev_test';
+ };
+
+ return(
+
+ );
+};
\ No newline at end of file
diff --git a/src/components/config/index.js b/src/components/config/index.js
new file mode 100644
index 0000000..f03c228
--- /dev/null
+++ b/src/components/config/index.js
@@ -0,0 +1 @@
+export * from './config';
From d6aa69458da80d0e862e9c37c7e4e8159b32755b Mon Sep 17 00:00:00 2001
From: Phil Owen <19691521+PhillipsOwen@users.noreply.github.com>
Date: Wed, 23 Oct 2024 12:32:16 -0400
Subject: [PATCH 03/15] adding the default instance name state and usage,
tidying up/adding comments
---
src/components/control-panel/control-panel.js | 4 ++--
src/context/map-context.js | 24 ++++++++++++-------
2 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/src/components/control-panel/control-panel.js b/src/components/control-panel/control-panel.js
index b2254ae..52faca4 100644
--- a/src/components/control-panel/control-panel.js
+++ b/src/components/control-panel/control-panel.js
@@ -23,7 +23,7 @@ import {
Water as MaxElevationIcon,
Waves as HIResMaxElevationIcon,
} from '@mui/icons-material';
-import { getBrandingHandler, getNamespacedEnvParam } from "@utils/map-utils";
+import { getBrandingHandler, getNamespacedEnvParam, getDefaultInstance } from "@utils/map-utils";
import { Branding } from './branding';
const layerIcons = {
@@ -44,7 +44,7 @@ export const ControlPanel = () => {
toggleLayerVisibility,
toggleHurricaneLayerVisibility } = useLayers();
- const data_url = `${ getNamespacedEnvParam('REACT_APP_UI_DATA_URL') }` + `get_ui_data_secure?limit=1&use_v3_sp=true${ getBrandingHandler() }`;
+ const data_url = `${ getNamespacedEnvParam('REACT_APP_UI_DATA_URL') }` + `get_ui_data_secure?limit=1&use_v3_sp=true${ getBrandingHandler() + getDefaultInstance() }`;
const layers = [...defaultModelLayers];
const hurrLayers = [...hurricaneTrackLayers];
diff --git a/src/context/map-context.js b/src/context/map-context.js
index 0ad8e6e..39dd849 100644
--- a/src/context/map-context.js
+++ b/src/context/map-context.js
@@ -40,14 +40,28 @@ const layerTypes = {
};
export const LayersProvider = ({ children }) => {
+ // default and hurricane layer states
const [defaultModelLayers, setDefaultModelLayers] = useState([]);
const [hurricaneTrackLayers, setHurricaneTrackLayers] = useState([]);
// this object contains data for graph rendering
const [selectedObservations, setSelectedObservations] = useState([]);
+ // map reference state
const [map, setMap] = useState(null);
+ // base map state
+ const [baseMap, setBaseMap] = useState();
+
+ // used to track the view state of the share comment
+ const [showShareComment, setShowShareComment] = useState(true);
+
+ // used to show alerts
+ const [alertMsg, setAlertMsg] = useState(null);
+
+ // state to capture the default startup instance name
+ const [defaultInstanceName, setDefaultInstanceName] = useState('');
+
/**
* this section is for the side-by-side compare mode items
* @type {string}
@@ -361,20 +375,14 @@ export const LayersProvider = ({ children }) => {
setDefaultModelLayers([...newLayers]);
};
- const [baseMap, setBaseMap] = React.useState();
-
- // used to track the view state of the share comment
- const [showShareComment, setShowShareComment] = useState(true);
-
- // used to show alerts
- const [alertMsg, setAlertMsg] = useState(null);
-
return (
Date: Wed, 23 Oct 2024 12:33:07 -0400
Subject: [PATCH 04/15] adding the default instance name usage
---
src/components/map/default-layers.js | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/components/map/default-layers.js b/src/components/map/default-layers.js
index 396520f..4ff4784 100644
--- a/src/components/map/default-layers.js
+++ b/src/components/map/default-layers.js
@@ -5,7 +5,7 @@ import { useLayers } from '@context';
import { useQuery } from '@tanstack/react-query';
import axios from 'axios';
import { AdcircRasterLayer } from './adcirc-raster-layer';
-import { markClicked, parseSharedURL, addSharedObservations, getNamespacedEnvParam, getBrandingHandler } from '@utils/map-utils';
+import { markClicked, parseSharedURL, addSharedObservations, getNamespacedEnvParam, getBrandingHandler, getDefaultInstance } from '@utils/map-utils';
const newLayerDefaultState = (layer) => {
const { product_type } = layer.properties;
@@ -93,7 +93,7 @@ export const DefaultLayers = () => {
const shared_params = parseSharedURL();
// create the URLs to the data endpoints
- const data_url = `${ getNamespacedEnvParam('REACT_APP_UI_DATA_URL') }get_ui_data_secure?limit=1&use_new_wb=true&use_v3_sp=true${ getBrandingHandler() }${ shared_params['run_id'] }`;
+ const data_url = `${ getNamespacedEnvParam('REACT_APP_UI_DATA_URL') }get_ui_data_secure?instance_name=hsofs_gfs_dev&limit=1&use_new_wb=true&use_v3_sp=true${ getBrandingHandler() + getDefaultInstance() }${ shared_params['run_id'] }`;
const gs_wfs_url = `${ getNamespacedEnvParam('REACT_APP_GS_DATA_URL') }`;
// retrieve the catalog member with the provided id
@@ -136,6 +136,7 @@ export const DefaultLayers = () => {
}
return(data);
};
+
useQuery({
queryKey: ['apsviz-default-data', data_url],
queryFn: getDefaultLayers,
From 641b445b24c1ef7ef418e1f2a3bea42c7ce78f21 Mon Sep 17 00:00:00 2001
From: Phil Owen <19691521+PhillipsOwen@users.noreply.github.com>
Date: Wed, 23 Oct 2024 12:33:32 -0400
Subject: [PATCH 05/15] using a better manner of finding the product name
---
src/components/map/adcirc-raster-layer.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/components/map/adcirc-raster-layer.js b/src/components/map/adcirc-raster-layer.js
index 9b74c34..806670a 100644
--- a/src/components/map/adcirc-raster-layer.js
+++ b/src/components/map/adcirc-raster-layer.js
@@ -117,7 +117,7 @@ export const AdcircRasterLayer = (layer) => {
// create the correct TDS URL without the hostname
const tds_url = layer.properties['tds_download_url'].replace('catalog', 'dodsC').replace('catalog.html',
- (layer.id.indexOf('swan') < 0 ? 'fort' : 'swan_HS') + '.63.nc').split('/thredds')[1];
+ (layer.id.includes('swan') ? 'fort' : 'swan_HS') + '.63.nc').split('/thredds')[1];
// generate the full url
const fullTDSURL = data_url + "get_geo_point_data?lon=" + e.latlng.lng + "&lat=" + e.latlng.lat + "&ensemble=nowcast" +
From df19c07cce6b1827661ae805d0bffcee4f13787d Mon Sep 17 00:00:00 2001
From: Phil Owen <19691521+PhillipsOwen@users.noreply.github.com>
Date: Wed, 23 Oct 2024 16:42:52 -0400
Subject: [PATCH 06/15] adding the wait for the default instance name to be
declared before continuing, config component
---
src/app.js | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/app.js b/src/app.js
index ec9fc5a..b379c4e 100644
--- a/src/app.js
+++ b/src/app.js
@@ -18,7 +18,7 @@ import { Config } from '@components/config';
*/
const Content = () => {
// install the selected observation list from the layer context
- const { selectedObservations } = useLayers();
+ const { selectedObservations, defaultInstanceName } = useLayers();
// render all the application content
return (
@@ -35,9 +35,11 @@ const Content = () => {
}
-
-
+ {/* here we are waiting for the retrieval of the default Instance name
+ before rendering these components */}
+ { (defaultInstanceName != null) && }
+ { (defaultInstanceName != null) && }
From 82b8df8a3e28575ef2fe5afcb92762d7bf9da9c0 Mon Sep 17 00:00:00 2001
From: Phil Owen <19691521+PhillipsOwen@users.noreply.github.com>
Date: Wed, 23 Oct 2024 17:00:26 -0400
Subject: [PATCH 07/15] adding the instance name to data retrieval, tidying up
---
src/components/map/default-layers.js | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/components/map/default-layers.js b/src/components/map/default-layers.js
index 4ff4784..be56b94 100644
--- a/src/components/map/default-layers.js
+++ b/src/components/map/default-layers.js
@@ -5,7 +5,8 @@ import { useLayers } from '@context';
import { useQuery } from '@tanstack/react-query';
import axios from 'axios';
import { AdcircRasterLayer } from './adcirc-raster-layer';
-import { markClicked, parseSharedURL, addSharedObservations, getNamespacedEnvParam, getBrandingHandler, getDefaultInstance } from '@utils/map-utils';
+import { markClicked, parseSharedURL, addSharedObservations, getNamespacedEnvParam, getBrandingHandler } from '@utils/map-utils';
+import { getDefaultInstanceName } from "@components/config";
const newLayerDefaultState = (layer) => {
const { product_type } = layer.properties;
@@ -93,7 +94,7 @@ export const DefaultLayers = () => {
const shared_params = parseSharedURL();
// create the URLs to the data endpoints
- const data_url = `${ getNamespacedEnvParam('REACT_APP_UI_DATA_URL') }get_ui_data_secure?instance_name=hsofs_gfs_dev&limit=1&use_new_wb=true&use_v3_sp=true${ getBrandingHandler() + getDefaultInstance() }${ shared_params['run_id'] }`;
+ const data_url = `${ getNamespacedEnvParam('REACT_APP_UI_DATA_URL') }get_ui_data_secure?limit=1&use_new_wb=true&use_v3_sp=true${ getBrandingHandler() + getDefaultInstanceName() }${ shared_params['run_id'] }`;
const gs_wfs_url = `${ getNamespacedEnvParam('REACT_APP_GS_DATA_URL') }`;
// retrieve the catalog member with the provided id
From 4395924e9acae18aa232293377302989d86288af Mon Sep 17 00:00:00 2001
From: Phil Owen <19691521+PhillipsOwen@users.noreply.github.com>
Date: Wed, 23 Oct 2024 17:01:18 -0400
Subject: [PATCH 08/15] fixing bug to not render this layer until the product
type is set
---
src/components/map/adcirc-raster-layer.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/components/map/adcirc-raster-layer.js b/src/components/map/adcirc-raster-layer.js
index 806670a..13980ba 100644
--- a/src/components/map/adcirc-raster-layer.js
+++ b/src/components/map/adcirc-raster-layer.js
@@ -165,7 +165,7 @@ export const AdcircRasterLayer = (layer) => {
sld_body: currentStyle,
}), [currentStyle]);
- return currentStyle && (
+ return currentStyle && productType && (
Date: Wed, 23 Oct 2024 17:02:22 -0400
Subject: [PATCH 09/15] moving the instance name stuff to another file, adding
the instance name to the data url
---
src/components/control-panel/control-panel.js | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/components/control-panel/control-panel.js b/src/components/control-panel/control-panel.js
index 52faca4..3877513 100644
--- a/src/components/control-panel/control-panel.js
+++ b/src/components/control-panel/control-panel.js
@@ -23,7 +23,8 @@ import {
Water as MaxElevationIcon,
Waves as HIResMaxElevationIcon,
} from '@mui/icons-material';
-import { getBrandingHandler, getNamespacedEnvParam, getDefaultInstance } from "@utils/map-utils";
+import { getBrandingHandler, getNamespacedEnvParam } from "@utils/map-utils";
+import { getDefaultInstanceName } from "@components/config";
import { Branding } from './branding';
const layerIcons = {
@@ -44,7 +45,7 @@ export const ControlPanel = () => {
toggleLayerVisibility,
toggleHurricaneLayerVisibility } = useLayers();
- const data_url = `${ getNamespacedEnvParam('REACT_APP_UI_DATA_URL') }` + `get_ui_data_secure?limit=1&use_v3_sp=true${ getBrandingHandler() + getDefaultInstance() }`;
+ const data_url = `${ getNamespacedEnvParam('REACT_APP_UI_DATA_URL') }` + `get_ui_data_secure?limit=1&use_v3_sp=true${ getBrandingHandler() + getDefaultInstanceName() }`;
const layers = [...defaultModelLayers];
const hurrLayers = [...hurricaneTrackLayers];
From f61d5704f4626999f399d2ba00ee7f379f53b7ef Mon Sep 17 00:00:00 2001
From: Phil Owen <19691521+PhillipsOwen@users.noreply.github.com>
Date: Wed, 23 Oct 2024 17:04:29 -0400
Subject: [PATCH 10/15] adding the default instance name to state
---
src/context/map-context.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/context/map-context.js b/src/context/map-context.js
index 39dd849..48a3f57 100644
--- a/src/context/map-context.js
+++ b/src/context/map-context.js
@@ -60,7 +60,7 @@ export const LayersProvider = ({ children }) => {
const [alertMsg, setAlertMsg] = useState(null);
// state to capture the default startup instance name
- const [defaultInstanceName, setDefaultInstanceName] = useState('');
+ const [defaultInstanceName, setDefaultInstanceName] = useState(null);
/**
* this section is for the side-by-side compare mode items
From 34088ebf6d7f91a3049bb8dd0ce928f86660abd3 Mon Sep 17 00:00:00 2001
From: Phil Owen <19691521+PhillipsOwen@users.noreply.github.com>
Date: Wed, 23 Oct 2024 17:05:25 -0400
Subject: [PATCH 11/15] adding the default instance name collection for the web
service, error handling
---
src/components/config/config.js | 101 +++++++++++++++++++++++++++-----
1 file changed, 85 insertions(+), 16 deletions(-)
diff --git a/src/components/config/config.js b/src/components/config/config.js
index 9cead2c..b0af10d 100644
--- a/src/components/config/config.js
+++ b/src/components/config/config.js
@@ -1,26 +1,95 @@
-import React, { Fragment, useEffect } from "react";
+import { useEffect, useState } from "react";
import { useLayers } from "@context";
+import { getNamespacedEnvParam } from "@utils";
+import { useQuery } from '@tanstack/react-query';
+import axios from 'axios';
+/**
+ * gets the default instance name for startup layers
+ *
+ */
+export const getDefaultInstanceName = () => {
+ // init the return
+ let ret_val = '';
+
+ // get the state variable that suppresses using the instance name
+ const {
+ defaultInstanceName
+ } = useLayers();
+
+ // if there is a valid default instance name
+ if (!defaultInstanceName.includes('Error') && defaultInstanceName.length) {
+ // build the extended query string
+ ret_val = '&instance_name=' + defaultInstanceName;
+ }
+
+ // return the query string addition
+ return ret_val;
+};
+
+/**
+ * handles getting the default instance name
+ *
+ * @returns JSX.Element
+ * @constructor
+ */
export const Config = () => {
// get the message alert details from state
const { setDefaultInstanceName } = useLayers();
- useEffect (() => {
- // get the instance name from UI data services
- const instance_name = getDefaultInstanceName();
+ // use this to trigger the data retrieval
+ const [ dataUrl, setDataUrl ] = useState(null);
+
+ /**
+ * create a url to get the instance name
+ */
+ useEffect( () => {
+ // get the site branding for the query string
+ const theUrl = 'get_ui_instance_name?reset=false&site_branding=' + (window.location.href.includes('nopp') ? 'NOPP' : 'APSViz');
+
+ // set the data url. this will spawn a data request
+ setDataUrl(getNamespacedEnvParam('REACT_APP_UI_DATA_URL') + theUrl);
+ }, [] );
+
+ /**
+ * grab the default instance name
+ */
+ useQuery( {
+ // specify the data key and url to use
+ queryKey: ['get_ui_instance_name', dataUrl],
+
+ // create the function to call for data
+ queryFn: async () => {
+ // create the authorization header
+ const requestOptions = {
+ method: 'GET',
+ headers: { Authorization: `Bearer ${ getNamespacedEnvParam('REACT_APP_UI_DATA_TOKEN') }`}
+ };
- // if the retrieval successful
- if (!instance_name.includes('Error')) {}
- // set the default instance name
- setDefaultInstanceName(instance_name);
- }, []
- );
+ // make the call to get the data
+ const ret_val = await axios
+ // make the call to get the data
+ .get(dataUrl, requestOptions)
+ // use the data returned
+ .then (( response ) => {
+ // return the data
+ return response.data;
+ })
+ .catch (( error ) => {
+ // make sure we do not render anything
+ return error.response.status;
+ });
- const getDefaultInstanceName = () => {
- return 'ec95d_dev_test';
- };
+ // if the retrieval did not have an issue
+ if (typeof ret_val === 'string' && !ret_val.includes('Error'))
+ // save the instance name value
+ setDefaultInstanceName(ret_val);
+ else
+ // blank the instance name on any http or data gathering error.
+ setDefaultInstanceName('');
- return(
-
- );
+ // return something
+ return true;
+ }, refetchOnWindowFocus: false
+ });
};
\ No newline at end of file
From e9bcb4fc5969022c87960b7697a27b27882304d4 Mon Sep 17 00:00:00 2001
From: Phil Owen <19691521+PhillipsOwen@users.noreply.github.com>
Date: Thu, 24 Oct 2024 09:34:11 -0400
Subject: [PATCH 12/15] making the tooltip more accurate
---
src/components/alert-user/alert-user.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/components/alert-user/alert-user.js b/src/components/alert-user/alert-user.js
index de554c8..51c772b 100644
--- a/src/components/alert-user/alert-user.js
+++ b/src/components/alert-user/alert-user.js
@@ -12,7 +12,7 @@ export const AlertUser = () => {