diff --git a/client/src/IO/UploadDevices/UploadDevicesFieldsDialog.jsx b/client/src/IO/UploadDevices/UploadDevicesFieldsDialog.jsx index 1a4ad54..30165eb 100644 --- a/client/src/IO/UploadDevices/UploadDevicesFieldsDialog.jsx +++ b/client/src/IO/UploadDevices/UploadDevicesFieldsDialog.jsx @@ -3,7 +3,7 @@ import { groupBy } from "lodash"; import { UploadDevicesTypeFieldsMatcher } from "./UploadDevicesTypeFieldsMatcher"; import { useState } from "react"; import { changeDeviceOnTrial } from "./changeDeviceOnTrial"; -import { FIELD_MAPNAME, FIELD_TYPE, FIELD_UNASSIGNED, LOCATION_FIELDS } from "./uploadDefs"; +import { FIELD_MAPNAME, FIELD_NAME, FIELD_TYPE, FIELD_UNASSIGNED, LOCATION_FIELDS } from "./uploadDefs"; export const UploadDevicesFieldsDialog = ({ devicesToUpload, setDevicesToUpload, data, setData, experiment }) => { @@ -54,6 +54,7 @@ export const UploadDevicesFieldsDialog = ({ devicesToUpload, setDevicesToUpload, setAttrMatch={updater => { setAttrMatch(prev => ({ ...(prev || {}), [deviceTypeName]: updater((prev || {})[deviceTypeName]) })); }} + headerFields={[FIELD_TYPE, FIELD_NAME]} /> } diff --git a/client/src/IO/UploadDevices/UploadDevicesTypeFieldsMatcher.tsx b/client/src/IO/UploadDevices/UploadDevicesTypeFieldsMatcher.tsx index 11e866f..bea5e86 100644 --- a/client/src/IO/UploadDevices/UploadDevicesTypeFieldsMatcher.tsx +++ b/client/src/IO/UploadDevices/UploadDevicesTypeFieldsMatcher.tsx @@ -1,7 +1,7 @@ import { Grid, Stack, Typography } from "@mui/material" import { SelectProperty } from "../../Property/SelectProperty"; import { useEffect } from "react"; -import { FIELD_MAPNAME, FIELD_UNASSIGNED, IGNORE_FIELDS, LOCATION_FIELDS } from "./uploadDefs"; +import { FIELD_MAPNAME, FIELD_UNASSIGNED, LOCATION_FIELDS } from "./uploadDefs"; import React from "react"; import { RealMapName } from "../../constants/constants"; @@ -53,14 +53,15 @@ const UploadDevicesTypeFieldsMatcherOne = ({ oneMatch, setOneMatch, attrName, at ) } -export const UploadDevicesTypeFieldsMatcher = ({ devicesDetails, deviceType, attrMatch, setAttrMatch }: { +export const UploadDevicesTypeFieldsMatcher = ({ devicesDetails, deviceType, attrMatch, setAttrMatch, headerFields }: { devicesDetails: { [key: string]: any }[], deviceType: { attributeTypes: { name: string }[] }, attrMatch: { [key: string]: string }, setAttrMatch: (updater: (prev: { [key: string]: string }) => { [key: string]: string }) => void, + headerFields: string[], }) => { const fieldNamesOnDetails = uniq(devicesDetails.flatMap(x => { - return Object.keys(x).filter(f => !IGNORE_FIELDS.includes(f)); + return Object.keys(x).filter(f => !headerFields.includes(f)); })); const attributeTypeNames = deviceType?.attributeTypes?.map(x => x.name) || []; diff --git a/client/src/IO/UploadDevices/uploadDefs.ts b/client/src/IO/UploadDevices/uploadDefs.ts index 7c03416..e01ee5f 100644 --- a/client/src/IO/UploadDevices/uploadDefs.ts +++ b/client/src/IO/UploadDevices/uploadDefs.ts @@ -4,5 +4,4 @@ export const FIELD_NAME = 'name'; export const FIELD_MAPNAME = 'MapName'; export const FIELD_LATITUDE = 'Latitude'; export const FIELD_LONGITUDE = 'Longitude'; -export const IGNORE_FIELDS = [FIELD_TYPE, FIELD_NAME]; export const LOCATION_FIELDS = [FIELD_LATITUDE, FIELD_LONGITUDE, FIELD_MAPNAME];