Skip to content

Commit

Permalink
Merge branch 'main' into refactor/sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
mheggelund authored Feb 8, 2024
2 parents 4d948b1 + 79daac1 commit cfec431
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 29 deletions.
1 change: 0 additions & 1 deletion src/api/generated/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export type { ConvertAnalogueModelCommand } from './models/ConvertAnalogueModelC
export type { Coordinate } from './models/Coordinate';
export type { CoordinateDto } from './models/CoordinateDto';
export type { CoordinateEqualityComparer } from './models/CoordinateEqualityComparer';
export type { CoordinateM } from './models/CoordinateM';
export type { CoordinateSequence } from './models/CoordinateSequence';
export type { CoordinateSequenceFactory } from './models/CoordinateSequenceFactory';
export type { CreateAnalogueCommand } from './models/CreateAnalogueCommand';
Expand Down
16 changes: 0 additions & 16 deletions src/api/generated/models/CoordinateM.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/api/generated/models/GetChannelResultsDto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import type { ChannelEstimationResultDto } from './ChannelEstimationResultDto';
import type { ChannelHeightDto } from './ChannelHeightDto';
import type { ComputeType } from './ComputeType';
import type { CoordinateM } from './CoordinateM';
import type { CoordinateDto } from './CoordinateDto';
import type { GetChannelResultsFileDto } from './GetChannelResultsFileDto';

export type GetChannelResultsDto = {
Expand All @@ -18,6 +18,6 @@ export type GetChannelResultsDto = {
channelWidth?: ChannelEstimationResultDto;
segmentHeight?: ChannelEstimationResultDto;
channelHeight?: ChannelHeightDto;
box?: Array<CoordinateM> | null;
box?: Array<CoordinateDto> | null;
};

2 changes: 1 addition & 1 deletion src/api/generated/models/GetChannelResultsFileDto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/* eslint-disable */

export type GetChannelResultsFileDto = {
name?: string | null;
fileName?: string | null;
channelResultFileId?: string | null;
};

4 changes: 2 additions & 2 deletions src/api/generated/models/GetVariogramResultsDto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* tslint:disable */
/* eslint-disable */

import type { CoordinateM } from './CoordinateM';
import type { CoordinateDto } from './CoordinateDto';
import type { VariogramResultFile } from './VariogramResultFile';

export type GetVariogramResultsDto = {
Expand All @@ -21,6 +21,6 @@ export type GetVariogramResultsDto = {
archelFilter?: string | null;
indicator?: string | null;
attribute?: string | null;
box?: Array<CoordinateM> | null;
box?: Array<CoordinateDto> | null;
};

40 changes: 33 additions & 7 deletions src/pages/ModelPages/Compute/ComputeVariogram/ComputeVariogram.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
/* eslint-disable max-lines-per-function */
import { Button, Icon, Snackbar, Tooltip } from '@equinor/eds-core-react';
import { add as ADD, play as PLAY } from '@equinor/eds-icons';
import { useMutation } from '@tanstack/react-query';
import { useState } from 'react';
import { useParams } from 'react-router-dom';
import {
EstimateVariogramCommand,
JobsService,
} from '../../../../api/generated';
import { queryClient } from '../../../../auth/queryClient';
import { CaseGroup } from '../../../../features/Compute/CaseGroup/CaseGroup';
import { ComputeHeader } from '../../../../features/Compute/ComputeHeader/ComputeHeader';
import { useFetchCases } from '../../../../hooks/useFetchCases';
Expand All @@ -27,6 +34,7 @@ export const ComputeVariogram = () => {
const [showAlert, setAlert] = useState<string>();
const [triggerAddCase, setTriggerAddCase] = useState<string>();
const [localCaseList, setLocalCaseList] = useState<Array<string>>([]);
const { modelId } = useParams<{ modelId: string }>();

const updateLocalCaseList = (type: string, add: boolean) => {
if (add) {
Expand Down Expand Up @@ -61,6 +69,27 @@ export const ComputeVariogram = () => {
setTriggerAddCase(type);
};

const computeVariogram = useMutation({
mutationFn: JobsService.postApiJobsComputeVariogramEstimations,
onSuccess: () => {
queryClient.refetchQueries({ queryKey: ['model-cases'] });
},
});

const runComputeVariogram = async (computeCaseId: string) => {
if (!modelId) return;
const requestBody: EstimateVariogramCommand = {
modelId: modelId,
computeCaseId: computeCaseId,
};

const res = await computeVariogram.mutateAsync(requestBody);

if (res.success) {
setAlertMessage('Started computing case');
}
};

return (
<>
<Styled.Case>
Expand Down Expand Up @@ -107,7 +136,7 @@ export const ComputeVariogram = () => {
<Button
variant="outlined"
// eslint-disable-next-line no-console
onClick={() => console.log('Running all')}
onClick={() => runComputeVariogram}
disabled
>
<Icon data={PLAY} size={18}></Icon>
Expand All @@ -125,8 +154,7 @@ export const ComputeVariogram = () => {
triggerAddCase={triggerAddCase}
setAlertMessage={setAlertMessage}
updateLocalCaseList={updateLocalCaseList}
// eslint-disable-next-line no-console
runCase={(id: string) => console.log('Running variogram case .... ')}
runCase={runComputeVariogram}
/>
<CaseGroup
caseList={
Expand All @@ -136,8 +164,7 @@ export const ComputeVariogram = () => {
triggerAddCase={triggerAddCase}
setAlertMessage={setAlertMessage}
updateLocalCaseList={updateLocalCaseList}
// eslint-disable-next-line no-console
runCase={(id: string) => console.log(id)}
runCase={runComputeVariogram}
/>

<CaseGroup
Expand All @@ -150,8 +177,7 @@ export const ComputeVariogram = () => {
triggerAddCase={triggerAddCase}
setAlertMessage={setAlertMessage}
updateLocalCaseList={updateLocalCaseList}
// eslint-disable-next-line no-console
runCase={(id: string) => console.log(id)}
runCase={runComputeVariogram}
/>
</Styled.Case>
<Snackbar
Expand Down

0 comments on commit cfec431

Please sign in to comment.