tango-app-ui-manage-tickets 3.7.0-beta.7 → 3.7.0-beta.70

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/.eslintrc.json +37 -0
  2. package/ng-package.json +7 -0
  3. package/package.json +12 -25
  4. package/src/lib/components/add-csm-modal/add-csm-modal.component.html +32 -0
  5. package/src/lib/components/add-csm-modal/add-csm-modal.component.scss +14 -0
  6. package/src/lib/components/add-csm-modal/add-csm-modal.component.spec.ts +23 -0
  7. package/src/lib/components/add-csm-modal/add-csm-modal.component.ts +94 -0
  8. package/src/lib/components/audit-log/audit-log.component.html +1 -0
  9. package/src/lib/components/audit-log/audit-log.component.scss +0 -0
  10. package/src/lib/components/audit-log/audit-log.component.spec.ts +23 -0
  11. package/src/lib/components/audit-log/audit-log.component.ts +10 -0
  12. package/src/lib/components/audit-mapping-list/audit-mapping-list.component.html +234 -0
  13. package/src/lib/components/audit-mapping-list/audit-mapping-list.component.scss +186 -0
  14. package/src/lib/components/audit-mapping-list/audit-mapping-list.component.spec.ts +23 -0
  15. package/src/lib/components/audit-mapping-list/audit-mapping-list.component.ts +536 -0
  16. package/src/lib/components/audit-metrics/audit-metrics.component.html +345 -0
  17. package/src/lib/components/audit-metrics/audit-metrics.component.scss +34 -0
  18. package/src/lib/components/audit-metrics/audit-metrics.component.spec.ts +23 -0
  19. package/src/lib/components/audit-metrics/audit-metrics.component.ts +292 -0
  20. package/src/lib/components/audit-report-popup/audit-report-popup.component.html +111 -0
  21. package/src/lib/components/audit-report-popup/audit-report-popup.component.scss +101 -0
  22. package/src/lib/components/audit-report-popup/audit-report-popup.component.spec.ts +23 -0
  23. package/src/lib/components/audit-report-popup/audit-report-popup.component.ts +397 -0
  24. package/src/lib/components/audit-retag/audit-retag.component.html +129 -0
  25. package/src/lib/components/audit-retag/audit-retag.component.scss +146 -0
  26. package/src/lib/components/audit-retag/audit-retag.component.spec.ts +23 -0
  27. package/src/lib/components/audit-retag/audit-retag.component.ts +497 -0
  28. package/src/lib/components/comment-model/comment-model.component.html +24 -0
  29. package/src/lib/components/comment-model/comment-model.component.scss +20 -0
  30. package/src/lib/components/comment-model/comment-model.component.spec.ts +23 -0
  31. package/src/lib/components/comment-model/comment-model.component.ts +53 -0
  32. package/src/lib/components/count/count.component.html +54 -0
  33. package/src/lib/components/count/count.component.scss +14 -0
  34. package/src/lib/components/count/count.component.spec.ts +23 -0
  35. package/src/lib/components/count/count.component.ts +82 -0
  36. package/src/lib/components/custom-select/custom-select.component.html +134 -0
  37. package/src/lib/components/custom-select/custom-select.component.scss +204 -0
  38. package/src/lib/components/custom-select/custom-select.component.spec.ts +23 -0
  39. package/src/lib/components/custom-select/custom-select.component.ts +189 -0
  40. package/src/lib/components/filter-options/filter-options.component.html +51 -0
  41. package/src/lib/components/filter-options/filter-options.component.scss +102 -0
  42. package/src/lib/components/filter-options/filter-options.component.spec.ts +23 -0
  43. package/src/lib/components/filter-options/filter-options.component.ts +38 -0
  44. package/src/lib/components/footfall-dic/footfall-dic.component.html +1275 -0
  45. package/src/lib/components/footfall-dic/footfall-dic.component.scss +273 -0
  46. package/src/lib/components/footfall-dic/footfall-dic.component.spec.ts +23 -0
  47. package/src/lib/components/footfall-dic/footfall-dic.component.ts +1206 -0
  48. package/src/lib/components/footfall-dicview/footfall-dicview.component.html +1136 -0
  49. package/src/lib/components/footfall-dicview/footfall-dicview.component.scss +416 -0
  50. package/src/lib/components/footfall-dicview/footfall-dicview.component.spec.ts +23 -0
  51. package/src/lib/components/footfall-dicview/footfall-dicview.component.ts +1168 -0
  52. package/src/lib/components/footfall-popup/footfall-popup.component.html +61 -0
  53. package/src/lib/components/footfall-popup/footfall-popup.component.scss +20 -0
  54. package/src/lib/components/footfall-popup/footfall-popup.component.spec.ts +23 -0
  55. package/src/lib/components/footfall-popup/footfall-popup.component.ts +12 -0
  56. package/src/lib/components/group-select/group-select.component.html +44 -0
  57. package/src/lib/components/group-select/group-select.component.scss +144 -0
  58. package/src/lib/components/group-select/group-select.component.spec.ts +23 -0
  59. package/src/lib/components/group-select/group-select.component.ts +145 -0
  60. package/src/lib/components/re-trigger/re-trigger.component.html +53 -0
  61. package/src/lib/components/re-trigger/re-trigger.component.scss +16 -0
  62. package/src/lib/components/re-trigger/re-trigger.component.spec.ts +23 -0
  63. package/src/lib/components/re-trigger/re-trigger.component.ts +96 -0
  64. package/src/lib/components/reactive-select/reactive-select.component.html +18 -0
  65. package/src/lib/components/reactive-select/reactive-select.component.scss +52 -0
  66. package/src/lib/components/reactive-select/reactive-select.component.spec.ts +23 -0
  67. package/src/lib/components/reactive-select/reactive-select.component.ts +104 -0
  68. package/src/lib/components/remove-audit/remove-audit.component.html +38 -0
  69. package/src/lib/components/remove-audit/remove-audit.component.scss +27 -0
  70. package/src/lib/components/remove-audit/remove-audit.component.spec.ts +23 -0
  71. package/src/lib/components/remove-audit/remove-audit.component.ts +81 -0
  72. package/src/lib/components/start-audit/start-audit.component.html +174 -0
  73. package/src/lib/components/start-audit/start-audit.component.scss +185 -0
  74. package/src/lib/components/start-audit/start-audit.component.spec.ts +23 -0
  75. package/src/lib/components/start-audit/start-audit.component.ts +772 -0
  76. package/src/lib/components/tango-manage-tickets/tango-manage-tickets.component.html +43 -0
  77. package/src/lib/components/tango-manage-tickets/tango-manage-tickets.component.scss +35 -0
  78. package/src/lib/components/tango-manage-tickets/tango-manage-tickets.component.spec.ts +23 -0
  79. package/src/lib/components/tango-manage-tickets/tango-manage-tickets.component.ts +118 -0
  80. package/src/lib/components/ticket-filter-panel/ticket-filter-panel.component.html +386 -0
  81. package/src/lib/components/ticket-filter-panel/ticket-filter-panel.component.scss +87 -0
  82. package/src/lib/components/ticket-filter-panel/ticket-filter-panel.component.spec.ts +23 -0
  83. package/src/lib/components/ticket-filter-panel/ticket-filter-panel.component.ts +493 -0
  84. package/src/lib/components/ticket-footfall-new/ticket-footfall-new.component.html +3751 -0
  85. package/src/lib/components/ticket-footfall-new/ticket-footfall-new.component.scss +1240 -0
  86. package/src/lib/components/ticket-footfall-new/ticket-footfall-new.component.spec.ts +23 -0
  87. package/src/lib/components/ticket-footfall-new/ticket-footfall-new.component.ts +2863 -0
  88. package/src/lib/components/ticketclosepopup/ticketclosepopup.component.html +100 -0
  89. package/src/lib/components/ticketclosepopup/ticketclosepopup.component.scss +34 -0
  90. package/src/lib/components/ticketclosepopup/ticketclosepopup.component.spec.ts +23 -0
  91. package/src/lib/components/ticketclosepopup/ticketclosepopup.component.ts +48 -0
  92. package/src/lib/components/tickets/tickets.component.html +451 -0
  93. package/src/lib/components/tickets/tickets.component.scss +131 -0
  94. package/src/lib/components/tickets/tickets.component.spec.ts +23 -0
  95. package/src/lib/components/tickets/tickets.component.ts +809 -0
  96. package/src/lib/components/viewcategory/viewcategory.component.html +38 -0
  97. package/src/lib/components/viewcategory/viewcategory.component.scss +29 -0
  98. package/src/lib/components/viewcategory/viewcategory.component.spec.ts +23 -0
  99. package/src/lib/components/viewcategory/viewcategory.component.ts +79 -0
  100. package/src/lib/services/audit.service.spec.ts +16 -0
  101. package/src/lib/services/audit.service.ts +98 -0
  102. package/src/lib/services/excel.service.ts +48 -0
  103. package/src/lib/services/ticket.service.spec.ts +16 -0
  104. package/src/lib/services/ticket.service.ts +501 -0
  105. package/src/lib/services/timer.service.spec.ts +16 -0
  106. package/src/lib/services/timer.service.ts +92 -0
  107. package/src/lib/tango-manage-tickets-routing.module.ts +37 -0
  108. package/src/lib/tango-manage-tickets.module.ts +68 -0
  109. package/{public-api.d.ts → src/public-api.ts} +8 -2
  110. package/tsconfig.lib.json +14 -0
  111. package/tsconfig.lib.prod.json +10 -0
  112. package/tsconfig.spec.json +14 -0
  113. package/esm2022/lib/components/add-csm-modal/add-csm-modal.component.mjs +0 -98
  114. package/esm2022/lib/components/audit-log/audit-log.component.mjs +0 -11
  115. package/esm2022/lib/components/audit-metrics/audit-metrics.component.mjs +0 -298
  116. package/esm2022/lib/components/comment-model/comment-model.component.mjs +0 -58
  117. package/esm2022/lib/components/count/count.component.mjs +0 -89
  118. package/esm2022/lib/components/footfall-dic/footfall-dic.component.mjs +0 -894
  119. package/esm2022/lib/components/group-select/group-select.component.mjs +0 -155
  120. package/esm2022/lib/components/re-trigger/re-trigger.component.mjs +0 -96
  121. package/esm2022/lib/components/reactive-select/reactive-select.component.mjs +0 -108
  122. package/esm2022/lib/components/tango-manage-tickets/tango-manage-tickets.component.mjs +0 -127
  123. package/esm2022/lib/components/tickets/tickets.component.mjs +0 -793
  124. package/esm2022/lib/services/excel.service.mjs +0 -45
  125. package/esm2022/lib/services/ticket.service.mjs +0 -158
  126. package/esm2022/lib/tango-manage-tickets-routing.module.mjs +0 -24
  127. package/esm2022/lib/tango-manage-tickets.module.mjs +0 -54
  128. package/esm2022/public-api.mjs +0 -6
  129. package/esm2022/tango-app-ui-manage-tickets.mjs +0 -5
  130. package/fesm2022/tango-app-ui-manage-tickets.mjs +0 -2914
  131. package/fesm2022/tango-app-ui-manage-tickets.mjs.map +0 -1
  132. package/index.d.ts +0 -5
  133. package/lib/components/add-csm-modal/add-csm-modal.component.d.ts +0 -30
  134. package/lib/components/audit-log/audit-log.component.d.ts +0 -5
  135. package/lib/components/audit-metrics/audit-metrics.component.d.ts +0 -59
  136. package/lib/components/comment-model/comment-model.component.d.ts +0 -17
  137. package/lib/components/count/count.component.d.ts +0 -23
  138. package/lib/components/footfall-dic/footfall-dic.component.d.ts +0 -130
  139. package/lib/components/group-select/group-select.component.d.ts +0 -33
  140. package/lib/components/re-trigger/re-trigger.component.d.ts +0 -32
  141. package/lib/components/reactive-select/reactive-select.component.d.ts +0 -32
  142. package/lib/components/tango-manage-tickets/tango-manage-tickets.component.d.ts +0 -27
  143. package/lib/components/tickets/tickets.component.d.ts +0 -84
  144. package/lib/services/excel.service.d.ts +0 -10
  145. package/lib/services/ticket.service.d.ts +0 -49
  146. package/lib/tango-manage-tickets-routing.module.d.ts +0 -7
  147. package/lib/tango-manage-tickets.module.d.ts +0 -21
@@ -0,0 +1,772 @@
1
+ import { Component, OnInit, HostListener, ViewChild, viewChild, OnDestroy, ChangeDetectorRef } from '@angular/core';
2
+ import { ActivatedRoute, Route, Router } from '@angular/router';
3
+ import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
4
+ import { Observable, Subject, timer, Subscription } from 'rxjs';
5
+ import { AuditService } from '../../services/audit.service';
6
+ import { ToastService } from 'tango-app-ui-shared';
7
+ import { NgxSpinnerService } from 'ngx-spinner';
8
+ import { RemoveAuditComponent } from '../remove-audit/remove-audit.component';
9
+ import * as LZString from 'lz-string';
10
+ import { ExcelService } from '../../services/excel.service';
11
+ import { takeUntil } from 'rxjs';
12
+ import { TimerService } from '../../services/timer.service';
13
+ import { ViewcategoryComponent } from '../viewcategory/viewcategory.component';
14
+
15
+ @Component({
16
+ selector: 'lib-start-audit',
17
+ templateUrl: './start-audit.component.html',
18
+ styleUrl: './start-audit.component.scss'
19
+ })
20
+ export class StartAuditComponent implements OnInit, OnDestroy {
21
+ junkimage: any;
22
+ employeimage: any;
23
+ filedetails: any = {};
24
+ datareason: any;
25
+ limit: any = 500;
26
+ nextId: any = ''
27
+ spinnerstart = true
28
+ submitted: boolean = false;
29
+ auditId: any;
30
+ customercount = 0;
31
+ junkcount = 0;
32
+ employeecount = 0;
33
+ demographic: any;
34
+ id: any = '';
35
+ queueName: any = '';
36
+ auditmappingdata: any;
37
+ totalfile: any = 0;
38
+ auditLoading = true;
39
+ badge = false;
40
+ imagelist: any = "./assets/tango/Images/loading-img.png"
41
+ selected: any = [];
42
+ selectedType: any;
43
+ auditLoading1 = true;
44
+ Nodata = false;
45
+ counter: any = 1;
46
+ clickedImages: boolean[] = [];
47
+ @ViewChild('confirmDraft') confirmDraft: any;
48
+ @ViewChild('confirmerror') confirmerror: any;
49
+ Errormsg: any;
50
+ storedetails: any;
51
+ openmodel: boolean = false;
52
+ private readonly destroy$ = new Subject();
53
+ getBack: boolean = false;
54
+ category: any = []
55
+ @HostListener("window:scroll", [])
56
+ onScroll(): void {
57
+ if ('totalfiles' in sessionStorage) {
58
+ let filedata = JSON.parse(sessionStorage.getItem('totalfiles') || '{}')
59
+ if (filedata?.filedetails?.nextToken) {
60
+ if (Math.ceil(window.innerHeight + window.scrollY) >= document.body.scrollHeight) {//this condition failed when the browser inspect screen open in horizontal
61
+ if (this.spinnerstart) {
62
+ this.spinnerService.show();
63
+ this.getMapping('nextId')
64
+ }
65
+ }
66
+ }
67
+ } else {
68
+ var result: any = window.confirm("Something Went Wrong. Please clear browser cache or Use incognito window")
69
+ if (result) {
70
+
71
+ this.router.navigate(['/manage/tickets'], { queryParams: { type: 'footfall' } })
72
+ } else {
73
+
74
+ }
75
+ }
76
+ }
77
+
78
+ @HostListener('window:keydown', ['$event'])
79
+ handleKeyPress(event: KeyboardEvent) {
80
+ if (this.openmodel) return;
81
+ // if (event.key === 'g' || event.code === 'KeyG') {
82
+ // var group = this.auditmappingdata.filter((data: any) => data.selected === true)
83
+ // if (group.length > 0) {
84
+ // if (group.length == 1) {
85
+ // this.toastr.getErrorToast('Please Select multiple file then add to Group')
86
+ // } else {
87
+ // let dummyarray = group.shift()
88
+ // var groupimages: any = []
89
+ // group.forEach((data: any) => {
90
+ // this.auditmappingdata.splice(this.auditmappingdata.findIndex(({ img_name }: { img_name: string }) => img_name == data.img_name), 1);
91
+ // groupimages.push(data.mappedid[0])
92
+ // })
93
+ // this.demographic = this.auditmappingdata.filter((data: any) => data.demographic === 'd').length;
94
+ // dummyarray.count = dummyarray.count + groupimages.length
95
+ // dummyarray.selected = false
96
+ // dummyarray.demographic = ''
97
+ // dummyarray.mappedid = [...dummyarray.mappedid, ...groupimages]
98
+ // const jsonString = JSON.stringify(this.auditmappingdata);
99
+ // const compressedData = LZString.compress(jsonString);
100
+ // sessionStorage.setItem('audit', compressedData)
101
+ // }
102
+
103
+ // // this.initial_data_loading()
104
+ // } else {
105
+ // this.toastr.getErrorToast('Please Select file then add to Group')
106
+ // }
107
+ // }
108
+ const pressed = (event.key || '').toLowerCase();
109
+ const matched = this.category.find((m: any) => {
110
+ if (!m.key) return false;
111
+ const mapKey = m.key.toLowerCase();
112
+ // match by event.key (preferred) OR by event.code like 'KeyJ'
113
+ return pressed === mapKey || event.code === `Key${mapKey.toUpperCase()}`;
114
+ });
115
+
116
+ if (!matched) return
117
+ if (matched) {
118
+ var newData = this.auditmappingdata.filter((data: any) => data.selected === true)
119
+ if (newData.length > 0) {
120
+ var oldData = JSON.parse(sessionStorage.getItem(matched?.type) || '{}')
121
+ if (Number(oldData.length) > 0) {
122
+ newData = [...oldData, ...newData]
123
+ } else {
124
+ newData = newData
125
+ }
126
+ this.category.map((data: any) => {
127
+ if (data.type === matched?.type) {
128
+ data.count = newData.length
129
+ }
130
+ })
131
+ sessionStorage.setItem(matched?.type, JSON.stringify(newData))
132
+ this.auditmappingdata = this.auditmappingdata.filter((data: any) => data.selected === false)
133
+ const jsonString = JSON.stringify(this.auditmappingdata);
134
+ const compressedData = LZString.compress(jsonString);
135
+ sessionStorage.setItem('audit', compressedData)
136
+ this.toastr.getSuccessToast(`${matched?.type} Added Succesfully!`);
137
+ } else {
138
+ this.toastr.getErrorToast(`Please Select file then add to ${matched?.type} `)
139
+ }
140
+
141
+ }
142
+
143
+ }
144
+
145
+ constructor(
146
+ private excel: ExcelService,
147
+ private auditservice: AuditService,
148
+ private toastr: ToastService,
149
+ private router: Router, private cd: ChangeDetectorRef,
150
+ private modalService: NgbModal, private timerService: TimerService,
151
+ private spinnerService: NgxSpinnerService, private route: ActivatedRoute
152
+ ) {
153
+ this.selectedType = this.route.snapshot.paramMap.get('type')
154
+ }
155
+ destroy = new Subject();
156
+ showDialog = false;
157
+ timePassed: number = 0;
158
+ subscription: Subscription | null = null;
159
+ formattedTime: string = '00:00:00';
160
+
161
+ notice = 'session expired';
162
+ showNotice = false;
163
+ rxjsTimer: Subscription[] = [];
164
+
165
+ ngOnInit(): void {
166
+
167
+ this.getAuditConfig()
168
+ if ('user-info' in localStorage) {
169
+ var user = JSON.parse(localStorage.getItem('user-info') || '{}')
170
+ this.id = user._id
171
+ }
172
+ if ('audit' in sessionStorage) {
173
+ let stringifydata = sessionStorage.getItem('audit') || '{}'
174
+ const decompressedData = LZString.decompress(stringifydata);
175
+ var auditdata = JSON.parse(decompressedData || '{}')
176
+ if (auditdata.length > 0) {
177
+ this.auditmappingdata = auditdata;
178
+ this.customercount = this.auditmappingdata.length
179
+ }
180
+ this.auditLoading = false;
181
+ this.setTimer();
182
+ } else {
183
+ var filedata
184
+ if ('totalfiles' in sessionStorage) {
185
+ filedata = JSON.parse(sessionStorage.getItem('totalfiles') || '{}')
186
+ this.getMapping()
187
+ }
188
+ }
189
+ }
190
+
191
+ setTimer() {
192
+ this.subscription = this.timerService.getTimePassed().subscribe(time => {
193
+ this.timePassed = time;
194
+ this.formattedTime = this.timerService.formatTime(time);
195
+ this.cd.detectChanges();
196
+ });
197
+ this.timerService.startTimer();
198
+ document.addEventListener('mousemove', this.handleGlobalMouseEvent);
199
+ document.addEventListener('click', this.handleGlobalMouseEvent);
200
+ document.addEventListener('mouseenter', this.handleGlobalMouseEvent);
201
+ document.addEventListener('scroll', this.handleGlobalMouseEvent);
202
+ }
203
+
204
+ handleGlobalMouseEvent = (): void => {
205
+ this.timerService.startTimer();
206
+ }
207
+
208
+
209
+ ngOnDestroy(): void {
210
+ this.destroy$.next(true);
211
+ this.destroy$.complete();
212
+ document.removeEventListener('mousemove', this.handleGlobalMouseEvent);
213
+ document.removeEventListener('click', this.handleGlobalMouseEvent);
214
+ document.removeEventListener('mouseenter', this.handleGlobalMouseEvent);
215
+ document.removeEventListener('scroll', this.handleGlobalMouseEvent);
216
+ this.timerService.clearTimer()
217
+ }
218
+
219
+ initial_data_loading() {
220
+ if ('audit' in sessionStorage) {
221
+ let stringifydata = sessionStorage.getItem('audit') || '{}'
222
+ const decompressedData = LZString.decompress(stringifydata);
223
+ var auditdata = JSON.parse(decompressedData || '{}')
224
+ if (auditdata.length > 0) {
225
+ this.auditmappingdata = auditdata;
226
+ this.demographic = this.auditmappingdata.filter((data: any) => data.demographic === 'd').length;
227
+ this.customercount = this.auditmappingdata.length
228
+ this.auditLoading = false;
229
+ } else {
230
+ this.auditmappingdata = []
231
+ this.customercount = 0
232
+ }
233
+ }
234
+
235
+
236
+ this.category.map((data: any) => {
237
+ var count = JSON.parse(sessionStorage.getItem(data.type) || '{}')
238
+ data.count = count?.length
239
+ })
240
+ if ('retag' in sessionStorage) {
241
+ var retagiamge = JSON.parse(sessionStorage.getItem('retag') || '[]')
242
+ if (retagiamge.length > 0) {
243
+ let stringifydata = sessionStorage.getItem('audit') || '{}'
244
+ const decompressedData = LZString.decompress(stringifydata);
245
+ var customer = JSON.parse(decompressedData || '{}')
246
+ customer = [...customer, ...retagiamge]
247
+ const jsonString = JSON.stringify(this.auditmappingdata);
248
+ const compressedData = LZString.compress(jsonString);
249
+ sessionStorage.setItem('audit', compressedData)
250
+ sessionStorage.removeItem('retag')
251
+ }
252
+ }
253
+ if ('totalfiles' in sessionStorage) {
254
+ var files = JSON.parse(sessionStorage.getItem('totalfiles') || '{}')
255
+ this.totalfile = files?.totalfiles
256
+ this.filedetails = files?.filedetails
257
+ this.storedetails = files?.storedetails
258
+ }
259
+ }
260
+ toggleImage(img_name: any) {
261
+ this.selected.push(img_name)
262
+ this.auditmappingdata.map((data: any) => {
263
+
264
+ if (data.img_name == img_name) {
265
+ if (data.mappedid.length == 1) {
266
+ data.selected = !data.selected
267
+ } else {
268
+ data.dropped = !data.dropped
269
+ }
270
+ }
271
+ })
272
+ }
273
+ getAuditConfig() {
274
+
275
+ let filedata = JSON.parse(sessionStorage.getItem('totalfiles') || '{}')
276
+ this.auditservice.getAuditconfig(filedata?.filedetails?.clientId).pipe(takeUntil(this.destroy$)).subscribe({
277
+ next: (res: any) => {
278
+ if (res && res?.code == 200) {
279
+
280
+ this.category = res.data.footfallDirectoryConfigs.taggingLimitation
281
+ this.category.map((data: any) => {
282
+ if (data?.type in sessionStorage) {
283
+
284
+ } else {
285
+ sessionStorage.setItem(data.type, JSON.stringify([]))
286
+ }
287
+ })
288
+ this.initial_data_loading()
289
+
290
+ }
291
+ }
292
+ })
293
+ }
294
+ getMapping(nextId?: any) {
295
+ this.auditLoading = true;
296
+ this.spinnerstart = false
297
+ let filedata = JSON.parse(sessionStorage.getItem('totalfiles') || '{}')
298
+ let tickettype = sessionStorage.getItem('ticketType')
299
+ console.log("🚀 ~ StartAuditComponent ~ getMapping ~ tickettype:", tickettype)
300
+ let payload = {
301
+ storeId: filedata?.filedetails?.storeId,
302
+ limit: this.limit,
303
+ nextId: filedata?.filedetails?.nextToken ? filedata?.filedetails?.nextToken : '',
304
+ Date: filedata?.filedetails?.Date,
305
+ count: filedata?.totalfiles,
306
+ tickettype:tickettype
307
+ }
308
+
309
+
310
+ this.auditservice.getAuditMapping(payload).pipe(takeUntil(this.destroy$)).subscribe({
311
+ next: (res: any) => {
312
+ if (res && res?.code == 200) {
313
+ this.storedetails = res?.data;
314
+ setTimeout(() => {
315
+ if (res?.data?.file?.nextToken) {
316
+ this.getMapping(res?.data?.file?.nextToken)
317
+ }
318
+ }, 100)
319
+ if (res?.data?.isDraft) {
320
+ sessionStorage.setItem('timeSpent', JSON.stringify(res?.data?.timeSpent));
321
+ this.spinnerstart = false;
322
+
323
+ this.category.map((data: any) => {
324
+
325
+ let filterData = res?.data?.result.filter((x: any) => x.type === data.type)
326
+
327
+ sessionStorage.setItem(data.type, JSON.stringify(filterData[0].value))
328
+ })
329
+ let customerData = res?.data?.result.filter((x: any) => x.type === 'customer')
330
+
331
+ this.auditmappingdata = customerData[0].value
332
+ const jsonString = JSON.stringify(customerData[0].value);
333
+ const compressedData = LZString.compress(jsonString);
334
+ sessionStorage.setItem('audit', compressedData)
335
+
336
+
337
+ this.totalfile = res?.data?.count;
338
+ this.filedetails = res?.data?.file;
339
+
340
+
341
+ this.category.map((data: any) => {
342
+
343
+ var count = JSON.parse(sessionStorage.getItem(data.type) || '{}')
344
+ data.count = count?.length
345
+ })
346
+
347
+ if (res?.data?.result?.retag_image?.length > 0) {
348
+ let stringifydata = sessionStorage.getItem('audit') || '{}'
349
+ const decompressedData = LZString.decompress(stringifydata);
350
+ var customer = JSON.parse(decompressedData || '{}')
351
+ customer = [...customer, ...res.data.result.retag_image]
352
+ this.auditmappingdata = customer;
353
+ const jsonString = JSON.stringify(customer);
354
+ const compressedData = LZString.compress(jsonString);
355
+ sessionStorage.setItem('audit', compressedData)
356
+ }
357
+
358
+ var totalfiles = {
359
+ "storedetails": {
360
+ "storeName": res?.data?.storeName,
361
+ "address": res?.data?.address
362
+ },
363
+ "totalfiles": this.storedetails?.count,
364
+ "auditId": res?.data.file?.auditId,
365
+ "filedetails": {
366
+ "storeId": this.storedetails?.file?.storeId,
367
+ "Date": res?.data?.file?.Date,
368
+ "userId": res?.data?.file?.userId,
369
+ "clientId": res?.data?.file?.clientId,
370
+ }
371
+ }
372
+ sessionStorage.setItem('totalfiles', JSON.stringify(totalfiles))
373
+ this.auditLoading = false;
374
+ this.setTimer();
375
+ } else {
376
+ this.spinnerstart = false
377
+ this.spinnerService.hide();
378
+ let filedata = JSON.parse(sessionStorage.getItem('totalfiles') || '{}')
379
+ if (filedata?.filedetails?.nextToken) {
380
+ this.auditLoading = false;
381
+ this.auditId = res.data.file?.auditId;
382
+ this.totalfile = res?.data?.count;
383
+ this.filedetails = res?.data?.file;
384
+ this.filedetails.zoneName = res?.data?.file?.zoneName;
385
+ if ('audit' in sessionStorage) {
386
+ if (this.auditmappingdata?.length > 0) {
387
+ this.auditmappingdata = [...this.auditmappingdata, ...res?.data?.result]
388
+ this.customercount = this.auditmappingdata?.length
389
+ }
390
+ }
391
+ } else {
392
+ this.auditLoading = false;
393
+ this.auditLoading1 = false;
394
+ this.filedetails = res?.data?.file;
395
+ this.auditId = res.data.file?.auditId;
396
+ this.auditmappingdata = res?.data?.result;
397
+ this.totalfile = res?.data?.count;
398
+ this.filedetails.queueName = this.queueName;
399
+ this.filedetails.zoneName = res?.data?.file?.zoneName;
400
+ }
401
+ const jsonString = JSON.stringify(this.auditmappingdata);
402
+ const compressedData = LZString.compress(jsonString);
403
+ sessionStorage.setItem('audit', compressedData)
404
+ let obj = {
405
+ totalfiles: this.totalfile,
406
+ filedetails: this.filedetails,
407
+ auditId: this.auditId,
408
+
409
+ storedetails: {
410
+ "storeName": res?.data?.storeName,
411
+ "address": res?.data?.address
412
+ },
413
+ }
414
+ sessionStorage.setItem('totalfiles', JSON.stringify(obj))
415
+ this.spinnerstart = true
416
+ this.setTimer();
417
+ }
418
+
419
+ } else if (!res || res.code == 204) {
420
+ if (this.counter < 6) {
421
+ this.counter = this.counter + 1;
422
+ this.getMapping()
423
+ this.showDialog = true;
424
+ } else {
425
+ this.auditLoading = false;
426
+ if (!nextId) { this.Nodata = true } else { }
427
+ this.submitted = true;
428
+ this.destroy.next(true);
429
+ this.destroy.complete();
430
+ this.showNotice = true;
431
+ }
432
+ }
433
+
434
+ },
435
+ error: (err: any) => {
436
+
437
+ if (err?.status == 404) {
438
+ let filedata = JSON.parse(sessionStorage.getItem('totalfiles') || '{}');
439
+ if (filedata.filedetails && filedata.filedetails.nextToken) {
440
+ delete filedata.filedetails.nextToken;
441
+ sessionStorage.setItem('totalfiles', JSON.stringify(filedata));
442
+ this.getMapping('')
443
+ }
444
+ } else {
445
+ this.toastr.getErrorToast(err?.error?.message)
446
+ }
447
+ }
448
+ })
449
+ }
450
+
451
+ removeaudit(data: any) {
452
+ const modalRef = this.modalService.open(RemoveAuditComponent, {
453
+ size: 'lg',
454
+ centered: true,
455
+ backdrop: 'static',
456
+ keyboard: false
457
+ })
458
+ modalRef.componentInstance.data = data,
459
+ modalRef.closed.subscribe((res: any) => {
460
+ if (res && res?.reload) {
461
+ this.initial_data_loading()
462
+ }
463
+ })
464
+ }
465
+ allowDrop(event: any) {
466
+ event.preventDefault();
467
+ }
468
+
469
+ dragImage(event: any) {
470
+ event.dataTransfer.setData('text/plain', event.target.id);
471
+ }
472
+
473
+ dropImage(event: any) {
474
+ event.preventDefault();
475
+ const draggedImageId = event.dataTransfer.getData('text/plain');
476
+ const draggedImage = document.getElementById(draggedImageId);
477
+ event.target.appendChild(draggedImage);
478
+ const dropZone = event.target;
479
+ this.auditmappingdata.map((data: any, index: number) => {
480
+ if (data.img_name == dropZone.id) {
481
+ if (data.mappedid.length > 0) {
482
+ var findone = this.auditmappingdata.filter((data: any) => data.img_name == draggedImageId)
483
+
484
+ if (findone.length > 0) {
485
+ data.count = data.count + findone[0].count
486
+ data.mappedid = [...data.mappedid, ...findone[0].mappedid]
487
+ }
488
+ if ('duplicate' in sessionStorage) {
489
+ let filedata = JSON.parse(sessionStorage.getItem('duplicate') || '{}')
490
+ let filteredData = findone[0].mappedid.filter((data: any) => data.img_id === findone[0].img_id)
491
+ let insertObj: any = {}
492
+ insertObj.img_id = filteredData[0]?.img_id
493
+ insertObj.img_name = filteredData[0]?.img_name
494
+ insertObj.img_path = filteredData[0]?.img_path
495
+ insertObj.mappedid = [
496
+ {
497
+ img_id: filteredData[0]?.img_id,
498
+ img_name: filteredData[0]?.img_name,
499
+ img_path: filteredData[0]?.img_path
500
+ }
501
+ ]
502
+
503
+
504
+ filedata = [...filedata, ...[insertObj]]
505
+
506
+ sessionStorage.setItem('duplicate', JSON.stringify(filedata))
507
+ }
508
+ this.category.map((data: any) => {
509
+ var count = JSON.parse(sessionStorage.getItem(data.type) || '{}')
510
+ data.count = count?.length
511
+ })
512
+ } else {
513
+ data.count = data.count + 1
514
+ data.mappedid.push(draggedImageId)
515
+ }
516
+ }
517
+ })
518
+
519
+
520
+
521
+ this.auditmappingdata.splice(this.auditmappingdata.findIndex(({ img_name }: { img_name: string }) => img_name == draggedImageId), 1);
522
+ this.auditmappingdata.map((data: any) => data.selected = false)
523
+ const jsonString = JSON.stringify(this.auditmappingdata);
524
+ const compressedData = LZString.compress(jsonString);
525
+ sessionStorage.setItem('audit', compressedData)
526
+ }
527
+
528
+ dragStart(event: DragEvent) {
529
+ const target = event.target as HTMLImageElement;
530
+ event.dataTransfer?.setData('text/plain', target.id);
531
+ }
532
+
533
+ Reviewdata() {
534
+ let filedata = JSON.parse(sessionStorage.getItem('totalfiles') || '{}')
535
+ if (filedata?.filedetails?.nextToken) {
536
+ this.toastr.getErrorToast('Scroll Down to bottom load the files before Move to Next page!');
537
+ } else {
538
+ this.submitted = true;
539
+ var totalfile: any = JSON.parse(sessionStorage.getItem('totalfiles') || '{}');
540
+ let stringifydata = sessionStorage.getItem('audit') || '{}'
541
+ const decompressedData = LZString.decompress(stringifydata);
542
+ var customer = JSON.parse(decompressedData || '{}')
543
+ let storedData = [
544
+ {
545
+ type: "customer",
546
+ value: customer ? customer : [],
547
+ }
548
+ ]
549
+
550
+ this.category.map((data: any) => {
551
+ let sessionvalue = JSON.parse(sessionStorage.getItem(data.type) || '[]');
552
+ storedData.push({
553
+ type: data.type,
554
+ value: sessionvalue && sessionvalue.length > 0 ? sessionvalue : []
555
+ })
556
+ })
557
+ var inserobj: any = {
558
+ userCommands: this.datareason ? this.datareason : "",
559
+ customerCount: customer ? customer?.length : 0,
560
+ storeId: totalfile?.filedetails?.storeId,
561
+ auditId: totalfile?.auditId ? totalfile?.auditId : totalfile?.filedetails.auditId,
562
+ fileDate: totalfile?.filedetails?.Date,
563
+ totalCount: totalfile?.totalfiles ? totalfile.totalfiles : 0,
564
+ retagCount: 0,
565
+ timeSpent: this.timePassed,
566
+ retagImage: [],
567
+ draftedData: storedData
568
+ }
569
+
570
+ this.auditservice.saveDraft(inserobj).pipe(takeUntil(this.destroy$)).subscribe({
571
+ next: (res: any) => {
572
+ if (res && res?.code == 200) {
573
+ this.submitted = false;
574
+ this.router.navigate(["/manage/tickets/mapping-list"])
575
+ } if (res && res.code == 203) {
576
+ this.Errormsg = res.message
577
+ const modalRef = this.modalService.open(this.confirmerror, { centered: true })
578
+ modalRef.result.then((result) => {
579
+ if (result.isConfirmed) {
580
+ this.router.navigate(['/manage/tickets'], { queryParams: { type: 'footfall' } })
581
+ }
582
+ })
583
+ }
584
+ },
585
+ error: (err: any) => {
586
+ if (err?.code == 400 || err?.code == 204 || err?.code == 404 || err?.code == 500) {
587
+ this.Errormsg = err.message
588
+ const modalRef = this.modalService.open(this.confirmerror, { centered: true })
589
+ modalRef.result.then((result) => {
590
+ if (result.isConfirmed) {
591
+ this.submitted = true;
592
+ }
593
+ })
594
+ }
595
+ }
596
+ })
597
+ }
598
+
599
+ }
600
+
601
+ viewcategory(data: any) {
602
+ const modalRef = this.modalService.open(ViewcategoryComponent, {
603
+ size: 'lg',
604
+ centered: true,
605
+ backdrop: 'static',
606
+ keyboard: false
607
+ })
608
+ modalRef.componentInstance.data = data
609
+ modalRef.componentInstance.imageList = data,
610
+ modalRef.closed.subscribe((res: any) => {
611
+ if (res && res?.reload) {
612
+ this.initial_data_loading()
613
+ }
614
+ })
615
+ }
616
+ async savedraft() {
617
+ let filedata = JSON.parse(sessionStorage.getItem('totalfiles') || '{}')
618
+ if (filedata?.filedetails?.nextToken) {
619
+ this.toastr.getErrorToast('Scroll Down to bottom load the files before save!');
620
+ } else {
621
+ this.openmodel = true;
622
+ const modalRef = this.modalService.open(this.confirmDraft, {
623
+ centered: true, size: 'md'
624
+ })
625
+ modalRef.result.then((result) => {
626
+
627
+
628
+ if (result === 'isDenied') {
629
+ var totalfile: any = JSON.parse(sessionStorage.getItem('totalfiles') || '{}');
630
+ let stringifydata = sessionStorage.getItem('audit') || '{}'
631
+ const decompressedData = LZString.decompress(stringifydata);
632
+ var customer = JSON.parse(decompressedData || '{}')
633
+ let storedData = [
634
+ {
635
+ type: "customer",
636
+ value: customer ? customer : [],
637
+ }
638
+ ]
639
+
640
+ this.category.map((data: any) => {
641
+ let sessionvalue = JSON.parse(sessionStorage.getItem(data.type) || '[]');
642
+ storedData.push({
643
+ type: data.type,
644
+ value: sessionvalue && sessionvalue.length > 0 ? sessionvalue : []
645
+ })
646
+ })
647
+
648
+ var inserobj: any = {
649
+ userCommands: this.datareason ? this.datareason : "",
650
+ // userId: user?.user,
651
+ storeId: totalfile?.filedetails?.storeId,
652
+ fileDate: totalfile?.filedetails?.Date,
653
+ auditId: totalfile?.auditId ? totalfile?.auditId : totalfile?.filedetails.auditId,
654
+ totalCount: totalfile?.totalfiles ? totalfile.totalfiles : 0,
655
+ customerCount: customer ? customer?.length : 0,
656
+ retagCount: 0,
657
+ timeSpent: this.timePassed,
658
+ retagImage: [],
659
+ draftedData: storedData
660
+ }
661
+ if (inserobj?.auditId && inserobj?.auditId != '') {
662
+ this.auditservice.saveDraft(inserobj).pipe(takeUntil(this.destroy$)).subscribe({
663
+ next: (res: any) => {
664
+ if (res && res.code == 200) {
665
+ this.submitted = false;
666
+ this.toastr.getSuccessToast(res?.data?.result)
667
+ } else {
668
+ if (res && res.code == 203) {
669
+ this.Errormsg = res.error;
670
+ const modalRef = this.modalService.open(this.confirmerror)
671
+ modalRef.result.then((result) => {
672
+ if (result.isConfirmed) {
673
+ this.router.navigate(['/manage/tickets'], { queryParams: { type: 'footfall' } })
674
+ }
675
+ })
676
+ }
677
+ }
678
+ },
679
+ error: (err: any) => {
680
+ if (err?.code == 400 || err?.code == 204 || err?.code == 404 || err?.code == 500) {
681
+ this.toastr.getErrorToast('File not saved!')
682
+ }
683
+ }
684
+ })
685
+ } else {
686
+ this.router.navigate(['/manage/tickets'], { queryParams: { type: 'footfall' } })
687
+ }
688
+
689
+ } else if (result === 'isConfirmed') {
690
+ var totalfile: any = JSON.parse(sessionStorage.getItem('totalfiles') || '{}');
691
+
692
+ let stringifydata = sessionStorage.getItem('audit') || '{}'
693
+ const decompressedData = LZString.decompress(stringifydata);
694
+ var customer = JSON.parse(decompressedData || '{}')
695
+ let storedData = [
696
+ {
697
+ type: "customer",
698
+ value: this.auditmappingdata ? this.auditmappingdata : [],
699
+ }
700
+ ]
701
+
702
+ this.category.map((data: any) => {
703
+ let sessionvalue = JSON.parse(sessionStorage.getItem(data.type) || '[]');
704
+ storedData.push({
705
+ type: data.type,
706
+ value: sessionvalue && sessionvalue.length > 0 ? sessionvalue : []
707
+ })
708
+ })
709
+ var inserobj: any = {
710
+ userCommands: this.datareason ? this.datareason : "",
711
+ customerCount: customer ? customer?.length : 0,
712
+ storeId: totalfile?.filedetails?.storeId,
713
+ auditType: totalfile?.filedetails?.type,
714
+ fileDate: totalfile?.filedetails?.Date,
715
+ auditId: totalfile?.auditId ? totalfile?.auditId : totalfile?.filedetails.auditId,
716
+ totalCount: totalfile?.totalfiles ? totalfile.totalfiles : 0,
717
+ retagCount: 0,
718
+ timeSpent: this.timePassed,
719
+ retagImage: [],
720
+ draftedData: storedData
721
+ }
722
+ if (inserobj?.auditId && inserobj.auditId !== '') {
723
+
724
+ this.auditservice.saveDraft(inserobj).pipe(takeUntil(this.destroy$)).subscribe({
725
+ next: (res: any) => {
726
+ if (res && res.code == 200) {
727
+ this.submitted = false;
728
+ this.router.navigate(['/manage/tickets'], { queryParams: { type: 'footfall' } })
729
+ } else {
730
+ if (res && res.code == 203) {
731
+ this.Errormsg = res.error;
732
+ const modalRef = this.modalService.open(this.confirmerror)
733
+ modalRef.result.then((result) => {
734
+ if (result.isConfirmed) {
735
+ this.router.navigate(['/manage/tickets'], { queryParams: { type: 'footfall' } })
736
+ }
737
+ })
738
+ }
739
+
740
+ }
741
+ },
742
+ error: (err: any) => {
743
+ if (err?.code == 400 || err?.code == 204 || err?.code == 404 || err?.code == 500) {
744
+ this.toastr.getErrorToast('File not saved!')
745
+ }
746
+ }
747
+ })
748
+ } else {
749
+ this.router.navigate(['/manage/tickets'], { queryParams: { type: 'footfall' } })
750
+ }
751
+ } else {
752
+
753
+ }
754
+ })
755
+ modalRef.result.finally(() => {
756
+ this.openmodel = false;
757
+ });
758
+ }
759
+ }
760
+
761
+ backtotickets() {
762
+ this.savedraft();
763
+ // this.router.navigate(['/manage/tickets'], { queryParams: { type: 'footfall' } })
764
+
765
+ }
766
+ cameraPreview() {
767
+ // const ModalRef = this.modalService.open(CameraPreviewComponent,{
768
+ // centered: true,
769
+ // size:'lg'
770
+ // })
771
+ }
772
+ }