diff options
author | 2019-09-11 14:32:33 +0000 | |
---|---|---|
committer | 2019-09-11 14:32:33 +0000 | |
commit | aa3f5347cc0f7e71f2eef85a0f688564dc11e0ff (patch) | |
tree | 7339439db9a41dd0e13bb87ae3d23996792e5990 /ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-result-set/run-report-result-set.component.ts | |
parent | 8e978f735eb286b9bf175dad4b27e02799c2082d (diff) | |
parent | e0de951fb38d1b2aff6f10f3135c01163d3d2f31 (diff) |
Merge "Raptor user interface code in Angular"
Diffstat (limited to 'ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-result-set/run-report-result-set.component.ts')
-rw-r--r-- | ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-result-set/run-report-result-set.component.ts | 148 |
1 files changed, 148 insertions, 0 deletions
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-result-set/run-report-result-set.component.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-result-set/run-report-result-set.component.ts new file mode 100644 index 00000000..b852964b --- /dev/null +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-result-set/run-report-result-set.component.ts @@ -0,0 +1,148 @@ +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"]; + }); + + // console.log(this.IncomingReportId); + + 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]]) + { + //console.log(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"]; + //this.displayedRowObj.push(response["reportDataRows"][j][this.displayedColumnsArr[k].split(",")[1]]); + } + k++; + } + this.displayedRowObj.push(obj); + //console.log(response["reportDataRows"][j]); + 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; + + }); + + // this.dataSource.data = [{id: 1, name: 'Hydrogen'}]; + + } + + 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]]) + { + //console.log(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"]; + //this.displayedRowObj.push(response["reportDataRows"][j][this.displayedColumnsArr[k].split(",")[1]]); + } + k++; + } + this.displayedRowObj.push(obj); + //console.log(response["reportDataRows"][j]); + 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; + + }); + + + } + + +} |