aboutsummaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared/components/auditInfoModal/auditInfoModal.component.ts
blob: 3a7f4ecfae7284622f149e8724fdca0102ae4930 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import {Component, ViewChild} from '@angular/core';
import {Subject} from 'rxjs/Subject';
import {ModalDirective} from 'ngx-bootstrap'
import {ModelInformationItem} from '../model-information/model-information.component';
import {ServiceModel} from '../../models/serviceModel';
import {ServiceInfoService} from '../../server/serviceInfo/serviceInfo.service';
import {ServiceInfoModel} from '../../server/serviceInfo/serviceInfo.model';
import {AuditStatus} from '../../server/serviceInfo/AuditStatus.model';
import {IframeService} from "../../utils/iframe.service";
import {NgRedux} from "@angular-redux/store";
import {AppState} from "../../store/reducers";
import {AuditInfoModalComponentService} from "./auditInfoModal.component.service";
import {FeatureFlagsService, Features} from "../../services/featureFlag/feature-flags.service";

@Component({
  selector: 'audit-info-modal',
  templateUrl: './auditInfoModal.component.html',
  styleUrls: ['./auditInfoModal.component.scss']
})
export class AuditInfoModalComponent {
  static openModal: Subject<ServiceInfoModel> = new Subject<ServiceInfoModel>();
  static openInstanceAuditInfoModal: Subject<{instanceId , type, model, instance}> = new Subject<{instanceId , type, model, instance}>();
  @ViewChild('auditInfoModal', {static: false}) public auditInfoModal: ModalDirective;
  title: string = 'Service Instantiation Information';
  modelInfoItems: ModelInformationItem[] = [];
  serviceModel: ServiceModel;
  serviceModelName: string;
  serviceModelId: string;
  jobId: string;
  vidInfoData: AuditStatus[] = [];
  msoInfoData: AuditStatus[] = [];
  isAlaCarte: boolean;
  parentElementClassName = 'content';
  isLoading = true;
  model: any;
  instanceId: string;
  isALaCarteFlagOn: boolean;
  showMoreAuditInfoLink: boolean;
  type : string = "Service";
  showVidStatus : boolean = true;
  auditInfoModalComponentService : AuditInfoModalComponentService;
  constructor(private _serviceInfoService: ServiceInfoService, private _iframeService : IframeService,
              private _auditInfoModalComponentService : AuditInfoModalComponentService,
              private _featureFlagsService: FeatureFlagsService,
              private store: NgRedux<AppState>) {
    this.auditInfoModalComponentService = this._auditInfoModalComponentService;
    AuditInfoModalComponent.openModal.subscribe((jobData: ServiceInfoModel) => {
      this.isALaCarteFlagOn = this.store.getState().global.flags['FLAG_A_LA_CARTE_AUDIT_INFO'];
      this.showMoreAuditInfoLink = _featureFlagsService.getFlagState(Features.FLAG_MORE_AUDIT_INFO_LINK_ON_AUDIT_INFO);
      this.initializeProperties();
      this.showVidStatus = true;
      if (jobData) {
        this.isAlaCarte = jobData.aLaCarte;
        this.openAuditInfoModal(jobData);
        _iframeService.addClassOpenModal(this.parentElementClassName);
        this.serviceModelName = jobData.serviceModelName ? jobData.serviceModelName : '';
        this.serviceModelId = jobData.serviceModelId;
        this.jobId = jobData.jobId;
        this.auditInfoModal.show();
      } else {
        _iframeService.removeClassCloseModal(this.parentElementClassName);
        this.auditInfoModal.hide();
      }
    });

    AuditInfoModalComponent.openInstanceAuditInfoModal.subscribe(({instanceId  , type ,  model, instance}) => {
      this.showVidStatus = false;
      this.showMoreAuditInfoLink = false;
      this.initializeProperties();
      this.setModalTitles(type);
      this.serviceModelName = AuditInfoModalComponentService.getInstanceModelName(model);

      if (instance.isFailed) {
        this._serviceInfoService.getAuditStatusForRetry(instance.trackById).subscribe((res: AuditStatus) => {
          this.msoInfoData = [res];
        });
      }else{
        this._serviceInfoService.getInstanceAuditStatus(instanceId, type).subscribe((res : AuditStatus[]) =>{
          this.msoInfoData = res;
       });
      }
      this.modelInfoItems = this.auditInfoModalComponentService.getModelInfo(model, instance, instanceId);
      _iframeService.addClassOpenModal(this.parentElementClassName);
      this.auditInfoModal.show();
    });
  }


  setModalTitles(type : string) : void{
    this.type = AuditInfoModalComponentService.setModalTitlesType(type) ;
    this.title = AuditInfoModalComponentService.setModalTitle(type);
  }

  initializeProperties() : void {
    this.modelInfoItems = null;
    this.vidInfoData = [];
    this.msoInfoData = [];
    this.isLoading = true;
  }

  openAuditInfoModal(jobData: ServiceInfoModel): void {
    this.modelInfoItems = AuditInfoModalComponentService.createModelInformationItemsJob(jobData);
    this.initAuditInfoData(jobData);
    this.auditInfoModal.onHide.subscribe(()=>{
      this._iframeService.removeClassCloseModal(this.parentElementClassName);
      this.initializeProperties();
    });
    this.auditInfoModal.show();
  }

  initAuditInfoData(jobData: ServiceInfoModel) {
    this._serviceInfoService.getJobAuditStatus(jobData)
      .subscribe((res: AuditStatus[][]) => {
        this.vidInfoData = res[0];
        this.msoInfoData = res[1];
        this.isLoading = false;
      });
  }

  onCancelClick() {
    this._iframeService.removeClassCloseModal(this.parentElementClassName);
    this.initializeProperties();
    this.auditInfoModal.hide();
  }


  onNavigate(){
    window.open("http://ecompguide.web.att.com:8000/#ecomp_ug/c_ecomp_ops_vid.htmll#r_ecomp_ops_vid_bbglossary", "_blank");
  }

  readOnlyRetryUrl = (): string =>
    `../../serviceModels.htm?more#/servicePlanning/RETRY?serviceModelId=${this.serviceModelId}&jobId=${this.jobId}`
}