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

fix: updated name mapping for results, added required for ini-file #436

Merged
merged 2 commits into from
Jan 27, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { useEffect, useRef } from 'react';
import { AreaCoordinateType } from '../../../AreaCoordinates/AreaCoordinates';
import { ImageMetadataDto } from '../../../../api/generated';
import { archelFilterMaps } from '../../../../utils/ArchelFilterMapping';

export const ModelImageCanvas = ({
imageData,
Expand Down Expand Up @@ -194,7 +195,9 @@ export const ModelImageCanvas = ({
context.font = '16px Arial';
context.textBaseline = 'middle';
context.fillText(
`${key}`,
`${
archelFilterMaps[key] !== undefined ? archelFilterMaps[key] : key
}`,
legendX + legendBoxSize + 10,
currentY + legendBoxSize / 2,
);
Expand Down
19 changes: 16 additions & 3 deletions src/features/Compute/Components/CaseGroup/CaseRow/CaseRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,23 @@ export const CaseRow = ({
};

const filterSettings = (
setting: ListComputeSettingsModelDto[] | undefined,
method: string,
settings: ListComputeSettingsModelDto[] | undefined,
inputValueType: InputValueType,
) => {
return setting?.filter((value) => value.inputValueType === method);
switch (inputValueType) {
case InputValueType.INDICATOR:
return settings
?.filter((setting) => setting.inputValueType === inputValueType)
.filter((setting) => setting.value !== '0');
case InputValueType.ARCHEL:
return settings
?.filter((setting) => setting.inputValueType === inputValueType)
.filter((setting) => setting.value !== '0');
default:
return settings?.filter(
(setting) => setting.inputValueType === inputValueType,
);
}
};

const indicatorFamilySettings = filterSettings(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ export const validateValues = (
}

if (files && !isEdit) {
if (!files.NC) {
errors.file = 'You must select an NC file to upload';
if (!(files.NC && files.INI)) {
errors.file = 'You must select an NC file and an INI file to upload';
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { IniFileTextField } from './HandleModelComponent.styled';
Icon.add({ error_outlined });

interface AddModelDialogProps {
confirm?: (file: File, iniFile?: File) => Promise<void>;
confirm?: (file: File, iniFile: File) => Promise<void>;
progress?: number;
uploading?: boolean;
isAddUploading?: boolean;
Expand Down Expand Up @@ -103,7 +103,7 @@ export const HandleModelComponent = ({
const finishSubmit = () => {
if (files.NC && confirm && files.INI) {
confirm(files.NC, files.INI);
} else if (files.NC && confirm) confirm(files.NC);
}
cleanupStates();
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { SubRowResult } from '../SubRowResult/SubRowResult';
import * as Styled from './TanStackTable.styled';
import { useIsOwnerOrAdmin } from '../../../../../../../hooks/useIsOwnerOrAdmin';
import { useMutateVariogramResult } from '../../../../../../../hooks/useMutateResults';
import { archelFilterMaps } from '../../../../../../../utils/ArchelFilterMapping';
// import { useMutateVariogramResult } from '../../../../../../../hooks/useMutateResults';

export interface ResultObjectType {
Expand Down Expand Up @@ -363,8 +364,15 @@ export const TanStackTable = ({
qualityY: roundResultString(e.qualityY),
qualityZ: roundResultString(e.qualityZ),
method: method ? method : '',
parameter: parameter,
archelFilter: e.archelFilter ? e.archelFilter : '',
parameter:
archelFilterMaps[parameter] !== undefined
? archelFilterMaps[parameter]
: parameter,
archelFilter: e.archelFilter
? archelFilterMaps[e.archelFilter] !== undefined
? archelFilterMaps[e.archelFilter]
: e.archelFilter
: '',
modelArea: modelArea ? modelArea.name : '',
variogramModel: e.family ? e.family : '',
quality: roundResultString(e.quality),
Expand Down
4 changes: 2 additions & 2 deletions src/pages/AddModel/AddModel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ export const AddModel = () => {
},
});

async function uploadModel(file: File, iniFile?: File) {
if (file === undefined) return;
async function uploadModel(file: File, iniFile: File) {
if (file === undefined && iniFile === undefined) return;
setUploading(true);
setProgress(1);

Expand Down
6 changes: 6 additions & 0 deletions src/utils/ArchelFilterMapping.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const archelFilterMaps: Record<string, string> = {
dtaqua: 'deltatop aqua',
dtair: 'deltatop air',
'diameter<0.25': 'Fine sand (0.250)',
'diameter<0.125': 'Very fine sand (0.125)',
};
Loading