From 0eef0de34c040ebf2957591aaa1a918d97ad013e Mon Sep 17 00:00:00 2001 From: Ruben Thoms <69145689+rubenthoms@users.noreply.github.com> Date: Fri, 6 Dec 2024 10:46:57 +0100 Subject: [PATCH] Multiple enhancements, adjustments, and bug fixes to frontend code (#809) --- frontend/src/framework/ModuleDataTags.ts | 8 +- frontend/src/framework/WorkbenchSession.ts | 2 +- .../EnsembleDropdown/ensembleDropdown.tsx | 25 ++- .../EnsembleSelect/ensembleSelect.tsx | 37 ++-- .../private-components/modulesList.tsx | 2 +- frontend/src/framework/utils/colorPalettes.ts | 2 +- frontend/src/lib/components/Input/input.tsx | 16 ++ .../src/lib/components/MenuButton/index.ts | 2 + .../lib/components/MenuButton/menuButton.tsx | 19 ++ .../components/MenuHeading/menuHeading.tsx | 14 +- .../src/lib/components/SortableList/index.ts | 4 +- .../SortableList/sortableListGroup.tsx | 31 ++-- .../SortableList/sortableListItem.tsx | 9 +- frontend/src/lib/utils/ColorPalette.ts | 22 +++ frontend/src/lib/utils/ColorScale.ts | 46 ++++- .../settings/components/wellboreSelector.tsx | 154 ++++++++++++---- .../modules/3DViewer/settings/settings.tsx | 2 +- .../components/SubsurfaceViewerWrapper.tsx | 6 +- .../modules/FlowNetwork/settings/settings.tsx | 2 +- .../components/layerSettings/gridLayer.tsx | 2 +- .../components/layerSettings/seismicLayer.tsx | 2 +- .../components/layerSettings/surfaceLayer.tsx | 2 +- .../surfacesUncertaintyLayer.tsx | 2 +- .../layerSettings/wellpicksLayer.tsx | 2 +- .../src/modules/Map/settings/settings.tsx | 2 +- .../settings/settings.tsx | 2 +- .../src/modules/Pvt/settings/settings.tsx | 2 +- frontend/src/modules/Rft/settings.tsx | 4 +- .../settings/settings.tsx | 2 +- .../settings/settings.tsx | 2 +- .../SubsurfaceMap/settings/settings.tsx | 2 +- .../src/modules/Vfp/settings/settings.tsx | 119 ++++++------ .../WellCompletions/settings/settings.tsx | 2 +- .../colorLegendsContainer.tsx | 174 +++++++++++------- .../ColorScaleSelector/colorScaleSelector.tsx | 8 + .../inplaceVolumetricsFilterComponent.tsx | 2 +- .../modules/_shared/components/ReadoutBox.tsx | 2 +- .../SubsurfaceViewerWithCameraState/index.ts | 2 + .../subsurfaceViewerWithCameraState.tsx} | 8 + package-lock.json | 6 - 40 files changed, 519 insertions(+), 233 deletions(-) create mode 100644 frontend/src/lib/components/MenuButton/index.ts create mode 100644 frontend/src/lib/components/MenuButton/menuButton.tsx create mode 100644 frontend/src/modules/_shared/components/SubsurfaceViewerWithCameraState/index.ts rename frontend/src/modules/{3DViewer/view/components/SubsurfaceViewerWithCameraState.tsx => _shared/components/SubsurfaceViewerWithCameraState/subsurfaceViewerWithCameraState.tsx} (85%) delete mode 100644 package-lock.json diff --git a/frontend/src/framework/ModuleDataTags.ts b/frontend/src/framework/ModuleDataTags.ts index b7251cc7c..092cf07ce 100644 --- a/frontend/src/framework/ModuleDataTags.ts +++ b/frontend/src/framework/ModuleDataTags.ts @@ -10,7 +10,8 @@ export enum ModuleDataTagId { OBSERVATIONS = "observations", SEISMIC = "seismic", WELL_COMPLETIONS = "well-completions", - VFP = "vfp" + VFP = "vfp", + POLYGONS = "polygons", } export type ModuleDataTag = { @@ -30,6 +31,11 @@ export const ModuleDataTags: ModuleDataTag[] = [ name: "3D grid model", description: "3D grid model", }, + { + id: ModuleDataTagId.POLYGONS, + name: "Polygons", + description: "Polygons", + }, { id: ModuleDataTagId.GROUP_TREE, name: "Group tree", diff --git a/frontend/src/framework/WorkbenchSession.ts b/frontend/src/framework/WorkbenchSession.ts index aa9d610c8..54fa1c5ad 100644 --- a/frontend/src/framework/WorkbenchSession.ts +++ b/frontend/src/framework/WorkbenchSession.ts @@ -77,7 +77,7 @@ export class WorkbenchSession { } } -function createEnsembleRealizationFilterFuncForWorkbenchSession(workbenchSession: WorkbenchSession) { +export function createEnsembleRealizationFilterFuncForWorkbenchSession(workbenchSession: WorkbenchSession) { return function ensembleRealizationFilterFunc(ensembleIdent: EnsembleIdent): readonly number[] { const realizationFilterSet = workbenchSession.getRealizationFilterSet(); const realizationFilter = realizationFilterSet.getRealizationFilterForEnsembleIdent(ensembleIdent); diff --git a/frontend/src/framework/components/EnsembleDropdown/ensembleDropdown.tsx b/frontend/src/framework/components/EnsembleDropdown/ensembleDropdown.tsx index b292f249a..f8bfd6a8c 100644 --- a/frontend/src/framework/components/EnsembleDropdown/ensembleDropdown.tsx +++ b/frontend/src/framework/components/EnsembleDropdown/ensembleDropdown.tsx @@ -1,24 +1,31 @@ +import React from "react"; + +import { Ensemble } from "@framework/Ensemble"; import { EnsembleIdent } from "@framework/EnsembleIdent"; -import { EnsembleSet } from "@framework/EnsembleSet"; import { ColorTile } from "@lib/components/ColorTile"; import { Dropdown, DropdownOption, DropdownProps } from "@lib/components/Dropdown"; type EnsembleDropdownProps = { - ensembleSet: EnsembleSet; + ensembles: readonly Ensemble[]; value: EnsembleIdent | null; onChange: (ensembleIdent: EnsembleIdent | null) => void; } & Omit, "options" | "value" | "onChange">; export function EnsembleDropdown(props: EnsembleDropdownProps): JSX.Element { - const { ensembleSet, value, onChange, ...rest } = props; + const { onChange, value, ...rest } = props; - function handleSelectionChanged(selectedEnsembleIdentStr: string) { - const foundEnsemble = ensembleSet.findEnsembleByIdentString(selectedEnsembleIdentStr); - onChange(foundEnsemble ? foundEnsemble.getIdent() : null); - } + const handleSelectionChange = React.useCallback( + function handleSelectionChange(selectedEnsembleIdentStr: string) { + const foundEnsemble = props.ensembles.find( + (ensemble) => ensemble.getIdent().toString() === selectedEnsembleIdentStr + ); + onChange(foundEnsemble ? foundEnsemble.getIdent() : null); + }, + [props.ensembles, onChange] + ); const optionsArr: DropdownOption[] = []; - for (const ens of ensembleSet.getEnsembleArr()) { + for (const ens of props.ensembles) { optionsArr.push({ value: ens.getIdent().toString(), label: ens.getDisplayName(), @@ -30,5 +37,5 @@ export function EnsembleDropdown(props: EnsembleDropdownProps): JSX.Element { }); } - return ; + return ; } diff --git a/frontend/src/framework/components/EnsembleSelect/ensembleSelect.tsx b/frontend/src/framework/components/EnsembleSelect/ensembleSelect.tsx index 51a9601f6..6fae717a6 100644 --- a/frontend/src/framework/components/EnsembleSelect/ensembleSelect.tsx +++ b/frontend/src/framework/components/EnsembleSelect/ensembleSelect.tsx @@ -1,31 +1,36 @@ +import React from "react"; + +import { Ensemble } from "@framework/Ensemble"; import { EnsembleIdent } from "@framework/EnsembleIdent"; -import { EnsembleSet } from "@framework/EnsembleSet"; import { ColorTile } from "@lib/components/ColorTile"; import { Select, SelectOption, SelectProps } from "@lib/components/Select"; type EnsembleSelectProps = { - ensembleSet: EnsembleSet; + ensembles: readonly Ensemble[]; value: EnsembleIdent[]; onChange: (ensembleIdentArr: EnsembleIdent[]) => void; } & Omit, "options" | "value" | "onChange">; -export function EnsembleSelect(props: EnsembleSelectProps): JSX.Element { - const { ensembleSet, value, onChange, multiple, ...rest } = props; - - function handleSelectionChanged(selectedEnsembleIdentStrArr: string[]) { - const identArr: EnsembleIdent[] = []; - for (const identStr of selectedEnsembleIdentStrArr) { - const foundEnsemble = ensembleSet.findEnsembleByIdentString(identStr); - if (foundEnsemble) { - identArr.push(foundEnsemble.getIdent()); +export function EnsembleSelect(props: EnsembleSelectProps): React.ReactNode { + const { ensembles, value, onChange, multiple, ...rest } = props; + + const handleSelectionChange = React.useCallback( + function handleSelectionChanged(selectedEnsembleIdentStrArr: string[]) { + const identArr: EnsembleIdent[] = []; + for (const identStr of selectedEnsembleIdentStrArr) { + const foundEnsemble = ensembles.find((ens) => ens.getIdent().toString() === identStr); + if (foundEnsemble) { + identArr.push(foundEnsemble.getIdent()); + } } - } - onChange(identArr); - } + onChange(identArr); + }, + [ensembles, onChange] + ); const optionsArr: SelectOption[] = []; - for (const ens of ensembleSet.getEnsembleArr()) { + for (const ens of ensembles) { optionsArr.push({ value: ens.getIdent().toString(), label: ens.getDisplayName(), @@ -48,7 +53,7 @@ export function EnsembleSelect(props: EnsembleSelectProps): JSX.Element { - + <> + +
+ +
+
+ + <> +
+ + +
+ value.toString()) ?? []} - onChange={handleThpIndicesSelectionChange} - size={Math.min(5, vfpDataAccessor?.getNumberOfValues(VfpParam.THP) ?? 5)} - multiple={true} - /> - - {vfpDataAccessor?.isProdTable() &&
- + {vfpDataAccessor?.isProdTable() && ( +
+ +