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;
94 this.afterViewInitProcesses();
98 afterViewInitProcesses()
101 this.displayedColumnsArr = new Array();
102 this.displayedRowObj = new Array();
103 this.displayedColumns = new Array();
104 this.formFieldList = new Array();
105 this.showSpinner = true;
106 this.isReady = false;
107 this.NEWdisplayedColumns = new Array();
108 this._dashboardReportService.getReportDataWithFormFields(this.queryString, this.reportId1)
109 .subscribe((response) => {
110 this.formFieldPresent = false;
111 this.responseFormFieldListLength = 0;
113 this.reportName = response["reportName"];
116 while(response["reportDataColumns"][i])
118 this.displayedColumnsArr.push(response["reportDataColumns"][i]["columnTitle"] +","+ response["reportDataColumns"][i]["colId"]);
123 while(response["reportDataRows"][j])
126 let obj = new Object();
127 while(this.displayedColumnsArr[k])
129 if(response["reportDataRows"][j][this.displayedColumnsArr[k].split(",")[1]])
131 obj[response["reportDataRows"][j][this.displayedColumnsArr[k].split(",")[1]]["colId"]] = response["reportDataRows"][j][this.displayedColumnsArr[k].split(",")[1]]["displayValue"];
135 this.displayedRowObj.push(obj);
139 for(let l=0; l<this.displayedColumnsArr.length; l++)
141 this.displayedColumns.push(this.displayedColumnsArr[l].split(",")[1]);
143 this.showSpinner = false;
145 this.dataSource = new MatTableDataSource<PeriodicElement>(this.displayedRowObj);
146 this.dataSource.sort = this.sort;
147 this.dataSource.paginator = this.paginator;
157 linkToReport(reportID : string, queryParameters : string)
159 this._router.navigate(['v2/run', reportID, queryParameters]);
162 linkToFeedback(feedBackId : string, queryParameters : string)
164 this._router.navigate(['v2/feedback', feedBackId]);
167 linkToMail(mailId : string)
169 var email = "mailto:" + mailId;
170 window.location.href = email;
173 applyFilter(filterValue: string) {
174 this.dataSource.filter = filterValue.trim().toLowerCase();