1 import {Component, ViewChild} from '@angular/core';
2 import {Subject} from 'rxjs/Subject';
3 import {ModalDirective} from 'ngx-bootstrap'
4 import {ModelInformationItem} from '../model-information/model-information.component';
5 import {ServiceModel} from '../../models/serviceModel';
6 import {ServiceInfoService} from '../../server/serviceInfo/serviceInfo.service';
7 import {ServiceInfoModel} from '../../server/serviceInfo/serviceInfo.model';
8 import {AuditStatus} from '../../server/serviceInfo/AuditStatus.model';
9 import {IframeService} from "../../utils/iframe.service";
10 import {NgRedux} from "@angular-redux/store";
11 import {AppState} from "../../store/reducers";
12 import {AuditInfoModalComponentService} from "./auditInfoModal.component.service";
13 import {FeatureFlagsService, Features} from "../../services/featureFlag/feature-flags.service";
14 import * as XLSX from 'xlsx';
15 import {DatePipe} from "@angular/common";
16 import {SpaceToUnderscorePipe} from "../../pipes/spaceToUnderscore/space-to-underscore.pipe";
17 import {ResizeEvent} from "angular-resizable-element";
20 selector: 'audit-info-modal',
21 templateUrl: './auditInfoModal.component.html',
22 styleUrls: ['./auditInfoModal.component.scss']
24 export class AuditInfoModalComponent {
25 static openModal: Subject<ServiceInfoModel> = new Subject<ServiceInfoModel>();
26 static openInstanceAuditInfoModal: Subject<{instanceId , type, model, instance}> = new Subject<{instanceId , type, model, instance}>();
27 @ViewChild('auditInfoModal', {static: false}) public auditInfoModal: ModalDirective;
28 title: string = 'Service Information';
29 modelInfoItems: ModelInformationItem[] = [];
30 serviceModel: ServiceModel;
31 serviceModelName: string;
32 serviceModelId: string;
34 vidInfoData: AuditStatus[] = [];
35 msoInfoData: AuditStatus[] = [];
37 parentElementClassName = 'content';
41 isALaCarteFlagOn: boolean;
42 showMoreAuditInfoLink: boolean;
43 type : string = "Service";
44 showVidStatus : boolean = true;
45 auditInfoModalComponentService : AuditInfoModalComponentService;
46 serviceInstanceName : string;
47 serviceModelVersion : any;
48 exportMSOStatusFeatureEnabled: boolean;
49 dataIsReady : boolean = false;
51 constructor(private _serviceInfoService: ServiceInfoService, private _iframeService : IframeService,
52 private _auditInfoModalComponentService : AuditInfoModalComponentService,
53 private _featureFlagsService: FeatureFlagsService,
54 private datePipe: DatePipe,
55 private spacetoUnderscore: SpaceToUnderscorePipe,
56 private store: NgRedux<AppState>) {
57 this.auditInfoModalComponentService = this._auditInfoModalComponentService;
58 AuditInfoModalComponent.openModal.subscribe((jobData: ServiceInfoModel) => {
59 this.isALaCarteFlagOn = this.store.getState().global.flags['FLAG_A_LA_CARTE_AUDIT_INFO'];
60 this.showMoreAuditInfoLink = _featureFlagsService.getFlagState(Features.FLAG_MORE_AUDIT_INFO_LINK_ON_AUDIT_INFO);
61 this.exportMSOStatusFeatureEnabled = _featureFlagsService.getFlagState(Features.FLAG_2011_EXPORT_MSO_STATUS);
62 this.initializeProperties();
63 this.showVidStatus = true;
65 this.jobDataLocal = jobData;
66 this.isAlaCarte = jobData.aLaCarte;
67 this.openAuditInfoModal(jobData);
68 _iframeService.addClassOpenModal(this.parentElementClassName);
69 this.serviceModelName = jobData.serviceModelName ? jobData.serviceModelName : '';
70 this.serviceModelId = jobData.serviceModelId;
71 this.jobId = jobData.jobId;
72 this.auditInfoModal.show();
73 this.serviceInstanceName = jobData.serviceInstanceName;
74 this.serviceModelVersion = jobData.serviceModelVersion;
76 _iframeService.removeClassCloseModal(this.parentElementClassName);
77 this.auditInfoModal.hide();
81 AuditInfoModalComponent.openInstanceAuditInfoModal.subscribe(({instanceId , type , model, instance}) => {
82 this.showVidStatus = false;
83 this.showMoreAuditInfoLink = false;
84 this.initializeProperties();
85 this.setModalTitles(type);
86 this.serviceModelName = AuditInfoModalComponentService.getInstanceModelName(model);
88 if (instance.isFailed) {
89 this._serviceInfoService.getAuditStatusForRetry(instance.trackById).subscribe((res: AuditStatus) => {
90 this.msoInfoData = [res];
93 this._serviceInfoService.getInstanceAuditStatus(instanceId, type).subscribe((res : AuditStatus[]) =>{
94 this.msoInfoData = res;
97 this.modelInfoItems = this.auditInfoModalComponentService.getModelInfo(model, instance, instanceId);
98 _iframeService.addClassOpenModal(this.parentElementClassName);
99 this.auditInfoModal.show();
103 public style: object = {};
104 validate(event: ResizeEvent): boolean {
105 console.log("event : ", event);
106 if(event.rectangle.width && event.rectangle.height &&
107 ( event.rectangle.width < 800 || event.rectangle.width > 1240)
114 onResizeEnd(event: ResizeEvent): void {
115 console.log('Element was resized', event);
118 left: `${event.rectangle.left}px`,
119 top: `${event.rectangle.top}px`,
120 width: `${event.rectangle.width}px`,
121 height: `${event.rectangle.height}px`
123 console.log("stle : ", this.style);
127 setModalTitles(type : string) : void{
128 this.type = AuditInfoModalComponentService.setModalTitlesType(type) ;
129 this.title = AuditInfoModalComponentService.setModalTitle(type);
132 initializeProperties() : void {
133 this.modelInfoItems = null;
134 this.vidInfoData = [];
135 this.msoInfoData = [];
136 this.isLoading = true;
139 openAuditInfoModal(jobData: ServiceInfoModel): void {
140 this.modelInfoItems = AuditInfoModalComponentService.createModelInformationItemsJob(jobData);
141 this.initAuditInfoData(jobData);
142 this.auditInfoModal.onHide.subscribe(()=>{
143 this._iframeService.removeClassCloseModal(this.parentElementClassName);
144 this.initializeProperties();
146 this.auditInfoModal.show();
149 initAuditInfoData(jobData: ServiceInfoModel) {
150 this._serviceInfoService.getJobAuditStatus(jobData)
151 .subscribe((res: AuditStatus[][]) => {
152 this.vidInfoData = res[0];
153 this.msoInfoData = res[1];
154 this.msoInfoData.sort(this.getSortOrder("startTime"));
155 this.isLoading = false;
159 exportMsoStatusTable(){
160 let currentTime = new Date();
161 let timestamp = this.datePipe.transform(currentTime, "MMMddyyyy")+'_'
162 +currentTime.getHours()+":"+currentTime.getMinutes()+":"+currentTime.getSeconds()
163 let fileName = this.spacetoUnderscore.transform(this.serviceInstanceName)+'_'+timestamp;
164 let msoStatusTableElement = document.getElementById('service-instantiation-audit-info-mso');
165 const ws: XLSX.WorkSheet = XLSX.utils.table_to_sheet(msoStatusTableElement);
166 const wb: XLSX.WorkBook = XLSX.utils.book_new();
167 XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
169 XLSX.writeFile(wb, fileName+'.csv');
170 this._iframeService.addClassOpenModal(this.parentElementClassName);
174 this._iframeService.removeClassCloseModal(this.parentElementClassName);
175 this.initializeProperties();
176 this.auditInfoModal.hide();
181 window.open("http://ecompguide.web.att.com:8000/#ecomp_ug/c_ecomp_ops_vid.htmll#r_ecomp_ops_vid_bbglossary", "_blank");
184 refreshData(): void {
185 this.dataIsReady = false;
186 this.initAuditInfoData(this.jobDataLocal);
187 this.dataIsReady = true;
192 getSortOrder(timestamp) {
193 return (obj1, obj2) =>{
195 let firstObj = obj1[timestamp];
196 let secondObj = obj2[timestamp];
197 return ((secondObj < firstObj) ? -1 : ((secondObj > firstObj) ? 1 : 0));
202 readOnlyRetryUrl = (): string =>
203 `../../serviceModels.htm?more#/servicePlanning/RETRY?serviceModelId=${this.serviceModelId}&jobId=${this.jobId}`