1 import { AfterViewInit, Component, OnInit, ViewChild, SimpleChange, Input, Output } 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 import {SemaphoreList} from '../model/semaphore-list';
10 import {Semaphore} from '../model/semaphore';
13 selector: 'app-column-list',
14 templateUrl: './column-list.component.html',
15 styleUrls: ['./column-list.component.css']
17 export class ColumnListComponent implements OnInit {
18 @ViewChild(MatPaginator, {static: false} as any) paginator: MatPaginator;
19 @ViewChild(MatSort, {static: false} as any) sort: MatSort;
20 @ViewChild(MatTable, {static: false} as any) table: MatTable<DataTableItem>;
22 @Input('reportId') reportId: number;
26 dataSource: DataTableDataSource;
28 finalEditRowGetObj: {};
29 finalObjArr: DataTableItem[];
40 dependsOnFormFields: string;
43 customTextForSubTotal: string;
44 hideRepeatedValues: boolean;
45 multiGroupColumnLevel;
48 displayWidthInPixel: string;
50 displayAlignment: string;
51 displayHeaderAlignment: string;
56 URLListObjArray: {}[];
58 TotalColListObjArray: {}[];
61 showConfirmButton: boolean;
63 /** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
64 displayedColumns = ['no', 'id', 'name', 'edit'];
67 showSaveColDialog: boolean;
69 EditColmessage: string;
70 EditColstatus: string;
72 showEditDrillDownPage: boolean;
73 showAdvancedDisplayPage = false;
74 drillDownReportId: string;
75 drilldownParams: string;
76 drilldownType: string;
80 displayTable: boolean;
81 semaphoreList: SemaphoreList;
82 semaphoreName: String;
84 private newSemaphoreList: any;
85 private addDisplay = false;
86 incomingDrillDownParams: string;
87 isIncomingDrillDownParams: boolean;
89 constructor(private _http: HttpClient, private _columnService: ColumnService) {
91 this.showEditDrillDownPage = false;
92 this.showAdvancedDisplayPage = false;
93 this.showConfirmButton = false;
94 this.addDisplay = false;
96 this.dataSource = new DataTableDataSource();
98 this.finalGetObj = new Object();
99 this.finalObjArr = new Array();
100 this.finalEditRowGetObj = new Object();
101 this.URLListObjArray = new Array();
102 this.TotalColListObjArray = new Array();
103 this.finalPOSTObj = new Object();
104 this.drillDownObj = new Object();
106 this.showSpinner = false;
107 this.semaphoreList = new class implements SemaphoreList {
108 semaphore: Semaphore[];
110 this.semaphoreName = 'No Display';
111 this.incomingDrillDownParams = '';
112 this.isIncomingDrillDownParams = false;
117 this.showSpinner = true;
118 this.displayTable = true;
119 this._columnService.getColumnList()
120 .subscribe((response) => {
121 this.showSpinner = true;
122 this.finalGetObj = response;
124 while (this.finalGetObj[fgo_counter]) {
125 this.finalGetObj[fgo_counter]['no'] = fgo_counter + 1;
126 this.finalGetObj[fgo_counter]['edit'] = '';
127 this.finalObjArr.push(this.finalGetObj[fgo_counter]);
130 this.dataSource.data = this.finalObjArr;
131 this.dataSource.sort = this.sort;
132 this.dataSource.paginator = this.paginator;
133 this.table.dataSource = this.dataSource;
134 this.dataSource.data = this.finalObjArr;
135 this.showSpinner = false;
137 this.showDialog = false;
138 this.showSaveColDialog = false;
145 this.drillDownReportId = this.drilldownURL;
146 this.drillDownObj['drillDownUrl'] = this.drilldownURL;
147 this.drillDownObj['drillDownParams'] = this.drilldownParams;
148 this.drillDownObj['drillDownType'] = this.drilldownType;
152 editRecord(id: string) {
153 this.showSpinner = true;
156 this._columnService.getIndividualColumnData(id)
157 .subscribe((response) => {
158 this.finalEditRowGetObj = response;
159 this.id = this.finalEditRowGetObj['colId'];
160 this.name = this.finalEditRowGetObj['colName'];
161 this.noWrap = (this.finalEditRowGetObj['noWrap'] === 'Y' ? true : false);
162 this.visible = this.finalEditRowGetObj['visible'];
163 this.dependsOnFormFields = this.finalEditRowGetObj['depeondsOnForField'];
164 this.dataType = this.finalEditRowGetObj['dataType'];
165 this.groupByPos = (this.finalEditRowGetObj['groupByPos'] == null ? 0 : this.finalEditRowGetObj['groupByPos'] );
166 this.customTextForSubTotal = this.finalEditRowGetObj['subTotalCustomText'];
167 this.hideRepeatedValues = this.finalEditRowGetObj['hideRepeatedKey'];
168 this.multiGroupColumnLevel = (this.finalEditRowGetObj['level'] == null ? 0 : this.finalEditRowGetObj['level']);
169 this.colspan = (this.finalEditRowGetObj['colspan'] == null ? 0 : this.finalEditRowGetObj['colspan']);
170 this.displayName = this.finalEditRowGetObj['displayName'];
171 this.displayWidthInPixel = (this.finalEditRowGetObj['displayWidthInPixel'] == null ? 0 : this.finalEditRowGetObj['displayWidthInPixel'] );
172 this.indentation = (this.finalEditRowGetObj['indentation'] == null ? 0 : this.finalEditRowGetObj['indentation']);
173 this.displayAlignment = this.finalEditRowGetObj['displayAlignment'];
174 this.displayHeaderAlignment = (this.finalEditRowGetObj['displayHeaderAlignment'] == null ? '' : this.finalEditRowGetObj['displayHeaderAlignment']);
175 this.sortable = this.finalEditRowGetObj['sortable'];
176 this.drilldownURL = this.finalEditRowGetObj['drilldownURL'];
177 this.drilldownParams = this.finalEditRowGetObj['drilldownParams'];
178 this.drilldownType = this.finalEditRowGetObj['drilldownType'];
179 this.drillDownObj['drillDownUrl'] = this.drilldownURL;
180 this.drillDownObj['drillDownParams'] = this.drilldownParams;
181 this.drillDownObj['drillDownType'] = this.drilldownType;
182 this.semaphoreList = this.finalEditRowGetObj['semaphoreList'];
183 this.semaphoreId = this.finalEditRowGetObj['semaphoreId'];
184 if (this.semaphoreId === '') {
185 this.semaphoreName = 'No Display';
187 if(this.semaphoreList && this.semaphoreList.semaphore){
188 for (let semCtr = 0; semCtr < this.semaphoreList.semaphore.length; semCtr++) {
189 if (this.semaphoreId === this.semaphoreList.semaphore[semCtr]['semaphoreId']) {
190 this.semaphoreName = this.semaphoreList.semaphore[semCtr]['semaphoreName'];
195 this. displayTotal = (this.finalEditRowGetObj['displayTotal'] == null ? '' : this.finalEditRowGetObj['displayTotal']);
196 this._columnService.getDrillDownReportList()
197 .subscribe((responseURLList) => {
198 this.URLListObj = responseURLList;
201 while (this.URLListObj[listCtr]) {
202 this.URLListObjArray.push(this.URLListObj[listCtr]);
207 this._columnService.getResponseTotalColsList()
208 .subscribe((responseTotalColList) => {
209 this.TotalColListObj = responseTotalColList;
211 while (this.TotalColListObj[colCtr]) {
212 this.TotalColListObjArray.push(this.TotalColListObj[colCtr]);
216 this.status = 'Success!';
217 this.message = 'Report Column - Edit';
218 this.showDialog = !this.showDialog;
219 this.closable = true;
220 this.showSpinner = false;
230 this._columnService.getColumnList()
231 .subscribe((response) => {
232 this.showSpinner = true;
233 this.dataSource = new DataTableDataSource();
234 this.finalObjArr = [];
235 this.finalGetObj = response;
238 while (this.finalGetObj[fgo_counter]) {
239 this.finalGetObj[fgo_counter]['no'] = fgo_counter + 1;
240 this.finalGetObj[fgo_counter]['edit'] = '';
241 this.finalObjArr.push(this.finalGetObj[fgo_counter]);
244 this.dataSource.data = this.finalObjArr;
245 this.dataSource.sort = this.sort;
246 this.dataSource.paginator = this.paginator;
247 this.table.dataSource = this.dataSource;
248 this.dataSource.data = this.finalObjArr;
249 this.showSpinner = false;
251 this.showDialog = false;
252 this.showSaveColDialog = false;
253 this.closable = false;
254 this.showEditDrillDownPage = false;
255 this.showAdvancedDisplayPage = false;
256 this.addDisplay = false;
257 this.Colclosable = false;
258 this.showConfirmButton = false;
262 this.showEditDrillDownPage = !this.showEditDrillDownPage;
263 this.showConfirmButton = false;
264 this.isIncomingDrillDownParams = true;
267 onCompleted(drilldownParamsArr: any) {
268 this.incomingDrillDownParams = drilldownParamsArr;
274 this.showSpinner = true;
276 this.finalPOSTObj['tabId'] = 'ColEdit';
277 this.finalPOSTObj['tabName'] = 'Column Edit';
279 this.finalPOSTObj['colId'] = this.id;
280 this.finalPOSTObj['colName'] = this.name;
282 this.finalPOSTObj['colType'] = '';
283 this.finalPOSTObj['colspan'] = this.colspan;
284 this.finalPOSTObj['dataType'] = this.dataType;
285 this.finalPOSTObj['depeondsOnForField'] = this.dependsOnFormFields;
286 this.finalPOSTObj['displayAlignment'] = this.displayAlignment;
287 this.finalPOSTObj['displayHeaderAlignment'] = this.displayHeaderAlignment;
288 this.finalPOSTObj['displayName'] = this.displayName;
289 this.finalPOSTObj['displayTotal'] = this.displayTotal;
290 this.finalPOSTObj['displayWidth'] = 10;
291 this.finalPOSTObj['displayWidthInPixel'] = this.displayWidthInPixel;
292 if (this.isIncomingDrillDownParams) {
293 this.finalPOSTObj['drilldownParams'] = this.incomingDrillDownParams;
295 this.finalPOSTObj['drilldownParams'] = this.drilldownParams;
297 this.finalPOSTObj['drilldownType'] = '';
298 this.finalPOSTObj['drilldownURL'] = this.drilldownURL;
299 this.finalPOSTObj['errorMessage'] = '';
300 this.finalPOSTObj['errorStackTrace'] = '';
301 this.finalPOSTObj['groupByPos'] = this.groupByPos;
302 this.finalPOSTObj['hideRepeatedKey'] = this.hideRepeatedValues;
303 this.finalPOSTObj['indentation'] = this.indentation;
304 this.finalPOSTObj['level'] = this.multiGroupColumnLevel;
305 this.finalPOSTObj['noWrap'] = (this.noWrap === true ? 'Y' : 'N');
306 this.finalPOSTObj['sortable'] = this.sortable;
307 this.finalPOSTObj['subTotalCustomText'] = this.displayTotal;
308 this.finalPOSTObj['visible'] = this.visible;
309 if (this.semaphoreName === 'No Display') {
310 this.semaphoreId = '';
312 for ( let slcount = 0 ; slcount < this.semaphoreList.semaphore.length; slcount++) {
313 if (this.semaphoreName === this.semaphoreList.semaphore[slcount].semaphoreName) {
314 this.semaphoreId = this.semaphoreList.semaphore[slcount].semaphoreId;
318 this.finalPOSTObj['semaphoreId'] = this.semaphoreId;
319 this.finalPOSTObj['semaphoreList'] = this.semaphoreList;
322 this._columnService.postColumnChanges(this.finalPOSTObj)
323 .subscribe((finalPOSTResponse) => {
325 if (finalPOSTResponse) {
326 this.EditColstatus = 'Success!';
327 this.EditColmessage = 'Your change has been saved! Row definition is updated.';
328 this.showSaveColDialog = !this.showSaveColDialog;
330 this.Colclosable = true;
333 this.EditColstatus = 'Failure!';
334 this.EditColmessage = 'Row definition could not be updated.';
335 this.showSaveColDialog = !this.showSaveColDialog;
337 this.Colclosable = true;
340 this.showEditDrillDownPage = false;
341 this.showAdvancedDisplayPage = false;
342 this.isIncomingDrillDownParams = false;
343 this.addDisplay = false;
344 this.showSpinner = false;
350 drillDownLinkPage() {
351 this.showEditDrillDownPage = !this.showEditDrillDownPage;
352 this.showConfirmButton = true;
356 this.showAdvancedDisplayPage = true;
360 finishAdvancedDisplay(displayObj: any) {
361 this.addDisplay = false;
362 this.semaphoreName = displayObj['semName'];
363 this.semaphoreList = displayObj['semList'];
364 this.semaphoreId = displayObj['semId'];
365 this.showAdvancedDisplayPage = displayObj['setCloseDisplay'];
369 this.showAdvancedDisplayPage = true;
370 this.addDisplay = true;