diff --git a/src/features/Compute/CaseGroup/CaseGroup.tsx b/src/features/Compute/CaseGroup/CaseGroup.tsx index 025ac9f2..85349250 100644 --- a/src/features/Compute/CaseGroup/CaseGroup.tsx +++ b/src/features/Compute/CaseGroup/CaseGroup.tsx @@ -114,19 +114,11 @@ export const CaseGroup = ({ ); } }; - const channelSettings = settingsFilter('Object'); - const variogramSettings = settingsFilter('Variogram'); - const variogramFilter = (name: string) => { - if (variogramSettings) { - return variogramSettings[0].allowedMethods.filter( - (item) => item.name === name, - ); - } - }; - const indicatorSettings = variogramFilter('Indicator'); - const NetToGrossSettings = variogramFilter('Net-To-Gross'); - const ContiniousParameterSettings = variogramFilter('ContiniousParameter'); + const channelSettings = settingsFilter('Channel'); + const indicatorSettings = settingsFilter('Indicator'); + const NetToGrossSettings = settingsFilter('Net-To-Gross'); + const ContiniousParameterSettings = settingsFilter('ContiniousParameter'); const filerLocalList = useCallback( (methodType: string) => { @@ -160,9 +152,7 @@ export const CaseGroup = ({ switch (methodType) { case 'Channel': - methodId = - channelSettings && - channelSettings[0].allowedMethods[0].computeMethodId; + methodId = channelSettings && channelSettings[0].computeMethodId; break; case 'Indicator': methodId = indicatorSettings && indicatorSettings[0].computeMethodId; @@ -235,13 +225,11 @@ export const CaseGroup = ({ const saveCase = async ( modelAreaId: string, computeMethodId: string, - computeTypeId: string, inputSettings: CreateComputeCaseInputSettingsForm[], ) => { const caseRequestBody: CreateComputeCaseCommandForm = { modelAreaId: modelAreaId, computeMethodId: computeMethodId, - computeTypeId: computeTypeId, inputSettings: inputSettings, }; if (modelId) { @@ -406,7 +394,6 @@ export const CaseGroup = ({ runCase={runCase} removeLocalCase={removeLocalCase} settingsFilter={settingsFilter} - variogramFilter={variogramFilter} duplicateCase={duplicateCase} /> ))} diff --git a/src/features/Compute/CaseGroup/CaseRow/CaseRow.tsx b/src/features/Compute/CaseGroup/CaseRow/CaseRow.tsx index 9b05d6da..ca1df703 100644 --- a/src/features/Compute/CaseGroup/CaseRow/CaseRow.tsx +++ b/src/features/Compute/CaseGroup/CaseRow/CaseRow.tsx @@ -7,7 +7,6 @@ import { CreateComputeCaseCommandResponse, CreateComputeCaseInputSettingsForm, ListComputeCasesByAnalogueModelIdQueryResponse, - ListComputeSettingsDto, ListComputeSettingsInputDto, ListComputeSettingsInputValueDto, ListComputeSettingsMethodDto, @@ -33,7 +32,6 @@ export const CaseRow = ({ deleteCase, removeLocalCase, settingsFilter, - variogramFilter, duplicateCase, }: { rowCase: ComputeCaseDto; @@ -44,7 +42,6 @@ export const CaseRow = ({ saveCase: ( modelAreaId: string, computeMethodId: string, - computeTypeId: string, inputSettings: CreateComputeCaseInputSettingsForm[], ) => Promise; updateCase?: ( @@ -58,10 +55,7 @@ export const CaseRow = ({ setAlertMessage: (message: string) => void; runCase: (id: string) => void; removeLocalCase: (id: string) => void; - settingsFilter: (name: string) => ListComputeSettingsDto[] | undefined; - variogramFilter?: ( - name: string, - ) => ListComputeSettingsMethodDto[] | undefined; + settingsFilter: (name: string) => ListComputeSettingsMethodDto[] | undefined; duplicateCase?: (id: string) => void; }) => { const [selectedModelArea, setModelArea] = useState(); @@ -80,13 +74,9 @@ export const CaseRow = ({ const { data, isLoading } = useFetchModel(); - const channelSettings = settingsFilter('Object'); - const variogramSettings = settingsFilter('Variogram'); - - const indicatorSettings = variogramFilter && variogramFilter('Indicator'); - const netToGrossSettings = variogramFilter && variogramFilter('Net-To-Gross'); - const continiousParameterSettings = - variogramFilter && variogramFilter('ContiniousParameter'); + const indicatorSettings = settingsFilter('Indicator'); + const netToGrossSettings = settingsFilter('Net-To-Gross'); + const continiousParameterSettings = settingsFilter('ContiniousParameter'); const runRowCase = () => { if (id) runCase(id); @@ -271,12 +261,7 @@ export const CaseRow = ({ // Check if the instance is an Object case and right data/methods is provided // TODO: Seperate into own method, take type as argument. Support all types not just Channel cases - if (saveCase && variogramSettings) { - const computeType: ListComputeSettingsDto = - caseType === 'Object' && channelSettings - ? channelSettings[0] - : variogramSettings[0]; - + if (saveCase) { if ( row[0] !== undefined && selectedModelArea && @@ -302,7 +287,6 @@ export const CaseRow = ({ const res = await saveCase( selectedModelArea[0].modelAreaId, row[0].computeMethod.computeMethodId, - computeType.computeTypeId, inputSettingsList, ); if (res?.success) { @@ -327,7 +311,6 @@ export const CaseRow = ({ const res = await saveCase( '', row[0].computeMethod.computeMethodId, - computeType.computeTypeId, inputSettingsList, ); if (res?.success) { diff --git a/src/features/Results/CaseResult/CaseResultView/CaseResultView.tsx b/src/features/Results/CaseResult/CaseResultView/CaseResultView.tsx index f7944e35..a9b13417 100644 --- a/src/features/Results/CaseResult/CaseResultView/CaseResultView.tsx +++ b/src/features/Results/CaseResult/CaseResultView/CaseResultView.tsx @@ -1,33 +1,52 @@ +/* eslint-disable max-lines-per-function */ import * as Styled from './CaseResultView.styled'; import { Typography } from '@equinor/eds-core-react'; -import { ComputeCaseDto, GetResultDto } from '../../../../api/generated'; +import { + ComputeCaseDto, + GetChannelResultsDto, +} from '../../../../api/generated'; import { ChannelResult } from './ObjectCaseResult/ChannelResult'; import { VariogramCaseResult } from './VariogramCaseResult/VariogramCaseResult'; import ResultIMG from './vargrest_output-0-_variogram_slices_.png'; export const CaseResultView = ({ - resultList, + channelResultList, + variogramResultList, computeCases, }: { - resultList: GetResultDto[]; + channelResultList?: GetChannelResultsDto[]; + variogramResultList?: GetChannelResultsDto[]; computeCases?: ComputeCaseDto[]; }) => { - const caseType = resultList[0].resultType; + const channelType = + channelResultList !== undefined && channelResultList[0].type + ? channelResultList[0].type + : ''; + const variogramType = + variogramResultList !== undefined && variogramResultList[0].type + ? variogramResultList[0].type + : ''; return ( - {caseType} results + + {channelType !== '' + ? channelType + : variogramType !== '' + ? variogramType + : ''}{' '} + results + - {caseType === 'Variogram' && ( + {variogramResultList && ( )} - - {caseType === 'Object' && - resultList.map((obj, index) => ( + {channelResultList && + channelResultList.map((obj, index) => ( - {index < resultList.length - 1 && ( + {index < channelResultList.length - 1 && ( { let modelArea = ''; diff --git a/src/features/Results/CaseResult/CaseResultView/ObjectCaseResult/ChannelResultTable.tsx b/src/features/Results/CaseResult/CaseResultView/ObjectCaseResult/ChannelResultTable.tsx index a411a73e..a232e887 100644 --- a/src/features/Results/CaseResult/CaseResultView/ObjectCaseResult/ChannelResultTable.tsx +++ b/src/features/Results/CaseResult/CaseResultView/ObjectCaseResult/ChannelResultTable.tsx @@ -1,28 +1,22 @@ /* eslint-disable max-lines-per-function */ import { Table } from '@equinor/eds-core-react'; -import { GetResultDto } from '../../../../../api/generated'; +import { GetChannelResultsDto } from '../../../../../api/generated'; import * as Styled from './ChannelResultTable.styled'; const NumberOfDecimals = 2; -export const ChannelResultTable = ({ data }: { data: GetResultDto }) => { - const filterValues = (name: string) => { - return data.resultValues.filter((d) => d.name === name); +export const ChannelResultTable = ({ + data, +}: { + data: GetChannelResultsDto; +}) => { + const roundResultString = (value?: number) => { + if (value) { + return value.toFixed(NumberOfDecimals); + } }; - const roundResultString = (value: string) => { - return parseFloat(value).toFixed(NumberOfDecimals); - }; - - const channelHeightCount = filterValues('channel-height_count'); - const channelHeightMean = filterValues('channel-height_mean'); - const channelHeightSD = filterValues('channel-height_sd'); - - const channelWidthCount = filterValues('channel-width_count'); - const channelWidthMean = filterValues('channel-width_mean'); - const channelWidthSD = filterValues('channel-width_sd'); - return ( @@ -37,22 +31,22 @@ export const ChannelResultTable = ({ data }: { data: GetResultDto }) => { Channel width - {roundResultString(channelWidthMean[0].value)} + {roundResultString(data.channelWidth?.mean)} - {roundResultString(channelWidthSD[0].value)} + {roundResultString(data.channelWidth?.sd)} - {channelWidthCount[0].value} + {data.channelWidth?.count} Channel height - {roundResultString(channelHeightMean[0].value)} + {roundResultString(data.channelHeight?.mean)} - {roundResultString(channelHeightSD[0].value)} + {roundResultString(data.channelHeight?.sd)} - {channelHeightCount[0].value} + {data.channelHeight?.count} diff --git a/src/features/Results/CaseResult/CaseResultView/VariogramCaseResult/VariogramCaseResult.tsx b/src/features/Results/CaseResult/CaseResultView/VariogramCaseResult/VariogramCaseResult.tsx index 7e09fd8b..746b54d4 100644 --- a/src/features/Results/CaseResult/CaseResultView/VariogramCaseResult/VariogramCaseResult.tsx +++ b/src/features/Results/CaseResult/CaseResultView/VariogramCaseResult/VariogramCaseResult.tsx @@ -1,4 +1,4 @@ -import { GetResultDto } from '../../../../../api/generated'; +import { GetVariogramResultsDto } from '../../../../../api/generated'; import { CaseCardComponent } from '../../../../../components/CaseCardComponent/CaseCardComponent'; import { ImageView } from '../../../../../components/ImageView/ImageView'; import * as Styled from './VariogramCaseResult.styled'; @@ -8,13 +8,13 @@ export const VariogramCaseResult = ({ resultList, img, }: { - resultList: GetResultDto[]; + resultList: GetVariogramResultsDto[]; img: string; }) => { return ( <> {resultList.map((item) => ( - + diff --git a/src/features/Results/CaseResult/CaseResultView/VariogramCaseResult/VariogramResultTable.tsx b/src/features/Results/CaseResult/CaseResultView/VariogramCaseResult/VariogramResultTable.tsx index fee64d25..2af3111b 100644 --- a/src/features/Results/CaseResult/CaseResultView/VariogramCaseResult/VariogramResultTable.tsx +++ b/src/features/Results/CaseResult/CaseResultView/VariogramCaseResult/VariogramResultTable.tsx @@ -1,29 +1,17 @@ -/* eslint-disable max-lines-per-function */ import { Table } from '@equinor/eds-core-react'; +import { GetVariogramResultsDto } from '../../../../../api/generated'; -import { GetResultDto } from '../../../../../api/generated'; - -// const NumberOfDecimals = 2; - -export const VariogramResultTable = ({ data }: { data: GetResultDto }) => { - // const filterValues = (name: string) => { - // return data.resultValues.filter((d) => d.name === name); - // }; - - // const roundResultString = (value: string) => { - // return parseFloat(value).toFixed(NumberOfDecimals); - // }; - - // const channelHeightCount = filterValues('channel-height_count'); - // const channelHeightMean = filterValues('channel-height_mean'); - // const channelHeightSD = filterValues('channel-height_sd'); - +export const VariogramResultTable = ({ + data, +}: { + data: GetVariogramResultsDto; +}) => { return ( Quality factor - --Data-- + {data.quality} Model area diff --git a/src/hooks/useFetchResults.ts b/src/hooks/useFetchChannelResults.ts similarity index 65% rename from src/hooks/useFetchResults.ts rename to src/hooks/useFetchChannelResults.ts index 165c01e9..3da68fc5 100644 --- a/src/hooks/useFetchResults.ts +++ b/src/hooks/useFetchChannelResults.ts @@ -1,19 +1,19 @@ import { useQuery } from '@tanstack/react-query'; -import { AnalogueModelsService } from '../api/generated/services/AnalogueModelsService'; +import { ResultsService } from '../api/generated/services/ResultsService'; import { useMsal } from '@azure/msal-react'; import { useParams } from 'react-router-dom'; import { useAccessToken } from './useAccessToken'; -export const useFetchResults = () => { +export const useFetchChannelResults = () => { const { modelId } = useParams(); const { instance, accounts } = useMsal(); const token = useAccessToken(instance, accounts[0]); const query = useQuery({ - queryKey: ['model-results', modelId], + queryKey: ['channel-results', modelId], queryFn: () => - AnalogueModelsService.getApiAnalogueModelsResults(modelId as string), + ResultsService.getApiAnalogueModelsResultsChannel(modelId as string), enabled: !!token, }); diff --git a/src/hooks/useFetchVariogramResults.ts b/src/hooks/useFetchVariogramResults.ts new file mode 100644 index 00000000..0d69a593 --- /dev/null +++ b/src/hooks/useFetchVariogramResults.ts @@ -0,0 +1,21 @@ +import { useQuery } from '@tanstack/react-query'; +import { ResultsService } from '../api/generated/services/ResultsService'; + +import { useMsal } from '@azure/msal-react'; +import { useParams } from 'react-router-dom'; +import { useAccessToken } from './useAccessToken'; + +export const useFetchVariogramResults = () => { + const { modelId } = useParams(); + const { instance, accounts } = useMsal(); + const token = useAccessToken(instance, accounts[0]); + + const query = useQuery({ + queryKey: ['variogram-results', modelId], + queryFn: () => + ResultsService.getApiAnalogueModelsResultsVariogram(modelId as string), + enabled: !!token, + }); + + return query; +}; diff --git a/src/pages/ModelPages/Results/ObjectResult/ObjectResult.tsx b/src/pages/ModelPages/Results/ObjectResult/ObjectResult.tsx index a37218e2..07d6e90c 100644 --- a/src/pages/ModelPages/Results/ObjectResult/ObjectResult.tsx +++ b/src/pages/ModelPages/Results/ObjectResult/ObjectResult.tsx @@ -1,19 +1,18 @@ -/* eslint-disable max-lines-per-function */ import { CaseResultView } from '../../../../features/Results/CaseResult/CaseResultView/CaseResultView'; import { NoResults } from '../../../../features/Results/NoResults/NoResults'; import { useFetchCases } from '../../../../hooks/useFetchCases'; -import { useFetchResults } from '../../../../hooks/useFetchResults'; +import { useFetchChannelResults } from '../../../../hooks/useFetchChannelResults'; export const ObjectResult = () => { const cases = useFetchCases(); - const { data } = useFetchResults(); - const objectResults = data?.filter((res) => res.resultType === 'Object'); + const { data } = useFetchChannelResults(); + const objectResults = data?.data; return ( <> - {objectResults !== undefined && objectResults?.length > 0 ? ( + {objectResults !== undefined && objectResults.length > 0 ? ( ) : ( diff --git a/src/pages/ModelPages/Results/VariogramResults/VariogramResults.tsx b/src/pages/ModelPages/Results/VariogramResults/VariogramResults.tsx index da9f7c96..66ae27f9 100644 --- a/src/pages/ModelPages/Results/VariogramResults/VariogramResults.tsx +++ b/src/pages/ModelPages/Results/VariogramResults/VariogramResults.tsx @@ -1,22 +1,18 @@ -/* eslint-disable max-lines-per-function */ import { CaseResultView } from '../../../../features/Results/CaseResult/CaseResultView/CaseResultView'; import { NoResults } from '../../../../features/Results/NoResults/NoResults'; import { useFetchCases } from '../../../../hooks/useFetchCases'; -import { useFetchResults } from '../../../../hooks/useFetchResults'; +import { useFetchVariogramResults } from '../../../../hooks/useFetchVariogramResults'; export const VariogramResults = () => { - const { data } = useFetchResults(); + const { data } = useFetchVariogramResults(); const cases = useFetchCases(); - - const variogramResults = data?.filter( - (res) => res.resultType === 'Variogram', - ); + const variogramResults = data?.data; return ( <> {variogramResults !== undefined && variogramResults?.length > 0 ? ( ) : (