@tuki-io/tuki-widgets 0.0.65 → 0.0.67

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 (233) hide show
  1. package/.editorconfig +16 -16
  2. package/.vscode/extensions.json +4 -4
  3. package/.vscode/launch.json +20 -20
  4. package/.vscode/tasks.json +42 -42
  5. package/README.md +25 -25
  6. package/package.json +1 -1
  7. package/projects/tuki/widgets/README.md +24 -24
  8. package/projects/tuki/widgets/di2mt/public-api.ts +3 -3
  9. package/projects/tuki/widgets/di2mt/widgets/site-upgrade/site-upgrade.module.ts +1 -1
  10. package/projects/tuki/widgets/karma.conf.js +44 -44
  11. package/projects/tuki/widgets/ng-package.json +10 -7
  12. package/projects/tuki/widgets/package.json +1 -1
  13. package/projects/tuki/widgets/src/lib/widgets.component.spec.ts +23 -23
  14. package/projects/tuki/widgets/src/lib/widgets.component.ts +20 -20
  15. package/projects/tuki/widgets/src/lib/widgets.module.ts +16 -16
  16. package/projects/tuki/widgets/src/lib/widgets.service.spec.ts +16 -16
  17. package/projects/tuki/widgets/src/lib/widgets.service.ts +9 -9
  18. package/projects/tuki/widgets/src/public-api.ts +7 -7
  19. package/projects/tuki/widgets/src/test.ts +27 -27
  20. package/projects/tuki/widgets/styles.scss +572 -572
  21. package/projects/tuki/widgets/tsconfig.lib.json +36 -36
  22. package/projects/tuki/widgets/tsconfig.lib.prod.json +10 -10
  23. package/projects/tuki/widgets/tsconfig.spec.json +17 -17
  24. package/projects/tuki/widgets/user-device-manage/ng-package.json +7 -7
  25. package/projects/tuki/widgets/user-device-manage/public-api.ts +8 -8
  26. package/projects/tuki/widgets/user-device-manage/src/app.constants.ts +96 -96
  27. package/projects/tuki/widgets/user-device-manage/src/assets/icons/arrow-left.svg +5 -5
  28. package/projects/tuki/widgets/user-device-manage/src/assets/icons/arrow-right.svg +5 -5
  29. package/projects/tuki/widgets/user-device-manage/src/assets/icons/close_icon_x.svg +3 -3
  30. package/projects/tuki/widgets/user-device-manage/src/assets/icons/delete_icon.svg +5 -5
  31. package/projects/tuki/widgets/user-device-manage/src/assets/icons/dragger-vertical-icon.svg +3 -3
  32. package/projects/tuki/widgets/user-device-manage/src/assets/icons/vartical_divider_icon.svg +3 -3
  33. package/projects/tuki/widgets/user-device-manage/src/classes/device.ts +292 -292
  34. package/projects/tuki/widgets/user-device-manage/src/classes/line-association-interface.ts +50 -50
  35. package/projects/tuki/widgets/user-device-manage/src/classes/line-association.ts +177 -177
  36. package/projects/tuki/widgets/user-device-manage/src/classes/line-call-info-display.ts +21 -21
  37. package/projects/tuki/widgets/user-device-manage/src/classes/line-directory.ts +41 -41
  38. package/projects/tuki/widgets/user-device-manage/src/classes/line.ts +144 -144
  39. package/projects/tuki/widgets/user-device-manage/src/classes/notification.ts +40 -40
  40. package/projects/tuki/widgets/user-device-manage/src/classes/recording-options.ts +6 -6
  41. package/projects/tuki/widgets/user-device-manage/src/classes/simplified-user.ts +169 -169
  42. package/projects/tuki/widgets/user-device-manage/src/classes/site-defaults.ts +167 -167
  43. package/projects/tuki/widgets/user-device-manage/src/classes/translation-pattern.ts +50 -50
  44. package/projects/tuki/widgets/user-device-manage/src/classes/types.ts +19 -19
  45. package/projects/tuki/widgets/user-device-manage/src/classes/user-interface.ts +225 -225
  46. package/projects/tuki/widgets/user-device-manage/src/classes/user.ts +8 -8
  47. package/projects/tuki/widgets/user-device-manage/src/common-functions.ts +16 -16
  48. package/projects/tuki/widgets/user-device-manage/src/confirm-dialog/info-dialog.component.html +14 -14
  49. package/projects/tuki/widgets/user-device-manage/src/confirm-dialog/info-dialog.component.scss +80 -80
  50. package/projects/tuki/widgets/user-device-manage/src/confirm-dialog/info-dialog.component.ts +35 -35
  51. package/projects/tuki/widgets/user-device-manage/src/device-associated-line/associated-line-row/associated-line-row.component.html +21 -21
  52. package/projects/tuki/widgets/user-device-manage/src/device-associated-line/associated-line-row/associated-line-row.component.scss +97 -97
  53. package/projects/tuki/widgets/user-device-manage/src/device-associated-line/associated-line-row/associated-line-row.component.ts +28 -28
  54. package/projects/tuki/widgets/user-device-manage/src/device-associated-line/device-associated-line-details-box/device-associated-line-details-box.component.html +5 -5
  55. package/projects/tuki/widgets/user-device-manage/src/device-associated-line/device-associated-line-details-box/device-associated-line-details-box.component.scss +19 -19
  56. package/projects/tuki/widgets/user-device-manage/src/device-associated-line/device-associated-line-details-box/device-associated-line-details-box.component.ts +13 -13
  57. package/projects/tuki/widgets/user-device-manage/src/device-associated-line/device-associated-line-extension/device-associated-line-extension.component.html +6 -6
  58. package/projects/tuki/widgets/user-device-manage/src/device-associated-line/device-associated-line-extension/device-associated-line-extension.component.scss +4 -4
  59. package/projects/tuki/widgets/user-device-manage/src/device-associated-line/device-associated-line-extension/device-associated-line-extension.component.ts +63 -63
  60. package/projects/tuki/widgets/user-device-manage/src/device-associated-line/device-associated-line.component.html +241 -241
  61. package/projects/tuki/widgets/user-device-manage/src/device-associated-line/device-associated-line.component.scss +500 -500
  62. package/projects/tuki/widgets/user-device-manage/src/device-associated-line/device-associated-line.component.ts +194 -194
  63. package/projects/tuki/widgets/user-device-manage/src/device-list/device-list.component.html +27 -27
  64. package/projects/tuki/widgets/user-device-manage/src/device-list/device-list.component.scss +131 -131
  65. package/projects/tuki/widgets/user-device-manage/src/device-list/device-list.component.ts +25 -25
  66. package/projects/tuki/widgets/user-device-manage/src/device-manage-widget.component.html +209 -209
  67. package/projects/tuki/widgets/user-device-manage/src/device-manage-widget.component.scss +502 -502
  68. package/projects/tuki/widgets/user-device-manage/src/device-manage-widget.component.ts +354 -354
  69. package/projects/tuki/widgets/user-device-manage/src/environments/environment.prod.ts +9 -9
  70. package/projects/tuki/widgets/user-device-manage/src/environments/environment.ts +10 -10
  71. package/projects/tuki/widgets/user-device-manage/src/interseptors/auth.interceptor.ts +35 -35
  72. package/projects/tuki/widgets/user-device-manage/src/lazy-loading-select/lazy-loading-select.component.html +50 -50
  73. package/projects/tuki/widgets/user-device-manage/src/lazy-loading-select/lazy-loading-select.component.scss +8 -8
  74. package/projects/tuki/widgets/user-device-manage/src/lazy-loading-select/lazy-loading-select.component.ts +81 -81
  75. package/projects/tuki/widgets/user-device-manage/src/material.module.ts +87 -87
  76. package/projects/tuki/widgets/user-device-manage/src/notifications/notification.component.html +33 -33
  77. package/projects/tuki/widgets/user-device-manage/src/notifications/notification.component.scss +84 -84
  78. package/projects/tuki/widgets/user-device-manage/src/notifications/notification.component.ts +46 -46
  79. package/projects/tuki/widgets/user-device-manage/src/removeKynFromIBM.service.ts +25 -25
  80. package/projects/tuki/widgets/user-device-manage/src/services/api.service.ts +87 -87
  81. package/projects/tuki/widgets/user-device-manage/src/services/common-functions.ts +17 -17
  82. package/projects/tuki/widgets/user-device-manage/src/services/device.service.ts +95 -95
  83. package/projects/tuki/widgets/user-device-manage/src/services/dns.service.ts +111 -111
  84. package/projects/tuki/widgets/user-device-manage/src/services/line.service.ts +89 -89
  85. package/projects/tuki/widgets/user-device-manage/src/services/notification.service.ts +68 -68
  86. package/projects/tuki/widgets/user-device-manage/src/services/removeKynFromIBM.service.ts +25 -25
  87. package/projects/tuki/widgets/user-device-manage/src/services/site-settings.service.ts +82 -82
  88. package/projects/tuki/widgets/user-device-manage/src/services/sorting-utils.service.ts +203 -203
  89. package/projects/tuki/widgets/user-device-manage/src/services/user.service.ts +283 -283
  90. package/projects/tuki/widgets/user-device-manage/src/services/utils.service.ts +87 -87
  91. package/projects/tuki/widgets/user-device-manage/src/services/validation.service.ts +829 -829
  92. package/projects/tuki/widgets/user-device-manage/src/styles/_variables.scss +90 -90
  93. package/projects/tuki/widgets/user-device-manage/src/styles/form.scss +231 -231
  94. package/projects/tuki/widgets/user-device-manage/src/styles/icons.scss +32 -32
  95. package/projects/tuki/widgets/user-device-manage/src/styles/styles.scss +110 -110
  96. package/projects/tuki/widgets/user-device-manage/src/styles/tables.scss +30 -30
  97. package/projects/tuki/widgets/user-device-manage/src/user-device-manage.module.ts +73 -73
  98. package/projects/tuki/widgets/user-device-manage/src/utils/app-loader/app-loader.component.html +6 -6
  99. package/projects/tuki/widgets/user-device-manage/src/utils/app-loader/app-loader.component.scss +11 -11
  100. package/projects/tuki/widgets/user-device-manage/src/utils/app-loader/app-loader.ts +13 -13
  101. package/projects/tuki/widgets/user-manage/ng-package.json +7 -7
  102. package/projects/tuki/widgets/user-manage/public-api.ts +6 -6
  103. package/projects/tuki/widgets/user-manage/src/app.constants.ts +50 -50
  104. package/projects/tuki/widgets/user-manage/src/assets/icons/arrow-left.svg +5 -5
  105. package/projects/tuki/widgets/user-manage/src/assets/icons/arrow-right.svg +5 -5
  106. package/projects/tuki/widgets/user-manage/src/assets/icons/delete_icon.svg +5 -5
  107. package/projects/tuki/widgets/user-manage/src/assets/icons/dragger-vertical-icon.svg +3 -3
  108. package/projects/tuki/widgets/user-manage/src/assets/icons/vartical_divider_icon.svg +3 -3
  109. package/projects/tuki/widgets/user-manage/src/classes/device.ts +232 -232
  110. package/projects/tuki/widgets/user-manage/src/classes/line-association-interface.ts +43 -43
  111. package/projects/tuki/widgets/user-manage/src/classes/line-association.ts +161 -161
  112. package/projects/tuki/widgets/user-manage/src/classes/line-call-info-display.ts +21 -21
  113. package/projects/tuki/widgets/user-manage/src/classes/line-directory.ts +42 -42
  114. package/projects/tuki/widgets/user-manage/src/classes/line.ts +144 -144
  115. package/projects/tuki/widgets/user-manage/src/classes/notification.ts +39 -39
  116. package/projects/tuki/widgets/user-manage/src/classes/pagination.ts +18 -18
  117. package/projects/tuki/widgets/user-manage/src/classes/recording-options.ts +6 -6
  118. package/projects/tuki/widgets/user-manage/src/classes/simplified-user.ts +165 -165
  119. package/projects/tuki/widgets/user-manage/src/classes/table-data.ts +6 -6
  120. package/projects/tuki/widgets/user-manage/src/classes/translation-pattern.ts +49 -49
  121. package/projects/tuki/widgets/user-manage/src/classes/user-interface.ts +225 -225
  122. package/projects/tuki/widgets/user-manage/src/classes/user-list.ts +42 -42
  123. package/projects/tuki/widgets/user-manage/src/classes/user.ts +8 -8
  124. package/projects/tuki/widgets/user-manage/src/common-functions.ts +16 -16
  125. package/projects/tuki/widgets/user-manage/src/device-list/device-list.component.html +27 -27
  126. package/projects/tuki/widgets/user-manage/src/device-list/device-list.component.scss +131 -131
  127. package/projects/tuki/widgets/user-manage/src/device-list/device-list.component.ts +25 -25
  128. package/projects/tuki/widgets/user-manage/src/environments/environment.prod.ts +9 -9
  129. package/projects/tuki/widgets/user-manage/src/environments/environment.ts +10 -10
  130. package/projects/tuki/widgets/user-manage/src/interseptors/auth.interceptor.ts +35 -35
  131. package/projects/tuki/widgets/user-manage/src/lazy-loading-select/lazy-loading-select.component.html +50 -50
  132. package/projects/tuki/widgets/user-manage/src/lazy-loading-select/lazy-loading-select.component.scss +8 -8
  133. package/projects/tuki/widgets/user-manage/src/lazy-loading-select/lazy-loading-select.component.ts +81 -81
  134. package/projects/tuki/widgets/user-manage/src/material.module.ts +85 -85
  135. package/projects/tuki/widgets/user-manage/src/notifications/notification.component.html +33 -33
  136. package/projects/tuki/widgets/user-manage/src/notifications/notification.component.scss +84 -84
  137. package/projects/tuki/widgets/user-manage/src/notifications/notification.component.ts +46 -46
  138. package/projects/tuki/widgets/user-manage/src/removeKynFromIBM.service.ts +25 -25
  139. package/projects/tuki/widgets/user-manage/src/services/api.service.ts +90 -90
  140. package/projects/tuki/widgets/user-manage/src/services/dns.service.ts +116 -116
  141. package/projects/tuki/widgets/user-manage/src/services/line.service.ts +31 -31
  142. package/projects/tuki/widgets/user-manage/src/services/notification.service.ts +68 -68
  143. package/projects/tuki/widgets/user-manage/src/services/removeKynFromIBM.service.ts +25 -25
  144. package/projects/tuki/widgets/user-manage/src/services/site-settings.service.ts +35 -35
  145. package/projects/tuki/widgets/user-manage/src/services/sorting-utils.service.ts +203 -203
  146. package/projects/tuki/widgets/user-manage/src/services/user.service.ts +242 -242
  147. package/projects/tuki/widgets/user-manage/src/services/users-search.service.ts +59 -59
  148. package/projects/tuki/widgets/user-manage/src/services/utils.service.ts +71 -71
  149. package/projects/tuki/widgets/user-manage/src/styles/_variables.scss +90 -90
  150. package/projects/tuki/widgets/user-manage/src/styles/form.scss +231 -231
  151. package/projects/tuki/widgets/user-manage/src/styles/icons.scss +32 -32
  152. package/projects/tuki/widgets/user-manage/src/styles/styles.scss +110 -110
  153. package/projects/tuki/widgets/user-manage/src/styles/tables.scss +30 -30
  154. package/projects/tuki/widgets/user-manage/src/user-calling/user-calling-extension/user-calling-extension.component.html +10 -10
  155. package/projects/tuki/widgets/user-manage/src/user-calling/user-calling-extension/user-calling-extension.component.scss +429 -429
  156. package/projects/tuki/widgets/user-manage/src/user-calling/user-calling-extension/user-calling-extension.component.ts +63 -63
  157. package/projects/tuki/widgets/user-manage/src/user-calling/user-calling.component.html +32 -32
  158. package/projects/tuki/widgets/user-manage/src/user-calling/user-calling.component.scss +444 -444
  159. package/projects/tuki/widgets/user-manage/src/user-calling/user-calling.component.ts +89 -89
  160. package/projects/tuki/widgets/user-manage/src/user-details/notification.service.ts +68 -68
  161. package/projects/tuki/widgets/user-manage/src/user-info/user-info.component.html +29 -29
  162. package/projects/tuki/widgets/user-manage/src/user-info/user-info.component.scss +64 -64
  163. package/projects/tuki/widgets/user-manage/src/user-info/user-info.component.ts +19 -19
  164. package/projects/tuki/widgets/user-manage/src/user-manage-widget.component.html +290 -290
  165. package/projects/tuki/widgets/user-manage/src/user-manage-widget.component.scss +463 -463
  166. package/projects/tuki/widgets/user-manage/src/user-manage-widget.component.ts +212 -212
  167. package/projects/tuki/widgets/user-manage/src/user-manage.module.ts +63 -63
  168. package/projects/tuki/widgets/user-manage/src/utils/app-loader/app-loader.component.html +6 -6
  169. package/projects/tuki/widgets/user-manage/src/utils/app-loader/app-loader.component.scss +11 -11
  170. package/projects/tuki/widgets/user-manage/src/utils/app-loader/app-loader.ts +13 -13
  171. package/projects/tuki/widgets/user-manage/src/utils/pagination/pagination.component.html +26 -26
  172. package/projects/tuki/widgets/user-manage/src/utils/pagination/pagination.component.scss +41 -41
  173. package/projects/tuki/widgets/user-manage/src/utils/pagination/pagination.component.ts +41 -41
  174. package/projects/tuki/widgets/users-list/ng-package.json +6 -6
  175. package/projects/tuki/widgets/users-list/public-api.ts +8 -8
  176. package/projects/tuki/widgets/users-list/src/app.constants.ts +54 -54
  177. package/projects/tuki/widgets/users-list/src/assets/icons/close_icon_modal.svg +3 -3
  178. package/projects/tuki/widgets/users-list/src/assets/icons/move_user_to_another_location.svg +14 -14
  179. package/projects/tuki/widgets/users-list/src/assets/icons/white-close-icon.svg +3 -3
  180. package/projects/tuki/widgets/users-list/src/classes/app-location.ts +36 -36
  181. package/projects/tuki/widgets/users-list/src/classes/device.ts +225 -225
  182. package/projects/tuki/widgets/users-list/src/classes/line.ts +144 -144
  183. package/projects/tuki/widgets/users-list/src/classes/move-user.ts +225 -225
  184. package/projects/tuki/widgets/users-list/src/classes/notification.ts +38 -38
  185. package/projects/tuki/widgets/users-list/src/classes/pagination.ts +18 -18
  186. package/projects/tuki/widgets/users-list/src/classes/simlified-user.ts +74 -74
  187. package/projects/tuki/widgets/users-list/src/classes/table-data.ts +6 -6
  188. package/projects/tuki/widgets/users-list/src/classes/user-interface.ts +225 -225
  189. package/projects/tuki/widgets/users-list/src/classes/user-list.ts +47 -47
  190. package/projects/tuki/widgets/users-list/src/classes/user.ts +8 -8
  191. package/projects/tuki/widgets/users-list/src/material.module.ts +94 -94
  192. package/projects/tuki/widgets/users-list/src/move-user-wizard/move-user-stepper/device-move-user/device-move-user-wizard.component.html +37 -37
  193. package/projects/tuki/widgets/users-list/src/move-user-wizard/move-user-stepper/device-move-user/device-move-user-wizard.component.scss +129 -129
  194. package/projects/tuki/widgets/users-list/src/move-user-wizard/move-user-stepper/device-move-user/device-move-user-wizard.component.ts +46 -46
  195. package/projects/tuki/widgets/users-list/src/move-user-wizard/move-user-stepper/device-move-user-tab/devices-move-user-wizard-tab.component.html +31 -31
  196. package/projects/tuki/widgets/users-list/src/move-user-wizard/move-user-stepper/device-move-user-tab/devices-move-user-wizard-tab.component.scss +20 -20
  197. package/projects/tuki/widgets/users-list/src/move-user-wizard/move-user-stepper/device-move-user-tab/devices-move-user-wizard-tab.component.ts +26 -26
  198. package/projects/tuki/widgets/users-list/src/move-user-wizard/move-user-stepper/move-user-stepper.component.html +222 -222
  199. package/projects/tuki/widgets/users-list/src/move-user-wizard/move-user-stepper/move-user-stepper.component.scss +239 -239
  200. package/projects/tuki/widgets/users-list/src/move-user-wizard/move-user-stepper/move-user-stepper.component.ts +206 -206
  201. package/projects/tuki/widgets/users-list/src/move-user-wizard/move-user-wizard.component.html +12 -12
  202. package/projects/tuki/widgets/users-list/src/move-user-wizard/move-user-wizard.component.scss +41 -41
  203. package/projects/tuki/widgets/users-list/src/move-user-wizard/move-user-wizard.component.ts +36 -36
  204. package/projects/tuki/widgets/users-list/src/services/api-webex.service.ts +14 -14
  205. package/projects/tuki/widgets/users-list/src/services/api.service.ts +90 -90
  206. package/projects/tuki/widgets/users-list/src/services/dns.service.ts +128 -128
  207. package/projects/tuki/widgets/users-list/src/services/events-communication.service.ts +11 -11
  208. package/projects/tuki/widgets/users-list/src/services/move-user.service.ts +59 -59
  209. package/projects/tuki/widgets/users-list/src/services/notification.service.ts +68 -68
  210. package/projects/tuki/widgets/users-list/src/services/removeKynFromIBM.service.ts +25 -25
  211. package/projects/tuki/widgets/users-list/src/services/site-settings.service.ts +26 -26
  212. package/projects/tuki/widgets/users-list/src/services/user.service.ts +159 -159
  213. package/projects/tuki/widgets/users-list/src/services/users-search.service.ts +137 -137
  214. package/projects/tuki/widgets/users-list/src/styles/styles.scss +572 -572
  215. package/projects/tuki/widgets/users-list/src/user-list-confirm-dialog/user-list-confirm-dialog.component.html +15 -15
  216. package/projects/tuki/widgets/users-list/src/user-list-confirm-dialog/user-list-confirm-dialog.component.scss +103 -103
  217. package/projects/tuki/widgets/users-list/src/user-list-confirm-dialog/user-list-confirm-dialog.component.ts +35 -35
  218. package/projects/tuki/widgets/users-list/src/users-list.component.html +86 -86
  219. package/projects/tuki/widgets/users-list/src/users-list.component.scss +572 -572
  220. package/projects/tuki/widgets/users-list/src/users-list.component.ts +312 -312
  221. package/projects/tuki/widgets/users-list/src/users-list.module.ts +63 -63
  222. package/projects/tuki/widgets/users-list/src/utils/app-loader/app-loader.component.html +6 -6
  223. package/projects/tuki/widgets/users-list/src/utils/app-loader/app-loader.component.scss +11 -11
  224. package/projects/tuki/widgets/users-list/src/utils/app-loader/app-loader.ts +13 -13
  225. package/projects/tuki/widgets/users-list/src/utils/common-functions.ts +32 -32
  226. package/projects/tuki/widgets/users-list/src/utils/notifications/notification.component.html +33 -33
  227. package/projects/tuki/widgets/users-list/src/utils/notifications/notification.component.scss +84 -84
  228. package/projects/tuki/widgets/users-list/src/utils/notifications/notification.component.ts +46 -46
  229. package/projects/tuki/widgets/users-list/src/utils/pagination/pagination.component.html +26 -26
  230. package/projects/tuki/widgets/users-list/src/utils/pagination/pagination.component.scss +41 -41
  231. package/projects/tuki/widgets/users-list/src/utils/pagination/pagination.component.ts +41 -41
  232. package/projects/tuki/widgets/users-list/src/utils/utils.service.ts +71 -71
  233. package/tsconfig.json +46 -46
@@ -1,829 +1,829 @@
1
- import { Injectable } from '@angular/core';
2
- import { SiteSettingsService } from './site-settings.service';
3
- import { DeviceTypes, MailboxQuotasType, SpeedDialType, VMNotificationsTypes } from './../classes/types';
4
- import { Device, DeviceKind } from './../classes/device';
5
-
6
- const speedDialRegex = new RegExp('^[^"]*$');
7
- const BLFRegex = new RegExp('^[^"><&%]*$');
8
- const timeRegex = new RegExp('^([0-1][0-9]|[2][0-3]):([0-5][0-9])$');
9
-
10
- @Injectable()
11
- export class ValidationService {
12
-
13
- constructor(
14
- private siteSettingsService: SiteSettingsService,
15
- ) {
16
- }
17
-
18
- e164MaskLabel(control: any) {
19
- const ruleText = `^[0-9*#+X]{0,24}$`;
20
- const rule = new RegExp(ruleText, 'g');
21
- if (control.value && rule && !rule.test(control.value)) {
22
- return {e164MaskRule: {rule: ruleText}};
23
- }
24
- return null;
25
- }
26
-
27
- index(control: any) {
28
- const value = parseInt(control.value);
29
- if (!value) {
30
- return null;
31
- }
32
- const pattern = '^[+0-9]*$';
33
- if (value && !Number.isInteger(value) || value < 1 || value > 199) {
34
- return {indexRule: true};
35
- }
36
- return null;
37
- }
38
-
39
- displayLabel(control: any) {
40
- const ruleText = `^[^""""%&<>]{0,30}$`;
41
- const rule = new RegExp(ruleText, 'g');
42
- if (rule && !rule.test(control.value)) {
43
- return {labelRule: {rule: ruleText, count: 30}};
44
- }
45
- return null;
46
- }
47
-
48
-
49
-
50
- displayLabelAscii(control: any) {
51
- const ruleText = '^[a-zA-Z0-9 !#$\'()*+,./:;=?@\\^_`}~-]{0,30}$';
52
- const rule = new RegExp(ruleText, 'g');
53
- if (rule && !rule.test(control.value)) {
54
- return {labelRule: {rule: ruleText, count: 30}};
55
- }
56
- return null;
57
- }
58
-
59
- requiredForSpeedDialPosition(type: string) {
60
-
61
- return (control: any) => {
62
- const parent = control.parent;
63
- if (type === SpeedDialType.slotBasic || !parent) {
64
- return null;
65
- }
66
- if (!control.value) {
67
- return {required: true};
68
- }
69
- return null;
70
- };
71
- }
72
-
73
- speedDialDestination() {
74
- return (control: any) => {
75
- if (!control || !control.value) {
76
- return null;
77
- }
78
- const numberOrHostNameIP = '' +
79
- '^([0-9\\*#+PpCcFf,]+)$' +
80
- '|' +
81
- '^(' +
82
- '([a-zA-Z0-9]){1,47}@' +
83
- '(' +
84
- '((?:[0-9]{1,3}\\.){3}[0-9]{1,3})' +
85
- '|' +
86
- '([a-zA-Z0-9][a-zA-Z0-9\\-]{1,61}[a-zA-Z0-9]\\.[a-zA-Z]{2,})' +
87
- ')' +
88
- ')$';
89
- const rule = new RegExp(numberOrHostNameIP, 'g');
90
- if (rule && !rule.test(control.value)) {
91
- return {pattern: true};
92
- }
93
- return null;
94
- };
95
-
96
- }
97
-
98
- requiredForSpeedDialDestination(type: string) {
99
-
100
- return (control: any) => {
101
- const parent = control.parent;
102
- if ((!parent || !parent.get('label')) || (type === SpeedDialType.slotBasic && !control.value && !parent.get('label').value)) {
103
- return null;
104
- }
105
- return null;
106
- };
107
- }
108
-
109
-
110
- labelPatternDependingOnType(control: any) {
111
- const parent = control?.parent;
112
- if (!parent || !parent.get('type') || !control.value) {
113
- return null;
114
- }
115
- const type = parent.get('type').value;
116
- if (!type && !speedDialRegex.test(control.value)) {
117
- return {labelRule: {wrong: '"'}};
118
- }
119
- if (type && !BLFRegex.test(control.value)) {
120
- return {labelRule: {wrong: '"><&%'}};
121
- }
122
- return null;
123
- }
124
-
125
- labelPatternBLF(control: any) {
126
- if (control.value && !BLFRegex.test(control.value)) {
127
- return {labelRule: {wrong: '"><&%'}};
128
- }
129
- return null;
130
- }
131
-
132
- labelPatternSpeedDial(control: any) {
133
- if (control?.value && !speedDialRegex.test(control.value)) {
134
- return {labelRule: {wrong: '"'}};
135
- }
136
- return null;
137
- }
138
-
139
- matchControl = (fieldName: string) => {
140
- return (control: any) => {
141
- if (!control?.parent) {
142
- return null;
143
- }
144
- const matchingControl = control.parent.get(fieldName);
145
- if (matchingControl.value && matchingControl.value !== control.value) {
146
- return {
147
- matchControl: true
148
- };
149
- }
150
- return null;
151
- };
152
- };
153
-
154
- matchLength = (fieldName: string) => {
155
- return (control: any) => {
156
- if (!control.parent || !control.value) {
157
- return null;
158
- }
159
- const matchingControl = control.parent.get(fieldName);
160
- if (((!control.value.startsWith('+') && !matchingControl.value.startsWith('+')) ||
161
- (control.value.startsWith('+') && matchingControl.value.startsWith('+'))) &&
162
- ((!control.value.startsWith('\\+') && !matchingControl.value.startsWith('\\+')) ||
163
- (control.value.startsWith('\\+') && matchingControl.value.startsWith('\\+'))) &&
164
- matchingControl.value.length !== control.value.length) {
165
- return {
166
- matchLength: true
167
- };
168
- }
169
- return null;
170
- };
171
- };
172
-
173
- dynamicMaxLength = (length1: number, length2: number) => {
174
- return (control: any) => {
175
- if (!control.parent || !control.value) {
176
- return null;
177
- }
178
- const maxLength = String(control.value).includes('[') ? length1 : length2;
179
- if (control.value.length > maxLength) {
180
- return {
181
- maxLength: true
182
- };
183
- }
184
- return null;
185
- };
186
- };
187
-
188
- biggerThan = (fieldName: string) => {
189
- return (control: any) => {
190
- if (!control.parent || !control.value) {
191
- return null;
192
- }
193
- const matchingControl = control.parent.get(fieldName);
194
- if (matchingControl.value.length === control.value.length && matchingControl.value && matchingControl.value > control.value) {
195
- return {
196
- biggerThan: true
197
- };
198
- }
199
- return null;
200
- };
201
- };
202
-
203
- requiredByType = (fieldName: string, type: string) => {
204
- return (control: any) => {
205
- if (
206
- fieldName === 'phoneSystem' && (type === VMNotificationsTypes['Phone Device'] || type === VMNotificationsTypes['Pager Device']) ||
207
- fieldName === 'htmlTemplate' && type === VMNotificationsTypes['HTML Device']
208
- ) {
209
- return {
210
- required: true
211
- };
212
- }
213
- return null;
214
- };
215
- };
216
-
217
- smallerThanQuota = (fieldName: string, quotaType: string, secondQuotaType: string) => {
218
- return (control: any) => {
219
- if (!control.parent) {
220
- return null;
221
- }
222
- const matchingControl = control.parent.get(fieldName);
223
- const quotaTypeControl = control.parent.get(quotaType);
224
- const secondQuotaTypeControl = control.parent.get(secondQuotaType);
225
-
226
- if (quotaTypeControl && secondQuotaTypeControl && secondQuotaTypeControl.value === MailboxQuotasType.system) {
227
- return null;
228
- }
229
-
230
- if (quotaTypeControl && quotaTypeControl.value === MailboxQuotasType.system || matchingControl && matchingControl.value && parseInt(matchingControl.value) < parseInt(control.value)) {
231
- return {
232
- smallerThan: true
233
- };
234
- }
235
- return null;
236
- };
237
- };
238
-
239
- biggerThanQuota = (fieldName: string, quotaType: string) => {
240
- return (control: any) => {
241
- if (!control?.parent) {
242
- return null;
243
- }
244
- const matchingControl = control.parent.get(fieldName);
245
- const quotaTypeControl = control.parent.get(quotaType);
246
-
247
- if (quotaTypeControl && quotaTypeControl.value === MailboxQuotasType.custom && matchingControl.value && parseInt(matchingControl.value) > parseInt(control.value)) {
248
- return {
249
- biggerThan: true
250
- };
251
- }
252
- return null;
253
- };
254
- };
255
-
256
- rangeLimit = (fieldName: string) => {
257
- return (control: any) => {
258
- if (!control?.parent || !control.value) {
259
- return null;
260
- }
261
- const matchingControl = control.parent.get(fieldName);
262
- if ((control.value - matchingControl.value) > 50000) {
263
- return {
264
- rangeLimit: true
265
- };
266
- }
267
- return null;
268
- };
269
- };
270
-
271
- comparepatternParts = (fieldName: string) => {
272
- return (control: any) => {
273
- if (!control?.value) {
274
- return null;
275
- }
276
- const matches = control.value.match(/\[(.*?)\]/);
277
- if (matches) {
278
- const submatch = matches[1];
279
- const submatchsplit: number[] = submatch.split('-');
280
- for (let i = 0; i < submatchsplit.length; i++) {
281
- if (submatchsplit[i] >= submatchsplit[i + 1]) {
282
- return {
283
- comparepatternParts: true
284
- };
285
- }
286
- }
287
- }
288
- return null;
289
- };
290
- };
291
-
292
- matchPrefix = (fieldName: string) => {
293
- return (control: any) => {
294
- if (!control?.parent || !control.value) {
295
- return null;
296
- }
297
- const matchingControl = control.parent.get(fieldName);
298
- if ((matchingControl.value.startsWith('+') || control.value.startsWith('+') || matchingControl.value.startsWith('\\+') || control.value.startsWith('\\+')) && (control.value.charAt(0) !== matchingControl.value.charAt(0))) {
299
- return {
300
- matchPrefix: true
301
- };
302
- }
303
- return null;
304
- };
305
- };
306
-
307
- deviceNameValidator = (device: Device) => {
308
- return (control: any) => {
309
- if (!control.value || device.deviceKind === DeviceKind.deviceProfile) {
310
- return;
311
- }
312
- if (device.isCtiRoutePoint) {
313
- let err = '';
314
- if (!control.value.match(/^[a-zA-Z0-9-_.]+$/)) {
315
- err = 'pattern';
316
- }
317
- if (control.value.trim().length > 15) {
318
- err = 'maxLength';
319
- }
320
- return err ? {nameRule: err} : null;
321
- }
322
- if (device.deviceDefaults && !device.isCtiRoutePoint) {
323
- const ruleText = device.deviceDefaults.deviceNameRegex;
324
- const rule = new RegExp(ruleText, 'g');
325
- const caption = device.deviceDefaults?.deviceNameExplained;
326
- const match = (control.value || '').match(rule) || [];
327
- const exactMatch = match && control.value === match[0];
328
- if (rule && !exactMatch) {
329
- return {nameRule: {caption}};
330
- }
331
- }
332
- return null;
333
- };
334
- };
335
-
336
- deviceNameValueValidator = (device: Device, deviceName: string) => {
337
- return (control: any) => {
338
- if (!control.value || device.deviceKind === DeviceKind.deviceProfile) {
339
- return;
340
- }
341
- if (device.name && device.alreadyUsedName && device.name === device.alreadyUsedName) {
342
- return {nameRule: 'alreadyUsedName'};
343
- }
344
- if (device.isCtiRoutePoint) {
345
- let err = '';
346
- if (!deviceName.match(/^[a-zA-Z0-9-_.]+$/)) {
347
- err = 'pattern';
348
- }
349
- if (deviceName.trim().length > 15) {
350
- err = 'maxLength';
351
- }
352
- return err ? {nameRule: err} : null;
353
- }
354
- if (device.deviceDefaults && !device.isCtiRoutePoint) {
355
- const ruleText = device.deviceDefaults.deviceNameRegex;
356
- // console.log('Dev name rule - ', ruleText);
357
- const rule = new RegExp(ruleText, 'g');
358
- let caption = device.deviceDefaults.deviceNameExplained;
359
- if (!caption) {
360
- caption = ruleText;
361
- }
362
- const match = (deviceName || '').match(rule) || [];
363
- const exactMatch = match && deviceName === match[0];
364
- if (rule && !exactMatch) {
365
- return {nameRule: {caption}};
366
- }
367
- }
368
- return null;
369
- };
370
- };
371
-
372
- deviceDuplicatingNameValidator = (user: any, pkid ?: string, prefix?: string) => {
373
- return (control: any) => {
374
- if (!control.value || !user || !user.devices || user.devices.length === 0) {
375
- return;
376
- }
377
- const deviceName = prefix ? `${prefix}${control.value}` : control.value;
378
- const devicesWithTheSameName = user.devices.filter((device: Device) => device.name === deviceName);
379
- if (devicesWithTheSameName.length > 0) {
380
- if (!pkid) { // For new device
381
- return {duplicateNameRule: true};
382
- } else if (pkid !== devicesWithTheSameName[0].pkid) { // For updating device, avoid validating with itself
383
- return {duplicateNameRule: true};
384
- }
385
- }
386
- return null;
387
- };
388
- };
389
-
390
- conditionalRequired = (fieldName: string, requiredConditionValues: any[]) => {
391
- return (control: any) => {
392
- const parent1 = control.parent;
393
- if (!parent1 || !parent1.get(fieldName) || !parent1.get(fieldName).value) {
394
- return;
395
- }
396
- if (requiredConditionValues.includes(parent1.get(fieldName).value) && !control.value) {
397
- return {
398
- required: true
399
- };
400
- }
401
- return null;
402
- };
403
- };
404
-
405
- conditionalRequiredForGroupAdmin = (fieldName: string, requiredConditionValues: any[]) => {
406
- return (control: any) => {
407
- const parent1 = control.parent;
408
- if (!parent1 || !parent1.get(fieldName) || !parent1.get(fieldName).value || !parent1.get(fieldName).value.type) {
409
- return;
410
- }
411
- if (requiredConditionValues.includes(parent1.get(fieldName).value.type) && !control.value) {
412
- return {
413
- required: true
414
- };
415
- }
416
- return null;
417
- };
418
- };
419
-
420
- conditionalSiteGroupCheckForGroupAdmin = (fieldName: string, requiredConditionValues: any[]) => {
421
- return (control: any) => {
422
- const parent1 = control.parent;
423
- if (!parent1 || !parent1.get(fieldName) || !parent1.get(fieldName).value || !parent1.get(fieldName).value.type) {
424
- return;
425
- }
426
- if (parent1.get(fieldName).value && requiredConditionValues.includes(parent1.get(fieldName).value.type) &&
427
- parent1.get('siteGroup') && parent1.get('siteGroup').value &&
428
- parent1.get('siteGroup').value.siteGroupMembers && parent1.get('siteGroup').value.siteGroupMembers.length < 1) {
429
- return {
430
- hasSiteGroupError: true
431
- };
432
- }
433
- return null;
434
- };
435
- };
436
-
437
- requiredIfFieldIsEmptyForBLF = (fieldName: any) => {
438
- const DATE_PATTERN = '^(0[1-9]|1[012])[- \/.](0[1-9]|[12][0-9]|3[01])[- \/.](19|20)\d\d$';
439
- return (control: any) => {
440
- const parent = control.parent;
441
- if (!parent || !parent.get(fieldName)) {
442
- return null;
443
- }
444
- if (!parent.get(fieldName).value && !control.value) {
445
- return {
446
- requiredEither: true,
447
- requiredBLFDN: true
448
- };
449
- }
450
- return null;
451
- };
452
- };
453
-
454
-
455
- validDate = (fieldName: string) => {
456
-
457
- return (control: any) => {
458
- const parent = control.parent;
459
- const ruleText = '^(0[1-9]|1[012])[- \/.](0[1-9]|[12][0-9]|3[01])[- \/.](19|20)\d\d$';
460
- const rule = new RegExp(ruleText, 'g');
461
- const val = control.value && control.value.getDate();
462
- if (rule && !rule.test(val)) {
463
- return {pattern: true};
464
- }
465
- return null;
466
- };
467
- };
468
-
469
-
470
- matchOption = (optionType: string, list?: any, isFullList?: boolean) => {
471
- return (control: any) => {
472
- if (!control.value || control.value === DeviceTypes.CTI_ROUTE_POINT) {
473
- return null;
474
- }
475
- let optionList = list || this.getOptionsList(optionType);
476
- if (optionList && optionList.length) {
477
- if (!isFullList && optionType === 'directoryNumbers') {
478
- optionList = optionList.map((str: string) => str.indexOf(' ') > -1 ? str.substring(0, str.indexOf(' ')) : str);
479
- }
480
- if (!optionList.includes(control.value)) {
481
- return {
482
- matchOptions: true
483
- };
484
- }
485
- }
486
- return null;
487
- };
488
- };
489
-
490
- confidentialAccessLevel = (confidentialAccessMode: string) => {
491
- return (control: any) => {
492
- if (!control.value && !confidentialAccessMode) {
493
- return null;
494
- }
495
- if (!control.value) {
496
- return {
497
- required: true
498
- };
499
- }
500
- return null;
501
- };
502
- };
503
-
504
- noResultDN = (optionType: string, list?: any) => {
505
- return (control: any) => {
506
- if (!control.value || list === null) {
507
- return null;
508
- }
509
- if (list && list.length === 0) {
510
- return {
511
- noResultDNs: true
512
- };
513
- }
514
- return null;
515
- };
516
- };
517
-
518
- matchExtensionOption = (optionType: string, optionList?: any) => {
519
- return (control: any) => {
520
- if (!control.value) {
521
- return control.value;
522
- }
523
- // @ts-ignore
524
- const newList = [];
525
- if (optionList && optionList.length) {
526
- optionList.forEach((list: any) => {
527
- const newOptionList = this.getMatchExistingVmLineValue(list);
528
- newList.push(newOptionList);
529
- });
530
- // @ts-ignore
531
- if (newList && !newList.includes(control.value)) {
532
- return {
533
- matchOptions: true
534
- };
535
- }
536
- } else if (!optionList || !optionList.length) {
537
- return {
538
- matchOptions: true
539
- };
540
- }
541
- return null;
542
- };
543
- };
544
-
545
- public getMatchExistingVmLineValue(dnWithType: string): string {
546
- const ind = dnWithType.indexOf('Type:');
547
- let dn = dnWithType;
548
- if (ind > -1) {
549
- dn = dnWithType.slice(0, ind);
550
- dn = dn.trim();
551
- }
552
- return dn;
553
- }
554
-
555
- requiredEitherForVmExtension = (fieldName1: string, fieldName2: string) => {
556
- return (control: any) => {
557
- if (!control.parent) {
558
- return null;
559
- }
560
- const matchControl1 = control.parent.get(fieldName1).value;
561
- const matchControl2 = control.parent.get(fieldName2).value;
562
- if (!matchControl1 && !matchControl2) {
563
- return {
564
- requiredEitherForVmExtension: true
565
- };
566
- }
567
- return null;
568
- };
569
- };
570
-
571
- requiredEitherOne = (fieldName1: string, fieldName2: string) => {
572
- return (control: any) => {
573
- if (!control.parent) {
574
- return null;
575
- }
576
- const matchControl1 = control.parent.get(fieldName1) && control.parent.get(fieldName1).value;
577
- const matchControl2 = control.parent.get(fieldName2) && control.parent.get(fieldName2).value;
578
- if (!matchControl1 && !matchControl2) {
579
- return {
580
- requiredEitherOne: true
581
- };
582
- }
583
- return null;
584
- };
585
- };
586
-
587
- requiredByValue = (fieldName: string, requestedFieldVal: any) => {
588
- return (control: any) => {
589
- if (!control || !control.parent) {
590
- return null;
591
- }
592
- const fieldVal = control.parent.get(fieldName) && control.parent.get(fieldName).value;
593
- if (fieldVal && fieldVal === requestedFieldVal && !control.value) {
594
- return {
595
- required: true
596
- };
597
- }
598
- return null;
599
- };
600
- };
601
-
602
- OneExtensionEmpty = (fieldName1: string, fieldName2: string) => {
603
- return (control: any) => {
604
- if (!control.parent) {
605
- return null;
606
- }
607
- const matchControl1 = control.parent.get(fieldName1).value;
608
- const matchControl2 = control.parent.get(fieldName2).value;
609
- if (matchControl1 && matchControl2) {
610
- return {
611
- OneExtensionIsEmpty: true
612
- };
613
- }
614
- return null;
615
- };
616
- };
617
-
618
- requiredByCondition = (requiredBy: string, fieldName: any) => {
619
- return (control: any) => {
620
- if (!control.parent) {
621
- return null;
622
- }
623
- const requiredByControl = control.parent.get(requiredBy).value;
624
- const requiredControl = control.parent.get(fieldName).value;
625
- if (requiredByControl && !requiredControl) {
626
- return {
627
- required: true
628
- };
629
- }
630
- return null;
631
- };
632
- };
633
-
634
- private getOptionsList(token: string): string[] {
635
- switch (token) {
636
- case 'css':
637
- case 'rerouteCss':
638
- case 'callingSearchSpace':
639
- return this.siteSettingsService.callingSearchSpaceTypes;
640
- case 'reroutingCss':
641
- return this.siteSettingsService.siteDefaults && this.siteSettingsService.siteDefaults.cssFilter;
642
- case 'deviceType':
643
- return this.siteSettingsService.deviceTypes;
644
- case 'routePartition':
645
- return this.siteSettingsService.routePartitionNames;
646
- case 'routePartitionFiltered':
647
- return this.siteSettingsService.filteredRoutePartitionNames;
648
- case 'devicePools':
649
- return this.siteSettingsService.devicePools;
650
- case 'allRoutePartitions':
651
- return this.siteSettingsService.allRoutePartitionNames;
652
- case 'directoryNumbers':
653
- return this.siteSettingsService.directoryNumbers;
654
- default:
655
- return [];
656
- }
657
- }
658
-
659
- autocompleteType(control: any) {
660
- if (!control.value) {
661
- return null;
662
- }
663
- if (typeof control.value !== 'object' && control.value !== '') {
664
- return {
665
- stringEntered: true
666
- };
667
- }
668
- return null;
669
- }
670
-
671
-
672
- password(control: any) {
673
- const ruleNumeric = new RegExp(/\d+/, 'g');
674
- const ruleCapitals = new RegExp(/[A-Z]+/, 'g');
675
- const ruleSmall = new RegExp(/[a-z]+/, 'g');
676
- const ruleSpecial = new RegExp(/[!@#$%&\/=\?_\.,:;\-\\+]+/, 'g');
677
-
678
- const hasNumeric = +ruleNumeric.test(control.value);
679
- const hasCapitals = +ruleCapitals.test(control.value);
680
- const hasSmall = +ruleSmall.test(control.value);
681
- const hasSpecial = +ruleSpecial.test(control.value);
682
-
683
- if (hasNumeric + hasCapitals + hasSmall + hasSpecial < 3) {
684
- return {
685
- weakPassword: true
686
- };
687
- }
688
-
689
- return null;
690
- }
691
-
692
- verifyAutoAnswer(control: any) {
693
- if (!control?.value || control.value.length === 0) {
694
- return null;
695
- }
696
- let autoAnswerErrorLine = null;
697
- if (control.parent && control.parent.parent && control.parent.parent.parent && control.parent.parent.parent.parent) {
698
- const controlSNR = control.parent;
699
- const controlUser = control.parent.parent.parent.parent;
700
- const lineAssociations = controlSNR.get('lineAssociations');
701
- const lines = controlUser.get('lines');
702
- if (lines) {
703
- lineAssociations.value.forEach((lineAssociation: any) => {
704
- const autoAnswerLine = lines.controls.find((line: any) => line.get('directoryNumber').value.directoryNumber === lineAssociation.directoryNumber && line.get('directoryNumber').value.routePartitionName === lineAssociation.routePartitionName
705
- && line.get('autoAnswer').value !== 'Auto Answer Off');
706
- if (autoAnswerLine) {
707
- autoAnswerErrorLine = {
708
- autoAnswerErrorLine: lineAssociation.directoryNumber
709
- };
710
- }
711
- });
712
- }
713
- }
714
-
715
- return autoAnswerErrorLine;
716
- }
717
-
718
- verifyBeginEndTime(control: any) {
719
- const parent = control.parent;
720
- if (!parent || !parent.get('isActive') || !parent.get('allDay') || !parent.get('from') || !parent.get('to')) {
721
- return null;
722
- }
723
-
724
- if (parent.get('isActive').value) {
725
- if (!parent.get('allDay').value) {
726
- if (!parent.get('from').value || parent.get('from').value === 'No Office Hours'
727
- || !parent.get('to').value || parent.get('to').value === 'No Office Hours'
728
- || parent.get('from').value > parent.get('to').value) {
729
- return {
730
- fromGreaterThanTo: true
731
- };
732
- }
733
- }
734
- }
735
-
736
- return null;
737
- }
738
-
739
- time(control: any) {
740
- if (control.value && !timeRegex.test(control.value)) {
741
- return {timeFormat: true};
742
- }
743
- return null;
744
- }
745
-
746
-
747
- pinMultiCharacterCheck = (fieldName: string) => {
748
- // @ts-ignore
749
- return (control: any) => {
750
- if (!control.parent) {
751
- return null;
752
- }
753
- const matchingControl = control.parent.get(fieldName);
754
- const ruleMultiCharacter = new RegExp('([0-9])\\1{2}');
755
- if (matchingControl.value) {
756
- const hasMultiCharacter = ruleMultiCharacter.test(matchingControl.value);
757
- if (hasMultiCharacter) {
758
- return {
759
- multiCharacter: true
760
- };
761
- }
762
- }
763
- };
764
- };
765
-
766
- pinConsecutiveNumberCheck = (fieldName: string) => {
767
- // @ts-ignore
768
- return (control: any) => {
769
- if (!control.parent) {
770
- return null;
771
- }
772
- const matchingControl = control.parent.get(fieldName);
773
- const strToCheck = matchingControl.value;
774
- if (strToCheck && strToCheck.length > 1) {
775
- const resAsc = this.pinOrderCheck(strToCheck);
776
- if (resAsc === true) {
777
- return {
778
- consecutiveNumbers: true
779
- };
780
- }
781
- }
782
- };
783
- };
784
-
785
-
786
- pinOrderCheck(str: string): any {
787
- if (str) {
788
- const arr_num = ('' + str).split('');
789
- for (let i = 0; i < arr_num.length - 2; i++) {
790
- const num1 = parseInt(arr_num[i]);
791
- const num2 = parseInt(arr_num[i + 1]);
792
- const num3 = parseInt(arr_num[i + 2]);
793
- if ((num2 - num1) === 1 && (num3 - num2 === num2 - num1)) {
794
- return true;
795
- }
796
- }
797
- return false;
798
- }
799
- }
800
-
801
-
802
- pinMailboxExtensionCheck = (fieldName: string, extension: string) => {
803
- return (control: any) => {
804
- if (!control.parent) {
805
- return null;
806
- }
807
- const matchingControl = control.parent.get(fieldName);
808
- const strToCheck = matchingControl.value;
809
- if (strToCheck === extension || strToCheck.includes(extension)) {
810
- return {
811
- mailboxExtension: true
812
- };
813
- }
814
- return null;
815
- };
816
- };
817
-
818
- isItemAlreadyInList(item: any, list: any): boolean {
819
- if (!item || !list || !list.length) {
820
- return false;
821
- }
822
- for (const listItem of list) {
823
- if (item.equals(listItem)) {
824
- return true;
825
- }
826
- }
827
- return false;
828
- }
829
- }
1
+ import { Injectable } from '@angular/core';
2
+ import { SiteSettingsService } from './site-settings.service';
3
+ import { DeviceTypes, MailboxQuotasType, SpeedDialType, VMNotificationsTypes } from './../classes/types';
4
+ import { Device, DeviceKind } from './../classes/device';
5
+
6
+ const speedDialRegex = new RegExp('^[^"]*$');
7
+ const BLFRegex = new RegExp('^[^"><&%]*$');
8
+ const timeRegex = new RegExp('^([0-1][0-9]|[2][0-3]):([0-5][0-9])$');
9
+
10
+ @Injectable()
11
+ export class ValidationService {
12
+
13
+ constructor(
14
+ private siteSettingsService: SiteSettingsService,
15
+ ) {
16
+ }
17
+
18
+ e164MaskLabel(control: any) {
19
+ const ruleText = `^[0-9*#+X]{0,24}$`;
20
+ const rule = new RegExp(ruleText, 'g');
21
+ if (control.value && rule && !rule.test(control.value)) {
22
+ return {e164MaskRule: {rule: ruleText}};
23
+ }
24
+ return null;
25
+ }
26
+
27
+ index(control: any) {
28
+ const value = parseInt(control.value);
29
+ if (!value) {
30
+ return null;
31
+ }
32
+ const pattern = '^[+0-9]*$';
33
+ if (value && !Number.isInteger(value) || value < 1 || value > 199) {
34
+ return {indexRule: true};
35
+ }
36
+ return null;
37
+ }
38
+
39
+ displayLabel(control: any) {
40
+ const ruleText = `^[^""""%&<>]{0,30}$`;
41
+ const rule = new RegExp(ruleText, 'g');
42
+ if (rule && !rule.test(control.value)) {
43
+ return {labelRule: {rule: ruleText, count: 30}};
44
+ }
45
+ return null;
46
+ }
47
+
48
+
49
+
50
+ displayLabelAscii(control: any) {
51
+ const ruleText = '^[a-zA-Z0-9 !#$\'()*+,./:;=?@\\^_`}~-]{0,30}$';
52
+ const rule = new RegExp(ruleText, 'g');
53
+ if (rule && !rule.test(control.value)) {
54
+ return {labelRule: {rule: ruleText, count: 30}};
55
+ }
56
+ return null;
57
+ }
58
+
59
+ requiredForSpeedDialPosition(type: string) {
60
+
61
+ return (control: any) => {
62
+ const parent = control.parent;
63
+ if (type === SpeedDialType.slotBasic || !parent) {
64
+ return null;
65
+ }
66
+ if (!control.value) {
67
+ return {required: true};
68
+ }
69
+ return null;
70
+ };
71
+ }
72
+
73
+ speedDialDestination() {
74
+ return (control: any) => {
75
+ if (!control || !control.value) {
76
+ return null;
77
+ }
78
+ const numberOrHostNameIP = '' +
79
+ '^([0-9\\*#+PpCcFf,]+)$' +
80
+ '|' +
81
+ '^(' +
82
+ '([a-zA-Z0-9]){1,47}@' +
83
+ '(' +
84
+ '((?:[0-9]{1,3}\\.){3}[0-9]{1,3})' +
85
+ '|' +
86
+ '([a-zA-Z0-9][a-zA-Z0-9\\-]{1,61}[a-zA-Z0-9]\\.[a-zA-Z]{2,})' +
87
+ ')' +
88
+ ')$';
89
+ const rule = new RegExp(numberOrHostNameIP, 'g');
90
+ if (rule && !rule.test(control.value)) {
91
+ return {pattern: true};
92
+ }
93
+ return null;
94
+ };
95
+
96
+ }
97
+
98
+ requiredForSpeedDialDestination(type: string) {
99
+
100
+ return (control: any) => {
101
+ const parent = control.parent;
102
+ if ((!parent || !parent.get('label')) || (type === SpeedDialType.slotBasic && !control.value && !parent.get('label').value)) {
103
+ return null;
104
+ }
105
+ return null;
106
+ };
107
+ }
108
+
109
+
110
+ labelPatternDependingOnType(control: any) {
111
+ const parent = control?.parent;
112
+ if (!parent || !parent.get('type') || !control.value) {
113
+ return null;
114
+ }
115
+ const type = parent.get('type').value;
116
+ if (!type && !speedDialRegex.test(control.value)) {
117
+ return {labelRule: {wrong: '"'}};
118
+ }
119
+ if (type && !BLFRegex.test(control.value)) {
120
+ return {labelRule: {wrong: '"><&%'}};
121
+ }
122
+ return null;
123
+ }
124
+
125
+ labelPatternBLF(control: any) {
126
+ if (control.value && !BLFRegex.test(control.value)) {
127
+ return {labelRule: {wrong: '"><&%'}};
128
+ }
129
+ return null;
130
+ }
131
+
132
+ labelPatternSpeedDial(control: any) {
133
+ if (control?.value && !speedDialRegex.test(control.value)) {
134
+ return {labelRule: {wrong: '"'}};
135
+ }
136
+ return null;
137
+ }
138
+
139
+ matchControl = (fieldName: string) => {
140
+ return (control: any) => {
141
+ if (!control?.parent) {
142
+ return null;
143
+ }
144
+ const matchingControl = control.parent.get(fieldName);
145
+ if (matchingControl.value && matchingControl.value !== control.value) {
146
+ return {
147
+ matchControl: true
148
+ };
149
+ }
150
+ return null;
151
+ };
152
+ };
153
+
154
+ matchLength = (fieldName: string) => {
155
+ return (control: any) => {
156
+ if (!control.parent || !control.value) {
157
+ return null;
158
+ }
159
+ const matchingControl = control.parent.get(fieldName);
160
+ if (((!control.value.startsWith('+') && !matchingControl.value.startsWith('+')) ||
161
+ (control.value.startsWith('+') && matchingControl.value.startsWith('+'))) &&
162
+ ((!control.value.startsWith('\\+') && !matchingControl.value.startsWith('\\+')) ||
163
+ (control.value.startsWith('\\+') && matchingControl.value.startsWith('\\+'))) &&
164
+ matchingControl.value.length !== control.value.length) {
165
+ return {
166
+ matchLength: true
167
+ };
168
+ }
169
+ return null;
170
+ };
171
+ };
172
+
173
+ dynamicMaxLength = (length1: number, length2: number) => {
174
+ return (control: any) => {
175
+ if (!control.parent || !control.value) {
176
+ return null;
177
+ }
178
+ const maxLength = String(control.value).includes('[') ? length1 : length2;
179
+ if (control.value.length > maxLength) {
180
+ return {
181
+ maxLength: true
182
+ };
183
+ }
184
+ return null;
185
+ };
186
+ };
187
+
188
+ biggerThan = (fieldName: string) => {
189
+ return (control: any) => {
190
+ if (!control.parent || !control.value) {
191
+ return null;
192
+ }
193
+ const matchingControl = control.parent.get(fieldName);
194
+ if (matchingControl.value.length === control.value.length && matchingControl.value && matchingControl.value > control.value) {
195
+ return {
196
+ biggerThan: true
197
+ };
198
+ }
199
+ return null;
200
+ };
201
+ };
202
+
203
+ requiredByType = (fieldName: string, type: string) => {
204
+ return (control: any) => {
205
+ if (
206
+ fieldName === 'phoneSystem' && (type === VMNotificationsTypes['Phone Device'] || type === VMNotificationsTypes['Pager Device']) ||
207
+ fieldName === 'htmlTemplate' && type === VMNotificationsTypes['HTML Device']
208
+ ) {
209
+ return {
210
+ required: true
211
+ };
212
+ }
213
+ return null;
214
+ };
215
+ };
216
+
217
+ smallerThanQuota = (fieldName: string, quotaType: string, secondQuotaType: string) => {
218
+ return (control: any) => {
219
+ if (!control.parent) {
220
+ return null;
221
+ }
222
+ const matchingControl = control.parent.get(fieldName);
223
+ const quotaTypeControl = control.parent.get(quotaType);
224
+ const secondQuotaTypeControl = control.parent.get(secondQuotaType);
225
+
226
+ if (quotaTypeControl && secondQuotaTypeControl && secondQuotaTypeControl.value === MailboxQuotasType.system) {
227
+ return null;
228
+ }
229
+
230
+ if (quotaTypeControl && quotaTypeControl.value === MailboxQuotasType.system || matchingControl && matchingControl.value && parseInt(matchingControl.value) < parseInt(control.value)) {
231
+ return {
232
+ smallerThan: true
233
+ };
234
+ }
235
+ return null;
236
+ };
237
+ };
238
+
239
+ biggerThanQuota = (fieldName: string, quotaType: string) => {
240
+ return (control: any) => {
241
+ if (!control?.parent) {
242
+ return null;
243
+ }
244
+ const matchingControl = control.parent.get(fieldName);
245
+ const quotaTypeControl = control.parent.get(quotaType);
246
+
247
+ if (quotaTypeControl && quotaTypeControl.value === MailboxQuotasType.custom && matchingControl.value && parseInt(matchingControl.value) > parseInt(control.value)) {
248
+ return {
249
+ biggerThan: true
250
+ };
251
+ }
252
+ return null;
253
+ };
254
+ };
255
+
256
+ rangeLimit = (fieldName: string) => {
257
+ return (control: any) => {
258
+ if (!control?.parent || !control.value) {
259
+ return null;
260
+ }
261
+ const matchingControl = control.parent.get(fieldName);
262
+ if ((control.value - matchingControl.value) > 50000) {
263
+ return {
264
+ rangeLimit: true
265
+ };
266
+ }
267
+ return null;
268
+ };
269
+ };
270
+
271
+ comparepatternParts = (fieldName: string) => {
272
+ return (control: any) => {
273
+ if (!control?.value) {
274
+ return null;
275
+ }
276
+ const matches = control.value.match(/\[(.*?)\]/);
277
+ if (matches) {
278
+ const submatch = matches[1];
279
+ const submatchsplit: number[] = submatch.split('-');
280
+ for (let i = 0; i < submatchsplit.length; i++) {
281
+ if (submatchsplit[i] >= submatchsplit[i + 1]) {
282
+ return {
283
+ comparepatternParts: true
284
+ };
285
+ }
286
+ }
287
+ }
288
+ return null;
289
+ };
290
+ };
291
+
292
+ matchPrefix = (fieldName: string) => {
293
+ return (control: any) => {
294
+ if (!control?.parent || !control.value) {
295
+ return null;
296
+ }
297
+ const matchingControl = control.parent.get(fieldName);
298
+ if ((matchingControl.value.startsWith('+') || control.value.startsWith('+') || matchingControl.value.startsWith('\\+') || control.value.startsWith('\\+')) && (control.value.charAt(0) !== matchingControl.value.charAt(0))) {
299
+ return {
300
+ matchPrefix: true
301
+ };
302
+ }
303
+ return null;
304
+ };
305
+ };
306
+
307
+ deviceNameValidator = (device: Device) => {
308
+ return (control: any) => {
309
+ if (!control.value || device.deviceKind === DeviceKind.deviceProfile) {
310
+ return;
311
+ }
312
+ if (device.isCtiRoutePoint) {
313
+ let err = '';
314
+ if (!control.value.match(/^[a-zA-Z0-9-_.]+$/)) {
315
+ err = 'pattern';
316
+ }
317
+ if (control.value.trim().length > 15) {
318
+ err = 'maxLength';
319
+ }
320
+ return err ? {nameRule: err} : null;
321
+ }
322
+ if (device.deviceDefaults && !device.isCtiRoutePoint) {
323
+ const ruleText = device.deviceDefaults.deviceNameRegex;
324
+ const rule = new RegExp(ruleText, 'g');
325
+ const caption = device.deviceDefaults?.deviceNameExplained;
326
+ const match = (control.value || '').match(rule) || [];
327
+ const exactMatch = match && control.value === match[0];
328
+ if (rule && !exactMatch) {
329
+ return {nameRule: {caption}};
330
+ }
331
+ }
332
+ return null;
333
+ };
334
+ };
335
+
336
+ deviceNameValueValidator = (device: Device, deviceName: string) => {
337
+ return (control: any) => {
338
+ if (!control.value || device.deviceKind === DeviceKind.deviceProfile) {
339
+ return;
340
+ }
341
+ if (device.name && device.alreadyUsedName && device.name === device.alreadyUsedName) {
342
+ return {nameRule: 'alreadyUsedName'};
343
+ }
344
+ if (device.isCtiRoutePoint) {
345
+ let err = '';
346
+ if (!deviceName.match(/^[a-zA-Z0-9-_.]+$/)) {
347
+ err = 'pattern';
348
+ }
349
+ if (deviceName.trim().length > 15) {
350
+ err = 'maxLength';
351
+ }
352
+ return err ? {nameRule: err} : null;
353
+ }
354
+ if (device.deviceDefaults && !device.isCtiRoutePoint) {
355
+ const ruleText = device.deviceDefaults.deviceNameRegex;
356
+ // console.log('Dev name rule - ', ruleText);
357
+ const rule = new RegExp(ruleText, 'g');
358
+ let caption = device.deviceDefaults.deviceNameExplained;
359
+ if (!caption) {
360
+ caption = ruleText;
361
+ }
362
+ const match = (deviceName || '').match(rule) || [];
363
+ const exactMatch = match && deviceName === match[0];
364
+ if (rule && !exactMatch) {
365
+ return {nameRule: {caption}};
366
+ }
367
+ }
368
+ return null;
369
+ };
370
+ };
371
+
372
+ deviceDuplicatingNameValidator = (user: any, pkid ?: string, prefix?: string) => {
373
+ return (control: any) => {
374
+ if (!control.value || !user || !user.devices || user.devices.length === 0) {
375
+ return;
376
+ }
377
+ const deviceName = prefix ? `${prefix}${control.value}` : control.value;
378
+ const devicesWithTheSameName = user.devices.filter((device: Device) => device.name === deviceName);
379
+ if (devicesWithTheSameName.length > 0) {
380
+ if (!pkid) { // For new device
381
+ return {duplicateNameRule: true};
382
+ } else if (pkid !== devicesWithTheSameName[0].pkid) { // For updating device, avoid validating with itself
383
+ return {duplicateNameRule: true};
384
+ }
385
+ }
386
+ return null;
387
+ };
388
+ };
389
+
390
+ conditionalRequired = (fieldName: string, requiredConditionValues: any[]) => {
391
+ return (control: any) => {
392
+ const parent1 = control.parent;
393
+ if (!parent1 || !parent1.get(fieldName) || !parent1.get(fieldName).value) {
394
+ return;
395
+ }
396
+ if (requiredConditionValues.includes(parent1.get(fieldName).value) && !control.value) {
397
+ return {
398
+ required: true
399
+ };
400
+ }
401
+ return null;
402
+ };
403
+ };
404
+
405
+ conditionalRequiredForGroupAdmin = (fieldName: string, requiredConditionValues: any[]) => {
406
+ return (control: any) => {
407
+ const parent1 = control.parent;
408
+ if (!parent1 || !parent1.get(fieldName) || !parent1.get(fieldName).value || !parent1.get(fieldName).value.type) {
409
+ return;
410
+ }
411
+ if (requiredConditionValues.includes(parent1.get(fieldName).value.type) && !control.value) {
412
+ return {
413
+ required: true
414
+ };
415
+ }
416
+ return null;
417
+ };
418
+ };
419
+
420
+ conditionalSiteGroupCheckForGroupAdmin = (fieldName: string, requiredConditionValues: any[]) => {
421
+ return (control: any) => {
422
+ const parent1 = control.parent;
423
+ if (!parent1 || !parent1.get(fieldName) || !parent1.get(fieldName).value || !parent1.get(fieldName).value.type) {
424
+ return;
425
+ }
426
+ if (parent1.get(fieldName).value && requiredConditionValues.includes(parent1.get(fieldName).value.type) &&
427
+ parent1.get('siteGroup') && parent1.get('siteGroup').value &&
428
+ parent1.get('siteGroup').value.siteGroupMembers && parent1.get('siteGroup').value.siteGroupMembers.length < 1) {
429
+ return {
430
+ hasSiteGroupError: true
431
+ };
432
+ }
433
+ return null;
434
+ };
435
+ };
436
+
437
+ requiredIfFieldIsEmptyForBLF = (fieldName: any) => {
438
+ const DATE_PATTERN = '^(0[1-9]|1[012])[- \/.](0[1-9]|[12][0-9]|3[01])[- \/.](19|20)\d\d$';
439
+ return (control: any) => {
440
+ const parent = control.parent;
441
+ if (!parent || !parent.get(fieldName)) {
442
+ return null;
443
+ }
444
+ if (!parent.get(fieldName).value && !control.value) {
445
+ return {
446
+ requiredEither: true,
447
+ requiredBLFDN: true
448
+ };
449
+ }
450
+ return null;
451
+ };
452
+ };
453
+
454
+
455
+ validDate = (fieldName: string) => {
456
+
457
+ return (control: any) => {
458
+ const parent = control.parent;
459
+ const ruleText = '^(0[1-9]|1[012])[- \/.](0[1-9]|[12][0-9]|3[01])[- \/.](19|20)\d\d$';
460
+ const rule = new RegExp(ruleText, 'g');
461
+ const val = control.value && control.value.getDate();
462
+ if (rule && !rule.test(val)) {
463
+ return {pattern: true};
464
+ }
465
+ return null;
466
+ };
467
+ };
468
+
469
+
470
+ matchOption = (optionType: string, list?: any, isFullList?: boolean) => {
471
+ return (control: any) => {
472
+ if (!control.value || control.value === DeviceTypes.CTI_ROUTE_POINT) {
473
+ return null;
474
+ }
475
+ let optionList = list || this.getOptionsList(optionType);
476
+ if (optionList && optionList.length) {
477
+ if (!isFullList && optionType === 'directoryNumbers') {
478
+ optionList = optionList.map((str: string) => str.indexOf(' ') > -1 ? str.substring(0, str.indexOf(' ')) : str);
479
+ }
480
+ if (!optionList.includes(control.value)) {
481
+ return {
482
+ matchOptions: true
483
+ };
484
+ }
485
+ }
486
+ return null;
487
+ };
488
+ };
489
+
490
+ confidentialAccessLevel = (confidentialAccessMode: string) => {
491
+ return (control: any) => {
492
+ if (!control.value && !confidentialAccessMode) {
493
+ return null;
494
+ }
495
+ if (!control.value) {
496
+ return {
497
+ required: true
498
+ };
499
+ }
500
+ return null;
501
+ };
502
+ };
503
+
504
+ noResultDN = (optionType: string, list?: any) => {
505
+ return (control: any) => {
506
+ if (!control.value || list === null) {
507
+ return null;
508
+ }
509
+ if (list && list.length === 0) {
510
+ return {
511
+ noResultDNs: true
512
+ };
513
+ }
514
+ return null;
515
+ };
516
+ };
517
+
518
+ matchExtensionOption = (optionType: string, optionList?: any) => {
519
+ return (control: any) => {
520
+ if (!control.value) {
521
+ return control.value;
522
+ }
523
+ // @ts-ignore
524
+ const newList = [];
525
+ if (optionList && optionList.length) {
526
+ optionList.forEach((list: any) => {
527
+ const newOptionList = this.getMatchExistingVmLineValue(list);
528
+ newList.push(newOptionList);
529
+ });
530
+ // @ts-ignore
531
+ if (newList && !newList.includes(control.value)) {
532
+ return {
533
+ matchOptions: true
534
+ };
535
+ }
536
+ } else if (!optionList || !optionList.length) {
537
+ return {
538
+ matchOptions: true
539
+ };
540
+ }
541
+ return null;
542
+ };
543
+ };
544
+
545
+ public getMatchExistingVmLineValue(dnWithType: string): string {
546
+ const ind = dnWithType.indexOf('Type:');
547
+ let dn = dnWithType;
548
+ if (ind > -1) {
549
+ dn = dnWithType.slice(0, ind);
550
+ dn = dn.trim();
551
+ }
552
+ return dn;
553
+ }
554
+
555
+ requiredEitherForVmExtension = (fieldName1: string, fieldName2: string) => {
556
+ return (control: any) => {
557
+ if (!control.parent) {
558
+ return null;
559
+ }
560
+ const matchControl1 = control.parent.get(fieldName1).value;
561
+ const matchControl2 = control.parent.get(fieldName2).value;
562
+ if (!matchControl1 && !matchControl2) {
563
+ return {
564
+ requiredEitherForVmExtension: true
565
+ };
566
+ }
567
+ return null;
568
+ };
569
+ };
570
+
571
+ requiredEitherOne = (fieldName1: string, fieldName2: string) => {
572
+ return (control: any) => {
573
+ if (!control.parent) {
574
+ return null;
575
+ }
576
+ const matchControl1 = control.parent.get(fieldName1) && control.parent.get(fieldName1).value;
577
+ const matchControl2 = control.parent.get(fieldName2) && control.parent.get(fieldName2).value;
578
+ if (!matchControl1 && !matchControl2) {
579
+ return {
580
+ requiredEitherOne: true
581
+ };
582
+ }
583
+ return null;
584
+ };
585
+ };
586
+
587
+ requiredByValue = (fieldName: string, requestedFieldVal: any) => {
588
+ return (control: any) => {
589
+ if (!control || !control.parent) {
590
+ return null;
591
+ }
592
+ const fieldVal = control.parent.get(fieldName) && control.parent.get(fieldName).value;
593
+ if (fieldVal && fieldVal === requestedFieldVal && !control.value) {
594
+ return {
595
+ required: true
596
+ };
597
+ }
598
+ return null;
599
+ };
600
+ };
601
+
602
+ OneExtensionEmpty = (fieldName1: string, fieldName2: string) => {
603
+ return (control: any) => {
604
+ if (!control.parent) {
605
+ return null;
606
+ }
607
+ const matchControl1 = control.parent.get(fieldName1).value;
608
+ const matchControl2 = control.parent.get(fieldName2).value;
609
+ if (matchControl1 && matchControl2) {
610
+ return {
611
+ OneExtensionIsEmpty: true
612
+ };
613
+ }
614
+ return null;
615
+ };
616
+ };
617
+
618
+ requiredByCondition = (requiredBy: string, fieldName: any) => {
619
+ return (control: any) => {
620
+ if (!control.parent) {
621
+ return null;
622
+ }
623
+ const requiredByControl = control.parent.get(requiredBy).value;
624
+ const requiredControl = control.parent.get(fieldName).value;
625
+ if (requiredByControl && !requiredControl) {
626
+ return {
627
+ required: true
628
+ };
629
+ }
630
+ return null;
631
+ };
632
+ };
633
+
634
+ private getOptionsList(token: string): string[] {
635
+ switch (token) {
636
+ case 'css':
637
+ case 'rerouteCss':
638
+ case 'callingSearchSpace':
639
+ return this.siteSettingsService.callingSearchSpaceTypes;
640
+ case 'reroutingCss':
641
+ return this.siteSettingsService.siteDefaults && this.siteSettingsService.siteDefaults.cssFilter;
642
+ case 'deviceType':
643
+ return this.siteSettingsService.deviceTypes;
644
+ case 'routePartition':
645
+ return this.siteSettingsService.routePartitionNames;
646
+ case 'routePartitionFiltered':
647
+ return this.siteSettingsService.filteredRoutePartitionNames;
648
+ case 'devicePools':
649
+ return this.siteSettingsService.devicePools;
650
+ case 'allRoutePartitions':
651
+ return this.siteSettingsService.allRoutePartitionNames;
652
+ case 'directoryNumbers':
653
+ return this.siteSettingsService.directoryNumbers;
654
+ default:
655
+ return [];
656
+ }
657
+ }
658
+
659
+ autocompleteType(control: any) {
660
+ if (!control.value) {
661
+ return null;
662
+ }
663
+ if (typeof control.value !== 'object' && control.value !== '') {
664
+ return {
665
+ stringEntered: true
666
+ };
667
+ }
668
+ return null;
669
+ }
670
+
671
+
672
+ password(control: any) {
673
+ const ruleNumeric = new RegExp(/\d+/, 'g');
674
+ const ruleCapitals = new RegExp(/[A-Z]+/, 'g');
675
+ const ruleSmall = new RegExp(/[a-z]+/, 'g');
676
+ const ruleSpecial = new RegExp(/[!@#$%&\/=\?_\.,:;\-\\+]+/, 'g');
677
+
678
+ const hasNumeric = +ruleNumeric.test(control.value);
679
+ const hasCapitals = +ruleCapitals.test(control.value);
680
+ const hasSmall = +ruleSmall.test(control.value);
681
+ const hasSpecial = +ruleSpecial.test(control.value);
682
+
683
+ if (hasNumeric + hasCapitals + hasSmall + hasSpecial < 3) {
684
+ return {
685
+ weakPassword: true
686
+ };
687
+ }
688
+
689
+ return null;
690
+ }
691
+
692
+ verifyAutoAnswer(control: any) {
693
+ if (!control?.value || control.value.length === 0) {
694
+ return null;
695
+ }
696
+ let autoAnswerErrorLine = null;
697
+ if (control.parent && control.parent.parent && control.parent.parent.parent && control.parent.parent.parent.parent) {
698
+ const controlSNR = control.parent;
699
+ const controlUser = control.parent.parent.parent.parent;
700
+ const lineAssociations = controlSNR.get('lineAssociations');
701
+ const lines = controlUser.get('lines');
702
+ if (lines) {
703
+ lineAssociations.value.forEach((lineAssociation: any) => {
704
+ const autoAnswerLine = lines.controls.find((line: any) => line.get('directoryNumber').value.directoryNumber === lineAssociation.directoryNumber && line.get('directoryNumber').value.routePartitionName === lineAssociation.routePartitionName
705
+ && line.get('autoAnswer').value !== 'Auto Answer Off');
706
+ if (autoAnswerLine) {
707
+ autoAnswerErrorLine = {
708
+ autoAnswerErrorLine: lineAssociation.directoryNumber
709
+ };
710
+ }
711
+ });
712
+ }
713
+ }
714
+
715
+ return autoAnswerErrorLine;
716
+ }
717
+
718
+ verifyBeginEndTime(control: any) {
719
+ const parent = control.parent;
720
+ if (!parent || !parent.get('isActive') || !parent.get('allDay') || !parent.get('from') || !parent.get('to')) {
721
+ return null;
722
+ }
723
+
724
+ if (parent.get('isActive').value) {
725
+ if (!parent.get('allDay').value) {
726
+ if (!parent.get('from').value || parent.get('from').value === 'No Office Hours'
727
+ || !parent.get('to').value || parent.get('to').value === 'No Office Hours'
728
+ || parent.get('from').value > parent.get('to').value) {
729
+ return {
730
+ fromGreaterThanTo: true
731
+ };
732
+ }
733
+ }
734
+ }
735
+
736
+ return null;
737
+ }
738
+
739
+ time(control: any) {
740
+ if (control.value && !timeRegex.test(control.value)) {
741
+ return {timeFormat: true};
742
+ }
743
+ return null;
744
+ }
745
+
746
+
747
+ pinMultiCharacterCheck = (fieldName: string) => {
748
+ // @ts-ignore
749
+ return (control: any) => {
750
+ if (!control.parent) {
751
+ return null;
752
+ }
753
+ const matchingControl = control.parent.get(fieldName);
754
+ const ruleMultiCharacter = new RegExp('([0-9])\\1{2}');
755
+ if (matchingControl.value) {
756
+ const hasMultiCharacter = ruleMultiCharacter.test(matchingControl.value);
757
+ if (hasMultiCharacter) {
758
+ return {
759
+ multiCharacter: true
760
+ };
761
+ }
762
+ }
763
+ };
764
+ };
765
+
766
+ pinConsecutiveNumberCheck = (fieldName: string) => {
767
+ // @ts-ignore
768
+ return (control: any) => {
769
+ if (!control.parent) {
770
+ return null;
771
+ }
772
+ const matchingControl = control.parent.get(fieldName);
773
+ const strToCheck = matchingControl.value;
774
+ if (strToCheck && strToCheck.length > 1) {
775
+ const resAsc = this.pinOrderCheck(strToCheck);
776
+ if (resAsc === true) {
777
+ return {
778
+ consecutiveNumbers: true
779
+ };
780
+ }
781
+ }
782
+ };
783
+ };
784
+
785
+
786
+ pinOrderCheck(str: string): any {
787
+ if (str) {
788
+ const arr_num = ('' + str).split('');
789
+ for (let i = 0; i < arr_num.length - 2; i++) {
790
+ const num1 = parseInt(arr_num[i]);
791
+ const num2 = parseInt(arr_num[i + 1]);
792
+ const num3 = parseInt(arr_num[i + 2]);
793
+ if ((num2 - num1) === 1 && (num3 - num2 === num2 - num1)) {
794
+ return true;
795
+ }
796
+ }
797
+ return false;
798
+ }
799
+ }
800
+
801
+
802
+ pinMailboxExtensionCheck = (fieldName: string, extension: string) => {
803
+ return (control: any) => {
804
+ if (!control.parent) {
805
+ return null;
806
+ }
807
+ const matchingControl = control.parent.get(fieldName);
808
+ const strToCheck = matchingControl.value;
809
+ if (strToCheck === extension || strToCheck.includes(extension)) {
810
+ return {
811
+ mailboxExtension: true
812
+ };
813
+ }
814
+ return null;
815
+ };
816
+ };
817
+
818
+ isItemAlreadyInList(item: any, list: any): boolean {
819
+ if (!item || !list || !list.length) {
820
+ return false;
821
+ }
822
+ for (const listItem of list) {
823
+ if (item.equals(listItem)) {
824
+ return true;
825
+ }
826
+ }
827
+ return false;
828
+ }
829
+ }