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';
11 selector: 'app-column-list',
12 templateUrl: './column-list.component.html',
13 styleUrls: ['./column-list.component.css']
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>;
20 @Input("reportId") reportId : number;
23 dataSource: DataTableDataSource;
25 finalEditRowGetObj : {};
26 finalObjArr: DataTableItem[];
37 dependsOnFormFields : string;
40 customTextForSubTotal : string;
41 hideRepeatedValues : boolean;
42 multiGroupColumnLevel;
45 displayWidthInPixel : string;
47 displayAlignment : string;
48 displayHeaderAlignment : string;
50 drilldownURL : string;
51 displayTotal : string;
53 URLListObjArray : {}[];
55 TotalColListObjArray : {}[];
58 showConfirmButton: boolean;
60 /** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
61 displayedColumns = ['no', 'id', 'name', 'edit'];
64 showSaveColDialog: boolean;
66 EditColmessage: string;
67 EditColstatus: string;
69 showEditDrillDownPage : boolean;
70 drillDownReportId : string;
71 drilldownParams : string;
72 drilldownType : string;
76 constructor(private _http : HttpClient, private _columnService : ColumnService){
78 this.showEditDrillDownPage = false;
79 this.showConfirmButton = false;
81 this.dataSource = new DataTableDataSource();
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();
95 this._columnService.getColumnList()
96 .subscribe((response) => {
97 //console.log(response);
99 this.finalGetObj = response;
102 while(this.finalGetObj[k])
104 this.finalGetObj[k]["no"] = k+1;
105 this.finalGetObj[k]["edit"] = "";
107 this.finalObjArr.push(this.finalGetObj[k]);
110 //console.log(this.finalObjArr);
117 this.dataSource.data = this.finalObjArr;
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:""}];
125 this.showDialog = false;
126 this.showSaveColDialog =false;
134 this.drillDownReportId = this.drilldownURL;
135 this.drillDownObj["drillDownUrl"] = this.drilldownURL;
136 this.drillDownObj["drillDownParams"] = this.drilldownParams;
137 this.drillDownObj["drillDownType"] = this.drilldownType;
144 editRecord(id : string)
147 this._columnService.getIndividualColumnData(id)
148 .subscribe((response) => {
149 this.finalEditRowGetObj = response;
150 //console.log(response);
152 this.id = this.finalEditRowGetObj["colId"];
153 this.name = this.finalEditRowGetObj["colName"];
155 this.noWrap = (this.finalEditRowGetObj["noWrap"] === "Y" ? true : false);
156 this.visible = this.finalEditRowGetObj["visible"];
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"];
175 this. displayTotal = (this.finalEditRowGetObj["displayTotal"] == null ? "" : this.finalEditRowGetObj["displayTotal"]);
178 this._columnService.getDrillDownReportList()
179 .subscribe((responseURLList) => {
181 this.URLListObj = responseURLList;
184 while(this.URLListObj[l])
186 this.URLListObjArray.push(this.URLListObj[l]);
189 //console.log(this.URLListObjArray);
194 this._columnService.getResponseTotalColsList()
195 .subscribe((responseTotalColList) => {
196 //console.log(responseTotalColList);
198 this.TotalColListObj = responseTotalColList;
201 while(this.TotalColListObj[l])
203 this.TotalColListObjArray.push(this.TotalColListObj[l]);
206 //console.log(this.TotalColListObjArray);
209 this.status = "Success!";
210 this.message = "Report Column - Edit";
211 this.showDialog = !this.showDialog;
212 this.closable = true;
222 this._columnService.getColumnList()
223 .subscribe((response) => {
224 //console.log(response);
226 this.finalObjArr = [];
228 this.finalGetObj = response;
231 while(this.finalGetObj[k])
233 this.finalGetObj[k]["no"] = k+1;
234 this.finalGetObj[k]["edit"] = "";
236 this.finalObjArr.push(this.finalGetObj[k]);
239 //console.log(this.finalObjArr);
246 this.dataSource.data = this.finalObjArr;
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:""}];
254 this.showDialog = false;
255 this.showSaveColDialog =false;
257 // this.showDialog = !this.showDialog;
258 this.closable = false;
260 // this.showSaveColDialog =false;
261 this.showEditDrillDownPage = false;
262 this.Colclosable = false;
263 this.showConfirmButton = false;
268 this.showEditDrillDownPage = !this.showEditDrillDownPage;
269 this.showConfirmButton = false;
272 onCompleted(arr : any)
283 this.finalPOSTObj["tabId"] = "ColEdit";
284 this.finalPOSTObj["tabName"] = "Column Edit";
286 this.finalPOSTObj["colId"] = this.id;
287 this.finalPOSTObj["colName"] = this.name;
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;
313 //console.log(this.finalPOSTObj);
315 this._columnService.postColumnChanges(this.finalPOSTObj)
316 .subscribe((finalPOSTResponse) => {
317 console.log(finalPOSTResponse);
319 if(finalPOSTResponse)
321 this.EditColstatus = "Success!";
322 this.EditColmessage = "Your change has been saved! Row definition is updated.";
323 this.showSaveColDialog = !this.showSaveColDialog;
325 this.Colclosable = true;
330 this.EditColstatus = "Failure!";
331 this.EditColmessage = "Row definition could not be updated.";
332 this.showSaveColDialog = !this.showSaveColDialog;
334 this.Colclosable = true;
337 this.showEditDrillDownPage = false;
341 console.log("Saved!!!");
347 this.showEditDrillDownPage = !this.showEditDrillDownPage;
348 this.showConfirmButton = true;