summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/report-run/run/run-report-form-fields/run-report-form-fields.component.ts
blob: ced812d21050cd79fecc3a46552242f8f0645c75 (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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
import {ChangeDetectorRef, Component, HostListener, OnInit, Input, SimpleChange, SystemJsNgModuleLoader, OnDestroy} from '@angular/core';
import {RunService} from '../run.service';
import {ActivatedRoute, Router} from '@angular/router';
import * as cloneDeep from 'lodash/cloneDeep';
import {environment} from 'src/environments/environment';
import {HttpCacheService} from '../../../shared/services/cache.service';

@Component({
    selector: 'app-run-report-form-fields',
    templateUrl: './run-report-form-fields.component.html',
    styleUrls: ['./run-report-form-fields.component.css']
})
export class RunReportFormFieldsComponent implements OnInit, OnDestroy {
    @Input('formFieldList') formFieldList: {}[];
    @Input('reportId') reportId: string;
    staticFormFieldList: {}[] = [];
    formFieldListValueArr: any[];
    saveFormFieldGroups: any[];
    finalQueryParamsObj: {};
    navigateToRun: boolean;
    reportMode: string;
    queryString: string;
    reportName: string;
    reportSubTitle: string;
    showSpinner: boolean;
    showLabel: boolean;
    runDashboardReport: boolean;
    DashboardReportObj: {}[] = [];
    triggerFormFieldArr = [];
    initialObject = {};
    formFieldGroupObjList: {}[] = [];
    toggleFormFieldRenderArr: {}[] = [];
    groupSelectValue = '';
    oldGroupSelectValue = '';
    unCommonCnt = 0;
    commonCount = 0;
    totalCommonCount = 0;
    totalCount = 0;
    errorMessage = '';
    stackTrace = '';
    error = false;
    iSDashboardReport = '';
    hitCnt = 0;
    directCallQueryParams: any = '';
    calledWithFormFields = false;
    showformFiledSpinner = false;
    actualformFieldValues: any[];
    allowEdit: boolean;
    runReportAgain: boolean;
    tempFieldValues = [];
    firstRun = false;
    saveFormFieldListValueArr: any[];
    saveGroupSelectValue = '';
    avoidDoCheck = false;
    toolTipPosition = 'right';
    isResetAllowed: boolean;
    save: {}[];
    unCommonGropusList: any[];
    commonFormFields: any[];
    formFieldListValueMap: any;
    saveFormFieldListValueMap: any;
    chartType = '';
    showRunButton = false;
    showBackButton = false;
    downloadPrevReport = '';
    timeStampArray: any[];
    hoursArray : any[];
    constructor(private _runService: RunService,
                private _route: ActivatedRoute,
                private _router: Router,
                private changeDetectorRefs: ChangeDetectorRef,
                private httpCacheService: HttpCacheService) {
        this.formFieldListValueArr = [];
        this.saveFormFieldListValueArr = [];
        this.saveFormFieldGroups = [];
        this.finalQueryParamsObj = {};
        this.navigateToRun = false;
        this.queryString = '';
        this.showSpinner = false;
        this.showLabel = false;
        this.runDashboardReport = false;
        this.showformFiledSpinner = false;
        this.runReportAgain = false;
        this.tempFieldValues = [];
        this.isResetAllowed = false;
        this.unCommonGropusList = [];
        this.commonFormFields = [];
        this.formFieldListValueMap = new Map<any, any>();
        this.saveFormFieldListValueMap = new Map<any, any>();
        this.chartType = '';
        this.showRunButton = false;
        this.showBackButton = false;
        this.downloadPrevReport = '';
        this.timeStampArray = [];
        this.hoursArray = [];

    }

    @HostListener('click') onClick() {
        this.changeDetectorRefs.detectChanges();
    }

    ngOnDestroy(): void {
        this.createNewObject();
        this.showSpinner = false;
    }

    createNewObject() {
        this.staticFormFieldList = [];
        this.formFieldListValueArr = [];
        this.saveFormFieldGroups = [];
        this.saveFormFieldListValueArr = [];
        this.finalQueryParamsObj = {};
        this.navigateToRun = false;
        this.reportMode = '';
        this.queryString = '';
        this.reportName = '';
        this.reportSubTitle = '';
        this.showSpinner = true;
        this.showLabel = false;
        this.runDashboardReport = false;
        this.DashboardReportObj = [];
        this.triggerFormFieldArr = [];
        this.initialObject = {};
        this.formFieldGroupObjList = [];
        this.toggleFormFieldRenderArr = [];
        this.groupSelectValue = '';
        this.oldGroupSelectValue = '';
        this.unCommonCnt = 0;
        this.totalCommonCount = 0;
        this.commonCount = 0;
        this.totalCount = 0;
        this.errorMessage = '';
        this.stackTrace = '';
        this.error = false;
        this.iSDashboardReport = '';
        this.hitCnt = 0;
        this.directCallQueryParams = '';
        this.calledWithFormFields = false;
        this.showformFiledSpinner = false;
        this.allowEdit = false;
        this.runReportAgain = false;
        this.isResetAllowed = false;
        this.unCommonGropusList = [];
        this.commonFormFields = [];
        this.formFieldListValueMap = new Map<any, any>();
        this.saveFormFieldListValueMap = new Map<any, any>();
        this.chartType = '';
        this.showRunButton = false;
        this.downloadPrevReport = '';
    }

    ngOnInit() {

        this.showSpinner = true;
        this.navigateToRun = false;
        this.getTime();
        this.getHours();
        this._route.params.subscribe(params => {
            this.createNewObject();
            this.reportId = params['reportId'];
            const checkOfCache = this.httpCacheService.getPreviousId(this.reportId) || null;
            if (!checkOfCache) {
                this.httpCacheService.clearCache();
            }
            const backButton = params['showBackButton'];
            const downloadPrevReport = params['downloadPrevReport'];
            if (downloadPrevReport && downloadPrevReport === 'true') {
                this.downloadPrevReport = 'true';
            }
            if (backButton && backButton === 'true') {
                this.showBackButton = true;
            } else if (backButton && backButton === 'false') {
                this.showBackButton = false;
            } else {
                this.showBackButton = false;
            }
            this.groupSelectValue = params['groupSelectValue'];
            if (this.groupSelectValue === undefined) {
                this.groupSelectValue = '';
            }
            if (params['queryParameters']) {
                this.directCallQueryParams = params['queryParameters'];
                this.calledWithFormFields = true;
                this.populateQueryParams(params['queryParameters']);
            }
            this.loadPage();
        });

    }

    populateQueryParams(queryParams: any) {
        this.actualformFieldValues = this.directCallQueryParams.substring(1, this.directCallQueryParams.length).split('&');
        for (const ff of this.actualformFieldValues) {
            const formfiledArray = ff.split('=');
            const formFieldId = formfiledArray[0];
            const formFieldObj = formfiledArray[1];
            this.finalQueryParamsObj[formFieldId] = formFieldObj;
        }
        this.queryString = this.directCallQueryParams;
    }

    loadPage() {
        this._runService.getDefinitionPageDetails(+this.reportId)
            .subscribe((responseDefPage) => {
                this.reportName = responseDefPage['reportName'];
                this.reportSubTitle = responseDefPage['reportSubTitle'];
                this.chartType = responseDefPage['chartType'];
                if (responseDefPage['reportType'] !== 'Dashboard') {
                    if (this.calledWithFormFields == false) {
                        this._runService.getReportData(this.reportId)
                            .subscribe((response) => {
                                if (response['errormessage']) {
                                    this.allowEdit = response['allowEdit'];
                                    this.showError(response);
                                } else {
                                    this.allowEdit = response['allowEdit'];
                                    this.reportName = response['reportName'];
                                    if (response['formFieldList'].length > 0) {
                                        this.fetchAndPopulateFormFields(response, this.reportId);
                                        this.showformFiledSpinner = true;
                                    } else {
                                        this.formFieldList = response['formFieldList'];
                                        this.reportMode = 'Regular';
                                        this.httpCacheService.setRouteCache(this.reportId, this.getQueryString());
                                        this.httpCacheService.setRouteGroupCache(this.reportId, this.groupSelectValue);
                                        this.navigateToRun = true;
                                        this.showformFiledSpinner = false;

                                    }
                                    this.showSpinner = false;
                                }
                            });
                    } else if (this.calledWithFormFields == true) {
                        this._runService.getReportData(this.reportId)
                            .subscribe((response) => {
                                if (response['errormessage']) {
                                    this.showError(response);
                                } else {
                                    this.error = false;
                                    this.reportName = response['reportName'];
                                    this.allowEdit = response['allowEdit'];
                                    if (response['formFieldList'].length > 0) {
                                        this.setDefaultFieldGroupValueForNonSelected(response['formFieldList']);
                                        this.generateQueryString();
                                        this.fetchAndPopulateFormFields(response, this.reportId);
                                        this.formFieldListValueMap = new Map<any, any>();
                                        for (const ff of response['formFieldList']) {
                                            if (this.finalQueryParamsObj[ff.fieldId]) {
                                                if (ff.validationType == 'DATE') {
                                                    const dateVal = this.finalQueryParamsObj[ff.fieldId];
                                                    this.formFieldListValueMap.set(ff.fieldId, new Date(dateVal.toString().replace(/%2F/g, '/')));
                                                } else if (ff.fieldType == 'LIST_MULTI_SELECT') {
                                                    const multiSelectArray = [];
                                                    let multiVal = this.finalQueryParamsObj[ff.fieldId];
                                                    multiVal = multiVal.toString().replace(/%2F/g, '/');
                                                    multiVal = multiVal.toString().replace(/%20/g, ' ');
                                                    multiVal = multiVal.toString().replace(/%28/g, '(');
                                                    multiVal = multiVal.toString().replace(/%29/g, ')');
                                                    multiVal = multiVal.toString().replace('+', ' ');
                                                    if (multiVal.split('|').length > 1) {
                                                        let tempArray = multiVal.split('|');
                                                        for (let arr = 0; arr < tempArray.length; arr++) {
                                                            multiSelectArray.push(tempArray[arr]);
                                                        }
                                                    } else {
                                                        multiSelectArray.push(multiVal);
                                                    }
                                                    this.formFieldListValueMap.set(ff.fieldId, multiSelectArray);
                                                } else {
                                                    let multiVal = this.finalQueryParamsObj[ff.fieldId];
                                                    multiVal = multiVal.toString().replace(/%2F/g, '/');
                                                    multiVal = multiVal.toString().replace(/%20/g, ' ');
                                                    multiVal = multiVal.toString().replace(/%28/g, '(');
                                                    multiVal = multiVal.toString().replace(/%29/g, ')');
                                                    multiVal = multiVal.toString().split('+').join(' ');
                                                    this.formFieldListValueMap.set(ff.fieldId, multiVal);
                                                }
                                            } else {
                                                if (ff.fieldType == 'LIST_MULTI_SELECT') {
                                                    const multiSelectArray = [];
                                                    this.formFieldListValueMap.set(ff.fieldId, multiSelectArray);
                                                } else {
                                                    this.formFieldListValueMap.set(ff.fieldId, '');
                                                }
                                            }
                                        }
                                        this.error = false;
                                        this.httpCacheService.setRouteCache(this.reportId, this.getQueryString());
                                        this.httpCacheService.setRouteGroupCache(this.reportId, this.groupSelectValue);
                                        this.navigateToRun = true;
                                        this.showformFiledSpinner = true;
                                        this.directCallQueryParams = '';
                                    } else {
                                        this.reportMode = 'Regular';
                                        this.navigateToRun = true;
                                        this.showformFiledSpinner = false;

                                    }
                                    this.showSpinner = false;

                                }
                            });
                    } else {
                        this.reportMode = 'FormField';
                        this.navigateToRun = true;
                        this.showSpinner = false;
                        this.showformFiledSpinner = true;
                    }
                } else {
                    if (this.calledWithFormFields == false) {
                        this.iSDashboardReport = 'Dashboard';
                        this.reportName = responseDefPage['reportName'];
                        this.DashboardReportObj = JSON.parse(responseDefPage['dashboardLayoutJSON']);
                        let i = 0;
                        let subReportId = '';
                        const tempDashboardArray = [];
                        for (let dash = 0; dash < this.DashboardReportObj.length; dash++) {
                            if (this.DashboardReportObj[dash]['hasContent']['hideDisplay'] !== true) {
                                tempDashboardArray.push(this.DashboardReportObj[dash]);
                            }
                        }
                        this.DashboardReportObj = [];
                        this.DashboardReportObj = tempDashboardArray;
                        while (this.DashboardReportObj[i]) {
                            subReportId = this.DashboardReportObj[i]['hasContent']['id'].split('#')[1];
                            i++;
                            break;
                        }
                        this._runService.getReportData(subReportId)
                            .subscribe((response) => {
                                if (response['errormessage']) {
                                    this.showError(response);
                                    this.allowEdit = response['allowEdit'];
                                } else {
                                    this.allowEdit = response['allowEdit'];
                                    if (response['formFieldList'].length > 0) {
                                        this.fetchAndPopulateFormFields(response, subReportId);
                                    } else {
                                        this.navigateToRun = true;
                                    }
                                    this.runDashboardReport = true;
                                    this.showSpinner = false;
                                    this.showformFiledSpinner = true;
                                }
                            });
                        this.showSpinner = false;
                        this.showformFiledSpinner = true;
                    } else if (this.calledWithFormFields == true) {
                        this.httpCacheService.setRouteCache(this.reportId, this.getQueryString());
                        this.httpCacheService.setRouteGroupCache(this.reportId, this.groupSelectValue);
                        this.iSDashboardReport = 'Dashboard';
                        this.reportName = responseDefPage['reportName'];
                        this.DashboardReportObj = JSON.parse(responseDefPage['dashboardLayoutJSON']);
                        const tempDashboardArray = [];
                        for (let dash = 0; dash < this.DashboardReportObj.length; dash++) {
                            if (this.DashboardReportObj[dash]['hasContent']['hideDisplay'] !== true) {
                                tempDashboardArray.push(this.DashboardReportObj[dash]);
                            }
                        }
                        this.DashboardReportObj = [];
                        this.DashboardReportObj = tempDashboardArray;
                            let subReportId1 = '';
                            let i = 0;
                            while (this.DashboardReportObj[i]) {
                                subReportId1 = this.DashboardReportObj[i]['hasContent']['id'].split('#')[1];
                                i++;
                                break;
                            }
                            this._runService.getReportData(subReportId1)
                                .subscribe((response) => {
                                    if (response['errormessage']) {
                                        this.showError(response);
                                        this.allowEdit = response['allowEdit'];
                                    } else {
                                        this.allowEdit = response['allowEdit'];
                                        if (response['formFieldList'].length > 0) {
                                            this.fetchAndPopulateFormFields(response, subReportId1);
                                            this.formFieldListValueMap = new Map<any, any>();
                                            for (const ff of response['formFieldList']) {
                                                if (this.finalQueryParamsObj[ff.fieldId]) {
                                                    if (ff.validationType == 'DATE') {
                                                        const dateVal = this.finalQueryParamsObj[ff.fieldId];
                                                        this.formFieldListValueMap.set(ff.fieldId, new Date(dateVal.toString().replace(/%2F/g, '/')));
                                                    } else if (ff.fieldType == 'LIST_MULTI_SELECT') {
                                                        const multiSelectArray = [];
                                                        let multiVal = this.finalQueryParamsObj[ff.fieldId];
                                                        multiVal = multiVal.toString().replace(/%2F/g, '/');
                                                        multiVal = multiVal.toString().replace(/%20/g, ' ');
                                                        multiVal = multiVal.toString().replace(/%28/g, '(');
                                                        multiVal = multiVal.toString().replace(/%29/g, ')');
                                                        multiVal = multiVal.toString().replace('+', ' ');
                                                        if (multiVal.split('|').length > 1) {
                                                            let tempArray = multiVal.split('|');
                                                            for (let arr = 0; arr < tempArray.length; arr++) {
                                                                multiSelectArray.push(tempArray[arr]);
                                                            }
                                                        } else {
                                                            multiSelectArray.push(multiVal);
                                                        }
                                                        this.formFieldListValueMap.set(ff.fieldId, multiSelectArray);
                                                    } else {
                                                        let multiVal = this.finalQueryParamsObj[ff.fieldId];
                                                        multiVal = multiVal.toString().replace(/%2F/g, '/');
                                                        multiVal = multiVal.toString().replace(/%20/g, ' ');
                                                        multiVal = multiVal.toString().replace(/%28/g, '(');
                                                        multiVal = multiVal.toString().replace(/%29/g, ')');
                                                        multiVal = multiVal.toString().split('+').join(' ');
                                                        if (multiVal == 'NULL') {
                                                            this.formFieldListValueMap.set(ff.fieldId, '');
                                                        } else {
                                                            this.formFieldListValueMap.set(ff.fieldId, multiVal);
                                                        }
                                                    }
                                                } else {
                                                    if (ff.fieldType == 'LIST_MULTI_SELECT') {
                                                        const multiSelectArray = [];
                                                        this.formFieldListValueMap.set(ff.fieldId, multiSelectArray);
                                                    } else {
                                                        this.formFieldListValueMap.set(ff.fieldId, '');
                                                    }
                                                }
                                            }
                                        } else {
                                            this.navigateToRun = true;
                                        }
                                        let subReportId = '';
                                        for (const dashboard of this.DashboardReportObj) {
                                            let temp = '';
                                            temp = dashboard['hasContent']['id'].split('#')[1];
                                            subReportId = temp;
                                            this.directCallQueryParams = '';
                                            this.runDashboardReport = true;
                                            this.navigateToRun = true;
                                            this.showSpinner = false;
                                        }
                                    }
                                });

                        }

                }
            });
    }

    toggleChangeWhenCalledWithFromFields() {
        this.calledWithFormFields = false;
    }

    async ngDoCheck() {

        if (this.formFieldList !== undefined) {

            if (this.groupSelectValue !== this.oldGroupSelectValue) {
                //  this.formFieldListValueArr.splice(this.commonCount-1, this.formFieldListValueArr.length)
                this.removePrevioustoggleGroupData();
                this.oldGroupSelectValue = this.groupSelectValue;
                this.formFieldGroupObjList = [];
                this.saveFormFieldGroups = [];
                this.formFieldGroupObjList = cloneDeep(this.save);
                this.saveFormFieldGroups = cloneDeep(this.save);
                for (const formFieldGroupObjItem of this.formFieldGroupObjList) {
                    if (formFieldGroupObjItem['name'] == this.groupSelectValue) {
                        this.toggleFormFieldRenderArr = formFieldGroupObjItem['formFieldList'];
                    }

                }
                if (this.toggleFormFieldRenderArr.length > 0) {
                    for (let i = 0; i < this.toggleFormFieldRenderArr.length; i++) {
                        const formFieldObj = this.toggleFormFieldRenderArr[i];
                        if (formFieldObj['triggerOtherFormFields'] === true) {
                            const formFieldId = formFieldObj['fieldId'];
                            this.triggerFormFieldArr.push(formFieldId);
                            this.initialObject[formFieldId] = '1';
                            this.finalQueryParamsObj[formFieldId] = '1';
                        }
                    }
                }

                if (this.calledWithFormFields != true) {
                    for (const formFieldGroupObjItem of this.saveFormFieldGroups) {
                        if (formFieldGroupObjItem['name'] == this.groupSelectValue) {
                            this.toggleFormFieldRenderArr = formFieldGroupObjItem['formFieldList'];
                            for (let ffGrpValue = 0; ffGrpValue < formFieldGroupObjItem['formFieldList'].length; ffGrpValue++) {
                                if (formFieldGroupObjItem['formFieldList'][ffGrpValue]['formFieldValues'].length > 0) {
                                    for (let ffValue = 0; ffValue < formFieldGroupObjItem['formFieldList'][ffGrpValue]['formFieldValues'].length; ffValue++) {
                                        if (formFieldGroupObjItem['formFieldList'][ffGrpValue]['fieldType'] == 'LIST_BOX' && formFieldGroupObjItem['formFieldList'][ffGrpValue]['formFieldValues'].length > 0) {
                                            let isAdded = false;
                                            for (let ffValue = 0; ffValue < formFieldGroupObjItem['formFieldList'][ffGrpValue]['formFieldValues'].length; ffValue++) {
                                                if (formFieldGroupObjItem['formFieldList'][ffGrpValue]['formFieldValues'][ffValue]['defaultValue'] == true) {
                                                    this.formFieldListValueMap.set(formFieldGroupObjItem['formFieldList'][ffGrpValue]['fieldId'], formFieldGroupObjItem['formFieldList'][ffGrpValue]['formFieldValues'][ffValue]['id']);
                                                    isAdded = true;
                                                }
                                            }
                                            if (!isAdded) {
                                                this.formFieldListValueMap.set(formFieldGroupObjItem['formFieldList'][ffGrpValue]['fieldId'], '');
                                            }
                                        } else if ((formFieldGroupObjItem['formFieldList'][ffGrpValue]['fieldType'] == 'LIST_MULTI_SELECT' || formFieldGroupObjItem['formFieldList'][ffGrpValue]['fieldType'] == 'TEXT') && formFieldGroupObjItem['formFieldList'][ffGrpValue]['formFieldValues'].length > 0) {
                                            let isAdded = false;
                                            for (let ffValue = 0; ffValue < formFieldGroupObjItem['formFieldList'][ffGrpValue]['formFieldValues'].length; ffValue++) {

                                                if (formFieldGroupObjItem['formFieldList'][ffGrpValue]['formFieldValues'][ffValue]['defaultValue'] == true) {
                                                    const multiSelectArray = [];
                                                    multiSelectArray.push(formFieldGroupObjItem['formFieldList'][ffGrpValue]['formFieldValues'][ffValue]['id']);
                                                    this.formFieldListValueMap.set(formFieldGroupObjItem['formFieldList'][ffGrpValue]['fieldId'], multiSelectArray);
                                                    isAdded = true;
                                                }
                                            }
                                            if (!isAdded) {
                                                this.formFieldListValueMap.set(formFieldGroupObjItem['formFieldList'][ffGrpValue]['fieldId'], '');
                                            }
                                        } else if (formFieldGroupObjItem['formFieldList'][ffGrpValue]['fieldType'] == 'Select Field Type' && formFieldGroupObjItem['formFieldList'][ffGrpValue]['validationType'] == 'NONE') {
                                            let isAdded = false;
                                            for (let ffValue = 0; ffValue < formFieldGroupObjItem['formFieldList'][ffGrpValue]['formFieldValues'].length; ffValue++) {

                                                if (formFieldGroupObjItem['formFieldList'][ffGrpValue]['formFieldValues'][ffValue]['defaultValue'] == true) {
                                                    this.formFieldListValueMap.set(formFieldGroupObjItem['formFieldList'][ffGrpValue]['fieldId'], formFieldGroupObjItem['formFieldList'][ffGrpValue]['formFieldValues'][ffValue]['id']);
                                                    isAdded = true;
                                                }
                                            }
                                            if (!isAdded) {
                                                this.formFieldListValueArr[this.totalCommonCount + ffGrpValue] = '';
                                            }
                                        } else {
                                            this.formFieldListValueMap.set(formFieldGroupObjItem['formFieldList'][ffGrpValue]['fieldId'], '');
                                        }
                                    }
                                } else {
                                    this.formFieldListValueMap.set(formFieldGroupObjItem['formFieldList'][ffGrpValue]['fieldId'], '');
                                }
                            }
                        }
                    }
                }
                if (this.formFieldGroupObjList.length > 0) {
                    for (let ffl = 0; ffl < this.formFieldList.length; ffl++) {
                        for (let ffgl = 0; ffgl < this.formFieldGroupObjList.length; ffgl++) {
                            const inList = this.formFieldGroupObjList[ffgl]['formFieldList'];

                            for (let inl = 0; inl < inList.length; inl++) {
                                let cntr = 0;
                                if (inList[inl]['fieldId'] == this.formFieldList[ffl]['fieldId']) {
                                    cntr++;
                                }
                                if (cntr == 0) {
                                    this.finalQueryParamsObj[inList[inl]['fieldId']] = '-1';
                                }
                            }

                        }
                    }
                }
            }
            for (const tffr of this.toggleFormFieldRenderArr) {
                if (this.formFieldListValueMap.get(tffr['fieldId']) || this.formFieldListValueMap.get(tffr['fieldId']) == '') {
                    if (tffr['validationType'] == 'DATE') {
                        this.finalQueryParamsObj[tffr['fieldId']] = this.convertDate(this.formFieldListValueMap.get(tffr['fieldId']));
                    } else if (this.formFieldListValueMap.get(tffr['fieldId']) == '') {

                        if (tffr['fieldType'] == 'LIST_MULTI_SELECT') {
                            let multiSelectValue = '';
                            if (multiSelectValue != '') {
                                multiSelectValue = multiSelectValue.substring(0, multiSelectValue.length - 1);
                            }
                            this.finalQueryParamsObj[tffr['fieldId']] = multiSelectValue;

                        } else {
                            this.finalQueryParamsObj[tffr['fieldId']] = '';
                        }
                    } else {
                        this.finalQueryParamsObj[tffr['fieldId']] = this.formFieldListValueMap.get(tffr['fieldId']);
                        if (this.initialObject[tffr['fieldId']] !== this.finalQueryParamsObj[tffr['fieldId']]) {
                            this.initialObject[tffr['fieldId']] = this.finalQueryParamsObj[tffr['fieldId']];
                            this.generateQueryString();
                            await this.delay(1000);
                            console.log('Afterp:  ' + new Date().toString());
                            if ( tffr['triggerOtherFormFields'] == true) {
                                    this._runService.refreshFormFields(this.reportId, this.queryString)
                                        .subscribe((responseRefreshFF) => {
                                            for (let rrff = 0; rrff < responseRefreshFF['formFieldList'].length; rrff++) {
                                                for (let innerTFRR = 0; innerTFRR < this.toggleFormFieldRenderArr.length; innerTFRR++) {
                                                    if (responseRefreshFF['formFieldList'][rrff]['fieldId'] == this.toggleFormFieldRenderArr[innerTFRR]['fieldId']) {
                                                        this.toggleFormFieldRenderArr[innerTFRR] = responseRefreshFF['formFieldList'][rrff];
                                                    }
                                                }
                                            }
                                        });
                              
                            }
                            this.initialObject[tffr['fieldId']] = this.finalQueryParamsObj[tffr['fieldId']];
                        }
                    }
                }
            }

            if (this.reportMode !== 'Regular' && this.reportMode !== 'Dashboard') {
                for (const ffvalue of this.formFieldList) {
                    if (this.formFieldListValueMap.get(ffvalue['fieldId']) === '' || this.formFieldListValueMap.get(ffvalue['fieldId']) ) {
                        if (ffvalue['validationType'] == 'DATE' && this.formFieldListValueMap.get(ffvalue['fieldId']) !== '' ) {
                            this.finalQueryParamsObj[ffvalue['fieldId']] = this.convertDate(this.formFieldListValueMap.get(ffvalue['fieldId']));
                        }else if (ffvalue['validationType'] == 'TIMESTAMP_SEC' && this.formFieldListValueMap.get(ffvalue['fieldId']) !== ''){
                            if(this.formFieldListValueMap.get(ffvalue['fieldId'])[0] != ''){
                            this.finalQueryParamsObj[ffvalue['fieldId']] = this.convertDate(this.formFieldListValueMap.get(ffvalue['fieldId'])[0]);
                        } else {
                                this.finalQueryParamsObj[ffvalue['fieldId']] = this.formFieldListValueMap.get(ffvalue['fieldId'])[0];
                            }
                            this.finalQueryParamsObj[ffvalue['fieldId']+'_Hr'] = this.formFieldListValueMap.get(ffvalue['fieldId'])[1];
                            this.finalQueryParamsObj[ffvalue['fieldId']+'_Min'] = this.formFieldListValueMap.get(ffvalue['fieldId'])[2];
                            this.finalQueryParamsObj[ffvalue['fieldId']+'_Sec'] = this.formFieldListValueMap.get(ffvalue['fieldId'])[3];
                        }else if (ffvalue['validationType'] == 'TIMESTAMP_MIN' && this.formFieldListValueMap.get(ffvalue['fieldId']) !== ''){
                            if(this.formFieldListValueMap.get(ffvalue['fieldId'])[0] != ''){
                                this.finalQueryParamsObj[ffvalue['fieldId']] = this.convertDate(this.formFieldListValueMap.get(ffvalue['fieldId'])[0]);
                                }else{
                                    this.finalQueryParamsObj[ffvalue['fieldId']] = this.formFieldListValueMap.get(ffvalue['fieldId'])[0];
                                }
                            this.finalQueryParamsObj[ffvalue['fieldId']+'_Hr'] = this.formFieldListValueMap.get(ffvalue['fieldId'])[1];
                            this.finalQueryParamsObj[ffvalue['fieldId']+'_Min'] = this.formFieldListValueMap.get(ffvalue['fieldId'])[2];
                        }else if (ffvalue['validationType'] == 'TIMESTAMP_HOUR' && this.formFieldListValueMap.get(ffvalue['fieldId']) !== ''){
                            if(this.formFieldListValueMap.get(ffvalue['fieldId'])[0] != ''){
                                this.finalQueryParamsObj[ffvalue['fieldId']] = this.convertDate(this.formFieldListValueMap.get(ffvalue['fieldId'])[0]);
                                }else{
                                    this.finalQueryParamsObj[ffvalue['fieldId']] = this.formFieldListValueMap.get(ffvalue['fieldId'])[0];
                                }                            
                                this.finalQueryParamsObj[ffvalue['fieldId']+'_Hr'] = this.formFieldListValueMap.get(ffvalue['fieldId'])[1];
                        }                    
                        else {
                            this.finalQueryParamsObj[ffvalue['fieldId']] = this.formFieldListValueMap.get(ffvalue['fieldId']);
                        }
                            for (const trigElement of this.triggerFormFieldArr) {
                                if (this.initialObject[trigElement] !== this.finalQueryParamsObj[trigElement]) {
                                    this.initialObject[trigElement] = this.finalQueryParamsObj[trigElement];
                                    this.generateQueryString();
                                    await this.delay(1000);
                                    console.log('Afterp:  ' + new Date().toString());
                                          if (ffvalue['triggerOtherFormFields'] == true) {
                                              this._runService.refreshFormFields(this.reportId, this.queryString)
                                                  .subscribe((responseRefreshFF) => {
                                                      for (let rrff = 0; rrff < responseRefreshFF['formFieldList'].length; rrff++) {
                                                          for (let innerFFL = 0; innerFFL < this.formFieldList.length; innerFFL++) {
                                                              if (responseRefreshFF['formFieldList'][rrff]['fieldId'] == this.formFieldList[innerFFL]['fieldId']) {
                                                                  this.formFieldList[innerFFL] = responseRefreshFF['formFieldList'][rrff];
                                                              }
                                                          }
                                                      }
                                                  });
                                          }      
                               
                            }

                        }
                    }
                }

            }
        }
        if (this.firstRun) {
            this.saveGroupSelectValue = this.groupSelectValue;
            this.saveFormFieldListValueMap = cloneDeep(this.formFieldListValueMap);
        }
        this.firstRun = false;
    }

    convertDate(str) {
        const date = new Date(str),
            mnth = ('0' + (date.getMonth() + 1)).slice(-2),
            day = ('0' + date.getDate()).slice(-2);
        return [mnth, day, date.getFullYear()].join('/');
    }

    getQueryString() {
        if (this.directCallQueryParams !== '') {
            return this.directCallQueryParams;
        } else {
            return this.queryString;
        }
    }

    fetchAndPopulateFormFields(respObj: any, ffReportId: string) {
        this._runService.getFormFieldGroupsData(ffReportId)
            .subscribe((responseFormFieldGroups) => {
                this.firstRun = true;
                this.showformFiledSpinner = false;
                this.formFieldGroupObjList = JSON.parse(responseFormFieldGroups['formFieldGroupsJSON']);
                this.saveFormFieldGroups = JSON.parse(responseFormFieldGroups['formFieldGroupsJSON']);
                this.formFieldList = respObj['formFieldList'];
                if (this.formFieldList.length === 1 && this.formFieldList[0]['visible'] === false) {
                    this.showRunButton = false;
                } else if (this.formFieldList.length > 0) {
                    this.showRunButton = true;
                }
                this.staticFormFieldList = respObj['formFieldList'];
                this.reportMode = 'FormField';
                this.totalCount = this.formFieldList.length;
                if (this.formFieldGroupObjList !== null) {
                    for (let ffgl = 0; ffgl < this.formFieldGroupObjList.length; ffgl++) {
                        for (let itemFFGL = 0; itemFFGL < this.formFieldGroupObjList[ffgl]['formFieldList'].length; itemFFGL++) {
                            const formFieldGroupItem = this.formFieldGroupObjList[ffgl]['formFieldList'][itemFFGL];
                            for (let fflg = 0; fflg < this.formFieldList.length; fflg++) {
                                if (formFieldGroupItem['id'] == this.formFieldList[fflg]['fieldId']) {
                                    this.formFieldGroupObjList[ffgl]['formFieldList'][itemFFGL] = this.formFieldList[fflg];
                                    this.saveFormFieldGroups[ffgl]['formFieldList'][itemFFGL] = this.formFieldList[fflg];

                                    if (this.formFieldList[fflg]['triggerOtherFormFields'] === true) {
                                        const formFieldId = this.formFieldList[fflg]['fieldId'];
                                        this.triggerFormFieldArr.push(formFieldId);
                                        this.initialObject[formFieldId] = [];
                                        this.finalQueryParamsObj[formFieldId] = [];
                                    }
                                    this.formFieldList.splice(fflg, 1);
                                    this.unCommonGropusList.push(formFieldGroupItem);
                                    this.unCommonCnt++;
                                }
                            }
                        }
                    }
                }
                if (this.calledWithFormFields != true) {
                    for (let checkRadio = 0; checkRadio < this.formFieldList.length; checkRadio++) {
                        if (this.formFieldList[checkRadio]['fieldDisplayName'] == 'selectCriteria') {
                            for (let ffValue = 0; ffValue < this.formFieldList[checkRadio]['formFieldValues'].length; ffValue++) {
                                if (this.formFieldList[checkRadio]['formFieldValues'][ffValue]['defaultValue'] == true) {
                                    this.groupSelectValue = this.formFieldList[checkRadio]['formFieldValues'][ffValue]['name'];
                                }
                            }
                            this.oldGroupSelectValue = this.groupSelectValue;
                        }
                    }
                }
                this.commonCount = this.totalCount - this.unCommonCnt;
                this.totalCommonCount = this.commonCount;
                console.log(this.unCommonGropusList);
                console.log(this.formFieldList);
                for (let i = 0; i < this.formFieldList.length; i++) {
                    const formFieldObj = this.formFieldList[i];
                    if (formFieldObj['formFieldValues'] != null && this.calledWithFormFields != true) {
                        if ((formFieldObj['validationType'] == 'DATE' && formFieldObj['formFieldValues'].length > 0) || formFieldObj['validationType'] == 'TIMESTAMP_SEC' || formFieldObj['validationType'] == 'TIMESTAMP_MIN' || formFieldObj['validationType'] == 'TIMESTAMP_HOUR') {
                            if (formFieldObj['validationType'] == 'TIMESTAMP_SEC') {
                                const multiSelectArray = [];

                                if (formFieldObj['formFieldValues'].length > 0) {
                                    const date = formFieldObj['formFieldValues'][0]['id'];
                                    let tempDate = new Date(date);
                                    multiSelectArray.push(tempDate);
                                    multiSelectArray.push(tempDate.getHours());
                                    multiSelectArray.push(tempDate.getMinutes());
                                    multiSelectArray.push(tempDate.getSeconds());
                                    this.formFieldListValueMap.set(formFieldObj['fieldId'], multiSelectArray);
                                } else {
                                    multiSelectArray.push('');
                                    multiSelectArray.push('0');
                                    multiSelectArray.push('0');
                                    multiSelectArray.push('0');
                                    this.formFieldListValueMap.set(formFieldObj['fieldId'], multiSelectArray);
                                }
                            }
                            else if (formFieldObj['validationType'] == 'TIMESTAMP_MIN') {
                                const multiSelectArray = [];
                                if (formFieldObj['formFieldValues'].length > 0) {
                                    const date = formFieldObj['formFieldValues'][0]['id'];
                                    let tempDate = new Date(date);
                                    multiSelectArray.push(tempDate);
                                    multiSelectArray.push(tempDate.getHours());
                                    multiSelectArray.push(tempDate.getMinutes());
                                    this.formFieldListValueMap.set(formFieldObj['fieldId'], multiSelectArray);
                                } else {
                                    multiSelectArray.push('');
                                    multiSelectArray.push('0');
                                    multiSelectArray.push('0');
                                    this.formFieldListValueMap.set(formFieldObj['fieldId'], multiSelectArray);
                                }
                            } else if (formFieldObj['validationType'] == 'TIMESTAMP_HOUR') {
                                const multiSelectArray = [];

                                if (formFieldObj['formFieldValues'].length > 0) {
                                    const date = formFieldObj['formFieldValues'][0]['id'];

                                    let tempDate = new Date(date);
                                    multiSelectArray.push(tempDate);
                                    multiSelectArray.push(tempDate.getHours());
                                    this.formFieldListValueMap.set(formFieldObj['fieldId'], multiSelectArray);
                                } else {
                                    multiSelectArray.push('');
                                    multiSelectArray.push('0');
                                    this.formFieldListValueMap.set(formFieldObj['fieldId'], multiSelectArray);
                                }
                            }
                               else{
                            const date = formFieldObj['formFieldValues'][0]['id'];
                            this.formFieldListValueMap.set(formFieldObj['fieldId'], new Date(date));
                            }
                        } else if (formFieldObj['fieldType'] == 'LIST_BOX' && formFieldObj['formFieldValues'].length > 0) {
                            let isAdded = false;
                            for (let ffValue = 0; ffValue < formFieldObj['formFieldValues'].length; ffValue++) {
                                if (formFieldObj['formFieldValues'][ffValue]['defaultValue'] == true) {
                                    this.formFieldListValueMap.set(formFieldObj['fieldId'], formFieldObj['formFieldValues'][ffValue]['id']);
                                    isAdded = true;
                                }
                            }
                            if (!isAdded) {
                                this.formFieldListValueMap.set(formFieldObj['fieldId'], '');
                            }
                        } else if ((formFieldObj['fieldType'] == 'LIST_MULTI_SELECT' || formFieldObj['fieldType'] == 'TEXT') && formFieldObj['formFieldValues'].length > 0) {
                            let isAdded = false;
                            const multiSelectArray = [];
                            for (let ffValue = 0; ffValue < formFieldObj['formFieldValues'].length; ffValue++) {
                                if (formFieldObj['formFieldValues'][ffValue]['defaultValue'] == true) {
                                    multiSelectArray.push(formFieldObj['formFieldValues'][ffValue]['id']);
                                    this.formFieldListValueMap.set(formFieldObj['fieldId'], multiSelectArray);
                                    isAdded = true;
                                }
                            }
                            if (!isAdded) {
                                this.formFieldListValueMap.set(formFieldObj['fieldId'], '');
                            }
                        } else if (formFieldObj['fieldDisplayName'] == 'DefaultRadio') {
                            this.formFieldListValueMap.set(formFieldObj['fieldId'], '');

                        } else {
                            this.formFieldListValueMap.set(formFieldObj['fieldId'], '');
                        }
                    }

                    if (formFieldObj['triggerOtherFormFields'] === true) {
                        const formFieldId = formFieldObj['fieldId'];
                        this.triggerFormFieldArr.push(formFieldId);
                        this.initialObject[formFieldId] = [];
                        this.finalQueryParamsObj[formFieldId] = [];
                    }
                }

                console.log(this.formFieldListValueMap);

                if (this.calledWithFormFields != true) {
                    if (this.formFieldGroupObjList !== null) {
                        for (const formFieldGroupObjItem of this.formFieldGroupObjList) {
                            if (formFieldGroupObjItem['name'] == this.groupSelectValue) {
                                this.toggleFormFieldRenderArr = formFieldGroupObjItem['formFieldList'];
                                for (let ffGrpValue = 0; ffGrpValue < formFieldGroupObjItem['formFieldList'].length; ffGrpValue++) {
                                    if (formFieldGroupObjItem['formFieldList'][ffGrpValue]['formFieldValues'].length > 0) {
                                        for (let ffValue = 0; ffValue < formFieldGroupObjItem['formFieldList'][ffGrpValue]['formFieldValues'].length; ffValue++) {
                                            if (formFieldGroupObjItem['formFieldList'][ffGrpValue]['formFieldValues'][ffValue]['defaultValue'] == true) {
                                                if (formFieldGroupObjItem['formFieldList'][ffGrpValue]['fieldType'] == 'LIST_MULTI_SELECT') {
                                                    const multiSelectArray = [];
                                                    multiSelectArray.push(formFieldGroupObjItem['formFieldList'][ffGrpValue]['formFieldValues'][ffValue]['id']);
                                                    this.formFieldListValueMap.set(formFieldGroupObjItem['formFieldList'][ffGrpValue]['fieldId'], multiSelectArray);
                                                } else {
                                                    this.formFieldListValueMap.set(formFieldGroupObjItem['formFieldList'][ffGrpValue]['fieldId'], formFieldGroupObjItem['formFieldList'][ffGrpValue]['formFieldValues'][ffValue]['id']);
                                                }
                                            }
                                        }
                                    } else {
                                        this.formFieldListValueMap.set(formFieldGroupObjItem['formFieldList'][ffGrpValue]['fieldId'], '');

                                    }
                                }
                            }

                        }
                    }
                }
                console.log('finalMap', this.formFieldListValueMap);
                if (this.formFieldGroupObjList !== null) {
                    if (this.formFieldGroupObjList.length > 0) {
                        for (let ffl = 0; ffl < this.formFieldList.length; ffl++) {
                            for (let ffgl = 0; ffgl < this.formFieldGroupObjList.length; ffgl++) {
                                const inList = this.formFieldGroupObjList[ffgl]['formFieldList'];

                                for (let inl = 0; inl < inList.length; inl++) {
                                    let cntr = 0;
                                    if (inList[inl]['fieldId'] == this.formFieldList[ffl]['fieldId']) {
                                        cntr++;
                                    }
                                    if (cntr == 0) {
                                        this.finalQueryParamsObj[inList[inl]['fieldId']] = '-1';
                                    }
                                }

                            }
                        }
                    }
                }
                this.save = cloneDeep(this.formFieldGroupObjList);
            });
    }

    generateQueryString() {

        this.queryString = '';
        for (let k = 0; k < Object.keys(this.finalQueryParamsObj).length; k++) {
            if (typeof (this.finalQueryParamsObj[Object.keys(this.finalQueryParamsObj)[k]]) == 'object') {
                const key = Object.keys(this.finalQueryParamsObj)[k];
                let qstr = '';
                let l = 0;
                while (this.finalQueryParamsObj[key][l]) {
                    if (l === 0) {
                        qstr = qstr + this.finalQueryParamsObj[Object.keys(this.finalQueryParamsObj)[k]][l];
                    } else {
                        qstr = qstr + '|' + this.finalQueryParamsObj[Object.keys(this.finalQueryParamsObj)[k]][l];
                    }
                    l++;
                }
                if (qstr !== '') {
                    this.queryString = this.queryString + '&' + Object.keys(this.finalQueryParamsObj)[k] + '=' + qstr;
                }
            } else {
                if (typeof (this.finalQueryParamsObj[Object.keys(this.finalQueryParamsObj)[k]]) == 'string') {
                    this.queryString = this.queryString + '&' + Object.keys(this.finalQueryParamsObj)[k] + '=' + this.finalQueryParamsObj[Object.keys(this.finalQueryParamsObj)[k]];
                } else {
                    this.queryString = this.queryString + '&' + Object.keys(this.finalQueryParamsObj)[k] + '=' + this.finalQueryParamsObj[Object.keys(this.finalQueryParamsObj)[k]];
                }
            }

        }

    }

    showError(Errresponse: any) {
        this.errorMessage = Errresponse['errormessage'];
        this.stackTrace = Errresponse['stacktrace'];
        this.error = true;
        this.showSpinner = false;
    }

    runReport() {
        this.hitCnt++;
        this.showSpinner = true;
        if (this.iSDashboardReport !== 'Dashboard') {
            if (this.formFieldList.length > 0) {
                this.reportMode = 'FormField';
                this.generateQueryString();
            } else {
                this.reportMode = 'Regular';
            }
            this.showSpinner = false;
        } else {
            this.generateQueryString();
            this.showSpinner = false;
        }
        this.httpCacheService.setRouteCache(this.reportId, this.getQueryString());
        this.httpCacheService.setRouteGroupCache(this.reportId, this.groupSelectValue);
        this.runReportAgain = !this.runReportAgain;
        this.navigateToRun = true;
    }

    editReport(reportId: string) {
        this._router.navigate(['v2/app/reports', 'Edit', reportId]);
    }

    showLabelFn() {
        this.showLabel = !this.showLabel;
    }

    setDefaultFieldGroupValueForNonSelected(formFieldsList: any) {
        this.tempFieldValues = [];
        const map = new Map<string, string>();
        for (const value in this.finalQueryParamsObj) {
            map.set(value, this.finalQueryParamsObj[value]);
        }
        for (const ffl of formFieldsList) {
            if (!map.get(ffl['fieldId']) && ffl['formFieldValues'].length === 1) {
                this.tempFieldValues = ffl['formFieldValues'];
                if (ffl['fieldDisplayName'] == this.tempFieldValues[0]['name']) {
                    this.finalQueryParamsObj[ffl['fieldId']] = '-1';
                }
            }
        }
    }

    resetFormFieldValues() {
        this.httpCacheService.clearCache();
        this._router.navigateByUrl('v2/app/refresh', {skipLocationChange: true}).then(() =>
            this._router.navigate(['v2/run', this.reportId]));
    }

    goBack() {
        const prevId = this.httpCacheService.getPreviousId(this.reportId) || null;
        const prevIdParent = this.httpCacheService.getPreviousId(prevId) || null;
        if (prevId) {
            if (prevIdParent && prevIdParent === 'parent') {
                this._router.navigate(['v2/run', prevId, this.httpCacheService.getRouteCache(prevId), this.httpCacheService.getRouteGroupCache(prevId), 'false', 'true']);
            } else {
                this._router.navigate(['v2/run', prevId, this.httpCacheService.getRouteCache(prevId), this.httpCacheService.getRouteGroupCache(prevId), 'true', 'true']);
            }
        }
    }

    private delay(ms: number) {
        return new Promise(resolve => setTimeout(resolve, ms));
    }

    private removePrevioustoggleGroupData() {
        for (const formFieldGroupObjItem of this.formFieldGroupObjList) {
            if (formFieldGroupObjItem['name'] == this.oldGroupSelectValue) {
                for (let ffGrpValue = 0; ffGrpValue < formFieldGroupObjItem['formFieldList'].length; ffGrpValue++) {
                    this.finalQueryParamsObj[formFieldGroupObjItem['formFieldList'][ffGrpValue]['fieldId']] = '-1';
                    this.formFieldListValueMap.delete(formFieldGroupObjItem['formFieldList'][ffGrpValue]['fieldId']);
                    this.triggerFormFieldArr = [];
                }

            }
        }
    }

    getTime(){
       for(let i=0; i<=59; i++){
        this.timeStampArray.push(i);
       }
    }

    getHours(){
        for(let i=0; i<=23; i++){
         this.hoursArray.push(i);
        }
     }
}