tango-app-ui-analyse-trax 3.9.2 → 3.9.3

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 (470) 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/action-centre/action-centre.component.html +607 -0
  5. package/src/lib/components/action-centre/action-centre.component.scss +185 -0
  6. package/src/lib/components/action-centre/action-centre.component.spec.ts +23 -0
  7. package/src/lib/components/action-centre/action-centre.component.ts +279 -0
  8. package/src/lib/components/activity-log/activity-log.component.html +84 -0
  9. package/src/lib/components/activity-log/activity-log.component.scss +33 -0
  10. package/src/lib/components/activity-log/activity-log.component.spec.ts +23 -0
  11. package/src/lib/components/activity-log/activity-log.component.ts +137 -0
  12. package/src/lib/components/activity-log-v2/activity-log-v2.component.html +189 -0
  13. package/src/lib/components/activity-log-v2/activity-log-v2.component.scss +162 -0
  14. package/src/lib/components/activity-log-v2/activity-log-v2.component.spec.ts +23 -0
  15. package/src/lib/components/activity-log-v2/activity-log-v2.component.ts +517 -0
  16. package/src/lib/components/activity-log-v2/log-view-popup/date-range-picker/date-range-picker.component.html +19 -0
  17. package/src/lib/components/activity-log-v2/log-view-popup/date-range-picker/date-range-picker.component.scss +148 -0
  18. package/src/lib/components/activity-log-v2/log-view-popup/date-range-picker/date-range-picker.component.spec.ts +23 -0
  19. package/src/lib/components/activity-log-v2/log-view-popup/date-range-picker/date-range-picker.component.ts +141 -0
  20. package/src/lib/components/activity-log-v2/log-view-popup/store-user-dropdown/store-user-dropdown.component.html +42 -0
  21. package/src/lib/components/activity-log-v2/log-view-popup/store-user-dropdown/store-user-dropdown.component.scss +49 -0
  22. package/src/lib/components/activity-log-v2/log-view-popup/store-user-dropdown/store-user-dropdown.component.spec.ts +23 -0
  23. package/src/lib/components/activity-log-v2/log-view-popup/store-user-dropdown/store-user-dropdown.component.ts +22 -0
  24. package/src/lib/components/activity-log-v2/log-view-popup/view-action/view-action.component.html +724 -0
  25. package/src/lib/components/activity-log-v2/log-view-popup/view-action/view-action.component.scss +217 -0
  26. package/src/lib/components/activity-log-v2/log-view-popup/view-action/view-action.component.spec.ts +23 -0
  27. package/src/lib/components/activity-log-v2/log-view-popup/view-action/view-action.component.ts +122 -0
  28. package/src/lib/components/add-checklist/add-checklist.component.html +1459 -0
  29. package/src/lib/components/add-checklist/add-checklist.component.scss +1205 -0
  30. package/src/lib/components/add-checklist/add-checklist.component.spec.ts +23 -0
  31. package/src/lib/components/add-checklist/add-checklist.component.ts +2460 -0
  32. package/src/lib/components/add-checklist/checklist-popup/checklist-popup.component.html +207 -0
  33. package/src/lib/components/add-checklist/checklist-popup/checklist-popup.component.scss +213 -0
  34. package/src/lib/components/add-checklist/checklist-popup/checklist-popup.component.spec.ts +23 -0
  35. package/src/lib/components/add-checklist/checklist-popup/checklist-popup.component.ts +621 -0
  36. package/src/lib/components/add-checklist/counter/counter.component.html +43 -0
  37. package/src/lib/components/add-checklist/counter/counter.component.scss +49 -0
  38. package/src/lib/components/add-checklist/counter/counter.component.spec.ts +23 -0
  39. package/src/lib/components/add-checklist/counter/counter.component.ts +123 -0
  40. package/src/lib/components/add-multitask/add-multitask.component.html +705 -0
  41. package/src/lib/components/add-multitask/add-multitask.component.scss +296 -0
  42. package/src/lib/components/add-multitask/add-multitask.component.spec.ts +23 -0
  43. package/src/lib/components/add-multitask/add-multitask.component.ts +611 -0
  44. package/src/lib/components/add-multitask/ascending-validator.ts +13 -0
  45. package/src/lib/components/add-multitask/bulkcreationmodel/bulkcreationmodel.component.html +197 -0
  46. package/src/lib/components/add-multitask/bulkcreationmodel/bulkcreationmodel.component.scss +31 -0
  47. package/src/lib/components/add-multitask/bulkcreationmodel/bulkcreationmodel.component.spec.ts +23 -0
  48. package/src/lib/components/add-multitask/bulkcreationmodel/bulkcreationmodel.component.ts +285 -0
  49. package/src/lib/components/add-multitask/create-task.data.ts +374 -0
  50. package/src/lib/components/add-multitask/create-task.interface.ts +177 -0
  51. package/src/lib/components/add-multitask/unique-string-validator.ts +13 -0
  52. package/src/lib/components/add-multitask/whitespace-validator.ts +11 -0
  53. package/src/lib/components/add-task/add-task.component.html +654 -0
  54. package/src/lib/components/add-task/add-task.component.scss +536 -0
  55. package/src/lib/components/add-task/add-task.component.spec.ts +23 -0
  56. package/src/lib/components/add-task/add-task.component.ts +569 -0
  57. package/src/lib/components/add-task/ascending-validator.ts +13 -0
  58. package/src/lib/components/add-task/create-task.data.ts +374 -0
  59. package/src/lib/components/add-task/create-task.interface.ts +192 -0
  60. package/src/lib/components/add-task/unique-string-validator.ts +13 -0
  61. package/src/lib/components/add-task/whitespace-validator.ts +11 -0
  62. package/src/lib/components/approval-popup/approval-popup.component.html +25 -0
  63. package/src/lib/components/approval-popup/approval-popup.component.scss +3 -0
  64. package/src/lib/components/approval-popup/approval-popup.component.spec.ts +23 -0
  65. package/src/lib/components/approval-popup/approval-popup.component.ts +26 -0
  66. package/src/lib/components/checklist/checklist.component.html +330 -0
  67. package/src/lib/components/checklist/checklist.component.scss +112 -0
  68. package/src/lib/components/checklist/checklist.component.spec.ts +23 -0
  69. package/src/lib/components/checklist/checklist.component.ts +344 -0
  70. package/src/lib/components/checklist-configure/assign/assign.component.html +665 -0
  71. package/src/lib/components/checklist-configure/assign/assign.component.scss +219 -0
  72. package/src/lib/components/checklist-configure/assign/assign.component.spec.ts +23 -0
  73. package/src/lib/components/checklist-configure/assign/assign.component.ts +932 -0
  74. package/src/lib/components/checklist-configure/checklist-configure.component.html +4340 -0
  75. package/src/lib/components/checklist-configure/checklist-configure.component.scss +2338 -0
  76. package/src/lib/components/checklist-configure/checklist-configure.component.spec.ts +23 -0
  77. package/src/lib/components/checklist-configure/checklist-configure.component.ts +4659 -0
  78. package/src/lib/components/checklistlayout/checklistlayout.component.html +30 -0
  79. package/src/lib/components/checklistlayout/checklistlayout.component.scss +15 -0
  80. package/src/lib/components/checklistlayout/checklistlayout.component.spec.ts +23 -0
  81. package/src/lib/components/checklistlayout/checklistlayout.component.ts +47 -0
  82. package/src/lib/components/chip-dropdown/chip-dropdown.component.html +36 -0
  83. package/src/lib/components/chip-dropdown/chip-dropdown.component.scss +97 -0
  84. package/src/lib/components/chip-dropdown/chip-dropdown.component.spec.ts +23 -0
  85. package/src/lib/components/chip-dropdown/chip-dropdown.component.ts +125 -0
  86. package/src/lib/components/create-task/create-task.component.html +2003 -0
  87. package/src/lib/components/create-task/create-task.component.scss +272 -0
  88. package/src/lib/components/create-task/create-task.component.spec.ts +23 -0
  89. package/src/lib/components/create-task/create-task.component.ts +614 -0
  90. package/src/lib/components/create-task/create-task.data.ts +372 -0
  91. package/src/lib/components/create-task/create-task.interface.ts +182 -0
  92. package/src/lib/components/create-task/validators/ascending-validator.ts +13 -0
  93. package/src/lib/components/create-task/validators/unique-string-validator.ts +13 -0
  94. package/src/lib/components/create-task/validators/whitespace-validator.ts +11 -0
  95. package/src/lib/components/custom-select/custom-select.component.html +44 -0
  96. package/src/lib/components/custom-select/custom-select.component.scss +144 -0
  97. package/src/lib/components/custom-select/custom-select.component.spec.ts +23 -0
  98. package/src/lib/components/custom-select/custom-select.component.ts +265 -0
  99. package/src/lib/components/dashboard/dashboard.component.html +1076 -0
  100. package/src/lib/components/dashboard/dashboard.component.scss +237 -0
  101. package/src/lib/components/dashboard/dashboard.component.spec.ts +23 -0
  102. package/src/lib/components/dashboard/dashboard.component.ts +539 -0
  103. package/src/lib/components/dashboard-info/dashboard-info.component.html +1420 -0
  104. package/src/lib/components/dashboard-info/dashboard-info.component.scss +409 -0
  105. package/src/lib/components/dashboard-info/dashboard-info.component.spec.ts +23 -0
  106. package/src/lib/components/dashboard-info/dashboard-info.component.ts +772 -0
  107. package/src/lib/components/dashboard-info/monthlyperformance-datepicker/monthlyperformance-datepicker.component.html +110 -0
  108. package/src/lib/components/dashboard-info/monthlyperformance-datepicker/monthlyperformance-datepicker.component.scss +260 -0
  109. package/src/lib/components/dashboard-info/monthlyperformance-datepicker/monthlyperformance-datepicker.component.spec.ts +23 -0
  110. package/src/lib/components/dashboard-info/monthlyperformance-datepicker/monthlyperformance-datepicker.component.ts +143 -0
  111. package/src/lib/components/dashboard-layout/dashboard-layout.component.html +1 -0
  112. package/src/lib/components/dashboard-layout/dashboard-layout.component.scss +0 -0
  113. package/src/lib/components/dashboard-layout/dashboard-layout.component.spec.ts +23 -0
  114. package/src/lib/components/dashboard-layout/dashboard-layout.component.ts +10 -0
  115. package/src/lib/components/disabled-select/disabled-select.component.html +44 -0
  116. package/src/lib/components/disabled-select/disabled-select.component.scss +149 -0
  117. package/src/lib/components/disabled-select/disabled-select.component.spec.ts +23 -0
  118. package/src/lib/components/disabled-select/disabled-select.component.ts +146 -0
  119. package/src/lib/components/export-gallery/export-gallery.component.html +175 -0
  120. package/src/lib/components/export-gallery/export-gallery.component.scss +200 -0
  121. package/src/lib/components/export-gallery/export-gallery.component.spec.ts +23 -0
  122. package/src/lib/components/export-gallery/export-gallery.component.ts +263 -0
  123. package/src/lib/components/eye-test-audit/chip-dropdown/chip-dropdown.component.html +36 -0
  124. package/src/lib/components/eye-test-audit/chip-dropdown/chip-dropdown.component.scss +97 -0
  125. package/src/lib/components/eye-test-audit/chip-dropdown/chip-dropdown.component.spec.ts +23 -0
  126. package/src/lib/components/eye-test-audit/chip-dropdown/chip-dropdown.component.ts +104 -0
  127. package/src/lib/components/eye-test-audit/custom-select/custom-select.component.html +44 -0
  128. package/src/lib/components/eye-test-audit/custom-select/custom-select.component.scss +144 -0
  129. package/src/lib/components/eye-test-audit/custom-select/custom-select.component.spec.ts +23 -0
  130. package/src/lib/components/eye-test-audit/custom-select/custom-select.component.ts +265 -0
  131. package/src/lib/components/eye-test-audit/eye-test/eye-test.component.html +1804 -0
  132. package/src/lib/components/eye-test-audit/eye-test/eye-test.component.scss +806 -0
  133. package/src/lib/components/eye-test-audit/eye-test/eye-test.component.spec.ts +23 -0
  134. package/src/lib/components/eye-test-audit/eye-test/eye-test.component.ts +1890 -0
  135. package/src/lib/components/eye-test-audit/eye-test/send-alert/send-alert.component.html +25 -0
  136. package/src/lib/components/eye-test-audit/eye-test/send-alert/send-alert.component.scss +0 -0
  137. package/src/lib/components/eye-test-audit/eye-test/send-alert/send-alert.component.spec.ts +23 -0
  138. package/src/lib/components/eye-test-audit/eye-test/send-alert/send-alert.component.ts +20 -0
  139. package/src/lib/components/eye-test-audit/eye-test-audit/eye-test-audit-routing.module.ts +26 -0
  140. package/src/lib/components/eye-test-audit/eye-test-audit/eye-test-audit.component.html +1 -0
  141. package/src/lib/components/eye-test-audit/eye-test-audit/eye-test-audit.component.scss +0 -0
  142. package/src/lib/components/eye-test-audit/eye-test-audit/eye-test-audit.component.spec.ts +23 -0
  143. package/src/lib/components/eye-test-audit/eye-test-audit/eye-test-audit.component.ts +24 -0
  144. package/src/lib/components/eye-test-audit/eye-test-audit/eye-test-audit.module.ts +44 -0
  145. package/src/lib/components/eye-test-audit/eye-test-audit/settings-audit/settings-audit.component.html +490 -0
  146. package/src/lib/components/eye-test-audit/eye-test-audit/settings-audit/settings-audit.component.scss +721 -0
  147. package/src/lib/components/eye-test-audit/eye-test-audit/settings-audit/settings-audit.component.spec.ts +23 -0
  148. package/src/lib/components/eye-test-audit/eye-test-audit/settings-audit/settings-audit.component.ts +1017 -0
  149. package/src/lib/components/eye-test-audit/eye-test-audit/start-audit/start-audit.component.html +708 -0
  150. package/src/lib/components/eye-test-audit/eye-test-audit/start-audit/start-audit.component.scss +247 -0
  151. package/src/lib/components/eye-test-audit/eye-test-audit/start-audit/start-audit.component.spec.ts +23 -0
  152. package/src/lib/components/eye-test-audit/eye-test-audit/start-audit/start-audit.component.ts +446 -0
  153. package/src/lib/components/eye-test-audit/group-select/group-select.component.html +44 -0
  154. package/src/lib/components/eye-test-audit/group-select/group-select.component.scss +144 -0
  155. package/src/lib/components/eye-test-audit/group-select/group-select.component.spec.ts +23 -0
  156. package/src/lib/components/eye-test-audit/group-select/group-select.component.ts +147 -0
  157. package/src/lib/components/eye-test-audit/reactive-select/reactive-select.component.html +18 -0
  158. package/src/lib/components/eye-test-audit/reactive-select/reactive-select.component.scss +49 -0
  159. package/src/lib/components/eye-test-audit/reactive-select/reactive-select.component.spec.ts +23 -0
  160. package/src/lib/components/eye-test-audit/reactive-select/reactive-select.component.ts +104 -0
  161. package/src/lib/components/eye-test-audit/select-drop/select-drop.component.html +44 -0
  162. package/src/lib/components/eye-test-audit/select-drop/select-drop.component.scss +144 -0
  163. package/src/lib/components/eye-test-audit/select-drop/select-drop.component.spec.ts +23 -0
  164. package/src/lib/components/eye-test-audit/select-drop/select-drop.component.ts +152 -0
  165. package/src/lib/components/eye-test-audit/services/eye-test-audit.service.spec.ts +16 -0
  166. package/src/lib/components/eye-test-audit/services/eye-test-audit.service.ts +190 -0
  167. package/src/lib/components/flag-layout/flag-layout.component.html +1 -0
  168. package/src/lib/components/flag-layout/flag-layout.component.scss +0 -0
  169. package/src/lib/components/flag-layout/flag-layout.component.spec.ts +23 -0
  170. package/src/lib/components/flag-layout/flag-layout.component.ts +10 -0
  171. package/src/lib/components/flags/flags.component.html +473 -0
  172. package/src/lib/components/flags/flags.component.scss +86 -0
  173. package/src/lib/components/flags/flags.component.spec.ts +23 -0
  174. package/src/lib/components/flags/flags.component.ts +280 -0
  175. package/{lib/components/flags/flags.interface.d.ts → src/lib/components/flags/flags.interface.ts} +73 -65
  176. package/src/lib/components/flags-info/flags-info.component.html +6012 -0
  177. package/src/lib/components/flags-info/flags-info.component.scss +278 -0
  178. package/src/lib/components/flags-info/flags-info.component.spec.ts +23 -0
  179. package/src/lib/components/flags-info/flags-info.component.ts +490 -0
  180. package/src/lib/components/flags-info/flags-info.interface.ts +441 -0
  181. package/src/lib/components/flags-info/unattended-pie-chart/unattended-pie-chart.component.html +1 -0
  182. package/src/lib/components/flags-info/unattended-pie-chart/unattended-pie-chart.component.scss +4 -0
  183. package/src/lib/components/flags-info/unattended-pie-chart/unattended-pie-chart.component.ts +78 -0
  184. package/src/lib/components/flags-new/flags-new.component.html +904 -0
  185. package/src/lib/components/flags-new/flags-new.component.scss +121 -0
  186. package/src/lib/components/flags-new/flags-new.component.spec.ts +23 -0
  187. package/src/lib/components/flags-new/flags-new.component.ts +357 -0
  188. package/{lib/components/flags-new/flags-new.interface.d.ts → src/lib/components/flags-new/flags-new.interface.ts} +90 -81
  189. package/src/lib/components/gallery/gallery.component.html +3660 -0
  190. package/src/lib/components/gallery/gallery.component.scss +930 -0
  191. package/src/lib/components/gallery/gallery.component.ts +3527 -0
  192. package/src/lib/components/group-select/group-select.component.html +44 -0
  193. package/src/lib/components/group-select/group-select.component.scss +144 -0
  194. package/src/lib/components/group-select/group-select.component.spec.ts +23 -0
  195. package/src/lib/components/group-select/group-select.component.ts +145 -0
  196. package/src/lib/components/image-popup/image-popup.component.html +11 -0
  197. package/src/lib/components/image-popup/image-popup.component.scss +5 -0
  198. package/src/lib/components/image-popup/image-popup.component.ts +18 -0
  199. package/src/lib/components/lib/custom-select/custom-select.component.html +42 -0
  200. package/src/lib/components/lib/custom-select/custom-select.component.scss +131 -0
  201. package/src/lib/components/lib/custom-select/custom-select.component.spec.ts +23 -0
  202. package/src/lib/components/lib/custom-select/custom-select.component.ts +151 -0
  203. package/src/lib/components/manage-task/manage-task.component.html +265 -0
  204. package/src/lib/components/manage-task/manage-task.component.scss +69 -0
  205. package/src/lib/components/manage-task/manage-task.component.spec.ts +23 -0
  206. package/src/lib/components/manage-task/manage-task.component.ts +267 -0
  207. package/src/lib/components/managechecklist/managechecklist.component.html +176 -0
  208. package/src/lib/components/managechecklist/managechecklist.component.scss +43 -0
  209. package/src/lib/components/managechecklist/managechecklist.component.spec.ts +23 -0
  210. package/src/lib/components/managechecklist/managechecklist.component.ts +176 -0
  211. package/src/lib/components/multi-chip-dropdown/multi-chip-dropdown.component.html +46 -0
  212. package/src/lib/components/multi-chip-dropdown/multi-chip-dropdown.component.scss +181 -0
  213. package/src/lib/components/multi-chip-dropdown/multi-chip-dropdown.component.spec.ts +23 -0
  214. package/src/lib/components/multi-chip-dropdown/multi-chip-dropdown.component.ts +221 -0
  215. package/src/lib/components/multi-date-datepicker/multi-date-datepicker.component.html +36 -0
  216. package/src/lib/components/multi-date-datepicker/multi-date-datepicker.component.scss +89 -0
  217. package/src/lib/components/multi-date-datepicker/multi-date-datepicker.component.spec.ts +23 -0
  218. package/src/lib/components/multi-date-datepicker/multi-date-datepicker.component.ts +118 -0
  219. package/src/lib/components/orders/orders.component.html +203 -0
  220. package/src/lib/components/orders/orders.component.scss +180 -0
  221. package/src/lib/components/orders/orders.component.spec.ts +25 -0
  222. package/src/lib/components/orders/orders.component.ts +197 -0
  223. package/src/lib/components/pagination/pagination.component.html +28 -0
  224. package/src/lib/components/pagination/pagination.component.scss +6 -0
  225. package/src/lib/components/pagination/pagination.component.spec.ts +23 -0
  226. package/src/lib/components/pagination/pagination.component.ts +54 -0
  227. package/src/lib/components/reactive-select/reactive-select.component.html +18 -0
  228. package/src/lib/components/reactive-select/reactive-select.component.scss +48 -0
  229. package/src/lib/components/reactive-select/reactive-select.component.spec.ts +23 -0
  230. package/src/lib/components/reactive-select/reactive-select.component.ts +104 -0
  231. package/src/lib/components/reports/date-picker/date-picker.component.html +54 -0
  232. package/src/lib/components/reports/date-picker/date-picker.component.scss +156 -0
  233. package/src/lib/components/reports/date-picker/date-picker.component.spec.ts +23 -0
  234. package/src/lib/components/reports/date-picker/date-picker.component.ts +60 -0
  235. package/src/lib/components/reports/reports.component.html +225 -0
  236. package/src/lib/components/reports/reports.component.scss +69 -0
  237. package/src/lib/components/reports/reports.component.spec.ts +23 -0
  238. package/src/lib/components/reports/reports.component.ts +334 -0
  239. package/{lib/components/reports/reports.interface.d.ts → src/lib/components/reports/reports.interface.ts} +50 -46
  240. package/src/lib/components/tango-analyse-trax/tango-analyse-trax.component.html +1 -0
  241. package/src/lib/components/tango-analyse-trax/tango-analyse-trax.component.scss +15 -0
  242. package/src/lib/components/tango-analyse-trax/tango-analyse-trax.component.spec.ts +23 -0
  243. package/src/lib/components/tango-analyse-trax/tango-analyse-trax.component.ts +31 -0
  244. package/src/lib/components/task/task.component.html +322 -0
  245. package/src/lib/components/task/task.component.scss +169 -0
  246. package/src/lib/components/task/task.component.spec.ts +23 -0
  247. package/src/lib/components/task/task.component.ts +340 -0
  248. package/src/lib/components/task-configure/task-configure.component.html +737 -0
  249. package/src/lib/components/task-configure/task-configure.component.scss +569 -0
  250. package/src/lib/components/task-configure/task-configure.component.spec.ts +23 -0
  251. package/src/lib/components/task-configure/task-configure.component.ts +1603 -0
  252. package/src/lib/components/task-configure/task-configure.interface.ts +138 -0
  253. package/src/lib/components/task-info/task-info.component.html +390 -0
  254. package/src/lib/components/task-info/task-info.component.scss +56 -0
  255. package/src/lib/components/task-info/task-info.component.spec.ts +23 -0
  256. package/src/lib/components/task-info/task-info.component.ts +400 -0
  257. package/src/lib/components/task-info/taskinfo-edit/taskinfo-edit.component.html +141 -0
  258. package/src/lib/components/task-info/taskinfo-edit/taskinfo-edit.component.scss +460 -0
  259. package/src/lib/components/task-info/taskinfo-edit/taskinfo-edit.component.spec.ts +23 -0
  260. package/src/lib/components/task-info/taskinfo-edit/taskinfo-edit.component.ts +202 -0
  261. package/src/lib/components/task-layout/task-layout.component.html +1 -0
  262. package/src/lib/components/task-layout/task-layout.component.scss +0 -0
  263. package/src/lib/components/task-layout/task-layout.component.spec.ts +23 -0
  264. package/src/lib/components/task-layout/task-layout.component.ts +10 -0
  265. package/src/lib/components/task-logs/task-logs.component.html +97 -0
  266. package/src/lib/components/task-logs/task-logs.component.scss +301 -0
  267. package/src/lib/components/task-logs/task-logs.component.spec.ts +23 -0
  268. package/src/lib/components/task-logs/task-logs.component.ts +80 -0
  269. package/src/lib/components/trax-run-ai-popup/trax-run-ai-popup.component.html +84 -0
  270. package/src/lib/components/trax-run-ai-popup/trax-run-ai-popup.component.scss +229 -0
  271. package/src/lib/components/trax-run-ai-popup/trax-run-ai-popup.component.spec.ts +23 -0
  272. package/src/lib/components/trax-run-ai-popup/trax-run-ai-popup.component.ts +111 -0
  273. package/src/lib/components/trax-store/trax-store.component.html +78 -0
  274. package/src/lib/components/trax-store/trax-store.component.scss +134 -0
  275. package/src/lib/components/trax-store/trax-store.component.spec.ts +23 -0
  276. package/src/lib/components/trax-store/trax-store.component.ts +172 -0
  277. package/src/lib/components/traxpopup/traxpopup.component.html +130 -0
  278. package/src/lib/components/traxpopup/traxpopup.component.scss +225 -0
  279. package/src/lib/components/traxpopup/traxpopup.component.spec.ts +23 -0
  280. package/src/lib/components/traxpopup/traxpopup.component.ts +71 -0
  281. package/src/lib/services/trax.service.spec.ts +16 -0
  282. package/src/lib/services/trax.service.ts +789 -0
  283. package/src/lib/tango-analyse-trax-routing.module.ts +151 -0
  284. package/src/lib/tango-analyse-trax.module.ts +140 -0
  285. package/{public-api.d.ts → src/public-api.ts} +6 -2
  286. package/tsconfig.lib.json +14 -0
  287. package/tsconfig.lib.prod.json +10 -0
  288. package/tsconfig.spec.json +14 -0
  289. package/esm2022/lib/components/action-centre/action-centre.component.mjs +0 -288
  290. package/esm2022/lib/components/activity-log/activity-log.component.mjs +0 -150
  291. package/esm2022/lib/components/activity-log-v2/activity-log-v2.component.mjs +0 -502
  292. package/esm2022/lib/components/activity-log-v2/log-view-popup/date-range-picker/date-range-picker.component.mjs +0 -114
  293. package/esm2022/lib/components/activity-log-v2/log-view-popup/store-user-dropdown/store-user-dropdown.component.mjs +0 -24
  294. package/esm2022/lib/components/activity-log-v2/log-view-popup/view-action/view-action.component.mjs +0 -126
  295. package/esm2022/lib/components/add-checklist/add-checklist.component.mjs +0 -2352
  296. package/esm2022/lib/components/add-checklist/checklist-popup/checklist-popup.component.mjs +0 -612
  297. package/esm2022/lib/components/add-checklist/counter/counter.component.mjs +0 -138
  298. package/esm2022/lib/components/add-multitask/add-multitask.component.mjs +0 -604
  299. package/esm2022/lib/components/add-multitask/ascending-validator.mjs +0 -11
  300. package/esm2022/lib/components/add-multitask/bulkcreationmodel/bulkcreationmodel.component.mjs +0 -297
  301. package/esm2022/lib/components/add-multitask/create-task.data.mjs +0 -372
  302. package/esm2022/lib/components/add-multitask/create-task.interface.mjs +0 -2
  303. package/esm2022/lib/components/add-multitask/unique-string-validator.mjs +0 -10
  304. package/esm2022/lib/components/add-multitask/whitespace-validator.mjs +0 -10
  305. package/esm2022/lib/components/add-task/add-task.component.mjs +0 -561
  306. package/esm2022/lib/components/add-task/ascending-validator.mjs +0 -11
  307. package/esm2022/lib/components/add-task/create-task.data.mjs +0 -372
  308. package/esm2022/lib/components/add-task/create-task.interface.mjs +0 -2
  309. package/esm2022/lib/components/add-task/unique-string-validator.mjs +0 -10
  310. package/esm2022/lib/components/add-task/whitespace-validator.mjs +0 -10
  311. package/esm2022/lib/components/approval-popup/approval-popup.component.mjs +0 -30
  312. package/esm2022/lib/components/checklist/checklist.component.mjs +0 -327
  313. package/esm2022/lib/components/checklist-configure/assign/assign.component.mjs +0 -912
  314. package/esm2022/lib/components/checklist-configure/checklist-configure.component.mjs +0 -4161
  315. package/esm2022/lib/components/checklistlayout/checklistlayout.component.mjs +0 -44
  316. package/esm2022/lib/components/chip-dropdown/chip-dropdown.component.mjs +0 -120
  317. package/esm2022/lib/components/create-task/create-task.component.mjs +0 -585
  318. package/esm2022/lib/components/create-task/create-task.data.mjs +0 -372
  319. package/esm2022/lib/components/create-task/create-task.interface.mjs +0 -2
  320. package/esm2022/lib/components/create-task/validators/ascending-validator.mjs +0 -11
  321. package/esm2022/lib/components/create-task/validators/unique-string-validator.mjs +0 -10
  322. package/esm2022/lib/components/create-task/validators/whitespace-validator.mjs +0 -10
  323. package/esm2022/lib/components/custom-select/custom-select.component.mjs +0 -240
  324. package/esm2022/lib/components/dashboard/dashboard.component.mjs +0 -532
  325. package/esm2022/lib/components/dashboard-info/dashboard-info.component.mjs +0 -741
  326. package/esm2022/lib/components/dashboard-info/monthlyperformance-datepicker/monthlyperformance-datepicker.component.mjs +0 -155
  327. package/esm2022/lib/components/dashboard-layout/dashboard-layout.component.mjs +0 -12
  328. package/esm2022/lib/components/disabled-select/disabled-select.component.mjs +0 -158
  329. package/esm2022/lib/components/export-gallery/export-gallery.component.mjs +0 -266
  330. package/esm2022/lib/components/eye-test-audit/chip-dropdown/chip-dropdown.component.mjs +0 -105
  331. package/esm2022/lib/components/eye-test-audit/custom-select/custom-select.component.mjs +0 -240
  332. package/esm2022/lib/components/eye-test-audit/eye-test/eye-test.component.mjs +0 -1733
  333. package/esm2022/lib/components/eye-test-audit/eye-test/send-alert/send-alert.component.mjs +0 -24
  334. package/esm2022/lib/components/eye-test-audit/eye-test-audit/eye-test-audit-routing.module.mjs +0 -34
  335. package/esm2022/lib/components/eye-test-audit/eye-test-audit/eye-test-audit.component.mjs +0 -27
  336. package/esm2022/lib/components/eye-test-audit/eye-test-audit/eye-test-audit.module.mjs +0 -71
  337. package/esm2022/lib/components/eye-test-audit/eye-test-audit/settings-audit/settings-audit.component.mjs +0 -823
  338. package/esm2022/lib/components/eye-test-audit/eye-test-audit/start-audit/start-audit.component.mjs +0 -412
  339. package/esm2022/lib/components/eye-test-audit/group-select/group-select.component.mjs +0 -157
  340. package/esm2022/lib/components/eye-test-audit/reactive-select/reactive-select.component.mjs +0 -105
  341. package/esm2022/lib/components/eye-test-audit/select-drop/select-drop.component.mjs +0 -162
  342. package/esm2022/lib/components/eye-test-audit/services/eye-test-audit.service.mjs +0 -166
  343. package/esm2022/lib/components/flag-layout/flag-layout.component.mjs +0 -12
  344. package/esm2022/lib/components/flags/flags.component.mjs +0 -263
  345. package/esm2022/lib/components/flags/flags.interface.mjs +0 -2
  346. package/esm2022/lib/components/flags-info/flags-info.component.mjs +0 -452
  347. package/esm2022/lib/components/flags-info/flags-info.interface.mjs +0 -2
  348. package/esm2022/lib/components/flags-info/unattended-pie-chart/unattended-pie-chart.component.mjs +0 -71
  349. package/esm2022/lib/components/flags-new/flags-new.component.mjs +0 -335
  350. package/esm2022/lib/components/flags-new/flags-new.interface.mjs +0 -2
  351. package/esm2022/lib/components/gallery/gallery.component.mjs +0 -3402
  352. package/esm2022/lib/components/group-select/group-select.component.mjs +0 -155
  353. package/esm2022/lib/components/image-popup/image-popup.component.mjs +0 -25
  354. package/esm2022/lib/components/lib/custom-select/custom-select.component.mjs +0 -158
  355. package/esm2022/lib/components/manage-task/manage-task.component.mjs +0 -264
  356. package/esm2022/lib/components/managechecklist/managechecklist.component.mjs +0 -186
  357. package/esm2022/lib/components/multi-chip-dropdown/multi-chip-dropdown.component.mjs +0 -229
  358. package/esm2022/lib/components/multi-date-datepicker/multi-date-datepicker.component.mjs +0 -124
  359. package/esm2022/lib/components/orders/orders.component.mjs +0 -171
  360. package/esm2022/lib/components/pagination/pagination.component.mjs +0 -62
  361. package/esm2022/lib/components/reactive-select/reactive-select.component.mjs +0 -108
  362. package/esm2022/lib/components/reports/date-picker/date-picker.component.mjs +0 -60
  363. package/esm2022/lib/components/reports/reports.component.mjs +0 -300
  364. package/esm2022/lib/components/reports/reports.interface.mjs +0 -2
  365. package/esm2022/lib/components/tango-analyse-trax/tango-analyse-trax.component.mjs +0 -32
  366. package/esm2022/lib/components/task/task.component.mjs +0 -341
  367. package/esm2022/lib/components/task-configure/task-configure.component.mjs +0 -1532
  368. package/esm2022/lib/components/task-configure/task-configure.interface.mjs +0 -2
  369. package/esm2022/lib/components/task-info/task-info.component.mjs +0 -375
  370. package/esm2022/lib/components/task-info/taskinfo-edit/taskinfo-edit.component.mjs +0 -208
  371. package/esm2022/lib/components/task-layout/task-layout.component.mjs +0 -12
  372. package/esm2022/lib/components/task-logs/task-logs.component.mjs +0 -104
  373. package/esm2022/lib/components/trax-run-ai-popup/trax-run-ai-popup.component.mjs +0 -107
  374. package/esm2022/lib/components/trax-store/trax-store.component.mjs +0 -179
  375. package/esm2022/lib/components/traxpopup/traxpopup.component.mjs +0 -70
  376. package/esm2022/lib/services/trax.service.mjs +0 -559
  377. package/esm2022/lib/tango-analyse-trax-routing.module.mjs +0 -153
  378. package/esm2022/lib/tango-analyse-trax.module.mjs +0 -221
  379. package/esm2022/public-api.mjs +0 -6
  380. package/esm2022/tango-app-ui-analyse-trax.mjs +0 -5
  381. package/fesm2022/tango-app-ui-analyse-trax.mjs +0 -28896
  382. package/fesm2022/tango-app-ui-analyse-trax.mjs.map +0 -1
  383. package/index.d.ts +0 -5
  384. package/lib/components/action-centre/action-centre.component.d.ts +0 -68
  385. package/lib/components/activity-log/activity-log.component.d.ts +0 -39
  386. package/lib/components/activity-log-v2/activity-log-v2.component.d.ts +0 -78
  387. package/lib/components/activity-log-v2/log-view-popup/date-range-picker/date-range-picker.component.d.ts +0 -24
  388. package/lib/components/activity-log-v2/log-view-popup/store-user-dropdown/store-user-dropdown.component.d.ts +0 -9
  389. package/lib/components/activity-log-v2/log-view-popup/view-action/view-action.component.d.ts +0 -34
  390. package/lib/components/add-checklist/add-checklist.component.d.ts +0 -121
  391. package/lib/components/add-checklist/checklist-popup/checklist-popup.component.d.ts +0 -45
  392. package/lib/components/add-checklist/counter/counter.component.d.ts +0 -29
  393. package/lib/components/add-multitask/add-multitask.component.d.ts +0 -102
  394. package/lib/components/add-multitask/ascending-validator.d.ts +0 -2
  395. package/lib/components/add-multitask/bulkcreationmodel/bulkcreationmodel.component.d.ts +0 -45
  396. package/lib/components/add-multitask/create-task.data.d.ts +0 -293
  397. package/lib/components/add-multitask/create-task.interface.d.ts +0 -159
  398. package/lib/components/add-multitask/unique-string-validator.d.ts +0 -2
  399. package/lib/components/add-multitask/whitespace-validator.d.ts +0 -2
  400. package/lib/components/add-task/add-task.component.d.ts +0 -89
  401. package/lib/components/add-task/ascending-validator.d.ts +0 -2
  402. package/lib/components/add-task/create-task.data.d.ts +0 -293
  403. package/lib/components/add-task/create-task.interface.d.ts +0 -161
  404. package/lib/components/add-task/unique-string-validator.d.ts +0 -2
  405. package/lib/components/add-task/whitespace-validator.d.ts +0 -2
  406. package/lib/components/approval-popup/approval-popup.component.d.ts +0 -14
  407. package/lib/components/checklist/checklist.component.d.ts +0 -40
  408. package/lib/components/checklist-configure/assign/assign.component.d.ts +0 -105
  409. package/lib/components/checklist-configure/checklist-configure.component.d.ts +0 -325
  410. package/lib/components/checklistlayout/checklistlayout.component.d.ts +0 -15
  411. package/lib/components/chip-dropdown/chip-dropdown.component.d.ts +0 -28
  412. package/lib/components/create-task/create-task.component.d.ts +0 -76
  413. package/lib/components/create-task/create-task.data.d.ts +0 -293
  414. package/lib/components/create-task/create-task.interface.d.ts +0 -163
  415. package/lib/components/create-task/validators/ascending-validator.d.ts +0 -2
  416. package/lib/components/create-task/validators/unique-string-validator.d.ts +0 -2
  417. package/lib/components/create-task/validators/whitespace-validator.d.ts +0 -2
  418. package/lib/components/custom-select/custom-select.component.d.ts +0 -35
  419. package/lib/components/dashboard/dashboard.component.d.ts +0 -80
  420. package/lib/components/dashboard-info/dashboard-info.component.d.ts +0 -117
  421. package/lib/components/dashboard-info/monthlyperformance-datepicker/monthlyperformance-datepicker.component.d.ts +0 -41
  422. package/lib/components/dashboard-layout/dashboard-layout.component.d.ts +0 -5
  423. package/lib/components/disabled-select/disabled-select.component.d.ts +0 -34
  424. package/lib/components/export-gallery/export-gallery.component.d.ts +0 -44
  425. package/lib/components/eye-test-audit/chip-dropdown/chip-dropdown.component.d.ts +0 -26
  426. package/lib/components/eye-test-audit/custom-select/custom-select.component.d.ts +0 -35
  427. package/lib/components/eye-test-audit/eye-test/eye-test.component.d.ts +0 -218
  428. package/lib/components/eye-test-audit/eye-test/send-alert/send-alert.component.d.ts +0 -12
  429. package/lib/components/eye-test-audit/eye-test-audit/eye-test-audit-routing.module.d.ts +0 -7
  430. package/lib/components/eye-test-audit/eye-test-audit/eye-test-audit.component.d.ts +0 -11
  431. package/lib/components/eye-test-audit/eye-test-audit/eye-test-audit.module.d.ts +0 -21
  432. package/lib/components/eye-test-audit/eye-test-audit/settings-audit/settings-audit.component.d.ts +0 -129
  433. package/lib/components/eye-test-audit/eye-test-audit/start-audit/start-audit.component.d.ts +0 -86
  434. package/lib/components/eye-test-audit/group-select/group-select.component.d.ts +0 -33
  435. package/lib/components/eye-test-audit/reactive-select/reactive-select.component.d.ts +0 -32
  436. package/lib/components/eye-test-audit/select-drop/select-drop.component.d.ts +0 -33
  437. package/lib/components/eye-test-audit/services/eye-test-audit.service.d.ts +0 -47
  438. package/lib/components/flag-layout/flag-layout.component.d.ts +0 -5
  439. package/lib/components/flags/flags.component.d.ts +0 -52
  440. package/lib/components/flags-info/flags-info.component.d.ts +0 -73
  441. package/lib/components/flags-info/flags-info.interface.d.ts +0 -430
  442. package/lib/components/flags-info/unattended-pie-chart/unattended-pie-chart.component.d.ts +0 -13
  443. package/lib/components/flags-new/flags-new.component.d.ts +0 -60
  444. package/lib/components/gallery/gallery.component.d.ts +0 -261
  445. package/lib/components/group-select/group-select.component.d.ts +0 -33
  446. package/lib/components/image-popup/image-popup.component.d.ts +0 -11
  447. package/lib/components/lib/custom-select/custom-select.component.d.ts +0 -33
  448. package/lib/components/manage-task/manage-task.component.d.ts +0 -47
  449. package/lib/components/managechecklist/managechecklist.component.d.ts +0 -33
  450. package/lib/components/multi-chip-dropdown/multi-chip-dropdown.component.d.ts +0 -40
  451. package/lib/components/multi-date-datepicker/multi-date-datepicker.component.d.ts +0 -27
  452. package/lib/components/orders/orders.component.d.ts +0 -38
  453. package/lib/components/pagination/pagination.component.d.ts +0 -16
  454. package/lib/components/reactive-select/reactive-select.component.d.ts +0 -32
  455. package/lib/components/reports/date-picker/date-picker.component.d.ts +0 -23
  456. package/lib/components/reports/reports.component.d.ts +0 -55
  457. package/lib/components/tango-analyse-trax/tango-analyse-trax.component.d.ts +0 -14
  458. package/lib/components/task/task.component.d.ts +0 -70
  459. package/lib/components/task-configure/task-configure.component.d.ts +0 -142
  460. package/lib/components/task-configure/task-configure.interface.d.ts +0 -128
  461. package/lib/components/task-info/task-info.component.d.ts +0 -76
  462. package/lib/components/task-info/taskinfo-edit/taskinfo-edit.component.d.ts +0 -61
  463. package/lib/components/task-layout/task-layout.component.d.ts +0 -5
  464. package/lib/components/task-logs/task-logs.component.d.ts +0 -27
  465. package/lib/components/trax-run-ai-popup/trax-run-ai-popup.component.d.ts +0 -26
  466. package/lib/components/trax-store/trax-store.component.d.ts +0 -45
  467. package/lib/components/traxpopup/traxpopup.component.d.ts +0 -24
  468. package/lib/services/trax.service.d.ts +0 -175
  469. package/lib/tango-analyse-trax-routing.module.d.ts +0 -7
  470. package/lib/tango-analyse-trax.module.d.ts +0 -68
@@ -0,0 +1,4659 @@
1
+ import { ChangeDetectorRef, Component, ElementRef, HostListener, OnDestroy, OnInit, ViewChild } from '@angular/core';
2
+ import { ActivatedRoute, Router } from '@angular/router';
3
+ import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
4
+ import { TraxpopupComponent } from '../traxpopup/traxpopup.component';
5
+ import { TraxStoreComponent } from '../trax-store/trax-store.component';
6
+ import * as XLSX from 'xlsx';
7
+ import { ToastService } from 'tango-app-ui-shared';
8
+ import { TraxService } from '../../services/trax.service';
9
+ import dayjs from 'dayjs';
10
+ import customParseFormat from 'dayjs/plugin/customParseFormat';
11
+ import { GlobalStateService, PageInfoService } from 'tango-app-ui-global';
12
+ import { Subject, takeUntil, filter } from 'rxjs';
13
+ import utc from 'dayjs/plugin/utc.js';
14
+ import timeZone from 'dayjs/plugin/timezone.js';
15
+ dayjs.extend(timeZone);
16
+ dayjs.extend(utc);
17
+ dayjs.extend(customParseFormat);
18
+
19
+ @Component({
20
+ selector: "lib-checklist-configure",
21
+ templateUrl: "./checklist-configure.component.html",
22
+ styleUrl: "./checklist-configure.component.scss",
23
+ })
24
+ export class ChecklistConfigureComponent implements OnInit, OnDestroy {
25
+ @ViewChild("file") fileInput!: ElementRef;
26
+ @ViewChild("file1") fileInput1!: ElementRef;
27
+ @ViewChild("bulkupload") bulkupload: any;
28
+ @ViewChild("emailBulkupload") emailBulkupload: any;
29
+ @ViewChild("afterValidation") afterValidation: any;
30
+ @ViewChild("confirmUser") confirmUser: any;
31
+ dayjs: any = dayjs;
32
+ selectedDates: any;
33
+ minDate: any;
34
+ type: string = "custom";
35
+ obj: any;
36
+ configData: any;
37
+ tableData: any = [];
38
+ tableLoading: any = false;
39
+ tableDisplayedColumns: any = ["name", "role", "email"];
40
+ pageValue: any = [];
41
+ offset: number = 0;
42
+ recordsTotal: any = 0;
43
+ assignType: any;
44
+ size: any = 5;
45
+ offsetvalue: number = 0;
46
+ pageDisplay: any = [];
47
+ nextbtn: boolean = true;
48
+ backbtn: boolean = true;
49
+ idList: any = [];
50
+ currentValue: any = 1;
51
+ tableFilter: any = "";
52
+ pageStart: any = 0;
53
+ pageEnd: any = 0;
54
+ recordsCount: any;
55
+ paginationSize = [5, 10, 15, 20];
56
+ userData: any = [];
57
+ excelUserData: any = [];
58
+ showImage: boolean = true;
59
+ monthDay: any;
60
+ show: number = 0;
61
+ popUpTitle: any;
62
+ showIntro: boolean = true;
63
+ searchUser: any;
64
+ addUserForm: boolean;
65
+ sopStores: any = [];
66
+ storeCoverage: boolean = true;
67
+ userCoverage: boolean = false;
68
+ selectAll: boolean = false;
69
+ errormsg: boolean = false;
70
+ startTime: any;
71
+ endTime: any;
72
+ checklistId: any;
73
+ reupload: boolean = false;
74
+ selectAllUser: boolean = false;
75
+ removeUsers: any = [];
76
+ selectedDays: any[] = [];
77
+ showRangeValue: boolean = false;
78
+ submittedDates: number[] = [];
79
+ monthDate: string = "";
80
+ specific: boolean = false;
81
+ globalConfigure: boolean = true;
82
+ storewiseConfigure: boolean = false;
83
+ configureType: any;
84
+ date: any;
85
+ sections: any = [];
86
+ MonthweekNumber: string;
87
+ popupCount: number = 0;
88
+ validTime: boolean = true;
89
+ disabledQuestion: boolean = false;
90
+ showconfig: boolean = true;
91
+ showadvance: boolean = true;
92
+ repeatType: string = "";
93
+ showDropDown: boolean = false;
94
+ selectedDate: any = [];
95
+ dates: number[] = Array.from({ length: 31 }, (_, i) => i + 1); // Array from 1 to 31
96
+ selectedDateList: any = [];
97
+ selectedStartDate: any;
98
+ minStartDate: any;
99
+ selectedEndDate: any;
100
+ minEndDate: any;
101
+ clientId: any;
102
+ alertUsers: any = [];
103
+ alertTeams: any = [];
104
+ zoneList: any = [];
105
+ loading: boolean = true;
106
+ approve: boolean = true;
107
+ initialLoading: boolean = true;
108
+ existingUsers: any;
109
+ assignSingle: any;
110
+ assignGroup: any;
111
+ singleAssign: any;
112
+ groupAssign: any;
113
+ remainder: boolean = false;
114
+ disabledPublish: boolean = false;
115
+ private detach = new Subject();
116
+ timeLoop: any[] = [1];
117
+ minutes: number[] = [30, 45, 60, 75, 90];
118
+ showEdit: boolean = false;
119
+ disableBtn: boolean = true;
120
+ preOpenCloseTimeConfig: any = [10, 20, 30, 40, 50, 60];
121
+ personDetectionTimeThreshold: any = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
122
+ scheduleTimeConfig: any = [10, 15, 20, 25, 30, 35, 40, 45, 50, 60];
123
+ alertTimeConfig: any = Array.from({ length: 30 }, (_, i) => i + 1);;
124
+ alerttimekeyconfig: any;
125
+ selectedSource: any;
126
+ selectedDetectionStatus: string[] = [];
127
+ selectedDataprocessing: any;
128
+ selectedExportConfig: string[] = [];
129
+ notificationkeyconfig: any;
130
+ autotaskkeyconfig: any;
131
+ exportkeyconfig: any;
132
+ detectedstatuskeyconfig: any;
133
+ auditkeyconfig: any;
134
+ userType: any;
135
+ scheduletype: any = "standard";
136
+ recurrence: any;
137
+ schedulestartTime: any;
138
+ scheduleendTime: any;
139
+ recurrenceStatus: any;
140
+ recurrenceType: any;
141
+ recurrencetime: any;
142
+ isThresholdEnabled: any = false;
143
+ detectionThreshold: number = 1;
144
+ thresholdOptions = [1, 2, 3, 4, 5];
145
+ queueLengthEnabled: boolean = false;
146
+ queueLimit: any = "3";
147
+ waitTimeEnabled: boolean = true;
148
+ cameraAngleEnabled: boolean = true;
149
+ waitTimeLimit: any = "1";
150
+ alertCooldownEnabled: boolean = false;
151
+ alertCooldownTime: any = "10";
152
+ notifyFlag: boolean = false;
153
+ recurringFlagNotify: boolean = false;
154
+ recurringThresholds: number[] = Array.from({ length: 30 }, (_, i) => i + 1);
155
+ enableEmail: boolean = false;
156
+ timeSlot: number[] = Array.from({ length: 60 }, (_, i) => i + 1);
157
+ bufferTime: number[] = Array.from({ length: 30 }, (_, i) => i + 1);
158
+ minutesSlot: number[] = Array.from({ length: 60 }, (_, i) => i + 1);
159
+ emailDropdown: boolean = false;
160
+ // adminUsers:any = [];
161
+ constructor(
162
+ private changedetector: ChangeDetectorRef,
163
+ private router: ActivatedRoute,
164
+ private route: Router,
165
+ private dialog: NgbModal,
166
+ private SopService: TraxService,
167
+ private toast: ToastService,
168
+ public gs: GlobalStateService,
169
+ private pageInfo: PageInfoService,
170
+ ) { }
171
+
172
+ ngOnInit(): void {
173
+ let userInfo = JSON.parse(localStorage.getItem("user-info") || "{}");
174
+ if (userInfo?.userType) {
175
+ this.userType = userInfo.userType;
176
+ }
177
+ let storageDetails = JSON.parse(
178
+ localStorage.getItem("header-filters") || "{}",
179
+ );
180
+ if (!storageDetails?.client) {
181
+ storageDetails = JSON.parse(
182
+ localStorage.getItem("client-details") || "{}",
183
+ );
184
+ storageDetails.client = storageDetails.clientId;
185
+ }
186
+ if (storageDetails?.client) {
187
+ this.clientId = storageDetails.client;
188
+ this.router.queryParams.subscribe((params) => {
189
+ if (params?.checkListId) {
190
+ this.obj = {
191
+ checkListId: params.checkListId,
192
+ clientId: this.clientId,
193
+ };
194
+ this.showEdit = params.showEdit;
195
+ this.type = "custom";
196
+ this.disabledQuestion = params.disabledQuestion;
197
+ } else if (params?.aicheckListId) {
198
+ this.disableBtn = false;
199
+ this.obj = {
200
+ id: params.aicheckListId,
201
+ clientId: this.clientId,
202
+ };
203
+ this.checklistId = params?.aicheckListId;
204
+ this.showEdit = params.showEdit;
205
+ this.type = params.type;
206
+ this.disabledQuestion = params.disabledQuestion;
207
+ } else {
208
+ this.disableBtn = false;
209
+ this.obj = {
210
+ type: params.type,
211
+ clientId: this.clientId,
212
+ };
213
+ this.type = params.type;
214
+ }
215
+ });
216
+ this.setPageData();
217
+ this.selectInitialTab();
218
+ this.type === "custom" ? this.GetConfig() : this.getAIconfig();
219
+ // this.getZoneList();
220
+ }
221
+ }
222
+
223
+ ngOnDestroy(): void {
224
+ this.detach.next(true);
225
+ this.detach.complete();
226
+ }
227
+
228
+ setPageData() {
229
+ this.pageInfo.setTitle("Manage Checklist");
230
+ this.pageInfo.setDescription(
231
+ "Automate or create checklists to improve operational efficiency",
232
+ );
233
+ this.pageInfo.setBreadcrumbs([
234
+ {
235
+ title: "Tango Trax",
236
+ path: "/manage/trax/dashboard",
237
+ isActive: false,
238
+ isSeparator: false,
239
+ },
240
+ {
241
+ title: "Tango Trax",
242
+ path: "/manage/trax/dashboard",
243
+ isActive: false,
244
+ isSeparator: true,
245
+ },
246
+ ]);
247
+ }
248
+
249
+ selectInitialTab() {
250
+ this.storeCoverage
251
+ ? (this.assignType = "store")
252
+ : (this.assignType = "user");
253
+ }
254
+
255
+ GetConfig() {
256
+ this.loading = true;
257
+ this.monthDate = "";
258
+ this.monthDay = "";
259
+ this.SopService.getconfig(this.obj)
260
+ .pipe(takeUntil(this.detach))
261
+ .subscribe(
262
+ (res: any) => {
263
+ if (res && res.code == 200) {
264
+ this.loading = false;
265
+ if (res.data.checkListDetails.checkListType) {
266
+ this.checklistId = res.data.checkListDetails._id;
267
+ this.type = res.data.checkListDetails.checkListType;
268
+ this.configData = res.data;
269
+ this.configData.checkListDetails.assign = [];
270
+ this.configData.checkListDetails.notifyType = [];
271
+ this.coverage = this.configData.checkListDetails.coverage;
272
+ if (
273
+ this.configData.checkListDetails?.notifyFlags?.notifyType
274
+ ?.length
275
+ ) {
276
+ this.notifyFlag = true;
277
+ }
278
+ if (
279
+ this.configData.checkListDetails?.recurringFlag?.notifyType
280
+ ?.length
281
+ ) {
282
+ this.recurringFlagNotify = true;
283
+ }
284
+ if (this.configData.checkListDetails?.autoEmail?.type?.length) {
285
+ this.enableEmail = true;
286
+ }
287
+ // this.configData.checkListDetails.assignedUsers = [...this.singleAssign,...this.groupAssign]
288
+ this.selectRadio(this.coverage);
289
+ // this.coverage === 'store' ? this.storeCoverage = true : this.userCoverage = true
290
+ this.removeUsers =
291
+ this.configData.checkListDetails?.removedUsers || [];
292
+ // this.approve = this.configData.checkListDetails.approver?.length ? true : false;
293
+ this.remainder = this.configData.checkListDetails?.remainder
294
+ ?.length
295
+ ? true
296
+ : false;
297
+ this.timeLoop = this.configData.checkListDetails?.remainder
298
+ ?.length
299
+ ? Array.from(
300
+ {
301
+ length: this.configData.checkListDetails.remainder.length,
302
+ },
303
+ (_, i) => i,
304
+ )
305
+ : [0];
306
+
307
+ if (this.configData?.checkListDetails?.publishDate) {
308
+ let date = this.dayjs();
309
+ if (
310
+ date.diff(
311
+ this.dayjs.utc(
312
+ this.configData?.checkListDetails?.publishDate,
313
+ ),
314
+ "minutes",
315
+ ) < 5
316
+ ) {
317
+ let startInterval = setInterval(() => {
318
+ date = this.dayjs();
319
+ this.disabledPublish = true;
320
+ if (
321
+ date.diff(
322
+ this.dayjs.utc(
323
+ this.configData?.checkListDetails?.publishDate,
324
+ ),
325
+ "minutes",
326
+ ) >= 5
327
+ ) {
328
+ this.disabledPublish = false;
329
+ clearInterval(startInterval);
330
+ this.changedetector.detectChanges();
331
+ }
332
+ }, 0);
333
+ }
334
+ }
335
+
336
+ this.removeUsers = res.data?.checkListDetails?.removedUsers || [];
337
+ // this.zones = this.configData?.checkListDetails?.detectionArea || [];
338
+ this.sections = this.configData.checkListDetails.sections;
339
+ this.selectedDays =
340
+ this.configData?.checkListDetails?.scheduleWeekDays || [];
341
+ this.endTime = this.configData.checkListDetails?.scheduleEndTime
342
+ ? this.dayjs(
343
+ this.configData.checkListDetails?.scheduleEndTime,
344
+ "h:mm A",
345
+ ).format("HH:mm")
346
+ : "22:00";
347
+ this.startTime = this.configData.checkListDetails
348
+ ?.scheduleStartTime
349
+ ? this.dayjs(
350
+ this.configData.checkListDetails?.scheduleStartTime,
351
+ "h:mm A",
352
+ ).format("HH:mm")
353
+ : "10:00";
354
+ this.repeatType =
355
+ this.configData.checkListDetails?.schedule == "daily"
356
+ ? "Day"
357
+ : ["weekly", "weekday"].includes(
358
+ this.configData.checkListDetails?.schedule,
359
+ )
360
+ ? "Week"
361
+ : "Month";
362
+ if (!this.configData.checkListDetails?.scheduleEndTime) {
363
+ this.configData.checkListDetails.scheduleEndTime = "10:00 PM";
364
+ }
365
+ if (!this.configData.checkListDetails?.scheduleStartTime) {
366
+ this.configData.checkListDetails.scheduleStartTime = "10:00 AM";
367
+ }
368
+ if (!this.configData.checkListDetails?.redoValidity) {
369
+ this.configData.checkListDetails.redoValidity = 7;
370
+ }
371
+
372
+ // if (this.configData?.checkListDetails?.alert?.alertsTo.length) {
373
+ // this.emailList = this.configData?.checkListDetails?.alert?.alertsTo;
374
+ // }
375
+
376
+ if (this.configData.checkListDetails.schedule != "onetime") {
377
+ this.showRangeValue =
378
+ this.configData.checkListDetails?.configStartDate != "" &&
379
+ this.configData.checkListDetails?.configStartDate != null
380
+ ? true
381
+ : false;
382
+ if (
383
+ this.configData.checkListDetails?.configStartDate != "" &&
384
+ this.configData.checkListDetails?.configStartDate != null
385
+ ) {
386
+ this.configData.checkListDetails.configStartDate = this.dayjs(
387
+ this.configData.checkListDetails?.configStartDate,
388
+ ).format("YYYY-MM-DD");
389
+ this.selectedStartDate = {
390
+ startDate: this.dayjs(
391
+ this.configData.checkListDetails?.configStartDate,
392
+ ).format("DD-MM-YYYY"),
393
+ endDate: this.dayjs(
394
+ this.configData.checkListDetails?.configStartDate,
395
+ ).format("DD-MM-YYYY"),
396
+ };
397
+ this.minStartDate = this.dayjs(
398
+ this.configData.checkListDetails?.configStartDate,
399
+ ).format();
400
+ }
401
+ if (
402
+ this.configData.checkListDetails?.configEndDate != "" &&
403
+ this.configData.checkListDetails?.configEndDate != null
404
+ ) {
405
+ this.configData.checkListDetails.configEndDate = this.dayjs(
406
+ this.configData.checkListDetails?.configEndDate,
407
+ ).format("YYYY-MM-DD");
408
+ this.selectedEndDate = {
409
+ startDate: this.dayjs(
410
+ this.configData.checkListDetails?.configEndDate,
411
+ ).format("DD-MM-YYYY"),
412
+ endDate: this.dayjs(
413
+ this.configData.checkListDetails?.configEndDate,
414
+ ).format("DD-MM-YYYY"),
415
+ };
416
+ this.minEndDate = this.dayjs(
417
+ this.configData.checkListDetails?.configEndDate,
418
+ ).format();
419
+ }
420
+ if (this.configData.checkListDetails?.schedule == "monthly") {
421
+ if (
422
+ this.configData.checkListDetails
423
+ ?.scheduleRepeatedMonthSetup == "date"
424
+ ) {
425
+ if (
426
+ this.configData.checkListDetails?.scheduleRepeatedMonthWeek.split(
427
+ " ",
428
+ )?.length > 1
429
+ ) {
430
+ this.monthDate =
431
+ this.configData.checkListDetails?.scheduleRepeatedMonthWeek.split(
432
+ " ",
433
+ )[0];
434
+ this.monthDay =
435
+ this.configData.checkListDetails?.scheduleRepeatedMonthWeek.split(
436
+ " ",
437
+ )[1];
438
+ this.configData.checkListDetails.scheduleRepeatedMonthWeek =
439
+ "";
440
+ }
441
+ }
442
+ if (
443
+ this.configData.checkListDetails
444
+ ?.scheduleRepeatedMonthSetup == "specific"
445
+ ) {
446
+ this.submittedDates =
447
+ this.configData.checkListDetails?.specificDate || [];
448
+ this.selectedDate = this.submittedDates;
449
+ }
450
+ }
451
+
452
+ if (
453
+ this.configData.checkListDetails?.schedule == "range" &&
454
+ this.configData.checkListDetails.specificDate.length
455
+ ) {
456
+ this.specific = true;
457
+ this.selectedDateList =
458
+ this.configData.checkListDetails.specificDate;
459
+ }
460
+ }
461
+
462
+ if (this.configData.checkListDetails.schedule == "onetime") {
463
+ this.configData.checkListDetails.scheduleDate = this.configData
464
+ .checkListDetails.scheduleDate
465
+ ? this.dayjs
466
+ .utc(this.configData.checkListDetails.scheduleDate)
467
+ .format()
468
+ : dayjs().format();
469
+ this.selectedDates = {
470
+ startDate: this.dayjs(
471
+ this.configData.checkListDetails.scheduleDate,
472
+ ).format("DD-MM-YYYY"),
473
+ endDate: this.dayjs(
474
+ this.configData.checkListDetails.scheduleDate,
475
+ ).format("DD-MM-YYYY"),
476
+ };
477
+ this.minDate = this.dayjs(
478
+ this.configData.checkListDetails.scheduleDate,
479
+ ).format();
480
+ }
481
+ // this.userDetailsV2();
482
+ // this.getassignDropdown();
483
+ // this.gettableData();
484
+ this.getClientUser();
485
+ }
486
+ }
487
+ },
488
+ (error) => {
489
+ if (error.code == 403) {
490
+ // this.router.navigate(['/error403'])
491
+ }
492
+ },
493
+ );
494
+ }
495
+
496
+ getAIconfig() {
497
+ this.SopService.getAIconfig(this.obj)
498
+ .pipe(takeUntil(this.detach))
499
+ .subscribe(
500
+ (res: any) => {
501
+ if (res && res.code == 200) {
502
+ this.loading = false;
503
+ this.configData = res.data;
504
+ if (
505
+ !this.configData?.aiConfig?.events?.length &&
506
+ ["scrum", "cleaning"].includes(this.type)
507
+ ) {
508
+ this.configData?.aiConfig?.events.push({
509
+ time: this.dayjs().format("HH:mm"),
510
+ duration: "15",
511
+ });
512
+ }
513
+ if (
514
+ !this.configData?.aiConfig?.assignConfig &&
515
+ ["scrum", "cleaning"].includes(this.type)
516
+ ) {
517
+ this.configData.aiConfig.assignConfig = "global";
518
+ }
519
+ if (!this.configData?.aiConfig?.autoTaskConfig?.taskValidity) {
520
+ this.configData.aiConfig.autoTaskConfig["taskValidity"] = {
521
+ type: "mins",
522
+ time: 1,
523
+ };
524
+ }
525
+ if (!this.configData?.aiConfig?.autoTaskConfig?.users) {
526
+ this.configData.aiConfig.autoTaskConfig["users"] = [];
527
+ }
528
+ if (!this.configData.aiConfig.autoTaskConfig.approverEnabled) {
529
+ this.configData.aiConfig.autoTaskConfig["approverEnabled"] =
530
+ false;
531
+ }
532
+ if (["storeopenandclose"].includes(this.type)) {
533
+ if (!this.configData.aiConfig.storeOpenClose) {
534
+ this.configData.aiConfig.storeOpenClose = {};
535
+ }
536
+ if (!this.configData.aiConfig.storeOpenClose.buffer) {
537
+ this.configData.aiConfig.storeOpenClose.buffer = { openTime: 0, closeTime: 0 };
538
+ }
539
+ if (!this.configData.aiConfig.storeOpenClose.detectionType) {
540
+ this.configData.aiConfig.storeOpenClose.detectionType = "allCameras";
541
+ }
542
+ }
543
+ if (["storehygienemonitoring"].includes(this.type)) {
544
+ this.scheduletype =
545
+ this.configData.aiConfig.hygieneMonitoring.schedule.scheduletype;
546
+ this.schedulestartTime =
547
+ this.configData.aiConfig.hygieneMonitoring.schedule.openTime;
548
+ this.scheduleendTime =
549
+ this.configData.aiConfig.hygieneMonitoring.schedule.closeTime;
550
+ this.recurrenceType =
551
+ this.configData.aiConfig.hygieneMonitoring.recurrence.type;
552
+ this.recurrencetime =
553
+ this.configData.aiConfig.hygieneMonitoring.recurrence.time;
554
+ if (!this.configData.aiConfig.hygieneMonitoring.floorDetection) {
555
+ this.configData.aiConfig.hygieneMonitoring.floorDetection = {
556
+ enabled: false,
557
+ duration: 2,
558
+ };
559
+ }
560
+ }
561
+ if (["tvcompliance"].includes(this.type)) {
562
+ this.scheduletype =
563
+ this.configData?.aiConfig?.tvcompliance?.schedule?.scheduletype;
564
+ this.schedulestartTime =
565
+ this.configData?.aiConfig?.tvcompliance?.schedule?.openTime;
566
+ this.scheduleendTime =
567
+ this.configData?.aiConfig?.tvcompliance?.schedule?.closeTime;
568
+ this.recurrenceStatus =
569
+ this.configData?.aiConfig?.tvcompliance?.recurrence?.status;
570
+ this.recurrencetime =
571
+ this.configData?.aiConfig?.tvcompliance?.recurrence?.time;
572
+ this.isThresholdEnabled =
573
+ this.configData?.aiConfig?.tvcompliance?.detectedStatus?.status;
574
+ this.detectionThreshold =
575
+ this.configData?.aiConfig?.tvcompliance?.detectedStatus?.detections;
576
+ }
577
+ if (["queuealert"].includes(this.type)) {
578
+ this.scheduletype =
579
+ this.configData?.aiConfig?.tvcompliance?.schedule?.scheduletype;
580
+ this.schedulestartTime =
581
+ this.configData?.aiConfig?.tvcompliance?.schedule?.openTime;
582
+ this.scheduleendTime =
583
+ this.configData?.aiConfig?.tvcompliance?.schedule?.closeTime;
584
+ this.queueLengthEnabled =
585
+ this.configData?.aiConfig?.queuealert?.queueLengthEnabled;
586
+ this.queueLimit =
587
+ this.configData?.aiConfig?.queuealert?.queueLimit;
588
+ this.waitTimeEnabled =
589
+ this.configData?.aiConfig?.queuealert?.waitTimeEnabled;
590
+ this.waitTimeLimit =
591
+ this.configData?.aiConfig?.queuealert?.waitTimeLimit;
592
+ this.alertCooldownEnabled =
593
+ this.configData?.aiConfig?.queuealert?.alertCooldownEnabled || false;
594
+ this.alertCooldownTime =
595
+ this.configData?.aiConfig?.queuealert?.alertCooldownTime || "10";
596
+ }
597
+ if (["staffgrouping"].includes(this.type)) {
598
+ this.scheduletype =
599
+ this.configData?.aiConfig?.staffGrouping?.schedule?.scheduletype || "standard";
600
+ this.schedulestartTime =
601
+ this.configData?.aiConfig?.staffGrouping?.schedule?.openTime;
602
+ this.scheduleendTime =
603
+ this.configData?.aiConfig?.staffGrouping?.schedule?.closeTime;
604
+ if (!this.configData.aiConfig.staffGrouping) {
605
+ this.configData.aiConfig.staffGrouping = {};
606
+ }
607
+ if (!this.configData.aiConfig.staffGrouping.countAlert) {
608
+ this.configData.aiConfig.staffGrouping.countAlert = {
609
+ enabled: false,
610
+ threshold: 3,
611
+ };
612
+ }
613
+ if (!this.configData.aiConfig.staffGrouping.timeSpentAlert) {
614
+ this.configData.aiConfig.staffGrouping.timeSpentAlert = {
615
+ enabled: false,
616
+ duration: 3,
617
+ };
618
+ }
619
+ if (!this.configData.aiConfig.staffGrouping.hibernation) {
620
+ this.configData.aiConfig.staffGrouping.hibernation = {
621
+ enabled: false,
622
+ startTime: "01:00",
623
+ startPeriod: "PM",
624
+ endTime: "02:00",
625
+ endPeriod: "PM",
626
+ };
627
+ }
628
+ this.alertCooldownEnabled =
629
+ this.configData?.aiConfig?.staffGrouping?.alertCooldownEnabled || false;
630
+ this.alertCooldownTime =
631
+ this.configData?.aiConfig?.staffGrouping?.alertCooldownTime || "10";
632
+ }
633
+ if (["boxalert"].includes(this.type)) {
634
+ this.scheduletype =
635
+ this.configData?.aiConfig?.boxAlert?.schedule?.scheduletype || "standard";
636
+ this.schedulestartTime =
637
+ this.configData?.aiConfig?.boxAlert?.schedule?.openTime;
638
+ this.scheduleendTime =
639
+ this.configData?.aiConfig?.boxAlert?.schedule?.closeTime;
640
+ this.recurrenceType =
641
+ this.configData?.aiConfig?.boxAlert?.recurrence?.type;
642
+ this.recurrencetime =
643
+ this.configData?.aiConfig?.boxAlert?.recurrence?.time;
644
+ if (!this.configData.aiConfig.boxAlert) {
645
+ this.configData.aiConfig.boxAlert = {};
646
+ }
647
+ if (!this.configData.aiConfig.boxAlert.emptyShelfAlert) {
648
+ this.configData.aiConfig.boxAlert.emptyShelfAlert = {
649
+ enabled: false,
650
+ duration: 20,
651
+ };
652
+ }
653
+ }
654
+ if (["employeeCount"].includes(this.type)) {
655
+ if (!this.configData.aiConfig.employeeCount) {
656
+ this.configData.aiConfig.employeeCount = {};
657
+ }
658
+ this.scheduletype =
659
+ this.configData?.aiConfig?.employeeCount?.schedule?.scheduletype || "standard";
660
+ this.schedulestartTime =
661
+ this.configData?.aiConfig?.employeeCount?.schedule?.openTime;
662
+ this.scheduleendTime =
663
+ this.configData?.aiConfig?.employeeCount?.schedule?.closeTime;
664
+ this.recurrenceType =
665
+ this.configData?.aiConfig?.employeeCount?.recurrence?.type;
666
+ this.recurrencetime =
667
+ this.configData?.aiConfig?.employeeCount?.recurrence?.time;
668
+ this.recurrenceStatus =
669
+ this.configData?.aiConfig?.employeeCount?.recurrence?.status || false;
670
+ }
671
+ if (
672
+ [
673
+ "halfshutter",
674
+ "tvcompliance",
675
+ "queuealert",
676
+ "cameratampering",
677
+ "storeopenandclose",
678
+ "mobileusagedetection",
679
+ "storehygienemonitoring",
680
+ "uniformdetection",
681
+ "staffgrouping",
682
+ "boxalert",
683
+ "employeeCount",
684
+ ].includes(this.type)
685
+ ) {
686
+ this.cameraAngleEnabled =
687
+ this.configData?.aiConfig?.cameraAngle?.enabled || false;
688
+ this.alerttimekeyconfig =
689
+ this.configData?.aiConfig?.alertConfig?.allowBuffer?.enabled ||
690
+ false;
691
+ this.selectedSource =
692
+ this.configData?.aiConfig?.advancedConfig?.auditConfig
693
+ ?.inputSourceFile || "";
694
+ this.selectedDetectionStatus =
695
+ this.configData?.aiConfig?.advancedConfig?.detectedStatus
696
+ ?.detections || [];
697
+ this.selectedDataprocessing =
698
+ this.configData?.aiConfig?.advancedConfig?.dataProcessing || "";
699
+ this.selectedExportConfig =
700
+ this.configData?.aiConfig?.exportConfig?.format || [];
701
+ this.notificationkeyconfig =
702
+ this.configData?.aiConfig?.alertConfig?.alertSendTo?.enabled ||
703
+ false;
704
+ this.autotaskkeyconfig =
705
+ this.configData?.aiConfig?.autoTaskConfig?.enabled || false;
706
+ this.exportkeyconfig =
707
+ this.configData?.aiConfig?.exportConfig?.enabled || false;
708
+ this.detectedstatuskeyconfig =
709
+ this.configData?.aiConfig?.advancedConfig?.detectedStatus
710
+ ?.enabled || false;
711
+ this.auditkeyconfig =
712
+ this.configData?.aiConfig?.advancedConfig?.auditConfig
713
+ ?.enabled || false;
714
+
715
+ if (this.configData?.aiConfig?.autoTaskConfig?.taskValidity?.type == "days") {
716
+ this.timeSlot = Array.from({ length: 3 }, (_, i) => i + 1);
717
+ } else if (this.configData?.aiConfig?.autoTaskConfig?.taskValidity?.type == "hours") {
718
+ this.timeSlot = Array.from({ length: 24 }, (_, i) => i + 1);
719
+ } else {
720
+ this.timeSlot = Array.from({ length: 60 }, (_, i) => i + 1);
721
+ }
722
+ }
723
+ // this.configData.checkListDetails.assign = [];
724
+ // this.coverage = this.configData.checkListDetails.coverage;
725
+ // this.checklistId = res.data.checkListDetails._id;
726
+ // this.type = res.data.checkListDetails.checkListType;
727
+ this.getClientUser();
728
+ this.getZoneList();
729
+ this.getTeamList();
730
+ }
731
+ },
732
+ (error) => {
733
+ if (error.code == 403) {
734
+ // this.router.navigate(['/error403'])
735
+ }
736
+ },
737
+ );
738
+ }
739
+
740
+ getInitialData(data: any, change?: any) {
741
+ let tempId = data.map((el: any) => el?.id);
742
+ let res = this.storeList.filter((el: any) => tempId.includes(el?._id));
743
+ res.forEach((element: any) => (element.isSelected = true));
744
+ this.configData.checkListDetails.assign = res;
745
+ if (this.assignType === "store" || this.assignType === "user") {
746
+ this.tableLoading = false;
747
+ this.tableLoading1 = false;
748
+ this.showImage = true;
749
+ // this.userDetails(),
750
+ // (this.assignType === 'store' && this.initialLoading) ? (this.initialLoading = false) : this.getTableData(change ? change : '');
751
+ this.idList = this.singleAssign;
752
+ } else {
753
+ this.idList = this.groupAssign;
754
+ this.userDetailsV2();
755
+ }
756
+ }
757
+
758
+ getTableData(change?: any) {
759
+ let count = 0;
760
+ if (this.assignSingle?.length) {
761
+ if (
762
+ this.configData.checkListDetails.assign.length !=
763
+ this.assignSingle.length
764
+ ) {
765
+ count++;
766
+ }
767
+ this.configData.checkListDetails.assign.forEach((assign: any) => {
768
+ let findList = this.assignSingle.filter(
769
+ (item: any) => item.storeId == assign.storeId,
770
+ );
771
+ if (findList.length) {
772
+ if (findList.length > 1) {
773
+ count++;
774
+ } else {
775
+ if (
776
+ assign.userEmail.toLowerCase() !=
777
+ findList[0].userEmail.toLowerCase() &&
778
+ this.coverage === "store"
779
+ ) {
780
+ assign.userEmail = findList[0].userEmail;
781
+ assign.userName = findList[0].userName;
782
+ count++;
783
+ }
784
+ }
785
+ }
786
+ });
787
+ if (count) {
788
+ this.upload = change ? "upload" : "store";
789
+ }
790
+ }
791
+
792
+ // this.tableArray = this.assignSingle ? this.assignSingle : this.configData.checkListDetails.assign;
793
+ change ? (this.tableArray = this.assignSingle) : [];
794
+ if (this.upload === "store") {
795
+ let table = [
796
+ ...this.tableArray,
797
+ ...this.configData.checkListDetails.assign,
798
+ ];
799
+ let uniqueTable = new Map();
800
+ // Convert objects to JSON strings for full comparison
801
+ table.forEach((item: any) => {
802
+ item = {
803
+ storeName: item?.storeName,
804
+ storeId: item.storeId,
805
+ userEmail: item.userEmail.toLowerCase(),
806
+ userName: item.userName,
807
+ _id: item._id,
808
+ };
809
+ let data = {
810
+ _id: item._id,
811
+ ...(this.storeCoverage
812
+ ? {
813
+ userEmail: item.userEmail.toLowerCase(),
814
+ storeName: item?.storeName,
815
+ }
816
+ : {}),
817
+ };
818
+ let key = JSON.stringify(data); // Convert entire object to string as a key
819
+ if (!uniqueTable.has(data)) {
820
+ uniqueTable.set(key, item); // Store the object only if it's completely unique
821
+ }
822
+ });
823
+ this.assignSingle = Array.from(uniqueTable.values());
824
+ this.tableArray = this.assignSingle;
825
+ } else if (this.upload === "upload") {
826
+ this.tableArray = this.assignSingle;
827
+ } else {
828
+ this.tableArray = this.configData.checkListDetails.assign;
829
+ this.assignSingle = this.tableArray;
830
+ }
831
+ this.tableArray?.length
832
+ ? (this.showImage = false)
833
+ : (this.showImage = true);
834
+ this.recordsTotal = this.tableArray.length;
835
+ if (this.recordsTotal < 5) {
836
+ this.paginationSize = [this.recordsTotal];
837
+ this.size = this.recordsTotal;
838
+ } else {
839
+ this.paginationSize = [5, 10, 15, 20];
840
+ this.size = 5;
841
+ }
842
+ this.tableLoading1 = false;
843
+ this.tableLoading = false;
844
+
845
+ this.tableData = this.tableArray.slice(
846
+ this.currentValue * this.size - this.size,
847
+ this.currentValue * this.size,
848
+ );
849
+ }
850
+
851
+ accordian(index: any) {
852
+ if (this.show == index) {
853
+ this.show = -1;
854
+ } else {
855
+ this.show = index;
856
+ }
857
+ }
858
+ configaccordian(): void {
859
+ this.showconfig = !this.showconfig;
860
+ }
861
+ advanceaccordian(): void {
862
+ this.showadvance = !this.showadvance;
863
+ }
864
+ Checklist() {
865
+ // this.mobileusagedetection = true;
866
+ // this.storeopenandclosedetection = false;
867
+ }
868
+ omit_special_char(event: any) {
869
+ var k;
870
+ k = event.charCode; // k = event.keyCode; (Both can be used)
871
+ return k == 8 || k == 32 || (k >= 48 && k <= 57);
872
+ }
873
+
874
+ clickAIconfigure(value: any) {
875
+ this.configData.aiConfig.assignConfig = value;
876
+ this.configureType = value;
877
+ this.changedetector.detectChanges();
878
+ }
879
+
880
+ validateLimit(event: any) {
881
+ if (event.target.value < 1 && this.type == "mobileusagedetection") {
882
+ // event.target.value = '';
883
+ this.errormsg = true;
884
+ // this.configData.checkListDetails.alert.usageExceeds = '';
885
+ this.changedetector.detectChanges();
886
+ } else if (
887
+ this.type == "storeopenandclose" &&
888
+ !this.configData.aiConfig.storeOpenClose.buffer.openTime &&
889
+ !this.configData.aiConfig.storeOpenClose.buffer.closeTime
890
+ ) {
891
+ this.checkBuffer = false;
892
+ } else this.errormsg = false;
893
+ }
894
+
895
+ coverage: any = "store";
896
+
897
+ selectRadio(data: any, change?: any) {
898
+ this.coverage = data;
899
+ this.currentValue = 1;
900
+ this.size = 5;
901
+ this.tableFilter = "";
902
+ this.configData.checkListDetails.assign = [];
903
+ this.tableArray = [];
904
+ this.tableData = [];
905
+ if (data === "store") {
906
+ this.storeCoverage = true;
907
+ this.userCoverage = false;
908
+ } else if (data === "user") {
909
+ this.userCoverage = true;
910
+ this.storeCoverage = false;
911
+ }
912
+ this.selectInitialTab();
913
+ if (this.coverage === this.configData.checkListDetails.coverage) {
914
+ this.singleAssign = this.configData.checkListDetails.singleAssign;
915
+ this.groupAssign = this.configData.checkListDetails.groupAssign;
916
+ setTimeout(() => {
917
+ this.assignType ? this.userDetails() : "";
918
+ }, 3000);
919
+ } else {
920
+ this.singleAssign = [];
921
+ this.groupAssign = [];
922
+ ((this.assignSingle = []), (this.assignGroup = []));
923
+ this.tableLoading = true;
924
+ this.showImage = true;
925
+ }
926
+ this.getassignDropdown();
927
+ }
928
+
929
+ excelData: any;
930
+ showUser: boolean = false;
931
+ showTeam: boolean = false;
932
+ showStore: boolean = false;
933
+ showCluster: boolean = false;
934
+
935
+ onFileUpload(event: any, reupload?: any) {
936
+ this.validatedStore = [];
937
+ this.validatedUser = [];
938
+ this.validatedCluster = [];
939
+ this.validatedTeam = [];
940
+ this.newUser = [];
941
+ this.inactiveStores = [];
942
+ this.showUser = false;
943
+ this.showTeam = false;
944
+ this.showStore = false;
945
+ this.showCluster = false;
946
+ this.showInactive = false;
947
+ this.currentValue = 1;
948
+ this.reupload = false;
949
+ this.upload = "upload";
950
+ this.userData = this.excelUserData = [];
951
+ let data: any;
952
+ const target: DataTransfer = <DataTransfer>event.target;
953
+ let isExcelFile = !!target.files[0].name.match(/(.xls|.xlsx)/);
954
+ let error: any = [];
955
+ let ValidationError: boolean = false;
956
+ if (isExcelFile) {
957
+ const reader: FileReader = new FileReader();
958
+ reader.readAsBinaryString(target.files[0]);
959
+ reader.onload = (e: any) => {
960
+ const bstr: string = e.target.result;
961
+ const wb: XLSX.WorkBook = XLSX.read(bstr, { type: "binary" });
962
+ const wsname: string = wb.SheetNames[0];
963
+ const ws: XLSX.WorkSheet = wb.Sheets[wsname];
964
+ data = XLSX.utils.sheet_to_json(ws);
965
+ this.excelData = data;
966
+ if (
967
+ !data.length ||
968
+ data.some((item: any) => "clusterName" in item || "teamName" in item)
969
+ ) {
970
+ this.toast.getErrorToast("Please Upload a Valid file.");
971
+ return;
972
+ }
973
+
974
+ const requiredKeys = this.storeCoverage
975
+ ? ["storeName", "userName", "userEmail"]
976
+ : ["userName", "userEmail"]; // Must always be present
977
+ const optionalKeys = this.storeCoverage
978
+ ? ["userPhone", "city"]
979
+ : ["userPhone", "city"];
980
+
981
+ const isValid = data.some((item: any) => {
982
+ const keys = Object.keys(item);
983
+ const hasRequiredKeys = requiredKeys.every((key) =>
984
+ keys.includes(key),
985
+ );
986
+ const allKeysAreAllowed = keys.every(
987
+ (key) => requiredKeys.includes(key) || optionalKeys.includes(key),
988
+ );
989
+ return hasRequiredKeys && allKeysAreAllowed;
990
+ });
991
+
992
+ if (!isValid) {
993
+ this.toast.getErrorToast("Please Upload a Valid file.");
994
+ return;
995
+ }
996
+
997
+ // data = data.filter((item:any) => {
998
+ // return ((item?.storeName && item?.storeName.trim() != '' && item?.storeName.trim() != null) || (item?.userName && item?.userName.trim() != '' && item?.userName.trim() != null) || (item?.userEmail && item?.userEmail.trim() != '' && item?.userEmail.trim() != null))
999
+ // })
1000
+
1001
+ data.forEach((element: any, index: any) => {
1002
+ if (element?.userEmail) {
1003
+ element.userEmail = element?.userEmail.replace(/\s/g, "");
1004
+ }
1005
+ if (this.storeCoverage) {
1006
+ if (element?.storeName?.trim() == "" || element.storeName == null) {
1007
+ error.push(`Invalid StoreName - A${index + 2}`);
1008
+ }
1009
+ if (element?.userName?.trim() == "" || element.userName == null) {
1010
+ error.push(`Invalid UserName - B${index + 2}`);
1011
+ }
1012
+ if (element?.userEmail?.trim() == "" || element.userEmail == null) {
1013
+ error.push(`Invalid userEmail - C${index + 2}`);
1014
+ }
1015
+ if (
1016
+ element?.userEmail &&
1017
+ !element.userEmail.match(
1018
+ /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/,
1019
+ )
1020
+ ) {
1021
+ error.push(`Invalid userEmail - C${index + 2}`);
1022
+ }
1023
+ if (element.clusterName) {
1024
+ if (
1025
+ element.clusterName?.trim() == "" ||
1026
+ element.clusterName == null
1027
+ ) {
1028
+ error.push(`Invalid clusterName - D${index + 2}`);
1029
+ }
1030
+ }
1031
+ } else if (this.userCoverage && !element?.storeName) {
1032
+ if (element?.userName?.trim() == "" || element.userName == null) {
1033
+ error.push(`Invalid UserName - A${index + 2}`);
1034
+ }
1035
+ if (element?.userEmail?.trim() == "" || element.userEmail == null) {
1036
+ error.push(`Invalid userEmail - B${index + 2}`);
1037
+ }
1038
+ if (
1039
+ element?.userEmail &&
1040
+ !element.userEmail.match(
1041
+ /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/,
1042
+ )
1043
+ ) {
1044
+ error.push(`Invalid userEmail - B${index + 2}`);
1045
+ }
1046
+ if (element.teamName) {
1047
+ if (element.teamName?.trim() == "" || element.teamName == null) {
1048
+ error.push(`Invalid teamName - C${index + 2}`);
1049
+ }
1050
+ }
1051
+ } else {
1052
+ this.toast.getErrorToast("Please upload a valid file.");
1053
+ ValidationError = true;
1054
+ }
1055
+ if (this.storeCoverage) {
1056
+ if (this.assignType === "store") {
1057
+ this.userData.push({
1058
+ storeName: element?.storeName?.trim(),
1059
+ userName: element?.userName?.trim(),
1060
+ userEmail: element?.userEmail?.toLowerCase()?.trim(),
1061
+ userPhone: element?.userPhone,
1062
+ // checkFlag: element?.check ? element.check : false,
1063
+ city: element?.city,
1064
+ type: "store",
1065
+ });
1066
+ } else {
1067
+ this.userData.push({
1068
+ storeName: element?.storeName?.trim(),
1069
+ userName: element?.userName?.trim(),
1070
+ userEmail: element?.userEmail?.toLowerCase()?.trim(),
1071
+ clusterName: element?.clusterName,
1072
+ userPhone: element?.userPhone,
1073
+ // checkFlag: element?.check ? element.check : false,
1074
+ city: element?.city,
1075
+ type: "cluster",
1076
+ });
1077
+ }
1078
+ } else if (this.userCoverage) {
1079
+ if (this.assignType === "user") {
1080
+ this.userData.push({
1081
+ userName: element?.userName?.trim(),
1082
+ userEmail: element?.userEmail?.toLowerCase()?.trim(),
1083
+ userPhone: element?.userPhone,
1084
+ // checkFlag: element?.check ? element.check : false,
1085
+ type: "user",
1086
+ });
1087
+ } else {
1088
+ this.userData.push({
1089
+ userName: element?.userName?.trim(),
1090
+ userEmail: element?.userEmail?.toLowerCase()?.trim(),
1091
+ teamName: element?.teamName,
1092
+ userPhone: element?.userPhone,
1093
+ // checkFlag: element?.check ? element.check : false,
1094
+ type: "teams",
1095
+ });
1096
+ }
1097
+ }
1098
+ });
1099
+
1100
+ if (error.length) {
1101
+ this.dialog.dismissAll();
1102
+ const popupcontent = {
1103
+ displayprop: false,
1104
+ imagesrc: `<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" viewBox="0 0 56 56" fill="none"><rect x="4" y="4" width="48" height="48" rx="24" fill="#FEF0C7"/><path d="M27.9998 24.0012V28.0012M27.9998 32.0012H28.0098M26.2898 18.8612L17.8198 33.0012C17.6451 33.3036 17.5527 33.6465 17.5518 33.9957C17.5508 34.3449 17.6413 34.6883 17.8142 34.9917C17.9871 35.2951 18.2365 35.5479 18.5375 35.725C18.8385 35.9021 19.1806 35.9973 19.5298 36.0012H36.4698C36.819 35.9973 37.1611 35.9021 37.4621 35.725C37.7631 35.5479 38.0124 35.2951 38.1854 34.9917C38.3583 34.6883 38.4488 34.3449 38.4478 33.9957C38.4468 33.6465 38.3544 33.3036 38.1798 33.0012L29.7098 18.8612C29.5315 18.5673 29.2805 18.3243 28.981 18.1557C28.6814 17.987 28.3435 17.8984 27.9998 17.8984C27.656 17.8984 27.3181 17.987 27.0186 18.1557C26.7191 18.3243 26.468 18.5673 26.2898 18.8612Z" stroke="#DC6803" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><rect x="4" y="4" width="48" height="48" rx="24" stroke="#FFFAEB" stroke-width="8"/></svg>`,
1105
+ title: `Invalid details!`,
1106
+ content: `Please provide correct and complete store information.`,
1107
+ buttontype: "error",
1108
+ error: error,
1109
+ };
1110
+ this.afterUplload(popupcontent);
1111
+ return;
1112
+ } else {
1113
+ !ValidationError ? this.afterUplload() : "";
1114
+ }
1115
+ if (this.fileInput) {
1116
+ this.fileInput.nativeElement.value = "";
1117
+ }
1118
+ if (this.fileInput1) {
1119
+ this.fileInput1.nativeElement.value = "";
1120
+ }
1121
+ };
1122
+ } else {
1123
+ if (this.fileInput) {
1124
+ this.fileInput.nativeElement.value = "";
1125
+ }
1126
+ if (this.fileInput1) {
1127
+ this.fileInput1.nativeElement.value = "";
1128
+ }
1129
+ this.toast.getErrorToast("Please Upload a Excel file.");
1130
+ }
1131
+ }
1132
+
1133
+ validateUserDetails(del?: any) {
1134
+ let params = {
1135
+ id: this.checklistId,
1136
+ assignedUsers: this.userData,
1137
+ uploadUser: true,
1138
+ type:
1139
+ this.obj?.type &&
1140
+ ["mobileusagedetection", "storeopenandclose"].includes(this.obj.type)
1141
+ ? this.obj.type
1142
+ : "",
1143
+ ...(del ? { delete: false } : {}),
1144
+ clientId: this.clientId,
1145
+ };
1146
+ this.SopService.validateUser(params)
1147
+ .pipe(takeUntil(this.detach))
1148
+ .subscribe(
1149
+ (res: any) => {
1150
+ let validate: Boolean = true;
1151
+ if (res && res.code == 200) {
1152
+ this.dialog.dismissAll();
1153
+ this.configData.uploadUser = true;
1154
+ if (res?.data?.ExistsEmail?.length) {
1155
+ this.toast.getErrorToast(
1156
+ res?.data?.ExistsEmail.join(", ") + " " + res?.data?.message,
1157
+ );
1158
+ if (this.fileInput) {
1159
+ this.fileInput.nativeElement.value = "";
1160
+ }
1161
+ if (this.fileInput1) {
1162
+ this.fileInput1.nativeElement.value = "";
1163
+ }
1164
+ return;
1165
+ } else if (res?.data?.id) {
1166
+ this.configData.checkListDetails._id = res.data.id;
1167
+ this.checklistId = res.data.id;
1168
+ this.configData.checkListDetails.assignedUsers = [];
1169
+ this.configData.uploadUser = true;
1170
+ this.userDetails();
1171
+ this.changedetector.detectChanges();
1172
+ } else {
1173
+ if (res?.data?.domain.length) {
1174
+ let email = res?.data?.domain.map((item: any) => item.email);
1175
+ // +' '+'<a href="profile/domains">Add domain</a>'
1176
+ this.toast.getErrorToast(
1177
+ email.join(", ") + " " + "Domain is not Exists.",
1178
+ );
1179
+ return;
1180
+ } else if (res?.data?.user?.length && res?.data?.store?.length) {
1181
+ validate = false;
1182
+ let popupcontent;
1183
+ let store: any = [];
1184
+ let location: any = [];
1185
+ let inactiveStore: any = [];
1186
+ store = res.data.store.filter((item: any) => {
1187
+ return item.message == "";
1188
+ });
1189
+
1190
+ inactiveStore = res.data.store.filter((item: any) => {
1191
+ return item.message == "store is inactive";
1192
+ });
1193
+
1194
+ // location = res.data.store.filter((item: any) => {
1195
+ // return item.message != '' && item.message != 'store is inactive';
1196
+ // });
1197
+
1198
+ store = [...new Set(store.map((item: any) => item.store))];
1199
+ inactiveStore = [
1200
+ ...new Set(inactiveStore.map((item: any) => item.store)),
1201
+ ];
1202
+ location = [
1203
+ ...new Set(location.map((item: any) => item.store)),
1204
+ ];
1205
+ if (store.length) {
1206
+ let title = `New Store found in uploaded file`;
1207
+ if (inactiveStore.length) {
1208
+ title = `New Store and Inactive Store found in uploaded file`;
1209
+ }
1210
+ popupcontent = {
1211
+ displayprop: false,
1212
+ imagesrc: "",
1213
+ title: title,
1214
+ content: `This CSV contains a new store. Add new stores in the Store Management under Manage menu.`,
1215
+ buttontype: "Addstore",
1216
+ subtitle: store.join(", "),
1217
+ location: location.join(),
1218
+ inactiveStores: inactiveStore.join(),
1219
+ };
1220
+ } else if (inactiveStore.length) {
1221
+ popupcontent = {
1222
+ displayprop: false,
1223
+ imagesrc:
1224
+ '<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" viewBox="0 0 56 56" fill="none"><rect x="4" y="4" width="48" height="48" rx="24" fill="#FEF0C7"/><path d="M27.9998 24.0012V28.0012M27.9998 32.0012H28.0098M26.2898 18.8612L17.8198 33.0012C17.6451 33.3036 17.5527 33.6465 17.5518 33.9957C17.5508 34.3449 17.6413 34.6883 17.8142 34.9917C17.9871 35.2951 18.2365 35.5479 18.5375 35.725C18.8385 35.9021 19.1806 35.9973 19.5298 36.0012H36.4698C36.819 35.9973 37.1611 35.9021 37.4621 35.725C37.7631 35.5479 38.0124 35.2951 38.1854 34.9917C38.3583 34.6883 38.4488 34.3449 38.4478 33.9957C38.4468 33.6465 38.3544 33.3036 38.1798 33.0012L29.7098 18.8612C29.5315 18.5673 29.2805 18.3243 28.981 18.1557C28.6814 17.987 28.3435 17.8984 27.9998 17.8984C27.656 17.8984 27.3181 17.987 27.0186 18.1557C26.7191 18.3243 26.468 18.5673 26.2898 18.8612Z" stroke="#DC6803" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><rect x="4" y="4" width="48" height="48" rx="24" stroke="#FFFAEB" stroke-width="8"/></svg>',
1225
+ title: `Inactive Store found in uploaded file`,
1226
+ content: `Inactive stores found in the .csv. Please activate or skip them to proceed to assign.`,
1227
+ buttontype: "Activestore",
1228
+ subtitle: inactiveStore.join(", "),
1229
+ };
1230
+ } else {
1231
+ }
1232
+ if (popupcontent) {
1233
+ const dialogRef = this.dialog.open(TraxpopupComponent, {
1234
+ centered: true,
1235
+ size: "md",
1236
+ backdrop: "static",
1237
+ });
1238
+ dialogRef.componentInstance.data = popupcontent;
1239
+ dialogRef.result.then((result) => {
1240
+ if (result == "confirmStore") {
1241
+ this.route.navigateByUrl(`manage/stores/addition-method`);
1242
+ }
1243
+ if (result == "activeStore") {
1244
+ this.route.navigateByUrl(`manage/stores`);
1245
+ }
1246
+ validate = true;
1247
+ if (result == "skip") {
1248
+ let userDataCopy = [...this.userData];
1249
+ this.userData = [];
1250
+ userDataCopy.forEach((item: any) => {
1251
+ if (
1252
+ !store.includes(item.storeName) &&
1253
+ !inactiveStore.includes(item.storeName)
1254
+ ) {
1255
+ this.userData.push(item);
1256
+ }
1257
+ });
1258
+
1259
+ if (!this.userData.length) {
1260
+ this.toast.getErrorToast("Please Enter valid Details");
1261
+ if (this.fileInput) {
1262
+ this.fileInput.nativeElement.value = "";
1263
+ }
1264
+ if (this.fileInput1) {
1265
+ this.fileInput1.nativeElement.value = "";
1266
+ }
1267
+ return;
1268
+ }
1269
+ let userDetails = this.userData.map(
1270
+ (item: any) => item.userEmail,
1271
+ );
1272
+ let user = [...res.data.user];
1273
+ res.data.user = [];
1274
+ user.forEach((item: any) => {
1275
+ if (userDetails.includes(item.userEmail)) {
1276
+ res.data.user.push(item);
1277
+ }
1278
+ });
1279
+ if (res.data.user.length) {
1280
+ popupcontent = {
1281
+ displayprop: false,
1282
+ imagesrc:
1283
+ '<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" viewBox="0 0 56 56" fill="none"><rect x="4" y="4" width="48" height="48" rx="24" fill="#FEF0C7"/><path d="M27.9998 24.0012V28.0012M27.9998 32.0012H28.0098M26.2898 18.8612L17.8198 33.0012C17.6451 33.3036 17.5527 33.6465 17.5518 33.9957C17.5508 34.3449 17.6413 34.6883 17.8142 34.9917C17.9871 35.2951 18.2365 35.5479 18.5375 35.725C18.8385 35.9021 19.1806 35.9973 19.5298 36.0012H36.4698C36.819 35.9973 37.1611 35.9021 37.4621 35.725C37.7631 35.5479 38.0124 35.2951 38.1854 34.9917C38.3583 34.6883 38.4488 34.3449 38.4478 33.9957C38.4468 33.6465 38.3544 33.3036 38.1798 33.0012L29.7098 18.8612C29.5315 18.5673 29.2805 18.3243 28.981 18.1557C28.6814 17.987 28.3435 17.8984 27.9998 17.8984C27.656 17.8984 27.3181 17.987 27.0186 18.1557C26.7191 18.3243 26.468 18.5673 26.2898 18.8612Z" stroke="#DC6803" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><rect x="4" y="4" width="48" height="48" rx="24" stroke="#FFFAEB" stroke-width="8"/></svg>',
1284
+ title: `Invite new users added in CSV`,
1285
+ content: `This CSV contains new users. Invite users by sending mail to them`,
1286
+ buttontype: "Invite",
1287
+ user: res.data.user,
1288
+ };
1289
+ const dialogRef = this.dialog.open(TraxpopupComponent, {
1290
+ centered: true,
1291
+ size: "md",
1292
+ backdrop: "static",
1293
+ });
1294
+ dialogRef.componentInstance.data = popupcontent;
1295
+ dialogRef.result.then((result) => {
1296
+ if (
1297
+ result?.message == "confirm" ||
1298
+ result == "skip"
1299
+ ) {
1300
+ if (result == "skip") {
1301
+ userDataCopy = [...this.userData];
1302
+ this.userData = [];
1303
+ userDataCopy.forEach((item: any) => {
1304
+ if (!userDetails.includes(item.userEmail)) {
1305
+ this.userData.push(item);
1306
+ }
1307
+ });
1308
+ } else {
1309
+ result?.user.forEach((item: any) => {
1310
+ let index = this.userData.findIndex(
1311
+ (user: any) => {
1312
+ return user.userEmail == item.userEmail;
1313
+ },
1314
+ );
1315
+ if (!item.invite) {
1316
+ this.userData.splice(index, 1);
1317
+ }
1318
+ });
1319
+ for (let item of res.data.user) {
1320
+ if (item?.message) {
1321
+ this.toast.getErrorToast(
1322
+ `${item.userEmail} - ${item.message}`,
1323
+ );
1324
+ if (this.fileInput) {
1325
+ this.fileInput.nativeElement.value = "";
1326
+ }
1327
+ if (this.fileInput1) {
1328
+ this.fileInput1.nativeElement.value = "";
1329
+ }
1330
+ validate = false;
1331
+ return;
1332
+ }
1333
+ }
1334
+ }
1335
+ if (!this.userData.length) {
1336
+ this.toast.getErrorToast(
1337
+ `Please Enter valid Details`,
1338
+ );
1339
+ if (this.fileInput) {
1340
+ this.fileInput.nativeElement.value = "";
1341
+ }
1342
+ if (this.fileInput1) {
1343
+ this.fileInput1.nativeElement.value = "";
1344
+ }
1345
+ return;
1346
+ }
1347
+ if (validate) {
1348
+ this.configData.uploadUser = true;
1349
+ this.uploadUser(del);
1350
+ }
1351
+ }
1352
+ });
1353
+ } else {
1354
+ this.configData.uploadUser = true;
1355
+ this.uploadUser(del);
1356
+ }
1357
+ }
1358
+ });
1359
+ }
1360
+ } else if (res?.data?.user?.length || res?.data?.store?.length) {
1361
+ validate = false;
1362
+ let popupcontent;
1363
+ let store: any = [];
1364
+ let location: any = [];
1365
+ let inactiveStore: any = [];
1366
+ if (res?.data?.user?.length) {
1367
+ popupcontent = {
1368
+ displayprop: false,
1369
+ imagesrc:
1370
+ '<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" viewBox="0 0 56 56" fill="none"><rect x="4" y="4" width="48" height="48" rx="24" fill="#FEF0C7"/><path d="M27.9998 24.0012V28.0012M27.9998 32.0012H28.0098M26.2898 18.8612L17.8198 33.0012C17.6451 33.3036 17.5527 33.6465 17.5518 33.9957C17.5508 34.3449 17.6413 34.6883 17.8142 34.9917C17.9871 35.2951 18.2365 35.5479 18.5375 35.725C18.8385 35.9021 19.1806 35.9973 19.5298 36.0012H36.4698C36.819 35.9973 37.1611 35.9021 37.4621 35.725C37.7631 35.5479 38.0124 35.2951 38.1854 34.9917C38.3583 34.6883 38.4488 34.3449 38.4478 33.9957C38.4468 33.6465 38.3544 33.3036 38.1798 33.0012L29.7098 18.8612C29.5315 18.5673 29.2805 18.3243 28.981 18.1557C28.6814 17.987 28.3435 17.8984 27.9998 17.8984C27.656 17.8984 27.3181 17.987 27.0186 18.1557C26.7191 18.3243 26.468 18.5673 26.2898 18.8612Z" stroke="#DC6803" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><rect x="4" y="4" width="48" height="48" rx="24" stroke="#FFFAEB" stroke-width="8"/></svg>',
1371
+ title: `Invite new users added in CSV`,
1372
+ content: `This CSV contains new users. Invite users by sending mail to them`,
1373
+ buttontype: "Invite",
1374
+ user: res.data.user,
1375
+ };
1376
+ } else {
1377
+ store = res.data.store.filter((item: any) => {
1378
+ return item.message == "";
1379
+ });
1380
+
1381
+ inactiveStore = res.data.store.filter((item: any) => {
1382
+ return item.message == "store is inactive";
1383
+ });
1384
+
1385
+ // location = res.data.store.filter((item: any) => {
1386
+ // return item.message != '';
1387
+ // });
1388
+
1389
+ store = [...new Set(store.map((item: any) => item.store))];
1390
+ inactiveStore = [
1391
+ ...new Set(inactiveStore.map((item: any) => item.store)),
1392
+ ];
1393
+ location = [
1394
+ ...new Set(location.map((item: any) => item.store)),
1395
+ ];
1396
+ if (store.length) {
1397
+ let title = `New Store found in uploaded file`;
1398
+ if (inactiveStore.length) {
1399
+ title = `New Store and Inactive Store found in uploaded file`;
1400
+ }
1401
+ popupcontent = {
1402
+ displayprop: false,
1403
+ imagesrc:
1404
+ '<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" viewBox="0 0 56 56" fill="none"><rect x="4" y="4" width="48" height="48" rx="24" fill="#FEF0C7"/><path d="M27.9998 24.0012V28.0012M27.9998 32.0012H28.0098M26.2898 18.8612L17.8198 33.0012C17.6451 33.3036 17.5527 33.6465 17.5518 33.9957C17.5508 34.3449 17.6413 34.6883 17.8142 34.9917C17.9871 35.2951 18.2365 35.5479 18.5375 35.725C18.8385 35.9021 19.1806 35.9973 19.5298 36.0012H36.4698C36.819 35.9973 37.1611 35.9021 37.4621 35.725C37.7631 35.5479 38.0124 35.2951 38.1854 34.9917C38.3583 34.6883 38.4488 34.3449 38.4478 33.9957C38.4468 33.6465 38.3544 33.3036 38.1798 33.0012L29.7098 18.8612C29.5315 18.5673 29.2805 18.3243 28.981 18.1557C28.6814 17.987 28.3435 17.8984 27.9998 17.8984C27.656 17.8984 27.3181 17.987 27.0186 18.1557C26.7191 18.3243 26.468 18.5673 26.2898 18.8612Z" stroke="#DC6803" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><rect x="4" y="4" width="48" height="48" rx="24" stroke="#FFFAEB" stroke-width="8"/></svg>',
1405
+ title: title,
1406
+ content: `This CSV contains a new store. Add new stores in the Store Management under Manage menu.`,
1407
+ buttontype: "Addstore",
1408
+ subtitle: store.join(", "),
1409
+ location: location.join(),
1410
+ inactiveStores: inactiveStore.join(),
1411
+ };
1412
+ } else if (inactiveStore.length) {
1413
+ popupcontent = {
1414
+ displayprop: false,
1415
+ imagesrc:
1416
+ '<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" viewBox="0 0 56 56" fill="none"><rect x="4" y="4" width="48" height="48" rx="24" fill="#FEF0C7"/><path d="M27.9998 24.0012V28.0012M27.9998 32.0012H28.0098M26.2898 18.8612L17.8198 33.0012C17.6451 33.3036 17.5527 33.6465 17.5518 33.9957C17.5508 34.3449 17.6413 34.6883 17.8142 34.9917C17.9871 35.2951 18.2365 35.5479 18.5375 35.725C18.8385 35.9021 19.1806 35.9973 19.5298 36.0012H36.4698C36.819 35.9973 37.1611 35.9021 37.4621 35.725C37.7631 35.5479 38.0124 35.2951 38.1854 34.9917C38.3583 34.6883 38.4488 34.3449 38.4478 33.9957C38.4468 33.6465 38.3544 33.3036 38.1798 33.0012L29.7098 18.8612C29.5315 18.5673 29.2805 18.3243 28.981 18.1557C28.6814 17.987 28.3435 17.8984 27.9998 17.8984C27.656 17.8984 27.3181 17.987 27.0186 18.1557C26.7191 18.3243 26.468 18.5673 26.2898 18.8612Z" stroke="#DC6803" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><rect x="4" y="4" width="48" height="48" rx="24" stroke="#FFFAEB" stroke-width="8"/></svg>',
1417
+ title: `Inactive Store found in uploaded file`,
1418
+ content: `Inactive stores found in the .csv. Please activate or skip them to proceed to assign.`,
1419
+ buttontype: "Activestore",
1420
+ subtitle: inactiveStore.join(", "),
1421
+ };
1422
+ } else {
1423
+ if (location.length) {
1424
+ let userDataCopy = [...this.userData];
1425
+ let store_id: any = [];
1426
+ location.forEach((item: any) => {
1427
+ let details = userDataCopy.find(
1428
+ (store: any) => item == store.storeName,
1429
+ );
1430
+ if (details.city == undefined || details.city == "") {
1431
+ store_id.push(item);
1432
+ }
1433
+ });
1434
+ if (store_id.length) {
1435
+ this.toast.getErrorToast(
1436
+ `City is required on this stores ${store_id.join()}`,
1437
+ );
1438
+ if (this.fileInput) {
1439
+ this.fileInput.nativeElement.value = "";
1440
+ }
1441
+ if (this.fileInput1) {
1442
+ this.fileInput1.nativeElement.value = "";
1443
+ }
1444
+ return;
1445
+ } else {
1446
+ this.configData.uploadUser = true;
1447
+ this.uploadUser(del);
1448
+ }
1449
+ }
1450
+ }
1451
+ }
1452
+ if (popupcontent) {
1453
+ const dialogRef = this.dialog.open(TraxpopupComponent, {
1454
+ centered: true,
1455
+ size: "md",
1456
+ backdrop: "static",
1457
+ });
1458
+ dialogRef.componentInstance.data = popupcontent;
1459
+ dialogRef.result.then((result) => {
1460
+ if (result == "confirmStore") {
1461
+ this.route.navigateByUrl(`manage/stores/addition-method`);
1462
+ }
1463
+ if (result == "activeStore") {
1464
+ this.route.navigateByUrl(`manage/stores`);
1465
+ }
1466
+ if (result?.message == "confirm" || result == "skip") {
1467
+ validate = true;
1468
+ if (result == "skip") {
1469
+ let userDataCopy = [...this.userData];
1470
+ this.userData = [];
1471
+ if (res?.data?.user?.length) {
1472
+ let userDetails = res.data.user.map(
1473
+ (item: any) => item.userEmail,
1474
+ );
1475
+ userDataCopy.forEach((item: any) => {
1476
+ if (!userDetails.includes(item.userEmail)) {
1477
+ this.userData.push(item);
1478
+ }
1479
+ });
1480
+ }
1481
+
1482
+ if (location.length) {
1483
+ let store_id: any = [];
1484
+ location.forEach((item: any) => {
1485
+ let details = userDataCopy.find(
1486
+ (store: any) => item == store.storeName,
1487
+ );
1488
+ if (
1489
+ details.city == undefined ||
1490
+ details.city == ""
1491
+ ) {
1492
+ store_id.push(item);
1493
+ }
1494
+ });
1495
+ if (store_id.length) {
1496
+ this.toast.getErrorToast(
1497
+ `City is required on this stores ${store_id.join()}`,
1498
+ );
1499
+ if (this.fileInput) {
1500
+ this.fileInput.nativeElement.value = "";
1501
+ }
1502
+ if (this.fileInput1) {
1503
+ this.fileInput1.nativeElement.value = "";
1504
+ }
1505
+ return;
1506
+ }
1507
+ }
1508
+
1509
+ if (res?.data?.store?.length) {
1510
+ userDataCopy.forEach((item: any) => {
1511
+ if (
1512
+ !store.includes(item.storeName) &&
1513
+ !inactiveStore.includes(item.storeName)
1514
+ ) {
1515
+ this.userData.push(item);
1516
+ }
1517
+ });
1518
+ }
1519
+ } else {
1520
+ result?.user.forEach((item: any) => {
1521
+ let index = this.userData.findIndex((user: any) => {
1522
+ return user.userEmail == item.userEmail;
1523
+ });
1524
+ if (!item.invite) {
1525
+ this.userData.splice(index, 1);
1526
+ }
1527
+ });
1528
+ for (let item of res.data.user) {
1529
+ if (item?.message) {
1530
+ this.toast.getErrorToast(
1531
+ `${item.userEmail} - ${item.message}`,
1532
+ );
1533
+ if (this.fileInput) {
1534
+ this.fileInput.nativeElement.value = "";
1535
+ }
1536
+ if (this.fileInput1) {
1537
+ this.fileInput1.nativeElement.value = "";
1538
+ }
1539
+ validate = false;
1540
+ return;
1541
+ }
1542
+ }
1543
+ }
1544
+ if (validate) {
1545
+ if (!this.userData.length) {
1546
+ this.toast.getErrorToast(
1547
+ "Please Enter valid Details",
1548
+ );
1549
+ if (this.fileInput) {
1550
+ this.fileInput.nativeElement.value = "";
1551
+ }
1552
+ if (this.fileInput1) {
1553
+ this.fileInput1.nativeElement.value = "";
1554
+ }
1555
+ return;
1556
+ }
1557
+ this.configData.uploadUser = true;
1558
+ this.uploadUser(del);
1559
+ }
1560
+ }
1561
+ });
1562
+ }
1563
+ } else {
1564
+ this.configData.uploadUser = true;
1565
+ if (this.fileInput) {
1566
+ this.fileInput.nativeElement.value = "";
1567
+ }
1568
+ if (this.fileInput1) {
1569
+ this.fileInput1.nativeElement.value = "";
1570
+ }
1571
+ this.uploadUser(del);
1572
+ }
1573
+ }
1574
+ }
1575
+ },
1576
+ (error) => {
1577
+ if (this.fileInput) {
1578
+ this.fileInput.nativeElement.value = "";
1579
+ }
1580
+ if (this.fileInput1) {
1581
+ this.fileInput1.nativeElement.value = "";
1582
+ }
1583
+ this.toast.getErrorToast(error.error.error);
1584
+ },
1585
+ );
1586
+ }
1587
+
1588
+ validatedStore: any = [];
1589
+ validatedUser: any = [];
1590
+ validatedCluster: any = [];
1591
+ validatedTeam: any = [];
1592
+ newUser: any = [];
1593
+ inactiveStores: any = [];
1594
+ showInactive: any = false;
1595
+
1596
+ validateDetails(addUser?: any) {
1597
+ let params: any = {
1598
+ checklistId: this.checklistId,
1599
+ assignedUsers: this.userData,
1600
+ clientId: this.clientId,
1601
+ coverage: this.coverage,
1602
+ };
1603
+ addUser ? (params.addUser = true) : "";
1604
+ this.SopService.validateUserv1(params)
1605
+ .pipe(takeUntil(this.detach))
1606
+ .subscribe({
1607
+ next: (res: any) => {
1608
+ if (res && res?.code == 200) {
1609
+ if (this.upload === "store") {
1610
+ this.tableArray.unshift(...res?.data?.data);
1611
+ this.configData.checkListDetails.assign = this.tableArray;
1612
+ let data = this.tableArray.map((el: any) => {
1613
+ return { id: el?._id, type: el?.type };
1614
+ });
1615
+ this.idList = data;
1616
+ this.singleAssign = this.idList;
1617
+ this.assignType === "user"
1618
+ ? this.getassignDropdown("change")
1619
+ : "";
1620
+ this.getTableData();
1621
+ } else {
1622
+ this.tableArray = [];
1623
+ this.tableLoading = true;
1624
+ this.tableArray = res?.data?.data;
1625
+ this.assignSingle = res?.data?.data;
1626
+ this.configData.checkListDetails.assign = this.tableArray;
1627
+ let data = res?.data?.data.map((el: any) => {
1628
+ return { id: el?._id, type: el?.type };
1629
+ });
1630
+ this.idList = data;
1631
+ this.singleAssign = this.idList;
1632
+ this.tableLoading = false;
1633
+ this.assignType === "user"
1634
+ ? this.getassignDropdown("change")
1635
+ : "";
1636
+ this.getTableData();
1637
+ }
1638
+ this.dialog.dismissAll();
1639
+ }
1640
+ },
1641
+ error: (err: any) => {
1642
+ if (err?.error?.error && err?.error?.code == 400) {
1643
+ let errorData = err?.error?.error;
1644
+ this.excelData = errorData?.data;
1645
+ this.userData = errorData?.data;
1646
+ if (errorData.existEmail?.length) {
1647
+ this.toast.getErrorToast(
1648
+ `Already ${errorData.existEmail.toString()} assigned to another client`,
1649
+ );
1650
+ } else if (
1651
+ errorData.store?.length &&
1652
+ !errorData.existEmail?.length
1653
+ ) {
1654
+ this.validatedStore = errorData?.store;
1655
+ this.showStore = true;
1656
+ this.afterUplload();
1657
+ } else if (
1658
+ errorData.store?.length &&
1659
+ errorData.existEmail?.length
1660
+ ) {
1661
+ !errorData?.inActiveStores?.length
1662
+ ? this.dialog.dismissAll()
1663
+ : "";
1664
+ this.toast.getErrorToast(
1665
+ `Already ${errorData.store.toString()} assigned to another client`,
1666
+ );
1667
+ } else if (errorData?.inActiveStores?.length) {
1668
+ this.inactiveStores = errorData?.inActiveStores;
1669
+ this.showInactive = true;
1670
+ this.afterUplload();
1671
+ } else if (
1672
+ errorData?.user?.length &&
1673
+ !errorData?.existEmail?.length
1674
+ ) {
1675
+ this.validatedUser = errorData.user;
1676
+ this.showUser = true;
1677
+ if (this.upload === "store") {
1678
+ this.confirmUserpopup();
1679
+ } else {
1680
+ this.afterUplload();
1681
+ }
1682
+ } else if (
1683
+ errorData?.user?.length &&
1684
+ errorData?.existEmail?.length
1685
+ ) {
1686
+ this.dialog.dismissAll();
1687
+ this.toast.getErrorToast(
1688
+ `Already ${errorData?.user.toString()} assigned to another client`,
1689
+ );
1690
+ }
1691
+ if (errorData?.duplicates?.length) {
1692
+ this.dialog.dismissAll();
1693
+ this.toast.getErrorToast(
1694
+ `${errorData?.duplicates?.toString()} - ${errorData?.message}`,
1695
+ );
1696
+ }
1697
+ }
1698
+ },
1699
+ });
1700
+ }
1701
+
1702
+ checkBuffer: any;
1703
+ changeBufferTime(event: any) {
1704
+ this.checkBuffer = event.target.checked;
1705
+ if (this.checkBuffer) {
1706
+ this.configData.aiConfig.storeOpenClose.buffer.openTime = 1;
1707
+ this.configData.aiConfig.storeOpenClose.buffer.closeTime = 1;
1708
+ } else {
1709
+ this.configData.aiConfig.storeOpenClose.buffer.openTime = 0;
1710
+ this.configData.aiConfig.storeOpenClose.buffer.closeTime = 0;
1711
+ }
1712
+ }
1713
+
1714
+ selectedTab(value: any) {
1715
+ this.tableArray = [];
1716
+ this.tableLoading = true;
1717
+ this.tableLoading1 = true;
1718
+ this.tableData = [];
1719
+ this.assignType = value;
1720
+ this.currentValue = 1;
1721
+ this.size = 5;
1722
+ this.tableFilter = "";
1723
+ this.configData.checkListDetails.assign = [];
1724
+ this.getassignDropdown();
1725
+ }
1726
+
1727
+ closeactivepopup() {
1728
+ this.dialog.dismissAll();
1729
+ }
1730
+
1731
+ uploadUser(del?: any) {
1732
+ let data = {
1733
+ id: this.checklistId,
1734
+ assignedUsers: this.userData,
1735
+ uploadUser: true,
1736
+ addUser: true,
1737
+ type:
1738
+ this.obj?.type &&
1739
+ ["mobileusagedetection", "storeopenandclose"].includes(this.obj.type)
1740
+ ? this.obj.type
1741
+ : "",
1742
+ ...(del ? { delete: false } : {}),
1743
+ clientId: this.clientId,
1744
+ };
1745
+ this.SopService.validateUser(data)
1746
+ .pipe(takeUntil(this.detach))
1747
+ .subscribe((response: any) => {
1748
+ if (response && response.code == 200) {
1749
+ this.configData.checkListDetails._id = response.data.id;
1750
+ this.checklistId = response.data.id;
1751
+ this.configData.checkListDetails.assignedUsers = [];
1752
+ this.userDetails();
1753
+ this.changedetector.detectChanges();
1754
+ }
1755
+ });
1756
+ }
1757
+
1758
+ storeList: any = [];
1759
+ searchKey: any = [];
1760
+
1761
+ getassignDropdown(change?: any) {
1762
+ let data = {
1763
+ clientId: this.clientId,
1764
+ coverage: this.coverage,
1765
+ assignType: this.assignType,
1766
+ };
1767
+
1768
+ this.storeList = [];
1769
+ this.SopService.getassignDropdown(data)
1770
+ .pipe(takeUntil(this.detach))
1771
+ .subscribe((res: any) => {
1772
+ if (res && res.code == 200 && res.data.data.length) {
1773
+ this.storeList = res?.data?.data;
1774
+ if (data?.coverage === "store") {
1775
+ this.searchKey = ["storeName", "clusterName"];
1776
+ } else if (data?.coverage === "user") {
1777
+ this.searchKey = ["userName", "teamName"];
1778
+ }
1779
+
1780
+ !change
1781
+ ? this.getInitialData(
1782
+ this.assignType === "store" || this.assignType === "user"
1783
+ ? this.singleAssign
1784
+ : this.groupAssign,
1785
+ change ? change : "",
1786
+ )
1787
+ : "";
1788
+ this.changedetector.detectChanges();
1789
+ } else {
1790
+ this.storeList = [];
1791
+ this.tableArray = [];
1792
+ this.tableData = [];
1793
+ this.tableLoading1 = false;
1794
+ this.tableLoading = false;
1795
+ }
1796
+ });
1797
+ }
1798
+
1799
+ getStoreCounts(data: any) {
1800
+ console.log(
1801
+ "🚀 ~ ChecklistConfigureComponent ~ getStoreCounts ~ data:",
1802
+ data,
1803
+ );
1804
+ if (this.storeCoverage) {
1805
+ const uniqueStoreNames = new Set(
1806
+ data?.map((item: any) => item.storeName),
1807
+ );
1808
+ return uniqueStoreNames.size;
1809
+ } else if (this.userCoverage) {
1810
+ const uniqueUserNames = new Set(data?.map((item: any) => item.userName));
1811
+ return uniqueUserNames.size;
1812
+ }
1813
+ }
1814
+
1815
+ userDetails() {
1816
+ this.size = 5;
1817
+ this.tableLoading = true;
1818
+ let params = {
1819
+ id: this.checklistId,
1820
+ clientId: this.clientId,
1821
+ };
1822
+ this.SopService.getUserDetailsV1(params)
1823
+ .pipe(takeUntil(this.detach))
1824
+ .subscribe((res: any) => {
1825
+ this.tableLoading = false;
1826
+ let count = 0;
1827
+ if (res == null) {
1828
+ this.disableBtn = false;
1829
+ this.showImage = true;
1830
+ if (this.tableFilter.length) this.showImage = false;
1831
+ this.tableLoading1 = false;
1832
+ this.tableArray = [];
1833
+ this.tableData = [];
1834
+ }
1835
+ if (res && res.code == 200) {
1836
+ this.disableBtn = false;
1837
+ this.showImage = false;
1838
+ this.tableLoading = false;
1839
+ this.tableLoading1 = false;
1840
+ if (this.storeCoverage) {
1841
+ this.tableArray = res.data.userDetails.filter(
1842
+ (el: any) => el?.clusterName == "" && el?.storeId != "",
1843
+ );
1844
+ this.assignGroup = res.data.userDetails.filter(
1845
+ (el: any) => el?.clusterName !== "",
1846
+ );
1847
+ } else if (this.userCoverage) {
1848
+ this.tableArray = res.data.userDetails.filter(
1849
+ (el: any) => el?.teamName == "" && el?.userName != "",
1850
+ );
1851
+ this.assignGroup = res.data.userDetails.filter(
1852
+ (el: any) => el?.teamName !== "",
1853
+ );
1854
+ }
1855
+ this.assignSingle = this.tableArray;
1856
+ this.recordsTotal = this.tableArray.length;
1857
+ // this.recordsTotal = res.data.count;
1858
+ if (this.recordsTotal < 5) {
1859
+ this.paginationSize = [this.recordsTotal];
1860
+ this.size = this.recordsTotal;
1861
+ } else {
1862
+ this.paginationSize = [5, 10, 15, 20];
1863
+ this.size = 5;
1864
+ }
1865
+ this.tableData = this.tableArray.slice(
1866
+ this.currentValue * this.size - this.size,
1867
+ this.currentValue * this.size,
1868
+ );
1869
+ this.tableData
1870
+ ? (this.tableLoading = false)
1871
+ : (this.tableLoading = true);
1872
+
1873
+ // this.getInitialData();
1874
+ }
1875
+ });
1876
+ }
1877
+
1878
+ downloadTemplateV2() {
1879
+ let excelData: any = [];
1880
+ if (this.storeCoverage) {
1881
+ if (this.tableArray == null || !this.tableArray?.length) {
1882
+ if (this.assignType === "store") {
1883
+ excelData.push({
1884
+ storeName: "",
1885
+ userName: "",
1886
+ userEmail: "",
1887
+ userPhone: "",
1888
+ city: "",
1889
+ });
1890
+ } else {
1891
+ excelData.push({
1892
+ storeName: "",
1893
+ userName: "",
1894
+ userEmail: "",
1895
+ clusterName: "",
1896
+ userPhone: "",
1897
+ city: "",
1898
+ });
1899
+ }
1900
+ }
1901
+ if (this.tableArray && this.tableArray?.length) {
1902
+ this.tableArray.forEach((item: any) => {
1903
+ if (this.assignType === "store") {
1904
+ excelData.push({
1905
+ storeName: item.storeName,
1906
+ userName: item.userName,
1907
+ userEmail: item.userEmail,
1908
+ userPhone: item.userPhone,
1909
+ city: item.city,
1910
+ });
1911
+ } else {
1912
+ excelData.push({
1913
+ storeName: item.storeName,
1914
+ userName: item.userName,
1915
+ userEmail: item.userEmail,
1916
+ clusterName: item.clusterName,
1917
+ userPhone: item.userPhone,
1918
+ city: item.city,
1919
+ });
1920
+ }
1921
+ });
1922
+ }
1923
+ } else if (this.userCoverage) {
1924
+ if (this.tableArray == null || !this.tableArray?.length) {
1925
+ if (this.assignType === "user") {
1926
+ excelData.push({
1927
+ userName: "",
1928
+ userEmail: "",
1929
+ userPhone: "",
1930
+ });
1931
+ } else {
1932
+ excelData.push({
1933
+ userName: "",
1934
+ userEmail: "",
1935
+ teamName: "",
1936
+ userPhone: "",
1937
+ });
1938
+ }
1939
+ }
1940
+ if (this.tableArray && this.tableArray?.length) {
1941
+ this.tableArray.forEach((item: any) => {
1942
+ if (this.assignType === "user") {
1943
+ excelData.push({
1944
+ userName: item.userName,
1945
+ userEmail: item.userEmail,
1946
+ userPhone: item.userPhone,
1947
+ });
1948
+ } else {
1949
+ excelData.push({
1950
+ userName: item.userName,
1951
+ userEmail: item.userEmail,
1952
+ teamName: item.teamName,
1953
+ userPhone: item.userPhone,
1954
+ });
1955
+ }
1956
+ });
1957
+ }
1958
+ }
1959
+ this.SopService.exportAsExcelFile(
1960
+ excelData,
1961
+ `CheckList_${this.assignType}_`,
1962
+ );
1963
+ }
1964
+
1965
+ emailDownloadTemplate() {
1966
+ let excelData: any = [];
1967
+ let users = this.configData.aiConfig.alertConfig.alertSendTo.email?.users || [];
1968
+ let teams = this.configData.aiConfig.alertConfig.alertSendTo.email?.teams || [];
1969
+ let maxLength = Math.max(users.length, teams.length);
1970
+ if (users.length || teams.length) {
1971
+ for (let i = 0; i < maxLength; i++) {
1972
+ excelData.push({
1973
+ Users: users[i]?.value || '',
1974
+ Teams: teams[i]?.name || '',
1975
+ });
1976
+ }
1977
+ } else {
1978
+ excelData.push({
1979
+ Users: '',
1980
+ Teams: '',
1981
+ });
1982
+ }
1983
+ this.SopService.exportAsExcelFile(excelData, 'emailTemplate');
1984
+ }
1985
+
1986
+ validateExcelTemplate(event: any) {
1987
+ const target: DataTransfer = <DataTransfer>event.target;
1988
+ const file = target.files[0];
1989
+ if (!file) return;
1990
+
1991
+ // 1. Check if file is xlsx
1992
+ if (!file.name.match(/\.xlsx$/)) {
1993
+ this.toast.getErrorToast("Please upload a valid .xlsx file.");
1994
+ event.target.value = '';
1995
+ return;
1996
+ }
1997
+
1998
+ const reader: FileReader = new FileReader();
1999
+ reader.readAsBinaryString(file);
2000
+ reader.onload = (e: any) => {
2001
+ const bstr: string = e.target.result;
2002
+ const wb: XLSX.WorkBook = XLSX.read(bstr, { type: "binary" });
2003
+ const wsname: string = wb.SheetNames[0];
2004
+ const ws: XLSX.WorkSheet = wb.Sheets[wsname];
2005
+ const data: any[] = XLSX.utils.sheet_to_json(ws);
2006
+
2007
+ if (!data.length) {
2008
+ this.toast.getErrorToast("Uploaded file is empty.");
2009
+ event.target.value = '';
2010
+ return;
2011
+ }
2012
+
2013
+ // Trim trailing spaces and filter null/empty rows
2014
+ let hasUsers = false;
2015
+ let hasTeams = false;
2016
+ const trimmedData = data.filter((row: any) => {
2017
+ let userVal = row.Users != null ? String(row.Users).trim() : '';
2018
+ let teamVal = row.Teams != null ? String(row.Teams).trim() : '';
2019
+ if (userVal) hasUsers = true;
2020
+ if (teamVal) hasTeams = true;
2021
+ return userVal || teamVal;
2022
+ });
2023
+
2024
+ // 2. Both users and teams empty — at least one is required
2025
+ if (!hasUsers && !hasTeams) {
2026
+ this.toast.getErrorToast("At least one of Users or Teams is required.");
2027
+ event.target.value = '';
2028
+ return;
2029
+ }
2030
+
2031
+ // Match uploaded users with alertUsers by email (value)
2032
+ let matchedUsers: any[] = [];
2033
+ if (hasUsers) {
2034
+ trimmedData.forEach((row: any) => {
2035
+ let userEmail = row.Users != null ? String(row.Users).trim() : '';
2036
+ if (userEmail) {
2037
+ let found = this.alertUsers.find((u: any) => u.value?.toLowerCase() === userEmail.toLowerCase());
2038
+ if (found && !matchedUsers.some((u: any) => u.value?.toLowerCase() === found.value?.toLowerCase())) {
2039
+ matchedUsers.push(found);
2040
+ }
2041
+ }
2042
+ });
2043
+ }
2044
+
2045
+ // Match uploaded teams with alertTeams by team name (name)
2046
+ let matchedTeams: any[] = [];
2047
+ if (hasTeams) {
2048
+ trimmedData.forEach((row: any) => {
2049
+ let teamName = row.Teams != null ? String(row.Teams).trim() : '';
2050
+ if (teamName) {
2051
+ let found = this.alertTeams.find((t: any) => t.name?.toLowerCase() === teamName.toLowerCase());
2052
+ if (found && !matchedTeams.some((t: any) => t.name?.toLowerCase() === found.name?.toLowerCase())) {
2053
+ matchedTeams.push(found);
2054
+ }
2055
+ }
2056
+ });
2057
+ }
2058
+
2059
+ if (!matchedUsers.length && !matchedTeams.length) {
2060
+ return this.toast.getErrorToast("Excel data is not matching with existing data");
2061
+ }
2062
+
2063
+ // Update type array based on which columns had data
2064
+ let typeArr: string[] = this.configData.aiConfig.alertConfig.alertSendTo.email?.type || [];
2065
+ if (hasUsers && !typeArr.includes('user')) {
2066
+ typeArr.push('user');
2067
+ }
2068
+ if (hasTeams && !typeArr.includes('teams')) {
2069
+ typeArr.push('teams');
2070
+ }
2071
+ this.configData.aiConfig.alertConfig.alertSendTo.email.type = typeArr;
2072
+
2073
+ this.configData.aiConfig.alertConfig.alertSendTo.email.users = matchedUsers;
2074
+ this.configData.aiConfig.alertConfig.alertSendTo.email.teams = matchedTeams;
2075
+ event.target.value = '';
2076
+ this.changedetector.detectChanges();
2077
+ this.dialog.dismissAll();
2078
+ this.toast.getSuccessToast("File uploaded Successfully");
2079
+ };
2080
+ }
2081
+
2082
+ onPageChange(event: any) {
2083
+ this.tableData = [];
2084
+ this.tableLoading = true;
2085
+ this.currentValue = event;
2086
+
2087
+ if (this.tableFilter) {
2088
+ // this.searchTableData();
2089
+ this.recordsTotal = this.searchTable.length;
2090
+ if (this.recordsTotal < 5) {
2091
+ this.paginationSize = [this.recordsTotal];
2092
+ this.size = this.recordsTotal;
2093
+ } else {
2094
+ this.paginationSize = [5, 10, 15, 20];
2095
+ this.size = 5;
2096
+ }
2097
+ this.tableData = this.searchTable.slice(
2098
+ this.currentValue * this.size - this.size,
2099
+ this.currentValue * this.size,
2100
+ );
2101
+ this.tableData ? (this.tableLoading = false) : (this.tableLoading = true);
2102
+ } else {
2103
+ this.tableData = this.tableArray.slice(
2104
+ this.currentValue * this.size - this.size,
2105
+ this.currentValue * this.size,
2106
+ );
2107
+ this.tableData ? (this.tableLoading = false) : (this.tableLoading = true);
2108
+ }
2109
+ this.changedetector.detectChanges();
2110
+ }
2111
+
2112
+ onPageSizeChange(event: any) {
2113
+ this.size = event;
2114
+ this.tableLoading = true;
2115
+ this.tableData = [];
2116
+ this.currentValue = 1;
2117
+
2118
+ if (this.tableFilter) {
2119
+ this.recordsTotal = this.searchTable.length;
2120
+ if (this.recordsTotal < 5) {
2121
+ this.paginationSize = [this.recordsTotal];
2122
+ this.size = this.recordsTotal;
2123
+ } else {
2124
+ this.paginationSize = [5, 10, 15, 20];
2125
+ }
2126
+ this.tableData = this.searchTable.slice(
2127
+ this.currentValue * this.size - this.size,
2128
+ this.currentValue * this.size,
2129
+ );
2130
+ this.tableData ? (this.tableLoading = false) : (this.tableLoading = true);
2131
+ } else {
2132
+ this.tableData = this.tableArray.slice(
2133
+ this.currentValue * this.size - this.size,
2134
+ this.currentValue * this.size,
2135
+ );
2136
+ this.tableData ? (this.tableLoading = false) : (this.tableLoading = true);
2137
+ }
2138
+ }
2139
+
2140
+ dropDown: boolean = false;
2141
+ openDropdown(event: any) {
2142
+ this.dropDown = !this.dropDown;
2143
+ }
2144
+
2145
+ openEmailDropdown() {
2146
+ this.emailDropdown = !this.emailDropdown;
2147
+ }
2148
+
2149
+ searchTable: any;
2150
+ searchTableData() {
2151
+ this.tableData = [];
2152
+ this.size = 5;
2153
+ this.currentValue = 1;
2154
+ this.tableLoading = true;
2155
+ let searchField: any = [
2156
+ "storeName",
2157
+ "userName",
2158
+ "userEmail",
2159
+ "clusterName",
2160
+ "teamName",
2161
+ ];
2162
+
2163
+ if (!this.tableFilter) {
2164
+ this.assignType === "store" || this.assignType === "user"
2165
+ ? this.getTableData()
2166
+ : this.userDetailsV2();
2167
+ } else {
2168
+ const searchData = this.tableFilter.toLowerCase();
2169
+ const searchTerm = searchData.split(",").map((el: any) => el.trim());
2170
+ this.searchTable = this.tableArray?.filter((item: any) =>
2171
+ searchField.some((field: any) =>
2172
+ searchTerm.some((term: any) =>
2173
+ item[field]?.toLowerCase().includes(term),
2174
+ ),
2175
+ ),
2176
+ );
2177
+ this.recordsTotal = this.searchTable.length;
2178
+ if (this.recordsTotal < 5) {
2179
+ this.paginationSize = [this.recordsTotal];
2180
+ this.size = this.recordsTotal;
2181
+ } else {
2182
+ this.paginationSize = [5, 10, 15, 20];
2183
+ this.size = 5;
2184
+ }
2185
+ this.tableData = this.searchTable.slice(
2186
+ this.currentValue * this.size - this.size,
2187
+ this.currentValue * this.size,
2188
+ );
2189
+ }
2190
+ this.tableData ? (this.tableLoading = false) : (this.tableLoading = true);
2191
+ }
2192
+
2193
+ sortData(value: any) {
2194
+ this.sortColumn = value;
2195
+ this.sortBy *= -1;
2196
+ const sortBy = parseInt(this.sortBy, 10) === -1 ? -1 : 1;
2197
+ this.tableArray.sort((a: any, b: any) => {
2198
+ return (
2199
+ sortBy *
2200
+ (a[this.sortColumn] || "").localeCompare(b[this.sortColumn] || "")
2201
+ );
2202
+ });
2203
+
2204
+ this.tableData = this.tableArray.slice(
2205
+ this.currentValue * this.size - this.size,
2206
+ this.currentValue * this.size,
2207
+ );
2208
+ }
2209
+
2210
+ updateFlag(event: any, index: any, element: any) {
2211
+ element.checkFlag = event.target.checked;
2212
+ if (event.target.checked) {
2213
+ let index = this.removeUsers.findIndex((item: any) => item == element.id);
2214
+ this.removeUsers.splice(index, 1);
2215
+ this.configData.checkListDetails.assignedUsers.push(element.id);
2216
+ }
2217
+ if (!event.target.checked) {
2218
+ this.removeUsers.push(element.id);
2219
+ let index = this.configData.checkListDetails.assignedUsers.findIndex(
2220
+ (item: any) => item == element.id,
2221
+ );
2222
+ this.configData.checkListDetails.assignedUsers.splice(index, 1);
2223
+ }
2224
+ this.tableData[index].checkFlag = event.target.checked;
2225
+ this.changedetector.detectChanges();
2226
+ if (
2227
+ this.configData.checkListDetails.assignedUsers.length != this.recordsTotal
2228
+ ) {
2229
+ this.selectAll = false;
2230
+ }
2231
+ }
2232
+ checkAll(event: any) {
2233
+ // this.configData.checkListDetails.assignedUsers = [];
2234
+ if (event.target.checked) {
2235
+ this.tableData.forEach((item: any) => {
2236
+ item.checkFlag = true;
2237
+ let index = this.removeUsers.findIndex(
2238
+ (element: any) => element == item.id,
2239
+ );
2240
+ this.removeUsers.splice(index, 1);
2241
+ if (!this.configData.checkListDetails.assignedUsers.includes(item.id))
2242
+ this.configData.checkListDetails.assignedUsers.push(item.id);
2243
+ });
2244
+ } else {
2245
+ this.tableData.forEach((item: any) => {
2246
+ item.checkFlag = false;
2247
+ this.removeUsers.push(item.id);
2248
+ let index = this.configData.checkListDetails.assignedUsers.findIndex(
2249
+ (id: any) => id == item.id,
2250
+ );
2251
+ this.configData.checkListDetails.assignedUsers.splice(index, 1);
2252
+ });
2253
+ }
2254
+
2255
+ this.changedetector.detectChanges();
2256
+ }
2257
+
2258
+ dateSpecific(event: any) {
2259
+ if (
2260
+ this.configData.checkListDetails?.schedule == "range" &&
2261
+ event?.selectedList
2262
+ ) {
2263
+ this.selectedDateList = event.selectedList;
2264
+ }
2265
+ }
2266
+ dateRangeStart(event: any) {
2267
+ if (event && event.startDate) {
2268
+ if (this.configData.checkListDetails?.schedule == "onetime")
2269
+ this.configData.checkListDetails.scheduleDate = this.dayjs(
2270
+ event.startDate,
2271
+ ).format("YYYY-MM-DD");
2272
+ else {
2273
+ this.configData.checkListDetails.configStartDate = this.dayjs(
2274
+ event.startDate,
2275
+ ).format("YYYY-MM-DD");
2276
+ }
2277
+ } else {
2278
+ if (this.configData.checkListDetails?.schedule == "onetime")
2279
+ this.configData.checkListDetails.scheduleDate =
2280
+ this.configData.checkListDetails.scheduleDate;
2281
+ else {
2282
+ this.configData.checkListDetails.configStartDate =
2283
+ this.configData.checkListDetails.configStartDate;
2284
+ }
2285
+ }
2286
+ this.selectedStartDate = {
2287
+ startDate: this.dayjs(
2288
+ this.configData.checkListDetails?.configStartDate,
2289
+ ).format("DD-MM-YYYY"),
2290
+ endDate: this.dayjs(
2291
+ this.configData.checkListDetails?.configStartDate,
2292
+ ).format("DD-MM-YYYY"),
2293
+ };
2294
+ this.minStartDate = this.dayjs().format();
2295
+ this.minDate = this.dayjs().format();
2296
+ this.minEndDate = this.dayjs(
2297
+ this.configData.checkListDetails?.configStartDate,
2298
+ ).format();
2299
+ this.selectedEndDate = "";
2300
+ this.selectedDateList = [];
2301
+ if (this.configData.checkListDetails.schedule == "range") {
2302
+ if (
2303
+ event?.startDate &&
2304
+ this.configData.checkListDetails.configStartDate != event.startDate
2305
+ ) {
2306
+ this.configData.checkListDetails.configEndDate = this.dayjs(
2307
+ this.configData.checkListDetails.configStartDate,
2308
+ )
2309
+ .add(1, "day")
2310
+ .format("YYYY-MM-DD");
2311
+ }
2312
+ this.selectedEndDate = {
2313
+ startDate: this.dayjs(
2314
+ this.configData.checkListDetails?.configEndDate,
2315
+ ).format("DD-MM-YYYY"),
2316
+ endDate: this.dayjs(
2317
+ this.configData.checkListDetails?.configEndDate,
2318
+ ).format("DD-MM-YYYY"),
2319
+ };
2320
+ } else {
2321
+ if (
2322
+ event?.startDate &&
2323
+ this.configData.checkListDetails.configStartDate != event.startDate
2324
+ ) {
2325
+ this.configData.checkListDetails.configEndDate = "";
2326
+ }
2327
+ }
2328
+ this.validateTime();
2329
+ }
2330
+
2331
+ dateRangeEnd(event: any) {
2332
+ if (event && event.endDate) {
2333
+ this.selectedDateList = [];
2334
+ if (
2335
+ this.configData.checkListDetails.configStartDate >
2336
+ this.dayjs(event.endDate).format("YYYY-MM-DD")
2337
+ ) {
2338
+ this.configData.checkListDetails.configEndDate =
2339
+ this.configData.checkListDetails.configStartDate;
2340
+ } else {
2341
+ this.configData.checkListDetails.configEndDate = this.dayjs(
2342
+ event.endDate,
2343
+ ).format("YYYY-MM-DD");
2344
+ }
2345
+ this.selectedEndDate = {
2346
+ startDate: this.dayjs(
2347
+ this.configData.checkListDetails?.configEndDate,
2348
+ ).format("DD-MM-YYYY"),
2349
+ endDate: this.dayjs(
2350
+ this.configData.checkListDetails?.configEndDate,
2351
+ ).format("DD-MM-YYYY"),
2352
+ };
2353
+ this.minEndDate = this.dayjs(
2354
+ this.configData.checkListDetails?.configStartDate,
2355
+ ).format();
2356
+ this.validateTime();
2357
+ }
2358
+ }
2359
+
2360
+ // dateChanged(event: any) {
2361
+ // this.date = this.dayjs(event.start);
2362
+ // this.monthDate = parseInt(this.date.format('DD')) == 1 ? parseInt(this.date.format('DD')) + 'st' : parseInt(this.date.format('DD')) == 2 ? parseInt(this.date.format('DD')) + 'nd' : parseInt(this.date.format('DD')) == 3 ? parseInt(this.date.format('DD')) + 'rd' : parseInt(this.date.format('DD')) + 'th';
2363
+ // this.monthDay = this.date.format('dddd');
2364
+ // this.configData.checkListDetails.scheduleDate = this.dayjs(event.start).format('YYYY-MM-DD');
2365
+
2366
+ // let weekNumber = getWeekNumber(this.date);
2367
+ // this.MonthweekNumber = weekNumber == 1 ? weekNumber + 'st' : weekNumber == 2 ? weekNumber + 'nd' : weekNumber == 3 ? weekNumber + 'rd' : weekNumber + 'th';
2368
+ // this.setMonthDate(this.configData.checkListDetails.scheduleRepeatedMonthSetup);
2369
+ // }
2370
+ // setDay(day: any) {
2371
+ // this.configData.checkListDetails.scheduleRepeatedDay = day;
2372
+ // }
2373
+ setDay(day: string) {
2374
+ if (this.selectedDays.includes(day)) {
2375
+ this.selectedDays = this.selectedDays.filter(
2376
+ (selectedDay) => selectedDay !== day,
2377
+ );
2378
+ } else {
2379
+ this.selectedDays.push(day);
2380
+ }
2381
+ }
2382
+ // setMonthDate(data: any) {
2383
+ // if (data == 'date') {
2384
+ // this.configData.checkListDetails.scheduleRepeatedDay = [this.monthDate];
2385
+ // this.selectedDays = [this.monthDate];
2386
+ // }
2387
+ // else {
2388
+ // this.configData.checkListDetails.scheduleRepeatedDay = [this.monthDay];
2389
+ // this.selectedDays = [this.monthDay];
2390
+ // let weekNumber = getWeekNumber(this.date);
2391
+ // this.configData.checkListDetails.scheduleRepeatedMonthWeek = weekNumber == 1 ? weekNumber + 'st' : weekNumber == 2 ? weekNumber + 'nd' : weekNumber == 3 ? weekNumber + 'rd' : weekNumber + 'th';
2392
+ // }
2393
+ // this.configData.checkListDetails.scheduleRepeatedMonthSetup = data;
2394
+
2395
+ // }
2396
+ // setDate(event: any) {
2397
+ // this.configData.checkListDetails.scheduleDate = event.start;
2398
+ // }
2399
+
2400
+ publish(showPopup: boolean = true) {
2401
+ if (
2402
+ ["weekly", "weekday"].includes(
2403
+ this.configData.checkListDetails.schedule,
2404
+ ) &&
2405
+ this.selectedDays.length == 0
2406
+ ) {
2407
+ this.toast.getErrorToast("Please select atleast 1 day to proceed");
2408
+ return false;
2409
+ }
2410
+ if (!this.validTime) {
2411
+ this.toast.getErrorToast("Invalid Schedule End Time");
2412
+ return false;
2413
+ }
2414
+ if (!this.showRangeValue) {
2415
+ this.configData.checkListDetails.configStartDate = "";
2416
+ this.configData.checkListDetails.configEndDate = "";
2417
+ }
2418
+ if (this.configData.checkListDetails.schedule != "onetime") {
2419
+ this.configData.checkListDetails.scheduleDate = "";
2420
+ }
2421
+ if (
2422
+ this.configData.checkListDetails.schedule == "monthly" &&
2423
+ this.configData.checkListDetails.scheduleRepeatedMonthSetup == "date"
2424
+ ) {
2425
+ this.configData.checkListDetails.scheduleRepeatedMonthWeek =
2426
+ this.monthDate + " " + this.monthDay;
2427
+ }
2428
+ if (
2429
+ this.configData.checkListDetails.schedule == "monthly" &&
2430
+ this.configData.checkListDetails.scheduleRepeatedMonthSetup == "specific"
2431
+ ) {
2432
+ if (this.submittedDates.length)
2433
+ this.configData.checkListDetails.specificDate = this.submittedDates;
2434
+ else {
2435
+ this.toast.getErrorToast("Please select atleast 1 date to proceed");
2436
+ return false;
2437
+ }
2438
+ }
2439
+ if (this.configData.checkListDetails.schedule == "range") {
2440
+ this.configData.checkListDetails.specificDate = this.selectedDateList;
2441
+ }
2442
+ if (showPopup) {
2443
+ let popupcontent = {
2444
+ displayprop: false,
2445
+ imagesrc: `<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" viewBox="0 0 56 56" fill="none"><rect x="4" y="4" width="48" height="48" rx="24" fill="#D1FADF"/><path d="M38 27.0818V28.0018C37.9988 30.1582 37.3005 32.2565 36.0093 33.9836C34.7182 35.7108 32.9033 36.9743 30.8354 37.5857C28.7674 38.1971 26.5573 38.1237 24.5345 37.3764C22.5117 36.6291 20.7847 35.2479 19.611 33.4389C18.4373 31.6299 17.8798 29.4899 18.0217 27.3381C18.1636 25.1864 18.9972 23.1381 20.3983 21.4989C21.7994 19.8596 23.6928 18.7172 25.7962 18.242C27.8996 17.7667 30.1003 17.9842 32.07 18.8618M38 20.0018L28 30.0118L25 27.0118" stroke="#039855" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><rect x="4" y="4" width="48" height="48" rx="24" stroke="#ECFDF3" stroke-width="8"/></svg>`,
2446
+ title: `Are you sure you want to publish ${this.configData.checkListDetails.checkListName} checklist?`,
2447
+ content: `Publishing will make this checklist live, and changes will take effect immediately.`,
2448
+ buttontype: "confirm",
2449
+ };
2450
+ const dialogRef = this.dialog.open(TraxpopupComponent, {
2451
+ centered: true,
2452
+ size: "md",
2453
+ backdrop: "static",
2454
+ });
2455
+ dialogRef.componentInstance.data = popupcontent;
2456
+ dialogRef.result.then((res) => {
2457
+ if (res == "confirm") {
2458
+ this.detassignUpdate((result: boolean) => {
2459
+ if (result) {
2460
+ this.updatePublish();
2461
+ } else {
2462
+ }
2463
+ });
2464
+ }
2465
+ });
2466
+ } else {
2467
+ this.detassignUpdate((result: boolean) => {
2468
+ if (result) {
2469
+ this.updatePublish();
2470
+ } else {
2471
+ }
2472
+ });
2473
+ }
2474
+ }
2475
+
2476
+ publishAI(showPopup: boolean = true) {
2477
+ if (!this.configData.clientId) {
2478
+ this.configData.type = this.type;
2479
+ } else {
2480
+ this.configData.id = this.checklistId;
2481
+ }
2482
+ this.configData.publish = true;
2483
+ this.configData?.aiConfig?.assignConfig !== "store"
2484
+ ? this.configData.aiConfig.events
2485
+ : (this.configData.aiConfig.events = []);
2486
+
2487
+ if (
2488
+ this.type == "mobileusagedetection" &&
2489
+ !this.configData.aiConfig.mobileDetection.usageExceed
2490
+ ) {
2491
+ this.toast.getErrorToast("Please Enter the Usage Exceed Duration");
2492
+ return;
2493
+ } else if (
2494
+ this.type == "mobileusagedetection" &&
2495
+ this.configData.aiConfig.mobileDetection.usageExceed < 1
2496
+ ) {
2497
+ this.configData.aiConfig.mobileDetection.usageExceed = 0;
2498
+ this.toast.getErrorToast(
2499
+ "Please Enter the Usage Exceed Duration 15 to 999",
2500
+ );
2501
+ return;
2502
+ }
2503
+
2504
+ if (
2505
+ this.type == "storeopenandclose" &&
2506
+ this.checkBuffer &&
2507
+ (this.configData.aiConfig.storeOpenClose.buffer.openTime > 30 ||
2508
+ this.configData.aiConfig.storeOpenClose.buffer.openTime < 1 ||
2509
+ this.configData.aiConfig.storeOpenClose.buffer.closeTime > 30 ||
2510
+ this.configData.aiConfig.storeOpenClose.buffer.closeTime < 1)
2511
+ ) {
2512
+ this.toast.getErrorToast("Buffer time min 1 and max 30");
2513
+ return;
2514
+ }
2515
+ if (
2516
+ ["user", "teams"].includes(
2517
+ this.configData.aiConfig.autoTaskConfig.taskAssignedTo,
2518
+ ) &&
2519
+ !this.configData.aiConfig.autoTaskConfig.users.length
2520
+ ) {
2521
+ this.toast.getErrorToast("Task assigned users is required");
2522
+ return;
2523
+ }
2524
+ if (["tvcompliance"].includes(this.type)) {
2525
+ this.configData.aiConfig.tvcompliance.recurrence = {};
2526
+ this.configData.aiConfig.tvcompliance.schedule = {};
2527
+ this.configData.aiConfig.tvcompliance.detectedStatus = {};
2528
+ this.configData.aiConfig.tvcompliance.schedule.scheduletype =
2529
+ this.scheduletype;
2530
+ this.configData.aiConfig.tvcompliance.schedule.openTime =
2531
+ this.schedulestartTime;
2532
+ this.configData.aiConfig.tvcompliance.schedule.closeTime =
2533
+ this.scheduleendTime;
2534
+ this.configData.aiConfig.tvcompliance.recurrence.status =
2535
+ this.recurrenceStatus;
2536
+ this.configData.aiConfig.tvcompliance.recurrence.time =
2537
+ this.recurrencetime;
2538
+ this.configData.aiConfig.tvcompliance.detectedStatus.status =
2539
+ this.isThresholdEnabled;
2540
+ this.configData.aiConfig.tvcompliance.detectedStatus.detections =
2541
+ this.detectionThreshold;
2542
+ }
2543
+ if (["storehygienemonitoring"].includes(this.type)) {
2544
+ this.configData.aiConfig.hygieneMonitoring.recurrence = {};
2545
+ this.configData.aiConfig.hygieneMonitoring.schedule = {};
2546
+ this.configData.aiConfig.hygieneMonitoring.detectedStatus = {};
2547
+ this.configData.aiConfig.hygieneMonitoring.schedule.scheduletype =
2548
+ this.scheduletype;
2549
+ this.configData.aiConfig.hygieneMonitoring.schedule.openTime =
2550
+ this.scheduletype == "standard" ? undefined : this.schedulestartTime;
2551
+ this.configData.aiConfig.hygieneMonitoring.schedule.closeTime =
2552
+ this.scheduletype == "standard" ? undefined : this.scheduleendTime;
2553
+ this.configData.aiConfig.hygieneMonitoring.recurrence.status = this
2554
+ .recurrenceType
2555
+ ? true
2556
+ : false;
2557
+ this.configData.aiConfig.hygieneMonitoring.recurrence.time =
2558
+ this.recurrencetime;
2559
+ this.configData.aiConfig.hygieneMonitoring.recurrence.type =
2560
+ this.recurrenceType;
2561
+ }
2562
+ if (["staffgrouping"].includes(this.type)) {
2563
+ if (!this.configData.aiConfig.staffGrouping) {
2564
+ this.configData.aiConfig.staffGrouping = {};
2565
+ }
2566
+ this.configData.aiConfig.staffGrouping.schedule = {
2567
+ scheduletype: this.scheduletype,
2568
+ openTime: this.schedulestartTime,
2569
+ closeTime: this.scheduleendTime,
2570
+ };
2571
+ this.configData.aiConfig.staffGrouping.alertCooldownEnabled =
2572
+ this.alertCooldownEnabled;
2573
+ this.configData.aiConfig.staffGrouping.alertCooldownTime =
2574
+ this.alertCooldownTime;
2575
+ }
2576
+ if (["boxalert"].includes(this.type)) {
2577
+ if (!this.configData.aiConfig.boxAlert) {
2578
+ this.configData.aiConfig.boxAlert = {};
2579
+ }
2580
+ this.configData.aiConfig.boxAlert.schedule = {
2581
+ scheduletype: this.scheduletype,
2582
+ openTime: this.schedulestartTime,
2583
+ closeTime: this.scheduleendTime,
2584
+ };
2585
+ this.configData.aiConfig.boxAlert.recurrence = {
2586
+ status: this.recurrenceType ? true : false,
2587
+ time: this.recurrencetime,
2588
+ type: this.recurrenceType,
2589
+ };
2590
+ }
2591
+ if (["employeeCount"].includes(this.type)) {
2592
+ if (!this.configData.aiConfig.employeeCount) {
2593
+ this.configData.aiConfig.employeeCount = {};
2594
+ }
2595
+ this.configData.aiConfig.employeeCount.schedule = {
2596
+ scheduletype: this.scheduletype,
2597
+ openTime: this.schedulestartTime,
2598
+ closeTime: this.scheduleendTime,
2599
+ };
2600
+ this.configData.aiConfig.employeeCount.recurrence = {
2601
+ status: this.recurrenceType ? true : false,
2602
+ time: this.recurrencetime,
2603
+ type: this.recurrenceType,
2604
+ };
2605
+ }
2606
+ if (["queuealert"].includes(this.type)) {
2607
+ console.log(this.waitTimeLimit, this.queueLimit);
2608
+ this.configData.aiConfig.queuealert = {};
2609
+ this.configData.aiConfig.tvcompliance.schedule = {};
2610
+ this.configData.aiConfig.tvcompliance.schedule.scheduletype =
2611
+ this.scheduletype;
2612
+ this.configData.aiConfig.tvcompliance.schedule.openTime =
2613
+ this.schedulestartTime;
2614
+ this.configData.aiConfig.tvcompliance.schedule.closeTime =
2615
+ this.scheduleendTime;
2616
+ this.configData.aiConfig.queuealert.queueLengthEnabled =
2617
+ this.queueLengthEnabled;
2618
+ this.configData.aiConfig.queuealert.queueLimit = this.queueLimit;
2619
+ this.configData.aiConfig.queuealert.waitTimeEnabled =
2620
+ this.waitTimeEnabled;
2621
+ this.configData.aiConfig.queuealert.waitTimeLimit = this.waitTimeLimit;
2622
+ this.configData.aiConfig.queuealert.alertCooldownEnabled =
2623
+ this.alertCooldownEnabled;
2624
+ this.configData.aiConfig.queuealert.alertCooldownTime =
2625
+ this.alertCooldownTime;
2626
+ }
2627
+ if (["cameratampering"].includes(this.type)) {
2628
+ this.configData.aiConfig.cameraAngle = {};
2629
+ this.configData.aiConfig.cameraAngle.enabled = this.cameraAngleEnabled;
2630
+ }
2631
+ if (showPopup) {
2632
+ let popupcontent = {
2633
+ displayprop: false,
2634
+ imagesrc: `<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" viewBox="0 0 56 56" fill="none"><rect x="4" y="4" width="48" height="48" rx="24" fill="#D1FADF"/><path d="M38 27.0818V28.0018C37.9988 30.1582 37.3005 32.2565 36.0093 33.9836C34.7182 35.7108 32.9033 36.9743 30.8354 37.5857C28.7674 38.1971 26.5573 38.1237 24.5345 37.3764C22.5117 36.6291 20.7847 35.2479 19.611 33.4389C18.4373 31.6299 17.8798 29.4899 18.0217 27.3381C18.1636 25.1864 18.9972 23.1381 20.3983 21.4989C21.7994 19.8596 23.6928 18.7172 25.7962 18.242C27.8996 17.7667 30.1003 17.9842 32.07 18.8618M38 20.0018L28 30.0118L25 27.0118" stroke="#039855" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><rect x="4" y="4" width="48" height="48" rx="24" stroke="#ECFDF3" stroke-width="8"/></svg>`,
2635
+ title: `Are you sure you want to publish ${this.configData.checkListName} checklist?`,
2636
+ content: `Publishing will make this checklist live, and changes will take effect immediately.`,
2637
+ buttontype: "confirm",
2638
+ };
2639
+ const dialogRef = this.dialog.open(TraxpopupComponent, {
2640
+ centered: true,
2641
+ size: "md",
2642
+ backdrop: "static",
2643
+ });
2644
+ dialogRef.componentInstance.data = popupcontent;
2645
+ dialogRef.result.then((res) => {
2646
+ if (res == "confirm") {
2647
+ this.configData.clientId = this.clientId;
2648
+ this.SopService.updateAiConfigure(this.configData).subscribe({
2649
+ next: (res: any) => {
2650
+ if (res && res?.code == 200) {
2651
+ this.toast.getSuccessToast(res?.message);
2652
+ this.route.navigate(["/manage/trax/checklist"]);
2653
+ }
2654
+ },
2655
+ error: (err: any) => {
2656
+ let error = err?.error?.error || "something went wrong";
2657
+ this.toast.getErrorToast(error);
2658
+ },
2659
+ });
2660
+ }
2661
+ });
2662
+ }
2663
+ }
2664
+
2665
+ saveDraftAI() {
2666
+ if (this.configData.clientId) {
2667
+ this.configData.id = this.checklistId;
2668
+ } else {
2669
+ this.configData.type = this.type;
2670
+ }
2671
+
2672
+ if (["tvcompliance"].includes(this.type)) {
2673
+ this.configData.aiConfig.tvcompliance.recurrence = {};
2674
+ this.configData.aiConfig.tvcompliance.schedule = {};
2675
+ this.configData.aiConfig.tvcompliance.detectedStatus = {};
2676
+ this.configData.aiConfig.tvcompliance.schedule.scheduletype =
2677
+ this.scheduletype;
2678
+ this.configData.aiConfig.tvcompliance.schedule.openTime =
2679
+ this.schedulestartTime;
2680
+ this.configData.aiConfig.tvcompliance.schedule.closeTime =
2681
+ this.scheduleendTime;
2682
+ this.configData.aiConfig.tvcompliance.recurrence.status =
2683
+ this.recurrenceStatus;
2684
+ this.configData.aiConfig.tvcompliance.recurrence.time =
2685
+ this.recurrencetime;
2686
+ this.configData.aiConfig.tvcompliance.detectedStatus.status =
2687
+ this.isThresholdEnabled;
2688
+ this.configData.aiConfig.tvcompliance.detectedStatus.detections =
2689
+ this.detectionThreshold;
2690
+ }
2691
+ if (["storehygienemonitoring"].includes(this.type)) {
2692
+ this.configData.aiConfig.hygieneMonitoring.recurrence = {};
2693
+ this.configData.aiConfig.hygieneMonitoring.schedule = {};
2694
+ this.configData.aiConfig.hygieneMonitoring.detectedStatus = {};
2695
+ this.configData.aiConfig.hygieneMonitoring.schedule.scheduletype =
2696
+ this.scheduletype;
2697
+ this.configData.aiConfig.hygieneMonitoring.schedule.openTime =
2698
+ this.scheduletype == 'standard' ? undefined : this.schedulestartTime;
2699
+ this.configData.aiConfig.hygieneMonitoring.schedule.closeTime =
2700
+ this.scheduletype == "standard" ? undefined : this.scheduleendTime;
2701
+ this.configData.aiConfig.hygieneMonitoring.recurrence.status = this
2702
+ .recurrenceType
2703
+ ? true
2704
+ : false;
2705
+ this.configData.aiConfig.hygieneMonitoring.recurrence.time =
2706
+ this.recurrencetime;
2707
+ }
2708
+ if (["staffgrouping"].includes(this.type)) {
2709
+ if (!this.configData.aiConfig.staffGrouping) {
2710
+ this.configData.aiConfig.staffGrouping = {};
2711
+ }
2712
+ this.configData.aiConfig.staffGrouping.schedule = {
2713
+ scheduletype: this.scheduletype,
2714
+ openTime: this.schedulestartTime,
2715
+ closeTime: this.scheduleendTime,
2716
+ };
2717
+ this.configData.aiConfig.staffGrouping.alertCooldownEnabled =
2718
+ this.alertCooldownEnabled;
2719
+ this.configData.aiConfig.staffGrouping.alertCooldownTime =
2720
+ this.alertCooldownTime;
2721
+ }
2722
+ if (["boxalert"].includes(this.type)) {
2723
+ if (!this.configData.aiConfig.boxAlert) {
2724
+ this.configData.aiConfig.boxAlert = {};
2725
+ }
2726
+ this.configData.aiConfig.boxAlert.schedule = {
2727
+ scheduletype: this.scheduletype,
2728
+ openTime: this.schedulestartTime,
2729
+ closeTime: this.scheduleendTime,
2730
+ };
2731
+ this.configData.aiConfig.boxAlert.recurrence = {
2732
+ status: this.recurrenceType ? true : false,
2733
+ time: this.recurrencetime,
2734
+ type: this.recurrenceType,
2735
+ };
2736
+ }
2737
+ if (["employeeCount"].includes(this.type)) {
2738
+ if (!this.configData.aiConfig.employeeCount) {
2739
+ this.configData.aiConfig.employeeCount = {};
2740
+ }
2741
+ this.configData.aiConfig.employeeCount.schedule = {
2742
+ scheduletype: this.scheduletype,
2743
+ openTime: this.schedulestartTime,
2744
+ closeTime: this.scheduleendTime,
2745
+ };
2746
+ this.configData.aiConfig.employeeCount.recurrence = {
2747
+ status: this.recurrenceType ? true : false,
2748
+ time: this.recurrencetime,
2749
+ type: this.recurrenceType,
2750
+ };
2751
+ }
2752
+ if (["queuealert"].includes(this.type)) {
2753
+ this.configData.aiConfig.queuealert = {};
2754
+ this.configData.aiConfig.tvcompliance.schedule = {};
2755
+ this.configData.aiConfig.tvcompliance.schedule.scheduletype =
2756
+ this.scheduletype;
2757
+ this.configData.aiConfig.tvcompliance.schedule.openTime =
2758
+ this.schedulestartTime;
2759
+ this.configData.aiConfig.tvcompliance.schedule.closeTime =
2760
+ this.scheduleendTime;
2761
+ this.configData.aiConfig.queuealert.queueLengthEnabled =
2762
+ this.queueLengthEnabled;
2763
+ this.configData.aiConfig.queuealert.queueLimit = this.queueLimit;
2764
+ this.configData.aiConfig.queuealert.waitTimeEnabled =
2765
+ this.waitTimeEnabled;
2766
+ this.configData.aiConfig.queuealert.waitTimeLimit = this.waitTimeLimit;
2767
+ this.configData.aiConfig.queuealert.alertCooldownEnabled =
2768
+ this.alertCooldownEnabled;
2769
+ this.configData.aiConfig.queuealert.alertCooldownTime =
2770
+ this.alertCooldownTime;
2771
+ }
2772
+ if (["cameratampering"].includes(this.type)) {
2773
+ this.configData.aiConfig.cameraAngle = {};
2774
+ this.configData.aiConfig.cameraAngle.enabled = this.cameraAngleEnabled;
2775
+ }
2776
+ this.configData.publish = false;
2777
+ this.configData?.aiConfig?.assignConfig !== "store"
2778
+ ? this.configData.aiConfig.events
2779
+ : (this.configData.aiConfig.events = []);
2780
+ if (
2781
+ this.type == "mobileusagedetection" &&
2782
+ !this.configData.aiConfig.mobileDetection.usageExceed
2783
+ ) {
2784
+ this.toast.getErrorToast("Please Enter the Usage Exceed Duration");
2785
+ return;
2786
+ } else if (
2787
+ this.type == "mobileusagedetection" &&
2788
+ this.configData.aiConfig.mobileDetection.usageExceed < 1
2789
+ ) {
2790
+ this.configData.aiConfig.mobileDetection.usageExceed = 0;
2791
+ this.toast.getErrorToast(
2792
+ "Please Enter the Usage Exceed Duration 15 to 999",
2793
+ );
2794
+ return;
2795
+ }
2796
+
2797
+ const popupcontent = {
2798
+ displayprop: false,
2799
+ imagesrc:
2800
+ '<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" viewBox="0 0 56 56" fill="none"><rect x="4" y="4" width="48" height="48" rx="24" fill="#FEF0C7"/><path d="M27.9998 24.0012V28.0012M27.9998 32.0012H28.0098M26.2898 18.8612L17.8198 33.0012C17.6451 33.3036 17.5527 33.6465 17.5518 33.9957C17.5508 34.3449 17.6413 34.6883 17.8142 34.9917C17.9871 35.2951 18.2365 35.5479 18.5375 35.725C18.8385 35.9021 19.1806 35.9973 19.5298 36.0012H36.4698C36.819 35.9973 37.1611 35.9021 37.4621 35.725C37.7631 35.5479 38.0124 35.2951 38.1854 34.9917C38.3583 34.6883 38.4488 34.3449 38.4478 33.9957C38.4468 33.6465 38.3544 33.3036 38.1798 33.0012L29.7098 18.8612C29.5315 18.5673 29.2805 18.3243 28.981 18.1557C28.6814 17.987 28.3435 17.8984 27.9998 17.8984C27.656 17.8984 27.3181 17.987 27.0186 18.1557C26.7191 18.3243 26.468 18.5673 26.2898 18.8612Z" stroke="#DC6803" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><rect x="4" y="4" width="48" height="48" rx="24" stroke="#FFFAEB" stroke-width="8"/></svg>',
2801
+ title: `Unsaved changes`,
2802
+ content: `Do you want to save as draft?`,
2803
+ buttontype: "draft",
2804
+ };
2805
+ const dialogRef = this.dialog.open(TraxpopupComponent, {
2806
+ centered: true,
2807
+ size: "md",
2808
+ backdrop: "static",
2809
+ });
2810
+ dialogRef.componentInstance.data = popupcontent;
2811
+
2812
+ dialogRef.result.then((res) => {
2813
+ if (!res) {
2814
+ this.popupCount = 0;
2815
+ }
2816
+ if (res == "confirm") {
2817
+ this.configData.clientId = this.clientId;
2818
+ this.SopService.updateAiConfigure(this.configData)
2819
+ .pipe(takeUntil(this.detach))
2820
+ .subscribe(
2821
+ (result: any) => {
2822
+ if (result && result.code == 200) {
2823
+ this.toast.getSuccessToast(
2824
+ "Draft has been saved successfully.",
2825
+ );
2826
+ this.route.navigate(["/manage/trax/checklist"]);
2827
+ }
2828
+ },
2829
+ (error: any) => {
2830
+ let err = error?.error?.error || "something went wrong";
2831
+ this.toast.getErrorToast(err);
2832
+ },
2833
+ );
2834
+ }
2835
+ });
2836
+ }
2837
+
2838
+ uploadData: boolean = false;
2839
+ uploadAIfiles() {
2840
+ this.uploadData = true;
2841
+ }
2842
+
2843
+ handleDataFromChild(data: any) {
2844
+ this.uploadData = data;
2845
+ }
2846
+
2847
+ updatePublish() {
2848
+ if (
2849
+ this.type == "mobileusagedetection" ||
2850
+ this.type == "storeopenandclose"
2851
+ ) {
2852
+ // if (this.type == 'mobileusagedetection') {
2853
+ // this.configData.checkListDetails.detectionArea = this.zones;
2854
+ // }
2855
+ if (this.type == "storeopenandclose") {
2856
+ this.configData.checkListDetails.scheduleStartTime =
2857
+ this.configData.openTime;
2858
+ this.configData.checkListDetails.scheduleEndTime =
2859
+ this.configData.closeTime;
2860
+ }
2861
+ // this.configData.checkListDetails.alert.alertsTo = this.emailList;
2862
+ }
2863
+ this.configData.checkListDetails.publish = true;
2864
+ this.configData.checkListDetails.coverage = this.coverage;
2865
+ this.configData.submitType = "publish";
2866
+ this.configData.removedUsers = this.removeUsers;
2867
+ this.configData.checkListDetails.scheduleWeekDays = this.selectedDays;
2868
+ this.configData.updateConfigure = this.disabledQuestion ? true : false;
2869
+ this.configData.clientId = this.clientId;
2870
+ this.configData.showEdit = this.showEdit;
2871
+ this.configData.checkListDetails.assignedUsers = [
2872
+ ...this.singleAssign,
2873
+ ...this.groupAssign,
2874
+ ];
2875
+ this.configData.checkListDetails.storeCount =
2876
+ this.assignSingle?.length + this.groupAssign?.length;
2877
+ this.configData.checkListDetails.enableNewDeployedStore = this.storeCoverage
2878
+ ? this.configData.checkListDetails.enableNewDeployedStore
2879
+ : false;
2880
+ const timeZone = dayjs.tz.guess();
2881
+ this.configData.timeZone = timeZone;
2882
+
2883
+ this.SopService.configUpdate(this.configData)
2884
+ .pipe(takeUntil(this.detach))
2885
+ .subscribe(
2886
+ (res: any) => {
2887
+ if (res) {
2888
+ if (res && res.code == 200) {
2889
+ this.toast.getSuccessToast(
2890
+ `${this.configData.checkListDetails.checkListName} checklist published.`,
2891
+ );
2892
+ this.route.navigate(["/manage/trax/checklist"]);
2893
+ } else {
2894
+ this.toast.getErrorToast("Please Assign a User!");
2895
+ }
2896
+ } else {
2897
+ this.toast.getErrorToast("Please Assign a User!");
2898
+ }
2899
+ },
2900
+ (error: any) => {
2901
+ let err = error?.error?.error || "something went wrong";
2902
+ if (err == "Checklist got submitted") {
2903
+ let popupcontent = {
2904
+ displayprop: false,
2905
+ imagesrc: `<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" viewBox="0 0 56 56" fill="none"><rect x="4" y="4" width="48" height="48" rx="24" fill="#FEF0C7"></rect><path d="M27.9998 24.0012V28.0012M27.9998 32.0012H28.0098M26.2898 18.8612L17.8198 33.0012C17.6451 33.3036 17.5527 33.6465 17.5518 33.9957C17.5508 34.3449 17.6413 34.6883 17.8142 34.9917C17.9871 35.2951 18.2365 35.5479 18.5375 35.725C18.8385 35.9021 19.1806 35.9973 19.5298 36.0012H36.4698C36.819 35.9973 37.1611 35.9021 37.4621 35.725C37.7631 35.5479 38.0124 35.2951 38.1854 34.9917C38.3583 34.6883 38.4488 34.3449 38.4478 33.9957C38.4468 33.6465 38.3544 33.3036 38.1798 33.0012L29.7098 18.8612C29.5315 18.5673 29.2805 18.3243 28.981 18.1557C28.6814 17.987 28.3435 17.8984 27.9998 17.8984C27.656 17.8984 27.3181 17.987 27.0186 18.1557C26.7191 18.3243 26.468 18.5673 26.2898 18.8612Z" stroke="#DC6803" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path><rect x="4" y="4" width="48" height="48" rx="24" stroke="#FFFAEB" stroke-width="8"></rect></svg>`,
2906
+ title: `Checklist Update!`,
2907
+ content: `Multiple stores have already submitted this checklist. Do you want to re-assign it to them?`,
2908
+ buttontype: "reAssign",
2909
+ };
2910
+ const dialogRef = this.dialog.open(TraxpopupComponent, {
2911
+ centered: true,
2912
+ size: "md",
2913
+ backdrop: "static",
2914
+ });
2915
+ dialogRef.componentInstance.data = popupcontent;
2916
+ dialogRef.result.then((res) => {
2917
+ if (res == "confirm") {
2918
+ this.configData.editSubmit = true;
2919
+ } else {
2920
+ this.configData.editSubmit = false;
2921
+ }
2922
+ this.publish(false);
2923
+ });
2924
+ } else {
2925
+ this.toast.getErrorToast(err);
2926
+ }
2927
+ },
2928
+ );
2929
+ }
2930
+
2931
+ detassignUpdate(callback: (result: boolean) => void): void {
2932
+ const payload = {
2933
+ checkListId: this.checklistId,
2934
+ assignedList: this.assignSingle || [],
2935
+ assignedGroup: this.assignGroup || [],
2936
+ clientId: this.clientId,
2937
+ coverage: this.coverage,
2938
+ };
2939
+
2940
+ this.SopService.assignUpdate(payload)
2941
+ .pipe(takeUntil(this.detach))
2942
+ .subscribe({
2943
+ next: (res: any) => {
2944
+ if (res?.code == 200) {
2945
+ this.configData.added = res?.data?.added;
2946
+ this.configData.removed = res?.data?.removed;
2947
+ callback(true);
2948
+ } else {
2949
+ callback(false);
2950
+ }
2951
+ },
2952
+ error: (err: any) => {
2953
+ this.toast.getErrorToast(err);
2954
+ callback(false);
2955
+ },
2956
+ });
2957
+ }
2958
+
2959
+ // selectstore(element: any) {
2960
+ // const dialogRef = this.dialog.open(TraxStoreComponent, {
2961
+ // centered:true,size:'md'
2962
+ // });
2963
+
2964
+ // dialogRef.componentInstance.data = element;
2965
+
2966
+ // dialogRef.result.then((data: any) => {
2967
+ // if (data && data.msg == 'confirm') {
2968
+ // if (data.stores.length) {
2969
+ // let sop = data.stores;
2970
+ // let id = element.id;
2971
+ // // this.SopService.assignSopStore(sop, id).subscribe((res: any) => {
2972
+ // // if (res && res.code == 200) {
2973
+ // // element.sop_stores = data.stores;
2974
+ // // this.changedetector.detectChanges();
2975
+ // // }
2976
+ // // }, (error: any) => {
2977
+
2978
+ // // })
2979
+ // }
2980
+ // }
2981
+ // })
2982
+ // }
2983
+ newstore() {
2984
+ this.route.navigate(["/manage/stores"], {
2985
+ queryParams: { checklistid: JSON.stringify(this.obj) },
2986
+ });
2987
+ }
2988
+
2989
+ inviteuser() {
2990
+ this.route.navigate(["/control-panel/assign-role"], {
2991
+ queryParams: { checklistid: JSON.stringify(this.obj) },
2992
+ });
2993
+ }
2994
+
2995
+ updateDay() {
2996
+ return this.configData.checkListDetails.scheduleRepeatedMonthSetup == "day"
2997
+ ? this.dayjs().format("DD")
2998
+ : "";
2999
+ }
3000
+
3001
+ updateValue(event: any) {
3002
+ if (event.target.value.length != 0) {
3003
+ this.configData.checkListDetails.scheduleRepeatedMonthWeek =
3004
+ event.target.value < 9 ? "0" + event.target.value : event.target.value;
3005
+ } else {
3006
+ this.configData.checkListDetails.scheduleRepeatedMonthWeek =
3007
+ this.dayjs().format("DD");
3008
+ }
3009
+ this.changedetector.detectChanges();
3010
+ }
3011
+
3012
+ validate(event: any) {
3013
+ if (!isNaN(event.target.value)) {
3014
+ if (event.target.value[0] == 3 && event.target.value[1] > 1) {
3015
+ event.target.value = 3;
3016
+ this.configData.checkListDetails.scheduleRepeatedMonthWeek = 3;
3017
+ }
3018
+ if (event.target.value[0] > 3 && event.target.value[1] >= 0) {
3019
+ event.target.value = event.target.value[0];
3020
+ this.configData.checkListDetails.scheduleRepeatedMonthWeek =
3021
+ event.target.value[0];
3022
+ }
3023
+ if (event.target.value[0] < 1) {
3024
+ event.target.value = "";
3025
+ this.configData.checkListDetails.scheduleRepeatedMonthWeek = "";
3026
+ }
3027
+ } else {
3028
+ this.configData.checkListDetails.scheduleRepeatedMonthWeek = "";
3029
+ event.target.value = "";
3030
+ }
3031
+ }
3032
+
3033
+ savedraft() {
3034
+ if (!this.validTime) {
3035
+ this.toast.getErrorToast("Invalid Schedule End Time");
3036
+ return false;
3037
+ }
3038
+ let startDateWithTime, endDateWithTime;
3039
+ if (!this.showRangeValue) {
3040
+ this.configData.checkListDetails.configStartDate = "";
3041
+ this.configData.checkListDetails.configEndDate = "";
3042
+ }
3043
+ if (this.configData.checkListDetails.schedule != "onetime") {
3044
+ this.configData.checkListDetails.scheduleDate = "";
3045
+ }
3046
+ if (
3047
+ this.configData.checkListDetails.schedule == "monthly" &&
3048
+ this.configData.checkListDetails.scheduleRepeatedMonthSetup == "date"
3049
+ ) {
3050
+ this.configData.checkListDetails.scheduleRepeatedMonthWeek =
3051
+ this.monthDate + " " + this.monthDay;
3052
+ }
3053
+ if (
3054
+ this.configData.checkListDetails.schedule == "monthly" &&
3055
+ this.configData.checkListDetails.scheduleRepeatedMonthSetup == "specific"
3056
+ ) {
3057
+ if (this.submittedDates.length)
3058
+ this.configData.checkListDetails.specificDate = this.submittedDates;
3059
+ }
3060
+
3061
+ if (this.configData.checkListDetails.schedule == "range") {
3062
+ this.configData.checkListDetails.specificDate = this.selectedDateList;
3063
+ }
3064
+ // if (this.configData.checkListDetails.scheduleRepeatedType == 'range') {
3065
+ // let start = this.configData.checkListDetails.scheduleStartTime.split(' ');
3066
+ // let end = this.configData.checkListDetails.scheduleEndTime.split(' ');
3067
+ // startDateWithTime = start.length > 2 ? start[1] + ' ' + start[2] : this.configData.checkListDetails.scheduleStartTime;
3068
+ // endDateWithTime = end.length > 2 ? end[1] + ' ' + end[2] : this.configData.checkListDetails.scheduleEndTime;
3069
+ // this.configData.checkListDetails.scheduleStartTime = this.dayjs(this.rangeStart).format('YYYY-MM-DD') + ' ' + startDateWithTime;
3070
+ // this.configData.checkListDetails.scheduleEndTime = this.dayjs(this.rangeEnd).format('YYYY-MM-DD') + ' ' + endDateWithTime;
3071
+
3072
+ // if (this.configData.checkListDetails.scheduleStartTime > this.configData.checkListDetails.scheduleEndTime) {
3073
+ // this.configData.checkListDetails.scheduleStartTime = startDateWithTime;
3074
+ // this.configData.checkListDetails.scheduleEndTime = endDateWithTime;
3075
+ // this.toast.getErrorToast('End time must be greater than start time');
3076
+ // return false;
3077
+ // }
3078
+ // }
3079
+
3080
+ this.popupCount = this.popupCount + 1;
3081
+ this.configData.submitType = "save";
3082
+ this.configData.checkListDetails.publish = false;
3083
+ this.configData.removedUsers = this.removeUsers;
3084
+ this.configData.checkListDetails.scheduleWeekDays = this.selectedDays;
3085
+ this.configData.checkListDetails.coverage = this.coverage;
3086
+ this.configData.checkListDetails.assignedUsers = [
3087
+ ...this.singleAssign,
3088
+ ...this.groupAssign,
3089
+ ];
3090
+ this.configData.checkListDetails.storeCount =
3091
+ this.assignSingle?.length + this.groupAssign?.length;
3092
+ this.configData.checkListDetails.enableNewDeployedStore = this.storeCoverage
3093
+ ? this.configData.checkListDetails.enableNewDeployedStore
3094
+ : false;
3095
+ const timeZone = dayjs.tz.guess();
3096
+ this.configData.timeZone = timeZone;
3097
+ const popupcontent = {
3098
+ displayprop: false,
3099
+ imagesrc:
3100
+ '<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" viewBox="0 0 56 56" fill="none"><rect x="4" y="4" width="48" height="48" rx="24" fill="#FEF0C7"/><path d="M27.9998 24.0012V28.0012M27.9998 32.0012H28.0098M26.2898 18.8612L17.8198 33.0012C17.6451 33.3036 17.5527 33.6465 17.5518 33.9957C17.5508 34.3449 17.6413 34.6883 17.8142 34.9917C17.9871 35.2951 18.2365 35.5479 18.5375 35.725C18.8385 35.9021 19.1806 35.9973 19.5298 36.0012H36.4698C36.819 35.9973 37.1611 35.9021 37.4621 35.725C37.7631 35.5479 38.0124 35.2951 38.1854 34.9917C38.3583 34.6883 38.4488 34.3449 38.4478 33.9957C38.4468 33.6465 38.3544 33.3036 38.1798 33.0012L29.7098 18.8612C29.5315 18.5673 29.2805 18.3243 28.981 18.1557C28.6814 17.987 28.3435 17.8984 27.9998 17.8984C27.656 17.8984 27.3181 17.987 27.0186 18.1557C26.7191 18.3243 26.468 18.5673 26.2898 18.8612Z" stroke="#DC6803" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><rect x="4" y="4" width="48" height="48" rx="24" stroke="#FFFAEB" stroke-width="8"/></svg>',
3101
+ title: `Unsaved changes`,
3102
+ content: `Do you want to save as draft?`,
3103
+ buttontype: "draft",
3104
+ };
3105
+ const dialogRef = this.dialog.open(TraxpopupComponent, {
3106
+ centered: true,
3107
+ size: "md",
3108
+ backdrop: "static",
3109
+ });
3110
+ dialogRef.componentInstance.data = popupcontent;
3111
+ dialogRef.result.then((res) => {
3112
+ if (
3113
+ this.type == "mobileusagedetection" ||
3114
+ this.type == "storeopenandclose"
3115
+ ) {
3116
+ if (this.type == "mobileusagedetection") {
3117
+ // this.configData.checkListDetails.detectionArea = this.zones;
3118
+ }
3119
+ if (this.type == "storeopenandclose") {
3120
+ this.configData.checkListDetails.scheduleStartTime =
3121
+ this.configData.openTime;
3122
+ this.configData.checkListDetails.scheduleEndTime =
3123
+ this.configData.closeTime;
3124
+ }
3125
+ // this.configData.checkListDetails.assignedUsers = this.sopStores;
3126
+ // this.configData.checkListDetails.alert.alertsTo = this.emailList;
3127
+ }
3128
+
3129
+ if (!res) {
3130
+ this.popupCount = 0;
3131
+ }
3132
+ if (res == "confirm") {
3133
+ this.detassignUpdate((result: boolean) => {
3134
+ if (result) {
3135
+ this.configData.clientId = this.clientId;
3136
+ this.SopService.configUpdate(this.configData)
3137
+ .pipe(takeUntil(this.detach))
3138
+ .subscribe(
3139
+ (result: any) => {
3140
+ if (result && result.code == 200) {
3141
+ this.toast.getSuccessToast(
3142
+ "Draft has been saved successfully.",
3143
+ );
3144
+ this.route.navigate(["/manage/trax/checklist"]);
3145
+ }
3146
+ },
3147
+ (error: any) => {
3148
+ let err = error?.error?.error || "something went wrong";
3149
+ this.toast.getErrorToast(err);
3150
+ },
3151
+ );
3152
+ } else {
3153
+ }
3154
+ });
3155
+ }
3156
+ });
3157
+ }
3158
+
3159
+ Reupload() {
3160
+ // this.dialog.dismissAll();
3161
+ this.validatedStore = [];
3162
+ this.validatedUser = [];
3163
+ this.validatedCluster = [];
3164
+ this.validatedTeam = [];
3165
+ this.newUser = [];
3166
+ this.inactiveStores = [];
3167
+ this.showUser = false;
3168
+ this.showTeam = false;
3169
+ this.showStore = false;
3170
+ this.showCluster = false;
3171
+ this.showInactive = false;
3172
+ if (this.fileInput) {
3173
+ this.fileInput.nativeElement.value = "";
3174
+ }
3175
+ if (this.fileInput1) {
3176
+ this.fileInput1.nativeElement.value = "";
3177
+ }
3178
+ let ele = document.getElementById("kt_account_team_size_select_2");
3179
+ ele?.click();
3180
+ this.changedetector.detectChanges();
3181
+ }
3182
+
3183
+ Reupload1() {
3184
+ if (this.fileInput) {
3185
+ this.fileInput.nativeElement.value = "";
3186
+ }
3187
+ if (this.fileInput1) {
3188
+ this.fileInput1.nativeElement.value = "";
3189
+ }
3190
+ this.popupCount = this.popupCount + 1;
3191
+ const popupcontent = {
3192
+ displayprop: false,
3193
+ imagesrc: `<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" viewBox="0 0 56 56" fill="none"><rect x="4" y="4" width="48" height="48" rx="24" fill="#FEF0C7"/><path d="M27.9998 24.0012V28.0012M27.9998 32.0012H28.0098M26.2898 18.8612L17.8198 33.0012C17.6451 33.3036 17.5527 33.6465 17.5518 33.9957C17.5508 34.3449 17.6413 34.6883 17.8142 34.9917C17.9871 35.2951 18.2365 35.5479 18.5375 35.725C18.8385 35.9021 19.1806 35.9973 19.5298 36.0012H36.4698C36.819 35.9973 37.1611 35.9021 37.4621 35.725C37.7631 35.5479 38.0124 35.2951 38.1854 34.9917C38.3583 34.6883 38.4488 34.3449 38.4478 33.9957C38.4468 33.6465 38.3544 33.3036 38.1798 33.0012L29.7098 18.8612C29.5315 18.5673 29.2805 18.3243 28.981 18.1557C28.6814 17.987 28.3435 17.8984 27.9998 17.8984C27.656 17.8984 27.3181 17.987 27.0186 18.1557C26.7191 18.3243 26.468 18.5673 26.2898 18.8612Z" stroke="#DC6803" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><rect x="4" y="4" width="48" height="48" rx="24" stroke="#FFFAEB" stroke-width="8"/></svg>`,
3194
+ title: `Reupload CSV`,
3195
+ content: `Are you sure you want to replace existing data by uploading new file? Your existing data will get replaced with the new one.`,
3196
+ buttontype: "Reupload",
3197
+ };
3198
+ const dialogRef = this.dialog.open(TraxpopupComponent, {
3199
+ centered: true,
3200
+ size: "md",
3201
+ backdrop: "static",
3202
+ });
3203
+ dialogRef.componentInstance.data = popupcontent;
3204
+ dialogRef.result.then((res) => {
3205
+ if (res == "confirm") {
3206
+ this.reupload = true;
3207
+ this.changedetector.detectChanges();
3208
+ let ele = document.getElementById("kt_account_team_size_select_2");
3209
+ ele?.click();
3210
+ }
3211
+ });
3212
+ }
3213
+ // invitenewuser() {
3214
+ // this.popupCount = this.popupCount + 1;
3215
+ // const popupcontent = {
3216
+ // displayprop: false,
3217
+ // imagesrc: `<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" viewBox="0 0 56 56" fill="none"><rect x="4" y="4" width="48" height="48" rx="24" fill="#FEF0C7"/><path d="M27.9998 24.0012V28.0012M27.9998 32.0012H28.0098M26.2898 18.8612L17.8198 33.0012C17.6451 33.3036 17.5527 33.6465 17.5518 33.9957C17.5508 34.3449 17.6413 34.6883 17.8142 34.9917C17.9871 35.2951 18.2365 35.5479 18.5375 35.725C18.8385 35.9021 19.1806 35.9973 19.5298 36.0012H36.4698C36.819 35.9973 37.1611 35.9021 37.4621 35.725C37.7631 35.5479 38.0124 35.2951 38.1854 34.9917C38.3583 34.6883 38.4488 34.3449 38.4478 33.9957C38.4468 33.6465 38.3544 33.3036 38.1798 33.0012L29.7098 18.8612C29.5315 18.5673 29.2805 18.3243 28.981 18.1557C28.6814 17.987 28.3435 17.8984 27.9998 17.8984C27.656 17.8984 27.3181 17.987 27.0186 18.1557C26.7191 18.3243 26.468 18.5673 26.2898 18.8612Z" stroke="#DC6803" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><rect x="4" y="4" width="48" height="48" rx="24" stroke="#FFFAEB" stroke-width="8"/></svg>`,
3218
+ // title: `Invite new users added in CSV`,
3219
+ // content: `This CSV contains new users. Invite users by sending mail to them. <br>`,
3220
+ // buttontype: 'Invite'
3221
+ // }
3222
+ // const dialogRef = this.dialog.open(TraxpopupComponent, {
3223
+ // centered:true,size:'md'
3224
+ // });
3225
+ // dialogRef.componentInstance.data = popupcontent;
3226
+ // dialogRef.result.then((res) => {
3227
+
3228
+ // if (res == 'confirm') {
3229
+ // // this.SopService.configUpdate(this.configData).subscribe((result: any) => {
3230
+ // // // console.log(result);
3231
+
3232
+ // // if (result && result.code == 200) {
3233
+ // // Swal.fire({
3234
+ // // toast: true,
3235
+ // // iconHtml: '<img src="../../../../assets/Icons/checklist-unpublished-icon.svg">',
3236
+ // // // titleText: `Email sent succesfully`,
3237
+ // // html: `<div class="row">
3238
+ // // <div class="col-12 mt-2">
3239
+ // // <h4>CSV has been Reuploaded successfully.</h4>
3240
+ // // </div>
3241
+ // // </div>`,
3242
+ // // position: 'bottom',
3243
+ // // showConfirmButton: false,
3244
+ // // showCloseButton: true,
3245
+ // // timer: 6000,
3246
+ // // timerProgressBar: true,
3247
+ // // didOpen: (toast) => {
3248
+ // // toast.addEventListener('mouseenter', Swal.stopTimer)
3249
+ // // toast.addEventListener('mouseleave', Swal.resumeTimer)
3250
+ // // $("#kt_create_account_form_account_type_personal").val('')
3251
+ // // this.changedetector.detectChanges();
3252
+ // // }
3253
+
3254
+ // // })
3255
+
3256
+ // // // this.route.navigate(['/sop/Checklists']);
3257
+
3258
+ // // }
3259
+ // // })
3260
+ // }
3261
+ // })
3262
+
3263
+ // }
3264
+ // Addstore() {
3265
+ // this.popupCount = this.popupCount + 1;
3266
+ // const popupcontent = {
3267
+ // displayprop: false,
3268
+ // imagesrc: `<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" viewBox="0 0 56 56" fill="none"><rect x="4" y="4" width="48" height="48" rx="24" fill="#FEF0C7"/><path d="M27.9998 24.0012V28.0012M27.9998 32.0012H28.0098M26.2898 18.8612L17.8198 33.0012C17.6451 33.3036 17.5527 33.6465 17.5518 33.9957C17.5508 34.3449 17.6413 34.6883 17.8142 34.9917C17.9871 35.2951 18.2365 35.5479 18.5375 35.725C18.8385 35.9021 19.1806 35.9973 19.5298 36.0012H36.4698C36.819 35.9973 37.1611 35.9021 37.4621 35.725C37.7631 35.5479 38.0124 35.2951 38.1854 34.9917C38.3583 34.6883 38.4488 34.3449 38.4478 33.9957C38.4468 33.6465 38.3544 33.3036 38.1798 33.0012L29.7098 18.8612C29.5315 18.5673 29.2805 18.3243 28.981 18.1557C28.6814 17.987 28.3435 17.8984 27.9998 17.8984C27.656 17.8984 27.3181 17.987 27.0186 18.1557C26.7191 18.3243 26.468 18.5673 26.2898 18.8612Z" stroke="#DC6803" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><rect x="4" y="4" width="48" height="48" rx="24" stroke="#FFFAEB" stroke-width="8"/></svg>`,
3269
+ // title: `Invite new users added in CSV`,
3270
+ // content: `This CSV contains new users. Invite users by sending mail to them. <br>`,
3271
+ // subtitle: 'LKST009, ST3045',
3272
+ // buttontype: 'Addstore'
3273
+ // }
3274
+ // const dialogRef = this.dialog.open(TraxpopupComponent, {
3275
+ // centered:true,size:'md'
3276
+ // });
3277
+ // dialogRef.componentInstance.data = popupcontent;
3278
+ // dialogRef.result.then((res) => {
3279
+
3280
+ // if (res == 'confirm') {
3281
+ // // this.SopService.configUpdate(this.configData).subscribe((result: any) => {
3282
+ // // // console.log(result);
3283
+
3284
+ // // if (result && result.code == 200) {
3285
+ // // Swal.fire({
3286
+ // // toast: true,
3287
+ // // iconHtml: '<img src="../../../../assets/Icons/checklist-unpublished-icon.svg">',
3288
+ // // // titleText: `Email sent succesfully`,
3289
+ // // html: `<div class="row">
3290
+ // // <div class="col-12 mt-2">
3291
+ // // <h4>CSV has been Reuploaded successfully.</h4>
3292
+ // // </div>
3293
+ // // </div>`,
3294
+ // // position: 'bottom',
3295
+ // // showConfirmButton: false,
3296
+ // // showCloseButton: true,
3297
+ // // timer: 6000,
3298
+ // // timerProgressBar: true,
3299
+ // // didOpen: (toast) => {
3300
+ // // toast.addEventListener('mouseenter', Swal.stopTimer)
3301
+ // // toast.addEventListener('mouseleave', Swal.resumeTimer)
3302
+ // // $("#kt_create_account_form_account_type_personal").val('')
3303
+ // // this.changedetector.detectChanges();
3304
+ // // }
3305
+
3306
+ // // })
3307
+
3308
+ // // // this.route.navigate(['/sop/Checklists']);
3309
+
3310
+ // // }
3311
+ // // })
3312
+ // }
3313
+ // })
3314
+
3315
+ // }
3316
+ // addUser() {
3317
+ // this.addUserForm = !this.addUserForm;
3318
+ // }
3319
+
3320
+ // createuserPopup(type: string, record: any = null): void {
3321
+ // if (type == 'view') {
3322
+ // this.popUpTitle = "View User Details";
3323
+ // } else if (type == 'edit') {
3324
+ // this.popUpTitle = "Edit User Details";
3325
+ // } else {
3326
+ // this.popUpTitle = "Enter New User Details";
3327
+ // // this.popUpTitle = "Enter New User Details";
3328
+ // }
3329
+ // let data = {
3330
+ // record: record,
3331
+ // type: type,
3332
+ // title: this.popUpTitle
3333
+ // }
3334
+
3335
+ // const dialogRef_createUser = this.dialog.open(UploadSingleUserComponent, {
3336
+ // panelClass: 'custom-modalbox',
3337
+ // data: data
3338
+ // });
3339
+
3340
+ // dialogRef_createUser.afterClosed().subscribe((res: any) => {
3341
+ // this.showIntro = false;
3342
+ // if (!record && res && res.data.code == 200) {
3343
+ // Swal.fire({
3344
+ // icon: 'success',
3345
+ // text: 'The user invite has been sent successfully to the user and added to the platform!',
3346
+ // confirmButtonText: 'OK',
3347
+ // allowOutsideClick: false,
3348
+ // heightAuto: false
3349
+ // }).then((result) => {
3350
+ // if (result.isConfirmed) {
3351
+ // this.searchUser = ''
3352
+ // this.addUserForm = false;
3353
+ // this.currentValue = 1;
3354
+ // // this.loadRecords(0, this.size)
3355
+ // }
3356
+ // })
3357
+ // } else if (res && res.data.code == 200) {
3358
+ // Swal.fire({
3359
+ // icon: 'success',
3360
+ // text: 'User Updated Successfully!',
3361
+ // heightAuto: false
3362
+ // });
3363
+ // this.searchUser = ''
3364
+ // this.addUserForm = false;
3365
+ // this.currentValue = 1;
3366
+ // // this.loadRecords(0, this.size)
3367
+ // }
3368
+ // })
3369
+ // }
3370
+
3371
+ // createuserPopup() {
3372
+ // const dialogRef = this.dialog.open(UploadSingleUserComponent, {
3373
+ // panelClass: 'custom-modalbox'
3374
+
3375
+ // });
3376
+ // dialogRef.afterClosed()
3377
+ // .subscribe((res: any) => {
3378
+
3379
+ // })
3380
+ // }
3381
+
3382
+ // transferFormData() {
3383
+ // this.SopService.sopData.asObservable()
3384
+ // }
3385
+ saveandredirect(id: any) {
3386
+ if (
3387
+ this.type == "mobileusagedetection" ||
3388
+ this.type == "storeopenandclose"
3389
+ ) {
3390
+ if (this.type == "mobileusagedetection") {
3391
+ // this.configData.checkListDetails.detectionArea = this.zones;
3392
+ }
3393
+ if (this.type == "storeopenandclose") {
3394
+ this.configData.checkListDetails.scheduleStartTime =
3395
+ this.configData.openTime;
3396
+ this.configData.checkListDetails.scheduleEndTime =
3397
+ this.configData.closeTime;
3398
+ }
3399
+ // this.configData.checkListDetails.alert.alertsTo = this.emailList;
3400
+ }
3401
+ this.configData.submitType = "save";
3402
+ this.configData.removedUsers = this.removeUsers;
3403
+
3404
+ let startDateWithTime, endDateWithTime;
3405
+ if (!this.showRangeValue) {
3406
+ this.configData.checkListDetails.configStartDate = "";
3407
+ this.configData.checkListDetails.configEndDate = "";
3408
+ }
3409
+ if (this.configData.checkListDetails.schedule != "onetime") {
3410
+ this.configData.checkListDetails.scheduleDate = "";
3411
+ }
3412
+
3413
+ if (
3414
+ this.configData.checkListDetails.schedule == "monthly" &&
3415
+ this.configData.checkListDetails.scheduleRepeatedMonthSetup == "date"
3416
+ ) {
3417
+ this.configData.checkListDetails.scheduleRepeatedMonthWeek =
3418
+ this.monthDate + " " + this.monthDay;
3419
+ }
3420
+ if (
3421
+ this.configData.checkListDetails.schedule == "monthly" &&
3422
+ this.configData.checkListDetails.scheduleRepeatedMonthSetup == "specific"
3423
+ ) {
3424
+ if (this.submittedDates.length)
3425
+ this.configData.checkListDetails.specificDate = this.submittedDates;
3426
+ }
3427
+ if (
3428
+ this.configData.checkListDetails.schedule == "range" &&
3429
+ this.selectedDateList.length
3430
+ ) {
3431
+ this.configData.checkListDetails.specificDate = this.selectedDateList;
3432
+ }
3433
+
3434
+ this.configData.clientId = this.clientId;
3435
+
3436
+ this.SopService.configUpdate(this.configData)
3437
+ .pipe(takeUntil(this.detach))
3438
+ .subscribe(
3439
+ (result: any) => {
3440
+ if (result && result.code == 200) {
3441
+ this.route.navigate(["/manage/trax/createChecklist"], {
3442
+ queryParams: { checklistId: id },
3443
+ });
3444
+ }
3445
+ },
3446
+ (error: any) => {
3447
+ let err = error?.error?.error || "something went wrong";
3448
+ return this.toast.getErrorToast(err);
3449
+ },
3450
+ );
3451
+ }
3452
+ validateTime() {
3453
+ let startTime = this.dayjs(this.startTime, "HH:mm");
3454
+ let endTime = this.dayjs(this.endTime, "HH:mm");
3455
+ if (this.showRangeValue) {
3456
+ if (
3457
+ this.configData.checkListDetails?.configStartDate != "" &&
3458
+ this.configData.checkListDetails?.configStartDate != null &&
3459
+ this.configData.checkListDetails.configEndDate != "" &&
3460
+ this.configData.checkListDetails.configEndDate != null
3461
+ ) {
3462
+ if (
3463
+ this.configData.checkListDetails?.configStartDate ==
3464
+ this.configData.checkListDetails?.configEndDate
3465
+ ) {
3466
+ if (startTime > endTime) {
3467
+ this.validTime = false;
3468
+ // this.toast.getErrorToast('Invalid Schedule End Time');
3469
+ return false;
3470
+ } else {
3471
+ this.validTime = true;
3472
+ return true;
3473
+ }
3474
+ } else if (
3475
+ this.configData.checkListDetails.configStartDate >
3476
+ this.configData.checkListDetails.configEndDate
3477
+ ) {
3478
+ this.validTime = false;
3479
+ this.toast.getErrorToast("Invalid Schedule End Date");
3480
+ return false;
3481
+ } else {
3482
+ this.validTime = true;
3483
+ return true;
3484
+ }
3485
+ } else {
3486
+ this.validTime = true;
3487
+ return true;
3488
+ }
3489
+ } else if (startTime > endTime) {
3490
+ this.validTime = false;
3491
+ // this.toast.getErrorToast('Invalid Schedule End Time');
3492
+ return false;
3493
+ } else {
3494
+ this.validTime = true;
3495
+ return true;
3496
+ }
3497
+ }
3498
+ updateTime(data: any) {
3499
+ if (this.validateTime()) {
3500
+ if (data == "start") {
3501
+ this.configData.checkListDetails.scheduleStartTime = this.dayjs(
3502
+ this.startTime,
3503
+ "HH:mm",
3504
+ ).format("hh:mm A");
3505
+ } else {
3506
+ this.configData.checkListDetails.scheduleEndTime = this.dayjs(
3507
+ this.endTime,
3508
+ "HH:mm",
3509
+ ).format("hh:mm A");
3510
+ }
3511
+ }
3512
+ this.changedetector.detectChanges();
3513
+ }
3514
+ updateSchedule(event: any) {
3515
+ this.configData.checkListDetails.scheduleRepeatedMonthSetup = "";
3516
+ this.configData.checkListDetails.scheduleRepeatedDay = "01";
3517
+ this.selectedDays = [];
3518
+ this.submittedDates = [];
3519
+ this.selectedDate = [];
3520
+ this.selectedDateList = [];
3521
+ this.specific = false;
3522
+ this.monthDate = "";
3523
+ this.monthDay = "";
3524
+ this.showDropDown = false;
3525
+ this.showRangeValue = event.target.value == "range" ? true : false;
3526
+ if (event.target.value == "range") {
3527
+ // this.refreshPicker = false;
3528
+ this.specific = false;
3529
+ this.selectedDateList = [];
3530
+ this.configData.checkListDetails.specificDate = [];
3531
+ this.configData.checkListDetails.configStartDate =
3532
+ this.configData.checkListDetails?.configStartDate ||
3533
+ this.dayjs().format("YYYY-MM-DD");
3534
+ this.configData.checkListDetails.configEndDate =
3535
+ this.configData.checkListDetails?.configEndDate ||
3536
+ this.dayjs().add(1, "day").format("YYYY-MM-DD");
3537
+ this.selectedEndDate = {
3538
+ startDate: this.dayjs(
3539
+ this.configData.checkListDetails?.configEndDate,
3540
+ ).format("DD-MM-YYYY"),
3541
+ endDate: this.dayjs(
3542
+ this.configData.checkListDetails?.configEndDate,
3543
+ ).format("DD-MM-YYYY"),
3544
+ };
3545
+ this.minEndDate = this.dayjs(
3546
+ this.configData.checkListDetails?.configEndDate,
3547
+ ).format();
3548
+ this.selectedStartDate = {
3549
+ startDate: this.dayjs(
3550
+ this.configData.checkListDetails?.configStartDate,
3551
+ ).format("DD-MM-YYYY"),
3552
+ endDate: this.dayjs(
3553
+ this.configData.checkListDetails?.configStartDate,
3554
+ ).format("DD-MM-YYYY"),
3555
+ };
3556
+ this.minStartDate = this.dayjs(
3557
+ this.configData.checkListDetails?.configStartDate,
3558
+ ).format();
3559
+ } else {
3560
+ this.configData.checkListDetails.configStartDate = "";
3561
+ this.selectedStartDate = "";
3562
+ this.minStartDate = "";
3563
+ this.selectedEndDate = "";
3564
+ this.minEndDate = "";
3565
+ this.configData.checkListDetails.configEndDate = this.dayjs()
3566
+ .add(1, "day")
3567
+ .format("YYYY-MM-DD");
3568
+ // this.refreshPicker = false;
3569
+ }
3570
+ if (event.target.value == "weekday") {
3571
+ this.selectedDays = [
3572
+ "Monday",
3573
+ "Tuesday",
3574
+ "Wednesday",
3575
+ "Thursday",
3576
+ "Friday",
3577
+ ];
3578
+ }
3579
+ if (event.target.value == "weekly") {
3580
+ let todayDate = this.dayjs().format("dddd");
3581
+ this.selectedDays = [todayDate];
3582
+ }
3583
+ if (event.target.value == "monthly") {
3584
+ this.configData.checkListDetails.scheduleRepeatedMonthSetup = "day";
3585
+ this.configData.checkListDetails.scheduleRepeatedMonthWeek =
3586
+ this.dayjs().format("DD");
3587
+ }
3588
+ if (
3589
+ ["daily", "onetime"].includes(event.target.value) ||
3590
+ (event.target.value == "monthly" &&
3591
+ ["day", "date"].includes(
3592
+ this.configData.checkListDetails.scheduleRepeatedMonthSetup,
3593
+ ))
3594
+ ) {
3595
+ if (event.target.value == "onetime") {
3596
+ this.configData.checkListDetails.scheduleDate = this.configData
3597
+ .checkListDetails.scheduleDate
3598
+ ? this.configData.checkListDetails.scheduleDate
3599
+ : dayjs().format();
3600
+ this.selectedDates = {
3601
+ startDate: this.dayjs(
3602
+ this.configData.checkListDetails.scheduleDate,
3603
+ ).format("DD-MM-YYYY"),
3604
+ endDate: this.dayjs(
3605
+ this.configData.checkListDetails.scheduleDate,
3606
+ ).format("DD-MM-YYYY"),
3607
+ };
3608
+ this.minDate = this.dayjs().format();
3609
+ }
3610
+ this.configData.checkListDetails.allowOnce = false;
3611
+ }
3612
+ this.repeatType =
3613
+ this.configData.checkListDetails?.schedule == "daily"
3614
+ ? "Day"
3615
+ : ["weekly", "weekday"].includes(
3616
+ this.configData.checkListDetails?.schedule,
3617
+ )
3618
+ ? "Week"
3619
+ : this.configData.checkListDetails?.schedule == "monthly"
3620
+ ? "Month"
3621
+ : "";
3622
+ this.changedetector.detectChanges();
3623
+ this.validateTime();
3624
+ }
3625
+
3626
+ navigateToControlCenter() {
3627
+ this.route.navigate(["/controlcenter/templateview"], {
3628
+ queryParams: { source: "cc" },
3629
+ });
3630
+ }
3631
+
3632
+ upload: any;
3633
+
3634
+ addStoreComponent() {
3635
+ const dialogRef = this.dialog.open(TraxStoreComponent, {
3636
+ centered: true,
3637
+ size: "md",
3638
+ backdrop: "static",
3639
+ });
3640
+ dialogRef.componentInstance.data = {
3641
+ checklistId: this.checklistId,
3642
+ obj: this.obj,
3643
+ coverage: this.coverage,
3644
+ };
3645
+ dialogRef.result.then((res) => {
3646
+ if (res) {
3647
+ this.userData = res;
3648
+ this.upload = "store";
3649
+ this.validateDetails();
3650
+ }
3651
+ });
3652
+ }
3653
+ toggleDropDown() {
3654
+ this.showDropDown = !this.showDropDown;
3655
+ }
3656
+ selectDate(date: number) {
3657
+ if (this.selectedDate.includes(date)) {
3658
+ this.selectedDate = this.selectedDate.filter((day: any) => day !== date);
3659
+ } else {
3660
+ if (!this.selectedDate.includes(date)) {
3661
+ this.selectedDate.push(date);
3662
+ }
3663
+ }
3664
+ }
3665
+ submitDate() {
3666
+ this.submittedDates = [...this.selectedDate];
3667
+ }
3668
+
3669
+ removeBadge(date: number) {
3670
+ this.submittedDates = this.submittedDates.filter((d) => d !== date);
3671
+ this.selectedDate = this.selectedDate.filter((d: any) => d !== date);
3672
+ }
3673
+ getDateWithSuffix(date: number): string {
3674
+ if (date == 1 || date == 31 || date == 21) {
3675
+ return date + "st";
3676
+ } else if (date == 2 || date == 22) {
3677
+ return date + "nd";
3678
+ } else if (date == 3 || date == 23) {
3679
+ return date + "rd";
3680
+ } else {
3681
+ return date + "th";
3682
+ }
3683
+ }
3684
+
3685
+ closeDropDown() {
3686
+ this.showDropDown = false;
3687
+ }
3688
+
3689
+ updateMonth(type: any) {
3690
+ this.configData.checkListDetails.scheduleRepeatedMonthWeek = "";
3691
+ this.submittedDates = [];
3692
+ this.selectedDate = [];
3693
+ this.configData.checkListDetails.specificDate = [];
3694
+ this.configData.checkListDetails.scheduleRepeatedMonthSetup = type;
3695
+ this.monthDate = "";
3696
+ this.monthDay = "";
3697
+ this.selectedDateList = [];
3698
+ this.configData.checkListDetails.allowOnce = false;
3699
+ if (this.configData.checkListDetails.scheduleRepeatedMonthSetup == "date") {
3700
+ let dateWeek = getWeekNumber(this.dayjs());
3701
+ this.monthDate = dateWeek.toString();
3702
+ this.monthDay = this.dayjs().format("dddd");
3703
+ }
3704
+ if (this.configData.checkListDetails.scheduleRepeatedMonthSetup == "day") {
3705
+ this.configData.checkListDetails.scheduleRepeatedMonthWeek =
3706
+ this.dayjs().format("DD");
3707
+ }
3708
+ }
3709
+
3710
+ updateRepeatDay() {
3711
+ let value = this.configData.checkListDetails.scheduleRepeatedDay;
3712
+ if (isNaN(value)) {
3713
+ value = "01";
3714
+ }
3715
+ this.configData.checkListDetails.scheduleRepeatedDay =
3716
+ value == "00" || value == "0" || value == "" ? "01" : value;
3717
+ }
3718
+
3719
+ updateMonthValue() {
3720
+ let dateValue = "";
3721
+ if (this.monthDate == "1") {
3722
+ dateValue = "First";
3723
+ }
3724
+ if (this.monthDate == "2") {
3725
+ dateValue = "Second";
3726
+ }
3727
+ if (this.monthDate == "3") {
3728
+ dateValue = "Third";
3729
+ }
3730
+ if (this.monthDate == "4") {
3731
+ dateValue = "Fourth";
3732
+ }
3733
+ if (this.monthDate == "5") {
3734
+ dateValue = "Last";
3735
+ }
3736
+ return "on the " + dateValue + " " + this.monthDay;
3737
+ }
3738
+
3739
+ updateSpecificValue() {
3740
+ let value: any = [];
3741
+ this.submittedDates.forEach((item: any) => {
3742
+ item =
3743
+ item == 1 || item == 31 || item == 21
3744
+ ? item + " st"
3745
+ : item == 2 || item == 22
3746
+ ? item + " nd"
3747
+ : item == 3 || item == 23
3748
+ ? item + "rd"
3749
+ : item + " th";
3750
+ value.push(item);
3751
+ });
3752
+ return value;
3753
+ }
3754
+
3755
+ removeDate(date: any) {
3756
+ this.selectedDateList = this.selectedDateList.filter(
3757
+ (ele: any) => ele != date,
3758
+ );
3759
+ }
3760
+
3761
+ updateSceduleDate() {
3762
+ // console.log('this.configData?.checkListDetails?.configEndDate',this.configData?.checkListDetails?.configEndDate)
3763
+ if (
3764
+ this.configData?.checkListDetails?.configEndDate != "" &&
3765
+ this.configData?.checkListDetails?.configEndDate != null
3766
+ ) {
3767
+ return this.configData?.checkListDetails?.configEndDate;
3768
+ } else {
3769
+ return "";
3770
+ }
3771
+ }
3772
+
3773
+ updateDateValue(event: any) {
3774
+ if (event.target.checked) {
3775
+ this.configData.checkListDetails.configStartDate =
3776
+ this.configData.checkListDetails?.configStartDate ||
3777
+ this.dayjs().format("YYYY-MM-DD");
3778
+ this.configData.checkListDetails.configEndDate = "";
3779
+ } else {
3780
+ this.configData.checkListDetails.configStartDate = "";
3781
+ this.configData.checkListDetails.configEndDate = "";
3782
+ }
3783
+ this.selectedEndDate = "";
3784
+ this.minDate = "";
3785
+ // this.selectedDate = [];
3786
+ this.selectedStartDate = {
3787
+ startDate: this.dayjs(
3788
+ this.configData.checkListDetails?.configStartDate,
3789
+ ).format("DD-MM-YYYY"),
3790
+ endDate: this.dayjs(
3791
+ this.configData.checkListDetails?.configStartDate,
3792
+ ).format("DD-MM-YYYY"),
3793
+ };
3794
+ this.minStartDate = this.dayjs(
3795
+ this.configData.checkListDetails?.configStartDate,
3796
+ ).format();
3797
+ }
3798
+
3799
+ updateSpecific(event: any) {
3800
+ if (!event.target.checked) {
3801
+ this.selectedDateList = [];
3802
+ }
3803
+ }
3804
+
3805
+ onDatepickerRefresh() {
3806
+ this.configData.checkListDetails.configEndDate = "";
3807
+ this.selectedEndDate = "";
3808
+ this.minEndDate = this.dayjs(
3809
+ this.configData.checkListDetails.configStartDate,
3810
+ ).format();
3811
+ }
3812
+
3813
+ selectSpecificDate(event: any) {
3814
+ this.showDropDown = false;
3815
+ this.selectedDateList = event;
3816
+ }
3817
+
3818
+ @HostListener("document:click", ["$event"])
3819
+ clickOutside(event: MouseEvent): void {
3820
+ const clickedInside = (event.target as HTMLElement).closest(
3821
+ ".dropdown-close",
3822
+ );
3823
+ // console.log(clickedInside);
3824
+
3825
+ if (!clickedInside) {
3826
+ this.closeDropDown();
3827
+ }
3828
+ }
3829
+
3830
+ getClientUser() {
3831
+ this.SopService.getClientUser(this.clientId)
3832
+ .pipe(takeUntil(this.detach))
3833
+ .subscribe((res: any) => {
3834
+ if (res && res.code == 200 && res.data.length) {
3835
+ this.alertUsers = res.data.map((item: any) => {
3836
+ return { name: item.userName, value: item.email, role: item.role };
3837
+ });
3838
+
3839
+ // this.adminUsers = this.alertUsers.filter((ele:any) => ele.role != 'user');
3840
+
3841
+ if (!this.configData?.checkListDetails?.approver?.length) {
3842
+ this.approve = true;
3843
+ let userInfo = JSON.parse(
3844
+ localStorage.getItem("user-info") || "{}",
3845
+ );
3846
+ if (userInfo.userType) {
3847
+ this.userType = userInfo.userType;
3848
+ }
3849
+ if (
3850
+ userInfo?.userType == "tango" ||
3851
+ (userInfo?.userType == "client" && userInfo?.role == "user")
3852
+ ) {
3853
+ let userList = this.alertUsers.find(
3854
+ (ele: any) => ele.role == "superadmin",
3855
+ );
3856
+ if (userList && this.type == "custom") {
3857
+ this.configData.checkListDetails.approver = [
3858
+ { name: userList.name, value: userList.value },
3859
+ ];
3860
+ }
3861
+ } else {
3862
+ this.configData.checkListDetails.approver = [
3863
+ this.alertUsers.find((ele: any) => ele.value == userInfo.email),
3864
+ ];
3865
+ }
3866
+ }
3867
+ } else {
3868
+ this.alertUsers = [];
3869
+ }
3870
+ });
3871
+ }
3872
+
3873
+ getZoneList() {
3874
+ this.SopService.getZoneList({
3875
+ clientId: this.clientId,
3876
+ checkListName: this.configData.checkListName,
3877
+ })
3878
+ .pipe(takeUntil(this.detach))
3879
+ .subscribe((res: any) => {
3880
+ if (res && res.code == 200) {
3881
+ this.zoneList = res.data.map((item: any) => {
3882
+ return { name: item.zone, value: item.zone };
3883
+ });
3884
+ } else {
3885
+ this.zoneList = [];
3886
+ }
3887
+ });
3888
+ }
3889
+
3890
+ getTeamList() {
3891
+ this.SopService.getTeamList(this.clientId)
3892
+ .pipe(takeUntil(this.detach))
3893
+ .subscribe((res: any) => {
3894
+ if (res && res.code == 200) {
3895
+ this.alertTeams = res.data.map((item: any) => {
3896
+ return { name: item.teamName, value: item._id };
3897
+ });
3898
+ } else {
3899
+ this.alertTeams = [];
3900
+ }
3901
+ });
3902
+ }
3903
+
3904
+ updateAlert(event: any, type: any) {
3905
+ if (type == "user") {
3906
+ this.configData.aiConfig.alerts.users = event;
3907
+ } else if (type == "approve") {
3908
+ this.configData.approver = event;
3909
+ }
3910
+ }
3911
+
3912
+ updateZone(event: any) {
3913
+ this.configData.aiConfig.mobileDetection.detectionArea = event;
3914
+ }
3915
+
3916
+ updateLoop() {
3917
+ let data = this.minutes.filter(
3918
+ (item) => !this.configData.checkListDetails.remainder.includes(item),
3919
+ );
3920
+ this.configData.checkListDetails.remainder.push(data[0]);
3921
+ }
3922
+
3923
+ updateRemainder(event: any, index: any) {
3924
+ this.configData.checkListDetails.remainder[index] = parseInt(
3925
+ event.target.value,
3926
+ );
3927
+ }
3928
+
3929
+ updateApprover(event: any) {
3930
+ this.configData.checkListDetails.approver = event;
3931
+ }
3932
+
3933
+ updateOwner(event: any) {
3934
+ this.configData.checkListDetails.owner = event;
3935
+ }
3936
+
3937
+ updateAssign(event: any) {
3938
+ this.upload = "";
3939
+ this.currentValue = 1;
3940
+ this.configData.checkListDetails.assign = event;
3941
+ // this.tableArray = event;
3942
+ let data = event.map((el: any) => {
3943
+ return { id: el?._id, type: el?.type };
3944
+ });
3945
+ this.idList = data;
3946
+ this.tableFilter = "";
3947
+ this.assignType === "store" || this.assignType === "user"
3948
+ ? ((this.singleAssign = this.idList), this.getTableData())
3949
+ : ((this.groupAssign = this.idList), this.userDetailsV2(event));
3950
+ }
3951
+
3952
+ removedChip(event: any) {
3953
+ this.tableArray = this.tableArray?.filter(
3954
+ (item: any) => !event.includes(item._id),
3955
+ );
3956
+ this.configData.checkListDetails.assign =
3957
+ this.configData.checkListDetails.assign?.filter(
3958
+ (item: any) => !event.includes(item._id),
3959
+ );
3960
+ // (this.assignType === 'store' || this.assignType === 'user') ? this.getTableData() :this.userDetailsV2();
3961
+ }
3962
+
3963
+ tableArray: any = [];
3964
+ tableLoading1: boolean = true;
3965
+
3966
+ userDetailsV2(data?: any) {
3967
+ const payload = {
3968
+ checklistId: this.checklistId,
3969
+ idList: this.idList,
3970
+ coverage: this.coverage, //["cluster","store","user","teams"]
3971
+ clientId: this.clientId,
3972
+ search: this.tableFilter,
3973
+ };
3974
+ this.tableLoading = true;
3975
+ this.tableLoading1 = true;
3976
+ this.showImage = true;
3977
+ this.tableArray = [];
3978
+ this.tableData = [];
3979
+ this.SopService.selectChips(payload)
3980
+ .pipe(takeUntil(this.detach))
3981
+ .subscribe({
3982
+ next: (res: any) => {
3983
+ if (res && res?.code === 200) {
3984
+ this.tableLoading = false;
3985
+ this.tableLoading1 = false;
3986
+ this.tableArray = res?.data?.uniqueArr;
3987
+ this.assignGroup = this.tableArray;
3988
+ this.recordsTotal = res.data.count;
3989
+ this.recordsCount = this.tableData.length;
3990
+ this.tableArray?.length
3991
+ ? (this.showImage = false)
3992
+ : (this.showImage = true);
3993
+ if (this.recordsTotal < 5) {
3994
+ this.paginationSize = [this.recordsTotal];
3995
+ this.size = this.recordsTotal;
3996
+ } else {
3997
+ this.paginationSize = [5, 10, 15, 20];
3998
+ this.size = 5;
3999
+ }
4000
+ this.tableData = this.tableArray.slice(
4001
+ this.currentValue * this.size - this.size,
4002
+ this.currentValue * this.size,
4003
+ );
4004
+ } else {
4005
+ this.tableArray = [];
4006
+ this.tableData = [];
4007
+ this.showImage = true;
4008
+ this.tableLoading = true;
4009
+ }
4010
+ // this.storeCoverage ? this.getInitialData(res?.data?.storeList) : this.getInitialData(res?.data?.userList);
4011
+ },
4012
+ error: (err: any) => {
4013
+ this.tableLoading = false;
4014
+ this.tableLoading1 = false;
4015
+ this.showImage = false;
4016
+ this.tableArray = [];
4017
+ this.tableData = [];
4018
+ this.toast.getErrorToast(err?.message);
4019
+ },
4020
+ });
4021
+ }
4022
+
4023
+ sortColumn: any = "";
4024
+ sortBy: any = -1;
4025
+
4026
+ gettableData() {
4027
+ const payload = {
4028
+ checklistId: this.checklistId,
4029
+ limit: this.size,
4030
+ offset: 0,
4031
+ search: this.tableFilter,
4032
+ clientId: this.clientId,
4033
+ sortColumn: this.sortColumn,
4034
+ sortBy: this.sortBy,
4035
+ coverage: this.coverage,
4036
+ };
4037
+ this.tableData = [];
4038
+ this.SopService.getUserDetailsV2(payload)
4039
+ .pipe(takeUntil(this.detach))
4040
+ .subscribe({
4041
+ next: (res: any) => {
4042
+ if (res && res?.code === 200) {
4043
+ this.disableBtn = false;
4044
+ this.showImage = false;
4045
+ this.tableData = res?.data?.users;
4046
+ this.recordsCount = this.tableData.length;
4047
+ this.recordsTotal = res.data.count;
4048
+ if (this.recordsTotal < 5) {
4049
+ this.paginationSize = [this.recordsTotal];
4050
+ this.size = this.recordsTotal;
4051
+ } else {
4052
+ this.paginationSize = [5, 10, 15, 20];
4053
+ this.size = 5;
4054
+ }
4055
+ }
4056
+ this.storeCoverage
4057
+ ? this.getInitialData(res?.data?.storeList)
4058
+ : this.getInitialData(res?.data?.userList);
4059
+ },
4060
+ error: (err: any) => {
4061
+ this.disableBtn = false;
4062
+ this.toast.getErrorToast(err?.message);
4063
+ },
4064
+ });
4065
+ }
4066
+
4067
+ updateHuddletime(event: Event, key: any) {
4068
+ // let sampleObject:any;
4069
+ // if (key === 'time') {
4070
+ // const selectedTime = (event.target as HTMLInputElement).value;
4071
+ // sampleObject.startTime = selectedTime;
4072
+ // } else if (key === 'duration') {
4073
+ // }
4074
+ // console.log('duration',this.huddleattimeArray)
4075
+ }
4076
+
4077
+ deleteHuddle(i: any) {
4078
+ this.configData?.aiConfig?.events.splice(i, 1);
4079
+ }
4080
+
4081
+ AddHuddleEent() {
4082
+ let sampleObject = { time: this.dayjs().format("HH:mm"), duration: "15" };
4083
+ this.configData?.aiConfig?.events?.length < 3
4084
+ ? this.configData?.aiConfig?.events.push(sampleObject)
4085
+ : "";
4086
+ }
4087
+
4088
+ updateConfigRemainder(event: any) {
4089
+ if (!event.target.checked) {
4090
+ this.configData.checkListDetails.remainder = [];
4091
+ } else {
4092
+ this.configData.checkListDetails.remainder = [this.minutes[0]];
4093
+ }
4094
+ }
4095
+ updateConfigApprover(event: any) {
4096
+ if (!event.target.checked) {
4097
+ this.configData.checkListDetails.approver = [];
4098
+ } else {
4099
+ let userInfo = JSON.parse(localStorage.getItem("user-info") || "{}");
4100
+ if (
4101
+ userInfo?.userType == "tango" ||
4102
+ (userInfo?.userType == "client" && userInfo?.role == "user")
4103
+ ) {
4104
+ this.configData.checkListDetails.approver = [
4105
+ this.alertUsers.find((ele: any) => ele.role == "superadmin"),
4106
+ ];
4107
+ } else {
4108
+ this.configData.checkListDetails.approver = [
4109
+ this.alertUsers.find((ele: any) => ele.value == userInfo.email),
4110
+ ];
4111
+ }
4112
+ }
4113
+ }
4114
+
4115
+ updateTimeLoop(index: any) {
4116
+ let data = JSON.parse(
4117
+ JSON.stringify(this.configData.checkListDetails.remainder),
4118
+ );
4119
+ if (data.length) {
4120
+ data.splice(index, 1);
4121
+ }
4122
+ return this.minutes.filter((item: any) =>
4123
+ data.length ? !data?.includes(item) : item,
4124
+ );
4125
+ }
4126
+
4127
+ bulkuploadModel() {
4128
+ this.dropDown = false;
4129
+ this.dialog.open(this.bulkupload, {
4130
+ centered: true,
4131
+ backdrop: "static",
4132
+ });
4133
+ }
4134
+
4135
+ emailBulkuploadModel() {
4136
+ this.dropDown = false;
4137
+ this.dialog.open(this.emailBulkupload, {
4138
+ centered: true,
4139
+ backdrop: "static",
4140
+ });
4141
+ }
4142
+
4143
+ excelError: any;
4144
+
4145
+ afterUplload(data?: any) {
4146
+ this.excelError = data;
4147
+ this.dialog.open(this.afterValidation, {
4148
+ centered: true,
4149
+ backdrop: "static",
4150
+ });
4151
+ }
4152
+
4153
+ getInitials(name: string): string {
4154
+ if (!name) return ""; // Handle empty case
4155
+ const [firstName, lastName] = name.split(" ");
4156
+ if (!lastName) {
4157
+ const initials = (firstName?.[0] || "") + (firstName?.[1] || "");
4158
+ return initials.toUpperCase();
4159
+ } else {
4160
+ const initials = (firstName?.[0] || "") + (lastName?.[0] || "");
4161
+ return initials.toUpperCase();
4162
+ }
4163
+ }
4164
+
4165
+ confirmUserpopup() {
4166
+ const dialogRef = this.dialog.open(this.confirmUser, {
4167
+ centered: true,
4168
+ backdrop: "static",
4169
+ });
4170
+ dialogRef.closed.subscribe((res: any) => {
4171
+ if (res === "confirm") {
4172
+ this.validateDetails("addUser");
4173
+ }
4174
+ });
4175
+ }
4176
+
4177
+ onDragLeave(event: DragEvent) {
4178
+ event.preventDefault();
4179
+ (event.target as HTMLElement).classList.remove("drag-over");
4180
+ }
4181
+
4182
+ onDragOver(event: DragEvent) {
4183
+ event.preventDefault();
4184
+ event.stopPropagation();
4185
+ // Add a visual effect to indicate drag is over the area
4186
+ (event.target as HTMLElement).classList.add("drag-over");
4187
+ }
4188
+
4189
+ onDrop(event: DragEvent) {
4190
+ event.preventDefault();
4191
+ (event.target as HTMLElement).classList.remove("drag-over");
4192
+
4193
+ if (event.dataTransfer?.files.length) {
4194
+ const file = event.dataTransfer.files[0];
4195
+ const fileInputElement = this.fileInput.nativeElement;
4196
+
4197
+ // Manually set the file to the input
4198
+ const dataTransfer = new DataTransfer();
4199
+ dataTransfer.items.add(file);
4200
+ fileInputElement.files = dataTransfer.files;
4201
+
4202
+ // Trigger the change event manually
4203
+ fileInputElement.dispatchEvent(new Event("change"));
4204
+ }
4205
+ }
4206
+
4207
+ removeAlphapet(event: any) {
4208
+ if (isNaN(event.target.value)) {
4209
+ event.target.value = "01";
4210
+ this.configData.checkListDetails.scheduleRepeatedDay = "01";
4211
+ }
4212
+ }
4213
+
4214
+ preopentimeconfig: any;
4215
+ changePreopentimeconfig(event: any) {
4216
+ this.preopentimeconfig = event.target.checked;
4217
+ if (!this.preopentimeconfig) {
4218
+ this.configData.aiConfig.outsidebusinesshoursqueuetracking.preopentimeconfig =
4219
+ "";
4220
+ }
4221
+ }
4222
+
4223
+ preclosetimeconfig: any;
4224
+ changePreclosetimeconfig(event: any) {
4225
+ this.preclosetimeconfig = event.target.checked;
4226
+ if (!this.preclosetimeconfig) {
4227
+ this.configData.aiConfig.outsidebusinesshoursqueuetracking.preclosetimeconfig =
4228
+ "";
4229
+ }
4230
+ }
4231
+
4232
+ changealerttimeconfig(event: any) {
4233
+ this.alerttimekeyconfig = event.target.checked;
4234
+ this.configData.aiConfig.alertConfig.allowBuffer.enabled =
4235
+ event.target.checked || false;
4236
+ if (!this.alerttimekeyconfig) {
4237
+ // this.configData.aiConfig.alertConfig.allowBuffer.afterOpenTime = '';
4238
+ // this.configData.aiConfig.alertConfig.allowBuffer.beforeCloseTime = '';
4239
+ }
4240
+ }
4241
+
4242
+ changenotificationconfig(event: any) {
4243
+ this.notificationkeyconfig = event.target.checked;
4244
+ this.configData.aiConfig.alertConfig.alertSendTo.enabled =
4245
+ event.target.checked || false;
4246
+ if (!this.notificationkeyconfig) {
4247
+ this.configData.aiConfig.alertConfig.alertSendTo.web = [];
4248
+ this.configData.aiConfig.alertConfig.alertSendTo.mobile = [];
4249
+ this.configData.aiConfig.alertConfig.alertSendTo.syncMobileWeb = false;
4250
+ this.configData.aiConfig.alertConfig.alertSendTo.email.type = [];
4251
+ this.configData.aiConfig.alertConfig.alertSendTo.email.users = [];
4252
+ this.configData.aiConfig.alertConfig.alertSendTo.email.teams = [];
4253
+ }
4254
+ }
4255
+
4256
+ changeautotaskconfig(event: any) {
4257
+ this.autotaskkeyconfig = event.target.checked;
4258
+ this.configData.aiConfig.autoTaskConfig.enabled =
4259
+ event.target.checked || false;
4260
+ if (!this.autotaskkeyconfig) {
4261
+ // this.configData.aiConfig.autoTaskConfig.approver = [];
4262
+ }
4263
+ }
4264
+ changequeuelengthconfig(event: any) {
4265
+ this.queueLengthEnabled = event.target.checked;
4266
+ console.log(
4267
+ "🚀 ~ ChecklistConfigureComponent ~ changequeuelengthconfig ~ this.queueLengthEnabled:",
4268
+ this.queueLengthEnabled,
4269
+ );
4270
+
4271
+ this.configData.aiConfig.queuealert.queueLengthEnabled =
4272
+ event.target.checked || false;
4273
+ }
4274
+ cameraAngleconfig(event: any) {
4275
+ this.cameraAngleEnabled = event.target.checked;
4276
+ console.log(
4277
+ "🚀 ~ ChecklistConfigureComponent ~ changequeuelengthconfig ~ this.queueLengthEnabled:",
4278
+ this.cameraAngleEnabled,
4279
+ );
4280
+
4281
+ this.configData.aiConfig.camerAngle.enabled = event.target.checked || false;
4282
+ }
4283
+ changequeuewaittimeconfig(event: any) {
4284
+ this.waitTimeEnabled = event.target.checked;
4285
+ this.configData.aiConfig.queuealert.waitTimeEnabled =
4286
+ event.target.checked || false;
4287
+ }
4288
+
4289
+ changealertcooldownconfig(event: any) {
4290
+ this.alertCooldownEnabled = event.target.checked;
4291
+ if (this.type === 'staffgrouping') {
4292
+ if (!this.configData.aiConfig.staffGrouping) {
4293
+ this.configData.aiConfig.staffGrouping = {};
4294
+ }
4295
+ this.configData.aiConfig.staffGrouping.alertCooldownEnabled =
4296
+ event.target.checked || false;
4297
+ } else {
4298
+ if (!this.configData.aiConfig.queuealert) {
4299
+ this.configData.aiConfig.queuealert = {};
4300
+ }
4301
+ this.configData.aiConfig.queuealert.alertCooldownEnabled =
4302
+ event.target.checked || false;
4303
+ }
4304
+ }
4305
+
4306
+ changeexportconfig(event: any) {
4307
+ this.exportkeyconfig = event.target.checked;
4308
+ this.configData.aiConfig.exportConfig.enabled =
4309
+ event.target.checked || false;
4310
+ if (!this.exportkeyconfig) {
4311
+ // this.configData.aiConfig.exportConfig.format = [];
4312
+ }
4313
+ }
4314
+
4315
+ changedetectedstatusconfig(event: any) {
4316
+ this.detectedstatuskeyconfig = event.target.checked;
4317
+ this.configData.aiConfig.advancedConfig.detectedStatus.enabled =
4318
+ event.target.checked || false;
4319
+ if (!this.detectedstatuskeyconfig) {
4320
+ // this.configData.aiConfig.advancedConfig.detectedStatus.detections = [];
4321
+ }
4322
+ }
4323
+
4324
+ changeauditrequiredconfig(event: any) {
4325
+ this.auditkeyconfig = event.target.checked;
4326
+ this.configData.aiConfig.advancedConfig.auditConfig.enabled =
4327
+ event.target.checked || false;
4328
+ if (!this.auditkeyconfig) {
4329
+ // this.configData.aiConfig.advancedConfig.auditConfig.inputSourceFile = '';
4330
+ }
4331
+ }
4332
+
4333
+ changesyncMobileWebconfig(event: any) {
4334
+ this.configData.aiConfig.alertConfig.alertSendTo.syncMobileWeb =
4335
+ event.target.checked || false;
4336
+ if (this.configData.aiConfig.alertConfig.alertSendTo.syncMobileWeb) {
4337
+ this.configData.aiConfig.alertConfig.alertSendTo.web = this.mergeUnique(
4338
+ [
4339
+ ...this.configData.aiConfig.alertConfig.alertSendTo.web,
4340
+ ...this.configData.aiConfig.alertConfig.alertSendTo.mobile,
4341
+ ],
4342
+ "name",
4343
+ );
4344
+ }
4345
+ }
4346
+
4347
+ // updateNotificationAlert(event: any,type:any,option:any) {
4348
+ // if (type == 'user') {
4349
+ // if (option == 'web') {
4350
+ // this.configData.aiConfig.alertConfig.alertSendTo.web = [...event];
4351
+ // }else if (option == 'mobile') {
4352
+ // this.configData.aiConfig.alertConfig.alertSendTo.mobile = [...event];
4353
+ // if(this.configData.aiConfig.alertConfig.alertSendTo.syncMobileWeb){
4354
+ // this.configData.aiConfig.alertConfig.alertSendTo.web = [...event];
4355
+ // }
4356
+ // }
4357
+ // } else if (type == 'approve') {
4358
+ // this.configData.approver = event;
4359
+ // }
4360
+ // }
4361
+
4362
+ // private mergeUnique(targetArr: any[], newItems: any | any[]): any[] {
4363
+ // const arr = Array.isArray(newItems) ? newItems : [newItems];
4364
+ // // merge arrays
4365
+ // const merged = [...targetArr, ...arr];
4366
+ // // remove duplicates by "value"
4367
+ // const unique = Array.from(
4368
+ // new Map(merged.map(item => [item.value, item])).values()
4369
+ // );
4370
+ // return unique;
4371
+ // }
4372
+
4373
+ updateNotificationAlert(event: any, type: any, option: any) {
4374
+ if (type === "user") {
4375
+ if (option === "web") {
4376
+ this.configData.aiConfig.alertConfig.alertSendTo.web = this.mergeUnique(
4377
+ [...this.configData.aiConfig.alertConfig.alertSendTo.web, ...event],
4378
+ "name",
4379
+ );
4380
+ } else if (option === "mobile") {
4381
+ this.configData.aiConfig.alertConfig.alertSendTo.mobile =
4382
+ this.mergeUnique(
4383
+ [
4384
+ ...this.configData.aiConfig.alertConfig.alertSendTo.mobile,
4385
+ ...event,
4386
+ ],
4387
+ "name",
4388
+ );
4389
+
4390
+ if (this.configData.aiConfig.alertConfig.alertSendTo.syncMobileWeb) {
4391
+ this.configData.aiConfig.alertConfig.alertSendTo.web =
4392
+ this.mergeUnique(
4393
+ [
4394
+ ...this.configData.aiConfig.alertConfig.alertSendTo.web,
4395
+ ...event,
4396
+ ],
4397
+ "name",
4398
+ );
4399
+ }
4400
+ }
4401
+ } else if (type === "approve") {
4402
+ this.configData.approver = event;
4403
+ }
4404
+ }
4405
+
4406
+ private mergeUnique(arr: any, key: string) {
4407
+ return [...new Map(arr.map((obj: any) => [obj[key], obj])).values()];
4408
+ }
4409
+
4410
+ updateAutoTask(event: any, type: any) {
4411
+ if (type == "user") {
4412
+ this.configData.aiConfig.autoTaskConfig.approver = event;
4413
+ this.configData.approver = event;
4414
+ }
4415
+ }
4416
+
4417
+ changeInputSourceFileRadio(data: any) {
4418
+ this.configData.aiConfig.advancedConfig.auditConfig.inputSourceFile = data;
4419
+ }
4420
+
4421
+ changeDetectionStatus(event: Event) {
4422
+ const input = event.target as HTMLInputElement;
4423
+ const value = input.value;
4424
+
4425
+ if (input.checked) {
4426
+ if (!this.selectedDetectionStatus.includes(value)) {
4427
+ this.selectedDetectionStatus.push(value);
4428
+ this.configData.aiConfig.advancedConfig.detectedStatus.detections =
4429
+ this.selectedDetectionStatus;
4430
+ }
4431
+ } else {
4432
+ if (this.selectedDetectionStatus.length > 0) {
4433
+ this.selectedDetectionStatus = this.selectedDetectionStatus.filter(
4434
+ (item: any) => item !== value,
4435
+ );
4436
+ }
4437
+ }
4438
+ }
4439
+
4440
+ changeDataprocessing(data: any) {
4441
+ this.configData.aiConfig.advancedConfig.dataProcessing = data;
4442
+ }
4443
+
4444
+ changeExportValue(event: any) {
4445
+ const input = event.target as HTMLInputElement;
4446
+ const value = input.value;
4447
+ const allValue = ["ALL", "CSV", "PDF", "PPT", "ZIP"];
4448
+ const requiredValues = ["CSV", "PDF", "PPT", "ZIP"];
4449
+ if (value == "ALL") {
4450
+ if (event.target.checked) {
4451
+ this.selectedExportConfig = allValue;
4452
+ this.configData.aiConfig.exportConfig.format =
4453
+ this.selectedExportConfig;
4454
+ } else {
4455
+ this.selectedExportConfig = [];
4456
+ this.configData.aiConfig.exportConfig.format =
4457
+ this.selectedExportConfig;
4458
+ }
4459
+ } else {
4460
+ // how to remove only 'ALL' value
4461
+ if (this.selectedExportConfig.includes("ALL")) {
4462
+ this.selectedExportConfig = this.selectedExportConfig.filter(
4463
+ (item) => item !== "ALL",
4464
+ );
4465
+ this.configData.aiConfig.exportConfig.format =
4466
+ this.selectedExportConfig;
4467
+ }
4468
+ if (input.checked) {
4469
+ if (!this.selectedExportConfig.includes(value)) {
4470
+ this.selectedExportConfig.push(value);
4471
+ if (
4472
+ requiredValues.every((val) =>
4473
+ this.selectedExportConfig.includes(val),
4474
+ )
4475
+ ) {
4476
+ if (!this.selectedExportConfig.includes("ALL")) {
4477
+ this.selectedExportConfig.push("ALL");
4478
+ }
4479
+ }
4480
+ this.configData.aiConfig.exportConfig.format =
4481
+ this.selectedExportConfig;
4482
+ }
4483
+ } else {
4484
+ if (this.selectedExportConfig.length > 0) {
4485
+ this.selectedExportConfig = this.selectedExportConfig.filter(
4486
+ (item: any) => item !== value,
4487
+ );
4488
+ this.configData.aiConfig.exportConfig.format =
4489
+ this.selectedExportConfig;
4490
+ }
4491
+ }
4492
+ }
4493
+ }
4494
+
4495
+ updateNotify(event: any, type: string) {
4496
+ if (!this.configData.checkListDetails?.notifyFlags) {
4497
+ this.configData.checkListDetails["notifyFlags"] = {
4498
+ notifyType: [],
4499
+ users: [],
4500
+ };
4501
+ }
4502
+ if (event.target.checked) {
4503
+ this.configData.checkListDetails.notifyFlags.notifyType.push(type);
4504
+ } else {
4505
+ this.configData.checkListDetails.notifyFlags.notifyType =
4506
+ this.configData.checkListDetails.notifyFlags.notifyType.filter(
4507
+ (ele: any) => ele != type,
4508
+ );
4509
+ }
4510
+ }
4511
+
4512
+ onNotifyFlagToggle() {
4513
+ if (this.notifyFlag) return;
4514
+ this.configData.checkListDetails.notifyFlags.notifyType = [];
4515
+ this.configData.checkListDetails.notifyFlags.users = [];
4516
+ }
4517
+
4518
+ onEnableEmailToggle() {
4519
+ if (this.enableEmail) return;
4520
+ this.configData.checkListDetails.autoEmail.type = [];
4521
+ this.configData.checkListDetails.autoEmail.users = [];
4522
+ }
4523
+
4524
+ onRecurringFlagToggle() {
4525
+ if (this.recurringFlagNotify) return;
4526
+ this.configData.checkListDetails.recurringFlag.notifyType = [];
4527
+ this.configData.checkListDetails.recurringFlag.users = [];
4528
+ this.configData.checkListDetails.recurringFlag.threshold = 2;
4529
+ }
4530
+
4531
+ updateMailer(event: any, type: string) {
4532
+ console.log(this.configData.aiConfig?.alertConfig?.alertSendTo);
4533
+ if (!this.configData.aiConfig?.alertConfig?.alertSendTo?.email) {
4534
+ this.configData.aiConfig.alertConfig.alertSendTo["email"] = {
4535
+ type: [],
4536
+ users: [],
4537
+ teams: [],
4538
+ };
4539
+ }
4540
+ if (event.target.checked) {
4541
+ this.configData.aiConfig.alertConfig.alertSendTo.email.type.push(type);
4542
+ } else {
4543
+ this.configData.aiConfig.alertConfig.alertSendTo.email.type =
4544
+ this.configData.aiConfig.alertConfig.alertSendTo.email.type.filter(
4545
+ (ele: any) => ele != type,
4546
+ );
4547
+ }
4548
+ }
4549
+
4550
+ updateNotifier(event: any) {
4551
+ this.configData.checkListDetails.notifyFlags.users = event;
4552
+ }
4553
+
4554
+ updateRecurringNotify(event: any, type: string) {
4555
+ if (!this.configData.checkListDetails?.recurringFlag) {
4556
+ this.configData.checkListDetails["recurringFlag"] = {
4557
+ notifyType: [],
4558
+ users: [],
4559
+ threshold: 3,
4560
+ };
4561
+ }
4562
+ if (event.target.checked) {
4563
+ this.configData.checkListDetails.recurringFlag.notifyType.push(type);
4564
+ } else {
4565
+ this.configData.checkListDetails.recurringFlag.notifyType =
4566
+ this.configData.checkListDetails.recurringFlag.notifyType.filter(
4567
+ (ele: any) => ele != type,
4568
+ );
4569
+ }
4570
+ }
4571
+
4572
+ updateRecurringFlagUsers(event: any) {
4573
+ if (!this.configData.checkListDetails?.recurringFlag) {
4574
+ this.configData.checkListDetails["recurringFlag"] = {
4575
+ notifyType: [],
4576
+ users: [],
4577
+ threshold: 3,
4578
+ };
4579
+ }
4580
+ this.configData.checkListDetails.recurringFlag.users = event;
4581
+ }
4582
+
4583
+ updateRecurringThreshold(value: any) {
4584
+ if (!this.configData.checkListDetails?.recurringFlag) {
4585
+ this.configData.checkListDetails["recurringFlag"] = {
4586
+ notifyType: [],
4587
+ users: [],
4588
+ threshold: 2,
4589
+ };
4590
+ }
4591
+ this.configData.checkListDetails.recurringFlag.threshold = Number(value);
4592
+ }
4593
+
4594
+ updateAutoEmail(event: any, type: string) {
4595
+ if (!this.configData.checkListDetails?.autoEmail) {
4596
+ this.configData.checkListDetails["autoEmail"] = {
4597
+ type: [],
4598
+ users: [],
4599
+ };
4600
+ }
4601
+ if (event.target.checked) {
4602
+ this.configData.checkListDetails.autoEmail.type.push(type);
4603
+ } else {
4604
+ this.configData.checkListDetails.autoEmail.type =
4605
+ this.configData.checkListDetails.autoEmail.type.filter(
4606
+ (ele: any) => ele != type,
4607
+ );
4608
+ }
4609
+ }
4610
+
4611
+ updateEmailer(event: any) {
4612
+ this.configData.checkListDetails.autoEmail.users = event;
4613
+ }
4614
+
4615
+ updateEmailUsers(event: any) {
4616
+ this.configData.aiConfig.alertConfig.alertSendTo.email.users = event;
4617
+ }
4618
+
4619
+ updateEmailTeams(event: any) {
4620
+ this.configData.aiConfig.alertConfig.alertSendTo.email.teams = event;
4621
+ }
4622
+
4623
+ updateAutoTaskUsers(event: any) {
4624
+ this.configData.aiConfig.autoTaskConfig.users = event;
4625
+ }
4626
+
4627
+ updateTimeSlot(event: any) {
4628
+ this.configData.aiConfig.autoTaskConfig.taskValidity.time = 1;
4629
+ if (event.target.value == "mins") {
4630
+ this.timeSlot = Array.from({ length: 60 }, (_, i) => i + 1);
4631
+ } else if (event.target.value == "hours") {
4632
+ this.timeSlot = Array.from({ length: 24 }, (_, i) => i + 1);
4633
+ } else {
4634
+ this.timeSlot = Array.from({ length: 3 }, (_, i) => i + 1);
4635
+ }
4636
+ }
4637
+
4638
+ updateRecurrence(event: any, type: string) {
4639
+ if (event.target.checked) {
4640
+ this.recurrenceType = type;
4641
+ this.recurrencetime = null;
4642
+ }
4643
+ }
4644
+ }
4645
+
4646
+ function getWeekNumber(date: any) {
4647
+ let days = [];
4648
+ let dateDat = dayjs(date).startOf('month');
4649
+
4650
+ while (dateDat.month() === date.month()) {
4651
+ if (dateDat.format('dddd') === date.format('dddd')) {
4652
+ days.push(dateDat.format('YYYY-MM-DD'));
4653
+ }
4654
+ dateDat = dateDat.add(1, 'day');
4655
+ }
4656
+
4657
+ let findIndex = days.findIndex((item: any) => item == date.format('YYYY-MM-DD'))
4658
+ return (findIndex + 1);
4659
+ }