cherry picking for lodash
This commit is contained in:
		@@ -1,4 +1,4 @@
 | 
				
			|||||||
pushstate: enabled
 | 
					pushstate: enabled
 | 
				
			||||||
force_https: true
 | 
					force_https: true
 | 
				
			||||||
root: UI
 | 
					root: UI
 | 
				
			||||||
location_include: ../../headers.conf
 | 
					location_include: ../../*.conf
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										9
									
								
								cf_config/nginx.conf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								cf_config/nginx.conf
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,9 @@
 | 
				
			|||||||
 | 
					gzip on;
 | 
				
			||||||
 | 
					gzip_disable "msie6";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					gzip_vary on;
 | 
				
			||||||
 | 
					gzip_proxied any;
 | 
				
			||||||
 | 
					gzip_comp_level 6;
 | 
				
			||||||
 | 
					gzip_buffers 16 8k;
 | 
				
			||||||
 | 
					gzip_http_version 1.1;
 | 
				
			||||||
 | 
					gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
 | 
				
			||||||
@@ -17,8 +17,7 @@ const routes: Routes = [
 | 
				
			|||||||
  {path: 'samples/new', component: SampleComponent, canActivate: [LoginService]},
 | 
					  {path: 'samples/new', component: SampleComponent, canActivate: [LoginService]},
 | 
				
			||||||
  {path: 'samples/edit/:id', component: SampleComponent, canActivate: [LoginService]},
 | 
					  {path: 'samples/edit/:id', component: SampleComponent, canActivate: [LoginService]},
 | 
				
			||||||
  {path: 'templates', component: TemplatesComponent, canActivate: [LoginService]},
 | 
					  {path: 'templates', component: TemplatesComponent, canActivate: [LoginService]},
 | 
				
			||||||
  // {path: 'users', component: UsersComponent, canActivate: [LoginService]},
 | 
					  {path: 'users', component: UsersComponent, canActivate: [LoginService]},
 | 
				
			||||||
  {path: 'users', component: UsersComponent},  // TODO: change
 | 
					 | 
				
			||||||
  {path: 'settings', component: SettingsComponent, canActivate: [LoginService]},
 | 
					  {path: 'settings', component: SettingsComponent, canActivate: [LoginService]},
 | 
				
			||||||
  {path: 'documentation', component: DocumentationComponent},
 | 
					  {path: 'documentation', component: DocumentationComponent},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,18 +3,11 @@ import {LoginService} from './services/login.service';
 | 
				
			|||||||
import {Router} from '@angular/router';
 | 
					import {Router} from '@angular/router';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// TODO: add multiple samples at once
 | 
					// TODO: add multiple samples at once
 | 
				
			||||||
// TODO: guess properties from material name
 | 
					// TODO: validation: DPT: filename
 | 
				
			||||||
// TODO: validation: VZ, Humidity: min/max value, DPT: filename
 | 
					 | 
				
			||||||
// TODO: filter by not completely filled/no measurements
 | 
					// TODO: filter by not completely filled/no measurements
 | 
				
			||||||
// TODO: account
 | 
					// TODO: validation of samples
 | 
				
			||||||
// TODO: admin user handling, template pages, validation of samples
 | 
					 | 
				
			||||||
// TODO: activate filter on start typing
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
// TODO: Build IconComponent free lib version because of CSP
 | 
					 | 
				
			||||||
// TODO: more helmet headers, UI presentatin plan
 | 
					 | 
				
			||||||
// TODO: sort material numbers, filter field measurements
 | 
					 | 
				
			||||||
// TODO: get rid of chart.js (+moment.js) and lodash
 | 
					// TODO: get rid of chart.js (+moment.js) and lodash
 | 
				
			||||||
// TODO: look into CSS/XHR/Anfragen tab of console
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
@Component({
 | 
					@Component({
 | 
				
			||||||
  selector: 'app-root',
 | 
					  selector: 'app-root',
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
import _ from 'lodash';
 | 
					import pick from 'lodash/pick';
 | 
				
			||||||
import {IdModel} from './id.model';
 | 
					import {IdModel} from './id.model';
 | 
				
			||||||
import {BaseModel} from './base.model';
 | 
					import {BaseModel} from './base.model';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -11,6 +11,6 @@ export class MaterialModel extends BaseModel {
 | 
				
			|||||||
  numbers: string[] = [''];
 | 
					  numbers: string[] = [''];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  sendFormat() {
 | 
					  sendFormat() {
 | 
				
			||||||
    return _.pick(this, ['name', 'supplier', 'group', 'numbers', 'properties']);
 | 
					    return pick(this, ['name', 'supplier', 'group', 'numbers', 'properties']);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,5 @@
 | 
				
			|||||||
import _ from 'lodash';
 | 
					import omit from 'lodash/omit';
 | 
				
			||||||
 | 
					import pick from 'lodash/pick';
 | 
				
			||||||
import {IdModel} from './id.model';
 | 
					import {IdModel} from './id.model';
 | 
				
			||||||
import {BaseModel} from './base.model';
 | 
					import {BaseModel} from './base.model';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -23,7 +24,7 @@ export class MeasurementModel extends BaseModel {
 | 
				
			|||||||
    return this;
 | 
					    return this;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  sendFormat(omit = []) {
 | 
					  sendFormat(omitValues = []) {
 | 
				
			||||||
    return _.omit(_.pick(this, ['sample_id', 'measurement_template', 'values']), omit);
 | 
					    return omit(pick(this, ['sample_id', 'measurement_template', 'values']), omitValues);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
import _ from 'lodash';
 | 
					import pick from 'lodash/pick';
 | 
				
			||||||
import {IdModel} from './id.model';
 | 
					import {IdModel} from './id.model';
 | 
				
			||||||
import {MaterialModel} from './material.model';
 | 
					import {MaterialModel} from './material.model';
 | 
				
			||||||
import {MeasurementModel} from './measurement.model';
 | 
					import {MeasurementModel} from './measurement.model';
 | 
				
			||||||
@@ -16,7 +16,11 @@ export class SampleModel extends BaseModel {
 | 
				
			|||||||
  measurements: MeasurementModel[] = [];
 | 
					  measurements: MeasurementModel[] = [];
 | 
				
			||||||
  note_id: IdModel = null;
 | 
					  note_id: IdModel = null;
 | 
				
			||||||
  user_id: IdModel = null;
 | 
					  user_id: IdModel = null;
 | 
				
			||||||
  notes: {comment: string, sample_references: {sample_id: IdModel, relation: string}[], custom_fields: {[prop: string]: string}} = {comment: '', sample_references: [], custom_fields: {}};
 | 
					  notes: {
 | 
				
			||||||
 | 
					    comment: string,
 | 
				
			||||||
 | 
					    sample_references: {sample_id: IdModel, relation: string}[],
 | 
				
			||||||
 | 
					    custom_fields: {[prop: string]: string}
 | 
				
			||||||
 | 
					  } = {comment: '', sample_references: [], custom_fields: {}};
 | 
				
			||||||
  added: Date = null;
 | 
					  added: Date = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  deserialize(input: any): this {
 | 
					  deserialize(input: any): this {
 | 
				
			||||||
@@ -35,6 +39,6 @@ export class SampleModel extends BaseModel {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  sendFormat() {
 | 
					  sendFormat() {
 | 
				
			||||||
    return _.pick(this, ['color', 'type', 'batch', 'condition', 'material_id', 'notes']);
 | 
					    return pick(this, ['color', 'type', 'batch', 'condition', 'material_id', 'notes']);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
import _ from 'lodash';
 | 
					import pick from 'lodash/pick';
 | 
				
			||||||
import {BaseModel} from './base.model';
 | 
					import {BaseModel} from './base.model';
 | 
				
			||||||
import {IdModel} from './id.model';
 | 
					import {IdModel} from './id.model';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -23,6 +23,6 @@ export class UserModel extends BaseModel{
 | 
				
			|||||||
    if (mode === 'admin') {
 | 
					    if (mode === 'admin') {
 | 
				
			||||||
      keys.push('level');
 | 
					      keys.push('level');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return _.pick(this, keys);
 | 
					    return pick(this, keys);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
import { Pipe, PipeTransform } from '@angular/core';
 | 
					import { Pipe, PipeTransform } from '@angular/core';
 | 
				
			||||||
import _ from 'lodash';
 | 
					import omit from 'lodash/omit';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@Pipe({
 | 
					@Pipe({
 | 
				
			||||||
  name: 'object',
 | 
					  name: 'object',
 | 
				
			||||||
@@ -7,8 +7,8 @@ import _ from 'lodash';
 | 
				
			|||||||
})
 | 
					})
 | 
				
			||||||
export class ObjectPipe implements PipeTransform {
 | 
					export class ObjectPipe implements PipeTransform {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  transform(value: object, omit: string[] = []): string {
 | 
					  transform(value: object, omitValue: string[] = []): string {
 | 
				
			||||||
    const res = _.omit(value, omit);
 | 
					    const res = omit(value, omitValue);
 | 
				
			||||||
    return res && Object.keys(res).length ? JSON.stringify(res) : '';
 | 
					    return res && Object.keys(res).length ? JSON.stringify(res) : '';
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,7 +10,7 @@ import {
 | 
				
			|||||||
  TemplateRef
 | 
					  TemplateRef
 | 
				
			||||||
} from '@angular/core';
 | 
					} from '@angular/core';
 | 
				
			||||||
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';
 | 
					import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';
 | 
				
			||||||
import _ from 'lodash';
 | 
					import cloneDeep from 'lodash/cloneDeep';
 | 
				
			||||||
import {ArrayInputHelperService} from './array-input-helper.service';
 | 
					import {ArrayInputHelperService} from './array-input-helper.service';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -87,7 +87,6 @@ export class RbArrayInputComponent implements ControlValueAccessor, OnInit, Afte
 | 
				
			|||||||
        else {
 | 
					        else {
 | 
				
			||||||
          this.values[data.index] = data.value;
 | 
					          this.values[data.index] = data.value;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        console.log(111, this.values);
 | 
					 | 
				
			||||||
        this.updateArray();
 | 
					        this.updateArray();
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
    }, 0);
 | 
					    }, 0);
 | 
				
			||||||
@@ -104,7 +103,7 @@ export class RbArrayInputComponent implements ControlValueAccessor, OnInit, Afte
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        // add element if last all are filled
 | 
					        // add element if last all are filled
 | 
				
			||||||
        else if (this.values.filter(e => e[this.pushPath] !== '').length === this.values.length) {
 | 
					        else if (this.values.filter(e => e[this.pushPath] !== '').length === this.values.length) {
 | 
				
			||||||
          this.values.push(_.cloneDeep(this.pushTemplate));
 | 
					          this.values.push(cloneDeep(this.pushTemplate));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        res = this.values.filter(e => e[this.pushPath] !== '');
 | 
					        res = this.values.filter(e => e[this.pushPath] !== '');
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
@@ -114,7 +113,7 @@ export class RbArrayInputComponent implements ControlValueAccessor, OnInit, Afte
 | 
				
			|||||||
          this.values.pop();
 | 
					          this.values.pop();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else if (this.values.filter(e => e !== '').length === this.values.length) {  // add element if all are is filled
 | 
					        else if (this.values.filter(e => e !== '').length === this.values.length) {  // add element if all are is filled
 | 
				
			||||||
          this.values.push(_.cloneDeep(this.pushTemplate));
 | 
					          this.values.push(cloneDeep(this.pushTemplate));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        res = this.values.filter(e => e !== '');
 | 
					        res = this.values.filter(e => e !== '');
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
@@ -134,7 +133,7 @@ export class RbArrayInputComponent implements ControlValueAccessor, OnInit, Afte
 | 
				
			|||||||
    if (this.values.length === 0 || this.values[0] !== '') {
 | 
					    if (this.values.length === 0 || this.values[0] !== '') {
 | 
				
			||||||
      // add empty last field if pushTemplate is specified
 | 
					      // add empty last field if pushTemplate is specified
 | 
				
			||||||
      if (this.pushTemplate !== null) {
 | 
					      if (this.pushTemplate !== null) {
 | 
				
			||||||
        this.values.push(_.cloneDeep(this.pushTemplate));
 | 
					        this.values.push(cloneDeep(this.pushTemplate));
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
import _ from 'lodash';
 | 
					import cloneDeep from 'lodash/cloneDeep';
 | 
				
			||||||
import strCompare from 'str-compare';
 | 
					import strCompare from 'str-compare';
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
  AfterContentChecked,
 | 
					  AfterContentChecked,
 | 
				
			||||||
@@ -22,7 +22,6 @@ import {ModalService} from '@inst-iot/bosch-angular-ui-components';
 | 
				
			|||||||
import {UserModel} from '../models/user.model';
 | 
					import {UserModel} from '../models/user.model';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// TODO: work on better recognition for file input
 | 
					 | 
				
			||||||
// TODO: only show condition (if not set) and measurements in edit sample dialog at first
 | 
					// TODO: only show condition (if not set) and measurements in edit sample dialog at first
 | 
				
			||||||
// TODO: multiple samples for base data, extend multiple measurements, conditions
 | 
					// TODO: multiple samples for base data, extend multiple measurements, conditions
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -144,7 +143,7 @@ export class SampleComponent implements OnInit, AfterContentChecked {
 | 
				
			|||||||
          const spectrumTemplate = this.measurementTemplates.find(e => e.name === 'spectrum')._id;
 | 
					          const spectrumTemplate = this.measurementTemplates.find(e => e.name === 'spectrum')._id;
 | 
				
			||||||
          let spectrumCounter = 0;
 | 
					          let spectrumCounter = 0;
 | 
				
			||||||
          this.sample.measurements.forEach((measurement, i) => {
 | 
					          this.sample.measurements.forEach((measurement, i) => {
 | 
				
			||||||
            this.charts.push(_.cloneDeep(this.chartInit));
 | 
					            this.charts.push(cloneDeep(this.chartInit));
 | 
				
			||||||
            if (measurement.measurement_template === spectrumTemplate) {
 | 
					            if (measurement.measurement_template === spectrumTemplate) {
 | 
				
			||||||
              setTimeout(() => {
 | 
					              setTimeout(() => {
 | 
				
			||||||
                this.generateChart(measurement.values.dpt, i);
 | 
					                this.generateChart(measurement.values.dpt, i);
 | 
				
			||||||
@@ -313,7 +312,7 @@ export class SampleComponent implements OnInit, AfterContentChecked {
 | 
				
			|||||||
  findMaterial(name) {
 | 
					  findMaterial(name) {
 | 
				
			||||||
    const res = this.materials.find(e => e.name === name);  // search for match
 | 
					    const res = this.materials.find(e => e.name === name);  // search for match
 | 
				
			||||||
    if (res) {
 | 
					    if (res) {
 | 
				
			||||||
      this.material = _.cloneDeep(res);
 | 
					      this.material = cloneDeep(res);
 | 
				
			||||||
      this.sample.material_id = this.material._id;
 | 
					      this.sample.material_id = this.material._id;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else {
 | 
					    else {
 | 
				
			||||||
@@ -371,7 +370,7 @@ export class SampleComponent implements OnInit, AfterContentChecked {
 | 
				
			|||||||
  addMeasurement() {
 | 
					  addMeasurement() {
 | 
				
			||||||
    this.sample.measurements.push(new MeasurementModel(this.measurementTemplates.filter(e => e.name === 'spectrum').reverse()[0]._id));
 | 
					    this.sample.measurements.push(new MeasurementModel(this.measurementTemplates.filter(e => e.name === 'spectrum').reverse()[0]._id));
 | 
				
			||||||
    this.sample.measurements[this.sample.measurements.length - 1].values.device = this.defaultDevice;
 | 
					    this.sample.measurements[this.sample.measurements.length - 1].values.device = this.defaultDevice;
 | 
				
			||||||
    this.charts.push(_.cloneDeep(this.chartInit));
 | 
					    this.charts.push(cloneDeep(this.chartInit));
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  removeMeasurement(index) {
 | 
					  removeMeasurement(index) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,7 +8,7 @@
 | 
				
			|||||||
    margin-bottom: 10px;
 | 
					    margin-bottom: 10px;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  button {
 | 
					  rb-icon-button {
 | 
				
			||||||
    float: right;
 | 
					    float: right;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,8 @@
 | 
				
			|||||||
import {Component, ElementRef, isDevMode, OnInit, ViewChild} from '@angular/core';
 | 
					import {Component, ElementRef, isDevMode, OnInit, ViewChild} from '@angular/core';
 | 
				
			||||||
import {ApiService} from '../services/api.service';
 | 
					import {ApiService} from '../services/api.service';
 | 
				
			||||||
import {AutocompleteService} from '../services/autocomplete.service';
 | 
					import {AutocompleteService} from '../services/autocomplete.service';
 | 
				
			||||||
import _ from 'lodash';
 | 
					import cloneDeep from 'lodash/cloneDeep';
 | 
				
			||||||
 | 
					import pick from 'lodash/pick';
 | 
				
			||||||
import {SampleModel} from '../models/sample.model';
 | 
					import {SampleModel} from '../models/sample.model';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -24,7 +25,6 @@ interface KeyInterface {
 | 
				
			|||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// TODO: check if custom-header.conf works, add headers from helmet https://docs.cloudfoundry.org/buildpacks/staticfile/index.html
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
export class SamplesComponent implements OnInit {
 | 
					export class SamplesComponent implements OnInit {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -214,7 +214,7 @@ export class SamplesComponent implements OnInit {
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    query.push(..._.cloneDeep(this.filters.filters)
 | 
					    query.push(...cloneDeep(this.filters.filters)
 | 
				
			||||||
      .map(e => {
 | 
					      .map(e => {
 | 
				
			||||||
        e.values = e.values.filter(el => el !== '');  // do not include empty values
 | 
					        e.values = e.values.filter(el => el !== '');  // do not include empty values
 | 
				
			||||||
        if (e.field === 'added') {  // correct timezone
 | 
					        if (e.field === 'added') {  // correct timezone
 | 
				
			||||||
@@ -223,7 +223,7 @@ export class SamplesComponent implements OnInit {
 | 
				
			|||||||
        return e;
 | 
					        return e;
 | 
				
			||||||
      })
 | 
					      })
 | 
				
			||||||
      .filter(e => e.active && e.values.length > 0)
 | 
					      .filter(e => e.active && e.values.length > 0)
 | 
				
			||||||
      .map(e => 'filters[]=' + encodeURIComponent(JSON.stringify(_.pick(e, ['mode', 'field', 'values']))))
 | 
					      .map(e => 'filters[]=' + encodeURIComponent(JSON.stringify(pick(e, ['mode', 'field', 'values']))))
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
    if (!options.export) {
 | 
					    if (!options.export) {
 | 
				
			||||||
      additionalTableKeys.forEach(key => {
 | 
					      additionalTableKeys.forEach(key => {
 | 
				
			||||||
@@ -269,7 +269,7 @@ export class SamplesComponent implements OnInit {
 | 
				
			|||||||
        .map(el => decodeURIComponent(el)));
 | 
					        .map(el => decodeURIComponent(el)));
 | 
				
			||||||
    this.activeTemplateKeys.measurements = this.keys.filter(e => e.id.indexOf('measurements.') >= 0 && e.active)
 | 
					    this.activeTemplateKeys.measurements = this.keys.filter(e => e.id.indexOf('measurements.') >= 0 && e.active)
 | 
				
			||||||
      .map(e => e.id.split('.')
 | 
					      .map(e => e.id.split('.')
 | 
				
			||||||
        .map(el => decodeURIComponent(el))); // TODO: glass fiber filter not working
 | 
					        .map(el => decodeURIComponent(el)));
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  calcFieldSelectKeys() {
 | 
					  calcFieldSelectKeys() {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,7 +3,8 @@ import {ApiService} from '../services/api.service';
 | 
				
			|||||||
import {TemplateModel} from '../models/template.model';
 | 
					import {TemplateModel} from '../models/template.model';
 | 
				
			||||||
import {animate, style, transition, trigger} from '@angular/animations';
 | 
					import {animate, style, transition, trigger} from '@angular/animations';
 | 
				
			||||||
import {ValidationService} from '../services/validation.service';
 | 
					import {ValidationService} from '../services/validation.service';
 | 
				
			||||||
import _ from 'lodash';
 | 
					import cloneDeep from 'lodash/cloneDeep';
 | 
				
			||||||
 | 
					import omit from 'lodash/omit';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@Component({
 | 
					@Component({
 | 
				
			||||||
  selector: 'app-templates',
 | 
					  selector: 'app-templates',
 | 
				
			||||||
@@ -62,8 +63,9 @@ export class TemplatesComponent implements OnInit {
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
    Object.keys(this.templateGroups).forEach(id => {
 | 
					    Object.keys(this.templateGroups).forEach(id => {
 | 
				
			||||||
      this.templateGroups[id] = this.templateGroups[id].sort((a, b) => a.version - b.version);
 | 
					      this.templateGroups[id] = this.templateGroups[id].sort((a, b) => a.version - b.version);
 | 
				
			||||||
      this.templateEdit[id] = _.cloneDeep(this.templateGroups[id][this.templateGroups[id].length - 1]);
 | 
					      this.templateEdit[id] = cloneDeep(this.templateGroups[id][this.templateGroups[id].length - 1]);
 | 
				
			||||||
      this.templateEdit[id].parameters = this.templateEdit[id].parameters.map(e => {e.rangeString = JSON.stringify(e.range, null, 2); return e; });
 | 
					      this.templateEdit[id].parameters = this.templateEdit[id].parameters
 | 
				
			||||||
 | 
					        .map(e => {e.rangeString = JSON.stringify(e.range, null, 2); return e; });
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    this.groupsView = Object.values(this.templateGroups)
 | 
					    this.groupsView = Object.values(this.templateGroups)
 | 
				
			||||||
      .map(e => ({
 | 
					      .map(e => ({
 | 
				
			||||||
@@ -77,7 +79,7 @@ export class TemplatesComponent implements OnInit {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  saveTemplate(first_id) {
 | 
					  saveTemplate(first_id) {
 | 
				
			||||||
    const template = _.cloneDeep(this.templateEdit[first_id]);
 | 
					    const template = cloneDeep(this.templateEdit[first_id]);
 | 
				
			||||||
    template.parameters = template.parameters.filter(e => e.name !== '');
 | 
					    template.parameters = template.parameters.filter(e => e.name !== '');
 | 
				
			||||||
    let valid = true;
 | 
					    let valid = true;
 | 
				
			||||||
    valid = valid && this.validate.string(template.name).ok;
 | 
					    valid = valid && this.validate.string(template.name).ok;
 | 
				
			||||||
@@ -90,7 +92,7 @@ export class TemplatesComponent implements OnInit {
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
    if (valid) {
 | 
					    if (valid) {
 | 
				
			||||||
      console.log('valid', template);
 | 
					      console.log('valid', template);
 | 
				
			||||||
      const sendData = {name: template.name, parameters: template.parameters.map(e => _.omit(e, ['rangeString']))};
 | 
					      const sendData = {name: template.name, parameters: template.parameters.map(e => omit(e, ['rangeString']))};
 | 
				
			||||||
      if (first_id === 'null') {
 | 
					      if (first_id === 'null') {
 | 
				
			||||||
        this.api.post<TemplateModel>(`/template/${this.collection}/new`, sendData, data => {
 | 
					        this.api.post<TemplateModel>(`/template/${this.collection}/new`, sendData, data => {
 | 
				
			||||||
          if (data.version > template.version) {  // there were actual changes and a new version was created
 | 
					          if (data.version > template.version) {  // there were actual changes and a new version was created
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user