Add support for data collection parameters across layers

Introduced serialization for `data_collection_parameters` in backend models and processing. Added logic to parse and attach data collection parameters in the frontend. This ensures consistent handling and storage of these parameters throughout the application.
This commit is contained in:
GotthardG
2025-01-08 09:19:23 +01:00
parent 35369fd13c
commit 9b4f8599f3
3 changed files with 60 additions and 4 deletions

View File

@ -247,6 +247,7 @@ const SpreadsheetTable = ({
continue;
}
// Extract values from the appropriate columns
const dewarName = typeof row.data[dewarNameIdx] === 'string' ? row.data[dewarNameIdx].trim() : null;
const puckName = row.data[puckNameIdx] !== undefined && row.data[puckNameIdx] !== null ? String(row.data[puckNameIdx]).trim() : null;
const puckType = typeof row.data[puckTypeIdx] === 'string' ? row.data[puckTypeIdx] : 'Unipuck';
@ -256,6 +257,34 @@ const SpreadsheetTable = ({
const priority = row?.data?.[priorityIdx] ? Number(row.data[priorityIdx]) : null;
const comments = typeof row.data[commentsIdx] === 'string' ? row.data[commentsIdx].trim() : null;
// Create data_collection_parameters object
const dataCollectionParameters = {
directory: row.data[fieldToCol['directory']],
oscillation: row.data[fieldToCol['oscillation']] ? parseFloat(row.data[fieldToCol['oscillation']]) : undefined,
aperture: row.data[fieldToCol['aperture']] ? row.data[fieldToCol['aperture']].trim() : undefined,
exposure: row.data[fieldToCol['exposure']] ? parseFloat(row.data[fieldToCol['exposure']]) : undefined,
totalrange: row.data[fieldToCol['totalrange']] ? parseInt(row.data[fieldToCol['totalrange']], 10) : undefined,
transmission: row.data[fieldToCol['transmission']] ? parseInt(row.data[fieldToCol['transmission']], 10) : undefined,
dose: row.data[fieldToCol['dose']] ? parseFloat(row.data[fieldToCol['dose']]) : undefined,
targetresolution: row.data[fieldToCol['targetresolution']] ? parseFloat(row.data[fieldToCol['targetresolution']]) : undefined,
datacollectiontype: row.data[fieldToCol['datacollectiontype']],
processingpipeline: row.data[fieldToCol['processingpipeline']],
spacegroupnumber: row.data[fieldToCol['spacegroupnumber']] ? parseInt(row.data[fieldToCol['spacegroupnumber']], 10) : undefined,
cellparameters: row.data[fieldToCol['cellparameters']],
rescutkey: row.data[fieldToCol['rescutkey']],
rescutvalue: row.data[fieldToCol['rescutvalue']] ? parseFloat(row.data[fieldToCol['rescutvalue']]) : undefined,
userresolution: row.data[fieldToCol['userresolution']] ? parseFloat(row.data[fieldToCol['userresolution']]) : undefined,
pdbid: row.data[fieldToCol['pdbid']],
autoprocfull: row.data[fieldToCol['autoprocfull']] === true,
procfull: row.data[fieldToCol['procfull']] === true,
adpenabled: row.data[fieldToCol['adpenabled']] === true,
noano: row.data[fieldToCol['noano']] === true,
ffcscampaign: row.data[fieldToCol['ffcscampaign']] === true,
trustedhigh: row.data[fieldToCol['trustedhigh']] ? parseFloat(row.data[fieldToCol['trustedhigh']]) : undefined,
autoprocextraparams: row.data[fieldToCol['autoprocextraparams']],
chiphiangles: row.data[fieldToCol['chiphiangles']] ? parseFloat(row.data[fieldToCol['chiphiangles']]) : undefined,
};
if (dewarName && puckName) {
let dewar;
if (!dewars.has(dewarName)) {
@ -301,7 +330,7 @@ const SpreadsheetTable = ({
position: samplePosition,
priority: priority,
comments: comments,
data_collection_parameters: null,
data_collection_parameters: dataCollectionParameters, // Attach the parameters
results: null // Placeholder for results field
};