forked from equinor/webviz
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
55dba4f
commit cf82c95
Showing
9 changed files
with
151 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
frontend/src/modules/LayerSpike/layers/implementations/settings/SurfaceLayer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React from "react"; | ||
|
||
import { Dropdown, DropdownOption } from "@lib/components/Dropdown"; | ||
|
||
import { SettingDelegate } from "../../delegates/SettingDelegate"; | ||
import { Setting, SettingComponentProps } from "../../interfaces"; | ||
import { SettingType } from "../../settingsTypes"; | ||
|
||
type ValueType = string | null; | ||
|
||
export class SurfaceLayer implements Setting<ValueType> { | ||
private _delegate: SettingDelegate<ValueType> = new SettingDelegate<ValueType>(null); | ||
|
||
getType(): SettingType { | ||
return SettingType.SURFACE_LAYER; | ||
} | ||
|
||
getLabel(): string { | ||
return "Surface layer"; | ||
} | ||
|
||
getDelegate(): SettingDelegate<ValueType> { | ||
return this._delegate; | ||
} | ||
|
||
makeComponent(): (props: SettingComponentProps<ValueType>) => React.ReactNode { | ||
return function SurfaceLayer(props: SettingComponentProps<ValueType>) { | ||
const options: DropdownOption[] = props.availableValues.map((value) => { | ||
return { | ||
value: value.toString(), | ||
label: value === null ? "None" : value.toString(), | ||
}; | ||
}); | ||
|
||
return ( | ||
<Dropdown | ||
options={options} | ||
value={!props.isOverridden ? props.value?.toString() : props.overriddenValue?.toString()} | ||
onChange={props.onValueChange} | ||
disabled={props.isOverridden} | ||
showArrows | ||
/> | ||
); | ||
}; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
frontend/src/modules/LayerSpike/layers/implementations/utils/surfaceNamesAndLayers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
export function extractSurfaceNamesAndLayers(surfaceNamesAndLayers: string[]): { | ||
surfaceName: string; | ||
surfaceLayers: string[]; | ||
}[] { | ||
const surfaceNamesAndLayersMap: Map<string, Set<string>> = new Map(); | ||
|
||
const regex = /^([\w .]+?)( (top|bottom))?$/i; | ||
|
||
for (const surfaceNameOrLayer of surfaceNamesAndLayers) { | ||
const match = regex.exec(surfaceNameOrLayer); | ||
if (match) { | ||
const [, surfaceName, , surfaceLayer] = match; | ||
const surfaceLayers = surfaceNamesAndLayersMap.get(surfaceName) || new Set(); | ||
if (surfaceLayer) { | ||
surfaceLayers.add(surfaceLayer); | ||
} | ||
surfaceNamesAndLayersMap.set(surfaceName, surfaceLayers); | ||
} | ||
} | ||
|
||
return Array.from(surfaceNamesAndLayersMap.entries()).map(([surfaceName, surfaceLayers]) => ({ | ||
surfaceName, | ||
surfaceLayers: Array.from(surfaceLayers), | ||
})); | ||
} | ||
|
||
export function combineSurfaceNameAndLayer(surfaceName: string | null, surfaceLayer: string | null): string | null { | ||
if (!surfaceName || !surfaceLayer) { | ||
return null; | ||
} | ||
return surfaceLayer !== "DEFAULT" ? `${surfaceName} ${surfaceLayer}` : surfaceName; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters