1 import { Component, OnInit, Input, EventEmitter, Output } from '@angular/core';
2 import { trigger, transition, style, animate } from '@angular/animations';
3 import { HttpClient } from '@angular/common/http';
4 import { ColumnService } from '../../column.service';
9 selector: 'app-edit-drill-down-link',
10 templateUrl: './edit-drill-down-link.component.html',
11 styleUrls: ['./edit-drill-down-link.component.css']
13 export class EditDrillDownLinkComponent implements OnInit {
16 @Input() closable = true;
17 @Input() visible: boolean;
19 @Input("reportId") reportId : number;
20 @Input("drillDownObj") drillDownObj : {};
22 @Output() completed = new EventEmitter<any>();
24 drillDownColsList : {}[];
25 valueOfColumnsList : {}[];
26 showSpinner : boolean;
28 valueOfColumns : string;
29 valueOfColumnsArr : any[];
30 valueOfFormFieldArr : any[];
31 fixedValueArr : any[];
33 noValueRadioArr : any[];
34 valueValueArr : any[];
35 radioButtonCheckedArr : boolean[];
36 fieldValuesArr : string[];
39 postDrillDownObj : {};
41 constructor(private _http : HttpClient, private _columnService : ColumnService) {
42 this.drillDownColsList = new Array();
43 this.valueOfColumnsList = new Array();
44 this.showSpinner = true;
45 this.valueOfColumnsArr = new Array();
46 this.valueOfFormFieldArr = new Array();
47 this.postDrillDownObj = new Object();
49 this.noValueRadioArr = new Array();
50 this.valueValueArr = new Array();
51 this.radioButtonCheckedArr = new Array();
52 this.fieldValuesArr = new Array();
59 console.log(this.drillDownObj);
61 this._columnService.getDrillDownReportColumnDetails(this.drillDownObj["drillDownUrl"])
62 .subscribe((response) => {
63 console.log(response);
68 this.drillDownColsList.push(response[i]);
69 // this.valueOfFormFieldArr.push(response[i]["name"]);
70 // console.log(response);
74 console.log(this.drillDownColsList);
76 this._columnService.getValueOfColumnDetails(this.reportId)
77 .subscribe((responseValueOfColumn)=> {
78 console.log(responseValueOfColumn);
82 while(responseValueOfColumn[k])
84 this.valueOfColumnsList.push(responseValueOfColumn[k]);
87 // for(let l=0; l<this.drillDownColsList.length; l++)
89 // this.valueOfColumnsArr.push("site_state");
92 console.log(this.drillDownObj["drillDownParams"]);
94 for(let kj=0; kj<this.drillDownObj["drillDownParams"].split("&").length; kj++)
96 for(let aj=0; aj<this.drillDownObj["drillDownParams"].split("&")[kj].split("=").length; aj++)
98 for(let lk=0; lk<this.drillDownColsList.length; lk++)
100 console.log(this.drillDownColsList[lk]["name"], this.drillDownObj["drillDownParams"].split("&")[kj].split("=")[1]);
101 if(this.drillDownColsList[lk]["id"] == this.drillDownObj["drillDownParams"].split("&")[kj].split("=")[0])
103 if(this.drillDownColsList[lk]["name"] == this.drillDownObj["drillDownParams"].split("&")[kj].split("=")[1])
105 let index = (lk*5) + 3;
106 this.radioButtonCheckedArr[index] = true;
107 console.log(this.radioButtonCheckedArr);
117 this.showSpinner = false;
129 let queryParamsString = "";
131 console.log(this.noValueRadioArr, this.valueValueArr);
133 if(this.noValueRadioArr && this.valueValueArr)
136 for(let j=0; j<this.noValueRadioArr.length; j++)
138 console.log(+this.noValueRadioArr[j]);
139 if(this.valueValueArr[+this.noValueRadioArr[j]] !== null)
142 // console.log(this.drillDownColsList[+this.noValueRadioArr[j]/5]["id"]);
143 // console.log(Math.floor((+this.noValueRadioArr[j]-1)/5));
145 if(Math.floor((+this.noValueRadioArr[j]-1)/5) === 0)
147 queryParamsString = queryParamsString + this.drillDownColsList[Math.floor((+this.noValueRadioArr[j]-1)/5)]["id"] + "=" + this.valueValueArr[+this.noValueRadioArr[j]];
148 // console.log(queryParamsString);
152 queryParamsString = queryParamsString + "&" + this.drillDownColsList[Math.floor((+this.noValueRadioArr[j]-1)/5)]["id"] + "=" + this.valueValueArr[+this.noValueRadioArr[j]];
153 // console.log(queryParamsString);
159 // console.log(queryParamsString);
161 this.postDrillDownObj["drilldownParams"] = queryParamsString;
162 this.postDrillDownObj["drilldownType"] = "";
164 // console.log(this.postDrillDownObj);
166 this.completed.emit(this.postDrillDownObj);