summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/columns/column-list/column-list.component.ts
blob: 193e5ad0752e3bd73661bf46b6cd5c89d78c4945 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
import {ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnInit, ViewChild} from '@angular/core';
import {MatPaginator} from '@angular/material/paginator';
import {MatSort} from '@angular/material/sort';
import {MatTable} from '@angular/material/table';
import {DataTableDataSource, DataTableItem} from './column-list-datasource';
import {HttpClient} from '@angular/common/http';
import {ColumnService} from '../column.service';
import {SemaphoreList} from '../model/semaphore-list';
import {Semaphore} from '../model/semaphore';

@Component({
    selector: 'app-column-list',
    templateUrl: './column-list.component.html',
    styleUrls: ['./column-list.component.css'],
})
export class ColumnListComponent implements OnInit {
    @ViewChild(MatPaginator, {static: false} as any) paginator: MatPaginator;
    @ViewChild(MatSort, {static: false} as any) sort: MatSort;
    @ViewChild(MatTable, {static: false} as any) table: MatTable<DataTableItem>;
    @Input('reportId') reportId: number;
    dataSource: DataTableDataSource;
    finalGetObj: {};
    finalEditRowGetObj: {};
    finalObjArr: DataTableItem[];
    status: string;
    message: string;
    showDialog: boolean;
    closable: boolean;
    columnId: string;
    id: string;
    name: string;
    noWrap: boolean;
    visible: boolean;
    dependsOnFormFields: string;
    dataType: string;
    groupByPos: string;
    customTextForSubTotal: string;
    hideRepeatedValues: boolean;
    multiGroupColumnLevel;
    colspan: string;
    displayName: string;
    displayWidthInPixel: string;
    indentation: string;
    displayAlignment: string;
    displayHeaderAlignment: string;
    sortable: boolean;
    drilldownURL: string;
    displayTotal: string;
    URLListObj: {};
    URLListObjArray: {}[];
    TotalColListObj: {};
    TotalColListObjArray: {}[];
    finalPOSTObj: {};
    isDisabled: boolean;
    showConfirmButton: boolean;
    displayedColumns = ['no', 'id', 'name', 'edit'];
    SQLstatus: string;
    SQLmessage: string;
    showSaveColDialog: boolean;
    Colclosable: boolean;
    EditColmessage: string;
    EditColstatus: string;
    showEditDrillDownPage: boolean;
    showAdvancedDisplayPage = false;
    drillDownReportId: string;
    drilldownParams: string;
    drilldownType: string;
    drillDownObj: {};
    checkCnt: number;
    showSpinner: boolean;
    displayTable: boolean;
    semaphoreList: SemaphoreList;
    semaphoreName: String;
    semaphoreId: String;
    incomingDrillDownParams: string;
    isIncomingDrillDownParams: boolean;
    SQLclosable: any;
    private newSemaphoreList: any;
    private addDisplay = false;
    columnList: any;

    constructor(private _http: HttpClient,
                private _columnService: ColumnService,
                private changeDetectorRefs: ChangeDetectorRef) {

        this.showEditDrillDownPage = false;
        this.showAdvancedDisplayPage = false;
        this.showConfirmButton = false;
        this.addDisplay = false;
        this.dataSource = new DataTableDataSource();
        this.finalGetObj = {};
        this.finalObjArr = [];
        this.finalEditRowGetObj = {};
        this.URLListObjArray = [];
        this.TotalColListObjArray = [];
        this.finalPOSTObj = {};
        this.drillDownObj = {};
        this.checkCnt = 0;
        this.showSpinner = false;
        this.semaphoreList = new class implements SemaphoreList {
            semaphore: Semaphore[];
        };
        this.semaphoreName = 'No Display';
        this.semaphoreId = '';
        this.incomingDrillDownParams = '';
        this.isIncomingDrillDownParams = false;
    }

    ngOnInit() {
        this.displayTable = true;
        this._columnService.getColumnList()
            .subscribe((response) => {
                this.showSpinner = true;
                this.finalGetObj = response;
                this.columnList = response;
                let fgo_counter = 0;
                while (this.finalGetObj[fgo_counter]) {
                    this.finalGetObj[fgo_counter]['no'] = fgo_counter + 1;
                    this.finalGetObj[fgo_counter]['edit'] = '';
                    this.finalObjArr.push(this.finalGetObj[fgo_counter]);
                    fgo_counter++;
                }
                this.dataSource.data = this.finalObjArr;
                this.dataSource.sort = this.sort;
                this.dataSource.paginator = this.paginator;
                this.table.dataSource = this.dataSource;
                this.dataSource.data = this.finalObjArr;
                this.showSpinner = false;
            });
        this.showDialog = false;
        this.showSaveColDialog = false;
    }


    ngDoCheck() {
        this.drillDownReportId = this.drilldownURL;
        this.drillDownObj['drillDownUrl'] = this.drilldownURL;
        this.drillDownObj['drillDownParams'] = this.drilldownParams;
        this.drillDownObj['drillDownType'] = this.drilldownType;
    }


    editRecord(id: string) {
        this.showSpinner = true;
        this.semaphoreList = new class implements SemaphoreList {
            semaphore: Semaphore[];
        };
        this.semaphoreName = 'No Display';
        this.semaphoreId = '';
        this.columnId = id;
        this._columnService.getIndividualColumnData(id)
            .subscribe((response) => {
                this.finalEditRowGetObj = response;
                this.id = this.finalEditRowGetObj['colId'];
                this.name = this.finalEditRowGetObj['colName'];
                this.noWrap = (this.finalEditRowGetObj['noWrap'] === 'Y' ? true : false);
                this.visible = this.finalEditRowGetObj['visible'];
                this.dependsOnFormFields = this.finalEditRowGetObj['depeondsOnForField'];
                this.dataType = this.finalEditRowGetObj['dataType'];
                this.groupByPos = (this.finalEditRowGetObj['groupByPos'] == null ? 0 : this.finalEditRowGetObj['groupByPos']);
                this.customTextForSubTotal = this.finalEditRowGetObj['subTotalCustomText'];
                this.hideRepeatedValues = this.finalEditRowGetObj['hideRepeatedKey'];
                this.multiGroupColumnLevel = (this.finalEditRowGetObj['level'] == null ? 0 : this.finalEditRowGetObj['level']);
                this.colspan = (this.finalEditRowGetObj['colspan'] == null ? 0 : this.finalEditRowGetObj['colspan']);
                this.displayName = this.finalEditRowGetObj['displayName'];
                this.displayWidthInPixel = (this.finalEditRowGetObj['displayWidthInPixel'] == null ? 0 : this.finalEditRowGetObj['displayWidthInPixel']);
                this.indentation = (this.finalEditRowGetObj['indentation'] == null ? 0 : this.finalEditRowGetObj['indentation']);
                this.displayAlignment = this.finalEditRowGetObj['displayAlignment'];
                this.displayHeaderAlignment = (this.finalEditRowGetObj['displayHeaderAlignment'] == null ? '' : this.finalEditRowGetObj['displayHeaderAlignment']);
                this.sortable = this.finalEditRowGetObj['sortable'];
                this.drilldownURL = this.finalEditRowGetObj['drilldownURL'];
                this.drilldownParams = this.finalEditRowGetObj['drilldownParams'];
                this.drilldownType = this.finalEditRowGetObj['drilldownType'];
                this.drillDownObj['drillDownUrl'] = this.drilldownURL;
                this.drillDownObj['drillDownParams'] = this.drilldownParams;
                this.drillDownObj['drillDownType'] = this.drilldownType;
                this.semaphoreList = this.finalEditRowGetObj['semaphoreList'];
                this.semaphoreId = this.finalEditRowGetObj['semaphoreId'];
                if (this.semaphoreId === '') {
                    this.semaphoreName = 'No Display';
                } else {
                    if(this.semaphoreList && this.semaphoreList.semaphore){
                        for (let semCtr = 0; semCtr < this.semaphoreList.semaphore.length; semCtr++) {
                            if (this.semaphoreId === this.semaphoreList.semaphore[semCtr]['semaphoreId']) {
                                this.semaphoreName = this.semaphoreList.semaphore[semCtr]['semaphoreName'];
                            }
                        }
                    }
                }
                this.displayTotal = (this.finalEditRowGetObj['displayTotal'] == null ? '' : this.finalEditRowGetObj['displayTotal']);
                this._columnService.getDrillDownReportList()
                    .subscribe((responseURLList) => {
                        this.URLListObj = responseURLList;

                        let listCtr = 0;
                        while (this.URLListObj[listCtr]) {
                            this.URLListObjArray.push(this.URLListObj[listCtr]);
                            listCtr++;
                        }
                    });
                this._columnService.getResponseTotalColsList()
                    .subscribe((responseTotalColList) => {
                        this.TotalColListObj = responseTotalColList;
                        let colCtr = 0;
                        while (this.TotalColListObj[colCtr]) {
                            this.TotalColListObjArray.push(this.TotalColListObj[colCtr]);
                            colCtr++;
                        }
                    });
                this.status = 'Success!';
                this.message = 'Report Column - Edit';
                this.showDialog = !this.showDialog;
                this.closable = true;
                this.showSpinner = false;
            });
    }

    ngOnChanges() {
        console.log('Hit');
    }


    close() {
        this.changeDetectorRefs.detectChanges();
        this._columnService.getColumnList()
            .subscribe((response) => {
                this.showSpinner = true;
                this.dataSource = new DataTableDataSource();
                this.finalObjArr = [];
                this.finalGetObj = response;
                let fgo_counter = 0;
                while (this.finalGetObj[fgo_counter]) {
                    this.finalGetObj[fgo_counter]['no'] = fgo_counter + 1;
                    this.finalGetObj[fgo_counter]['edit'] = '';
                    this.finalObjArr.push(this.finalGetObj[fgo_counter]);
                    fgo_counter++;
                }
                this.dataSource.data = this.finalObjArr;
                this.dataSource.sort = this.sort;
                this.dataSource.paginator = this.paginator;
                this.table.dataSource = this.dataSource;
                this.dataSource.data = this.finalObjArr;
                this.showSpinner = false;
            });
        this.showDialog = false;
        this.showSaveColDialog = false;
        this.closable = false;
        this.showEditDrillDownPage = false;
        this.showAdvancedDisplayPage = false;
        this.addDisplay = false;
        this.Colclosable = false;
        this.showConfirmButton = false;
    }

    complete() {
        this.showEditDrillDownPage = !this.showEditDrillDownPage;
        this.showConfirmButton = false;
        this.isIncomingDrillDownParams = true;
    }

    onCompleted(drilldownParamsArr: any) {
        this.incomingDrillDownParams = drilldownParamsArr;
    }


    save() {
        this.changeDetectorRefs.detectChanges();
        this.showSpinner = true;
        this.finalPOSTObj['tabId'] = 'ColEdit';
        this.finalPOSTObj['tabName'] = 'Column Edit';
        this.finalPOSTObj['colId'] = this.id;
        this.finalPOSTObj['colName'] = this.name;
        this.finalPOSTObj['colType'] = '';
        this.finalPOSTObj['colspan'] = this.colspan;
        this.finalPOSTObj['dataType'] = this.dataType;
        this.finalPOSTObj['depeondsOnForField'] = this.dependsOnFormFields;
        this.finalPOSTObj['displayAlignment'] = this.displayAlignment;
        this.finalPOSTObj['displayHeaderAlignment'] = this.displayHeaderAlignment;
        this.finalPOSTObj['displayName'] = this.displayName;
        this.finalPOSTObj['displayTotal'] = this.displayTotal;
        this.finalPOSTObj['displayWidth'] = 10;
        this.finalPOSTObj['displayWidthInPixel'] = this.displayWidthInPixel;
        if (this.isIncomingDrillDownParams) {
            this.finalPOSTObj['drilldownParams'] = this.incomingDrillDownParams;
        } else {
            this.finalPOSTObj['drilldownParams'] = this.drilldownParams;
        }
        this.finalPOSTObj['drilldownType'] = '';
        this.finalPOSTObj['drilldownURL'] = this.drilldownURL;
        this.finalPOSTObj['errorMessage'] = '';
        this.finalPOSTObj['errorStackTrace'] = '';
        this.finalPOSTObj['groupByPos'] = this.groupByPos;
        this.finalPOSTObj['hideRepeatedKey'] = this.hideRepeatedValues;
        this.finalPOSTObj['indentation'] = this.indentation;
        this.finalPOSTObj['level'] = this.multiGroupColumnLevel;
        this.finalPOSTObj['noWrap'] = (this.noWrap === true ? 'Y' : 'N');
        this.finalPOSTObj['sortable'] = this.sortable;
        this.finalPOSTObj['subTotalCustomText'] = this.displayTotal;
        this.finalPOSTObj['visible'] = this.visible;
        if (this.semaphoreName === 'No Display') {
            this.semaphoreId = '';
        } else {
            if(this.semaphoreList && this.semaphoreList.semaphore){
                for (let slcount = 0; slcount < this.semaphoreList.semaphore.length; slcount++) {
                    if (this.semaphoreName === this.semaphoreList.semaphore[slcount].semaphoreName) {
                        this.semaphoreId = this.semaphoreList.semaphore[slcount].semaphoreId;
                        this.semaphoreList.semaphore[slcount].comment = this.id;
                    }
                }
            }
        }
        this.finalPOSTObj['semaphoreId'] = this.semaphoreId;
        this.finalPOSTObj['semaphoreList'] = this.semaphoreList;

        this._columnService.postColumnChanges(this.finalPOSTObj)
            .subscribe((finalPOSTResponse) => {
                if (finalPOSTResponse) {
                    this.EditColstatus = 'Success!';
                    this.EditColmessage = 'Your change has been saved! Row definition is updated.';
                    this.showSaveColDialog = !this.showSaveColDialog;
                    this.Colclosable = true;
                } else {
                    this.EditColstatus = 'Failure!';
                    this.EditColmessage = 'Row definition could not be updated.';
                    this.showSaveColDialog = !this.showSaveColDialog;
                    this.Colclosable = true;
                }
                this.showEditDrillDownPage = false;
                this.showAdvancedDisplayPage = false;
                this.isIncomingDrillDownParams = false;
                this.addDisplay = false;
                this.showSpinner = false;

            });
    }


    drillDownLinkPage() {
        this.showEditDrillDownPage = !this.showEditDrillDownPage;
        this.showConfirmButton = true;
    }

    editDisplay() {
        this.showAdvancedDisplayPage = true;
    }


    finishAdvancedDisplay(displayObj: any) {
        this.addDisplay = false;
        this.semaphoreName = displayObj['semName'];
        this.semaphoreList = displayObj['semList'];
        this.semaphoreId = displayObj['semId'];
        this.showAdvancedDisplayPage = displayObj['setCloseDisplay'];
    }

    addNewDisplay() {
        this.showAdvancedDisplayPage = true;
        this.addDisplay = true;
    }
}