diff --git a/frontend/src/modules/Map/MapSettings.tsx b/frontend/src/modules/Map/MapSettings.tsx index b3b64789b..bcf8d71fb 100644 --- a/frontend/src/modules/Map/MapSettings.tsx +++ b/frontend/src/modules/Map/MapSettings.tsx @@ -3,6 +3,7 @@ import React from "react"; import { SurfaceStatisticFunction_api } from "@api"; import { EnsembleIdent } from "@framework/EnsembleIdent"; import { ModuleFCProps } from "@framework/Module"; +import { useSettingsStatusWriter } from "@framework/StatusWriter"; import { SyncSettingKey, SyncSettingsHelper } from "@framework/SyncSettings"; import { useEnsembleSet } from "@framework/WorkbenchSession"; import { SingleEnsembleSelect } from "@framework/components/SingleEnsembleSelect"; @@ -32,13 +33,12 @@ const TimeTypeEnumToStringMapping = { }; //----------------------------------------------------------------------------------------------------------- export function MapSettings(props: ModuleFCProps) { - const myInstanceIdStr = props.moduleContext.getInstanceIdString(); - console.debug(`${myInstanceIdStr} -- render MapSettings`); - const ensembleSet = useEnsembleSet(props.workbenchSession); const [selectedEnsembleIdent, setSelectedEnsembleIdent] = React.useState(null); const [timeType, setTimeType] = React.useState(TimeType.None); + const statusWriter = useSettingsStatusWriter(props.moduleContext); + const [selectedSurfaceName, setSelectedSurfaceName] = React.useState(null); const [selectedSurfaceAttribute, setSelectedSurfaceAttribute] = React.useState(null); const [realizationNum, setRealizationNum] = React.useState(0); @@ -51,11 +51,6 @@ export function MapSettings(props: ModuleFCProps) { const syncedValueSurface = syncHelper.useValue(SyncSettingKey.SURFACE, "global.syncValue.surface"); const syncedValueDate = syncHelper.useValue(SyncSettingKey.DATE, "global.syncValue.date"); - const renderCount = React.useRef(0); - React.useEffect(function incrementRenderCount() { - renderCount.current = renderCount.current + 1; - }); - const candidateEnsembleIdent = maybeAssignFirstSyncedEnsemble(selectedEnsembleIdent, syncedValueEnsembles); const computedEnsembleIdent = fixupEnsembleIdent(candidateEnsembleIdent, ensembleSet); const surfaceDirectoryQuery = useSurfaceDirectoryQuery( @@ -63,6 +58,11 @@ export function MapSettings(props: ModuleFCProps) { computedEnsembleIdent?.getEnsembleName() ); + const isError = surfaceDirectoryQuery.isError; + if (isError) { + statusWriter.addError("Error loading surface directory"); + } + const surfaceDirectory = new SurfaceDirectory( surfaceDirectoryQuery.data ? { surfaceMetas: surfaceDirectoryQuery.data, timeType: timeType, useObservedSurfaces: useObserved } @@ -286,7 +286,6 @@ export function MapSettings(props: ModuleFCProps) { onAggregationSelectionChange={handleAggregationChanged} /> {chooseRealizationElement} -
({renderCount.current})
); } diff --git a/frontend/src/modules/Map/MapView.tsx b/frontend/src/modules/Map/MapView.tsx index 6f158503b..336948fe9 100644 --- a/frontend/src/modules/Map/MapView.tsx +++ b/frontend/src/modules/Map/MapView.tsx @@ -1,62 +1,63 @@ import React from "react"; import { ModuleFCProps } from "@framework/Module"; +import { useViewStatusWriter } from "@framework/StatusWriter"; +import { ContentError, ContentInfo } from "@modules/_shared/components/ContentMessage"; import { useSurfaceDataQueryByAddress } from "@modules_shared/Surface"; import SubsurfaceViewer from "@webviz/subsurface-viewer"; import { MapState } from "./MapState"; -import { makeSurfaceAddressString } from "@modules_shared/Surface/surfaceAddress"; //----------------------------------------------------------------------------------------------------------- export function MapView(props: ModuleFCProps) { const surfaceAddress = props.moduleContext.useStoreValue("surfaceAddress"); - const renderCount = React.useRef(0); - React.useEffect(function incrementRenderCount() { - renderCount.current = renderCount.current + 1; - }); - - console.debug(`render MapView start [${surfaceAddress ? makeSurfaceAddressString(surfaceAddress) : "null"}]`); - + const statusWriter = useViewStatusWriter(props.moduleContext); const surfDataQuery = useSurfaceDataQueryByAddress(surfaceAddress); - console.debug(`surfDataQuery.status=${surfDataQuery.status}`); - if (!surfDataQuery.data) { - return
No data
; - } + const isLoading = surfDataQuery.isFetching; + statusWriter.setLoading(isLoading); - console.debug(`render MapView done [${surfaceAddress ? makeSurfaceAddressString(surfaceAddress) : "null"}]`); + const hasError = surfDataQuery.isError; + if (hasError) { + statusWriter.addError("Error fetching surface data"); + } const surfData = surfDataQuery.data; return (
- Error loading surface data + ) : isLoading ? ( + Is loading surface data + ) : !surfData ? ( + No surface data - make valid selection + ) : ( + -
- {props.moduleContext.getInstanceIdString()} -
+ ]} + /> + )}
); }