Skip to content

Commit

Permalink
refactor: Refactor VariogramResult component to match data structure.
Browse files Browse the repository at this point in the history
  • Loading branch information
mheggelund committed Jan 30, 2024
1 parent 6ae1304 commit 3e9f84c
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const CaseResultView = ({
<Styled.CaseResultList>
{caseType === 'Variogram' && (
<VariogramCaseResult
caseList={[]}
resultList={resultList}
img={ResultIMG}
></VariogramCaseResult>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,55 +1,26 @@
import { Table } from '@equinor/eds-core-react';
import { GetResultDto } from '../../../../../api/generated';
import { CaseCardComponent } from '../../../../../components/CaseCardComponent/CaseCardComponent';
import { ImageView } from '../../../../../components/ImageView/ImageView';
import { VariogramResultListType } from '../../../../../pages/ModelPages/Results/VariogramResults/VariogramResults';
import * as Styled from './VariogramCaseResult.styled';
import { VariogramResultTable } from './VariogramResultTable';

export const VariogramCaseResult = ({
caseList,
resultList,
img,
}: {
caseList: VariogramResultListType[];
resultList: GetResultDto[];
img: string;
}) => {
return (
<>
{caseList.map((caseItem) => (
<CaseCardComponent key={caseItem.caseId} title={caseItem.title}>
{caseItem.resultList.map((item) => (
<Styled.CaseResultCard key={item.identifier}>
<ImageView text="run" img={img} altText="run"></ImageView>
<Styled.CaseLeftDiv>
<Table>
<Table.Body>
<Table.Row>
<Table.Cell>Quality factor</Table.Cell>
<Table.Cell>{item.quality}</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>Model area</Table.Cell>
<Table.Cell>{item.modelArea}</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>Compute method</Table.Cell>
<Table.Cell>{item.computeMethod}</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>Attribute</Table.Cell>
<Table.Cell>{item.attribute}</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>Variogram model</Table.Cell>
<Table.Cell>{item.family}</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>Sigma</Table.Cell>
<Table.Cell>{item.sigma}</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
</Styled.CaseLeftDiv>
</Styled.CaseResultCard>
))}
{resultList.map((item) => (
<CaseCardComponent key={item.computeCaseId} title={item.resultType}>
<Styled.CaseResultCard>
<ImageView text="run" img={img} altText="run"></ImageView>
<Styled.CaseLeftDiv>
<VariogramResultTable data={item}></VariogramResultTable>
</Styled.CaseLeftDiv>
</Styled.CaseResultCard>
</CaseCardComponent>
))}
</>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* eslint-disable max-lines-per-function */
import { Table } from '@equinor/eds-core-react';

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');

return (
<Table>
<Table.Body>
<Table.Row>
<Table.Cell>Quality factor</Table.Cell>
<Table.Cell>--Data--</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>Model area</Table.Cell>
<Table.Cell>--Data--</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>Compute method</Table.Cell>
<Table.Cell>--Data--</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>Attribute</Table.Cell>
<Table.Cell>--Data--</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>Variogram model</Table.Cell>
<Table.Cell>--Data--</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>Sigma</Table.Cell>
<Table.Cell>--Data--</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
);
};
19 changes: 0 additions & 19 deletions src/pages/ModelPages/Results/VariogramResults/VariogramResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,6 @@ import { NoResults } from '../../../../features/Results/NoResults/NoResults';
import { useFetchCases } from '../../../../hooks/useFetchCases';
import { useFetchResults } from '../../../../hooks/useFetchResultts';

export interface VariogramResultListType {
caseId: number;
title: string;
resultList: VariogramResultType[];
}

export interface VariogramResultType {
identifier: number;
family: string;
computeMethod: string;
modelArea: string;
attribute: string;
quality: GLfloat;
sigma: GLfloat;
approved: string;
}

export const VariogramResults = () => {
const { data } = useFetchResults();
const cases = useFetchCases();
Expand All @@ -29,8 +12,6 @@ export const VariogramResults = () => {
(res) => res.resultType === 'Variogram',
);

console.log(variogramResults);

return (
<>
{variogramResults !== undefined && variogramResults?.length > 0 ? (
Expand Down

0 comments on commit 3e9f84c

Please sign in to comment.