aboutsummaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/drawingBoard/service-planning/component-info/component-info.component.ts
blob: c69ab52e1fd016cd01d64ebf4fba8958bababd3c (plain)
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 {ChangeDetectionStrategy, Component, OnInit} from '@angular/core';
import {ComponentInfoService} from "./component-info.service";
import {ComponentInfoModel, ComponentInfoType} from "./component-info-model";
import {ActivatedRoute} from "@angular/router";


@Component({
  selector: 'component-info',
  templateUrl: './component-info.component.html',
  styleUrls: ['./component-info.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class ComponentInfoComponent implements OnInit {
  componentInfoModel: ComponentInfoModel = null;

  constructor(private _componentInfoService:ComponentInfoService, private route: ActivatedRoute) {}

  ngOnInit() {
    ComponentInfoService.triggerComponentInfoChange.subscribe((input : ComponentInfoModel) => {
        if(input.type === ComponentInfoType.SERVICE){
          this.getServiceInformation();
        }else {
          this.componentInfoModel = input;
        }
      });

    this.getServiceInformation();
  }



  getServiceInformation() : void {
    this.route
      .queryParams
      .subscribe(params => {
        let serviceModelId = params['serviceModelId'];
        this.componentInfoModel = this._componentInfoService.getInfoForService(serviceModelId);
      });
  }
}