blob: 95e9825dadffcc92dac3396f4dafd8abd29fe136 [file] [log] [blame]
Ittay Stern6f900cc2018-08-29 17:01:32 +03001import {Component, ViewChild} from '@angular/core';
2import {Subject} from 'rxjs/Subject';
3import {ModalDirective} from 'ngx-bootstrap'
4import {ModelInformationItem} from '../model-information/model-information.component';
5import {ServiceModel} from '../../models/serviceModel';
6import {ServiceInfoService} from '../../server/serviceInfo/serviceInfo.service';
7import {ServiceInfoModel} from '../../server/serviceInfo/serviceInfo.model';
8import {AuditStatus} from '../../server/serviceInfo/AuditStatus.model';
9import {IframeService} from "../../utils/iframe.service";
10import {NgRedux} from "@angular-redux/store";
11import {AppState} from "../../store/reducers";
12import {AuditInfoModalComponentService} from "./auditInfoModal.component.service";
13
14@Component({
15 selector: 'audit-info-modal',
16 templateUrl: './auditInfoModal.component.html',
17 styleUrls: ['./auditInfoModal.component.scss']
18})
19export class AuditInfoModalComponent {
20 static openModal: Subject<ServiceInfoModel> = new Subject<ServiceInfoModel>();
Ittay Sternf7926712019-07-07 19:23:03 +030021 static openInstanceAuditInfoModal: Subject<{instanceId , type, model, instance}> = new Subject<{instanceId , type, model, instance}>();
Ittay Stern6f900cc2018-08-29 17:01:32 +030022 @ViewChild('auditInfoModal') public auditInfoModal: ModalDirective;
23 title: string = 'Service Instantiation Information';
24 modelInfoItems: ModelInformationItem[] = [];
25 serviceModel: ServiceModel;
26 serviceModelName: string;
27 vidInfoData: AuditStatus[] = [];
28 msoInfoData: AuditStatus[] = [];
29 isAlaCarte: boolean;
30 parentElementClassName = 'content';
31 isLoading = true;
32 model: any;
33 instanceId: string;
34 isALaCarteFlagOn: boolean;
35 type : string = "Service";
36 showVidStatus : boolean = true;
37 auditInfoModalComponentService : AuditInfoModalComponentService;
38 constructor(private _serviceInfoService: ServiceInfoService, private _iframeService : IframeService,
39 private _auditInfoModalComponentService : AuditInfoModalComponentService,
40 private store: NgRedux<AppState>) {
41 this.auditInfoModalComponentService = this._auditInfoModalComponentService;
42 AuditInfoModalComponent.openModal.subscribe((jobData: ServiceInfoModel) => {
43 this.isALaCarteFlagOn = this.store.getState().global.flags['FLAG_A_LA_CARTE_AUDIT_INFO'];
44 this.initializeProperties();
45 this.showVidStatus = true;
46 if (jobData) {
47 this.isAlaCarte = jobData.aLaCarte;
48 this.openAuditInfoModal(jobData);
49 _iframeService.addClassOpenModal(this.parentElementClassName);
50 this.serviceModelName = jobData.serviceModelName ? jobData.serviceModelName : '';
51 this.auditInfoModal.show();
52 } else {
53 _iframeService.removeClassCloseModal(this.parentElementClassName);
54 this.auditInfoModal.hide();
55 }
56 });
57
Ittay Sternf7926712019-07-07 19:23:03 +030058 AuditInfoModalComponent.openInstanceAuditInfoModal.subscribe(({instanceId , type , model, instance}) => {
Ittay Stern6f900cc2018-08-29 17:01:32 +030059 this.showVidStatus = false;
60 this.initializeProperties();
61 this.setModalTitles(type);
62 this.serviceModelName = AuditInfoModalComponentService.getInstanceModelName(model);
63
Ittay Sternf7926712019-07-07 19:23:03 +030064 if (instance.isFailed) {
65 this._serviceInfoService.getAuditStatusForRetry(instance.trackById).subscribe((res: AuditStatus) => {
Ittay Stern6f900cc2018-08-29 17:01:32 +030066 this.msoInfoData = [res];
67 });
68 }else{
69 this._serviceInfoService.getInstanceAuditStatus(instanceId, type).subscribe((res : AuditStatus[]) =>{
70 this.msoInfoData = res;
71 });
72 }
73 this.modelInfoItems = this.auditInfoModalComponentService.getModelInfo(model, instance, instanceId);
74 _iframeService.addClassOpenModal(this.parentElementClassName);
75 this.auditInfoModal.show();
76 });
77 }
78
79
80 setModalTitles(type : string) : void{
81 this.type = AuditInfoModalComponentService.setModalTitlesType(type) ;
82 this.title = AuditInfoModalComponentService.setModalTitle(type);
83 }
84
85 initializeProperties() : void {
86 this.modelInfoItems = null;
87 this.vidInfoData = [];
88 this.msoInfoData = [];
89 this.isLoading = true;
90 }
91
92 openAuditInfoModal(jobData: ServiceInfoModel): void {
93 this.modelInfoItems = AuditInfoModalComponentService.createModelInformationItemsJob(jobData);
94 this.initAuditInfoData(jobData);
95 this.auditInfoModal.onHide.subscribe(()=>{
96 this._iframeService.removeClassCloseModal(this.parentElementClassName);
97 this.initializeProperties();
98 });
99 this.auditInfoModal.show();
100 }
101
102 initAuditInfoData(jobData: ServiceInfoModel) {
103 this._serviceInfoService.getJobAuditStatus(jobData)
104 .subscribe((res: AuditStatus[][]) => {
105 this.vidInfoData = res[0];
106 this.msoInfoData = res[1];
107 this.isLoading = false;
108 });
109 }
110
111 onCancelClick() {
112 this._iframeService.removeClassCloseModal(this.parentElementClassName);
113 this.initializeProperties();
114 this.auditInfoModal.hide();
115 }
116
117
118 onNavigate(){
Ittay Sternf7926712019-07-07 19:23:03 +0300119 window.open("http://ecompguide.web.att.com:8000/#ecomp_ug/c_ecomp_ops_vid.htmll#r_ecomp_ops_vid_bbglossary", "_blank");
Ittay Stern6f900cc2018-08-29 17:01:32 +0300120 }
121}
122