From 6731621a7851fa327d2c475fdd067d082e7d268d Mon Sep 17 00:00:00 2001 From: braddf Date: Thu, 19 Dec 2024 16:02:22 +0000 Subject: [PATCH 1/2] fix delta gsp selection bug --- apps/nowcasting-app/components/map/deltaMap.tsx | 3 ++- apps/nowcasting-app/pages/index.tsx | 11 ++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/nowcasting-app/components/map/deltaMap.tsx b/apps/nowcasting-app/components/map/deltaMap.tsx index ab03f558..a8e5a49c 100644 --- a/apps/nowcasting-app/components/map/deltaMap.tsx +++ b/apps/nowcasting-app/components/map/deltaMap.tsx @@ -152,7 +152,8 @@ const DeltaMap: React.FC = ({ ); map.addSource("latestPV", { type: "geojson", - data: forecastGeoJson + data: forecastGeoJson, + promoteId: "id" }); } else { if (generatedGeoJsonForecastData && source) { diff --git a/apps/nowcasting-app/pages/index.tsx b/apps/nowcasting-app/pages/index.tsx index fd0fd784..82d52786 100644 --- a/apps/nowcasting-app/pages/index.tsx +++ b/apps/nowcasting-app/pages/index.tsx @@ -35,7 +35,7 @@ import { getSitesLoadingState, isProduction } from "../components/helpers/utils"; -import { ActiveUnit } from "../components/map/types"; +import { ActiveUnit, NationalAggregation } from "../components/map/types"; import DeltaMap from "../components/map/deltaMap"; import * as Sentry from "@sentry/nextjs"; import SolarSiteChart from "../components/charts/solar-site-view/solar-site-chart"; @@ -71,6 +71,8 @@ export default function Home({ dashboardModeServer }: { dashboardModeServer: str const [, setSitesLoadingState] = useGlobalState("sitesLoadingState"); const [, setLoadingState] = useGlobalState("loadingState"); const [nHourForecast] = useGlobalState("nHourForecast"); + const [nationalAggregationLevel] = useGlobalState("nationalAggregationLevel"); + const [, setClickedGspId] = useGlobalState("clickedGspId"); const [forecastLastFetch30MinISO, setForecastLastFetch30MinISO] = useState(get30MinNow(-30)); const [forecastHistoricBackwardIntervalMinutes, setForecastHistoricBackwardIntervalMinutes] = @@ -106,6 +108,13 @@ export default function Home({ dashboardModeServer }: { dashboardModeServer: str setArraySettingInCookieStorage(CookieStorageKeys.VISIBLE_LINES, visibleLines); }, [visibleLines]); + // On view change, unset the clicked "GSP" if the aggregation is not GSP + useEffect(() => { + if (nationalAggregationLevel !== NationalAggregation.GSP) { + setClickedGspId(undefined); + } + }, [view]); + const currentView = (v: VIEWS) => v === view; useEffect(() => { From 42caeb061dde88300365cbc15b53a2bfd71a5045 Mon Sep 17 00:00:00 2001 From: braddf Date: Thu, 19 Dec 2024 16:05:12 +0000 Subject: [PATCH 2/2] explicit type on ngZones json const --- apps/nowcasting-app/components/helpers/data.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/nowcasting-app/components/helpers/data.ts b/apps/nowcasting-app/components/helpers/data.ts index 5ee9d9c5..21e258c6 100644 --- a/apps/nowcasting-app/components/helpers/data.ts +++ b/apps/nowcasting-app/components/helpers/data.ts @@ -240,8 +240,9 @@ export const generateGeoJsonForecastData: ( ); } else if (aggregation === NationalAggregation.zone) { console.log("aggregating to zone"); + const ngZonesJson = ngZones as FeatureCollection; features = mapZoneFeatures( - ngZones.features as Feature[], + ngZonesJson.features as Feature[], ngGSPZoneGroupings, combinedData, gspForecastsDataByTimestamp,