e08190e7f983c36ff2381ab30ff919c1e65930dc
[portal/sdk.git] /
1 import { Component, OnInit, ViewChild } from '@angular/core';
2 import { ActivatedRoute, Router } from '@angular/router';
3 import { DisplayAreaService } from 'src/app/shared/services/displayArea/display-area.service';
4 import { MatPaginator } from '@angular/material/paginator';
5 import { MatSort } from '@angular/material/sort';
6 import { MatTable, MatTableDataSource } from '@angular/material/table';
7
8 @Component({
9   selector: 'app-display-area',
10   templateUrl: './display-area.component.html',
11   styleUrls: ['./display-area.component.scss']
12 })
13 export class DisplayAreaComponent implements OnInit {
14
15   @ViewChild( MatPaginator, { static: false } as any ) paginator: MatPaginator;
16   @ViewChild( MatSort, { static: false } as any ) sort: MatSort;
17   @ViewChild( MatTable, { static: false } as any ) table: MatTable<any>;
18   menuId:string;
19   showSpinner: boolean;
20   dataSource1: any;
21   displayedColumns = ["reportName", "reportDescr","reportURL"];
22   finalGETObj: {};
23   finalRowArr: any[];
24   rowObj: any;
25   reportId: string;
26
27   constructor(private _route: ActivatedRoute, private _router: Router, private _displayAreaService: DisplayAreaService) { }
28
29   ngOnInit() {
30     this._route.params.subscribe(params => {
31       this.menuId = params['menuId'];
32       console.log("displayArea " +this.menuId);
33       this.initializeReportList(this.menuId);   
34   });
35
36
37     
38   }
39
40     initializeReportList(menuId:string) {
41     this.showSpinner = true;
42     this.dataSource1 = new MatTableDataSource();
43     this.finalGETObj = new Object();
44 //this.finalGETObjRowsArr = new Array();
45     this.finalRowArr = new Array();
46     this._displayAreaService.getMenuIdSpecificReports(this.menuId)
47         .subscribe(( responseObj ) => {
48             this.finalGETObj = responseObj;
49             for (let entry of responseObj) {
50               this.rowObj = new Object();
51               this.rowObj["reportName"] = entry["reportName"];
52               this.rowObj["reportDescr"] = entry["reportDescr"];
53               this.rowObj["reportURL"] = entry["reportURL"];
54               this.finalRowArr.push( this.rowObj );
55             }
56             this.showSpinner = false;
57         } );
58 }
59
60 runReport( reportId: string ) {
61   this.reportId = reportId;
62   this._router.navigate( [reportId] );
63 }
64
65 }