-
Notifications
You must be signed in to change notification settings - Fork 26
/
performance-aspect-inspect.component.ts
40 lines (34 loc) · 1.4 KB
/
performance-aspect-inspect.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import {Component, EventEmitter, Input, OnChanges, OnInit, Output} from '@angular/core';
import {PerformanceAspect} from "../../../../../models/perfomance-aspect.model";
import {ReplaySubject} from "rxjs";
import {ResponseWithLoadingState} from "../../../../../models/response-with-loading-state.model";
import {SelectableMeasurand} from "../../../../../models/measurand.model";
@Component({
selector: 'osm-performance-aspect-inspect',
templateUrl: './performance-aspect-inspect.component.html',
styleUrls: ['./performance-aspect-inspect.component.scss']
})
export class PerformanceAspectInspectComponent implements OnInit, OnChanges {
@Input() performanceAspectWrapped: ResponseWithLoadingState<PerformanceAspect>;
@Output() onSelect: EventEmitter<PerformanceAspect> = new EventEmitter<PerformanceAspect>();
metric$: ReplaySubject<SelectableMeasurand> = new ReplaySubject<SelectableMeasurand>();
constructor() {
}
ngOnInit() {
if(this.performanceAspectWrapped){
this.updateSelectedMetric();
}
}
ngOnChanges(){
if(this.performanceAspectWrapped){
this.updateSelectedMetric();
}
}
private updateSelectedMetric() {
this.metric$.next(this.performanceAspectWrapped.data.measurand);
}
selectMeasurandForAspect(measurand: SelectableMeasurand) {
this.performanceAspectWrapped.data.measurand = measurand;
this.onSelect.emit(this.performanceAspectWrapped.data);
}
}