summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/report-run/run/run-report/run-dashboard-report/run-dashboard-report.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/report-run/run/run-report/run-dashboard-report/run-dashboard-report.component.ts')
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/report-run/run/run-report/run-dashboard-report/run-dashboard-report.component.ts303
1 files changed, 303 insertions, 0 deletions
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/report-run/run/run-report/run-dashboard-report/run-dashboard-report.component.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/report-run/run/run-report/run-dashboard-report/run-dashboard-report.component.ts
new file mode 100644
index 00000000..e37154a1
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/report-run/run/run-report/run-dashboard-report/run-dashboard-report.component.ts
@@ -0,0 +1,303 @@
+import {Component, OnInit, Input, AfterViewInit, ViewChild, ElementRef, ChangeDetectorRef} from '@angular/core';
+import { GridsterConfig, GridType, GridsterItem } from 'angular-gridster2';
+import { MatTableDataSource } from '@angular/material/table';
+import { MatPaginator } from '@angular/material/paginator';
+import { DashboardReportService } from './dashboard-report.service';
+import { MatSort } from '@angular/material';
+import { Router } from '@angular/router';
+import { RunService } from '../../run.service';
+import {FormControl} from '@angular/forms';
+import {NgbModal} from '@ng-bootstrap/ng-bootstrap';
+import {environment} from '../../../../../environments/environment';
+import {DisplayHtml} from '../../../../pages/analytics/Report_List/Report/display-html';
+import {ErrorModalComponent} from '../../../../modals/error-modal/error-modal.component';
+
+export interface PeriodicElement {
+
+}
+
+const ELEMENT_DATA: PeriodicElement[] = [{}];
+
+@Component({
+ selector: 'app-run-dashboard-report',
+ templateUrl: './run-dashboard-report.component.html',
+ styleUrls: ['./run-dashboard-report.component.css']
+})
+
+export class RunDashboardReportComponent implements AfterViewInit {
+
+ @Input('reportId') inputReportId: string;
+ @Input('queryString') queryString: string;
+ @Input('hitCnt') hitCnt: number;
+ @Input('reportType') reportType: string;
+ @Input('parentId') parentId: string;
+ dataSource = new MatTableDataSource<PeriodicElement>(ELEMENT_DATA);
+ @ViewChild(MatPaginator, {static: false} as any) paginator: MatPaginator;
+ @ViewChild(MatSort, {static: false} as any) sort: MatSort;
+ @ViewChild('iframe') iframe: ElementRef;
+ options: GridsterConfig;
+ dashboard: Array<GridsterItem> = [];
+ displayedColumns: string[];
+ IncomingReportId: string;
+ displayedColumnsArr: string[];
+ displayedRowObj: {}[];
+ formFieldPresent: boolean;
+ showSpinner: boolean;
+ formFieldList: {}[];
+ isReady: boolean;
+ responseFormFieldListLength: number;
+ NEWdisplayedColumns: string[];
+ initCnt: number;
+ reportName: string;
+ showDashboardReport: boolean;
+ checkCnt: number;
+ initialQueryString: string;
+ initCounter: number;
+ runButtonHitCounter: number;
+ showChart = false;
+ displayColumValue: string;
+ displayTotal: any[];
+ private chartRunUrl: string;
+ replaceDisplayValue: String;
+saveResponseObj:any;
+
+ constructor(private _dashboardReportService: DashboardReportService,
+ private _router: Router,
+ private _runService: RunService,
+ private ngModal: NgbModal,
+ private changeDetectorRefs: ChangeDetectorRef,
+ public ngbModal: NgbModal) {
+ this.initCounter = 0;
+ this.runButtonHitCounter = 0;
+ }
+
+ ngOnInit() {
+ this.initialQueryString = this.queryString;
+ this.initCounter++;
+ this.runButtonHitCounter = this.hitCnt;
+ if (this.reportType === 'Chart') {
+ this.showChart = true;
+ }
+
+ this.initialProcesses();
+ }
+
+ initialProcesses() {
+ // this.dataSource.paginator = this.paginator;
+ }
+
+ ngOnChanges() {
+ if (this.initialQueryString !== this.queryString && this.initCounter > 0 && this.runButtonHitCounter !== this.hitCnt) {
+ this.initialQueryString = this.queryString;
+ this.runButtonHitCounter = this.hitCnt;
+ this.initialProcesses();
+ this.afterViewInitProcesses();
+ } else {
+ this.runButtonHitCounter = this.hitCnt;
+ this.initialQueryString = this.queryString;
+ }
+ }
+
+ ngAfterViewInit() {
+ this.afterViewInitProcesses();
+ }
+
+ afterViewInitProcesses() {
+ if (this.showChart) {
+ this.chartRunUrl = environment.baseUrl + 'raptor.htm?action=chart.run&c_master=' +
+ this.inputReportId + this.queryString + '&refresh=Y&display_content=Y&r_page=0';
+ this.iframe.nativeElement.setAttribute('src', this.chartRunUrl);
+ this.showSpinner = false;
+ } else {
+
+ this.displayedColumnsArr = [];
+ this.displayedRowObj = [];
+ this.displayedColumns = [];
+ this.formFieldList = [];
+ this.showSpinner = true;
+ this.isReady = false;
+ this.NEWdisplayedColumns = [];
+ this.displayTotal = [];
+ if (localStorage.getItem(this.inputReportId)) {
+ this.postFetchingReportDataFn(JSON.parse(localStorage.getItem(this.inputReportId)));
+ localStorage.removeItem(this.inputReportId);
+ } else {
+ this._dashboardReportService.getReportDataWithFormFields(this.queryString, this.inputReportId)
+ .subscribe((response) => {
+ if (response['errormessage']){
+ this.openErrorModel(response['errormessage']);
+ this.showSpinner = false;
+ this.changeDetectorRefs.detectChanges();
+ } else {
+ this.postFetchingReportDataFn(response);
+ }
+ }, error => {
+ this.openErrorModel('Error occurred while running report: ' + this.inputReportId);
+ this.showSpinner = false;
+ this.changeDetectorRefs.detectChanges();
+ });
+ }
+ }
+ }
+
+ postFetchingReportDataFn(response: any){
+ this.saveResponseObj = response;
+ this.formFieldPresent = false;
+ this.responseFormFieldListLength = 0;
+ this.reportName = response['reportName'];
+ let columnCntr = 0;
+ this.displayedColumnsArr.push('RowNum,RowNum');
+ while (response['reportDataColumns'][columnCntr]) {
+ this.displayedColumnsArr.push(response['reportDataColumns'][columnCntr]['columnTitle'] + ','
+ + response['reportDataColumns'][columnCntr]['colId']);
+ columnCntr++;
+ }
+ 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('{')) {
+ displayObj = JSON.parse(reportDataRows[rowColumnId]['displayValueHtml']);
+ }
+ displayObj['text-align'] = reportDataRows[rowColumnId]['alignment'];
+ obj['RowNum'] = (rdr_cntr + 1) + '|{"text-align":"center"}';
+ if (this.replaceDisplayValue.includes('linkToReport') || this.replaceDisplayValue.includes('linkToMail')) {
+ obj[reportDataRows[rowColumnId]['colId']] = this.replaceDisplayValue.split(',').join('|')
+ + '|' + JSON.stringify(displayObj);
+ } else {
+ obj[reportDataRows[rowColumnId]['colId']] = this.replaceDisplayValue
+ + '|' + JSON.stringify(displayObj);
+ }
+ }
+ dca_cntr++;
+ }
+ this.displayedRowObj.push(obj);
+ rdr_cntr++;
+ }
+ for (let pushCounter = 0; pushCounter < this.displayedColumnsArr.length; pushCounter++) {
+ this.displayedColumns.push(this.displayedColumnsArr[pushCounter].split(',')[1]);
+ }
+ this.showSpinner = false;
+ this.dataSource = new MatTableDataSource<PeriodicElement>(this.displayedRowObj);
+ this.dataSource.sort = this.sort;
+ this.changeDetectorRefs.detectChanges();
+ }
+
+ linkToReport(reportID: string, queryParameters: string) {
+ localStorage.setItem(this.inputReportId, JSON.stringify(this.saveResponseObj));
+ if (sessionStorage.length === 0) {
+ sessionStorage.setItem('1', this.parentId + '|' + this.queryString);
+ } else {
+ let length = sessionStorage.length;
+ length++;
+ sessionStorage.setItem(length.toString(), this.parentId + '|' + this.queryString);
+ }
+ this._router.navigate(['v2/run', reportID, queryParameters]);
+ }
+
+ linkToMail(mailId: string) {
+ const email = 'mailto:' + mailId;
+ window.location.href = email;
+ }
+
+ applyFilter(filterValue: string) {
+ this.dataSource.filter = filterValue.trim().toLowerCase();
+ }
+
+ 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 !== undefined && styles.includes('{')) {
+ return JSON.parse(styles);
+ } else {
+ return {};
+ }
+ }
+
+ getDisplayTotal(keys: any) {
+ if (this.displayTotal.length > 0) {
+ return this.displayTotal[0][keys].displayValue;
+ } else {
+ return '';
+ }
+ }
+
+ 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('&');
+ // const spltFirst = split[0].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;
+ }
+
+ openErrorModel(_message: string) {
+ const modalInfoRef = this.ngbModal.open(ErrorModalComponent);
+ modalInfoRef.componentInstance.message = _message;
+ return modalInfoRef;
+ }
+
+}