fixed spaces in measurement name
This commit is contained in:
parent
37a5ba1bfd
commit
656795f02c
@ -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);
|
const {error, value: filters} = SampleValidate.query(req.query, ['dev', 'admin'].indexOf(req.authDetails.level) >= 0);
|
||||||
if (error) return res400(error, res);
|
if (error) return res400(error, res);
|
||||||
|
console.log(filters.filters);
|
||||||
|
|
||||||
// spectral data and csv not allowed for read/write users
|
// spectral data and csv not allowed for read/write users
|
||||||
if ((filters.fields.find(e => e.indexOf('.' + globals.spectrum.dpt) >= 0) || filters.output !== 'json') &&
|
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))
|
const measurementFilterFields = _.uniq(sortFilterKeys.filter(e => /measurements\./.test(e))
|
||||||
.map(e => e.split('.')[1])); // filter measurement names and remove duplicates from parameters
|
.map(e => e.split('.')[1])); // filter measurement names and remove duplicates from parameters
|
||||||
if (sortFilterKeys.find(e => /measurements\./.test(e))) { // add measurement fields
|
if (sortFilterKeys.find(e => /measurements\./.test(e))) { // add measurement fields
|
||||||
|
console.log(measurementFilterFields);
|
||||||
const measurementTemplates = await MeasurementTemplateModel.find({name: {$in: measurementFilterFields}})
|
const measurementTemplates = await MeasurementTemplateModel.find({name: {$in: measurementFilterFields}})
|
||||||
.lean().exec().catch(err => {next(err);});
|
.lean().exec().catch(err => {next(err);});
|
||||||
if (measurementTemplates instanceof Error) return;
|
if (measurementTemplates instanceof Error) return;
|
||||||
|
@ -193,13 +193,14 @@ export default class SampleValidate {
|
|||||||
try {
|
try {
|
||||||
for (let i in data.filters) {
|
for (let i in data.filters) {
|
||||||
// data.filters[i] = JSON.parse(decodeURIComponent(data.filters[i]));
|
// 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
|
data.filters[i].values = data.filters[i].values.map(e => { // validate filter values
|
||||||
if (e === null) { // null values are always allowed
|
if (e === null) { // null values are always allowed
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
let validator;
|
let validator;
|
||||||
let field = data.filters[i].field
|
let field = data.filters[i].field;
|
||||||
if (/material\./.test(field)) { // select right validation model
|
if (/material\./.test(field)) { // select right validation model
|
||||||
validator = MaterialValidate.outputV().append({
|
validator = MaterialValidate.outputV().append({
|
||||||
number: Joi.string().max(128).allow(''),
|
number: Joi.string().max(128).allow(''),
|
||||||
|
Reference in New Issue
Block a user