c9763772df5522f53070ef9f10cb377f93ccc997
[portal/sdk.git] /
1 import { Component, OnInit, Input, ChangeDetectionStrategy } from '@angular/core';
2
3 @Component({
4   selector: 'app-sql-validate-success-dialog-component',
5   templateUrl: './sql-validate-success-dialog.component.html',
6   styleUrls: ['./sql-validate-success-dialog.component.css'],
7   changeDetection: ChangeDetectionStrategy.OnPush 
8 })
9 export class SQLValidateSuccessDialogComponent implements OnInit {
10
11   @Input('tableObj') tableObj : any;
12   
13
14   headers = [];
15   rows = [];
16   finalDisplayObjArr : any[] = new Array();
17   subArr : string[] = new Array();
18   constructor() { }
19
20   ngOnInit() {
21
22   }
23
24   ngOnChanges(){
25     //console.log(this.tableObj);
26     this.rows = new Array();
27     this.headers = new Array();
28     this.finalDisplayObjArr = new Array();
29     
30     this.tableObj = this.tableObj;
31
32     this.headers = JSON.parse(this.tableObj)["reportDataColumns"];
33     this.rows = JSON.parse(this.tableObj)["reportDataRows"];
34
35     // for(let i=0; i<this.headers.length; i++)
36     // {
37     //   this.subArr.push(this.headers[i]);
38     // }
39     // this.finalDisplayObjArr.push(this.subArr);
40
41     for(let i=0; i<this.rows.length; i++)
42     {
43       this.subArr = [];
44       
45       for(let j=0; j<this.headers.length; j++)
46       {
47         //console.log(this.rows[i][this.headers[j]]);
48         this.subArr.push(this.rows[i][this.headers[j]]);  
49             
50       }
51
52      // console.log(this.subArr);
53       this.finalDisplayObjArr.push(this.subArr);
54       
55     }
56
57     console.log(this.finalDisplayObjArr);
58   }
59
60   
61
62 }