1 import { Component, OnInit, Input, AfterViewInit, ViewChild } from '@angular/core';
2 import { GridsterConfig, GridType, GridsterItem } from 'angular-gridster2';
3 import { MatTableDataSource } from '@angular/material/table';
4 import { MatPaginator } from '@angular/material/paginator';
5 import { DashboardReportService } from './dashboard-report.service';
6 import { MatSort } from '@angular/material';
7 import { Router } from '@angular/router';
11 export interface PeriodicElement {
17 const ELEMENT_DATA: PeriodicElement[] = [{}];
20 selector: 'app-run-dashboard-report',
21 templateUrl: './run-dashboard-report.component.html',
22 styleUrls: ['./run-dashboard-report.component.css']
25 export class RunDashboardReportComponent implements AfterViewInit {
29 @Input("reportId") reportId1 : string;
30 @Input("queryString") queryString : string;
31 @Input("hitCnt") hitCnt : number;
32 dataSource = new MatTableDataSource<PeriodicElement>(ELEMENT_DATA);
34 @ViewChild(MatPaginator, {static: false} as any) paginator: MatPaginator;
35 @ViewChild(MatSort, {static: false} as any) sort: MatSort;
37 options: GridsterConfig;
38 dashboard : Array<GridsterItem> = new Array();
40 displayedColumns : string[];
41 IncomingReportId : string;
42 displayedColumnsArr : string[];
43 displayedRowObj : {}[];
44 formFieldPresent : boolean;
45 showSpinner : boolean;
48 responseFormFieldListLength : number;
49 NEWdisplayedColumns : string[];
52 showDashboardReport : boolean;
54 initialQueryString : string;
56 runButtonHitCounter : number;
58 constructor(private _dashboardReportService : DashboardReportService, private _router : Router) {
60 this.runButtonHitCounter = 0;
64 this.initialQueryString = this.queryString;
66 this.runButtonHitCounter = this.hitCnt;
67 this.initialProcesses();
72 this.dataSource.paginator = this.paginator;
77 if(this.initialQueryString !== this.queryString && this.initCounter > 0 && this.runButtonHitCounter !== this.hitCnt)
79 this.initialQueryString = this.queryString;
80 this.runButtonHitCounter = this.hitCnt;
81 this.initialProcesses();
82 this.afterViewInitProcesses();
86 this.runButtonHitCounter = this.hitCnt;
87 this.initialQueryString = this.queryString;
93 this.afterViewInitProcesses();
96 afterViewInitProcesses()
99 this.displayedColumnsArr = new Array();
100 this.displayedRowObj = new Array();
101 this.displayedColumns = new Array();
102 this.formFieldList = new Array();
103 this.showSpinner = true;
104 this.isReady = false;
105 this.NEWdisplayedColumns = new Array();
106 this._dashboardReportService.getReportDataWithFormFields(this.queryString, this.reportId1)
107 .subscribe((response) => {
108 this.formFieldPresent = false;
109 this.responseFormFieldListLength = 0;
111 this.reportName = response["reportName"];
114 while(response["reportDataColumns"][i])
116 this.displayedColumnsArr.push(response["reportDataColumns"][i]["columnTitle"] +","+ response["reportDataColumns"][i]["colId"]);
121 while(response["reportDataRows"][j])
124 let obj = new Object();
125 while(this.displayedColumnsArr[k])
127 if(response["reportDataRows"][j][this.displayedColumnsArr[k].split(",")[1]])
129 obj[response["reportDataRows"][j][this.displayedColumnsArr[k].split(",")[1]]["colId"]] = response["reportDataRows"][j][this.displayedColumnsArr[k].split(",")[1]]["displayValue"];
133 this.displayedRowObj.push(obj);
137 for(let l=0; l<this.displayedColumnsArr.length; l++)
139 this.displayedColumns.push(this.displayedColumnsArr[l].split(",")[1]);
141 this.showSpinner = false;
143 this.dataSource = new MatTableDataSource<PeriodicElement>(this.displayedRowObj);
144 this.dataSource.sort = this.sort;
145 this.dataSource.paginator = this.paginator;
155 linkToReport(reportID : string, queryParameters : string)
157 this._router.navigate(['v2/run', reportID, queryParameters]);
160 linkToFeedback(feedBackId : string, queryParameters : string)
162 this._router.navigate(['v2/feedback', feedBackId]);
165 linkToMail(mailId : string)
167 var email = "mailto:" + mailId;
168 window.location.href = email;
171 applyFilter(filterValue: string) {
172 this.dataSource.filter = filterValue.trim().toLowerCase();