Skip to content

Commit

Permalink
feat: Add run compute cahnnel
Browse files Browse the repository at this point in the history
  • Loading branch information
mheggelund committed Nov 8, 2023
1 parent 63ada81 commit 167ce5b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 18 deletions.
19 changes: 4 additions & 15 deletions src/features/Compute/ComputeVariogram/CaseCard/CaseCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ export default interface optionTypes {
export const CaseCard = ({
name,
id,
removeCase,
caseType,
removeCase,
runCase,
}: {
name: string;
id: string;
removeCase: (id: string) => void;
caseType: string;
removeCase: (id: string) => void;
runCase: () => void;
}) => {
const [selectedModelArea, setModelArea] = useState<optionTypes>();
const [selectedComputeMethod, setComputeMethod] = useState<optionTypes>();
Expand Down Expand Up @@ -70,19 +72,6 @@ export const CaseCard = ({
];
const objectComputeMethods: optionTypes[] = [{ id: 15, name: 'Channel' }];

const runCase = () => {
// eslint-disable-next-line no-console
console.log(selectedModelArea);
// eslint-disable-next-line no-console
console.log(selectedComputeMethod);
// eslint-disable-next-line no-console
console.log(selectedGrainSize);
// eslint-disable-next-line no-console
console.log(selectedVariogramModels);
// eslint-disable-next-line no-console
console.log(selectedParameters);
};

return (
<CaseCardComponent title={name}>
<Styled.Case>
Expand Down
25 changes: 24 additions & 1 deletion src/pages/ModelPages/Compute/ComputeObject/ComputeObject.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { Typography } from '@equinor/eds-core-react';
import { useMutation } from '@tanstack/react-query';
import { useState } from 'react';
import { useParams } from 'react-router-dom';
import { EstimateChannelCommand } from '../../../../api/generated/models/EstimateChannelCommand';
import { JobsService } from '../../../../api/generated/services/JobsService';
import { CaseCard } from '../../../../features/Compute/ComputeVariogram/CaseCard/CaseCard';
import { ComputeCaseInfoActions } from '../../../../features/Compute/ComputeVariogram/ComputeCaseInfoActions/ComputeCaseInfoActions';
import { CaseInfoTyoe, Casetype } from '../ComputeVariogram/ComputeVariogram';
Expand All @@ -9,6 +13,12 @@ export const ComputeObject = () => {
const [cases, setCases] = useState<Casetype[]>([
{ id: '1', name: 'Variogram Case 1' },
]);
const { modelId } = useParams<{ modelId: string }>();

const computeObject = useMutation({
mutationFn: JobsService.postApiJobsComputeChannelEstimations,
});

const ObjectCaseInfo: CaseInfoTyoe = {
title: 'Object cases',
info: 'You can add multiple cases for the different areas in your model.',
Expand All @@ -29,6 +39,18 @@ export const ComputeObject = () => {
setCases(newCaseList);
};

const runComputeObject = async () => {
if (!modelId) return;
const requestBody: EstimateChannelCommand = {
modelId: modelId,
};

const runCompute = await computeObject.mutateAsync(requestBody);

console.log(runCompute);
console.log(computeObject);
};

return (
<Styled.Case>
<ComputeCaseInfoActions addCase={addCase} caseInfo={ObjectCaseInfo} />
Expand All @@ -38,8 +60,9 @@ export const ComputeObject = () => {
key={c.id}
id={c.id}
name={c.name}
removeCase={removeCase}
caseType={'object'}
removeCase={removeCase}
runCase={runComputeObject}
/>
))
) : (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Typography } from '@equinor/eds-core-react';
import { useState } from 'react';

import { CaseCard } from '../../../../features/Compute/ComputeVariogram/CaseCard/CaseCard';
import { ComputeCaseInfoActions } from '../../../../features/Compute/ComputeVariogram/ComputeCaseInfoActions/ComputeCaseInfoActions';
import * as Styled from './ComputeVariogram.styled';
Expand All @@ -16,6 +15,7 @@ export interface CaseInfoTyoe {
addText: string;
runText: string;
}

export const ComputeVariogram = () => {
const [cases, setCases] = useState<Casetype[]>([
{ id: '1', name: 'Variogram Case 1' },
Expand All @@ -41,6 +41,10 @@ export const ComputeVariogram = () => {
setCases(newCaseList);
};

const runComputeVariogram = () => {
console.log('variogram run');
};

return (
<Styled.Case>
<ComputeCaseInfoActions addCase={addCase} caseInfo={variogramCaseInfo} />
Expand All @@ -50,8 +54,9 @@ export const ComputeVariogram = () => {
key={c.id}
id={c.id}
name={c.name}
removeCase={removeCase}
caseType={'variogram'}
removeCase={removeCase}
runCase={runComputeVariogram}
/>
))
) : (
Expand Down

0 comments on commit 167ce5b

Please sign in to comment.