Skip to content

Commit

Permalink
chore: Variogram result cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
mheggelund committed Feb 13, 2024
1 parent 96a0428 commit ca80270
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 39 deletions.
20 changes: 0 additions & 20 deletions src/components/ImageView/ImageView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,10 @@ export const ImageView = ({
img: string;
altText: string;
}) => {
// function _arrayBufferToBase64(buffer: any) {
// let binary = '';
// const bytes = new Uint8Array(buffer);
// const len = bytes.byteLength;
// for (let i = 0; i < len; i++) {
// binary += String.fromCharCode(bytes[i]);
// }
// return window.btoa(binary);
// }

// const [res, setRes] = useState<string>();

// useEffect(() => {
// const res = _arrayBufferToBase64(img);
// setRes(res);
// }, [img]);
// console.log(res);

return (
<Styled.ImageWrapper>
<img className="image" alt={altText} src={img} />
<Typography variant="h5">{text}</Typography>
</Styled.ImageWrapper>
);
};

// `data:image/png;base64,${img}`
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import { useQuery } from '@tanstack/react-query';
// import { ImageView } from '../../../../../../components/ImageView/ImageView';

import { useMsal } from '@azure/msal-react';
import { GetVariogramResultsVariogramResultFileDto } from '../../../../../../api/generated';
import { useAccessToken } from '../../../../../../hooks/useAccessToken';
import { getVariogramImage } from '../../../../../../api/custom/getImageById';
// import { ImageView } from '../../../../../../components/ImageView/ImageView';
import { GetVariogramResultsVariogramResultFileDto } from '../../../../../../api/generated';
import { ImageView } from '../../../../../../components/ImageView/ImageView';

export const ImageResult = ({
resultFiels,
}: {
resultFiels: GetVariogramResultsVariogramResultFileDto[];
}) => {
const { instance, accounts } = useMsal();
const token = useAccessToken(instance, accounts[0]);
const wantedResultFile = resultFiels.find((x) =>
x.fileName.includes('variogram_slices_'),
);
Expand All @@ -23,16 +17,17 @@ export const ImageResult = ({
: '';

const { data } = useQuery({
queryKey: ['model-cases', imageId],
queryKey: ['case-image', imageId],
queryFn: () => getVariogramImage(imageId),
enabled: !!token,
refetchInterval: 30000,
});

return (
<>
<img src={data ? data : ''} alt="lol" />
{/* <ImageView text="run" img={imageUrl} altText="run"></ImageView> */}
<ImageView
text="Case results"
img={data ? data : ''}
altText="Case results"
></ImageView>
</>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ export const VariogramCaseResult = ({
}: {
resultList: GetVariogramResultsDto[];
}) => {
console.log(resultList);

return (
<>
{resultList.map((item) => (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,43 @@
import { Table } from '@equinor/eds-core-react';
import { GetVariogramResultsDto } from '../../../../../api/generated';
import { useFetchCases } from '../../../../../hooks/useFetchCases';

const NumberOfDecimals = 3;

export const VariogramResultTable = ({
data,
}: {
data: GetVariogramResultsDto;
}) => {
const roundResultString = (value?: number) => {
if (value) {
return value.toFixed(NumberOfDecimals);
}
};
const caseList = useFetchCases();
const resultCase = caseList.data?.data.filter(
(c) => c.computeCaseId === data.computeCaseId,
);

// console.log(data);
// console.log(resultCase && resultCase[0]);

return (
<Table>
<Table.Body>
<Table.Row>
<Table.Cell>Quality factor</Table.Cell>
<Table.Cell>{data.quality}</Table.Cell>
<Table.Cell>{roundResultString(data.quality)}</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>Model area</Table.Cell>
<Table.Cell>--Data--</Table.Cell>
<Table.Cell>{resultCase && resultCase[0].modelArea.name}</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>Compute method</Table.Cell>
<Table.Cell>--Method--</Table.Cell>
<Table.Cell>
{resultCase && resultCase[0].computeMethod.name}
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>Attribute</Table.Cell>
Expand All @@ -31,7 +49,7 @@ export const VariogramResultTable = ({
</Table.Row>
<Table.Row>
<Table.Cell>Sigma</Table.Cell>
<Table.Cell>{data.sigma}</Table.Cell>
<Table.Cell>{roundResultString(data.sigma)}</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
Expand Down

0 comments on commit ca80270

Please sign in to comment.