summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/display-area/display-area.component.ts
blob: e08190e7f983c36ff2381ab30ff919c1e65930dc (plain)
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
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<any>;
  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] );
}

}