import { Component, OnInit, ViewChild } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { DisplayAreaService } from 'src/app/shared/services/displayArea/display-area.service'; import { MatPaginator } from '@angular/material/paginator'; import { MatSort } from '@angular/material/sort'; import { MatTable, MatTableDataSource } from '@angular/material/table'; @Component({ selector: 'app-display-area', templateUrl: './display-area.component.html', styleUrls: ['./display-area.component.scss'] }) export class DisplayAreaComponent implements OnInit { @ViewChild( MatPaginator, { static: false } as any ) paginator: MatPaginator; @ViewChild( MatSort, { static: false } as any ) sort: MatSort; @ViewChild( MatTable, { static: false } as any ) table: MatTable; menuId:string; showSpinner: boolean; dataSource1: any; displayedColumns = ["reportName", "reportDescr","reportURL"]; finalGETObj: {}; finalRowArr: any[]; rowObj: any; reportId: string; constructor(private _route: ActivatedRoute, private _router: Router, private _displayAreaService: DisplayAreaService) { } ngOnInit() { this._route.params.subscribe(params => { this.menuId = params['menuId']; console.log("displayArea " +this.menuId); this.initializeReportList(this.menuId); }); } initializeReportList(menuId:string) { this.showSpinner = true; this.dataSource1 = new MatTableDataSource(); this.finalGETObj = new Object(); //this.finalGETObjRowsArr = new Array(); this.finalRowArr = new Array(); this._displayAreaService.getMenuIdSpecificReports(this.menuId) .subscribe(( responseObj ) => { this.finalGETObj = responseObj; for (let entry of responseObj) { this.rowObj = new Object(); this.rowObj["reportName"] = entry["reportName"]; this.rowObj["reportDescr"] = entry["reportDescr"]; this.rowObj["reportURL"] = entry["reportURL"]; this.finalRowArr.push( this.rowObj ); } this.showSpinner = false; } ); } runReport( reportId: string ) { this.reportId = reportId; this._router.navigate( [reportId] ); } }