Archived
2

fixed spaces in measurement name

This commit is contained in:
VLE2FE 2020-08-18 08:10:12 +02:00
parent 37a5ba1bfd
commit 656795f02c
2 changed files with 5 additions and 2 deletions

View File

@ -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;

View File

@ -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(''),