1 import { AfterViewInit, Component, OnInit, ViewChild, SimpleChange } 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>;
21 dataSource: DataTableDataSource;
23 finalEditRowGetObj : {};
24 finalObjArr: DataTableItem[];
35 dependsOnFormFields : string;
38 customTextForSubTotal : string;
39 hideRepeatedValues : boolean;
40 multiGroupColumnLevel;
43 displayWidthInPixel : string;
45 displayAlignment : string;
46 displayHeaderAlignment : string;
48 drilldownURL : string;
49 displayTotal : string;
51 URLListObjArray : {}[];
53 TotalColListObjArray : {}[];
58 /** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
59 displayedColumns = ['no', 'id', 'name', 'edit'];
62 showSaveColDialog: boolean;
64 EditColmessage: string;
65 EditColstatus: string;
67 constructor(private _http : HttpClient, private _columnService : ColumnService){
69 this.dataSource = new DataTableDataSource();
71 this.finalGetObj = new Object();
72 this.finalObjArr = new Array();
73 this.finalEditRowGetObj = new Object();
74 this.URLListObjArray = new Array();
75 this.TotalColListObjArray = new Array();
76 this.finalPOSTObj = new Object();
81 this._columnService.getColumnList()
82 .subscribe((response) => {
83 //console.log(response);
85 this.finalGetObj = response;
88 while(this.finalGetObj[k])
90 this.finalGetObj[k]["no"] = k+1;
91 this.finalGetObj[k]["edit"] = "";
93 this.finalObjArr.push(this.finalGetObj[k]);
95 //console.log(this.finalObjArr);
102 this.dataSource.data = this.finalObjArr;
104 this.dataSource.sort = this.sort;
105 this.dataSource.paginator = this.paginator;
106 this.table.dataSource = this.dataSource;
107 this.dataSource.data = this.finalObjArr;
108 //this.dataSource.data = [{id:"1", no:1, name:"1", edit:""}];
110 this.showDialog = false;
111 this.showSaveColDialog =false;
120 editRecord(id : string)
123 this._columnService.getIndividualColumnData(id)
124 .subscribe((response) => {
125 this.finalEditRowGetObj = response;
126 //console.log(response);
128 this.id = this.finalEditRowGetObj["colId"];
129 this.name = this.finalEditRowGetObj["colName"];
131 this.noWrap = (this.finalEditRowGetObj["noWrap"] === "Y" ? true : false);
132 this.visible = this.finalEditRowGetObj["visible"];
134 this.dependsOnFormFields = this.finalEditRowGetObj["depeondsOnForField"];
135 this.dataType = this.finalEditRowGetObj["dataType"];
136 this.groupByPos = (this.finalEditRowGetObj["groupByPos"] == null ? 0 : this.finalEditRowGetObj["groupByPos"] );
137 this.customTextForSubTotal = this.finalEditRowGetObj["subTotalCustomText"];
138 this.hideRepeatedValues = this.finalEditRowGetObj["hideRepeatedKey"];
139 this.multiGroupColumnLevel = (this.finalEditRowGetObj["level"] == null ? 0 : this.finalEditRowGetObj["level"]);
140 this.colspan = (this.finalEditRowGetObj["colspan"] == null ? 0 : this.finalEditRowGetObj["colspan"]);
141 this.displayName = this.finalEditRowGetObj["displayName"];
142 this.displayWidthInPixel = (this.finalEditRowGetObj["displayWidthInPixel"] == null ? 0 : this.finalEditRowGetObj["displayWidthInPixel"] );
143 this.indentation = (this.finalEditRowGetObj["indentation"] == null ? 0 : this.finalEditRowGetObj["indentation"]);
144 this.displayAlignment = this.finalEditRowGetObj["displayAlignment"];
145 this.displayHeaderAlignment = (this.finalEditRowGetObj["displayHeaderAlignment"] == null ? "" : this.finalEditRowGetObj["displayHeaderAlignment"]);
146 this.sortable = this.finalEditRowGetObj["sortable"];
147 this.drilldownURL = this.finalEditRowGetObj["drilldownURL"];
148 this. displayTotal = (this.finalEditRowGetObj["displayTotal"] == null ? "" : this.finalEditRowGetObj["displayTotal"]);
151 this._columnService.getDrillDownReportList()
152 .subscribe((responseURLList) => {
154 this.URLListObj = responseURLList;
157 while(this.URLListObj[l])
159 this.URLListObjArray.push(this.URLListObj[l]);
162 //console.log(this.URLListObjArray);
167 this._columnService.getResponseTotalColsList()
168 .subscribe((responseTotalColList) => {
169 //console.log(responseTotalColList);
171 this.TotalColListObj = responseTotalColList;
174 while(this.TotalColListObj[l])
176 this.TotalColListObjArray.push(this.TotalColListObj[l]);
179 //console.log(this.TotalColListObjArray);
182 this.status = "Success!";
183 this.message = "Report Column - Edit";
184 this.showDialog = !this.showDialog;
185 this.closable = true;
195 this.showDialog = !this.showDialog;
196 this.closable = false;
198 this.showSaveColDialog =false;
199 this.Colclosable = false;
206 this.showDialog = !this.showDialog;
207 this.closable = true;
209 this.finalPOSTObj["tabId"] = "ColEdit";
210 this.finalPOSTObj["tabName"] = "Column Edit";
212 this.finalPOSTObj["colId"] = this.id;
213 this.finalPOSTObj["colName"] = this.name;
215 this.finalPOSTObj["colType"] = "";
216 this.finalPOSTObj["colspan"] = this.colspan;
217 this.finalPOSTObj["dataType"] = this.dataType;
218 this.finalPOSTObj["depeondsOnForField"] = this.dependsOnFormFields;
219 this.finalPOSTObj["displayAlignment"] = this.displayAlignment;
220 this.finalPOSTObj["displayHeaderAlignment"] = this.displayHeaderAlignment;
221 this.finalPOSTObj["displayName"] = this.displayName;
222 this.finalPOSTObj["displayTotal"] = this.displayTotal;
223 this.finalPOSTObj["displayWidth"] = 10;
224 this.finalPOSTObj["displayWidthInPixel"] = this.displayWidthInPixel;
225 this.finalPOSTObj["drilldownParams"] = "";
226 this.finalPOSTObj["drilldownType"] = "";
227 this.finalPOSTObj["drilldownURL"] = this.drilldownURL;
228 this.finalPOSTObj["errorMessage"] = "";
229 this.finalPOSTObj["errorStackTrace"] = "";
230 this.finalPOSTObj["groupByPos"] = this.groupByPos;
231 this.finalPOSTObj["hideRepeatedKey"] = this.hideRepeatedValues;
232 this.finalPOSTObj["indentation"] = this.indentation;
233 this.finalPOSTObj["level"] = this.multiGroupColumnLevel;
234 this.finalPOSTObj["noWrap"] = (this.noWrap === true? "Y" : "N");
235 this.finalPOSTObj["sortable"] = this.sortable;
236 this.finalPOSTObj["subTotalCustomText"] = this.displayTotal;
237 this.finalPOSTObj["visible"] = this.visible;
239 //console.log(this.finalPOSTObj);
241 this._columnService.postColumnChanges(this.finalPOSTObj)
242 .subscribe((finalPOSTResponse) => {
243 console.log(finalPOSTResponse);
245 if(finalPOSTResponse)
247 this.EditColstatus = "Success!";
248 this.EditColmessage = "Your change has been saved! Row definition is updated.";
249 this.showSaveColDialog = !this.showSaveColDialog;
250 this.Colclosable = true;
254 this.EditColstatus = "Failure!";
255 this.EditColmessage = "Row definition could not be updated.";
256 this.showSaveColDialog = !this.showSaveColDialog;
257 this.Colclosable = true;
264 console.log("Saved!!!");