1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
import { AfterViewInit, Component, OnInit, ViewChild, Input, SimpleChange } from '@angular/core';
import { MatPaginator } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
import { MatTable } from '@angular/material/table';
import { RunReportFinalTableDataSource, RunReportFinalTableItem } from './run-report-result-set-datasource';
import { ActivatedRoute } from '@angular/router';
import { HttpClient } from '@angular/common/http';
import { environment } from '../../../../../../../environments/environment';
import { RunService } from '../run.service';
@Component({
selector: 'app-run-report-result-set',
templateUrl: './run-report-result-set.component.html',
styleUrls: ['./run-report-result-set.component.css']
})
export class RunReportResultSetComponent implements AfterViewInit, OnInit {
@Input("reportId") reportId1 : string;
@ViewChild(MatPaginator, {static: false} as any) paginator: MatPaginator;
@ViewChild(MatSort, {static: false} as any) sort: MatSort;
@ViewChild(MatTable, {static: false} as any) table: MatTable<RunReportFinalTableItem>;
dataSource: RunReportFinalTableDataSource;
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
displayedColumns : string[];
IncomingReportId : string;
displayedColumnsArr : string[];
displayedRowObj : RunReportFinalTableItem[];
constructor(private _http : HttpClient, private _route : ActivatedRoute, private _runService : RunService){
this.displayedColumnsArr = new Array();
this.displayedRowObj = new Array();
this.displayedColumns = new Array();
}
ngOnInit() {
this.dataSource = new RunReportFinalTableDataSource();
this._route.params.subscribe(params => {
this.IncomingReportId = params["reportId"];
});
this._runService.getReportData(this.reportId1)
.subscribe((response) => {
console.log(response);
let i=0;
while(response["reportDataColumns"][i])
{
this.displayedColumnsArr.push(response["reportDataColumns"][i]["columnTitle"] +","+ response["reportDataColumns"][i]["colId"]);
i++;
}
let j=0;
while(response["reportDataRows"][j])
{
let k=0;
let obj = new Object();
while(this.displayedColumnsArr[k])
{
if(response["reportDataRows"][j][this.displayedColumnsArr[k].split(",")[1]])
{
obj[response["reportDataRows"][j][this.displayedColumnsArr[k].split(",")[1]]["colId"]] = response["reportDataRows"][j][this.displayedColumnsArr[k].split(",")[1]]["displayValue"];
}
k++;
}
this.displayedRowObj.push(obj);
j++;
}
console.log(this.displayedColumnsArr);
console.log(this.displayedRowObj);
for(let l=0; l<this.displayedColumnsArr.length; l++)
{
this.displayedColumns.push(this.displayedColumnsArr[l].split(",")[1]);
}
this.dataSource.data = this.displayedRowObj;
this.dataSource.sort = this.sort;
this.dataSource.paginator = this.paginator;
this.table.dataSource = this.dataSource;
});
}
ngAfterViewInit() {
this._runService.getReportData(this.reportId1)
.subscribe((response) => {
console.log(response);
let i=0;
while(response["reportDataColumns"][i])
{
this.displayedColumnsArr.push(response["reportDataColumns"][i]["columnTitle"] +","+ response["reportDataColumns"][i]["colId"]);
i++;
}
let j=0;
while(response["reportDataRows"][j])
{
let k=0;
let obj = new Object();
while(this.displayedColumnsArr[k])
{
if(response["reportDataRows"][j][this.displayedColumnsArr[k].split(",")[1]])
{
obj[response["reportDataRows"][j][this.displayedColumnsArr[k].split(",")[1]]["colId"]] = response["reportDataRows"][j][this.displayedColumnsArr[k].split(",")[1]]["displayValue"];
}
k++;
}
this.displayedRowObj.push(obj);
j++;
}
console.log(this.displayedColumnsArr);
console.log(this.displayedRowObj);
for(let l=0; l<this.displayedColumnsArr.length; l++)
{
this.displayedColumns.push(this.displayedColumnsArr[l].split(",")[1]);
}
this.dataSource.data = this.displayedRowObj;
this.dataSource.sort = this.sort;
this.dataSource.paginator = this.paginator;
this.table.dataSource = this.dataSource;
});
}
}
|