tango-app-ui-shared 3.7.3-dev6-demo7 → 3.7.3-dev6-demo8

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 (402) hide show
  1. package/esm2022/lib/guards/auth.guard.mjs +26 -0
  2. package/esm2022/lib/guards/lead.guard.mjs +16 -0
  3. package/esm2022/lib/guards/stores.guard.mjs +16 -0
  4. package/esm2022/lib/guards/tickets.guard.mjs +16 -0
  5. package/esm2022/lib/i18n/index.mjs +3 -0
  6. package/esm2022/lib/i18n/translation.module.mjs +17 -0
  7. package/esm2022/lib/i18n/translation.service.mjs +53 -0
  8. package/esm2022/lib/i18n/vocabs/ch.mjs +106 -0
  9. package/esm2022/lib/i18n/vocabs/de.mjs +106 -0
  10. package/esm2022/lib/i18n/vocabs/en.mjs +106 -0
  11. package/esm2022/lib/i18n/vocabs/es.mjs +106 -0
  12. package/esm2022/lib/i18n/vocabs/fr.mjs +106 -0
  13. package/esm2022/lib/i18n/vocabs/jp.mjs +106 -0
  14. package/esm2022/lib/interceptors/http-auth-interceptor.mjs +124 -0
  15. package/esm2022/lib/interfaces/global-state.mjs +2 -0
  16. package/esm2022/lib/modules/common/common-shared.module.mjs +31 -0
  17. package/esm2022/lib/modules/common/custom-select/custom-select.component.mjs +155 -0
  18. package/esm2022/lib/modules/common/filters/filters.component.mjs +179 -0
  19. package/esm2022/lib/modules/common/pagination/pagination.component.mjs +49 -0
  20. package/esm2022/lib/modules/errors/error403/error403.component.mjs +33 -0
  21. package/esm2022/lib/modules/errors/error404/error404.component.mjs +44 -0
  22. package/esm2022/lib/modules/errors/error500/error500.component.mjs +45 -0
  23. package/esm2022/lib/modules/errors/errors-routing.module.mjs +48 -0
  24. package/esm2022/lib/modules/errors/errors.component.mjs +39 -0
  25. package/esm2022/lib/modules/errors/errors.module.mjs +37 -0
  26. package/esm2022/lib/modules/errors/invalid-ip/invalid-ip.component.mjs +44 -0
  27. package/esm2022/lib/modules/intro/contact-support/contact-support.component.mjs +19 -0
  28. package/esm2022/lib/modules/intro/intro-routing.module.mjs +24 -0
  29. package/esm2022/lib/modules/intro/intro.module.mjs +32 -0
  30. package/esm2022/lib/modules/intro/lead-intro/lead-intro.component.mjs +110 -0
  31. package/esm2022/lib/modules/layout/components/csm-assign-confirmation/csm-assign-confirmation.component.mjs +31 -0
  32. package/esm2022/lib/modules/layout/content/content.component.mjs +107 -0
  33. package/esm2022/lib/modules/layout/footer/footer.component.mjs +17 -0
  34. package/esm2022/lib/modules/layout/header/header-menu/header-menu.component.mjs +41 -0
  35. package/esm2022/lib/modules/layout/header/header.component.mjs +100 -0
  36. package/esm2022/lib/modules/layout/header/navbar/navbar.component.mjs +256 -0
  37. package/esm2022/lib/modules/layout/header/notifications-inner/notifications-inner.component.mjs +79 -0
  38. package/esm2022/lib/modules/layout/header/page-title/page-title.component.mjs +56 -0
  39. package/esm2022/lib/modules/layout/keenicon/icons.json +1 -0
  40. package/esm2022/lib/modules/layout/keenicon/keenicon.component.mjs +37 -0
  41. package/esm2022/lib/modules/layout/layout/layout.component.mjs +314 -0
  42. package/esm2022/lib/modules/layout/layout.module.mjs +198 -0
  43. package/esm2022/lib/modules/layout/scripts-init/scripts-init.component.mjs +74 -0
  44. package/esm2022/lib/modules/layout/scroll-top/scroll-top.component.mjs +74 -0
  45. package/esm2022/lib/modules/layout/sidebar/sidebar-footer/sidebar-footer.component.mjs +159 -0
  46. package/esm2022/lib/modules/layout/sidebar/sidebar-logo/sidebar-logo.component.mjs +45 -0
  47. package/esm2022/lib/modules/layout/sidebar/sidebar-menu/sidebar-menu.component.mjs +122 -0
  48. package/esm2022/lib/modules/layout/sidebar/sidebar.component.mjs +134 -0
  49. package/esm2022/lib/modules/layout/toolbar/accounting/accounting.component.mjs +16 -0
  50. package/esm2022/lib/modules/layout/toolbar/classic/classic.component.mjs +331 -0
  51. package/esm2022/lib/modules/layout/toolbar/client-settings/client-settings.component.mjs +88 -0
  52. package/esm2022/lib/modules/layout/toolbar/date-single-select/date-single-select.component.mjs +207 -0
  53. package/esm2022/lib/modules/layout/toolbar/datepicker/datepicker.component.mjs +158 -0
  54. package/esm2022/lib/modules/layout/toolbar/extended/extended.component.mjs +15 -0
  55. package/esm2022/lib/modules/layout/toolbar/metrics-header/metrics-header.component.mjs +1321 -0
  56. package/esm2022/lib/modules/layout/toolbar/reports/reports.component.mjs +18 -0
  57. package/esm2022/lib/modules/layout/toolbar/saas/saas.component.mjs +18 -0
  58. package/esm2022/lib/modules/layout/toolbar/single-clientstore-date/single-clientstore-date.component.mjs +216 -0
  59. package/esm2022/lib/modules/layout/toolbar/single-store/single-store.component.mjs +178 -0
  60. package/esm2022/lib/modules/layout/toolbar/single-storedate/single-storedate.component.mjs +166 -0
  61. package/esm2022/lib/modules/layout/toolbar/storesingle/storesingle.component.mjs +105 -0
  62. package/esm2022/lib/modules/layout/toolbar/toolbar.component.mjs +372 -0
  63. package/esm2022/lib/modules/layout/toolbar/traffic-header/traffic-header/traffic-header.component.mjs +1062 -0
  64. package/esm2022/lib/modules/layout/toolbar/traffic-nob/traffic-nob.component.mjs +795 -0
  65. package/esm2022/lib/modules/layout/toolbar/trax-header/trax-header.component.mjs +880 -0
  66. package/esm2022/lib/modules/layout/toolbar/trax-withoutdate/trax-withoutdate.component.mjs +729 -0
  67. package/esm2022/lib/modules/layout/toolbar/zone-header/zone-header.component.mjs +1100 -0
  68. package/esm2022/lib/modules/notification/conformation/conformation.component.mjs +22 -0
  69. package/esm2022/lib/modules/notification/notification/notification.component.mjs +317 -0
  70. package/esm2022/lib/modules/notification/notification-routing.module.mjs +28 -0
  71. package/esm2022/lib/modules/notification/notification.module.mjs +32 -0
  72. package/esm2022/lib/pipes/customDate.pipe.mjs +22 -0
  73. package/esm2022/lib/routes/route-wraper-modules/edge-wrapper.module.mjs +18 -0
  74. package/esm2022/lib/routes/route-wraper-modules/manage-wrapper.module.mjs +18 -0
  75. package/esm2022/lib/routes/route-wraper-modules/profile-wrapper.module.mjs +18 -0
  76. package/esm2022/lib/routes/route-wraper-modules/store-wrapper.module.mjs +18 -0
  77. package/esm2022/lib/routes/route-wraper-modules/ticket-wrapper.module.mjs +18 -0
  78. package/esm2022/lib/routes/routing.mjs +53 -0
  79. package/esm2022/lib/services/auth.service.mjs +141 -0
  80. package/esm2022/lib/services/notification.service.mjs +74 -0
  81. package/esm2022/lib/services/toast.service.mjs +83 -0
  82. package/esm2022/public-api.mjs +56 -0
  83. package/esm2022/tango-app-ui-shared.mjs +5 -0
  84. package/fesm2022/tango-app-ui-shared-edge-wrapper.module-CFDk0tvS.mjs +21 -0
  85. package/fesm2022/tango-app-ui-shared-edge-wrapper.module-CFDk0tvS.mjs.map +1 -0
  86. package/fesm2022/tango-app-ui-shared-intro.module-DYh4ZRha.mjs +188 -0
  87. package/fesm2022/tango-app-ui-shared-intro.module-DYh4ZRha.mjs.map +1 -0
  88. package/fesm2022/tango-app-ui-shared-manage-wrapper.module-BHyh4Njw.mjs +21 -0
  89. package/fesm2022/tango-app-ui-shared-manage-wrapper.module-BHyh4Njw.mjs.map +1 -0
  90. package/fesm2022/tango-app-ui-shared-notification.module-C5ZmCf8U.mjs +400 -0
  91. package/fesm2022/tango-app-ui-shared-notification.module-C5ZmCf8U.mjs.map +1 -0
  92. package/fesm2022/tango-app-ui-shared-profile-wrapper.module-BNC1AGOk.mjs +21 -0
  93. package/fesm2022/tango-app-ui-shared-profile-wrapper.module-BNC1AGOk.mjs.map +1 -0
  94. package/fesm2022/tango-app-ui-shared-store-wrapper.module-DdaCYHdv.mjs +21 -0
  95. package/fesm2022/tango-app-ui-shared-store-wrapper.module-DdaCYHdv.mjs.map +1 -0
  96. package/fesm2022/tango-app-ui-shared-ticket-wrapper.module-r32uKkDO.mjs +21 -0
  97. package/fesm2022/tango-app-ui-shared-ticket-wrapper.module-r32uKkDO.mjs.map +1 -0
  98. package/fesm2022/tango-app-ui-shared.mjs +12450 -0
  99. package/fesm2022/tango-app-ui-shared.mjs.map +1 -0
  100. package/index.d.ts +5 -0
  101. package/lib/guards/auth.guard.d.ts +10 -0
  102. package/lib/guards/lead.guard.d.ts +2 -0
  103. package/lib/guards/stores.guard.d.ts +2 -0
  104. package/lib/guards/tickets.guard.d.ts +2 -0
  105. package/{src/lib/i18n/index.ts → lib/i18n/index.d.ts} +2 -2
  106. package/lib/i18n/translation.module.d.ts +8 -0
  107. package/lib/i18n/translation.service.d.ts +19 -0
  108. package/lib/i18n/vocabs/ch.d.ts +104 -0
  109. package/lib/i18n/vocabs/de.d.ts +104 -0
  110. package/lib/i18n/vocabs/en.d.ts +104 -0
  111. package/lib/i18n/vocabs/es.d.ts +104 -0
  112. package/lib/i18n/vocabs/fr.d.ts +104 -0
  113. package/lib/i18n/vocabs/jp.d.ts +104 -0
  114. package/lib/interceptors/http-auth-interceptor.d.ts +19 -0
  115. package/lib/interfaces/global-state.d.ts +5 -0
  116. package/lib/modules/common/common-shared.module.d.ts +13 -0
  117. package/lib/modules/common/custom-select/custom-select.component.d.ts +33 -0
  118. package/lib/modules/common/filters/filters.component.d.ts +38 -0
  119. package/lib/modules/common/pagination/pagination.component.d.ts +18 -0
  120. package/lib/modules/errors/error403/error403.component.d.ts +14 -0
  121. package/lib/modules/errors/error404/error404.component.d.ts +15 -0
  122. package/lib/modules/errors/error500/error500.component.d.ts +15 -0
  123. package/lib/modules/errors/errors-routing.module.d.ts +7 -0
  124. package/lib/modules/errors/errors.component.d.ts +13 -0
  125. package/lib/modules/errors/errors.module.d.ts +13 -0
  126. package/lib/modules/errors/invalid-ip/invalid-ip.component.d.ts +17 -0
  127. package/lib/modules/intro/contact-support/contact-support.component.d.ts +9 -0
  128. package/lib/modules/intro/intro-routing.module.d.ts +7 -0
  129. package/lib/modules/intro/intro.module.d.ts +11 -0
  130. package/lib/modules/intro/lead-intro/lead-intro.component.d.ts +31 -0
  131. package/lib/modules/layout/components/csm-assign-confirmation/csm-assign-confirmation.component.d.ts +13 -0
  132. package/lib/modules/layout/content/content.component.d.ts +25 -0
  133. package/lib/modules/layout/footer/footer.component.d.ts +8 -0
  134. package/lib/modules/layout/header/header-menu/header-menu.component.d.ts +18 -0
  135. package/lib/modules/layout/header/header.component.d.ts +30 -0
  136. package/lib/modules/layout/header/navbar/navbar.component.d.ts +45 -0
  137. package/lib/modules/layout/header/notifications-inner/notifications-inner.component.d.ts +25 -0
  138. package/lib/modules/layout/header/page-title/page-title.component.d.ts +23 -0
  139. package/lib/modules/layout/keenicon/keenicon.component.d.ts +13 -0
  140. package/lib/modules/layout/layout/layout.component.d.ts +82 -0
  141. package/lib/modules/layout/layout.module.d.ts +50 -0
  142. package/lib/modules/layout/scripts-init/scripts-init.component.d.ts +19 -0
  143. package/lib/modules/layout/scroll-top/scroll-top.component.d.ts +19 -0
  144. package/lib/modules/layout/sidebar/sidebar-footer/sidebar-footer.component.d.ts +45 -0
  145. package/lib/modules/layout/sidebar/sidebar-logo/sidebar-logo.component.d.ts +19 -0
  146. package/lib/modules/layout/sidebar/sidebar-menu/sidebar-menu.component.d.ts +26 -0
  147. package/lib/modules/layout/sidebar/sidebar.component.d.ts +36 -0
  148. package/lib/modules/layout/toolbar/accounting/accounting.component.d.ts +8 -0
  149. package/lib/modules/layout/toolbar/classic/classic.component.d.ts +48 -0
  150. package/lib/modules/layout/toolbar/client-settings/client-settings.component.d.ts +16 -0
  151. package/lib/modules/layout/toolbar/date-single-select/date-single-select.component.d.ts +28 -0
  152. package/lib/modules/layout/toolbar/datepicker/datepicker.component.d.ts +28 -0
  153. package/lib/modules/layout/toolbar/extended/extended.component.d.ts +8 -0
  154. package/lib/modules/layout/toolbar/metrics-header/metrics-header.component.d.ts +103 -0
  155. package/lib/modules/layout/toolbar/reports/reports.component.d.ts +9 -0
  156. package/lib/modules/layout/toolbar/saas/saas.component.d.ts +9 -0
  157. package/lib/modules/layout/toolbar/single-clientstore-date/single-clientstore-date.component.d.ts +32 -0
  158. package/lib/modules/layout/toolbar/single-store/single-store.component.d.ts +33 -0
  159. package/lib/modules/layout/toolbar/single-storedate/single-storedate.component.d.ts +34 -0
  160. package/lib/modules/layout/toolbar/storesingle/storesingle.component.d.ts +24 -0
  161. package/lib/modules/layout/toolbar/toolbar.component.d.ts +57 -0
  162. package/lib/modules/layout/toolbar/traffic-header/traffic-header/traffic-header.component.d.ts +93 -0
  163. package/lib/modules/layout/toolbar/traffic-nob/traffic-nob.component.d.ts +80 -0
  164. package/lib/modules/layout/toolbar/trax-header/trax-header.component.d.ts +83 -0
  165. package/lib/modules/layout/toolbar/trax-withoutdate/trax-withoutdate.component.d.ts +74 -0
  166. package/lib/modules/layout/toolbar/zone-header/zone-header.component.d.ts +97 -0
  167. package/lib/modules/notification/conformation/conformation.component.d.ts +10 -0
  168. package/lib/modules/notification/notification/notification.component.d.ts +63 -0
  169. package/lib/modules/notification/notification-routing.module.d.ts +7 -0
  170. package/lib/modules/notification/notification.module.d.ts +11 -0
  171. package/lib/pipes/customDate.pipe.d.ts +7 -0
  172. package/lib/routes/route-wraper-modules/edge-wrapper.module.d.ts +7 -0
  173. package/lib/routes/route-wraper-modules/manage-wrapper.module.d.ts +7 -0
  174. package/lib/routes/route-wraper-modules/profile-wrapper.module.d.ts +7 -0
  175. package/lib/routes/route-wraper-modules/store-wrapper.module.d.ts +7 -0
  176. package/lib/routes/route-wraper-modules/ticket-wrapper.module.d.ts +7 -0
  177. package/lib/routes/routing.d.ts +3 -0
  178. package/lib/services/auth.service.d.ts +49 -0
  179. package/lib/services/notification.service.d.ts +30 -0
  180. package/lib/services/toast.service.d.ts +10 -0
  181. package/package.json +25 -12
  182. package/{src/public-api.ts → public-api.d.ts} +44 -71
  183. package/.eslintrc.json +0 -37
  184. package/ng-package.json +0 -7
  185. package/src/lib/guards/auth.guard.ts +0 -20
  186. package/src/lib/guards/lead.guard.ts +0 -16
  187. package/src/lib/guards/stores.guard.ts +0 -16
  188. package/src/lib/guards/tickets.guard.ts +0 -16
  189. package/src/lib/i18n/translation.module.ts +0 -9
  190. package/src/lib/i18n/translation.service.ts +0 -61
  191. package/src/lib/i18n/vocabs/ch.ts +0 -105
  192. package/src/lib/i18n/vocabs/de.ts +0 -105
  193. package/src/lib/i18n/vocabs/en.ts +0 -105
  194. package/src/lib/i18n/vocabs/es.ts +0 -105
  195. package/src/lib/i18n/vocabs/fr.ts +0 -105
  196. package/src/lib/i18n/vocabs/jp.ts +0 -105
  197. package/src/lib/interceptors/http-auth-interceptor.ts +0 -225
  198. package/src/lib/interfaces/global-state.ts +0 -6
  199. package/src/lib/modules/common/common-shared.module.ts +0 -20
  200. package/src/lib/modules/common/custom-select/custom-select.component.html +0 -42
  201. package/src/lib/modules/common/custom-select/custom-select.component.scss +0 -131
  202. package/src/lib/modules/common/custom-select/custom-select.component.spec.ts +0 -23
  203. package/src/lib/modules/common/custom-select/custom-select.component.ts +0 -149
  204. package/src/lib/modules/common/filters/filters.component.html +0 -76
  205. package/src/lib/modules/common/filters/filters.component.scss +0 -131
  206. package/src/lib/modules/common/filters/filters.component.spec.ts +0 -23
  207. package/src/lib/modules/common/filters/filters.component.ts +0 -181
  208. package/src/lib/modules/common/pagination/pagination.component.html +0 -26
  209. package/src/lib/modules/common/pagination/pagination.component.scss +0 -63
  210. package/src/lib/modules/common/pagination/pagination.component.spec.ts +0 -23
  211. package/src/lib/modules/common/pagination/pagination.component.ts +0 -46
  212. package/src/lib/modules/errors/error403/error403.component.html +0 -25
  213. package/src/lib/modules/errors/error403/error403.component.scss +0 -0
  214. package/src/lib/modules/errors/error403/error403.component.spec.ts +0 -23
  215. package/src/lib/modules/errors/error403/error403.component.ts +0 -28
  216. package/src/lib/modules/errors/error404/error404.component.html +0 -24
  217. package/src/lib/modules/errors/error404/error404.component.scss +0 -0
  218. package/src/lib/modules/errors/error404/error404.component.spec.ts +0 -25
  219. package/src/lib/modules/errors/error404/error404.component.ts +0 -50
  220. package/src/lib/modules/errors/error500/error500.component.html +0 -24
  221. package/src/lib/modules/errors/error500/error500.component.scss +0 -0
  222. package/src/lib/modules/errors/error500/error500.component.spec.ts +0 -25
  223. package/src/lib/modules/errors/error500/error500.component.ts +0 -50
  224. package/src/lib/modules/errors/errors-routing.module.ts +0 -40
  225. package/src/lib/modules/errors/errors.component.html +0 -15
  226. package/src/lib/modules/errors/errors.component.scss +0 -4
  227. package/src/lib/modules/errors/errors.component.spec.ts +0 -25
  228. package/src/lib/modules/errors/errors.component.ts +0 -42
  229. package/src/lib/modules/errors/errors.module.ts +0 -25
  230. package/src/lib/modules/errors/invalid-ip/invalid-ip.component.html +0 -16
  231. package/src/lib/modules/errors/invalid-ip/invalid-ip.component.scss +0 -0
  232. package/src/lib/modules/errors/invalid-ip/invalid-ip.component.spec.ts +0 -23
  233. package/src/lib/modules/errors/invalid-ip/invalid-ip.component.ts +0 -43
  234. package/src/lib/modules/intro/contact-support/contact-support.component.html +0 -30
  235. package/src/lib/modules/intro/contact-support/contact-support.component.scss +0 -60
  236. package/src/lib/modules/intro/contact-support/contact-support.component.spec.ts +0 -23
  237. package/src/lib/modules/intro/contact-support/contact-support.component.ts +0 -17
  238. package/src/lib/modules/intro/intro-routing.module.ts +0 -16
  239. package/src/lib/modules/intro/intro.module.ts +0 -21
  240. package/src/lib/modules/intro/lead-intro/lead-intro.component.html +0 -325
  241. package/src/lib/modules/intro/lead-intro/lead-intro.component.scss +0 -185
  242. package/src/lib/modules/intro/lead-intro/lead-intro.component.spec.ts +0 -23
  243. package/src/lib/modules/intro/lead-intro/lead-intro.component.ts +0 -120
  244. package/src/lib/modules/layout/components/csm-assign-confirmation/csm-assign-confirmation.component.html +0 -44
  245. package/src/lib/modules/layout/components/csm-assign-confirmation/csm-assign-confirmation.component.scss +0 -28
  246. package/src/lib/modules/layout/components/csm-assign-confirmation/csm-assign-confirmation.component.spec.ts +0 -23
  247. package/src/lib/modules/layout/components/csm-assign-confirmation/csm-assign-confirmation.component.ts +0 -24
  248. package/src/lib/modules/layout/content/content.component.html +0 -12
  249. package/src/lib/modules/layout/content/content.component.scss +0 -0
  250. package/src/lib/modules/layout/content/content.component.ts +0 -102
  251. package/src/lib/modules/layout/footer/footer.component.html +0 -29
  252. package/src/lib/modules/layout/footer/footer.component.scss +0 -7
  253. package/src/lib/modules/layout/footer/footer.component.spec.ts +0 -25
  254. package/src/lib/modules/layout/footer/footer.component.ts +0 -13
  255. package/src/lib/modules/layout/header/header-menu/header-menu.component.html +0 -27
  256. package/src/lib/modules/layout/header/header-menu/header-menu.component.scss +0 -4
  257. package/src/lib/modules/layout/header/header-menu/header-menu.component.spec.ts +0 -25
  258. package/src/lib/modules/layout/header/header-menu/header-menu.component.ts +0 -38
  259. package/src/lib/modules/layout/header/header.component.html +0 -90
  260. package/src/lib/modules/layout/header/header.component.scss +0 -7
  261. package/src/lib/modules/layout/header/header.component.spec.ts +0 -25
  262. package/src/lib/modules/layout/header/header.component.ts +0 -139
  263. package/src/lib/modules/layout/header/navbar/navbar.component.html +0 -156
  264. package/src/lib/modules/layout/header/navbar/navbar.component.scss +0 -223
  265. package/src/lib/modules/layout/header/navbar/navbar.component.spec.ts +0 -23
  266. package/src/lib/modules/layout/header/navbar/navbar.component.ts +0 -255
  267. package/src/lib/modules/layout/header/notifications-inner/notifications-inner.component.html +0 -200
  268. package/src/lib/modules/layout/header/notifications-inner/notifications-inner.component.scss +0 -139
  269. package/src/lib/modules/layout/header/notifications-inner/notifications-inner.component.ts +0 -76
  270. package/src/lib/modules/layout/header/page-title/page-title.component.html +0 -32
  271. package/src/lib/modules/layout/header/page-title/page-title.component.scss +0 -11
  272. package/src/lib/modules/layout/header/page-title/page-title.component.ts +0 -47
  273. package/src/lib/modules/layout/keenicon/icons.json +0 -1
  274. package/src/lib/modules/layout/keenicon/keenicon.component.html +0 -4
  275. package/src/lib/modules/layout/keenicon/keenicon.component.scss +0 -0
  276. package/src/lib/modules/layout/keenicon/keenicon.component.spec.ts +0 -23
  277. package/src/lib/modules/layout/keenicon/keenicon.component.ts +0 -30
  278. package/src/lib/modules/layout/layout/layout.component.html +0 -71
  279. package/src/lib/modules/layout/layout/layout.component.scss +0 -23
  280. package/src/lib/modules/layout/layout/layout.component.ts +0 -425
  281. package/src/lib/modules/layout/layout.module.ts +0 -129
  282. package/src/lib/modules/layout/scripts-init/scripts-init.component.html +0 -0
  283. package/src/lib/modules/layout/scripts-init/scripts-init.component.ts +0 -81
  284. package/src/lib/modules/layout/scroll-top/scroll-top.component.html +0 -1
  285. package/src/lib/modules/layout/scroll-top/scroll-top.component.ts +0 -75
  286. package/src/lib/modules/layout/sidebar/sidebar-footer/sidebar-footer.component.html +0 -70
  287. package/src/lib/modules/layout/sidebar/sidebar-footer/sidebar-footer.component.scss +0 -57
  288. package/src/lib/modules/layout/sidebar/sidebar-footer/sidebar-footer.component.spec.ts +0 -23
  289. package/src/lib/modules/layout/sidebar/sidebar-footer/sidebar-footer.component.ts +0 -136
  290. package/src/lib/modules/layout/sidebar/sidebar-logo/sidebar-logo.component.html +0 -26
  291. package/src/lib/modules/layout/sidebar/sidebar-logo/sidebar-logo.component.scss +0 -0
  292. package/src/lib/modules/layout/sidebar/sidebar-logo/sidebar-logo.component.spec.ts +0 -23
  293. package/src/lib/modules/layout/sidebar/sidebar-logo/sidebar-logo.component.ts +0 -36
  294. package/src/lib/modules/layout/sidebar/sidebar-menu/sidebar-menu.component.html +0 -761
  295. package/src/lib/modules/layout/sidebar/sidebar-menu/sidebar-menu.component.scss +0 -38
  296. package/src/lib/modules/layout/sidebar/sidebar-menu/sidebar-menu.component.spec.ts +0 -23
  297. package/src/lib/modules/layout/sidebar/sidebar-menu/sidebar-menu.component.ts +0 -130
  298. package/src/lib/modules/layout/sidebar/sidebar.component.html +0 -16
  299. package/src/lib/modules/layout/sidebar/sidebar.component.scss +0 -3
  300. package/src/lib/modules/layout/sidebar/sidebar.component.spec.ts +0 -23
  301. package/src/lib/modules/layout/sidebar/sidebar.component.ts +0 -203
  302. package/src/lib/modules/layout/toolbar/accounting/accounting.component.html +0 -84
  303. package/src/lib/modules/layout/toolbar/accounting/accounting.component.scss +0 -0
  304. package/src/lib/modules/layout/toolbar/accounting/accounting.component.spec.ts +0 -23
  305. package/src/lib/modules/layout/toolbar/accounting/accounting.component.ts +0 -14
  306. package/src/lib/modules/layout/toolbar/classic/classic.component.html +0 -69
  307. package/src/lib/modules/layout/toolbar/classic/classic.component.scss +0 -238
  308. package/src/lib/modules/layout/toolbar/classic/classic.component.spec.ts +0 -23
  309. package/src/lib/modules/layout/toolbar/classic/classic.component.ts +0 -389
  310. package/src/lib/modules/layout/toolbar/client-settings/client-settings.component.html +0 -4
  311. package/src/lib/modules/layout/toolbar/client-settings/client-settings.component.scss +0 -3
  312. package/src/lib/modules/layout/toolbar/client-settings/client-settings.component.spec.ts +0 -23
  313. package/src/lib/modules/layout/toolbar/client-settings/client-settings.component.ts +0 -91
  314. package/src/lib/modules/layout/toolbar/date-single-select/date-single-select.component.html +0 -22
  315. package/src/lib/modules/layout/toolbar/date-single-select/date-single-select.component.scss +0 -156
  316. package/src/lib/modules/layout/toolbar/date-single-select/date-single-select.component.spec.ts +0 -23
  317. package/src/lib/modules/layout/toolbar/date-single-select/date-single-select.component.ts +0 -238
  318. package/src/lib/modules/layout/toolbar/datepicker/datepicker.component.html +0 -14
  319. package/src/lib/modules/layout/toolbar/datepicker/datepicker.component.scss +0 -149
  320. package/src/lib/modules/layout/toolbar/datepicker/datepicker.component.spec.ts +0 -23
  321. package/src/lib/modules/layout/toolbar/datepicker/datepicker.component.ts +0 -183
  322. package/src/lib/modules/layout/toolbar/extended/extended.component.html +0 -100
  323. package/src/lib/modules/layout/toolbar/extended/extended.component.scss +0 -0
  324. package/src/lib/modules/layout/toolbar/extended/extended.component.spec.ts +0 -23
  325. package/src/lib/modules/layout/toolbar/extended/extended.component.ts +0 -12
  326. package/src/lib/modules/layout/toolbar/metrics-header/metrics-header.component.html +0 -311
  327. package/src/lib/modules/layout/toolbar/metrics-header/metrics-header.component.scss +0 -311
  328. package/src/lib/modules/layout/toolbar/metrics-header/metrics-header.component.spec.ts +0 -23
  329. package/src/lib/modules/layout/toolbar/metrics-header/metrics-header.component.ts +0 -1555
  330. package/src/lib/modules/layout/toolbar/reports/reports.component.html +0 -62
  331. package/src/lib/modules/layout/toolbar/reports/reports.component.scss +0 -0
  332. package/src/lib/modules/layout/toolbar/reports/reports.component.spec.ts +0 -23
  333. package/src/lib/modules/layout/toolbar/reports/reports.component.ts +0 -14
  334. package/src/lib/modules/layout/toolbar/saas/saas.component.html +0 -77
  335. package/src/lib/modules/layout/toolbar/saas/saas.component.scss +0 -0
  336. package/src/lib/modules/layout/toolbar/saas/saas.component.spec.ts +0 -23
  337. package/src/lib/modules/layout/toolbar/saas/saas.component.ts +0 -14
  338. package/src/lib/modules/layout/toolbar/single-clientstore-date/single-clientstore-date.component.html +0 -26
  339. package/src/lib/modules/layout/toolbar/single-clientstore-date/single-clientstore-date.component.scss +0 -176
  340. package/src/lib/modules/layout/toolbar/single-clientstore-date/single-clientstore-date.component.spec.ts +0 -23
  341. package/src/lib/modules/layout/toolbar/single-clientstore-date/single-clientstore-date.component.ts +0 -235
  342. package/src/lib/modules/layout/toolbar/single-store/single-store.component.html +0 -39
  343. package/src/lib/modules/layout/toolbar/single-store/single-store.component.scss +0 -176
  344. package/src/lib/modules/layout/toolbar/single-store/single-store.component.spec.ts +0 -23
  345. package/src/lib/modules/layout/toolbar/single-store/single-store.component.ts +0 -188
  346. package/src/lib/modules/layout/toolbar/single-storedate/single-storedate.component.html +0 -17
  347. package/src/lib/modules/layout/toolbar/single-storedate/single-storedate.component.scss +0 -172
  348. package/src/lib/modules/layout/toolbar/single-storedate/single-storedate.component.spec.ts +0 -23
  349. package/src/lib/modules/layout/toolbar/single-storedate/single-storedate.component.ts +0 -179
  350. package/src/lib/modules/layout/toolbar/storesingle/storesingle.component.html +0 -4
  351. package/src/lib/modules/layout/toolbar/storesingle/storesingle.component.scss +0 -19
  352. package/src/lib/modules/layout/toolbar/storesingle/storesingle.component.spec.ts +0 -23
  353. package/src/lib/modules/layout/toolbar/storesingle/storesingle.component.ts +0 -105
  354. package/src/lib/modules/layout/toolbar/toolbar.component.html +0 -64
  355. package/src/lib/modules/layout/toolbar/toolbar.component.scss +0 -0
  356. package/src/lib/modules/layout/toolbar/toolbar.component.spec.ts +0 -25
  357. package/src/lib/modules/layout/toolbar/toolbar.component.ts +0 -400
  358. package/src/lib/modules/layout/toolbar/traffic-header/traffic-header/traffic-header.component.html +0 -259
  359. package/src/lib/modules/layout/toolbar/traffic-header/traffic-header/traffic-header.component.scss +0 -305
  360. package/src/lib/modules/layout/toolbar/traffic-header/traffic-header/traffic-header.component.spec.ts +0 -23
  361. package/src/lib/modules/layout/toolbar/traffic-header/traffic-header/traffic-header.component.ts +0 -1202
  362. package/src/lib/modules/layout/toolbar/traffic-nob/traffic-nob.component.html +0 -199
  363. package/src/lib/modules/layout/toolbar/traffic-nob/traffic-nob.component.scss +0 -311
  364. package/src/lib/modules/layout/toolbar/traffic-nob/traffic-nob.component.spec.ts +0 -23
  365. package/src/lib/modules/layout/toolbar/traffic-nob/traffic-nob.component.ts +0 -899
  366. package/src/lib/modules/layout/toolbar/trax-header/trax-header.component.html +0 -204
  367. package/src/lib/modules/layout/toolbar/trax-header/trax-header.component.scss +0 -311
  368. package/src/lib/modules/layout/toolbar/trax-header/trax-header.component.spec.ts +0 -23
  369. package/src/lib/modules/layout/toolbar/trax-header/trax-header.component.ts +0 -1045
  370. package/src/lib/modules/layout/toolbar/trax-withoutdate/trax-withoutdate.component.html +0 -190
  371. package/src/lib/modules/layout/toolbar/trax-withoutdate/trax-withoutdate.component.scss +0 -311
  372. package/src/lib/modules/layout/toolbar/trax-withoutdate/trax-withoutdate.component.spec.ts +0 -23
  373. package/src/lib/modules/layout/toolbar/trax-withoutdate/trax-withoutdate.component.ts +0 -825
  374. package/src/lib/modules/layout/toolbar/zone-header/zone-header.component.html +0 -259
  375. package/src/lib/modules/layout/toolbar/zone-header/zone-header.component.scss +0 -305
  376. package/src/lib/modules/layout/toolbar/zone-header/zone-header.component.spec.ts +0 -23
  377. package/src/lib/modules/layout/toolbar/zone-header/zone-header.component.ts +0 -1242
  378. package/src/lib/modules/notification/conformation/conformation.component.html +0 -25
  379. package/src/lib/modules/notification/conformation/conformation.component.scss +0 -0
  380. package/src/lib/modules/notification/conformation/conformation.component.spec.ts +0 -23
  381. package/src/lib/modules/notification/conformation/conformation.component.ts +0 -23
  382. package/src/lib/modules/notification/notification/notification.component.html +0 -209
  383. package/src/lib/modules/notification/notification/notification.component.scss +0 -211
  384. package/src/lib/modules/notification/notification/notification.component.spec.ts +0 -23
  385. package/src/lib/modules/notification/notification/notification.component.ts +0 -310
  386. package/src/lib/modules/notification/notification-routing.module.ts +0 -20
  387. package/src/lib/modules/notification/notification.module.ts +0 -21
  388. package/src/lib/pipes/customDate.pipe.ts +0 -18
  389. package/src/lib/routes/route-wraper-modules/analyse-wrapper.module.ts +0 -12
  390. package/src/lib/routes/route-wraper-modules/edge-wrapper.module.ts +0 -11
  391. package/src/lib/routes/route-wraper-modules/manage-wrapper.module.ts +0 -11
  392. package/src/lib/routes/route-wraper-modules/profile-wrapper.module.ts +0 -12
  393. package/src/lib/routes/route-wraper-modules/store-wrapper.module.ts +0 -11
  394. package/src/lib/routes/route-wraper-modules/ticket-wrapper.module.ts +0 -10
  395. package/src/lib/routes/routing.ts +0 -56
  396. package/src/lib/services/auth.service.ts +0 -178
  397. package/src/lib/services/notification.service.spec.ts +0 -16
  398. package/src/lib/services/notification.service.ts +0 -73
  399. package/src/lib/services/toast.service.ts +0 -82
  400. package/tsconfig.lib.json +0 -14
  401. package/tsconfig.lib.prod.json +0 -10
  402. package/tsconfig.spec.json +0 -14
@@ -1,1202 +0,0 @@
1
- import {
2
- ChangeDetectorRef,
3
- Component,
4
- HostListener,
5
- OnInit,
6
- } from "@angular/core";
7
- import dayjs from "dayjs";
8
- import "dayjs/locale/en";
9
- import { AuthService } from "../../../../../services/auth.service";
10
- import { GlobalStateService } from "tango-app-ui-global";
11
- import { NavigationEnd, Router } from "@angular/router";
12
- @Component({
13
- selector: "lib-traffic-header",
14
- templateUrl: "./traffic-header.component.html",
15
- styleUrl: "./traffic-header.component.scss",
16
- })
17
- export class TrafficHeaderComponent implements OnInit {
18
- dayjs = dayjs;
19
- isCustomDate = (m: dayjs.Dayjs) => {
20
- if (m.isSame(this.dayjs(), "day")) {
21
- return "invalid-date"; // disable today
22
- }
23
- return false;
24
- };
25
-
26
- selectedDateRange: any = { startDate: dayjs().subtract(30, 'days'),
27
- endDate: dayjs().subtract(1, "days"),};
28
- selectedFilters: any = {
29
- client: null,
30
- clientName: null,
31
- clients: [],
32
- store: null,
33
- stores: [],
34
- date: null,
35
- group: [],
36
- location: [],
37
- country: [],
38
- };
39
- Opendropdown: boolean = false;
40
- dropdownOpen: string | null = null; // 'location' or 'group'
41
- searchLocationText: string = "";
42
- searchGroupText: string = "";
43
- locations: any[] = [];
44
- filteredLocations: any[] = [];
45
- groupsData: any[] = [];
46
- filteredGroups: any[] = [];
47
- filteredStores: any[] = [];
48
- stores:any[] = []
49
- searchStoreText:string = '';
50
- clientList:any = []
51
- selectedClient:any
52
- locationLabel: any[]=[];
53
- groupLabel: any[]=[];
54
- users: any;
55
- url: any;
56
- filteredCountries: any[] = [];
57
- countryLabel: any[]=[];
58
- searchCountryText: string = "";
59
- countries: any[] = [];
60
- constructor(
61
- private auth: AuthService, private router: Router,
62
- public gs: GlobalStateService,
63
- private cd: ChangeDetectorRef,
64
- ) {}
65
-
66
- @HostListener('document:click', ['$event'])
67
- onClick (event: MouseEvent) {
68
- const target = event.target as HTMLElement;
69
- if(!target.closest('.dropdown2')) {
70
- this.Opendropdown = false;
71
- }
72
- }
73
- closeDropdown1(){
74
- this.Opendropdown = false;
75
- }
76
- ngOnInit(): void {
77
- // this.setRangesBasedOnRoute();
78
-
79
- // Listen for route changes to update ranges
80
- // this.router?.events?.subscribe((event) => {
81
- // if (event instanceof NavigationEnd) {
82
- // this.setRangesBasedOnRoute();
83
- // }
84
- // });
85
- this.url = this.router.url.split("?")[0].split('/');
86
- const user = JSON.parse(localStorage.getItem('user-info') as string);
87
- this.users = user;
88
- this.gs?.manageRefreshTrigger?.subscribe((e) => {
89
- if (e) {
90
- if (user.userType === 'tango') {
91
- this.getClient();
92
- } else{
93
- const storedFilters = localStorage.getItem("header-filters");
94
- if (storedFilters) {
95
- const headerFilters = JSON.parse(storedFilters);
96
- this.filteredStores = headerFilters?.stores.map((store:any) => ({
97
- ...store,
98
- checked: store.checked
99
- }));
100
- }
101
- }
102
- }
103
- });
104
-
105
- // Fetch client data if the user is of type 'tango'
106
- if (user.userType === 'tango') {
107
- this.getClient();
108
- } else {
109
- this.getCountry();
110
- this.getLocations();
111
- this.getGroups();
112
- this.getStore();
113
- const clientFilters = localStorage.getItem("client-details");
114
- if (clientFilters) {
115
- const headerclientFilters = JSON.parse(clientFilters);
116
- this.selectedClient = {
117
- trafficDateRange : headerclientFilters.trafficDateRange
118
- }
119
- }
120
- }
121
-
122
- // Load filters from localStorage if they exist
123
- const storedFilters = localStorage.getItem("header-filters");
124
- if (storedFilters) {
125
- const headerFilters = JSON.parse(storedFilters);
126
-
127
- // Initialize selectedFilters with defaults or existing values
128
- this.selectedFilters = {
129
- client: headerFilters.client || this.users.client,
130
- clientName: headerFilters.clientName || '',
131
- clients: headerFilters.clients || [],
132
- store: headerFilters.store || null,
133
- date: headerFilters.date || {},
134
- stores: headerFilters.stores || [],
135
- group: headerFilters.group || [],
136
- location: headerFilters.location || [],
137
- country: headerFilters.country || []
138
- };
139
-
140
- // Sync filtered data with stored selections
141
- this.filteredCountries = this.syncWithLocalStorage(headerFilters.country);
142
- this.filteredLocations = this.syncWithLocalStorage(headerFilters.location);
143
- this.filteredGroups = this.syncWithLocalStorage(headerFilters.group);
144
- this.filteredStores = this.syncWithLocalStorage(headerFilters.stores);
145
-
146
- // Format date range if it exists
147
- if (headerFilters.date) {
148
-
149
- this.selectedDateRange = {
150
- startDate: this.dayjs(headerFilters.date.startDate, "YYYY-MM-DD").format("DD-MM-YYYY"),
151
- endDate: this.dayjs(headerFilters.date.endDate, "YYYY-MM-DD").format("DD-MM-YYYY"),
152
- };
153
- } else {
154
- this.selectedDateRange = {
155
- startDate: this.dayjs(this.selectedDateRange.startDate, "YYYY-MM-DD").format("DD-MM-YYYY"),
156
- endDate: this.dayjs(this.selectedDateRange.endDate, "YYYY-MM-DD").format("DD-MM-YYYY"),
157
- };
158
- }
159
- // console.log("3")
160
- // Emit data via service and update localStorage
161
- this.emitAndStoreFilters();
162
- } else {
163
- // Initialize empty states if no header filters are present in localStorage
164
- this.resetFilters();
165
- // console.log("2")
166
- }
167
- }
168
- private syncWithLocalStorage(items: any[]): any[] {
169
- return items
170
- ? items.map((item: any) => ({
171
- ...item,
172
- checked: item.checked === true
173
- }))
174
- : [];
175
- }
176
-
177
- private emitAndStoreFilters(): void {
178
- this.gs.dataRangeValue.next(this.selectedFilters);
179
- localStorage.setItem("header-filters", JSON.stringify(this.selectedFilters));
180
- // console.log("1")
181
- }
182
-
183
- /**
184
- * Reset selectedFilters and all related arrays to empty states
185
- */
186
- private resetFilters(): void {
187
- this.selectedFilters = {
188
- client: null,
189
- clientName: '',
190
- clients: [],
191
- store: null,
192
- date: {},
193
- stores: [],
194
- group: [],
195
- location: [],
196
- country: []
197
- };
198
- this.filteredLocations = [];
199
- this.filteredGroups = [];
200
- this.filteredStores = [];
201
- this.filteredCountries = [];
202
- }
203
- getClient(){
204
- this.auth.getClients().subscribe({
205
- next: (e) => {
206
- if (e) {
207
- this.clientList = e.data.result;
208
- const headerFilters: any = JSON.parse(
209
- localStorage.getItem("header-filters") || "{}"
210
- );
211
- if (headerFilters.client) {
212
- this.clientList.find((obj: any) => {
213
- if (obj.clientId === headerFilters.client) {
214
- this.selectedClient = obj;
215
- }
216
- });
217
- // const startDate = this.dayjs(headerFilters.date.startDate);
218
- // const endDate = this.dayjs(headerFilters.date.endDate);
219
- // const differenceInDays = endDate.diff(startDate, 'days');
220
- // if (differenceInDays >= 90 && this.selectedClient?.trafficDateRange === 90) {
221
- // this.selectedDateRange = {
222
- // startDate: this.dayjs(headerFilters.date.startDate, "YYYY-MM-DD").subtract(-90, 'days').format("DD-MM-YYYY"),
223
- // endDate: this.dayjs(headerFilters.date.endDate, "YYYY-MM-DD").format("DD-MM-YYYY"),
224
- // };
225
- // } else {
226
- // this.selectedDateRange = {
227
- // startDate: this.dayjs(this.selectedDateRange.startDate, "YYYY-MM-DD").format("DD-MM-YYYY"),
228
- // endDate: this.dayjs(this.selectedDateRange.endDate, "YYYY-MM-DD").format("DD-MM-YYYY"),
229
- // };
230
- // }
231
- this.selectedFilters.client = headerFilters.client;
232
- this.selectedFilters.clientName = headerFilters.clientName;
233
- this.selectedFilters.clients = headerFilters.clients;
234
- this.selectedFilters.store = headerFilters.store;
235
- this.selectedFilters.date = headerFilters.date;
236
- this.selectedFilters.stores = headerFilters.stores;
237
- this.selectedFilters.group = headerFilters.group;
238
- this.selectedFilters.location = headerFilters.location;
239
- this.selectedFilters.country = headerFilters.country;
240
- this.gs.dataRangeValue.next(this.selectedFilters);
241
- // console.log("2")
242
- // Ensure locations and groups are loaded before fetching stores
243
- this.getCountry();
244
- this.getLocations();
245
- this.getGroups();
246
- // Fetch stores only after locations and groups are set
247
- this.getStore();
248
- } else {
249
- this.selectedClient = this.clientList[0];
250
- this.selectedFilters.client = this.selectedClient.clientId;
251
- this.selectedFilters.clientName = this.selectedClient.clientName
252
- this.selectedFilters.clients = headerFilters.clients;
253
- this.selectedFilters.store = headerFilters.store;
254
- this.selectedFilters.date = headerFilters.date;
255
- this.selectedFilters.stores = headerFilters.stores;
256
- this.selectedFilters.group = headerFilters.group;
257
- this.selectedFilters.location = headerFilters.location;
258
- this.selectedFilters.country = headerFilters.country;
259
- localStorage.setItem(
260
- "header-filters",
261
- JSON.stringify(this.selectedFilters)
262
- );
263
- this.gs.dataRangeValue.next(this.selectedFilters);
264
- // console.log("3")
265
- this.cd.detectChanges();
266
- // Ensure locations and groups are loaded before fetching stores
267
- this.getCountry();
268
- this.getLocations();
269
- this.getGroups();
270
- // Fetch stores only after locations and groups are set
271
- this.getStore();
272
- }
273
-
274
-
275
- } else {
276
- this.selectedClient = this.clientList[0];
277
- this.selectedFilters.client = this.selectedClient.clientId;
278
- this.selectedFilters.clientName = this.selectedClient.clientName
279
- // Ensure locations and groups are loaded before fetching stores
280
- this.getCountry();
281
- this.getLocations();
282
- this.getGroups();
283
- // Fetch stores only after locations and groups are set
284
- this.getStore();
285
- localStorage.setItem(
286
- "header-filters",
287
- JSON.stringify(this.selectedFilters)
288
- );
289
- this.gs.dataRangeValue.next(this.selectedFilters);
290
- // console.log("4")
291
- this.cd.detectChanges();
292
- }
293
- this.getUserInfo(this.selectedFilters.client);
294
-
295
- },
296
- });
297
- }
298
- getUserInfo(client:any){
299
- let obj ={
300
- clientId: client ? client :''
301
- }
302
- if(client){
303
- this.auth.getHeaderUsers(obj).subscribe({
304
- next: (e) => {
305
- localStorage.setItem(
306
- "usersEmail-info",
307
- JSON.stringify(e?.data?.userEmailData || [])
308
- );
309
- }
310
- })
311
- }
312
- }
313
- onClientSelect(event: any): void {
314
- // Update the selected client
315
- this.selectedClient = event;
316
- // Clear previous filtered data and selections
317
- this.filteredGroups = [];
318
- this.filteredStores = [];
319
- this.filteredLocations = [];
320
- this.selectedFilters.stores = [];
321
- this.selectedFilters.group = [];
322
- this.selectedFilters.location = [];
323
- this.selectedFilters.country = [];
324
-
325
-
326
- // Fetch header filters from localStorage
327
- const headerFilters: any = JSON.parse(localStorage.getItem("header-filters") || "{}");
328
-
329
- // Update the selected filters with the new client
330
- this.selectedFilters.client = this.selectedClient.clientId;
331
- this.selectedFilters.clientName = this.selectedClient.clientName;
332
-
333
- // Remove old store, group, and location data from the header filters
334
- delete headerFilters.stores;
335
- delete headerFilters.groups;
336
- delete headerFilters.location;
337
- delete headerFilters.country;
338
-
339
-
340
- // Fetch new data based on the new client
341
- this.getCountry();
342
- this.getLocations();
343
- this.getStore();
344
- this.getGroups();
345
-
346
- // Update localStorage with the new client selection and empty filter data
347
- localStorage.setItem('header-filters', JSON.stringify(this.selectedFilters));
348
- window.location.reload()
349
- // Emit data to the global service
350
- // this.gs.dataRangeValue.next(this.selectedFilters);
351
- // Trigger change detection to reflect UI changes
352
- this.cd.detectChanges();
353
- }
354
-
355
-
356
-
357
- ranges:any = {
358
- // Today: [dayjs(), dayjs()],
359
- Yesterday: [dayjs().subtract(1, 'days'), dayjs().subtract(1, 'days')],
360
- 'This Week': [dayjs().subtract(7, 'days'), dayjs().subtract(1, 'days')],
361
- 'Last Week': [
362
- dayjs().subtract(14, 'days').startOf('day'),
363
- dayjs().subtract(8, 'days').endOf('day'),
364
- ],
365
- 'This Month': [dayjs().subtract(30, 'days'), dayjs().subtract(1, 'days')],
366
- 'Last Month': [
367
- dayjs().subtract(1, 'month').startOf('month'),
368
- dayjs().subtract(1, 'month').endOf('month'),
369
- ],
370
- };
371
-
372
- onStartDateChange(event: any) {
373
- if (this.dayjs(event.startDate).isValid()) {
374
- if(this.selectedClient?.traxDateRange === 90){
375
- this.isCustomDate = (m: dayjs.Dayjs) => {
376
- const isValidDate =
377
- m > this.dayjs() || m > this.dayjs(event.startDate.add(90, "days"));
378
- return isValidDate ? "invalid-date" : false;
379
- };
380
- } else {
381
- this.isCustomDate = (m: dayjs.Dayjs) => {
382
- const isValidDate =
383
- m > this.dayjs() || m > this.dayjs(event.startDate.add(180, "days"));
384
- return isValidDate ? "invalid-date" : false;
385
- };
386
- }
387
-
388
- }
389
- }
390
-
391
- datechange(event: any) {
392
- if (event && event.startDate && event.endDate) {
393
- if (
394
- this.dayjs(event.startDate).isValid() &&
395
- this.dayjs(event.endDate).isValid()
396
- ) {
397
- this.selectedDateRange.startDate = event.startDate;
398
- this.selectedDateRange.endDate = event.endDate;
399
- var datetime = {
400
- startDate: this.dayjs(event.startDate, "DD-MM-YYYY").format(
401
- "YYYY-MM-DD"
402
- ),
403
- endDate: this.dayjs(event.endDate, "DD-MM-YYYY").format("YYYY-MM-DD"),
404
- };
405
- this.selectedFilters.date = datetime;
406
- localStorage.setItem(
407
- "header-filters",
408
- JSON.stringify(this.selectedFilters)
409
- );
410
- window.location.reload()
411
- // this.gs.dataRangeValue.next(this.selectedFilters);
412
- }
413
- }
414
- }
415
- opendropdown(e:MouseEvent) {
416
- e.stopPropagation();
417
- this.Opendropdown = !this.Opendropdown;
418
- }
419
- getLocations(): void {
420
- const country = this.countries
421
- .filter(country => country.checked)
422
- .map(country => country.country);
423
- // const headerFilters: any = JSON.parse(localStorage.getItem("header-filters") || "{}");
424
- let obj ={
425
- clientId: this.selectedFilters.client ? this.selectedFilters.client :this.users.clientId,
426
- country,
427
- city: [],
428
- group: [],
429
- }
430
- this.auth.getLocation(obj).subscribe({
431
- next: (res: any) => {
432
- let cityList = this.selectedFilters?.location?.filter((location:any) => location.checked).map((loc:any) => loc.city);
433
- // Map the fetched locations with default unchecked state
434
- this.locations = res?.data?.locationData.map((city: any) => ({
435
- city: city.city,
436
- // checked: cityList?.length ? cityList.includes(city.city) : true,
437
- checked: cityList?.includes(city.city) ? true : false,
438
- }));
439
-
440
- // Sync the fetched locations with any stored checked values in localStorage
441
- if (this.selectedFilters.location && Array.isArray(this.selectedFilters.location)) {
442
- this.filteredLocations = this.locations.map(location => {
443
- const matchedLocation = this.selectedFilters.location.find((loc: any) => loc.city === location.city);
444
- return matchedLocation ? { ...location, checked: matchedLocation.checked } : location;
445
- });
446
- } else {
447
- this.filteredLocations = this.locations;
448
- }
449
-
450
- if(this.searchLocationText) {
451
- this.filteredLocations = this.locations.filter((location:any) => location.city.toLowerCase().includes(this.searchLocationText.toLowerCase()))
452
- }
453
- const selectedLocations = this.locations.filter((location) => location.checked).map((location) => location.city);
454
- if (selectedLocations.length > 0) {
455
- setTimeout(()=>{
456
- this.getGroups();
457
- this.getStore(); // Fetch stores based on selected groups
458
- },1000)
459
- }
460
-
461
- if(!selectedLocations.length && country.length) {
462
- this.getGroups();
463
- }
464
- },
465
- error: (err) => {
466
- console.error("Failed to fetch locations", err);
467
- },
468
- });
469
- }
470
-
471
- isAllLocationsSelected(): boolean {
472
- return this.filteredLocations.every(location => location.checked);
473
-
474
- }
475
-
476
- selectedLocationsLabel(): string {
477
- const selectedLocations = this.locationLabel = this.searchLocationText.length ? this.locations
478
- .filter(location => location.checked).map(location => location.city) : this.filteredLocations
479
- .filter(location => location.checked).map(location => location.city);
480
- return selectedLocations.length === 0
481
- ? ''
482
- : selectedLocations.length === 1
483
- ? selectedLocations[0]
484
- : `${selectedLocations.length} Regions`;
485
- }
486
-
487
- removeLocation(): void {
488
- this.Reset();
489
- }
490
-
491
- getGroups(): void {
492
- const country = this.countries
493
- .filter(country => country.checked)
494
- .map(country => country.country);
495
- let city;
496
- city = this.locations
497
- .filter(location => location.checked)
498
- .map(location => location.city);
499
-
500
- if(!city.length && country.length) {
501
- city = this.locations.map((loc) => loc.city);
502
- }
503
- const obj = { country,city,clientId:this.selectedFilters.client ? this.selectedFilters.client :this.users.clientId,group:[] };
504
- this.auth.getGroups(obj).subscribe({
505
- next: (res: any) => {
506
- let checkedGroup = this.selectedFilters?.group?.filter((group:any) => group.checked).map((group:any) => group.groupName);
507
- const combinedGroups = res?.data?.groupData?.map((groupName: any) => ({
508
- groupName: groupName.groupName,
509
- checked: checkedGroup?.includes(groupName.groupName) ? true : false,
510
- // checked: checkedGroup?.length ? checkedGroup.includes(groupName.groupName) : true,
511
- }));
512
- this.groupsData = combinedGroups;
513
- if(this.searchGroupText.length) {
514
- this.filteredGroups = combinedGroups.filter((item:any) => item.groupName.toLowerCase().includes(this.searchGroupText));
515
- }
516
- else {
517
- this.filteredGroups = combinedGroups;
518
- }
519
-
520
- // Auto-fetch stores when groups are selected
521
- const selectedGroups = this.groupsData.filter((group) => group.checked).map((group) => group.groupName);
522
- if (selectedGroups.length > 0) {
523
- setTimeout(()=>{
524
- this.getStore(); // Fetch stores based on selected groups
525
- },1000)
526
- }
527
- },
528
- error: (err) => {
529
- console.error("Failed to fetch groups", err);
530
- },
531
- });
532
- }
533
-
534
- toggleDropdown(type: 'country' | 'location' | 'group' | 'store'): void {
535
- if (this.dropdownOpen === type) {
536
- // If the dropdown is open, close it and avoid resetting the selected values unnecessarily
537
- this.dropdownOpen = null;
538
- } else {
539
- // Open the specific dropdown and handle data fetching only if necessary
540
- this.dropdownOpen = type;
541
-
542
- if (type === 'country') {
543
- // Fetch countries only if not already fetched and no search text exists
544
- if ((!this.filteredCountries || this.filteredCountries.length === 0) && !this.searchCountryText.trim()) {
545
- this.getCountry();
546
- }
547
- }
548
-
549
- if (type === 'group') {
550
- // Fetch groups only if there are selected cities and no active search text
551
- const selectedCities = this.locations
552
- .filter((location) => location.checked)
553
- .map((location) => location.city);
554
-
555
- // Fetch groups only if locations are selected, no search text exists, and dropdown is opened
556
- if (this.filteredLocations.length > 0 || (selectedCities.length > 0 && !this.searchGroupText.trim())) {
557
- this.getGroups();
558
- } else {
559
- this.filteredGroups = []; // Clear groups if no locations are selected
560
- }
561
- }
562
-
563
- if (type === 'store') {
564
- // Fetch stores only if not already fetched and no search text is active
565
- if ((!this.filteredStores || this.filteredStores.length === 0) && !this.searchStoreText.trim()) {
566
- this.getStore();
567
- }
568
- }
569
- }
570
- }
571
-
572
-
573
- handleGroupDropdownClick(): void {
574
- if (this.dropdownOpen === 'group') {
575
- this.resetSelectedGroups();
576
- }
577
- this.toggleDropdown('group');
578
- }
579
-
580
- resetSelectedGroups(): void {
581
- this.filteredGroups.forEach((group) => (group.checked = false));
582
- this.searchGroupText = "";
583
- }
584
- selectedGroupsLabel(): string {
585
- const selectedGroups = this.groupLabel = this.searchGroupText.length ? this.groupsData.filter((group) => group.checked) : this.filteredGroups.filter((group) => group.checked);
586
- return selectedGroups.length === 0
587
- ? ""
588
- : selectedGroups.length === 1
589
- ? selectedGroups[0].groupName
590
- : `${selectedGroups.length} Clusters`;
591
- }
592
- removeGroup(): void {
593
- this.Reset();
594
-
595
- }
596
-
597
-
598
- isAllGroupsSelected(): boolean {
599
-
600
- return this.filteredGroups.length ? this.filteredGroups.every((group) => group.checked) : false;
601
- }
602
-
603
- getStore(): void {
604
- const country = this.countries
605
- .filter(country => country.checked)
606
- .map(country => country.country);
607
- const city = this.locations
608
- .filter(location => location.checked)
609
- .map(location => location.city);
610
- const group = this.groupsData
611
- .filter(group => group.checked)
612
- .map(group => group.groupName);
613
-
614
- const data = {
615
- country,
616
- city,
617
- clusters: group,
618
- clientId: this.users.clientId || this.selectedFilters.client
619
- };
620
-
621
- this.auth.getHeaderStores(data).subscribe({
622
- next: (res: any) => {
623
- if (res && res.code === 200) {
624
- // Initialize stores from API response
625
- this.stores = res.data.storesData;
626
- // Check if there are previously selected stores
627
- const checkedStoreIds = this.selectedFilters?.stores
628
- ? this.selectedFilters.stores.filter((store:any) => store.checked).map((store:any) => store.storeId)
629
- : [];
630
- // Sync the `checked` state
631
- this.stores.forEach(store => {
632
- store.checked = checkedStoreIds.length
633
- ? checkedStoreIds.includes(store.storeId) // Use previous selection
634
- : true; // Default to true if no previous selection
635
- });
636
-
637
- // Apply search filter if search text is present
638
- if (this.searchStoreText.length) {
639
- this.filteredStores = this.stores.filter(store =>
640
- store.storeName.toLowerCase().includes(this.searchStoreText.toLowerCase())
641
- );
642
- } else {
643
- this.filteredStores = [...this.stores];
644
- }
645
-
646
- // Update `selectedFilters.stores` to reflect the current state
647
- this.selectedFilters.stores = this.filteredStores.map(store => ({
648
- storeId: store.storeId,
649
- storeName: store.storeName,
650
- checked: store.checked
651
- }));
652
- // this.selectedFilters.country = country;
653
-
654
- // Save updated filters to localStorage
655
- localStorage.setItem('header-filters', JSON.stringify(this.selectedFilters));
656
-
657
- // Trigger UI change detection
658
- this.cd.detectChanges();
659
- } else {
660
- // Handle empty or error response
661
- this.clearStoresState();
662
- }
663
- },
664
- error: (err) => {
665
- console.error("Failed to fetch stores", err);
666
- this.clearStoresState();
667
- }
668
- });
669
- }
670
-
671
- // Clear stores state and reset filters
672
- private clearStoresState(): void {
673
- this.stores = [];
674
- this.filteredStores = [];
675
- this.selectedFilters.stores = [];
676
- localStorage.setItem('header-filters', JSON.stringify(this.selectedFilters));
677
- }
678
-
679
- resetSelectedStores(): void {
680
- this.filteredStores.forEach((store) => (store.checked = false));
681
- this.searchStoreText = "";
682
- }
683
-
684
- selectedStoresLabel(): string {
685
- const selectedStores = this.searchStoreText.length ? this.stores.filter((store) => store.checked) : this.filteredStores.filter((store) => store.checked);
686
- return selectedStores.length === 0
687
- ? "0 Stores"
688
- : selectedStores.length === 1
689
- ? selectedStores[0].storeName
690
- : `${selectedStores.length} Stores`;
691
- }
692
-
693
- isAllStoresSelected(): boolean {
694
- return this.filteredStores.length > 0 && this.filteredStores.every(store => store.checked);
695
- }
696
- // Method to handle dropdown item selection
697
- updateSelectedStores(): void {
698
- this.filteredStores.forEach(store => {
699
- const filteredStore = this.stores.findIndex(fStore => fStore.storeId === store.storeId);
700
- if (filteredStore != -1) {
701
- this.stores[filteredStore].checked = store.checked; // Sync the checked state with full store list
702
- }
703
- });
704
- // Update selectedFilters based on the current store selection
705
- this.selectedFilters.stores = this.stores.filter(store => store.checked);
706
-
707
- // Update localStorage with the latest selection
708
- localStorage.setItem('header-filters', JSON.stringify(this.selectedFilters));
709
-
710
- // Emit updated filters via service
711
- // this.gs.dataRangeValue.next(this.selectedFilters);
712
-
713
- // Trigger change detection if necessary
714
- this.cd.detectChanges();
715
- }
716
- toggleSelectAllLocations(event: any): void {
717
- const isChecked = event.target.checked;
718
- this.filteredLocations.forEach((location) => (location.checked = isChecked));
719
- this.updateSelectedLocations();
720
- }
721
-
722
- toggleSelectAllStores(event: Event): void {
723
- const checked = (event.target as HTMLInputElement).checked;
724
-
725
- // Apply the selection to both filtered and full list of stores
726
- this.filteredStores.forEach(store => store.checked = checked);
727
- this.stores.forEach(store => {
728
- const filteredStore = this.filteredStores.find(fStore => fStore.storeId === store.storeId);
729
- if (filteredStore) {
730
- store.checked = checked; // Sync the checked state with full store list
731
- }
732
- });
733
-
734
- // Update the selected stores and persist the selection
735
- this.updateSelectedStores();
736
- }
737
-
738
- updateSelectedLocations(): void {
739
- // When locations are selected, fetch the related groups
740
- const selectedCities = this.filteredLocations
741
- .filter((location) => location.checked)
742
- .map((location) => location.city);
743
- this.filteredLocations.forEach((location:any) => {
744
- let findLocationIndex = this.locations.findIndex((loc:any) => loc.city == location.city);
745
- if(findLocationIndex != -1) {
746
- this.locations[findLocationIndex].checked = location.checked;
747
- }
748
- })
749
- if (selectedCities.length > 0 || !selectedCities.length) {
750
- this.selectedFilters.stores =[];
751
- this.groupsData =[]
752
- this.getGroups(); // Fetch groups based on selected cities
753
- // If there are selected groups, fetch the stores based on selected groups
754
- this.getStore();
755
- this.selectedFilters.location = this.locations;
756
-
757
- } else {
758
- this.filteredGroups = []; // Clear groups if no locations are selected
759
- this.selectedFilters.location = [];
760
- }
761
-
762
- this.selectedFilters.group = [];
763
- this.filteredStores = []; // Reset stores as well
764
- this.searchGroupText = '';
765
- this.searchStoreText = '';
766
- // this.Opendropdown = false;
767
- }
768
-
769
- toggleSelectAllGroups(event: any): void {
770
- const isChecked = event.target.checked;
771
- this.filteredGroups.forEach((group) => (group.checked = isChecked));
772
- this.updateSelectedGroups();
773
- }
774
-
775
- updateSelectedGroups(): void {
776
- // Fetch the relevant stores after groups are selected
777
- const selectedGroups = this.filteredGroups
778
- .filter((group) => group.checked)
779
- .map((group) => group.groupName);
780
-
781
- this.filteredGroups.forEach((group:any) => {
782
- let findGroupIndex = this.groupsData.findIndex((item:any) => item.groupName == group.groupName);
783
- if(findGroupIndex != -1) {
784
- this.groupsData[findGroupIndex].checked = group.checked;
785
- }
786
- })
787
- if (selectedGroups.length > 0 || !selectedGroups.length) {
788
- this.selectedFilters.stores =[];
789
- // If there are selected groups, fetch the stores based on selected groups
790
- this.getStore();
791
- this.selectedFilters.group = this.groupsData;
792
- } else {
793
- // If no groups are selected, clear the stores list
794
- this.filteredStores = [];
795
-
796
- // Also, update localStorage to reflect the cleared store selection
797
- this.selectedFilters.stores = [];
798
- localStorage.setItem('header-filters', JSON.stringify(this.selectedFilters));
799
-
800
- // Emit data via service
801
- // this.gs.dataRangeValue.next(this.selectedFilters);
802
- }
803
-
804
- // Clear the search store text when groups are updated
805
- this.searchStoreText = '';
806
- }
807
-
808
-
809
- Reset(): void {
810
- setTimeout(()=>{
811
- // Clear selected groups, stores, and locations
812
- this.filteredCountries = []
813
- this.filteredGroups = [];
814
- this.filteredStores = [];
815
- this.filteredLocations = []; // Reset locations as well
816
- this.locations =[];this.groupsData =[]; this.stores =[]; this.countries =[];
817
- // Clear search input fields
818
- this.searchLocationText = "";
819
- this.searchGroupText = "";
820
- this.searchStoreText = "";
821
- this.selectedFilters.stores =[];
822
- this.selectedFilters.group =[];
823
- this.selectedFilters.location =[];
824
- this.selectedFilters.country =[];
825
-
826
-
827
- // Fetch locations, groups, and stores again
828
- this.getCountry();
829
- this.getLocations();
830
- this.getStore();
831
- this.getGroups();
832
- // Reset the filters in selectedFilters
833
-
834
-
835
- // // Once stores are fetched, mark all as checked
836
- // setTimeout(() => {
837
- // this.filteredStores = this.stores.map(store => ({
838
- // ...store,
839
- // checked: true // Mark all stores as checked
840
- // }));
841
-
842
- // // Sync selectedFilters with the updated store state
843
- // this.selectedFilters.stores = this.filteredStores.map(store => ({
844
- // ...store,
845
- // checked: true
846
- // }));
847
-
848
- // Update localStorage with the latest selectedFilters
849
- localStorage.setItem('header-filters', JSON.stringify(this.selectedFilters));
850
- window.location.reload()
851
- // Emit the reset filters to update other components if needed
852
- // this.gs.dataRangeValue.next(this.selectedFilters);
853
- // Trigger change detection
854
- this.cd.detectChanges();
855
- // Adding a slight delay to ensure stores are fetched first
856
-
857
-
858
- // Close dropdown after reset if necessary
859
- this.Opendropdown = false;
860
- },100)
861
- }
862
-
863
-
864
-
865
-
866
- filterLocations(): void {
867
- const searchText = this.searchLocationText.toLowerCase();
868
-
869
- if (searchText) {
870
- // Preserve the checked state during filtering
871
- this.filteredLocations = this.locations
872
- .map(location => ({
873
- ...location,
874
- checked: this.filteredLocations.find(l => l.city === location.city)?.checked || false
875
- }))
876
- .filter(location =>
877
- location?.city?.toLowerCase().includes(searchText)
878
- );
879
- } else {
880
- // Restore the original checked state when search text is cleared
881
- this.filteredLocations = this.locations.map(location => ({
882
- ...location,
883
- checked: this.selectedFilters.location.find((l:any) => l.city === location.city)?.checked || false
884
- }));
885
- }
886
- }
887
-
888
-
889
- filterGroups(): void {
890
- const searchText = this.searchGroupText.toLowerCase();
891
-
892
- if (searchText) {
893
- // Preserve the checked state during filtering
894
- this.filteredGroups = this.groupsData
895
- .map(group => ({
896
- ...group,
897
- checked: this.filteredGroups.find(g => g.groupName === group.groupName)?.checked || false
898
- }))
899
- .filter(group =>
900
- group?.groupName?.toLowerCase().includes(searchText)
901
- );
902
- } else {
903
- // Restore the original checked state when search text is cleared
904
- this.filteredGroups = this.groupsData.map(group => ({
905
- ...group,
906
- checked: this.selectedFilters.group.find((g:any) => g.groupName === group.groupName)?.checked || false
907
- }));
908
- }
909
- }
910
-
911
-
912
- filterStores(): void {
913
- const searchText = this.searchStoreText.toLowerCase();
914
- // Preserve checked states during filtering
915
- if (searchText) {
916
- // Filter based on search text while preserving checked state
917
- this.filteredStores = this.stores
918
- .map(store => ({
919
- ...store,
920
- // Check if the store is already checked in filteredStores, fallback to original stores' checked state
921
- checked: this.selectedFilters.stores.find((s: any) => s.storeId === store.storeId)?.checked || store.checked || false
922
- }))
923
- .filter(store => store.storeName.toLowerCase().includes(searchText));
924
- } else {
925
- // When the search text is cleared, restore the original list with preserved checked states
926
- this.filteredStores = this.stores.map(store => ({
927
- ...store,
928
- // Preserve the checked state based on the selected filters
929
- checked: this.selectedFilters.stores.find((s: any) => s.storeId === store.storeId)?.checked || store.checked || false
930
- }));
931
- }
932
- }
933
-
934
- closeDropdown(): void {
935
- this.dropdownOpen = null;
936
- }
937
-
938
- @HostListener("document:click", ["$event"])
939
- clickOutside(event: MouseEvent): void {
940
- const clickedInside = (event.target as HTMLElement).closest(
941
- ".dropdown-container"
942
- );
943
- const clickedoutSide = (event.target as HTMLElement).closest(
944
- ".dropdown2"
945
- );
946
- if (!clickedInside) {
947
- this.closeDropdown();
948
- }
949
- if(!clickedoutSide) {
950
- this.closeDropdown1();
951
- }
952
-
953
- }
954
-
955
- // getCountry(): void {
956
- // // const headerFilters: any = JSON.parse(localStorage.getItem("header-filters") || "{}");
957
- // let obj ={
958
- // clientId: this.selectedFilters.client ? this.selectedFilters.client :this.users.clientId,
959
- // }
960
- // this.auth.getCountry(obj).subscribe({
961
- // next: (res: any) => {
962
- // let countryList = this.selectedFilters?.country?.filter((country:any) => country.checked).map((loc:any) => loc.allCountry);
963
- // // Map the fetched countries with default unchecked state
964
- // this.countires = res?.data?.countryData.map((allCountry: any) => ({
965
- // allCountry: allCountry.allCountry,
966
- // checked: countryList?.includes(allCountry.allCountry) ? true : false,
967
- // }));
968
-
969
- // // Sync the fetched countries with any stored checked values in localStorage
970
- // if (this.selectedFilters.country && Array.isArray(this.selectedFilters.country)) {
971
- // this.filteredCountries = this.countries.map(country => {
972
- // const matchedLocation = this.selectedFilters.country.find((loc: any) => loc.allCountry === country.allCountry);
973
- // return matchedLocation ? { ...country, checked: matchedLocation.checked } : country;
974
- // });
975
- // } else {
976
- // this.filteredCountries = this.countries;
977
- // }
978
-
979
- // if(this.searchLocationText) {
980
- // this.filteredCountries = this.countries.filter((country:any) => country.city.toLowerCase().includes(this.searchLocationText.toLowerCase()))
981
- // }
982
- // const selectedCountries = this.countries.filter((country) => country.checked).map((country) => country.allCountry);
983
- // if (selectedCountries.length > 0) {
984
- // setTimeout(()=>{
985
- // this.getStore(); // Fetch stores based on selected groups
986
- // },1000)
987
- // }
988
- // },
989
- // error: (err) => {
990
- // console.error("Failed to fetch countries", err);
991
- // },
992
- // });
993
- // }
994
-
995
- // selectedCountriesLabel(): string {
996
- // const selectedCountries = this.countryLabel = this.searchLocationText.length ? this.countries
997
- // .filter(country => country.checked).map(country => country.allCountry) : this.filteredCountries
998
- // .filter(country => country.checked).map(country => country.allCountry);
999
- // return selectedCountries.length === 0
1000
- // ? ''
1001
- // : selectedCountries.length === 1
1002
- // ? selectedCountries[0]
1003
- // : `${selectedCountries.length} countries`;
1004
- // }
1005
-
1006
- // isAllCountriesSelected(): boolean {
1007
- // return this.filteredCountries.every(country => country.checked);
1008
-
1009
- // }
1010
- // filterCountries(): void {
1011
- // const searchText = this.searchCountryText.toLowerCase();
1012
-
1013
- // if (searchText) {
1014
- // // Preserve the checked state during filtering
1015
- // this.filteredCountries = this.countires
1016
- // .map(country => ({
1017
- // ...country,
1018
- // checked: this.filteredCountries.find(l => l.allCountry === country.allCountry)?.checked || false
1019
- // }))
1020
- // .filter(location =>
1021
- // location?.allCountry?.toLowerCase().includes(searchText)
1022
- // );
1023
- // } else {
1024
- // // Restore the original checked state when search text is cleared
1025
- // this.filteredCountries = this.countires.map(country => ({
1026
- // ...country,
1027
- // checked: this.selectedFilters.country.find((l:any) => l.allCountry === country.allCountry)?.checked || false
1028
- // }));
1029
- // }
1030
- // }
1031
-
1032
-
1033
- getCountry(): void {
1034
- let obj = {
1035
- clientId: this.selectedFilters.client ? this.selectedFilters.client : this.users.clientId,
1036
- };
1037
-
1038
- this.auth.getCountry(obj).subscribe({
1039
- next: (res: any) => {
1040
- // Extract selected countries from existing filters (if any)
1041
- let countryList = this.selectedFilters?.country?.filter((country: any) => country.checked).map((loc: any) => loc.country);
1042
-
1043
- // Map API response to frontend model
1044
- this.countries = res?.data?.countryData.map((item: any) => ({
1045
- country: item.country,
1046
- // checked: countryList?.length ? countryList.includes(item.country) : true,
1047
- // checked: cityList?.length ? cityList.includes(city.city) : true,
1048
- checked: countryList?.includes(item.country) ? true : false,
1049
-
1050
- }));
1051
- if (this.selectedFilters.country && Array.isArray(this.selectedFilters.country)) {
1052
- this.filteredCountries = this.countries.map(location => {
1053
- const matchedLocation = this.selectedFilters.country.find((loc: any) => loc.country === location.country);
1054
- return matchedLocation ? { ...location, checked: matchedLocation.checked } : location;
1055
- });
1056
- } else {
1057
- this.filteredCountries = this.countries;
1058
- }
1059
-
1060
-
1061
- // Initially, all countries are visible
1062
- this.filteredCountries = [...this.countries];
1063
-
1064
-
1065
- // If a search text already exists, filter immediately
1066
- if (this.searchCountryText) {
1067
- this.filterCountries();
1068
- }
1069
-
1070
- // Fetch stores if at least one country is selected
1071
- let selectedCountries = this.countries.filter((country) => country.checked);
1072
- if (selectedCountries.length > 0) {
1073
- setTimeout(() => {
1074
- this.getLocations();
1075
- this.getStore(); // fetch stores
1076
- }, 1000);
1077
- }
1078
- },
1079
- error: (err) => {
1080
- console.error("Failed to fetch countries", err);
1081
- },
1082
- });
1083
- }
1084
-
1085
- selectedCountriesLabel(): string {
1086
- const selectedCountries = this.searchCountryText.length
1087
- ? this.filteredCountries.filter(country => country.checked).map(country => country.country)
1088
- : this.countries.filter(country => country.checked).map(country => country.country);
1089
-
1090
- return selectedCountries.length === 0
1091
- ? ''
1092
- : selectedCountries.length === 1
1093
- ? selectedCountries[0]
1094
- : `${selectedCountries.length} countries`;
1095
- }
1096
-
1097
- filterCountries(): void {
1098
- const searchText = this.searchCountryText.toLowerCase();
1099
-
1100
- if (searchText) {
1101
- // Filter and preserve checked state
1102
- this.filteredCountries = this.countries
1103
- .map(country => ({
1104
- ...country,
1105
- checked: this.filteredCountries.find(c => c.country === country.country)?.checked || false
1106
- }))
1107
- .filter(country => country.country.toLowerCase().includes(searchText));
1108
- } else {
1109
- // Reset to full list
1110
- this.filteredCountries = this.countries.map((country: Country) => ({
1111
- ...country,
1112
- checked: this.selectedFilters.country?.find((c: any) => c.country === country.country)?.checked || false
1113
- }));
1114
- }
1115
- }
1116
-
1117
- isAllCountriesSelected(): boolean {
1118
- return this.filteredCountries.length > 0 && this.filteredCountries.every(country => country.checked);
1119
- }
1120
- toggleSelectAllCountries(event: any): void {
1121
- const isChecked = event.target.checked;
1122
- this.filteredCountries.forEach((country) => (country.checked = isChecked));
1123
- this.updateSelectedCountries();
1124
-
1125
- }
1126
-
1127
- updateSelectedCountries(): void {
1128
- // When locations are selected, fetch the related groups
1129
- const selectedCountries = this.filteredCountries
1130
- .filter((country) => country.checked)
1131
- .map((country) => country.country);
1132
- this.filteredCountries.forEach((country:any) => {
1133
- let findCountryIndex = this.countries.findIndex((loc:any) => loc.country == country.country);
1134
- if(findCountryIndex != -1) {
1135
- this.countries[findCountryIndex].checked = country.checked;
1136
- }
1137
- })
1138
- if (selectedCountries.length > 0 || !selectedCountries.length) {
1139
- this.selectedFilters.stores =[];
1140
- this.groupsData =[]
1141
- this.locations =[];
1142
- this.getLocations();
1143
- this.getGroups(); // Fetch groups based on selected cities
1144
- // If there are selected groups, fetch the stores based on selected groups
1145
- this.getStore();
1146
- this.selectedFilters.country = this.filteredCountries;
1147
-
1148
- } else {
1149
- this.filteredGroups = []; // Clear groups if no locations are selected
1150
- this.selectedFilters.country = [];
1151
- }
1152
-
1153
- this.selectedFilters.group = [];
1154
- this.filteredStores = []; // Reset stores as well
1155
- this.searchGroupText = '';
1156
- this.searchStoreText = '';
1157
- // this.Opendropdown = false;
1158
- }
1159
-
1160
- removeCountry(): void {
1161
- this.Reset();
1162
- }
1163
-
1164
- Apply(): void {
1165
- // Close the dropdown
1166
- this.Opendropdown = false;
1167
-
1168
- // Fetch existing filters from localStorage
1169
- const headerFilters: any = JSON.parse(localStorage.getItem("header-filters") || "{}");
1170
- this.selectedFilters.store = null
1171
-
1172
- // Ensure current selections are reflected
1173
- this.selectedFilters.country = this.filteredCountries;
1174
- this.selectedFilters.location = this.locations;
1175
- this.selectedFilters.group = this.groupsData;
1176
- this.selectedFilters.stores = headerFilters.stores ? headerFilters.stores : this.stores;
1177
- // Store updated filters back in localStorage
1178
- localStorage.setItem("header-filters", JSON.stringify(this.selectedFilters));
1179
- // this.gs.dataRangeValue.next(this.selectedFilters);
1180
- window.location.reload()
1181
- // Emit the updated filters via the service
1182
- // this.gs.dataRangeValue.next(this.selectedFilters);
1183
- // Trigger refresh if necessary
1184
- // this.gs.manageRefreshTrigger.next(true);
1185
- this.cd.detectChanges();
1186
- }
1187
-
1188
-
1189
-
1190
- }
1191
- interface City {
1192
- city: string;
1193
- }
1194
-
1195
- interface Location {
1196
- city: City;
1197
- checked: boolean;
1198
- }
1199
- interface Country {
1200
- country: string;
1201
- checked: boolean;
1202
- }