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

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

  @Input('tableObj') tableObj : any;
  

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

  ngOnInit() {

  }

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

    if(JSON.parse(this.tableObj)["errormessage"] != undefined){
      this.showMessage = true;
      this.errorMessage = JSON.parse(this.tableObj)["errormessage"];
      this.Validatestatus = "Sql Verify: failed! "
 
    } else{    
       this.showMessage = false;
       this.headers = JSON.parse(this.tableObj)["reportDataColumns"];
       this.rows = JSON.parse(this.tableObj)["reportDataRows"];
    for(let i=0; i<this.rows.length; i++)
    {
      this.subArr = [];
      
      for(let j=0; j<this.headers.length; j++)
      {
        this.subArr.push(this.rows[i][this.headers[j]]);           
      }
      this.finalDisplayObjArr.push(this.subArr);
       
     }
   }
  }

  

}