New audit info screen changes
[vid.git] / vid-webpack-master / src / app / shared / components / auditInfoModal / auditInfoModal.component.ts
index 95e9825..d8d3c32 100644 (file)
@@ -10,6 +10,11 @@ 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";
+import * as XLSX from 'xlsx';
+import {DatePipe} from "@angular/common";
+import {SpaceToUnderscorePipe} from "../../pipes/spaceToUnderscore/space-to-underscore.pipe";
+import {ResizeEvent} from "angular-resizable-element";
 
 @Component({
   selector: 'audit-info-modal',
@@ -19,11 +24,13 @@ import {AuditInfoModalComponentService} from "./auditInfoModal.component.service
 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') public auditInfoModal: ModalDirective;
-  title: string = 'Service Instantiation Information';
+  @ViewChild('auditInfoModal', {static: false}) public auditInfoModal: ModalDirective;
+  title: string = 'Service Information';
   modelInfoItems: ModelInformationItem[] = [];
   serviceModel: ServiceModel;
   serviceModelName: string;
+  serviceModelId: string;
+  jobId: string;
   vidInfoData: AuditStatus[] = [];
   msoInfoData: AuditStatus[] = [];
   isAlaCarte: boolean;
@@ -32,23 +39,39 @@ export class AuditInfoModalComponent {
   model: any;
   instanceId: string;
   isALaCarteFlagOn: boolean;
+  showMoreAuditInfoLink: boolean;
   type : string = "Service";
   showVidStatus : boolean = true;
   auditInfoModalComponentService : AuditInfoModalComponentService;
+  serviceInstanceName : string;
+  serviceModelVersion : any;
+  exportMSOStatusFeatureEnabled: boolean;
+  dataIsReady : boolean = false;
+  jobDataLocal : any;
   constructor(private _serviceInfoService: ServiceInfoService, private _iframeService : IframeService,
               private _auditInfoModalComponentService : AuditInfoModalComponentService,
+              private _featureFlagsService: FeatureFlagsService,
+              private datePipe: DatePipe,
+              private spacetoUnderscore: SpaceToUnderscorePipe,
               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.exportMSOStatusFeatureEnabled = _featureFlagsService.getFlagState(Features.FLAG_2011_EXPORT_MSO_STATUS);
       this.initializeProperties();
       this.showVidStatus = true;
       if (jobData) {
+        this.jobDataLocal = 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();
+        this.serviceInstanceName = jobData.serviceInstanceName;
+        this.serviceModelVersion = jobData.serviceModelVersion;
       } else {
         _iframeService.removeClassCloseModal(this.parentElementClassName);
         this.auditInfoModal.hide();
@@ -57,6 +80,7 @@ export class AuditInfoModalComponent {
 
     AuditInfoModalComponent.openInstanceAuditInfoModal.subscribe(({instanceId  , type ,  model, instance}) => {
       this.showVidStatus = false;
+      this.showMoreAuditInfoLink = false;
       this.initializeProperties();
       this.setModalTitles(type);
       this.serviceModelName = AuditInfoModalComponentService.getInstanceModelName(model);
@@ -76,6 +100,29 @@ export class AuditInfoModalComponent {
     });
   }
 
+  public style: object = {};
+  validate(event: ResizeEvent): boolean {
+    console.log("event : ", event);
+    if(event.rectangle.width && event.rectangle.height &&
+      ( event.rectangle.width < 800 || event.rectangle.width > 1240)
+    ){
+      return false;
+    } else{
+      return true;
+    }
+  }
+  onResizeEnd(event: ResizeEvent): void {
+    console.log('Element was resized', event);
+    this.style = {
+      position: 'fixed',
+      left: `${event.rectangle.left}px`,
+      top: `${event.rectangle.top}px`,
+      width: `${event.rectangle.width}px`,
+      height: `${event.rectangle.height}px`
+    };
+    console.log("stle : ", this.style);
+  }
+
 
   setModalTitles(type : string) : void{
     this.type = AuditInfoModalComponentService.setModalTitlesType(type) ;
@@ -108,6 +155,20 @@ export class AuditInfoModalComponent {
       });
   }
 
+  exportMsoStatusTable(){
+    let currentTime = new Date();
+    let timestamp = this.datePipe.transform(currentTime, "MMMddyyyy")+'_'
+      +currentTime.getHours()+":"+currentTime.getMinutes()+":"+currentTime.getSeconds()
+    let fileName = this.spacetoUnderscore.transform(this.serviceInstanceName)+'_'+timestamp;
+    let msoStatusTableElement = document.getElementById('service-instantiation-audit-info-mso');
+    const ws: XLSX.WorkSheet = XLSX.utils.table_to_sheet(msoStatusTableElement);
+    const wb: XLSX.WorkBook = XLSX.utils.book_new();
+    XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
+    /* save to file */
+    XLSX.writeFile(wb, fileName+'.csv');
+    this._iframeService.addClassOpenModal(this.parentElementClassName);
+  }
+
   onCancelClick() {
     this._iframeService.removeClassCloseModal(this.parentElementClassName);
     this.initializeProperties();
@@ -118,5 +179,15 @@ export class AuditInfoModalComponent {
   onNavigate(){
     window.open("http://ecompguide.web.att.com:8000/#ecomp_ug/c_ecomp_ops_vid.htmll#r_ecomp_ops_vid_bbglossary", "_blank");
   }
+
+  refreshData(): void {
+    this.dataIsReady = false;
+    this.initAuditInfoData(this.jobDataLocal);
+    this.dataIsReady = true;
+
+  }
+
+  readOnlyRetryUrl = (): string =>
+    `../../serviceModels.htm?more#/servicePlanning/RETRY?serviceModelId=${this.serviceModelId}&jobId=${this.jobId}`
 }