From 656795f02cfaf2740ab8c56d5785449faa5689fa Mon Sep 17 00:00:00 2001 From: VLE2FE Date: Tue, 18 Aug 2020 08:10:12 +0200 Subject: [PATCH] fixed spaces in measurement name --- src/routes/sample.ts | 2 ++ src/routes/validate/sample.ts | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/routes/sample.ts b/src/routes/sample.ts index 270389b..7d97c64 100644 --- a/src/routes/sample.ts +++ b/src/routes/sample.ts @@ -28,6 +28,7 @@ router.get('/samples', async (req, res, next) => { const {error, value: filters} = SampleValidate.query(req.query, ['dev', 'admin'].indexOf(req.authDetails.level) >= 0); if (error) return res400(error, res); + console.log(filters.filters); // spectral data and csv not allowed for read/write users if ((filters.fields.find(e => e.indexOf('.' + globals.spectrum.dpt) >= 0) || filters.output !== 'json') && @@ -218,6 +219,7 @@ router.get('/samples', async (req, res, next) => { const measurementFilterFields = _.uniq(sortFilterKeys.filter(e => /measurements\./.test(e)) .map(e => e.split('.')[1])); // filter measurement names and remove duplicates from parameters if (sortFilterKeys.find(e => /measurements\./.test(e))) { // add measurement fields + console.log(measurementFilterFields); const measurementTemplates = await MeasurementTemplateModel.find({name: {$in: measurementFilterFields}}) .lean().exec().catch(err => {next(err);}); if (measurementTemplates instanceof Error) return; diff --git a/src/routes/validate/sample.ts b/src/routes/validate/sample.ts index a204e6c..15db60f 100644 --- a/src/routes/validate/sample.ts +++ b/src/routes/validate/sample.ts @@ -193,13 +193,14 @@ export default class SampleValidate { try { for (let i in data.filters) { // data.filters[i] = JSON.parse(decodeURIComponent(data.filters[i])); - data.filters[i] = JSON.parse(data.filters[i]); + data.filters[i] = JSON.parse(decodeURIComponent(data.filters[i])); + console.log(data.filters[i]); data.filters[i].values = data.filters[i].values.map(e => { // validate filter values if (e === null) { // null values are always allowed return null; } let validator; - let field = data.filters[i].field + let field = data.filters[i].field; if (/material\./.test(field)) { // select right validation model validator = MaterialValidate.outputV().append({ number: Joi.string().max(128).allow(''),