From 237f924946c3a7cb18cc0567860051b3c542da9b Mon Sep 17 00:00:00 2001 From: mheggelund Date: Thu, 19 Oct 2023 12:18:55 +0200 Subject: [PATCH 1/3] chore: Add nameInput to add model --- .../AddModel/AddModelDialog/AddModelDialog.tsx | 14 +++++++++----- .../AddModel/ModelMetadata/ModelMetadata.tsx | 13 ++++++++++++- src/pages/Browse/Browse.tsx | 17 +++++++++-------- 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/src/features/AddModel/AddModelDialog/AddModelDialog.tsx b/src/features/AddModel/AddModelDialog/AddModelDialog.tsx index fefb7e75..96e1aa31 100644 --- a/src/features/AddModel/AddModelDialog/AddModelDialog.tsx +++ b/src/features/AddModel/AddModelDialog/AddModelDialog.tsx @@ -8,16 +8,17 @@ import * as Styled from './AddModelDialog.styled'; interface AddModelDialogProps { isOpen: boolean; - confirm: (file: File) => Promise; + confirm: (file: File, metadata: Partial) => Promise; cancel: () => void; } export default interface MetadataProps { - description?: string; + name: string; + description: string; field: string[]; zone?: string[]; formation: string[]; - analogue?: string[] | AnalogueList[]; + analogue?: AnalogueList[]; } export type ErrorType = { @@ -35,7 +36,10 @@ export const AddModelDialog = ({ NC: undefined, INI: undefined, }); - const [metadata, setMetadata] = useState>(); + const [metadata, setMetadata] = useState>({ + name: '', + description: '', + }); const [errors, setErrors] = useState({}); const [submitting, setSubmitting] = useState(false); @@ -70,7 +74,7 @@ export const AddModelDialog = ({ }; const finishSubmit = () => { - if (files.NC) confirm(files.NC); + if (files.NC) confirm(files.NC, metadata); }; useEffect(() => { diff --git a/src/features/AddModel/ModelMetadata/ModelMetadata.tsx b/src/features/AddModel/ModelMetadata/ModelMetadata.tsx index 94462f0a..07e30118 100644 --- a/src/features/AddModel/ModelMetadata/ModelMetadata.tsx +++ b/src/features/AddModel/ModelMetadata/ModelMetadata.tsx @@ -21,7 +21,6 @@ export const ModelMetadata = ({ setMetadata: (metadata: Partial) => void; }) => { const fields = { - description: 'Description string', field: ['Tor', 'Pål'], zone: ['Zone 1', 'Zone 2', 'Zone 3'], formation: ['Rocky', 'Hilly', 'Flat'], @@ -43,6 +42,14 @@ export const ModelMetadata = ({ Description and metadata + ) => + setMetadata({ ...metadata, name: e.currentTarget.value }) + } + /> ) => handleInput(e, 'field') } @@ -72,6 +80,7 @@ export const ModelMetadata = ({ className={`${errors.formation && 'model-required'}`} label="Formation" options={fields.formation} + selectedOptions={metadata?.formation} multiple onOptionsChange={(e: AutocompleteChanges) => handleInput(e, 'formation') @@ -87,6 +96,7 @@ export const ModelMetadata = ({ label="Analogue (optional)" options={data.data} optionLabel={(option) => option.name} + selectedOptions={metadata?.analogue} multiple onOptionsChange={(e: AutocompleteChanges) => setMetadata({ ...metadata, analogue: e.selectedItems }) @@ -95,6 +105,7 @@ export const ModelMetadata = ({ ) => setMetadata({ ...metadata, zone: e.selectedItems }) } diff --git a/src/pages/Browse/Browse.tsx b/src/pages/Browse/Browse.tsx index 9001e09f..d95724d6 100644 --- a/src/pages/Browse/Browse.tsx +++ b/src/pages/Browse/Browse.tsx @@ -9,7 +9,9 @@ import { JobsService, } from '../../api/generated'; import { Table } from '../../components/Table'; -import { AddModelDialog } from '../../features/AddModel/AddModelDialog/AddModelDialog'; +import MetadataProps, { + AddModelDialog, +} from '../../features/AddModel/AddModelDialog/AddModelDialog'; import * as Styled from './Browse.styled'; enum UploadProcess { @@ -23,12 +25,6 @@ type MutationContract = { file: Blob; }; -const ModelBody: CreateAnalogueModelCommand = { - name: 'Model test', - description: 'New test of the model', - sourceType: 'ResQML', -}; - export const Browse = () => { const createModel = useMutation({ mutationFn: AnalogueModelsService.postApiAnalogueModels, @@ -60,8 +56,13 @@ export const Browse = () => { setAddModelDialog(!isAddModelDialog); } - async function uploadModel(file: File) { + async function uploadModel(file: File, metadata: Partial) { setUploadStatus(UploadProcess.STARTED); + const ModelBody: CreateAnalogueModelCommand = { + name: metadata.name, + description: metadata.description, + sourceType: 'ResQML', + }; const modelUpload = await createModel.mutateAsync(ModelBody); From c0260f247900c1b7b4aac7440df6140c8764c39d Mon Sep 17 00:00:00 2001 From: mheggelund Date: Thu, 19 Oct 2023 14:07:46 +0200 Subject: [PATCH 2/3] chore: Add selected options AddModel and AddCase Autocompletes --- .../ComputeVariogram/CaseCard/CaseCard.tsx | 2 +- .../GrainSizeSelect/GrainSizeSelect.tsx | 15 +++++++++------ .../ModelSelect/ModelSelect.tsx | 1 + .../ParameterSelect/ParameterSelect.tsx | 1 + 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/features/Compute/ComputeVariogram/CaseCard/CaseCard.tsx b/src/features/Compute/ComputeVariogram/CaseCard/CaseCard.tsx index e6d6d714..3bd61c5b 100644 --- a/src/features/Compute/ComputeVariogram/CaseCard/CaseCard.tsx +++ b/src/features/Compute/ComputeVariogram/CaseCard/CaseCard.tsx @@ -29,7 +29,7 @@ export const CaseCard = ({ }) => { const [selectedModelArea, setModelArea] = useState(); const [selectedComputeMethod, setComputeMethod] = useState(); - const [selectedGrainSize, setGrainSize] = useState(); + const [selectedGrainSize, setGrainSize] = useState(); const [selectedVariogramModels, setVariogramModels] = useState(); const [selectedParameters, setParameters] = useState(); diff --git a/src/features/Compute/ComputeVariogram/CaseCard/CaseCardParameters/GrainSizeSelect/GrainSizeSelect.tsx b/src/features/Compute/ComputeVariogram/CaseCard/CaseCardParameters/GrainSizeSelect/GrainSizeSelect.tsx index b1d70a9c..a907abe0 100644 --- a/src/features/Compute/ComputeVariogram/CaseCard/CaseCardParameters/GrainSizeSelect/GrainSizeSelect.tsx +++ b/src/features/Compute/ComputeVariogram/CaseCard/CaseCardParameters/GrainSizeSelect/GrainSizeSelect.tsx @@ -16,11 +16,11 @@ export const GrainSizeSelect = ({ label: string; type: string; options: optionTypes[]; - selectedGrainSize?: optionTypes; - setGrainSize: React.Dispatch>; + selectedGrainSize?: optionTypes[]; + setGrainSize: React.Dispatch>; }) => { const onGrainSizeChange = (changes: AutocompleteChanges) => { - setGrainSize && setGrainSize(changes.selectedItems[0]); + setGrainSize && setGrainSize(changes.selectedItems); }; return ( @@ -30,11 +30,14 @@ export const GrainSizeSelect = ({ options={options} optionLabel={(option) => option.name} onOptionsChange={onGrainSizeChange} + selectedOptions={selectedGrainSize} > - {selectedGrainSize && ( - {selectedGrainSize.size} - )} + {/* {selectedGrainSize && ( + {selectedGrainSize[0].size} + )} */} + {selectedGrainSize && + selectedGrainSize.map((s) => {s.name})} ); }; diff --git a/src/features/Compute/ComputeVariogram/CaseCard/CaseCardParameters/ModelSelect/ModelSelect.tsx b/src/features/Compute/ComputeVariogram/CaseCard/CaseCardParameters/ModelSelect/ModelSelect.tsx index 33804e23..d9ad6dba 100644 --- a/src/features/Compute/ComputeVariogram/CaseCard/CaseCardParameters/ModelSelect/ModelSelect.tsx +++ b/src/features/Compute/ComputeVariogram/CaseCard/CaseCardParameters/ModelSelect/ModelSelect.tsx @@ -34,6 +34,7 @@ export const ModelSelect = ({ options={options} optionLabel={(opt) => opt.name} onOptionsChange={onModelChange} + selectedOptions={selectedVariogramModels} multiple > diff --git a/src/features/Compute/ComputeVariogram/CaseCard/CaseCardParameters/ParameterSelect/ParameterSelect.tsx b/src/features/Compute/ComputeVariogram/CaseCard/CaseCardParameters/ParameterSelect/ParameterSelect.tsx index 14dda1f7..b9bf65b2 100644 --- a/src/features/Compute/ComputeVariogram/CaseCard/CaseCardParameters/ParameterSelect/ParameterSelect.tsx +++ b/src/features/Compute/ComputeVariogram/CaseCard/CaseCardParameters/ParameterSelect/ParameterSelect.tsx @@ -32,6 +32,7 @@ export const ParameterSelect = ({ options={options} optionLabel={(option) => option.name} onOptionsChange={onParameterChange} + selectedOptions={selectedParameters} multiple > {selectedParameters && From cf218010d355dbdd72a6cd78522965af1209c7db Mon Sep 17 00:00:00 2001 From: mheggelund Date: Thu, 19 Oct 2023 14:08:13 +0200 Subject: [PATCH 3/3] chore: Add navigate button to each row in model. Removed hardcoded button in browse file. --- src/components/Table.tsx | 25 +++++++++++++++++++++++-- src/pages/Browse/Browse.tsx | 3 --- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/components/Table.tsx b/src/components/Table.tsx index 8735d8aa..96508401 100644 --- a/src/components/Table.tsx +++ b/src/components/Table.tsx @@ -1,15 +1,21 @@ -import { Chip } from '@equinor/eds-core-react'; +/* eslint-disable max-lines-per-function */ +import { Button, Chip } from '@equinor/eds-core-react'; import { EdsDataGrid } from '@equinor/eds-data-grid-react'; -import * as Styled from './Table.styled'; import { useQuery } from '@tanstack/react-query'; +import { useNavigate } from 'react-router-dom'; import { AnalogueModelsService } from '../api/generated'; +import * as Styled from './Table.styled'; export const Table = () => { const { isLoading, data } = useQuery({ queryKey: ['analogue-models'], queryFn: () => AnalogueModelsService.getApiAnalogueModels(), }); + + const navigate = useNavigate(); + if (isLoading || !data?.success) return

Loading...

; + return ( { header: 'Status', id: 'isProcessed', }, + + { + accessorKey: 'navigate', + cell: ({ row }) => ( + + ), + header: '', + id: 'navigate', + }, ]} /> diff --git a/src/pages/Browse/Browse.tsx b/src/pages/Browse/Browse.tsx index d95724d6..1fb476aa 100644 --- a/src/pages/Browse/Browse.tsx +++ b/src/pages/Browse/Browse.tsx @@ -98,9 +98,6 @@ export const Browse = () => { Browse all models
-