summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/sqlcomponent/validate-success-component/validate-success-component.component.ts
blob: 7717970b1d72eb21064e18b4f38cb333e9cd8a59 (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
import { Component, OnInit, Input, ChangeDetectionStrategy } from '@angular/core';

@Component({
  selector: 'app-validate-success-component',
  templateUrl: './validate-success-component.component.html',
  styleUrls: ['./validate-success-component.component.css'],
  changeDetection: ChangeDetectionStrategy.OnPush 
})
export class ValidateSuccessComponentComponent implements OnInit {

  @Input('tableObj') tableObj : any;
  

  headers = [];
  rows = [];
  finalDisplayObjArr : any[] = new Array();
  subArr : string[] = new Array();
  constructor() { }

  ngOnInit() {

  }

  ngOnChanges(){
    //console.log(this.tableObj);
    this.rows = new Array();
    this.headers = new Array();
    this.finalDisplayObjArr = new Array();
    
    this.tableObj = this.tableObj;

    this.headers = JSON.parse(this.tableObj)["reportDataColumns"];
    this.rows = JSON.parse(this.tableObj)["reportDataRows"];

    // for(let i=0; i<this.headers.length; i++)
    // {
    //   this.subArr.push(this.headers[i]);
    // }
    // this.finalDisplayObjArr.push(this.subArr);

    for(let i=0; i<this.rows.length; i++)
    {
      this.subArr = [];
      
      for(let j=0; j<this.headers.length; j++)
      {
        //console.log(this.rows[i][this.headers[j]]);
        this.subArr.push(this.rows[i][this.headers[j]]);  
            
      }

     // console.log(this.subArr);
      this.finalDisplayObjArr.push(this.subArr);
      
    }

    console.log(this.finalDisplayObjArr);
  }

  

}