diff --git a/src/features/Compute/CaseGroup/CaseButtons/CaseButtons.tsx b/src/features/Compute/CaseGroup/CaseButtons/CaseButtons.tsx index 2e2ad8ae..4e4990a5 100644 --- a/src/features/Compute/CaseGroup/CaseButtons/CaseButtons.tsx +++ b/src/features/Compute/CaseGroup/CaseButtons/CaseButtons.tsx @@ -1,3 +1,4 @@ +/* eslint-disable max-lines-per-function */ import { Button, Icon, Tooltip } from '@equinor/eds-core-react'; import { copy as COPY, @@ -5,18 +6,21 @@ import { play as PLAY, save as SAVE, } from '@equinor/eds-icons'; +import { ComputeJobStatus } from '../../../../api/generated'; import * as Styled from './CaseButtons.styled'; export const CaseButtons = ({ caseType, - disableRun, + enableRun, isProcessed, + caseStatus, saveCase, runCase, }: { caseType: string; - disableRun: boolean; + enableRun: boolean; isProcessed?: boolean; + caseStatus: ComputeJobStatus; saveCase: () => void; runCase?: () => void; }) => { @@ -44,19 +48,43 @@ export const CaseButtons = ({ )} - {disableRun ? ( - + {enableRun ? ( + ) : ( - diff --git a/src/features/Compute/CaseGroup/CaseGroup.tsx b/src/features/Compute/CaseGroup/CaseGroup.tsx index 48f6f268..3818f1eb 100644 --- a/src/features/Compute/CaseGroup/CaseGroup.tsx +++ b/src/features/Compute/CaseGroup/CaseGroup.tsx @@ -4,6 +4,7 @@ import { add as ADD, play as PLAY } from '@equinor/eds-icons'; import { useState } from 'react'; import { ComputeCaseDto, + ComputeJobStatus, CreateComputeCaseCommandResponse, CreateComputeCaseInputSettingsForm, } from '../../../api/generated'; @@ -12,14 +13,14 @@ import * as Styled from './CaseGroup.styled'; import { CaseRow } from './CaseRow/CaseRow'; export const CaseGroup = ({ - caseGroup, + caseList, methodName, localCaseList, saveObjectCase, saveCaseAlert, runCase, }: { - caseGroup: ComputeCaseDto[]; + caseList: ComputeCaseDto[]; methodName: string; localCaseList?: ComputeCaseDto[]; saveObjectCase?: ( @@ -50,6 +51,7 @@ export const CaseGroup = ({ name: '', }, inputSettings: [], + jobStatus: ComputeJobStatus.NOT_STARTED, }; if (localObjectCaseList.length < 1) { @@ -104,18 +106,18 @@ export const CaseGroup = ({ 0 ? caseGroup[0].computeCaseId : null} + key={caseList.length > 0 ? caseList[0].computeCaseId : null} > {methodName === 'Channel' ? ( <> - {caseGroup.concat(localObjectCaseList).map((c, index) => ( + {caseList.concat(localObjectCaseList).map((c, index) => ( {localCaseList && - caseGroup + caseList .concat(localCaseList) .map((c, index) => ( { // Checks if Case already exists in the db - const caseExists = caseGroup.filter((c) => c.computeCaseId === id); + const caseExists = caseList.filter((c) => c.computeCaseId === id); if (caseExists.length > 0) { // Handle updates and PUT request // Check if model area has changed // Check if the new settings already exists } else { - const row = caseList.filter((c) => c.computeCaseId === id); + const row = allCasesList.filter((c) => c.computeCaseId === id); // 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 @@ -135,10 +135,10 @@ export const CaseRow = ({ ) { // filters out cases without defined model area, 'Whole model' // Checks if given model area already exists - const checkDuplicateType = caseGroup + const checkDuplicateType = caseList .filter((c) => c.modelArea !== null) .filter( - (ca) => ca.modelArea.name === selectedModelArea[0].modelAreaType, + (cl) => cl.modelArea.name === selectedModelArea[0].modelAreaType, ); if (checkDuplicateType.length === 0) { @@ -160,7 +160,7 @@ export const CaseRow = ({ } else { // Case should have no set model area, is a 'whole model' case // Checks if 'whole model' case already exists - const checkDuplicate = caseGroup.filter((c) => c.modelArea === null); + const checkDuplicate = caseList.filter((c) => c.modelArea === null); if (checkDuplicate.length <= 0) { const res = await saveObjectCase( @@ -185,7 +185,7 @@ export const CaseRow = ({ const selectedRowArea = useCallback( (rowId: string) => { - const rowCase = caseList.filter((c) => c.computeCaseId === rowId); + const rowCase = allCasesList.filter((c) => c.computeCaseId === rowId); // Set default selected area to empty let defaultArea: ModelAreaDto[] = [ @@ -217,7 +217,7 @@ export const CaseRow = ({ } return defaultArea; }, - [areaList, caseList, selectedModelArea], + [areaList, allCasesList, selectedModelArea], ); const modelAreas = data && data.data.modelAreas; @@ -228,10 +228,10 @@ export const CaseRow = ({ setSaved(false); } } - caseList - .filter((c) => !caseGroup.includes(c)) + allCasesList + .filter((c) => !caseList.includes(c)) .forEach((r) => setNotSaved(r)); - }, [caseGroup, caseList, id, saved]); + }, [caseList, allCasesList, id, saved]); return ( @@ -303,10 +303,11 @@ export const CaseRow = ({ )} saveCase(id)} runCase={runRowCase} + caseStatus={rowCase.jobStatus} /> diff --git a/src/pages/ModelPages/Compute/ComputeObject/ComputeObject.tsx b/src/pages/ModelPages/Compute/ComputeObject/ComputeObject.tsx index 6ab7d53a..8c1f9044 100644 --- a/src/pages/ModelPages/Compute/ComputeObject/ComputeObject.tsx +++ b/src/pages/ModelPages/Compute/ComputeObject/ComputeObject.tsx @@ -53,7 +53,7 @@ export const ComputeObject = () => { requestBody, ); }, - onSuccess: (data) => { + onSuccess: () => { queryClient.refetchQueries(); }, }); @@ -113,7 +113,7 @@ export const ComputeObject = () => { 0 ? channel : []} + caseList={channel !== undefined && channel.length > 0 ? channel : []} methodName={ObjectCaseInfo.type} saveObjectCase={saveObjectCase} saveCaseAlert={saveCaseAlert} diff --git a/src/pages/ModelPages/Compute/ComputeVariogram/ComputeVariogram.tsx b/src/pages/ModelPages/Compute/ComputeVariogram/ComputeVariogram.tsx index f7c71d17..6172e976 100644 --- a/src/pages/ModelPages/Compute/ComputeVariogram/ComputeVariogram.tsx +++ b/src/pages/ModelPages/Compute/ComputeVariogram/ComputeVariogram.tsx @@ -8,6 +8,7 @@ import { useParams } from 'react-router-dom'; import { AnalogueModelComputeCasesService, ComputeCaseDto, + ComputeJobStatus, } from '../../../../api/generated'; import { CaseGroup } from '../../../../features/Compute/CaseGroup/CaseGroup'; import { ComputeHeader } from '../../../../features/Compute/ComputeHeader/ComputeHeader'; @@ -97,6 +98,7 @@ export const ComputeVariogram = () => { name: '', }, inputSettings: [], + jobStatus: ComputeJobStatus.NOT_STARTED, }; if (methodName === 'Indicator' && localIndicatorCaseList.length < 1) { @@ -167,7 +169,7 @@ export const ComputeVariogram = () => { 0 ? Indicator : [] } methodName="Indicator" @@ -177,7 +179,7 @@ export const ComputeVariogram = () => { saveCaseAlert={saveCaseAlert} /> 0 ? NetToGross : [] } methodName="Net-to-gross" @@ -188,7 +190,7 @@ export const ComputeVariogram = () => { /> 0 ? ContiniousParameter : []