diff options
Diffstat (limited to 'ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/report-run/run/run-report/run-report.component.ts')
-rw-r--r-- | ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/report-run/run/run-report/run-report.component.ts | 786 |
1 files changed, 786 insertions, 0 deletions
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/report-run/run/run-report/run-report.component.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/report-run/run/run-report/run-report.component.ts new file mode 100644 index 00000000..54a45226 --- /dev/null +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/report-run/run/run-report/run-report.component.ts @@ -0,0 +1,786 @@ +import { + AfterViewInit, + ChangeDetectionStrategy, + ChangeDetectorRef, + Component, + ElementRef, + HostListener, + Input, + OnChanges, + OnInit, + SimpleChanges, + ViewChild +} from '@angular/core'; +import { MatPaginator } from '@angular/material/paginator'; +import { MatSort } from '@angular/material/sort'; +import { MatTableDataSource } from '@angular/material/table'; +import { ActivatedRoute, Router } from '@angular/router'; +import { HttpClient } from '@angular/common/http'; +import { RunService } from '../run.service'; +import { GridsterConfig, GridsterItem, GridType } from 'angular-gridster2'; +import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser'; +import {environment} from '../../../../environments/environment'; +import {DisplayHtml} from '../../../pages/analytics/Report_List/Report/display-html'; +import {ErrorModalComponent} from '../../../modals/error-modal/error-modal.component'; +import {InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component'; +import { FormControl } from '@angular/forms'; +import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; +import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component'; +import {MatDialog} from '@angular/material'; +import {HttpCacheService} from '../../../shared/services/cache.service'; + +export interface PeriodicElement { + +} + +const ELEMENT_DATA: PeriodicElement[] = [{}]; + +@Component({ + selector: 'app-run-report', + templateUrl: './run-report.component.html', + styleUrls: ['./run-report.component.css'], + changeDetection: ChangeDetectionStrategy.OnPush +}) +export class RunReportComponent implements OnInit, AfterViewInit, OnChanges { + @Input('reportId') inputReportId: string; + @Input('reportMode') reportMode: string; + @Input('queryString') queryString: string; + @Input('isGoBack') isGoBack: string; + @Input('DashboardReportObj') DashboardReportObj: Array<GridsterItem>; + @Input('TriggerFFArr') TriggerFFArr: string[]; + @Input('hitCnt') hitCnt: number; + @Input('runAgain') runAgain: string; + @Input('groupSelectValue') groupSelectValue: string; + @Input('chartType') chartType: string; + @ViewChild('iframe') iframe: ElementRef; + @ViewChild(MatPaginator, {static: false} as any) paginator: MatPaginator; + @ViewChild(MatSort, {static: false} as any) sort: MatSort; + dataSource = new MatTableDataSource<PeriodicElement>(ELEMENT_DATA); + displayedColumns: string[]; + IncomingReportId: string; + displayedColumnsArr: string[]; + displayedRowObj: PeriodicElement[]; + formFieldPresent: boolean; + showSpinner: boolean; + formFieldList: {}[]; + isReady: boolean; + responseFormFieldListLength: number; + NEWdisplayedColumns: string[]; + initCnt: number; + reportName: string; + showDashboardReport: boolean; + checkCnt: number; + options: GridsterConfig; + dashboard: Array<GridsterItem> = []; + openOptionsFlag: boolean; + showMoreVert: boolean; + errorMessage = ''; + stackTrace = ''; + error = false; + environment: any; + initialQueryString: string; + initCounter: number; + runButtonHitCnt: number; + chartRunUrl: string; + url: SafeResourceUrl; + replaceDisplayValue: String; + nodeName: string; + uploadId: string; + ecgi: string; + lac: string; + cid: string; + displayTotal: any[]; + totalRecords: number; + pageSize: number; + download_in_progress: boolean; + commentCtrl = new FormControl(''); + isChartAvailable = false; + timeTaken = '...'; + saveResponseObj: any; + showBackButton = false; + + isDashboardExcelReadyToDownload = false; + + constructor(private _http: HttpClient, + private _route: ActivatedRoute, + private _runService: RunService, + private _router: Router, + private changeDetectorRefs: ChangeDetectorRef, + public sanitizer: DomSanitizer, + public ngbModal: NgbModal, + private httpCacheService: HttpCacheService, + private dialog: MatDialog) { + this.displayedColumnsArr = []; + this.displayedRowObj = []; + this.displayedColumns = []; + this.formFieldList = []; + this.showSpinner = true; + this.isReady = false; + this.NEWdisplayedColumns = []; + this.initCnt = 0; + this.checkCnt = 0; + this.showDashboardReport = false; + this.openOptionsFlag = false; + this.showMoreVert = false; + this.environment = environment; + this.initCounter = 0; + this.runButtonHitCnt = 0; + this.displayTotal = []; + this.totalRecords = 0; + this.pageSize = 0; + this.download_in_progress = false; + this.isGoBack = ''; + this.isDashboardExcelReadyToDownload = false; + } + + @HostListener('click') onClick() { + this.changeDetectorRefs.detectChanges(); + } + + ngOnChanges(changes: SimpleChanges) { + if (this.reportMode !== 'Regular' && this.initCnt > 0 && changes['runAgain']) { + this.isGoBack = ''; + this.showMoreVert = false; + if (changes['queryString']) { + this.queryString = changes['queryString']['currentValue']; + } + if (this.queryString !== this.initialQueryString) { + this.initCnt = 1; + this.showDashboardReport = false; + this.dataSource = new MatTableDataSource<PeriodicElement>(ELEMENT_DATA); + this.displayedColumnsArr = []; + this.displayedRowObj = []; + this.displayedColumns = []; + this.formFieldList = []; + this.showSpinner = true; + this.isReady = false; + this.NEWdisplayedColumns = []; + this.displayTotal = []; + this.isChartAvailable = false; + this.timeTaken = '...'; + const startDate: Date = new Date(); + const startTime = startDate.getTime(); + this._runService.getReportDataWithFormFields(this.queryString, this.inputReportId, this.groupSelectValue) + .subscribe((response) => { + if (response['errormessage']) { + this.openErrorModel(response['errormessage']); + this.showError(); + this.changeDetectorRefs.detectChanges(); + } else { + this.chartRunUrl = environment.baseUrl + 'raptor.htm?action=chart.run&c_master=' + + this.inputReportId + this.queryString + '&refresh=Y&display_content=Y&r_page=0'; + if (this.reportMode !== 'FormField') { + this.postFetchingReportDataFn(response, false, 0); + const endDate: Date = new Date(); + const endTime = endDate.getTime(); + this.showMoreVert = true; + this.showDashboardReport = true; + this.errorMessage = ''; + this.error = false; + } else { + this.postFetchingReportDataFn(response, false, 0); + const endDate: Date = new Date(); + const endTime = endDate.getTime(); + this.showMoreVert = true; + this.errorMessage = ''; + this.error = false; + } + } + }, error => { + this.openErrorModel('Error occurred while running report: ' + this.inputReportId); + this.showError(); + }); + } + } else { + } + if (this.initialQueryString !== this.queryString && this.initCounter > 0 && this.hitCnt !== this.runButtonHitCnt) { + this.runButtonHitCnt = this.hitCnt; + this.initialQueryString = this.queryString; + this.initialProcesses(); + } else { + this.runButtonHitCnt = this.hitCnt; + } + + } + + ngOnInit() { + this.dataSource.paginator = this.paginator; + this.dataSource.sort = this.sort; + this.dataSource.data = this.displayedRowObj; + this.initialProcesses(); + this.errorMessage = ''; + this.error = false; + } + + initialProcesses() { + if (this.DashboardReportObj.length > 0) { + this.dashboard = this.DashboardReportObj; + this.options = { + gridType: GridType.VerticalFixed, + margin: 10, + outerMargin: true, + outerMarginTop: 10, + outerMarginRight: 10, + outerMarginBottom: 5000, + outerMarginLeft: 10, + scrollSensitivity: 10, + scrollSpeed: 20, + fixedColWidth: 400, + fixedRowHeight: 600, + emptyCellDragMaxCols: null, + emptyCellDragMaxRows: null, + ignoreContentClass: 'gridster-item-content', + enableOccupiedCellDrop: true, + ignoreMarginInRow: false, + draggable: { + enabled: true, + }, + resizable: { + enabled: true, + }, + swap: true, + pushItems: true, + disablePushOnDrag: false, + disablePushOnResize: false, + pushDirections: {north: true, east: true, south: true, west: true}, + pushResizeItems: true, + disableWindowResize: true, + disableWarnings: false, + scrollToNewItems: true, + enableDropToAdd: true, + enableEmptyCellDrop: true, + minCols: 2, + minRows: 2, + }; + this._runService.getDashboardReportFormFields(this.inputReportId) + .subscribe((dashboardFormFields) => { + this.changeDetectorRefs.detectChanges(); + this._runService.runDashboardReport(this.inputReportId, this.queryString) + .subscribe((runDashboardReportResp) => { + if (runDashboardReportResp) { + this.isDashboardExcelReadyToDownload = true; + this.changeDetectorRefs.detectChanges(); + } + }); + this.download_in_progress = false; + + }); + + this.showDashboardReport = true; + + } + this.hitCnt = this.runButtonHitCnt; + this.initialQueryString = this.queryString; + this.initCounter++; + } + + ngAfterViewInit() { + this.afterViewInitialProcesses(); + } + + afterViewInitialProcesses() { + if (sessionStorage.length > 0) { + this.showBackButton = true; + } else { + this.showBackButton = false; + } + if (this.DashboardReportObj.length === 0) { + if (this.reportMode === 'Regular' && this.initCnt == 0) { + this.showMoreVert = false; + this.dataSource = new MatTableDataSource<PeriodicElement>(ELEMENT_DATA); + this.displayedColumnsArr = []; + this.displayedRowObj = []; + this.displayedColumns = []; + this.formFieldList = []; + this.showSpinner = true; + this.isReady = false; + this.NEWdisplayedColumns = []; + this.timeTaken = '...'; + const startDate: Date = new Date(); + const startTime = startDate.getTime(); + this._runService.getReportData(this.inputReportId) + .subscribe((response) => { + if (response['errormessage']) { + this.openErrorModel(response['errormessage']); + this.showError(); + this.changeDetectorRefs.detectChanges(); + } else { + this.chartRunUrl = environment.baseUrl + 'raptor.htm?action=chart.run&c_master=' + + this.inputReportId + '&refresh=Y&display_content=Y&r_page=0'; + this.postFetchingReportDataFn(response, false, 0); + const endDate: Date = new Date(); + const endTime = endDate.getTime(); + this.showMoreVert = true; + } + }, error => { + this.openErrorModel('Error occurred while running report: ' + this.inputReportId); + this.showError(); + }); + } else { + this.showMoreVert = false; + this.dataSource = new MatTableDataSource<PeriodicElement>(ELEMENT_DATA); + this.displayedColumnsArr = []; + this.displayedRowObj = []; + this.displayedColumns = []; + this.formFieldList = []; + this.showSpinner = true; + this.isReady = false; + this.NEWdisplayedColumns = []; + this.timeTaken = '...'; + const startDate: Date = new Date(); + const startTime = startDate.getTime(); + if (localStorage.getItem(this.inputReportId)) { + this.chartRunUrl = environment.baseUrl + 'raptor.htm?action=chart.run&c_master=' + + this.inputReportId + this.queryString + '&refresh=Y&display_content=Y&r_page=0'; + this.postFetchingReportDataFn(JSON.parse(localStorage.getItem(this.inputReportId)), false, 0); + this.saveResponseObj = JSON.parse(localStorage.getItem(this.inputReportId)); + const endDate: Date = new Date(); + const endTime = endDate.getTime(); + this.showMoreVert = true; + localStorage.removeItem(this.inputReportId); + this.isGoBack = 'true'; + } else { + this._runService.getReportDataWithFormFields(this.queryString, this.inputReportId, this.groupSelectValue) + .subscribe((response) => { + if (response['errormessage']) { + this.openErrorModel(response['errormessage']); + this.showError(); + this.changeDetectorRefs.detectChanges(); + } else { + this.chartRunUrl = environment.baseUrl + 'raptor.htm?action=chart.run&c_master=' + + this.inputReportId + this.queryString + '&refresh=Y&display_content=Y&r_page=0'; + this.saveResponseObj = response; + this.postFetchingReportDataFn(response, false, 0); + const endDate: Date = new Date(); + const endTime = endDate.getTime(); + this.showMoreVert = true; + } + }, error => { + this.openErrorModel('Error occurred while running report: ' + this.inputReportId); + this.showError(); + }); + } + } + } else { + this.showMoreVert = true; + this.showSpinner = false; + } + this.errorMessage = ''; + this.error = false; + this.initCnt = 1; + } + + showError() { + this.showSpinner = false; + this.isChartAvailable = false; + this.changeDetectorRefs.detectChanges(); + } + + postFetchingReportDataFn(response: any, isPageChange: boolean, pagenum: any) { + this.pageSize = 0; + this.totalRecords = 0; + this.displayedColumnsArr = []; + this.displayedColumns = []; + this.formFieldPresent = false; + this.responseFormFieldListLength = 0; + this.reportName = response['reportName']; + let rdc_cntr = 0; + this.timeTaken = (response['totalRunTime'] / 1000).toString(); + this.displayedColumnsArr.push('RowNum,RowNum'); + while (response['reportDataColumns'][rdc_cntr]) { + const columnTitle = response['reportDataColumns'][rdc_cntr]['columnTitle']; + const columnId = response['reportDataColumns'][rdc_cntr]['colId']; + this.displayedColumnsArr.push(columnTitle + ',' + columnId); + rdc_cntr++; + } + + if (response['chartWizardAvailable'] === true && this.chartType !== 'none') { + this.isChartAvailable = true; + this.iframe.nativeElement.setAttribute('src', this.chartRunUrl); + } + + let totalCnt = 0; + while (response['reportTotalDataRows'][totalCnt]) { + this.displayTotal.push(response['reportTotalDataRows'][totalCnt]); + totalCnt++; + } + + let rdr_cntr = 0; + while (response['reportDataRows'][rdr_cntr]) { + let dca_cntr = 0; + const obj = {}; + const reportDataRows = response['reportDataRows'][rdr_cntr]; + while (this.displayedColumnsArr[dca_cntr]) { + const rowColumnId = this.displayedColumnsArr[dca_cntr].split(',')[1]; + if (reportDataRows[rowColumnId]) { + let drillDownHtml = ''; + let displayValue = ''; + drillDownHtml = reportDataRows[rowColumnId]['drillDownURL']; + displayValue = reportDataRows[rowColumnId]['displayValue']; + if (drillDownHtml !== null && + drillDownHtml.length > 0 && + !displayValue.includes('linkToReport')) { + const value = this.convertToLinkToReport(drillDownHtml); + if (value.length > 0) { + this.replaceDisplayValue = value + ',' + + reportDataRows[rowColumnId]['displayValue']; + } else { + this.replaceDisplayValue = reportDataRows[rowColumnId]['displayValue']; + } + } else { + this.replaceDisplayValue = reportDataRows[rowColumnId]['displayValue']; + } + let displayObj: DisplayHtml = new class implements DisplayHtml { + 'background-color': string; + 'font-family': string; + 'font-size': string; + 'font-style': string; + 'font-weight': string; + 'text-align': string; + 'text-decoration': string; + color: string; + }; + if (reportDataRows[rowColumnId]['displayValueHtml'].includes('setStyle')) { + displayObj = JSON.parse(reportDataRows[rowColumnId]['displayValueHtml']); + } + displayObj['text-align'] = reportDataRows[rowColumnId]['alignment']; + obj['RowNum'] = (pagenum * response['pageSize'] + rdr_cntr + 1) + '|{"text-align":"center"}'; + if (this.replaceDisplayValue.includes('linkToReport') || this.replaceDisplayValue.includes('linkToFeedback') || this.replaceDisplayValue.includes('linkToMail') + || this.replaceDisplayValue.includes('linkToMap')) { + let replaceValArr = new Array(); + if (this.replaceDisplayValue.includes('linkToReport')) { + obj[reportDataRows[rowColumnId]['colId']] = this.replaceDisplayValue.split(',').join('|'); + replaceValArr = obj[reportDataRows[rowColumnId]['colId']].split('|'); + if (replaceValArr.length > 4) { + const dispValue = replaceValArr[3] + ',' + replaceValArr[4]; + obj[reportDataRows[rowColumnId]['colId']] = obj[reportDataRows[rowColumnId]['colId']].replace(replaceValArr[3] + '|' + replaceValArr[4], replaceValArr[3] + ',' + replaceValArr[4])+ '|' + JSON.stringify(displayObj); + } else { + obj[reportDataRows[rowColumnId]['colId']] = this.replaceDisplayValue.split(',').join('|') + + '|' + JSON.stringify(displayObj); + } + } else { + obj[reportDataRows[rowColumnId]['colId']] = this.replaceDisplayValue.split(',').join('|') + + '|' + JSON.stringify(displayObj); + } + } else { + obj[reportDataRows[rowColumnId]['colId']] = this.replaceDisplayValue.split('comment-break-line').join('') + + '|' + JSON.stringify(displayObj); + } + } + dca_cntr++; + } + this.displayedRowObj.push(obj); + rdr_cntr++; + } + this.pageSize = response['pageSize']; + for (let cntr = 0; cntr < this.displayedColumnsArr.length; cntr++) { + const columnArrId = this.displayedColumnsArr[cntr].split(',')[1]; + this.displayedColumns.push(columnArrId); + } + this.totalRecords = 0; + this.totalRecords = response['totalRows']; + this.showSpinner = false; + if (!isPageChange) { + this.paginator.length = this.totalRecords; + this.paginator.pageSize = this.pageSize; + this.paginator.pageIndex = 0; + } + this.dataSource.data = this.displayedRowObj; + this.dataSource.sort = this.sort; + this.changeDetectorRefs.detectChanges(); + } + +linkToReport(reportID: string, queryParameters: string) { + if (!this.httpCacheService.getPreviousId(this.inputReportId)) { + this.httpCacheService.setPreviousId(this.inputReportId, 'parent'); + } + this.httpCacheService.setPreviousId(reportID, this.inputReportId); +/* localStorage.setItem(this.inputReportId, JSON.stringify(this.saveResponseObj)); + if (sessionStorage.length === 0) { + sessionStorage.setItem('1', this.inputReportId + '|' + this.queryString); + } else { + let length = sessionStorage.length; + length++; + sessionStorage.setItem(length.toString(), this.inputReportId + '|' + this.queryString); + }*/ + let queryParamsArr = new Array(); + let columnDrilldownqueryParamsArr = new Array(); + let groupSelectValue = ''; + if (queryParameters.includes('groupSelectValue')) { + queryParamsArr = queryParameters.split('&'); + for (let val = 0; val < queryParamsArr.length; val++) { + if (queryParamsArr[val].includes('groupSelectValue')) { + groupSelectValue = queryParamsArr[val].substring(queryParamsArr[val].indexOf('=') + 1, queryParamsArr[val].length); + } + } + this._router.navigate(['v2/run', reportID, queryParameters, groupSelectValue]); + } else if (queryParameters.includes('SELECTCRITERIA-')) { + columnDrilldownqueryParamsArr = queryParameters.split('&'); + for (let val = 0; val < columnDrilldownqueryParamsArr.length; val++) { + if (columnDrilldownqueryParamsArr[val].includes('SELECTCRITERIA-')) { + groupSelectValue = columnDrilldownqueryParamsArr[val].substring(columnDrilldownqueryParamsArr[val].indexOf('-') + 1, columnDrilldownqueryParamsArr[val].length); + } + } + this._router.navigate(['v2/run', reportID, queryParameters, groupSelectValue, 'true', '']); + } else { + this._router.navigate(['v2/run', reportID, queryParameters, '' , 'true', '']); + } + } + + + linkToMail(mailId: string) { + this.changeDetectorRefs.detectChanges(); + const email = 'mailto:' + mailId; + window.location.href = email; + } + + openOptions() { + this.changeDetectorRefs.detectChanges(); + this.openOptionsFlag = !this.openOptionsFlag; + } + + downloadReport(contentType: string, extension: string) { + + this.changeDetectorRefs.detectChanges(); + if (this.showDashboardReport === false) { + this.download_in_progress = true; + this._runService.downloadReport(this.inputReportId, extension,this.isGoBack) + .subscribe((responseExcel) => { + + this.downLoadFile(responseExcel, contentType, extension, ''); + this.download_in_progress = false; + this.changeDetectorRefs.detectChanges(); + }); + } else { + this.download_in_progress = true; + this._runService.getDashboardReportFormFields(this.inputReportId) + .subscribe((dashboardFormFields) => { +/* this._runService.runDashboardReport(this.inputReportId, this.queryString) + .subscribe((runDashboardReportResp) => {*/ + this._runService.downloadDashboardReportExcel(this.inputReportId) + .subscribe((responseDownloadDashboardReport) => { + this.downLoadFile(responseDownloadDashboardReport, contentType, extension, 'Dashboard'); + this.download_in_progress = false; + this.changeDetectorRefs.detectChanges(); + }); + //}); + + }); + } + } + + downloadSinglePage(contentType: string, extension: string) { + this.changeDetectorRefs.detectChanges(); + this.download_in_progress = true; + this._runService.downloadSinglePageReport(this.inputReportId, extension, this.isGoBack) + .subscribe((responseExcel) => { + + this.downLoadFile(responseExcel, contentType, extension, ''); + this.download_in_progress = false; + this.changeDetectorRefs.detectChanges(); + }); + } + + downLoadFile(data: any, type: string, extension: string, reportType: string) { + const blob = new Blob([data], {type: type}); + const date = new Date(); + const dateStr = + ('00' + (date.getMonth() + 1)).slice(-2) + + ('00' + date.getDate()).slice(-2) + + date.getFullYear() + + ('00' + date.getHours()).slice(-2) + + ('00' + date.getMinutes()).slice(-2) + + ('00' + date.getMilliseconds()); + let fileName = this.reportName + dateStr + '.' + extension; + if (reportType === 'Dashboard') { + fileName = ''; + fileName = reportType + '_' + this.inputReportId + '_' + dateStr + '.' + extension; + } + if (window.navigator.msSaveOrOpenBlob) { + window.navigator.msSaveBlob(blob, fileName); + } else { + const anchor = window.document.createElement('a'); + anchor.href = window.URL.createObjectURL(blob); + anchor.download = fileName; + document.body.appendChild(anchor); + anchor.click(); + document.body.removeChild(anchor); + window.URL.revokeObjectURL(anchor.href); + } + } + + applyFilter(filterValue: string) { + this.changeDetectorRefs.detectChanges(); + this.dataSource.data = this.displayedRowObj; + this.dataSource.sort = this.sort; + if (filterValue === '' || filterValue === null) { + } else { + this.dataSource.filter = filterValue.trim().toLowerCase(); + this.changeDetectorRefs.detectChanges(); + } + } + + setStyle(rowData: string) { + let styles = ''; + if (rowData.split('|')[0] === 'linkToReport') { + styles = rowData.split('|')[4]; + } else if (rowData.split('|')[0] === 'linkToMail') { + styles = rowData.split('|')[3]; + } else { + styles = rowData.split('|')[1]; + } + if (styles.includes('{')) { + return JSON.parse(styles); + } else { + return {}; + } + } + + + + getDisplayTotal(keys: string) { + if (this.displayTotal.length > 0 && this.displayTotal[0][keys]) { + return this.displayTotal[0][keys].displayValue; + } else { + return ''; + } + } + + onPaginationChange(event: any) { + this.changeDetectorRefs.detectChanges(); + if (this.DashboardReportObj.length === 0) { + if (this.reportMode === 'Regular' && this.initCnt === 0) { + this.showMoreVert = false; + this.displayedColumnsArr = []; + this.displayedRowObj = []; + this.displayedColumns = []; + this.formFieldList = []; + this.showSpinner = true; + this.isReady = false; + this.NEWdisplayedColumns = []; + this.isChartAvailable = false; + this.timeTaken = '...'; + const startDate: Date = new Date(); + const startTime = startDate.getTime(); + this._runService.getReportDataWithPageNo(this.inputReportId, event.pageIndex) + .subscribe((response) => { + if (response['errormessage']) { + this.openErrorModel(response['errormessage']); + this.showError(); + this.changeDetectorRefs.detectChanges(); + } else { + const endDate: Date = new Date(); + const endTime = endDate.getTime(); + this.chartRunUrl = environment.baseUrl + 'raptor.htm?action=chart.run&c_master=' + + this.inputReportId + '&refresh=Y&display_content=Y&r_page=' + event.pageIndex; + this.postFetchingReportDataFn(response, true, event.pageIndex); + this.showMoreVert = true; + } + }, error => { + this.openErrorModel('Error occurred while running report: ' + this.inputReportId); + this.showError(); + }); + } else { + this.showMoreVert = false; + this.displayedColumnsArr = []; + this.displayedRowObj = []; + this.displayedColumns = []; + this.formFieldList = []; + this.showSpinner = true; + this.isReady = false; + this.NEWdisplayedColumns = []; + this.isChartAvailable = false; + this.timeTaken = '...'; + const startDate: Date = new Date(); + const startTime = startDate.getTime(); + this._runService.getReportDataWithFormFieldsWithPageNo(this.queryString, this.inputReportId, event.pageIndex) + .subscribe((response) => { + if (response['errormessage']) { + this.openErrorModel(response['errormessage']); + this.showError(); + this.changeDetectorRefs.detectChanges(); + } else { + const endDate: Date = new Date(); + const endTime = endDate.getTime(); + this.chartRunUrl = environment.baseUrl + 'raptor.htm?action=chart.run&c_master=' + + this.inputReportId + this.queryString + '&refresh=Y&display_content=Y&r_page=' + event.pageIndex; + this.postFetchingReportDataFn(response, true, event.pageIndex); + this.showMoreVert = true; + } + }, error => { + this.openErrorModel('Error occurred while running report: ' + this.inputReportId); + this.showError(); + }); + } + } else { + this.showMoreVert = true; + this.showSpinner = false; + } + this.errorMessage = ''; + this.error = false; + this.initCnt = 1; + } + + convertToLinkToReport(value: string) { + value = value.replace(/;/g, ''); + let outPut = ''; + while (value.includes('c_master=')) { + const index = value.indexOf('c_master='); + if (index > 0) { + value = value.substring(index, value.length); + } else if (index === 0) { + value = value.replace('c_master=', ''); + } + } + const split = value.split('&'); + if (split[1].length <= 0) { + return outPut; + } + outPut = 'linkToReport,' + split[0] + ','; + let splitCounter = 1; + for (splitCounter = 1; splitCounter < split.length; splitCounter++) { + if (!split[splitCounter].includes('LOGIN_ID=') && + !split[splitCounter].includes('display_content=') && + !split[splitCounter].includes('drilldown_index=') && + !split[splitCounter].includes('show_back_btn=') && + !split[splitCounter].includes('r_action')) { + outPut = outPut + '&' + split[splitCounter]; + } + } + return outPut; + } + + takeToReport(queryString: string, reportID: string) { + this._router.navigate(['v2/run', reportID, queryString, this.groupSelectValue]); + } + + goBack() { + this.changeDetectorRefs.detectChanges(); + const length = sessionStorage.length; + let repId = ''; + let queryString = ''; + if (length > 1) { + let split = []; + split = sessionStorage.getItem((length).toString()).split('|'); + repId = split[0]; + queryString = split[1]; + sessionStorage.removeItem((length).toString()); + } else if (length === 1) { + let split = []; + split = sessionStorage.getItem('1').split('|'); + repId = split[0]; + queryString = split[1]; + sessionStorage.removeItem('1'); + } + localStorage.removeItem(this.inputReportId); + this._router.navigate(['v2/run', repId, queryString]); + } + + openErrorModel(_message: string) { + this.changeDetectorRefs.detectChanges(); + const modalInfoRef = this.ngbModal.open(ErrorModalComponent); + modalInfoRef.componentInstance.message = _message; + return modalInfoRef; + } + +} |