Merge from ecomp 718fd196 - Modern UI
[vid.git] / vid-webpack-master / src / app / drawingBoard / service-planning / component-info / component-info.component.ts
1 import {ChangeDetectionStrategy, Component, OnInit} from '@angular/core';
2 import {ComponentInfoService} from "./component-info.service";
3 import {ComponentInfoModel, ComponentInfoType} from "./component-info-model";
4 import {ActivatedRoute} from "@angular/router";
5
6
7 @Component({
8   selector: 'component-info',
9   templateUrl: './component-info.component.html',
10   styleUrls: ['./component-info.component.scss']//,
11   // changeDetection: ChangeDetectionStrategy.OnPush
12 })
13 export class ComponentInfoComponent implements OnInit {
14   componentInfoModel: ComponentInfoModel = null;
15
16   constructor(private _componentInfoService:ComponentInfoService, private route: ActivatedRoute) {}
17
18   ngOnInit() {
19     ComponentInfoService.triggerComponentInfoChange.subscribe((input : ComponentInfoModel) => {
20         if(input.type === ComponentInfoType.SERVICE){
21           this.getServiceInformation();
22         }else {
23           this.componentInfoModel = input;
24         }
25       });
26
27     this.getServiceInformation();
28   }
29
30
31
32   getServiceInformation() : void {
33     this.route
34       .queryParams
35       .subscribe(params => {
36         let serviceModelId = params['serviceModelId'];
37         this.componentInfoModel = this._componentInfoService.getInfoForService(serviceModelId);
38       });
39   }
40 }