blob: d9fa985556af387b622673c9a0fc8bf8e4230227 [file] [log] [blame]
Ittay Stern6f900cc2018-08-29 17:01:32 +03001import {ChangeDetectionStrategy, Component, OnInit} from '@angular/core';
2import {ComponentInfoService} from "./component-info.service";
3import {ComponentInfoModel, ComponentInfoType} from "./component-info-model";
4import {ActivatedRoute} from "@angular/router";
5
6
7@Component({
8 selector: 'component-info',
9 templateUrl: './component-info.component.html',
Ittay Sternf7926712019-07-07 19:23:03 +030010 styleUrls: ['./component-info.component.scss']//,
11 // changeDetection: ChangeDetectionStrategy.OnPush
Ittay Stern6f900cc2018-08-29 17:01:32 +030012})
13export 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}