Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 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', |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame^] | 10 | styleUrls: ['./component-info.component.scss']//, |
| 11 | // changeDetection: ChangeDetectionStrategy.OnPush |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 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 | } |