3 ChangeDetectionStrategy,
13 } from '@angular/core';
14 import { MatPaginator } from '@angular/material/paginator';
15 import { MatSort } from '@angular/material/sort';
16 import { MatTableDataSource } from '@angular/material/table';
17 import { ActivatedRoute, Router } from '@angular/router';
18 import { HttpClient } from '@angular/common/http';
19 import { RunService } from '../run.service';
20 import { GridsterConfig, GridsterItem, GridType } from 'angular-gridster2';
21 import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
22 import {environment} from '../../../../environments/environment';
23 import {DisplayHtml} from '../../../pages/analytics/Report_List/Report/display-html';
24 import {ErrorModalComponent} from '../../../modals/error-modal/error-modal.component';
25 import {InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component';
26 import { FormControl } from '@angular/forms';
27 import { NgbModal, NgbModalOptions} from '@ng-bootstrap/ng-bootstrap';
28 import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component';
29 import {MatDialog} from '@angular/material';
30 import {HttpCacheService} from '../../../shared/services/cache.service';
32 export interface PeriodicElement {
36 const ELEMENT_DATA: PeriodicElement[] = [{}];
39 selector: 'app-run-report',
40 templateUrl: './run-report.component.html',
41 styleUrls: ['./run-report.component.css'],
42 changeDetection: ChangeDetectionStrategy.OnPush
44 export class RunReportComponent implements OnInit, AfterViewInit, OnChanges {
45 @Input('reportId') inputReportId: string;
46 @Input('reportMode') reportMode: string;
47 @Input('reportType') reportType: string;
48 @Input('queryString') queryString: string;
49 @Input('isGoBack') isGoBack: string;
50 @Input('DashboardReportObj') DashboardReportObj: Array<GridsterItem>;
51 @Input('TriggerFFArr') TriggerFFArr: string[];
52 @Input('hitCnt') hitCnt: number;
53 @Input('runAgain') runAgain: string;
54 @Input('groupSelectValue') groupSelectValue: string;
55 @Input('chartType') chartType: string;
56 @ViewChild('iframe') iframe: ElementRef;
57 @ViewChild(MatPaginator, {static: false} as any) paginator: MatPaginator;
58 @ViewChild(MatSort, {static: false} as any) sort: MatSort;
59 dataSource = new MatTableDataSource<PeriodicElement>(ELEMENT_DATA);
60 displayedColumns: string[];
61 IncomingReportId: string;
62 displayedColumnsArr: string[];
63 displayedRowObj: PeriodicElement[];
64 formFieldPresent: boolean;
68 responseFormFieldListLength: number;
69 NEWdisplayedColumns: string[];
72 showDashboardReport: boolean;
74 options: GridsterConfig;
75 dashboard: Array<GridsterItem> = [];
76 openOptionsFlag: boolean;
77 showMoreVert: boolean;
82 initialQueryString: string;
84 runButtonHitCnt: number;
87 replaceDisplayValue: String;
96 download_in_progress: boolean;
97 commentCtrl = new FormControl('');
98 isChartAvailable = false;
100 saveResponseObj: any;
101 showBackButton = false;
102 customFieldsDataArray: any[];
104 isDashboardExcelReadyToDownload = false;
105 modalOptions: NgbModalOptions;
107 constructor(private _http: HttpClient,
108 private _route: ActivatedRoute,
109 private _runService: RunService,
110 private _router: Router,
111 private changeDetectorRefs: ChangeDetectorRef,
112 public sanitizer: DomSanitizer,
113 public ngbModal: NgbModal,
114 private httpCacheService: HttpCacheService,
115 private dialog: MatDialog) {
116 this.displayedColumnsArr = [];
117 this.displayedRowObj = [];
118 this.displayedColumns = [];
119 this.formFieldList = [];
120 this.showSpinner = true;
121 this.isReady = false;
122 this.NEWdisplayedColumns = [];
125 this.showDashboardReport = false;
126 this.openOptionsFlag = false;
127 this.showMoreVert = false;
128 this.environment = environment;
129 this.initCounter = 0;
130 this.runButtonHitCnt = 0;
131 this.displayTotal = [];
132 this.totalRecords = 0;
134 this.download_in_progress = false;
136 this.isDashboardExcelReadyToDownload = false;
137 this.modalOptions = {
144 @HostListener('click') onClick() {
145 this.changeDetectorRefs.detectChanges();
148 ngOnChanges(changes: SimpleChanges) {
149 if (this.reportMode !== 'Regular' && this.initCnt > 0 && changes['runAgain']) {
151 this.showMoreVert = false;
152 if (changes['queryString']) {
153 this.queryString = changes['queryString']['currentValue'];
155 if (this.queryString !== this.initialQueryString) {
157 this.showDashboardReport = false;
158 this.dataSource = new MatTableDataSource<PeriodicElement>(ELEMENT_DATA);
159 this.displayedColumnsArr = [];
160 this.displayedRowObj = [];
161 this.displayedColumns = [];
162 this.formFieldList = [];
163 this.showSpinner = true;
164 this.isReady = false;
165 this.NEWdisplayedColumns = [];
166 this.displayTotal = [];
167 this.isChartAvailable = false;
168 this.timeTaken = '...';
169 const startDate: Date = new Date();
170 const startTime = startDate.getTime();
171 this._runService.getReportDataWithFormFields(this.queryString, this.inputReportId, this.groupSelectValue)
172 .subscribe((response) => {
173 if (response['errormessage']) {
174 this.openErrorModel(response['errormessage']);
176 this.changeDetectorRefs.detectChanges();
178 this.chartRunUrl = environment.baseUrl + 'raptor.htm?action=chart.run&c_master=' +
179 this.inputReportId + this.queryString + '&refresh=Y&display_content=Y&r_page=0';
180 if (this.reportMode !== 'FormField') {
181 this.postFetchingReportDataFn(response, false, 0);
182 const endDate: Date = new Date();
183 const endTime = endDate.getTime();
184 this.showMoreVert = true;
185 this.showDashboardReport = true;
186 this.errorMessage = '';
189 this.postFetchingReportDataFn(response, false, 0);
190 const endDate: Date = new Date();
191 const endTime = endDate.getTime();
192 this.showMoreVert = true;
193 this.errorMessage = '';
198 this.openErrorModel('Error occurred while running report: ' + this.inputReportId);
204 if (this.initialQueryString !== this.queryString && this.initCounter > 0 && this.hitCnt !== this.runButtonHitCnt) {
205 this.runButtonHitCnt = this.hitCnt;
206 this.initialQueryString = this.queryString;
207 this.initialProcesses();
209 this.runButtonHitCnt = this.hitCnt;
215 this.dataSource.paginator = this.paginator;
216 this.dataSource.sort = this.sort;
217 this.dataSource.data = this.displayedRowObj;
218 this.initialProcesses();
219 this.errorMessage = '';
224 if (this.DashboardReportObj.length > 0) {
225 this.dashboard = this.DashboardReportObj;
227 gridType: GridType.VerticalFixed,
231 outerMarginRight: 10,
232 outerMarginBottom: 5000,
234 scrollSensitivity: 10,
238 emptyCellDragMaxCols: null,
239 emptyCellDragMaxRows: null,
240 ignoreContentClass: 'gridster-item-content',
241 enableOccupiedCellDrop: true,
242 ignoreMarginInRow: false,
251 disablePushOnDrag: false,
252 disablePushOnResize: false,
253 pushDirections: {north: true, east: true, south: true, west: true},
254 pushResizeItems: true,
255 disableWindowResize: true,
256 disableWarnings: false,
257 scrollToNewItems: true,
258 enableDropToAdd: true,
259 enableEmptyCellDrop: true,
263 this._runService.getDashboardReportFormFields(this.inputReportId)
264 .subscribe((dashboardFormFields) => {
265 this.changeDetectorRefs.detectChanges();
266 this._runService.runDashboardReport(this.inputReportId, this.queryString)
267 .subscribe((runDashboardReportResp) => {
268 if (runDashboardReportResp) {
269 this.isDashboardExcelReadyToDownload = true;
270 this.changeDetectorRefs.detectChanges();
273 this.download_in_progress = false;
277 this.showDashboardReport = true;
280 this.hitCnt = this.runButtonHitCnt;
281 this.initialQueryString = this.queryString;
286 this.afterViewInitialProcesses();
289 afterViewInitialProcesses() {
290 if (sessionStorage.length > 0) {
291 this.showBackButton = true;
293 this.showBackButton = false;
295 if (this.DashboardReportObj.length === 0) {
296 if (this.reportMode === 'Regular' && this.initCnt == 0) {
297 this.showMoreVert = false;
298 this.dataSource = new MatTableDataSource<PeriodicElement>(ELEMENT_DATA);
299 this.displayedColumnsArr = [];
300 this.displayedRowObj = [];
301 this.displayedColumns = [];
302 this.formFieldList = [];
303 this.showSpinner = true;
304 this.isReady = false;
305 this.NEWdisplayedColumns = [];
306 this.timeTaken = '...';
307 const startDate: Date = new Date();
308 const startTime = startDate.getTime();
309 this._runService.getReportData(this.inputReportId)
310 .subscribe((response) => {
311 if (response['errormessage']) {
312 this.openErrorModel(response['errormessage']);
314 this.changeDetectorRefs.detectChanges();
316 this.chartRunUrl = environment.baseUrl + 'raptor.htm?action=chart.run&c_master=' +
317 this.inputReportId + '&refresh=Y&display_content=Y&r_page=0';
318 this.postFetchingReportDataFn(response, false, 0);
319 const endDate: Date = new Date();
320 const endTime = endDate.getTime();
321 this.showMoreVert = true;
324 this.openErrorModel('Error occurred while running report: ' + this.inputReportId);
328 this.showMoreVert = false;
329 this.dataSource = new MatTableDataSource<PeriodicElement>(ELEMENT_DATA);
330 this.displayedColumnsArr = [];
331 this.displayedRowObj = [];
332 this.displayedColumns = [];
333 this.formFieldList = [];
334 this.showSpinner = true;
335 this.isReady = false;
336 this.NEWdisplayedColumns = [];
337 this.timeTaken = '...';
338 const startDate: Date = new Date();
339 const startTime = startDate.getTime();
340 if (localStorage.getItem(this.inputReportId)) {
341 this.chartRunUrl = environment.baseUrl + 'raptor.htm?action=chart.run&c_master=' +
342 this.inputReportId + this.queryString + '&refresh=Y&display_content=Y&r_page=0';
343 this.postFetchingReportDataFn(JSON.parse(localStorage.getItem(this.inputReportId)), false, 0);
344 this.saveResponseObj = JSON.parse(localStorage.getItem(this.inputReportId));
345 const endDate: Date = new Date();
346 const endTime = endDate.getTime();
347 this.showMoreVert = true;
348 localStorage.removeItem(this.inputReportId);
349 this.isGoBack = 'true';
351 this._runService.getReportDataWithFormFields(this.queryString, this.inputReportId, this.groupSelectValue)
352 .subscribe((response) => {
353 if (response['errormessage']) {
354 this.openErrorModel(response['errormessage']);
356 this.changeDetectorRefs.detectChanges();
358 this.chartRunUrl = environment.baseUrl + 'raptor.htm?action=chart.run&c_master=' +
359 this.inputReportId + this.queryString + '&refresh=Y&display_content=Y&r_page=0';
360 this.saveResponseObj = response;
361 this.postFetchingReportDataFn(response, false, 0);
362 const endDate: Date = new Date();
363 const endTime = endDate.getTime();
364 this.showMoreVert = true;
367 this.openErrorModel('Error occurred while running report: ' + this.inputReportId);
373 this.showMoreVert = true;
374 this.showSpinner = false;
376 this.errorMessage = '';
382 this.showSpinner = false;
383 this.isChartAvailable = false;
384 this.changeDetectorRefs.detectChanges();
387 postFetchingReportDataFn(response: any, isPageChange: boolean, pagenum: any) {
389 this.totalRecords = 0;
390 this.displayedColumnsArr = [];
391 this.displayedColumns = [];
392 this.customFieldsDataArray = [];
393 this.formFieldPresent = false;
394 this.responseFormFieldListLength = 0;
395 this.reportName = response['reportName'];
397 this.timeTaken = (response['totalRunTime'] / 1000).toString();
398 this.displayedColumnsArr.push('RowNum,RowNum');
399 while (response['reportDataColumns'][rdc_cntr]) {
400 const columnTitle = response['reportDataColumns'][rdc_cntr]['columnTitle'];
401 const columnId = response['reportDataColumns'][rdc_cntr]['colId'];
402 this.displayedColumnsArr.push(columnTitle + ',' + columnId);
406 if (response['chartWizardAvailable'] === true && this.chartType !== 'none') {
407 this.isChartAvailable = true;
408 this.iframe.nativeElement.setAttribute('src', this.chartRunUrl);
412 while (response['reportTotalDataRows'][totalCnt]) {
413 this.displayTotal.push(response['reportTotalDataRows'][totalCnt]);
416 this.customFieldsDataArray = response['reportDataRows'];
418 while (response['reportDataRows'][rdr_cntr]) {
421 const reportDataRows = response['reportDataRows'][rdr_cntr];
422 while (this.displayedColumnsArr[dca_cntr]) {
423 const rowColumnId = this.displayedColumnsArr[dca_cntr].split(',')[1];
424 if (reportDataRows[rowColumnId]) {
425 let drillDownHtml = '';
426 let displayValue = '';
427 drillDownHtml = reportDataRows[rowColumnId]['drillDownURL'];
428 displayValue = reportDataRows[rowColumnId]['displayValue'];
429 if (drillDownHtml !== null &&
430 drillDownHtml.length > 0 &&
431 !displayValue.includes('linkToReport')) {
432 const value = this.convertToLinkToReport(drillDownHtml);
433 if (value.length > 0) {
435 let valueDisplay = '';
436 valueCount = reportDataRows[rowColumnId]['displayValue'].split('|');
437 if (valueCount.length > 1 && this.reportType === 'Cross-Tab') {
438 for (let count = 0; count < valueCount.length - 1; count++) {
439 valueDisplay = valueDisplay + valueCount[count];
441 this.replaceDisplayValue = value + ',' + valueDisplay;
443 this.replaceDisplayValue = value + ',' + reportDataRows[rowColumnId]['displayValue'];
446 this.replaceDisplayValue = reportDataRows[rowColumnId]['displayValue'];
449 this.replaceDisplayValue = reportDataRows[rowColumnId]['displayValue'];
451 let displayObj: DisplayHtml = new class implements DisplayHtml {
452 'background-color': string;
453 'font-family': string;
455 'font-style': string;
456 'font-weight': string;
457 'text-align': string;
458 'text-decoration': string;
461 if (this.reportType === ('Cross-Tab') && reportDataRows[rowColumnId]['displayValueHtml'].includes('|')) {
462 let crossTabDisplayValArr = [];
463 crossTabDisplayValArr = reportDataRows[rowColumnId]['displayValueHtml'].split('|');
464 if (crossTabDisplayValArr.length > 1) {
465 displayObj['background-color'] = crossTabDisplayValArr[1];
468 if (reportDataRows[rowColumnId]['displayValueHtml'].includes('setStyle')) {
469 displayObj = JSON.parse(reportDataRows[rowColumnId]['displayValueHtml']);
471 displayObj['text-align'] = reportDataRows[rowColumnId]['alignment'];
472 obj['RowNum'] = (pagenum * response['pageSize'] + rdr_cntr + 1) + '|{"text-align":"center"}';
473 if (this.replaceDisplayValue.includes('linkToReport') || this.replaceDisplayValue.includes('linkToFeedback') || this.replaceDisplayValue.includes('linkToMail')
474 || this.replaceDisplayValue.includes('linkToMap') || this.replaceDisplayValue.includes('linkToHref')) {
475 let replaceValArr = new Array();
476 if (this.replaceDisplayValue.includes('linkToReport')) {
477 obj[reportDataRows[rowColumnId]['colId']] = this.replaceDisplayValue.split(',').join('|');
478 replaceValArr = obj[reportDataRows[rowColumnId]['colId']].split('|');
479 if (replaceValArr.length > 4) {
480 const dispValue = replaceValArr[3] + ',' + replaceValArr[4];
481 obj[reportDataRows[rowColumnId]['colId']] = obj[reportDataRows[rowColumnId]['colId']].replace(replaceValArr[3] + '|' + replaceValArr[4], replaceValArr[3] + ',' + replaceValArr[4])+ '|' + JSON.stringify(displayObj);
483 obj[reportDataRows[rowColumnId]['colId']] = this.replaceDisplayValue.split(',').join('|')
484 + '|' + JSON.stringify(displayObj);
487 obj[reportDataRows[rowColumnId]['colId']] = this.replaceDisplayValue.split(',').join('|')
488 + '|' + JSON.stringify(displayObj);
491 obj[reportDataRows[rowColumnId]['colId']] = this.replaceDisplayValue.split('comment-break-line').join('')
492 + '|' + JSON.stringify(displayObj);
497 this.displayedRowObj.push(obj);
500 this.pageSize = response['pageSize'];
501 for (let cntr = 0; cntr < this.displayedColumnsArr.length; cntr++) {
502 const columnArrId = this.displayedColumnsArr[cntr].split(',')[1];
503 this.displayedColumns.push(columnArrId);
505 this.totalRecords = 0;
506 this.totalRecords = response['totalRows'];
507 this.showSpinner = false;
509 this.paginator.length = this.totalRecords;
510 this.paginator.pageSize = this.pageSize;
511 this.paginator.pageIndex = 0;
513 this.dataSource.data = this.displayedRowObj;
514 this.dataSource.sort = this.sort;
515 this.changeDetectorRefs.detectChanges();
518 linkToReport(reportID: string, queryParameters: string) {
519 if (!this.httpCacheService.getPreviousId(this.inputReportId)) {
520 this.httpCacheService.setPreviousId(this.inputReportId, 'parent');
522 this.httpCacheService.setPreviousId(reportID, this.inputReportId);
523 /* localStorage.setItem(this.inputReportId, JSON.stringify(this.saveResponseObj));
524 if (sessionStorage.length === 0) {
525 sessionStorage.setItem('1', this.inputReportId + '|' + this.queryString);
527 let length = sessionStorage.length;
529 sessionStorage.setItem(length.toString(), this.inputReportId + '|' + this.queryString);
531 let queryParamsArr = [];
532 let columnDrilldownqueryParamsArr = [];
533 let groupSelectValue = '';
534 if (queryParameters.includes('groupSelectValue')) {
535 queryParamsArr = queryParameters.split('&');
536 for (let val = 0; val < queryParamsArr.length; val++) {
537 if (queryParamsArr[val].includes('groupSelectValue')) {
538 groupSelectValue = queryParamsArr[val].substring(queryParamsArr[val].indexOf('=') + 1, queryParamsArr[val].length);
541 this._router.navigate(['v2/run', reportID, queryParameters, groupSelectValue]);
542 } else if (queryParameters.includes('SELECTCRITERIA-')) {
543 columnDrilldownqueryParamsArr = queryParameters.split('&');
544 for (let val = 0; val < columnDrilldownqueryParamsArr.length; val++) {
545 if (columnDrilldownqueryParamsArr[val].includes('SELECTCRITERIA-')) {
546 groupSelectValue = columnDrilldownqueryParamsArr[val].substring(columnDrilldownqueryParamsArr[val].indexOf('-') + 1, columnDrilldownqueryParamsArr[val].length);
549 this._router.navigate(['v2/run', reportID, queryParameters, groupSelectValue, 'true', '']);
551 this._router.navigate(['v2/run', reportID, queryParameters, '' , 'true', '']);
556 linkToMail(mailId: string) {
557 this.changeDetectorRefs.detectChanges();
558 const email = 'mailto:' + mailId;
559 window.location.href = email;
563 this.changeDetectorRefs.detectChanges();
564 this.openOptionsFlag = !this.openOptionsFlag;
567 downloadReport(contentType: string, extension: string) {
569 this.changeDetectorRefs.detectChanges();
570 if (this.showDashboardReport === false) {
571 this.download_in_progress = true;
572 this._runService.downloadReport(this.inputReportId, extension,this.isGoBack)
573 .subscribe((responseExcel) => {
575 this.downLoadFile(responseExcel, contentType, extension, '');
576 this.download_in_progress = false;
577 this.changeDetectorRefs.detectChanges();
580 this.download_in_progress = true;
581 this._runService.getDashboardReportFormFields(this.inputReportId)
582 .subscribe((dashboardFormFields) => {
583 /* this._runService.runDashboardReport(this.inputReportId, this.queryString)
584 .subscribe((runDashboardReportResp) => {*/
585 this._runService.downloadDashboardReportExcel(this.inputReportId)
586 .subscribe((responseDownloadDashboardReport) => {
587 this.downLoadFile(responseDownloadDashboardReport, contentType, extension, 'Dashboard');
588 this.download_in_progress = false;
589 this.changeDetectorRefs.detectChanges();
597 downloadSinglePage(contentType: string, extension: string) {
598 this.changeDetectorRefs.detectChanges();
599 this.download_in_progress = true;
600 this._runService.downloadSinglePageReport(this.inputReportId, extension, this.isGoBack)
601 .subscribe((responseExcel) => {
603 this.downLoadFile(responseExcel, contentType, extension, '');
604 this.download_in_progress = false;
605 this.changeDetectorRefs.detectChanges();
609 downLoadFile(data: any, type: string, extension: string, reportType: string) {
610 const blob = new Blob([data], {type: type});
611 const date = new Date();
613 ('00' + (date.getMonth() + 1)).slice(-2) +
614 ('00' + date.getDate()).slice(-2) +
616 ('00' + date.getHours()).slice(-2) +
617 ('00' + date.getMinutes()).slice(-2) +
618 ('00' + date.getMilliseconds());
619 let fileName = this.reportName + dateStr + '.' + extension;
620 if (reportType === 'Dashboard') {
622 fileName = reportType + '_' + this.inputReportId + '_' + dateStr + '.' + extension;
624 if (window.navigator.msSaveOrOpenBlob) {
625 window.navigator.msSaveBlob(blob, fileName);
627 const anchor = window.document.createElement('a');
628 anchor.href = window.URL.createObjectURL(blob);
629 anchor.download = fileName;
630 document.body.appendChild(anchor);
632 document.body.removeChild(anchor);
633 window.URL.revokeObjectURL(anchor.href);
637 applyFilter(filterValue: string) {
638 this.changeDetectorRefs.detectChanges();
639 this.dataSource.data = this.displayedRowObj;
640 this.dataSource.sort = this.sort;
641 if (filterValue === '' || filterValue === null) {
643 this.dataSource.filter = filterValue.trim().toLowerCase();
644 this.changeDetectorRefs.detectChanges();
648 setStyle(rowData: string) {
650 if (rowData.split('|')[0] === 'linkToReport') {
651 styles = rowData.split('|')[4];
652 } else if (rowData.split('|')[0] === 'linkToMail') {
653 styles = rowData.split('|')[3];
654 } else if (this.reportType === 'Cross-Tab') {
655 const rowDataArray = rowData.split('|');
656 let crossTabstyles = {};
657 if (rowDataArray.length > 0) {
658 if (rowDataArray[1].includes('{')) {
659 styles = rowDataArray[1];
660 return JSON.parse(styles);
662 crossTabstyles = {'background-color': rowData.split('|')[1]};
663 return crossTabstyles;
667 styles = rowData.split('|')[1];
669 if (styles !== undefined && styles.includes('{')) {
670 return JSON.parse(styles);
678 getDisplayTotal(keys: string) {
679 if (this.displayTotal.length > 0 && this.displayTotal[0][keys]) {
680 return this.displayTotal[0][keys].displayValue;
686 onPaginationChange(event: any) {
687 this.changeDetectorRefs.detectChanges();
688 if (this.DashboardReportObj.length === 0) {
689 if (this.reportMode === 'Regular' && this.initCnt === 0) {
690 this.showMoreVert = false;
691 this.displayedColumnsArr = [];
692 this.displayedRowObj = [];
693 this.displayedColumns = [];
694 this.formFieldList = [];
695 this.showSpinner = true;
696 this.isReady = false;
697 this.NEWdisplayedColumns = [];
698 this.isChartAvailable = false;
699 this.timeTaken = '...';
700 const startDate: Date = new Date();
701 const startTime = startDate.getTime();
702 this._runService.getReportDataWithPageNo(this.inputReportId, event.pageIndex)
703 .subscribe((response) => {
704 if (response['errormessage']) {
705 this.openErrorModel(response['errormessage']);
707 this.changeDetectorRefs.detectChanges();
709 const endDate: Date = new Date();
710 const endTime = endDate.getTime();
711 this.chartRunUrl = environment.baseUrl + 'raptor.htm?action=chart.run&c_master=' +
712 this.inputReportId + '&refresh=Y&display_content=Y&r_page=' + event.pageIndex;
713 this.postFetchingReportDataFn(response, true, event.pageIndex);
714 this.showMoreVert = true;
717 this.openErrorModel('Error occurred while running report: ' + this.inputReportId);
721 this.showMoreVert = false;
722 this.displayedColumnsArr = [];
723 this.displayedRowObj = [];
724 this.displayedColumns = [];
725 this.formFieldList = [];
726 this.showSpinner = true;
727 this.isReady = false;
728 this.NEWdisplayedColumns = [];
729 this.isChartAvailable = false;
730 this.timeTaken = '...';
731 const startDate: Date = new Date();
732 const startTime = startDate.getTime();
733 this._runService.getReportDataWithFormFieldsWithPageNo(this.queryString, this.inputReportId, event.pageIndex)
734 .subscribe((response) => {
735 if (response['errormessage']) {
736 this.openErrorModel(response['errormessage']);
738 this.changeDetectorRefs.detectChanges();
740 const endDate: Date = new Date();
741 const endTime = endDate.getTime();
742 this.chartRunUrl = environment.baseUrl + 'raptor.htm?action=chart.run&c_master=' +
743 this.inputReportId + this.queryString + '&refresh=Y&display_content=Y&r_page=' + event.pageIndex;
744 this.postFetchingReportDataFn(response, true, event.pageIndex);
745 this.showMoreVert = true;
748 this.openErrorModel('Error occurred while running report: ' + this.inputReportId);
753 this.showMoreVert = true;
754 this.showSpinner = false;
756 this.errorMessage = '';
761 convertToLinkToReport(value: string) {
762 value = value.replace(/;/g, '');
764 while (value.includes('c_master=')) {
765 const index = value.indexOf('c_master=');
767 value = value.substring(index, value.length);
768 } else if (index === 0) {
769 value = value.replace('c_master=', '');
772 const split = value.split('&');
773 if (split[1].length <= 0) {
776 outPut = 'linkToReport,' + split[0] + ',';
777 let splitCounter = 1;
778 for (splitCounter = 1; splitCounter < split.length; splitCounter++) {
779 if (!split[splitCounter].includes('LOGIN_ID=') &&
780 !split[splitCounter].includes('display_content=') &&
781 !split[splitCounter].includes('drilldown_index=') &&
782 !split[splitCounter].includes('show_back_btn=') &&
783 !split[splitCounter].includes('r_action')) {
784 outPut = outPut + '&' + split[splitCounter];
790 takeToReport(queryString: string, reportID: string) {
791 this._router.navigate(['v2/run', reportID, queryString, this.groupSelectValue]);
795 this.changeDetectorRefs.detectChanges();
796 const length = sessionStorage.length;
798 let queryString = '';
801 split = sessionStorage.getItem((length).toString()).split('|');
803 queryString = split[1];
804 sessionStorage.removeItem((length).toString());
805 } else if (length === 1) {
807 split = sessionStorage.getItem('1').split('|');
809 queryString = split[1];
810 sessionStorage.removeItem('1');
812 localStorage.removeItem(this.inputReportId);
813 this._router.navigate(['v2/run', repId, queryString]);
816 openErrorModel(_message: string) {
817 this.changeDetectorRefs.detectChanges();
818 const modalInfoRef = this.ngbModal.open(ErrorModalComponent, this.modalOptions);
819 modalInfoRef.componentInstance.message = _message;
823 openErrorModelPopup(_message: string) {
824 this.changeDetectorRefs.detectChanges();
825 const modalInfoRef = this.ngbModal.open(ErrorModalComponent, this.modalOptions);
826 modalInfoRef.componentInstance.message = _message;
827 modalInfoRef.result.then((data) => {
828 this.resetFormFieldValues(this.inputReportId);
833 resetFormFieldValues(reportId) {
834 this.httpCacheService.clearCache();
835 this._router.navigateByUrl('v2/app/refresh', {skipLocationChange: true}).then(() =>
836 this._router.navigate(['v2/run', reportId]));
839 linkToOpenNewTab(repId, formfiledValues) {
841 formfiledValues = formfiledValues.replaceAll('%2F','||');
842 str = window.location.pathname.split('/');
843 let approot = str[1];
844 let reportLink2 = this._router.serializeUrl(this._router.createUrlTree([approot + '/v2/run', repId, formfiledValues]));
845 window.open(reportLink2, '_blank');