5399d792a89bb0b97bb580fc5fb722e7dcc347b0
[portal/sdk.git] /
1 import { AfterViewInit, Component, OnInit, ViewChild, SimpleChange, Input } from '@angular/core';
2 import { MatPaginator } from '@angular/material/paginator';
3 import { MatSort } from '@angular/material/sort';
4 import { MatTable } from '@angular/material/table';
5 import { DataTableDataSource, DataTableItem } from './column-list-datasource';
6 import { HttpClient } from '@angular/common/http';
7 import { environment } from '../../../../../../../environments/environment';
8 import { ColumnService } from '../column.service';
9
10 @Component({
11   selector: 'app-column-list',
12   templateUrl: './column-list.component.html',
13   styleUrls: ['./column-list.component.css']
14 })
15 export class ColumnListComponent implements OnInit {
16   @ViewChild(MatPaginator, {static: false} as any) paginator: MatPaginator;
17   @ViewChild(MatSort, {static: false} as any) sort: MatSort;
18   @ViewChild(MatTable, {static: false} as any) table: MatTable<DataTableItem>;
19
20   @Input("reportId") reportId : number;
21
22   
23   dataSource: DataTableDataSource;
24   finalGetObj : {};
25   finalEditRowGetObj : {};
26   finalObjArr: DataTableItem[];
27   status : string;
28   message : string;
29   showDialog : boolean;
30   closable : boolean;
31
32   columnId : string;
33   id : string;
34   name : string;
35   noWrap : boolean;
36   visible : boolean;
37   dependsOnFormFields : string;
38   dataType : string;
39   groupByPos : string;
40   customTextForSubTotal : string;
41   hideRepeatedValues : boolean;
42   multiGroupColumnLevel;
43   colspan : string;
44   displayName : string;
45   displayWidthInPixel : string;
46   indentation : string;
47   displayAlignment : string;
48   displayHeaderAlignment : string;
49   sortable : boolean;
50   drilldownURL : string;
51   displayTotal : string;
52   URLListObj : {};
53   URLListObjArray : {}[];
54   TotalColListObj : {};
55   TotalColListObjArray : {}[];
56   finalPOSTObj : {};
57   isDisabled: boolean;
58   showConfirmButton: boolean;
59
60   /** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
61   displayedColumns = ['no', 'id', 'name', 'edit'];
62   SQLstatus: string;
63   SQLmessage: string;
64   showSaveColDialog: boolean;
65   Colclosable: boolean;
66   EditColmessage: string;
67   EditColstatus: string;
68
69   showEditDrillDownPage : boolean;
70   drillDownReportId : string;
71   drilldownParams : string;
72   drilldownType : string;
73   drillDownObj : {};
74   checkCnt : number;
75
76   constructor(private _http : HttpClient, private _columnService : ColumnService){
77
78     this.showEditDrillDownPage = false;
79     this.showConfirmButton = false;
80
81     this.dataSource = new DataTableDataSource();
82
83     this.finalGetObj = new Object();
84     this.finalObjArr = new Array();
85     this.finalEditRowGetObj = new Object();
86   this.URLListObjArray = new Array();
87   this.TotalColListObjArray = new Array();
88     this.finalPOSTObj = new Object();
89     this.drillDownObj = new Object();
90     this.checkCnt = 0;
91
92   }
93
94   ngOnInit() {
95     this._columnService.getColumnList()
96     .subscribe((response) => {
97       //console.log(response);
98
99      this.finalGetObj = response;
100
101      let k=0;
102      while(this.finalGetObj[k])
103      {
104       this.finalGetObj[k]["no"] = k+1;
105       this.finalGetObj[k]["edit"] = "";
106
107       this.finalObjArr.push(this.finalGetObj[k]);
108     
109
110       //console.log(this.finalObjArr);
111       k++;
112      }
113
114
115      
116
117       this.dataSource.data = this.finalObjArr;
118
119       this.dataSource.sort = this.sort;
120     this.dataSource.paginator = this.paginator;
121     this.table.dataSource = this.dataSource;
122     this.dataSource.data = this.finalObjArr;
123       //this.dataSource.data = [{id:"1", no:1, name:"1", edit:""}];
124     });
125     this.showDialog = false;
126     this.showSaveColDialog =false;
127     
128     
129   }
130
131
132   ngDoCheck()
133   {
134     this.drillDownReportId = this.drilldownURL;
135     this.drillDownObj["drillDownUrl"] = this.drilldownURL;
136     this.drillDownObj["drillDownParams"] = this.drilldownParams;
137     this.drillDownObj["drillDownType"] = this.drilldownType;
138
139     
140     
141   }
142
143
144   editRecord(id : string)
145   {
146     this.columnId = id;
147     this._columnService.getIndividualColumnData(id)
148     .subscribe((response) => {
149       this.finalEditRowGetObj = response;
150       //console.log(response);
151
152       this.id = this.finalEditRowGetObj["colId"];
153       this.name = this.finalEditRowGetObj["colName"];
154
155       this.noWrap = (this.finalEditRowGetObj["noWrap"] === "Y" ? true : false);
156       this.visible = this.finalEditRowGetObj["visible"];
157
158       this.dependsOnFormFields = this.finalEditRowGetObj["depeondsOnForField"];
159       this.dataType = this.finalEditRowGetObj["dataType"];
160       this.groupByPos = (this.finalEditRowGetObj["groupByPos"] == null ? 0 : this.finalEditRowGetObj["groupByPos"] );
161       this.customTextForSubTotal = this.finalEditRowGetObj["subTotalCustomText"];
162       this.hideRepeatedValues = this.finalEditRowGetObj["hideRepeatedKey"];
163       this.multiGroupColumnLevel = (this.finalEditRowGetObj["level"] == null ? 0 : this.finalEditRowGetObj["level"]);
164       this.colspan  = (this.finalEditRowGetObj["colspan"] == null ? 0 : this.finalEditRowGetObj["colspan"]);
165       this.displayName = this.finalEditRowGetObj["displayName"];
166       this.displayWidthInPixel = (this.finalEditRowGetObj["displayWidthInPixel"] == null ? 0 : this.finalEditRowGetObj["displayWidthInPixel"] );
167       this.indentation = (this.finalEditRowGetObj["indentation"] == null ? 0 : this.finalEditRowGetObj["indentation"]);
168       this.displayAlignment = this.finalEditRowGetObj["displayAlignment"];
169       this.displayHeaderAlignment = (this.finalEditRowGetObj["displayHeaderAlignment"] == null ? "" : this.finalEditRowGetObj["displayHeaderAlignment"]);
170       this.sortable = this.finalEditRowGetObj["sortable"];
171       this.drilldownURL = this.finalEditRowGetObj["drilldownURL"];
172       this.drilldownParams = this.finalEditRowGetObj["drilldownParams"];
173       this.drilldownType = this.finalEditRowGetObj["drilldownType"];
174
175       this. displayTotal = (this.finalEditRowGetObj["displayTotal"] == null ? "" : this.finalEditRowGetObj["displayTotal"]);
176
177
178       this._columnService.getDrillDownReportList()
179       .subscribe((responseURLList) => {
180         
181         this.URLListObj = responseURLList;
182
183         let l=0;
184         while(this.URLListObj[l])
185         {
186             this.URLListObjArray.push(this.URLListObj[l]);
187             l++;
188         }
189         //console.log(this.URLListObjArray);
190
191       });
192
193
194       this._columnService.getResponseTotalColsList()
195       .subscribe((responseTotalColList) => {
196         //console.log(responseTotalColList);
197
198         this.TotalColListObj = responseTotalColList;
199
200         let l=0;
201         while(this.TotalColListObj[l])
202         {
203             this.TotalColListObjArray.push(this.TotalColListObj[l]);
204             l++;
205         }
206         //console.log(this.TotalColListObjArray);
207       });
208
209       this.status = "Success!";
210       this.message = "Report Column - Edit";
211         this.showDialog = !this.showDialog;
212         this.closable = true; 
213     });
214
215
216     
217   }
218
219   
220   close() {
221
222     this._columnService.getColumnList()
223     .subscribe((response) => {
224       //console.log(response);
225
226       this.finalObjArr = [];
227       
228      this.finalGetObj = response;
229
230      let k=0;
231      while(this.finalGetObj[k])
232      {
233       this.finalGetObj[k]["no"] = k+1;
234       this.finalGetObj[k]["edit"] = "";
235
236       this.finalObjArr.push(this.finalGetObj[k]);
237     
238
239       //console.log(this.finalObjArr);
240       k++;
241      }
242
243
244      
245
246       this.dataSource.data = this.finalObjArr;
247
248       this.dataSource.sort = this.sort;
249     this.dataSource.paginator = this.paginator;
250     this.table.dataSource = this.dataSource;
251     this.dataSource.data = this.finalObjArr;
252       //this.dataSource.data = [{id:"1", no:1, name:"1", edit:""}];
253     });
254     this.showDialog = false;
255     this.showSaveColDialog =false;
256
257     // this.showDialog = !this.showDialog;
258     this.closable = false;
259
260     // this.showSaveColDialog =false;
261     this.showEditDrillDownPage = false;
262     this.Colclosable = false;
263     this.showConfirmButton = false;
264   }
265
266   complete()
267   {
268     this.showEditDrillDownPage = !this.showEditDrillDownPage;
269     this.showConfirmButton = false;
270   }
271
272   onCompleted(arr : any)
273   {
274       console.log(arr);
275   }
276
277
278   save()
279   {
280
281     
282
283     this.finalPOSTObj["tabId"] = "ColEdit";
284     this.finalPOSTObj["tabName"] = "Column Edit";
285
286     this.finalPOSTObj["colId"] = this.id;
287     this.finalPOSTObj["colName"] = this.name;
288
289     this.finalPOSTObj["colType"] = "";
290     this.finalPOSTObj["colspan"] = this.colspan;
291     this.finalPOSTObj["dataType"] = this.dataType;
292     this.finalPOSTObj["depeondsOnForField"] = this.dependsOnFormFields;
293     this.finalPOSTObj["displayAlignment"] = this.displayAlignment;
294     this.finalPOSTObj["displayHeaderAlignment"] = this.displayHeaderAlignment;
295     this.finalPOSTObj["displayName"] = this.displayName;
296     this.finalPOSTObj["displayTotal"] = this.displayTotal;
297     this.finalPOSTObj["displayWidth"] = 10;
298     this.finalPOSTObj["displayWidthInPixel"] = this.displayWidthInPixel;
299     this.finalPOSTObj["drilldownParams"] = "";
300     this.finalPOSTObj["drilldownType"] = "";
301     this.finalPOSTObj["drilldownURL"] = this.drilldownURL;
302     this.finalPOSTObj["errorMessage"] = "";
303     this.finalPOSTObj["errorStackTrace"] = "";
304     this.finalPOSTObj["groupByPos"] = this.groupByPos;
305     this.finalPOSTObj["hideRepeatedKey"] = this.hideRepeatedValues;
306     this.finalPOSTObj["indentation"] = this.indentation;
307     this.finalPOSTObj["level"] = this.multiGroupColumnLevel;
308     this.finalPOSTObj["noWrap"] = (this.noWrap === true? "Y" : "N");
309     this.finalPOSTObj["sortable"] = this.sortable;
310     this.finalPOSTObj["subTotalCustomText"] = this.displayTotal;
311     this.finalPOSTObj["visible"] = this.visible;
312
313     //console.log(this.finalPOSTObj);
314
315     this._columnService.postColumnChanges(this.finalPOSTObj)
316     .subscribe((finalPOSTResponse) => {
317       console.log(finalPOSTResponse);
318
319       if(finalPOSTResponse)
320       {
321         this.EditColstatus = "Success!";
322         this.EditColmessage = "Your change has been saved! Row definition is updated.";
323           this.showSaveColDialog = !this.showSaveColDialog;
324           
325           this.Colclosable = true; 
326     
327       }
328       else
329       {
330         this.EditColstatus = "Failure!";
331         this.EditColmessage = "Row definition could not be updated.";
332           this.showSaveColDialog = !this.showSaveColDialog;
333           
334           this.Colclosable = true;
335       }
336
337       this.showEditDrillDownPage = false;
338     });
339
340     
341     console.log("Saved!!!");
342   }
343
344
345   drillDownLinkPage()
346   {
347       this.showEditDrillDownPage = !this.showEditDrillDownPage;
348       this.showConfirmButton = true;
349   }
350
351
352 }