2020-05-22 09:36:50 +02:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
2020-05-22 12:52:17 +02:00
|
|
|
import {ApiService} from '../api.service';
|
2020-05-22 09:36:50 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-samples',
|
|
|
|
templateUrl: './samples.component.html',
|
|
|
|
styleUrls: ['./samples.component.scss']
|
|
|
|
})
|
2020-05-22 12:52:17 +02:00
|
|
|
export class SamplesComponent implements OnInit { // TODO: implement paging
|
2020-05-22 09:36:50 +02:00
|
|
|
|
2020-05-22 12:52:17 +02:00
|
|
|
materials = {};
|
|
|
|
samples = [];
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
private api: ApiService
|
|
|
|
) { }
|
2020-05-22 09:36:50 +02:00
|
|
|
|
|
|
|
ngOnInit(): void {
|
2020-05-22 12:52:17 +02:00
|
|
|
this.api.get('/materials').subscribe((mData: any) => {
|
|
|
|
this.materials = {};
|
|
|
|
mData.forEach(material => {
|
|
|
|
this.materials[material._id] = material;
|
|
|
|
});
|
|
|
|
console.log(this.materials);
|
|
|
|
this.api.get('/samples').subscribe(sData => {
|
|
|
|
console.log(sData);
|
|
|
|
this.samples = sData as any;
|
|
|
|
this.samples.forEach(sample => {
|
|
|
|
sample.material_number = this.materials[sample.material_id].numbers.find(e => sample.color === e.color).number;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2020-05-22 09:36:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|