diff --git a/public/config.yaml b/public/config.yaml old mode 100644 new mode 100755 index 14cf2494..440b9cf0 --- a/public/config.yaml +++ b/public/config.yaml @@ -4,11 +4,11 @@ baseMap: BC # sdsUrl values will be replaced by dev or prod URLs when they become ready. # For now, we have demo instances inside the firewall. # Uses monsoon database -sdsUrl: http://docker-dev02.pcic.uvic.ca:30512 +#sdsUrl: http://docker-dev02.pcic.uvic.ca:30512 # Uses new database #sdsUrl: http://docker-dev02.pcic.uvic.ca:30562 # Local instance -#sdsUrl: http://localhost:5000 +sdsUrl: http://localhost:5000 # Currently deployed metadata backends do not respond to provinces QP. # When they do, we can use stationsQpProvinces and lose stationFilters @@ -34,3 +34,8 @@ pdpDataUrl: http://docker-dev02.pcic.uvic.ca:30514 #stationStride: undefined #showReloadStationsButton: false #timingEnabled: false + +# Preview Options +plotColor: "#1f77b4" +dataRequestDurations: [1, 3, 6, 12] # months +dataRequestDurationsDefault: 6 # months diff --git a/src/components/daterange/sub/DataTrack.js b/src/components/daterange/sub/DataTrack.js index 7039d0df..f4f4af2c 100644 --- a/src/components/daterange/sub/DataTrack.js +++ b/src/components/daterange/sub/DataTrack.js @@ -21,12 +21,11 @@ const baseHeight = 50; const getTrackStyle = ({ source, target, count, index, color }) => { const height = baseHeight / count / 2; const topPosition = -22 + (baseHeight / count) * index + height / 2; - console.log("### getTrackStyle", source, target, count, index, color); const basicStyle = { top: `${topPosition}px`, height: `${height}px`, left: `${source.percent}%`, - width: `calc(${target.percent - source.percent}% - 1px)`, + width: `calc(${target.percent - source.percent}% + 1px)`, backgroundColor: color, }; diff --git a/src/components/main/App/App.js b/src/components/main/App/App.js index ddd843af..9e4400d8 100644 --- a/src/components/main/App/App.js +++ b/src/components/main/App/App.js @@ -1,19 +1,16 @@ -import React, { useEffect } from "react"; +import React from "react"; import { Container } from "react-bootstrap"; import Disclaimer from "../../info/Disclaimer"; import Header from "../Header/Header"; -import useInitializeApp from "./use-initialize-app"; import { Outlet } from "react-router-dom"; import "./App.css"; -import { useConfig } from "../../../state/query-hooks/use-config"; - -export default function App() { - const { isLoading, isError } = useConfig(); - useInitializeApp(); +import { useConfigDefaults } from "../../../state/client-server-hooks/use-config-defaults"; +export const App = () => { + const { isLoading, isError } = useConfigDefaults(); if (isError) { - return
{configErrorMessage}
; + return
An Error occoured while loading the app configuration.
; } if (isLoading) { @@ -27,4 +24,6 @@ export default function App() { ); -} +}; + +export default App; diff --git a/src/components/main/App/use-initialize-app.js b/src/components/main/App/use-initialize-app.js deleted file mode 100644 index d7750a15..00000000 --- a/src/components/main/App/use-initialize-app.js +++ /dev/null @@ -1,55 +0,0 @@ -// This hook performs a number of one-time app initializations. -import { useEffect } from "react"; -import L from "leaflet"; -import { setLethargicMapScrolling } from "../../../utils/leaflet-extensions"; -import { setTimingEnabled } from "../../../utils/timing"; -import { useConfig } from "../../../state/query-hooks/use-config"; - -function initializeApp(config) { - console.log("### initializeApp", config); - if (config === null) { - return; - } - - // Set browser title - document.title = config.appTitle; - - // Set up (polygon) drawing tool in Leaflet. - L.drawLocal.edit.toolbar.buttons = { - edit: "Edit shapes", - editDisabled: "No shapes to edit", - remove: "Remove shapes", - removeDisabled: "No shapes to remove", - }; - L.drawLocal.edit.handlers.remove.tooltip = "Click shape to remove"; - L.drawLocal.edit.toolbar.actions.clearAll = { - title: "Remove all shapes", - text: "Remove all", - }; - - // Initialize Lethargy, which fixes scrolling problems with Mac computers. - if (config.lethargy.enabled) { - setLethargicMapScrolling( - config.lethargy.stability, - config.lethargy.sensitivity, - config.lethargy.tolerance, - ); - } - - // Export timing values to non-component code - setTimingEnabled(config.timingEnabled); -} - -/** - * This hook loads the config and initializes the app. Primarily setting up Map, Scrolling behaviour and debug timing. - * - * @returns {void} - */ -export default function useInitializeApp() { - const { data } = useConfig(); - useEffect(() => { - if (data) { - initializeApp(data); - } - }, [data]); -} diff --git a/src/components/main/Body/Body.js b/src/components/main/Body/Body.js index 48b1eec3..2db1d935 100644 --- a/src/components/main/Body/Body.js +++ b/src/components/main/Body/Body.js @@ -29,6 +29,7 @@ import { useConfig } from "../../../state/query-hooks/use-config"; import { useStations } from "../../../state/query-hooks/use-stations"; import { useVariables } from "../../../state/query-hooks/use-variables"; import { useFrequencies } from "../../../state/query-hooks/use-frequencies"; +import { useNetworks } from "../../../state/query-hooks/use-networks"; import css from "../common.module.css"; @@ -51,8 +52,12 @@ function Body() { isLoading: isFrequenciesLoading, isError: isFrequenciesError, } = useFrequencies(); + const { + data: networks, + isLoading: networksLoading, + isError: networksError, + } = useNetworks(); - // actions should be fixed functions on the store, so they shouldn't really change const actions = useStore( useShallow((state) => ({ setStationsLimit: state.setStationsLimit, @@ -117,7 +122,7 @@ function Body() {