Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add run compute channel #131

Merged
merged 2 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const CaseCardButtons = ({
}: {
id: string;
removeCase: (id: string) => void;
runCase: () => void;
runCase?: () => void;
}) => {
return (
<Styled.ButtonDiv>
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 Down Expand Up @@ -50,8 +50,8 @@ export const ComputeVariogram = () => {
key={c.id}
id={c.id}
name={c.name}
removeCase={removeCase}
caseType={'variogram'}
removeCase={removeCase}
/>
))
) : (
Expand Down