@lenne.tech/ng-base 13.1.0 → 13.3.0

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 (296) hide show
  1. package/base-components/base-components.module.d.ts +12 -0
  2. package/base-components/components/checkbox/checkbox.component.d.ts +11 -0
  3. package/base-components/components/input/input.component.d.ts +14 -0
  4. package/base-components/components/select/select.component.d.ts +19 -0
  5. package/base-components/components/textarea/textarea.component.d.ts +13 -0
  6. package/base-components/lenne.tech-ng-base-base-components.d.ts +5 -0
  7. package/base-components/package.json +10 -0
  8. package/base-components/public-api.d.ts +8 -0
  9. package/base-prototype/base-prototype.module.d.ts +12 -0
  10. package/{src/lib/base/lenne.tech-ng-base-src-lib-base.d.ts → base-prototype/lenne.tech-ng-base-base-prototype.d.ts} +1 -1
  11. package/base-prototype/package.json +10 -0
  12. package/base-prototype/pages/login/login.component.d.ts +20 -0
  13. package/base-prototype/pages/register/register.component.d.ts +20 -0
  14. package/base-prototype/public-api.d.ts +6 -0
  15. package/esm2020/base-components/base-components.module.mjs +42 -0
  16. package/esm2020/base-components/components/checkbox/checkbox.component.mjs +28 -0
  17. package/esm2020/base-components/components/input/input.component.mjs +36 -0
  18. package/esm2020/base-components/components/select/select.component.mjs +37 -0
  19. package/esm2020/base-components/components/textarea/textarea.component.mjs +35 -0
  20. package/esm2020/base-components/lenne.tech-ng-base-base-components.mjs +5 -0
  21. package/esm2020/base-components/public-api.mjs +11 -0
  22. package/esm2020/base-prototype/base-prototype.module.mjs +36 -0
  23. package/esm2020/base-prototype/lenne.tech-ng-base-base-prototype.mjs +5 -0
  24. package/esm2020/base-prototype/pages/login/login.component.mjs +39 -0
  25. package/esm2020/base-prototype/pages/register/register.component.mjs +45 -0
  26. package/esm2020/base-prototype/public-api.mjs +9 -0
  27. package/esm2020/lenne.tech-ng-base.mjs +1 -1
  28. package/esm2020/public-api.mjs +68 -3
  29. package/esm2020/src/base.module.mjs +101 -0
  30. package/esm2020/src/classes/basic-user.class.mjs +51 -0
  31. package/esm2020/src/classes/graphql-enum.class.mjs +9 -0
  32. package/esm2020/src/classes/graphql-meta.class.mjs +171 -0
  33. package/esm2020/src/classes/graphql-type.class.mjs +13 -0
  34. package/esm2020/src/classes/helper.class.mjs +304 -0
  35. package/esm2020/src/classes/standard.class.mjs +40 -0
  36. package/esm2020/src/decorators/debounce.decorator.mjs +12 -0
  37. package/esm2020/src/directives/context-menu.directive.mjs +109 -0
  38. package/esm2020/src/directives/lazy-load.directive.mjs +45 -0
  39. package/esm2020/src/directives/match-height.directive.mjs +79 -0
  40. package/esm2020/src/directives/resizable.directive.mjs +90 -0
  41. package/esm2020/src/enums/comparison-operator.enum.mjs +16 -0
  42. package/esm2020/src/enums/graphql-request-type.enum.mjs +10 -0
  43. package/esm2020/src/enums/logical-operator.enum.mjs +10 -0
  44. package/esm2020/src/enums/sort-order.enum.mjs +6 -0
  45. package/esm2020/src/factories/apollo-options.factory.mjs +61 -0
  46. package/esm2020/src/guards/auth.guard.mjs +61 -0
  47. package/esm2020/src/guards/can-deactivate.guard.mjs +16 -0
  48. package/esm2020/src/guards/logout.guard.mjs +32 -0
  49. package/esm2020/src/interfaces/base-module-config.interface.mjs +3 -0
  50. package/esm2020/src/interfaces/can-component-deactivate.interface.mjs +2 -0
  51. package/esm2020/src/interfaces/combined-filter-input.interface.mjs +2 -0
  52. package/esm2020/src/interfaces/field-object.interface.mjs +2 -0
  53. package/esm2020/src/interfaces/field.interface.mjs +2 -0
  54. package/esm2020/src/interfaces/filter-input.interface.mjs +2 -0
  55. package/esm2020/src/interfaces/find-args.interface.mjs +2 -0
  56. package/esm2020/src/interfaces/graphql-fields-object.interface.mjs +2 -0
  57. package/esm2020/src/interfaces/graphql-options.interface.mjs +2 -0
  58. package/esm2020/src/interfaces/graphql-plus-options.interfacen.mjs +2 -0
  59. package/esm2020/src/interfaces/graphql-type-collection.interface.mjs +2 -0
  60. package/esm2020/src/interfaces/single-filter-input.interface.mjs +2 -0
  61. package/esm2020/src/interfaces/sort-input.interface.mjs +2 -0
  62. package/esm2020/src/pipes/date-ago.pipe.mjs +65 -0
  63. package/esm2020/src/pipes/ellipses.pipe.mjs +22 -0
  64. package/esm2020/src/pipes/safe-html.pipe.mjs +21 -0
  65. package/esm2020/src/services/auth.service.mjs +71 -0
  66. package/esm2020/src/services/forms.service.mjs +26 -0
  67. package/esm2020/src/services/fullscreen.service.mjs +51 -0
  68. package/esm2020/src/services/graphql-meta.service.mjs +123 -0
  69. package/esm2020/src/services/graphql-plus.service.mjs +84 -0
  70. package/esm2020/src/services/graphql.service.mjs +441 -0
  71. package/esm2020/src/services/image.service.mjs +102 -0
  72. package/esm2020/src/services/loader.service.mjs +29 -0
  73. package/esm2020/src/services/scroll.service.mjs +179 -0
  74. package/esm2020/src/services/seo.service.mjs +97 -0
  75. package/esm2020/src/services/storage.service.mjs +132 -0
  76. package/esm2020/src/services/theme.service.mjs +43 -0
  77. package/esm2020/src/services/ws.service.mjs +17 -0
  78. package/esm2020/src/types/graphql-fields.type.mjs +2 -0
  79. package/esm2020/src/types/storage.type.mjs +2 -0
  80. package/esm2020/src/validators/must-match.validator.mjs +22 -0
  81. package/fesm2015/lenne.tech-ng-base-base-components.mjs +173 -0
  82. package/fesm2015/lenne.tech-ng-base-base-components.mjs.map +1 -0
  83. package/fesm2015/lenne.tech-ng-base-base-prototype.mjs +122 -0
  84. package/fesm2015/lenne.tech-ng-base-base-prototype.mjs.map +1 -0
  85. package/fesm2015/lenne.tech-ng-base.mjs +225 -77
  86. package/fesm2015/lenne.tech-ng-base.mjs.map +1 -1
  87. package/fesm2020/lenne.tech-ng-base-base-components.mjs +171 -0
  88. package/fesm2020/lenne.tech-ng-base-base-components.mjs.map +1 -0
  89. package/fesm2020/lenne.tech-ng-base-base-prototype.mjs +120 -0
  90. package/fesm2020/lenne.tech-ng-base-base-prototype.mjs.map +1 -0
  91. package/fesm2020/lenne.tech-ng-base.mjs +225 -77
  92. package/fesm2020/lenne.tech-ng-base.mjs.map +1 -1
  93. package/package.json +24 -15
  94. package/public-api.d.ts +55 -1
  95. package/{lib/base → src}/base.module.d.ts +2 -1
  96. package/{lib/base → src}/classes/basic-user.class.d.ts +0 -0
  97. package/{lib/base → src}/classes/graphql-enum.class.d.ts +0 -0
  98. package/{lib/base → src}/classes/graphql-meta.class.d.ts +0 -0
  99. package/{lib/base → src}/classes/graphql-type.class.d.ts +0 -0
  100. package/{lib/base → src}/classes/helper.class.d.ts +1 -0
  101. package/{lib/base → src}/classes/standard.class.d.ts +0 -0
  102. package/src/decorators/debounce.decorator.d.ts +1 -0
  103. package/{lib/base → src}/directives/context-menu.directive.d.ts +0 -0
  104. package/{lib/base → src}/directives/lazy-load.directive.d.ts +0 -0
  105. package/{lib/base → src}/directives/match-height.directive.d.ts +0 -0
  106. package/{lib/base → src}/directives/resizable.directive.d.ts +0 -0
  107. package/{lib/base → src}/enums/comparison-operator.enum.d.ts +0 -0
  108. package/{lib/base → src}/enums/graphql-request-type.enum.d.ts +0 -0
  109. package/{lib/base → src}/enums/logical-operator.enum.d.ts +0 -0
  110. package/{lib/base → src}/enums/sort-order.enum.d.ts +0 -0
  111. package/{lib/base → src}/factories/apollo-options.factory.d.ts +0 -0
  112. package/{lib/base → src}/guards/auth.guard.d.ts +0 -0
  113. package/{lib/base → src}/guards/can-deactivate.guard.d.ts +0 -0
  114. package/{lib/base → src}/guards/logout.guard.d.ts +0 -0
  115. package/{lib/base → src}/interfaces/base-module-config.interface.d.ts +0 -0
  116. package/{lib/base → src}/interfaces/can-component-deactivate.interface.d.ts +0 -0
  117. package/{lib/base → src}/interfaces/combined-filter-input.interface.d.ts +0 -0
  118. package/{lib/base → src}/interfaces/field-object.interface.d.ts +0 -0
  119. package/{lib/base → src}/interfaces/field.interface.d.ts +0 -0
  120. package/{lib/base → src}/interfaces/filter-input.interface.d.ts +0 -0
  121. package/{lib/base → src}/interfaces/find-args.interface.d.ts +0 -0
  122. package/src/interfaces/graphql-fields-object.interface.d.ts +6 -0
  123. package/{lib/base → src}/interfaces/graphql-options.interface.d.ts +0 -0
  124. package/{lib/base → src}/interfaces/graphql-plus-options.interfacen.d.ts +0 -0
  125. package/{lib/base → src}/interfaces/graphql-type-collection.interface.d.ts +0 -0
  126. package/{lib/base → src}/interfaces/single-filter-input.interface.d.ts +0 -0
  127. package/{lib/base → src}/interfaces/sort-input.interface.d.ts +0 -0
  128. package/src/pipes/date-ago.pipe.d.ts +34 -0
  129. package/{lib/base → src}/pipes/ellipses.pipe.d.ts +0 -0
  130. package/{lib/base → src}/pipes/safe-html.pipe.d.ts +0 -0
  131. package/{lib/base → src}/services/auth.service.d.ts +0 -0
  132. package/src/services/forms.service.d.ts +8 -0
  133. package/{lib/base → src}/services/fullscreen.service.d.ts +0 -0
  134. package/{lib/base → src}/services/graphql-meta.service.d.ts +0 -0
  135. package/{lib/base → src}/services/graphql-plus.service.d.ts +0 -0
  136. package/{lib/base → src}/services/graphql.service.d.ts +0 -0
  137. package/{lib/base → src}/services/image.service.d.ts +0 -0
  138. package/{lib/base → src}/services/loader.service.d.ts +0 -0
  139. package/{lib/base → src}/services/scroll.service.d.ts +0 -0
  140. package/{lib/base → src}/services/seo.service.d.ts +0 -0
  141. package/{lib/base → src}/services/storage.service.d.ts +0 -0
  142. package/src/services/theme.service.d.ts +17 -0
  143. package/{lib/base → src}/services/ws.service.d.ts +0 -0
  144. package/src/types/graphql-fields.type.d.ts +5 -0
  145. package/{lib/base → src}/types/storage.type.d.ts +0 -0
  146. package/{lib/base → src}/validators/must-match.validator.d.ts +2 -2
  147. package/esm2020/lib/base/base.module.mjs +0 -97
  148. package/esm2020/lib/base/classes/basic-user.class.mjs +0 -51
  149. package/esm2020/lib/base/classes/graphql-enum.class.mjs +0 -9
  150. package/esm2020/lib/base/classes/graphql-meta.class.mjs +0 -171
  151. package/esm2020/lib/base/classes/graphql-type.class.mjs +0 -13
  152. package/esm2020/lib/base/classes/helper.class.mjs +0 -295
  153. package/esm2020/lib/base/classes/standard.class.mjs +0 -40
  154. package/esm2020/lib/base/directives/context-menu.directive.mjs +0 -109
  155. package/esm2020/lib/base/directives/lazy-load.directive.mjs +0 -45
  156. package/esm2020/lib/base/directives/match-height.directive.mjs +0 -79
  157. package/esm2020/lib/base/directives/resizable.directive.mjs +0 -90
  158. package/esm2020/lib/base/enums/comparison-operator.enum.mjs +0 -16
  159. package/esm2020/lib/base/enums/graphql-request-type.enum.mjs +0 -10
  160. package/esm2020/lib/base/enums/logical-operator.enum.mjs +0 -10
  161. package/esm2020/lib/base/enums/sort-order.enum.mjs +0 -6
  162. package/esm2020/lib/base/factories/apollo-options.factory.mjs +0 -61
  163. package/esm2020/lib/base/guards/auth.guard.mjs +0 -61
  164. package/esm2020/lib/base/guards/can-deactivate.guard.mjs +0 -16
  165. package/esm2020/lib/base/guards/logout.guard.mjs +0 -32
  166. package/esm2020/lib/base/index.mjs +0 -2
  167. package/esm2020/lib/base/interfaces/base-module-config.interface.mjs +0 -3
  168. package/esm2020/lib/base/interfaces/can-component-deactivate.interface.mjs +0 -2
  169. package/esm2020/lib/base/interfaces/combined-filter-input.interface.mjs +0 -2
  170. package/esm2020/lib/base/interfaces/field-object.interface.mjs +0 -2
  171. package/esm2020/lib/base/interfaces/field.interface.mjs +0 -2
  172. package/esm2020/lib/base/interfaces/filter-input.interface.mjs +0 -2
  173. package/esm2020/lib/base/interfaces/find-args.interface.mjs +0 -2
  174. package/esm2020/lib/base/interfaces/graphql-options.interface.mjs +0 -2
  175. package/esm2020/lib/base/interfaces/graphql-plus-options.interfacen.mjs +0 -2
  176. package/esm2020/lib/base/interfaces/graphql-type-collection.interface.mjs +0 -2
  177. package/esm2020/lib/base/interfaces/single-filter-input.interface.mjs +0 -2
  178. package/esm2020/lib/base/interfaces/sort-input.interface.mjs +0 -2
  179. package/esm2020/lib/base/pipes/ellipses.pipe.mjs +0 -22
  180. package/esm2020/lib/base/pipes/safe-html.pipe.mjs +0 -21
  181. package/esm2020/lib/base/public-api.mjs +0 -61
  182. package/esm2020/lib/base/services/auth.service.mjs +0 -71
  183. package/esm2020/lib/base/services/fullscreen.service.mjs +0 -51
  184. package/esm2020/lib/base/services/graphql-meta.service.mjs +0 -123
  185. package/esm2020/lib/base/services/graphql-plus.service.mjs +0 -84
  186. package/esm2020/lib/base/services/graphql.service.mjs +0 -441
  187. package/esm2020/lib/base/services/image.service.mjs +0 -102
  188. package/esm2020/lib/base/services/loader.service.mjs +0 -29
  189. package/esm2020/lib/base/services/scroll.service.mjs +0 -179
  190. package/esm2020/lib/base/services/seo.service.mjs +0 -97
  191. package/esm2020/lib/base/services/storage.service.mjs +0 -132
  192. package/esm2020/lib/base/services/ws.service.mjs +0 -17
  193. package/esm2020/lib/base/types/storage.type.mjs +0 -2
  194. package/esm2020/lib/base/validators/must-match.validator.mjs +0 -22
  195. package/esm2020/src/lib/base/base.module.mjs +0 -97
  196. package/esm2020/src/lib/base/classes/basic-user.class.mjs +0 -51
  197. package/esm2020/src/lib/base/classes/graphql-enum.class.mjs +0 -9
  198. package/esm2020/src/lib/base/classes/graphql-meta.class.mjs +0 -171
  199. package/esm2020/src/lib/base/classes/graphql-type.class.mjs +0 -13
  200. package/esm2020/src/lib/base/classes/helper.class.mjs +0 -295
  201. package/esm2020/src/lib/base/classes/standard.class.mjs +0 -40
  202. package/esm2020/src/lib/base/directives/context-menu.directive.mjs +0 -109
  203. package/esm2020/src/lib/base/directives/lazy-load.directive.mjs +0 -45
  204. package/esm2020/src/lib/base/directives/match-height.directive.mjs +0 -79
  205. package/esm2020/src/lib/base/directives/resizable.directive.mjs +0 -90
  206. package/esm2020/src/lib/base/enums/comparison-operator.enum.mjs +0 -16
  207. package/esm2020/src/lib/base/enums/graphql-request-type.enum.mjs +0 -10
  208. package/esm2020/src/lib/base/enums/logical-operator.enum.mjs +0 -10
  209. package/esm2020/src/lib/base/enums/sort-order.enum.mjs +0 -6
  210. package/esm2020/src/lib/base/factories/apollo-options.factory.mjs +0 -61
  211. package/esm2020/src/lib/base/guards/auth.guard.mjs +0 -61
  212. package/esm2020/src/lib/base/guards/can-deactivate.guard.mjs +0 -16
  213. package/esm2020/src/lib/base/guards/logout.guard.mjs +0 -32
  214. package/esm2020/src/lib/base/interfaces/base-module-config.interface.mjs +0 -3
  215. package/esm2020/src/lib/base/interfaces/can-component-deactivate.interface.mjs +0 -2
  216. package/esm2020/src/lib/base/interfaces/combined-filter-input.interface.mjs +0 -2
  217. package/esm2020/src/lib/base/interfaces/field-object.interface.mjs +0 -2
  218. package/esm2020/src/lib/base/interfaces/field.interface.mjs +0 -2
  219. package/esm2020/src/lib/base/interfaces/filter-input.interface.mjs +0 -2
  220. package/esm2020/src/lib/base/interfaces/find-args.interface.mjs +0 -2
  221. package/esm2020/src/lib/base/interfaces/graphql-options.interface.mjs +0 -2
  222. package/esm2020/src/lib/base/interfaces/graphql-plus-options.interfacen.mjs +0 -2
  223. package/esm2020/src/lib/base/interfaces/graphql-type-collection.interface.mjs +0 -2
  224. package/esm2020/src/lib/base/interfaces/single-filter-input.interface.mjs +0 -2
  225. package/esm2020/src/lib/base/interfaces/sort-input.interface.mjs +0 -2
  226. package/esm2020/src/lib/base/lenne.tech-ng-base-src-lib-base.mjs +0 -5
  227. package/esm2020/src/lib/base/pipes/ellipses.pipe.mjs +0 -22
  228. package/esm2020/src/lib/base/pipes/safe-html.pipe.mjs +0 -21
  229. package/esm2020/src/lib/base/public-api.mjs +0 -61
  230. package/esm2020/src/lib/base/services/auth.service.mjs +0 -71
  231. package/esm2020/src/lib/base/services/fullscreen.service.mjs +0 -51
  232. package/esm2020/src/lib/base/services/graphql-meta.service.mjs +0 -123
  233. package/esm2020/src/lib/base/services/graphql-plus.service.mjs +0 -84
  234. package/esm2020/src/lib/base/services/graphql.service.mjs +0 -441
  235. package/esm2020/src/lib/base/services/image.service.mjs +0 -102
  236. package/esm2020/src/lib/base/services/loader.service.mjs +0 -29
  237. package/esm2020/src/lib/base/services/scroll.service.mjs +0 -179
  238. package/esm2020/src/lib/base/services/seo.service.mjs +0 -97
  239. package/esm2020/src/lib/base/services/storage.service.mjs +0 -132
  240. package/esm2020/src/lib/base/services/ws.service.mjs +0 -17
  241. package/esm2020/src/lib/base/types/storage.type.mjs +0 -2
  242. package/esm2020/src/lib/base/validators/must-match.validator.mjs +0 -22
  243. package/fesm2015/lenne.tech-ng-base-src-lib-base.mjs +0 -2470
  244. package/fesm2015/lenne.tech-ng-base-src-lib-base.mjs.map +0 -1
  245. package/fesm2020/lenne.tech-ng-base-src-lib-base.mjs +0 -2524
  246. package/fesm2020/lenne.tech-ng-base-src-lib-base.mjs.map +0 -1
  247. package/lib/base/index.d.ts +0 -1
  248. package/lib/base/public-api.d.ts +0 -49
  249. package/src/lib/base/base.module.d.ts +0 -21
  250. package/src/lib/base/classes/basic-user.class.d.ts +0 -26
  251. package/src/lib/base/classes/graphql-enum.class.d.ts +0 -7
  252. package/src/lib/base/classes/graphql-meta.class.d.ts +0 -46
  253. package/src/lib/base/classes/graphql-type.class.d.ts +0 -9
  254. package/src/lib/base/classes/helper.class.d.ts +0 -98
  255. package/src/lib/base/classes/standard.class.d.ts +0 -32
  256. package/src/lib/base/directives/context-menu.directive.d.ts +0 -22
  257. package/src/lib/base/directives/lazy-load.directive.d.ts +0 -17
  258. package/src/lib/base/directives/match-height.directive.d.ts +0 -19
  259. package/src/lib/base/directives/resizable.directive.d.ts +0 -26
  260. package/src/lib/base/enums/comparison-operator.enum.d.ts +0 -14
  261. package/src/lib/base/enums/graphql-request-type.enum.d.ts +0 -8
  262. package/src/lib/base/enums/logical-operator.enum.d.ts +0 -8
  263. package/src/lib/base/enums/sort-order.enum.d.ts +0 -4
  264. package/src/lib/base/factories/apollo-options.factory.d.ts +0 -18
  265. package/src/lib/base/guards/auth.guard.d.ts +0 -27
  266. package/src/lib/base/guards/can-deactivate.guard.d.ts +0 -11
  267. package/src/lib/base/guards/logout.guard.d.ts +0 -16
  268. package/src/lib/base/interfaces/base-module-config.interface.d.ts +0 -57
  269. package/src/lib/base/interfaces/can-component-deactivate.interface.d.ts +0 -7
  270. package/src/lib/base/interfaces/combined-filter-input.interface.d.ts +0 -9
  271. package/src/lib/base/interfaces/field-object.interface.d.ts +0 -6
  272. package/src/lib/base/interfaces/field.interface.d.ts +0 -5
  273. package/src/lib/base/interfaces/filter-input.interface.d.ts +0 -9
  274. package/src/lib/base/interfaces/find-args.interface.d.ts +0 -10
  275. package/src/lib/base/interfaces/graphql-options.interface.d.ts +0 -11
  276. package/src/lib/base/interfaces/graphql-plus-options.interfacen.d.ts +0 -9
  277. package/src/lib/base/interfaces/graphql-type-collection.interface.d.ts +0 -7
  278. package/src/lib/base/interfaces/single-filter-input.interface.d.ts +0 -11
  279. package/src/lib/base/interfaces/sort-input.interface.d.ts +0 -5
  280. package/src/lib/base/package.json +0 -10
  281. package/src/lib/base/pipes/ellipses.pipe.d.ts +0 -10
  282. package/src/lib/base/pipes/safe-html.pipe.d.ts +0 -13
  283. package/src/lib/base/public-api.d.ts +0 -49
  284. package/src/lib/base/services/auth.service.d.ts +0 -32
  285. package/src/lib/base/services/fullscreen.service.d.ts +0 -18
  286. package/src/lib/base/services/graphql-meta.service.d.ts +0 -45
  287. package/src/lib/base/services/graphql-plus.service.d.ts +0 -25
  288. package/src/lib/base/services/graphql.service.d.ts +0 -56
  289. package/src/lib/base/services/image.service.d.ts +0 -27
  290. package/src/lib/base/services/loader.service.d.ts +0 -13
  291. package/src/lib/base/services/scroll.service.d.ts +0 -85
  292. package/src/lib/base/services/seo.service.d.ts +0 -49
  293. package/src/lib/base/services/storage.service.d.ts +0 -48
  294. package/src/lib/base/services/ws.service.d.ts +0 -8
  295. package/src/lib/base/types/storage.type.d.ts +0 -4
  296. package/src/lib/base/validators/must-match.validator.d.ts +0 -6
@@ -1,2470 +0,0 @@
1
- import * as i1$2 from 'apollo-angular';
2
- import { APOLLO_OPTIONS, gql } from 'apollo-angular';
3
- import { HttpLink } from 'apollo-angular/http';
4
- import * as i0 from '@angular/core';
5
- import { InjectionToken, Injectable, Inject, Directive, Input, Output, HostBinding, PLATFORM_ID, HostListener, Pipe, NgModule } from '@angular/core';
6
- import { BehaviorSubject, Observable, of, throwError } from 'rxjs';
7
- import { ApolloLink, split, concat } from '@apollo/client/core';
8
- import { InMemoryCache } from '@apollo/client/cache';
9
- import { WebSocketLink } from '@apollo/client/link/ws';
10
- import { getMainDefinition } from '@apollo/client/utilities';
11
- import { __awaiter } from 'tslib';
12
- import { isPlatformBrowser } from '@angular/common';
13
- import * as i1 from '@angular/platform-browser';
14
- import * as i1$1 from '@angular/router';
15
- import { buildClientSchema, getIntrospectionQuery } from 'graphql';
16
- import { map } from 'rxjs/operators';
17
-
18
- const BASE_MODULE_CONFIG = new InjectionToken('BASE_MODULE_CONFIG');
19
-
20
- /**
21
- * Storage service for local data storage
22
- */
23
- class StorageService {
24
- /**
25
- * Initializations
26
- */
27
- constructor(moduleConfig) {
28
- this.moduleConfig = moduleConfig;
29
- /**
30
- * Storage
31
- */
32
- this.storage = null;
33
- /**
34
- * Prefix for storage keys
35
- */
36
- this.prefix = '';
37
- // Set storage
38
- const type = moduleConfig.storageType ? moduleConfig.storageType : 'local';
39
- if (window[type + 'Storage']) {
40
- this.storage = window[type + 'Storage'];
41
- }
42
- // Set prefix
43
- this.prefix = '';
44
- if (moduleConfig.prefix) {
45
- this.prefix += moduleConfig.prefix + '_';
46
- }
47
- if (moduleConfig.version) {
48
- this.prefix += moduleConfig.version + '_';
49
- }
50
- }
51
- /**
52
- * Save itemKeys
53
- *
54
- * If you want to save one item, use itemKeys and value parameters like these:
55
- * save('KEY_OF_THE_ITEM', ITEM)
56
- *
57
- * If you want to save multiple items, use itemKeys only (value parameter will be ignored):
58
- * save({'KEY_OF_ITEM_1': ITEM_1, 'KEY_OF_ITEM_2': ITEM_2, ...})
59
- */
60
- save(itemKeys, value) {
61
- // Check local storage
62
- if (!this.storage) {
63
- return false;
64
- }
65
- // Check item keys and value
66
- if (!itemKeys ||
67
- (typeof itemKeys === 'object' && !Object.keys(itemKeys).length) ||
68
- (typeof itemKeys === 'string' && value === undefined)) {
69
- return false;
70
- }
71
- if (typeof itemKeys === 'object') {
72
- for (const [itemKey, itemValue] of Object.entries(itemKeys)) {
73
- this.storage.setItem(this.prefix + itemKey, JSON.stringify(itemValue));
74
- }
75
- return true;
76
- }
77
- this.storage.setItem(this.prefix + itemKeys, JSON.stringify(value));
78
- return true;
79
- }
80
- /**
81
- * Load items via key(s)
82
- */
83
- load(itemKeys) {
84
- // Check local storage
85
- if (!this.storage) {
86
- return;
87
- }
88
- // Check item keys
89
- if (!itemKeys || (Array.isArray(itemKeys) && !itemKeys.length)) {
90
- return null;
91
- }
92
- if (Array.isArray(itemKeys)) {
93
- const back = {};
94
- itemKeys.forEach((itemKey) => {
95
- const loadedItem = this.storage.getItem(this.prefix + itemKey);
96
- if (loadedItem) {
97
- back[itemKey] = JSON.parse(loadedItem);
98
- }
99
- else {
100
- back[itemKey] = null;
101
- }
102
- });
103
- return back;
104
- }
105
- let value = this.storage.getItem(this.prefix + itemKeys);
106
- if (value) {
107
- value = JSON.parse(value);
108
- }
109
- return value;
110
- }
111
- /**
112
- * Remove item from storage
113
- *
114
- * @param itemKeys keys or key to remove
115
- */
116
- remove(itemKeys) {
117
- // Check local storage
118
- if (!this.storage) {
119
- return false;
120
- }
121
- if (Array.isArray(itemKeys)) {
122
- itemKeys.forEach((key) => {
123
- this.storage.removeItem(this.prefix + key);
124
- });
125
- return true;
126
- }
127
- this.storage.removeItem(this.prefix + itemKeys);
128
- return true;
129
- }
130
- /**
131
- * Clear local storage
132
- */
133
- reset() {
134
- this.storage.clear();
135
- }
136
- }
137
- StorageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: StorageService, deps: [{ token: BASE_MODULE_CONFIG }], target: i0.ɵɵFactoryTarget.Injectable });
138
- StorageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: StorageService, providedIn: 'root' });
139
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: StorageService, decorators: [{
140
- type: Injectable,
141
- args: [{
142
- providedIn: 'root',
143
- }]
144
- }], ctorParameters: function () {
145
- return [{ type: undefined, decorators: [{
146
- type: Inject,
147
- args: [BASE_MODULE_CONFIG]
148
- }] }];
149
- } });
150
-
151
- class WsService {
152
- reconnect() {
153
- var _a, _b;
154
- (_a = this.client) === null || _a === void 0 ? void 0 : _a.close();
155
- (_b = this.client) === null || _b === void 0 ? void 0 : _b.connect();
156
- }
157
- }
158
- WsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: WsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
159
- WsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: WsService, providedIn: 'root' });
160
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: WsService, decorators: [{
161
- type: Injectable,
162
- args: [{
163
- providedIn: 'root',
164
- }]
165
- }] });
166
-
167
- /**
168
- * Authentication service
169
- */
170
- class AuthService {
171
- /**
172
- * Constructor
173
- */
174
- constructor(moduleConfig, storageService, wsService) {
175
- this.moduleConfig = moduleConfig;
176
- this.storageService = storageService;
177
- this.wsService = wsService;
178
- // Subjects
179
- this._currentUser = new BehaviorSubject(null);
180
- this._token = new BehaviorSubject(null);
181
- this.token = this.storageService.load('token');
182
- this.currentUser = this.storageService.load('currentUser');
183
- }
184
- /**
185
- * Logout
186
- */
187
- logout() {
188
- this.storageService.remove(['token', 'currentUser']);
189
- this.currentUser = null;
190
- this.token = null;
191
- }
192
- // #################################################################
193
- // Current User
194
- // #################################################################
195
- get currentUser() {
196
- return this._currentUser.value;
197
- }
198
- set currentUser(user) {
199
- this._currentUser.next(user);
200
- this.storageService.save('currentUser', user);
201
- }
202
- get currentUserObservable() {
203
- return this._currentUser.asObservable();
204
- }
205
- // #################################################################
206
- // Token
207
- // #################################################################
208
- get token() {
209
- return this._token.value;
210
- }
211
- set token(token) {
212
- this._token.next(token);
213
- this.storageService.save('token', token);
214
- this.wsService.reconnect();
215
- }
216
- get tokenObservable() {
217
- return this._token.asObservable();
218
- }
219
- }
220
- AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: AuthService, deps: [{ token: BASE_MODULE_CONFIG }, { token: StorageService }, { token: WsService }], target: i0.ɵɵFactoryTarget.Injectable });
221
- AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: AuthService, providedIn: 'root' });
222
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: AuthService, decorators: [{
223
- type: Injectable,
224
- args: [{
225
- providedIn: 'root',
226
- }]
227
- }], ctorParameters: function () {
228
- return [{ type: undefined, decorators: [{
229
- type: Inject,
230
- args: [BASE_MODULE_CONFIG]
231
- }] }, { type: StorageService }, { type: WsService }];
232
- } });
233
-
234
- /**
235
- * Factory for apollo-angular options
236
- */
237
- function apolloOptionsFactory(baseModuleConfig, httpLink, authService, wsService) {
238
- const links = [];
239
- const defaultUrl = 'api.' + window.location.href + '/graphql';
240
- const http = httpLink.create({
241
- uri: baseModuleConfig.apiUrl ? baseModuleConfig.apiUrl : 'https://' + defaultUrl,
242
- });
243
- const authMiddleware = new ApolloLink((operation, forward) => {
244
- const headers = {};
245
- if (localStorage) {
246
- const token = authService.token || null;
247
- if (token) {
248
- headers.Authorization = 'Bearer ' + token;
249
- }
250
- operation.setContext(() => ({ headers }));
251
- }
252
- return forward(operation);
253
- });
254
- if (baseModuleConfig.wsUrl) {
255
- const wsLink = new WebSocketLink({
256
- uri: baseModuleConfig.wsUrl,
257
- options: {
258
- reconnect: true,
259
- connectionParams: () => ({
260
- Authorization: authService.token ? 'Bearer ' + authService.token : undefined,
261
- }),
262
- },
263
- });
264
- // Set client for reconnection on logout/login
265
- wsService.client = wsLink.subscriptionClient;
266
- // using the ability to split links, you can send data to each link
267
- // depending on what kind of operation is being sent
268
- links.push(split(
269
- // split based on operation type
270
- ({ query }) => {
271
- // @ts-ignore
272
- const { kind, operation } = getMainDefinition(query);
273
- return kind === 'OperationDefinition' && operation === 'subscription';
274
- }, wsLink, concat(authMiddleware, http)));
275
- }
276
- else {
277
- links.push(http);
278
- links.push(authMiddleware);
279
- }
280
- return {
281
- link: ApolloLink.from(links),
282
- cache: new InMemoryCache(),
283
- defaultOptions: {
284
- query: {
285
- fetchPolicy: 'network-only',
286
- },
287
- },
288
- };
289
- }
290
-
291
- /**
292
- * Directive vor context menu
293
- * See https://stackblitz.com/edit/angular-custom-context-menu
294
- */
295
- class ContextMenuDirective {
296
- constructor(el) {
297
- this.el = el;
298
- this.xGap = 0;
299
- this.yGap = 0;
300
- this.overflowSpace = 10;
301
- this.selectors = '*';
302
- this.clickedElement = null;
303
- this.previousDisplayStatus = null;
304
- }
305
- ngOnInit() {
306
- if (this.ltContextMenu) {
307
- this.previousDisplayStatus = this.ltContextMenu.style.display;
308
- }
309
- // Add a click listener to the window,
310
- // so that we can close the context menu on left click
311
- window.addEventListener('click', () => {
312
- this.showContextMenu(null, false);
313
- });
314
- // Close context menu when escape is pressed
315
- window.addEventListener('keydown', (e) => {
316
- if (e.code === 'Escape') {
317
- this.showContextMenu(null, false);
318
- }
319
- });
320
- // Add an event listener to listen to the 'contextmenu' event
321
- this.el.nativeElement.addEventListener('contextmenu', (e) => {
322
- // Prevent the default context menu to popup
323
- if (e.preventDefault) {
324
- e.preventDefault();
325
- }
326
- // Shows our own context menu
327
- this.showContextMenu(e, true);
328
- });
329
- }
330
- // Shows or hides our custom context menu, which is specified as a input
331
- showContextMenu(event, show) {
332
- var _a;
333
- const cm = this.ltContextMenu;
334
- if (cm) {
335
- // Try to open context menu
336
- if (show && event && event instanceof MouseEvent) {
337
- // Get valid clicked structureElement
338
- const clickedElement = (_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.closest(this.selectors);
339
- if (clickedElement) {
340
- // Set clicked structureElement
341
- this.clickedElement = clickedElement;
342
- setTimeout(() => {
343
- // Set display status
344
- cm.style.display = 'block';
345
- // Calculate top position
346
- let top = event.y + this.yGap;
347
- if (top + cm.offsetHeight + 10 > document.documentElement.clientHeight) {
348
- top = document.documentElement.clientHeight - cm.offsetHeight - this.overflowSpace;
349
- }
350
- // Calculate left position
351
- let left = event.x + this.xGap;
352
- if (left + cm.offsetWidth + 10 > document.documentElement.clientWidth) {
353
- left = document.documentElement.clientWidth - cm.offsetWidth - this.overflowSpace;
354
- }
355
- // Set position
356
- cm.style.top = top + 'px';
357
- cm.style.left = left + 'px';
358
- // Show
359
- cm.style.opacity = '1.0';
360
- cm.style['pointer-events'] = 'auto';
361
- }, 1);
362
- return;
363
- }
364
- }
365
- // Close context menu
366
- this.clickedElement = null;
367
- if (this.previousDisplayStatus) {
368
- cm.style.display = this.previousDisplayStatus;
369
- }
370
- cm.style.opacity = '0.01';
371
- cm.style['pointer-events'] = 'none';
372
- }
373
- }
374
- }
375
- ContextMenuDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: ContextMenuDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
376
- ContextMenuDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.0", type: ContextMenuDirective, selector: "[ltContextMenu]", inputs: { contextMenuData: "contextMenuData", ltContextMenu: "ltContextMenu", xGap: "xGap", yGap: "yGap", overflowSpace: "overflowSpace", selectors: "selectors" }, outputs: { clickedElement: "clickedElement" }, exportAs: ["contextMenuData"], ngImport: i0 });
377
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: ContextMenuDirective, decorators: [{
378
- type: Directive,
379
- args: [{
380
- selector: '[ltContextMenu]',
381
- exportAs: 'contextMenuData',
382
- }]
383
- }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { contextMenuData: [{
384
- type: Input
385
- }], ltContextMenu: [{
386
- type: Input
387
- }], xGap: [{
388
- type: Input
389
- }], yGap: [{
390
- type: Input
391
- }], overflowSpace: [{
392
- type: Input
393
- }], selectors: [{
394
- type: Input
395
- }], clickedElement: [{
396
- type: Output
397
- }] } });
398
-
399
- /**
400
- * Directive for lazy loading images
401
- */
402
- class LazyLoadDirective {
403
- constructor(el) {
404
- this.el = el;
405
- this.srcAttr = null;
406
- }
407
- ngAfterViewInit() {
408
- this.canLazyLoad() ? this.lazyLoadImage() : this.loadImage();
409
- }
410
- canLazyLoad() {
411
- return window && 'IntersectionObserver' in window;
412
- }
413
- lazyLoadImage() {
414
- const obs = new IntersectionObserver((entries) => {
415
- entries.forEach(({ isIntersecting }) => {
416
- if (isIntersecting) {
417
- this.loadImage();
418
- obs.unobserve(this.el.nativeElement);
419
- }
420
- });
421
- });
422
- obs.observe(this.el.nativeElement);
423
- }
424
- loadImage() {
425
- this.srcAttr = this.src;
426
- }
427
- }
428
- LazyLoadDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: LazyLoadDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
429
- LazyLoadDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.0", type: LazyLoadDirective, selector: "img[ltLazyLoad]", inputs: { src: "src" }, host: { properties: { "attr.src": "this.srcAttr" } }, ngImport: i0 });
430
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: LazyLoadDirective, decorators: [{
431
- type: Directive,
432
- args: [{
433
- selector: 'img[ltLazyLoad]',
434
- }]
435
- }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { srcAttr: [{
436
- type: HostBinding,
437
- args: ['attr.src']
438
- }], src: [{
439
- type: Input
440
- }] } });
441
-
442
- /**
443
- * Helper class
444
- */
445
- class Helper {
446
- /**
447
- * Simple filter function for plain objects
448
- */
449
- static filter(objects, filter) {
450
- return ((objects === null || objects === void 0 ? void 0 : objects.filter((element) => {
451
- for (const [key, value] of Object.entries(filter)) {
452
- if (Array.isArray(element[key])) {
453
- for (const item of element[key]) {
454
- if (!element[key].includs(value)) {
455
- return false;
456
- }
457
- }
458
- }
459
- else if (element[key] !== value) {
460
- return false;
461
- }
462
- }
463
- return true;
464
- })) || []);
465
- }
466
- /**
467
- * Convert to a url/uri conform string
468
- * Only:
469
- * - lower case
470
- * - chars, numbers and hyphens
471
- */
472
- static urlString(str, options = {}) {
473
- // Config
474
- const config = Object.assign({ allowAll: false }, options);
475
- // To string
476
- str = str + '';
477
- // Trim
478
- str = str.trim();
479
- // Lower case
480
- str = str.toLowerCase();
481
- if (!config.allowAll) {
482
- // Replace spaces
483
- str = str.trim().replace(/\s+/g, '-');
484
- // Replace some special chars
485
- str = str.replace('ä', 'ae');
486
- str = str.replace('ö', 'oe');
487
- str = str.replace('ü', 'ue');
488
- str = str.replace('ß', 'ss');
489
- // Remove other special chars
490
- str = str.replace(/[^a-zA-Z0-9-]/g, '');
491
- }
492
- // Return url conform string
493
- return encodeURI(str);
494
- }
495
- /**
496
- * Simple map function
497
- */
498
- static map(source, target, options = {}) {
499
- // Set config
500
- const config = Object.assign({ funcAllowed: false, dateStringToDate: true }, options);
501
- // Check source
502
- if (!source || typeof source !== 'object' || Array.isArray(source)) {
503
- return target;
504
- }
505
- // Update properties
506
- for (const key of Object.keys(target)) {
507
- if (source[key] !== undefined && (config.funcAllowed || typeof (source[key] !== 'function'))) {
508
- if (typeof source[key] === 'string' && config.dateStringToDate) {
509
- if (Array.isArray(config.dateStringToDate)) {
510
- if (config.dateStringToDate.includes(key)) {
511
- target[key] = Helper.parseDate(source[key]);
512
- }
513
- }
514
- else {
515
- target[key] = Helper.parseDate(source[key]);
516
- }
517
- }
518
- else {
519
- target[key] = source[key];
520
- }
521
- }
522
- }
523
- // Return target
524
- return target;
525
- }
526
- /**
527
- * Create Object or Objects of specified type with specified data
528
- */
529
- static maps(data, targetClass) {
530
- // Check data
531
- if (!data || typeof data !== 'object') {
532
- return undefined;
533
- }
534
- // Check array
535
- if (!Array.isArray(data)) {
536
- data = [data];
537
- }
538
- // Map
539
- return data.map((item) => {
540
- return targetClass.map(item);
541
- });
542
- }
543
- /**
544
- * Get plain parameter
545
- */
546
- static getPlainParameter(parameter) {
547
- var _a, _b, _c;
548
- if (!parameter) {
549
- return parameter;
550
- }
551
- return (_c = (_b = (_a = parameter === null || parameter === void 0 ? void 0 : parameter.split('?')) === null || _a === void 0 ? void 0 : _a.shift()) === null || _b === void 0 ? void 0 : _b.split('#')) === null || _c === void 0 ? void 0 : _c.shift();
552
- }
553
- /**
554
- * Get ID of an url parameter
555
- */
556
- static getParameterId(parameter) {
557
- var _a;
558
- if (!parameter) {
559
- return parameter;
560
- }
561
- return (_a = Helper.getPlainParameter(parameter)) === null || _a === void 0 ? void 0 : _a.split('-').pop();
562
- }
563
- /**
564
- * Delay
565
- */
566
- static delay(ms) {
567
- const promise = new Promise((resolve) => setTimeout(resolve, ms));
568
- return promise;
569
- }
570
- /**
571
- * Deep freeze
572
- * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze#What_is_shallow_freeze
573
- */
574
- static deepFreeze(object, preparedObjects = []) {
575
- // Prevent infinit regress
576
- if (preparedObjects.includes(object)) {
577
- return object;
578
- }
579
- preparedObjects.push(object);
580
- // Retrieve the property names defined on object
581
- const propNames = Object.getOwnPropertyNames(object);
582
- // Freeze properties before freezing self
583
- for (const name of propNames) {
584
- const value = object[name];
585
- if (value && typeof value === 'object') {
586
- Helper.deepFreeze(value, preparedObjects);
587
- }
588
- }
589
- return Object.freeze(object);
590
- }
591
- /**
592
- * Generates an unique identifier with 24 characters
593
- */
594
- static getUID() {
595
- let dt = new Date().getTime();
596
- const uuid = 'xxxxxxxxxxxxxxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
597
- // eslint-disable-next-line no-bitwise
598
- const r = (dt + Math.random() * 16) % 16 | 0;
599
- dt = Math.floor(dt / 16);
600
- // eslint-disable-next-line no-bitwise
601
- return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16);
602
- });
603
- return uuid;
604
- }
605
- /**
606
- * Parse date string to date object
607
- */
608
- static parseDate(dateString) {
609
- const reISO = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*))(?:Z|(\+|-)([\d|:]*))?$/;
610
- const reMsAjax = /^\/Date\((d|-|.*)\)[\/|\\]$/;
611
- if (typeof dateString === 'string') {
612
- const isoExec = reISO.exec(dateString);
613
- if (isoExec) {
614
- return new Date(dateString);
615
- }
616
- const msAjaxExec = reMsAjax.exec(dateString);
617
- if (msAjaxExec) {
618
- const cleaned = msAjaxExec[1].split(/[-+,.]/);
619
- return new Date(cleaned[0] ? +cleaned[0] : 0 - +cleaned[1]);
620
- }
621
- }
622
- return dateString;
623
- }
624
- /**
625
- * Get browser name and version
626
- */
627
- static getBrowser() {
628
- const userAgent = navigator.userAgent;
629
- let data = userAgent.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
630
- let version;
631
- if (/trident/i.test(data[1])) {
632
- version = /\brv[ :]+(\d+)/g.exec(userAgent) || [];
633
- return { name: 'IE', version: version[1] || '' };
634
- }
635
- if (data[1] === 'Chrome') {
636
- version = userAgent.match(/\bOPR|Edge\/(\d+)/);
637
- if (version != null) {
638
- return { name: 'Opera', version: version[1] };
639
- }
640
- }
641
- data = data[2] ? [data[1], data[2]] : [navigator.appName, navigator.appVersion, '-?'];
642
- version = userAgent.match(/version\/(\d+)/i);
643
- if (version !== null) {
644
- data.splice(1, 1, version[1]);
645
- }
646
- return {
647
- name: data[0],
648
- version: data[1],
649
- };
650
- }
651
- /**
652
- * Whether first parameter is a deep subset of second parameter
653
- * Hint: functions will be ignored
654
- */
655
- static isSubset(a, b) {
656
- // Equal
657
- if (a === b) {
658
- return true;
659
- }
660
- // Different type
661
- if (typeof a !== typeof b) {
662
- return false;
663
- }
664
- // Process array
665
- if (Array.isArray(a)) {
666
- for (const [key, value] of Object.entries(a)) {
667
- if (Helper.isSubset(value, b[key])) {
668
- return false;
669
- }
670
- }
671
- return true;
672
- }
673
- // Process object
674
- if (typeof a === 'object') {
675
- const plain = JSON.parse(JSON.stringify(a));
676
- for (const [key, value] of Object.entries(plain)) {
677
- if (Helper.isSubset(value, b[key])) {
678
- return false;
679
- }
680
- }
681
- return true;
682
- }
683
- // Else
684
- return true;
685
- }
686
- /**
687
- * Whether parameters are equal (have equal properties)
688
- * Hint: functions will be ignored
689
- */
690
- static isEqual(a, b) {
691
- return Helper.isSubset(a, b) && Helper.isSubset(b, a);
692
- }
693
- /**
694
- * First level difference of two objects
695
- * Hint: functions will be ignored and when an array or an object is different the hole array or object will used as property value
696
- *
697
- * @returns Record<string, any> Object with properties from first object
698
- */
699
- static getDiff(a, b, clone = true) {
700
- const result = {};
701
- let firstObject = a;
702
- if (clone) {
703
- firstObject = JSON.parse(JSON.stringify(a));
704
- }
705
- for (const [key, value] of Object.entries(firstObject)) {
706
- if (!Helper.isSubset(value, b[key])) {
707
- result[key] = value;
708
- }
709
- }
710
- return result;
711
- }
712
- /**
713
- * Check if propertie is type of HTMLCollection or NodeList
714
- * See https://stackoverflow.com/a/7238344
715
- *
716
- * @param nodes
717
- */
718
- static isNodeList(nodes) {
719
- try {
720
- const stringRepr = Object.prototype.toString.call(nodes);
721
- return (typeof nodes === 'object' &&
722
- /^\[object (HTMLCollection|NodeList|Object)\]$/.test(stringRepr) &&
723
- typeof nodes.length === 'number' &&
724
- (nodes.length === 0 || (typeof nodes[0] === 'object' && nodes[0].nodeType > 0)));
725
- }
726
- catch (e) {
727
- return false;
728
- }
729
- }
730
- }
731
-
732
- /**
733
- * Image service
734
- */
735
- class ImageService {
736
- /**
737
- * Preaload images (for lazy handling)
738
- *
739
- * @param options
740
- * @protected
741
- */
742
- preLoadImages(options) {
743
- // Init configuration
744
- const config = Object.assign({ doneFunnction: undefined, elements: document, regExp: undefined }, options);
745
- return new Promise((resolve) => {
746
- var _a;
747
- // Convert element(s) into array
748
- if (!Array.isArray(config.elements)) {
749
- // NodeList or HTMLCollection
750
- if (Helper.isNodeList(config.elements)) {
751
- config.elements = Array.from(config.elements);
752
- }
753
- // Single element
754
- else {
755
- config.elements = [config.elements];
756
- }
757
- }
758
- // Init loading
759
- const promises = [];
760
- // Get all images
761
- let images = [];
762
- config.elements.forEach((element) => {
763
- images = images.concat(Array.from(element.getElementsByTagName('img')));
764
- });
765
- // Prepare images
766
- for (let image of images) {
767
- const src = image.getAttribute('src');
768
- // Check if changes are necessary and possible
769
- if ((image.complete && image.naturalHeight !== 0) || // already laoded
770
- !src || // Image has no src
771
- ((_a = config.regExp) === null || _a === void 0 ? void 0 : _a.test(src)) // Test if src matches regular expression
772
- ) {
773
- continue;
774
- }
775
- // Replace lazy loading image with immediately loading image
776
- if (image.getAttribute('loading') === 'lazy') {
777
- const newImage = document.createElement('img');
778
- Array.from(image.attributes).forEach((attr) => {
779
- if (attr.name !== 'loading' && attr.name !== 'src') {
780
- newImage.setAttribute(attr.name, attr.value);
781
- }
782
- });
783
- image.replaceWith(newImage);
784
- image = newImage;
785
- }
786
- // Wait for laoding
787
- promises.push(this.loadImage(image, src));
788
- }
789
- // Wait until all images loaded
790
- Promise.all(promises)
791
- .catch((e) => console.error('Error during image loading', e))
792
- .finally(() => __awaiter(this, void 0, void 0, function* () {
793
- // Return result
794
- let result;
795
- if (config.doneFunnction) {
796
- result = yield config.doneFunction();
797
- }
798
- resolve(result);
799
- }));
800
- });
801
- }
802
- /**
803
- * Load image for image element
804
- *
805
- * @param imageElement
806
- * @param src
807
- * @protected
808
- */
809
- loadImage(imageElement, src) {
810
- return __awaiter(this, void 0, void 0, function* () {
811
- src = src || imageElement.src;
812
- return new Promise((resolve, reject) => {
813
- imageElement.onload = () => resolve(imageElement);
814
- imageElement.onerror = reject;
815
- imageElement.src = src;
816
- });
817
- });
818
- }
819
- }
820
- ImageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: ImageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
821
- ImageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: ImageService, providedIn: 'root' });
822
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: ImageService, decorators: [{
823
- type: Injectable,
824
- args: [{
825
- providedIn: 'root',
826
- }]
827
- }] });
828
-
829
- /**
830
- * Set same height (maximum) to different elements
831
- */
832
- class MatchHeightDirective {
833
- constructor(el, imageService, platformId) {
834
- this.el = el;
835
- this.imageService = imageService;
836
- // Replace lazy loading images with immediate loading images
837
- this.loadImages = true;
838
- this.isBrowser = isPlatformBrowser(platformId);
839
- }
840
- onResize() {
841
- this.matchHeight(this.el.nativeElement, this.ltMatchHeight);
842
- }
843
- ngOnInit() {
844
- this.matchHeight(this.el.nativeElement, this.ltMatchHeight);
845
- }
846
- matchHeight(parent, target) {
847
- return __awaiter(this, void 0, void 0, function* () {
848
- if (!parent) {
849
- return;
850
- }
851
- let classNames;
852
- if (!Array.isArray(target)) {
853
- classNames = [target];
854
- }
855
- else {
856
- classNames = target;
857
- }
858
- for (const className of classNames) {
859
- // find all child structureElements with the selected class name
860
- const children = parent.getElementsByClassName(className);
861
- if (!children || children.length < 2) {
862
- continue;
863
- }
864
- // Load images of children
865
- if (this.loadImages) {
866
- yield this.imageService.preLoadImages({ elements: children });
867
- }
868
- // reset all children height
869
- Array.from(children).forEach((element) => {
870
- element.style.height = 'initial';
871
- });
872
- // get all the child structureElements heights
873
- const itemHeights = Array.from(children).map((element) => {
874
- if (element.getBoundingClientRect) {
875
- return element.getBoundingClientRect().height;
876
- }
877
- return 0;
878
- });
879
- // find out the tallest one
880
- const maxHeight = itemHeights.reduce((prev, curr) => (curr > prev ? curr : prev), 0);
881
- // update the child structureElements height to the tallest one
882
- Array.from(children).forEach((element) => (element.style.height = `${maxHeight}px`));
883
- }
884
- });
885
- }
886
- }
887
- MatchHeightDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: MatchHeightDirective, deps: [{ token: i0.ElementRef }, { token: ImageService }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Directive });
888
- MatchHeightDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.0", type: MatchHeightDirective, selector: "[ltMatchHeight]", inputs: { ltMatchHeight: "ltMatchHeight", loadImages: "loadImages" }, host: { listeners: { "window:resize": "onResize()" } }, ngImport: i0 });
889
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: MatchHeightDirective, decorators: [{
890
- type: Directive,
891
- args: [{
892
- selector: '[ltMatchHeight]',
893
- }]
894
- }], ctorParameters: function () {
895
- return [{ type: i0.ElementRef }, { type: ImageService }, { type: undefined, decorators: [{
896
- type: Inject,
897
- args: [PLATFORM_ID]
898
- }] }];
899
- }, propDecorators: { ltMatchHeight: [{
900
- type: Input
901
- }], loadImages: [{
902
- type: Input
903
- }], onResize: [{
904
- type: HostListener,
905
- args: ['window:resize']
906
- }] } });
907
-
908
- /**
909
- * Reszise detection
910
- * (inpsired by: https://stackblitz.com/edit/angular-resizable)
911
- */
912
- class ResizableDirective {
913
- constructor(el) {
914
- this.el = el;
915
- this.resizableGrabWidth = 8;
916
- this.resizableMinWidth = 10;
917
- this.dragging = false;
918
- }
919
- ngOnInit() {
920
- this.addListenerToDocument();
921
- this.addListenerToElement();
922
- }
923
- mouseMoveG(evt) {
924
- if (!this.dragging) {
925
- return;
926
- }
927
- this.newWidth(evt.clientX - this.el.nativeElement.offsetLeft);
928
- evt.stopPropagation();
929
- }
930
- newWidth(wid) {
931
- const result = Math.max(this.resizableMinWidth, wid);
932
- this.el.nativeElement.style.width = result + 'px';
933
- }
934
- mouseDown(evt) {
935
- if (this.inDragRegion(evt)) {
936
- this.dragging = true;
937
- this.preventGlobalMouseEvents();
938
- evt.stopPropagation();
939
- }
940
- }
941
- restoreGlobalMouseEvents() {
942
- document.body.style['pointer-events'] = 'auto';
943
- }
944
- mouseUpG(evt) {
945
- if (!this.dragging) {
946
- return;
947
- }
948
- this.restoreGlobalMouseEvents();
949
- this.dragging = false;
950
- evt.stopPropagation();
951
- }
952
- mouseMove(evt) {
953
- if (this.inDragRegion(evt) || this.dragging) {
954
- this.el.nativeElement.style.cursor = 'col-resize';
955
- }
956
- else {
957
- this.el.nativeElement.style.cursor = 'default';
958
- }
959
- }
960
- preventGlobalMouseEvents() {
961
- document.body.style['pointer-events'] = 'none';
962
- }
963
- inDragRegion(evt) {
964
- return this.el.nativeElement.clientWidth - evt.clientX + this.el.nativeElement.offsetLeft < this.resizableGrabWidth;
965
- }
966
- addListenerToDocument() {
967
- document.addEventListener('mousemove', (e) => {
968
- this.mouseMoveG(e);
969
- }, true);
970
- document.addEventListener('mouseup', (e) => {
971
- this.mouseUpG(e);
972
- }, true);
973
- }
974
- addListenerToElement() {
975
- this.el.nativeElement.addEventListener('mousedown', (e) => {
976
- this.mouseDown(e);
977
- }, true);
978
- this.el.nativeElement.addEventListener('mousemove', (e) => {
979
- this.mouseMove(e);
980
- }, true);
981
- }
982
- }
983
- ResizableDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: ResizableDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
984
- ResizableDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.0", type: ResizableDirective, selector: "[ltResizable]", inputs: { resizableGrabWidth: "resizableGrabWidth", resizableMinWidth: "resizableMinWidth" }, ngImport: i0 });
985
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: ResizableDirective, decorators: [{
986
- type: Directive,
987
- args: [{
988
- selector: '[ltResizable]',
989
- }]
990
- }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { resizableGrabWidth: [{
991
- type: Input
992
- }], resizableMinWidth: [{
993
- type: Input
994
- }] } });
995
-
996
- /**
997
- * Truncate string with ellipses
998
- */
999
- class EllipsesPipe {
1000
- transform(value, limit) {
1001
- if (!value) {
1002
- return null;
1003
- }
1004
- return value.length > limit ? value.substring(0, limit) + '...' : value;
1005
- }
1006
- }
1007
- EllipsesPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: EllipsesPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1008
- EllipsesPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: EllipsesPipe, name: "ltEllipses" });
1009
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: EllipsesPipe, decorators: [{
1010
- type: Pipe,
1011
- args: [{
1012
- name: 'ltEllipses',
1013
- }]
1014
- }] });
1015
-
1016
- /**
1017
- * Declarate html as safe
1018
- */
1019
- class SafeHtmlPipe {
1020
- constructor(sanitized) {
1021
- this.sanitized = sanitized;
1022
- }
1023
- transform(value) {
1024
- return this.sanitized.bypassSecurityTrustHtml(value);
1025
- }
1026
- }
1027
- SafeHtmlPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: SafeHtmlPipe, deps: [{ token: i1.DomSanitizer }], target: i0.ɵɵFactoryTarget.Pipe });
1028
- SafeHtmlPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: SafeHtmlPipe, name: "ltSafeHtml" });
1029
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: SafeHtmlPipe, decorators: [{
1030
- type: Pipe,
1031
- args: [{ name: 'ltSafeHtml' }]
1032
- }], ctorParameters: function () { return [{ type: i1.DomSanitizer }]; } });
1033
-
1034
- // Imported and exported elements
1035
- const elements = [
1036
- // Directives
1037
- ContextMenuDirective,
1038
- LazyLoadDirective,
1039
- MatchHeightDirective,
1040
- ResizableDirective,
1041
- // Pipes
1042
- EllipsesPipe,
1043
- SafeHtmlPipe,
1044
- ];
1045
- /**
1046
- * Base module
1047
- */
1048
- class BaseModule {
1049
- /**
1050
- * Set configuration of base module in root module of the app
1051
- */
1052
- static forRoot(baseModuleConfig = {}, AppAuthService) {
1053
- // Default config
1054
- const config = Object.assign({ apiUrl: 'localhost:3000', authGuardRedirectUrl: '/auth', logging: false, version: null, prefix: null, scrollDetectionOffset: 200, scrollOffset: 100, storageType: 'local' }, baseModuleConfig);
1055
- // Prepare providers
1056
- const providers = [
1057
- {
1058
- provide: BASE_MODULE_CONFIG,
1059
- useValue: baseModuleConfig,
1060
- },
1061
- ];
1062
- // Add apollo features if API URL is set
1063
- if (baseModuleConfig.apiUrl) {
1064
- providers.push({
1065
- provide: APOLLO_OPTIONS,
1066
- useFactory: apolloOptionsFactory,
1067
- deps: [BASE_MODULE_CONFIG, HttpLink, AppAuthService ? AppAuthService : AuthService, WsService],
1068
- });
1069
- }
1070
- else if (config.logging) {
1071
- console.log('apiUrl is missing, ApolloLink is not initialized');
1072
- }
1073
- // Return root module
1074
- return {
1075
- ngModule: BaseModule,
1076
- providers,
1077
- };
1078
- }
1079
- }
1080
- BaseModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: BaseModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1081
- BaseModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: BaseModule, declarations: [
1082
- // Directives
1083
- ContextMenuDirective,
1084
- LazyLoadDirective,
1085
- MatchHeightDirective,
1086
- ResizableDirective,
1087
- // Pipes
1088
- EllipsesPipe,
1089
- SafeHtmlPipe
1090
- ], exports: [
1091
- // Directives
1092
- ContextMenuDirective,
1093
- LazyLoadDirective,
1094
- MatchHeightDirective,
1095
- ResizableDirective,
1096
- // Pipes
1097
- EllipsesPipe,
1098
- SafeHtmlPipe
1099
- ] });
1100
- BaseModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: BaseModule });
1101
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: BaseModule, decorators: [{
1102
- type: NgModule,
1103
- args: [{
1104
- declarations: elements,
1105
- exports: elements,
1106
- }]
1107
- }] });
1108
-
1109
- /**
1110
- * Standard class
1111
- * Other classes should extend the Standard class, if they offer own functions
1112
- * If the extended class uses object properties with own map functions, it should implement its own map function
1113
- */
1114
- class Standard {
1115
- /**
1116
- * Static map method
1117
- */
1118
- static map(data, item = new this()) {
1119
- return item.map(data);
1120
- }
1121
- /**
1122
- * Map data into an object
1123
- */
1124
- map(data) {
1125
- return Helper.map(data, this);
1126
- }
1127
- /**
1128
- * Clone object (and map additional data)
1129
- */
1130
- clone(mapData) {
1131
- const current = JSON.parse(JSON.stringify(this));
1132
- if (mapData) {
1133
- Object.assign(current, mapData);
1134
- }
1135
- return new this.constructor().map(current);
1136
- }
1137
- /**
1138
- * Compare this with another object
1139
- * Hint: functions will be ignored and when an array or an object is different the hole array or object will used as property value
1140
- *
1141
- * @return Record<string, any> with properties of this object which are different
1142
- */
1143
- getDiff(compare, clone = true) {
1144
- return Helper.getDiff(this, compare, clone);
1145
- }
1146
- }
1147
-
1148
- /**
1149
- * User class
1150
- */
1151
- class BasicUser extends Standard {
1152
- constructor() {
1153
- super(...arguments);
1154
- this.id = undefined;
1155
- this.email = undefined;
1156
- this.firstName = undefined;
1157
- this.lastName = undefined;
1158
- this.roles = [];
1159
- this.username = undefined;
1160
- }
1161
- // ===================================================================================================================
1162
- // Methods
1163
- // ===================================================================================================================
1164
- /**
1165
- * Mapping
1166
- */
1167
- map(data) {
1168
- Helper.map(data, this);
1169
- return this;
1170
- }
1171
- /**
1172
- * Checks whether the user has at least one of the required roles
1173
- */
1174
- hasRole(roles) {
1175
- if (typeof roles === 'string') {
1176
- roles = [roles];
1177
- }
1178
- if (!this.roles || this.roles.length < 1) {
1179
- return false;
1180
- }
1181
- return !roles || roles.length < 1 ? true : this.roles.some((role) => roles.includes(role));
1182
- }
1183
- /**
1184
- * Checks whether the user has all required roles
1185
- */
1186
- hasAllRoles(roles) {
1187
- if (typeof roles === 'string') {
1188
- roles = [roles];
1189
- }
1190
- if (!this.roles || this.roles.length < 1) {
1191
- return false;
1192
- }
1193
- return !roles ? true : roles.every((role) => this.roles.includes(role));
1194
- }
1195
- }
1196
-
1197
- /**
1198
- * GraphQL enum
1199
- */
1200
- class GraphQLEnum {
1201
- constructor(value) {
1202
- this.value = value;
1203
- }
1204
- }
1205
-
1206
- /**
1207
- * GraphQL type
1208
- */
1209
- class GraphQLType extends Standard {
1210
- constructor() {
1211
- super(...arguments);
1212
- this.type = '';
1213
- this.isEnum = false;
1214
- this.validEnums = [];
1215
- }
1216
- }
1217
-
1218
- /**
1219
- * GraphQL meta
1220
- */
1221
- class GraphQLMeta {
1222
- /**
1223
- * Integrate schema
1224
- */
1225
- constructor(schema) {
1226
- this.schema = schema;
1227
- // Frozen caches
1228
- this.args = {};
1229
- this.fields = {};
1230
- if (!schema) {
1231
- throw Error('Missing schema');
1232
- }
1233
- }
1234
- /**
1235
- * Get arguments of GraphQL function
1236
- */
1237
- getArgs(functionName, options = {}) {
1238
- const { cache, freeze, type } = Object.assign({ cache: true, freeze: true, type: undefined }, options);
1239
- // Get cache
1240
- if (cache && freeze) {
1241
- const args = this.args[functionName + type];
1242
- if (args) {
1243
- return args;
1244
- }
1245
- }
1246
- const func = this.getFunction(functionName, { type });
1247
- const result = {};
1248
- if (func === null || func === void 0 ? void 0 : func.args) {
1249
- func.args.forEach((item) => {
1250
- result[item.name] = this.getDeepType(item.type);
1251
- });
1252
- }
1253
- // Set cache
1254
- if (freeze) {
1255
- this.args[functionName + type] = Helper.deepFreeze(result);
1256
- }
1257
- return result;
1258
- }
1259
- /**
1260
- * Get fields of GraphQL function
1261
- */
1262
- getFields(functionName, options = {}) {
1263
- const { cache, freeze, type } = Object.assign({ cache: true, freeze: true, type: undefined }, options);
1264
- // Get cache
1265
- if (cache && freeze) {
1266
- const args = this.fields[functionName + type];
1267
- if (args) {
1268
- return args;
1269
- }
1270
- }
1271
- const func = this.getFunction(functionName, options);
1272
- const result = this.getDeepType(func.type);
1273
- // Set cache
1274
- if (freeze) {
1275
- this.fields[functionName + type] = Helper.deepFreeze(result);
1276
- }
1277
- return result;
1278
- }
1279
- /**
1280
- * Get GraphQL function
1281
- */
1282
- getFunction(name, options = {}) {
1283
- // Set config
1284
- const config = Object.assign({}, options);
1285
- // Init possible functions
1286
- let functions = {};
1287
- // If function type is set
1288
- if (config.type) {
1289
- const graphQLType = config.type.charAt(0).toUpperCase() + config.type.slice(1);
1290
- const type = this.schema.getType(graphQLType);
1291
- if (type) {
1292
- functions = type.getFields();
1293
- }
1294
- }
1295
- // If function type is not set
1296
- else {
1297
- ['Subscription', 'Mutation', 'Query'].forEach((item) => {
1298
- const type = this.schema.getType(item);
1299
- if (type) {
1300
- functions = Object.assign(Object.assign({}, functions), (type.getFields() || {}));
1301
- }
1302
- });
1303
- }
1304
- // Get function via name
1305
- return functions[name];
1306
- }
1307
- /**
1308
- * Get type
1309
- */
1310
- getType(name) {
1311
- return this.schema.getType(name);
1312
- }
1313
- /**
1314
- * Get deep type data
1315
- */
1316
- getDeepType(type, prepared = new WeakMap()) {
1317
- // Check type
1318
- if (!type) {
1319
- return type;
1320
- }
1321
- // Infinite regress protection
1322
- const preparedObject = {};
1323
- // Check prepared
1324
- if (typeof type === 'object') {
1325
- const preparedType = prepared.get(type);
1326
- if (preparedType) {
1327
- return preparedType;
1328
- }
1329
- // Set prepared
1330
- prepared.set(type, preparedObject);
1331
- }
1332
- // Search deeper
1333
- if (type.ofType) {
1334
- const ofTypeResult = this.getDeepType(type.ofType, prepared);
1335
- Object.assign(preparedObject, ofTypeResult);
1336
- return ofTypeResult;
1337
- }
1338
- // Process fields
1339
- if (type._fields) {
1340
- const result = {};
1341
- for (const [key, value] of Object.entries(type._fields)) {
1342
- result[key] = this.getDeepType(value, prepared);
1343
- }
1344
- Object.assign(preparedObject, result);
1345
- return result;
1346
- }
1347
- // Get type name
1348
- if (type.type) {
1349
- const typeResult = this.getDeepType(type.type, prepared);
1350
- Object.assign(preparedObject, typeResult);
1351
- return typeResult;
1352
- }
1353
- // Initialize GraphQLType
1354
- const graphqlType = GraphQLType.map({
1355
- type: type.name,
1356
- });
1357
- // Set enum values
1358
- if (!!type._values) {
1359
- graphqlType.isEnum = true;
1360
- for (const [key, value] of Object.entries(type._nameLookup)) {
1361
- if (!value.isDeprecated) {
1362
- graphqlType.validEnums.push(key);
1363
- }
1364
- }
1365
- }
1366
- // Finish
1367
- prepared.set(type, graphqlType);
1368
- return graphqlType;
1369
- }
1370
- }
1371
-
1372
- /**
1373
- * Authentication guard
1374
- */
1375
- class AuthGuard {
1376
- /**
1377
- * Imports
1378
- */
1379
- constructor(router, authService, moduleConfig) {
1380
- this.router = router;
1381
- this.authService = authService;
1382
- this.moduleConfig = moduleConfig;
1383
- }
1384
- /**
1385
- * Can activate main route
1386
- */
1387
- canActivate(route, state) {
1388
- return new Observable((subscriber) => {
1389
- var _a, _b, _c, _d;
1390
- let allowed = false;
1391
- const opposite = ((_a = route === null || route === void 0 ? void 0 : route.data) === null || _a === void 0 ? void 0 : _a.opposite) ? (_b = route === null || route === void 0 ? void 0 : route.data) === null || _b === void 0 ? void 0 : _b.opposite : false;
1392
- const redirectUrl = ((_c = route === null || route === void 0 ? void 0 : route.data) === null || _c === void 0 ? void 0 : _c.redirectUrl) ? route.data.redirectUrl : this.moduleConfig.authGuardRedirectUrl;
1393
- if (this.authService.token && !opposite) {
1394
- if (route.data.allowedRole) {
1395
- const user = this.authService.currentUser;
1396
- allowed = (_d = user === null || user === void 0 ? void 0 : user.roles) === null || _d === void 0 ? void 0 : _d.includes(route.data.allowedRole);
1397
- }
1398
- else {
1399
- allowed = true;
1400
- }
1401
- }
1402
- else if (!this.authService.token && opposite) {
1403
- allowed = true;
1404
- }
1405
- if (!allowed) {
1406
- this.router.navigate([redirectUrl]);
1407
- }
1408
- subscriber.next(allowed);
1409
- subscriber.complete();
1410
- });
1411
- }
1412
- /**
1413
- * Can activate child route
1414
- */
1415
- canActivateChild(route, state) {
1416
- return this.canActivate(route, state);
1417
- }
1418
- }
1419
- AuthGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: AuthGuard, deps: [{ token: i1$1.Router }, { token: AuthService }, { token: BASE_MODULE_CONFIG }], target: i0.ɵɵFactoryTarget.Injectable });
1420
- AuthGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: AuthGuard });
1421
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: AuthGuard, decorators: [{
1422
- type: Injectable
1423
- }], ctorParameters: function () {
1424
- return [{ type: i1$1.Router }, { type: AuthService }, { type: undefined, decorators: [{
1425
- type: Inject,
1426
- args: [BASE_MODULE_CONFIG]
1427
- }] }];
1428
- } });
1429
-
1430
- /**
1431
- * Guard to check if a component can be deactivated
1432
- */
1433
- class CanDeactivateGuard {
1434
- canDeactivate(component) {
1435
- return component.canDeactivate ? component.canDeactivate() : true;
1436
- }
1437
- }
1438
- CanDeactivateGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: CanDeactivateGuard, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1439
- CanDeactivateGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: CanDeactivateGuard });
1440
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: CanDeactivateGuard, decorators: [{
1441
- type: Injectable
1442
- }] });
1443
-
1444
- /**
1445
- * Logout guard
1446
- */
1447
- class LogoutGuard {
1448
- constructor(router, authService) {
1449
- this.router = router;
1450
- this.authService = authService;
1451
- }
1452
- canActivate(route, state) {
1453
- return new Observable((subscriber) => {
1454
- if (this.authService.token) {
1455
- this.authService.logout();
1456
- }
1457
- subscriber.next(true);
1458
- subscriber.complete();
1459
- });
1460
- }
1461
- canActivateChild(route, state) {
1462
- return this.canActivate(route, state);
1463
- }
1464
- }
1465
- LogoutGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: LogoutGuard, deps: [{ token: i1$1.Router }, { token: AuthService }], target: i0.ɵɵFactoryTarget.Injectable });
1466
- LogoutGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: LogoutGuard });
1467
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: LogoutGuard, decorators: [{
1468
- type: Injectable
1469
- }], ctorParameters: function () { return [{ type: i1$1.Router }, { type: AuthService }]; } });
1470
-
1471
- /**
1472
- * Comparison operator enum
1473
- */
1474
- var ComparisonOperatorEnum;
1475
- (function (ComparisonOperatorEnum) {
1476
- ComparisonOperatorEnum["EQ"] = "EQ";
1477
- ComparisonOperatorEnum["GT"] = "GT";
1478
- ComparisonOperatorEnum["GTE"] = "GTE";
1479
- ComparisonOperatorEnum["IN"] = "IN";
1480
- ComparisonOperatorEnum["LT"] = "LT";
1481
- ComparisonOperatorEnum["LTE"] = "LTE";
1482
- ComparisonOperatorEnum["NE"] = "NE";
1483
- ComparisonOperatorEnum["NIN"] = "NIN";
1484
- ComparisonOperatorEnum["REGEX"] = "REGEX";
1485
- })(ComparisonOperatorEnum || (ComparisonOperatorEnum = {}));
1486
-
1487
- /**
1488
- * GraphQL request type enum
1489
- */
1490
- var GraphQLRequestType;
1491
- (function (GraphQLRequestType) {
1492
- GraphQLRequestType["QUERY"] = "query";
1493
- GraphQLRequestType["MUTATION"] = "mutation";
1494
- GraphQLRequestType["SUBSCRIPTION"] = "subscription";
1495
- })(GraphQLRequestType || (GraphQLRequestType = {}));
1496
-
1497
- /**
1498
- * Logical operator enum
1499
- */
1500
- var LogicalOperatorEnum;
1501
- (function (LogicalOperatorEnum) {
1502
- LogicalOperatorEnum["AND"] = "AND";
1503
- LogicalOperatorEnum["NOR"] = "NOR";
1504
- LogicalOperatorEnum["OR"] = "OR";
1505
- })(LogicalOperatorEnum || (LogicalOperatorEnum = {}));
1506
-
1507
- var SortOrderEnum;
1508
- (function (SortOrderEnum) {
1509
- SortOrderEnum["ASC"] = "ASC";
1510
- SortOrderEnum["DESC"] = "DESC";
1511
- })(SortOrderEnum || (SortOrderEnum = {}));
1512
-
1513
- /**
1514
- * Fullscreen service
1515
- */
1516
- class FullscreenService {
1517
- constructor() {
1518
- this._isFullscreenActive = new BehaviorSubject(false);
1519
- this.listenToFullscreenEvent();
1520
- }
1521
- get fullscreenState() {
1522
- return this._isFullscreenActive.value;
1523
- }
1524
- get fullscreenStateAsObservable() {
1525
- return this._isFullscreenActive.asObservable();
1526
- }
1527
- toggleFullscreen() {
1528
- const elem = document.documentElement;
1529
- if (!this._isFullscreenActive.value) {
1530
- elem.requestFullscreen();
1531
- this._isFullscreenActive.next(true);
1532
- }
1533
- else {
1534
- document.exitFullscreen();
1535
- this._isFullscreenActive.next(false);
1536
- }
1537
- }
1538
- /**
1539
- * Event Listener for fullscreen toggle
1540
- */
1541
- listenToFullscreenEvent() {
1542
- document.addEventListener('fullscreenchange', () => {
1543
- if (document.fullscreenElement) {
1544
- this._isFullscreenActive.next(true);
1545
- }
1546
- else {
1547
- this._isFullscreenActive.next(false);
1548
- }
1549
- });
1550
- }
1551
- }
1552
- FullscreenService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: FullscreenService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1553
- FullscreenService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: FullscreenService, providedIn: 'root' });
1554
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: FullscreenService, decorators: [{
1555
- type: Injectable,
1556
- args: [{
1557
- providedIn: 'root',
1558
- }]
1559
- }], ctorParameters: function () { return []; } });
1560
-
1561
- /**
1562
- * GraphQL meta service
1563
- *
1564
- * For collecting meta information of the GraphQL API
1565
- */
1566
- class GraphQLMetaService {
1567
- /**
1568
- * Include services
1569
- */
1570
- constructor(apollo) {
1571
- this.apollo = apollo;
1572
- }
1573
- /**
1574
- * Getter of introspectionQuery
1575
- */
1576
- get introspectionQuery() {
1577
- return JSON.parse(JSON.stringify(this._introspectionQuery));
1578
- }
1579
- /**
1580
- * Get schema for API
1581
- * See https://www.apollographql.com/blog/three-ways-to-represent-your-graphql-schema-a41f4175100d
1582
- */
1583
- getSchema(options = {}) {
1584
- // Get configurations
1585
- const config = Object.assign({ cache: true, freeze: true }, options);
1586
- // Use caching
1587
- if (config.cache) {
1588
- if (config.freeze && this._frozenSchema) {
1589
- return of(this._frozenSchema);
1590
- }
1591
- if (this._introspectionQuery) {
1592
- return of(buildClientSchema(this.introspectionQuery));
1593
- }
1594
- if (config.freeze && this._frozenSchemaObservable) {
1595
- return this._frozenSchemaObservable;
1596
- }
1597
- else if (!config.freeze && this._schemaObservable) {
1598
- return this._schemaObservable;
1599
- }
1600
- }
1601
- // Request schema from server
1602
- const observable = this.apollo
1603
- .query({
1604
- query: gql(getIntrospectionQuery({ descriptions: false })),
1605
- })
1606
- .pipe(map((schema) => {
1607
- // Cache introspectionQuery
1608
- this._introspectionQuery = schema.data;
1609
- // Convert schema to GraphQLSchema
1610
- this._frozenSchema = Helper.deepFreeze(buildClientSchema(this.introspectionQuery));
1611
- // Return GraphQLSchema
1612
- if (config.freeze) {
1613
- return this._frozenSchema;
1614
- }
1615
- return buildClientSchema(schema.data);
1616
- }));
1617
- // Set observables
1618
- if (config.freeze) {
1619
- this._frozenSchemaObservable = observable;
1620
- }
1621
- else {
1622
- this._schemaObservable = observable;
1623
- }
1624
- // Return result
1625
- return observable;
1626
- }
1627
- /**
1628
- * Get meta for API
1629
- * See https://www.apollographql.com/blog/three-ways-to-represent-your-graphql-schema-a41f4175100d
1630
- */
1631
- getMeta(options = {}) {
1632
- // Get configurations
1633
- const config = Object.assign({ cache: true, log: false }, options);
1634
- // Use caching
1635
- if (config.cache) {
1636
- if (this._meta) {
1637
- return of(this._meta);
1638
- }
1639
- else if (this._metaObservable) {
1640
- return this._metaObservable;
1641
- }
1642
- }
1643
- // Request schema from server
1644
- const observable = this.getSchema(options).pipe(map((schema) => {
1645
- // Log
1646
- if (config.log) {
1647
- console.log({ schema });
1648
- }
1649
- this._meta = new GraphQLMeta(schema);
1650
- return this._meta;
1651
- }));
1652
- // Set observables
1653
- this._metaObservable = observable;
1654
- // Return result
1655
- return observable;
1656
- }
1657
- }
1658
- GraphQLMetaService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: GraphQLMetaService, deps: [{ token: i1$2.Apollo }], target: i0.ɵɵFactoryTarget.Injectable });
1659
- GraphQLMetaService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: GraphQLMetaService, providedIn: 'root' });
1660
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: GraphQLMetaService, decorators: [{
1661
- type: Injectable,
1662
- args: [{
1663
- providedIn: 'root',
1664
- }]
1665
- }], ctorParameters: function () { return [{ type: i1$2.Apollo }]; } });
1666
-
1667
- /**
1668
- * GraphQL service
1669
- */
1670
- class GraphQLService {
1671
- /**
1672
- * Include services
1673
- */
1674
- constructor(apollo, graphQLMetaService) {
1675
- this.apollo = apollo;
1676
- this.graphQLMetaService = graphQLMetaService;
1677
- }
1678
- /**
1679
- * GraphQL request
1680
- */
1681
- graphQl(graphql, options = {}) {
1682
- // Check arguments
1683
- if (!graphql) {
1684
- throwError('Missing graphql argument');
1685
- }
1686
- // Get config
1687
- const config = Object.assign({ arguments: null, fields: null, log: false, model: null, type: GraphQLRequestType.QUERY }, options);
1688
- // Convert class to Object for arguments
1689
- if (typeof config.arguments === 'function') {
1690
- config.arguments = new config.arguments();
1691
- }
1692
- // Convert class to Object for fields
1693
- if (typeof config.fields === 'function') {
1694
- config.fields = new config.fields();
1695
- }
1696
- // Log
1697
- if (config.log) {
1698
- console.log({ config });
1699
- }
1700
- // Send request
1701
- return new Observable((subscriber) => {
1702
- // Get meta
1703
- this.graphQLMetaService.getMeta({ log: config.log }).subscribe((meta) => {
1704
- // Prepare fields
1705
- let fields;
1706
- let allowedFields;
1707
- // Log meta
1708
- if (config.log) {
1709
- console.log({ meta });
1710
- }
1711
- if (config.fields) {
1712
- allowedFields = meta.getFields(graphql, { type: config.type });
1713
- // Log meta
1714
- if (config.log) {
1715
- console.log({ allowedFields });
1716
- }
1717
- const fieldsData = this.prepareFields(config.fields, {
1718
- allowed: allowedFields,
1719
- });
1720
- // Log fields data
1721
- if (config.log) {
1722
- fieldsData.usedFields.sort();
1723
- fieldsData.schemaFields.sort();
1724
- const filtered = fieldsData.schemaFields.filter((field) => !fieldsData.usedFields.includes(field));
1725
- const unused = this.graphQLTypeCollectionToStringArray(allowedFields).filter((field) => !fieldsData.usedFields.includes(field));
1726
- console.log({ fieldsData, filtered, unused });
1727
- }
1728
- fields = fieldsData.fieldsString;
1729
- }
1730
- if (fields && !fields.startsWith('{')) {
1731
- fields = '{' + fields + '\n}';
1732
- }
1733
- // Log fields
1734
- if (config.log) {
1735
- console.log({ fields });
1736
- }
1737
- // Get allowed args
1738
- const allowedArgs = meta.getArgs(graphql, { type: config.type });
1739
- // Log allowed args
1740
- if (config.log) {
1741
- console.log({ allowedArgs });
1742
- }
1743
- const argsData = this.prepareArguments(config.arguments, {
1744
- allowed: allowedArgs,
1745
- });
1746
- // Log args data
1747
- if (config.log) {
1748
- argsData.usedArgs.sort();
1749
- argsData.schemaArgs.sort();
1750
- const filtered = argsData.schemaArgs.filter((field) => !argsData.usedArgs.includes(field));
1751
- const unused = this.graphQLTypeCollectionToStringArray(allowedArgs)
1752
- .sort()
1753
- .filter((field) => !argsData.usedArgs.includes(field));
1754
- console.log({ argsData, filtered, unused });
1755
- }
1756
- const args = (argsData === null || argsData === void 0 ? void 0 : argsData.argsString) || '';
1757
- // Log
1758
- if (config.log) {
1759
- console.log({ graphQL: graphql, args, fields, type: config.type });
1760
- }
1761
- // Prepare request
1762
- const documentNode = fields
1763
- ? gql(config.type + '{\n' + graphql + args + fields + '\n}')
1764
- : gql(config.type + '{\n' + graphql + args + '\n}');
1765
- // Log
1766
- if (config.log) {
1767
- console.log({ documentNode });
1768
- }
1769
- const request = {};
1770
- request[config.type] = documentNode;
1771
- // Log
1772
- if (config.log) {
1773
- console.log({ request });
1774
- }
1775
- let func;
1776
- if (config.type === GraphQLRequestType.MUTATION) {
1777
- func = 'mutate';
1778
- request[config.type] = documentNode;
1779
- }
1780
- else if (config.type === GraphQLRequestType.SUBSCRIPTION) {
1781
- func = 'subscribe';
1782
- request.query = documentNode;
1783
- }
1784
- else {
1785
- func = config.type;
1786
- request[config.type] = documentNode;
1787
- }
1788
- this.apollo[func](request).subscribe((result) => {
1789
- var _a;
1790
- const data = ((_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a[graphql]) !== undefined ? result.data[graphql] : result;
1791
- // Direct data
1792
- if (!config.model) {
1793
- subscriber.next(data);
1794
- }
1795
- // Map data as array
1796
- else if (Array.isArray(data)) {
1797
- subscriber.next(data.map((item) => {
1798
- return config.model.map(item);
1799
- }));
1800
- }
1801
- // Map data
1802
- else {
1803
- subscriber.next(config.model.map(data));
1804
- }
1805
- if (config.type !== GraphQLRequestType.SUBSCRIPTION) {
1806
- // Done
1807
- subscriber.complete();
1808
- }
1809
- }, (error) => {
1810
- subscriber.error(error);
1811
- subscriber.complete();
1812
- });
1813
- });
1814
- });
1815
- }
1816
- /**
1817
- * Get fields / args from IGraphQLTypeCollection
1818
- */
1819
- graphQLTypeCollectionToStringArray(collection, current = '', result = [], cacheNode = []) {
1820
- if (collection) {
1821
- if (collection instanceof GraphQLType) {
1822
- result.push(current);
1823
- }
1824
- else {
1825
- if (current === null || current === void 0 ? void 0 : current.includes('.')) {
1826
- cacheNode.push(current.split('.')[1]);
1827
- }
1828
- else if (current) {
1829
- cacheNode.push(current);
1830
- }
1831
- for (const key of Object.keys(collection)) {
1832
- if (current === key || cacheNode.includes(key)) {
1833
- continue;
1834
- }
1835
- this.graphQLTypeCollectionToStringArray(collection[key], current ? current + '.' + key : key, result, cacheNode);
1836
- }
1837
- }
1838
- }
1839
- return result;
1840
- }
1841
- /**
1842
- * Prepare arguments for GraphQL request
1843
- */
1844
- prepareArguments(args, options = {}) {
1845
- // Init config variables
1846
- const { allowed, level, parent, schemaArgs, usedArgs } = Object.assign({ allowed: null, level: 1, parent: '', schemaArgs: [], usedArgs: [] }, options);
1847
- // Check args
1848
- if (args === undefined || args === null) {
1849
- return { argsString: '', schemaArgs, usedArgs };
1850
- }
1851
- // Init args
1852
- const result = [];
1853
- // Process array
1854
- if (Array.isArray(args)) {
1855
- const allowedKeys = allowed ? Object.keys(allowed) : null;
1856
- for (const item of args) {
1857
- let key = null;
1858
- if (allowed) {
1859
- if (allowed.length < 1) {
1860
- break;
1861
- }
1862
- key = allowedKeys === null || allowedKeys === void 0 ? void 0 : allowedKeys.shift();
1863
- }
1864
- // Process value
1865
- result.push(this.prepareArguments(item, {
1866
- allowed: key ? allowed[key] : null,
1867
- level: level + 1,
1868
- parent: parent + key + '.',
1869
- schemaArgs,
1870
- usedArgs,
1871
- }).argsString);
1872
- }
1873
- // Encapsulation of the array result
1874
- if (result.length) {
1875
- // Complete result, encapsulated via round brackets
1876
- if (level === 1) {
1877
- return { argsString: '(' + result.join(', ') + ')', schemaArgs, usedArgs };
1878
- }
1879
- // Deeper result part, encapsulated via square brackets
1880
- else {
1881
- return { argsString: '[' + result.join(', ') + ']', schemaArgs, usedArgs };
1882
- }
1883
- }
1884
- }
1885
- // Process object
1886
- else if (typeof args === 'object') {
1887
- // Check object is empty
1888
- if (args && Object.keys(args).length === 0 && Object.getPrototypeOf(args) === Object.prototype) {
1889
- return { argsString: '{}', schemaArgs, usedArgs };
1890
- }
1891
- // Process all object entries
1892
- for (const [key, value] of Object.entries(args)) {
1893
- // Init data for current entry
1894
- const currentKey = parent + key;
1895
- schemaArgs.push(currentKey);
1896
- // If the allowed key handling is enabled and the current key is not included in the list of allowed keys,
1897
- // the current key will be skipped
1898
- if (allowed && !allowed[key]) {
1899
- continue;
1900
- }
1901
- // Skip value if not exists
1902
- if (value === undefined || value === null) {
1903
- continue;
1904
- }
1905
- // Add current key to metadata
1906
- usedArgs.push(currentKey);
1907
- // Process GraphQLEnum
1908
- if (value instanceof GraphQLEnum) {
1909
- result.push(key + ':' + value.value);
1910
- continue;
1911
- }
1912
- // Process array
1913
- else if (Array.isArray(value)) {
1914
- result.push(key +
1915
- ': [' +
1916
- value.map((item) => this.prepareArguments(item, {
1917
- allowed: allowed[key],
1918
- level: level + 1,
1919
- parent: currentKey + '.',
1920
- schemaArgs,
1921
- usedArgs,
1922
- }).argsString) +
1923
- ']');
1924
- continue;
1925
- }
1926
- // Prepare additional result string
1927
- let additionalResult = key + ': ';
1928
- // Value is a date object
1929
- if (typeof value === 'object' && Object.prototype.toString.call(value) === '[object Date]') {
1930
- additionalResult += `"""${value.toString()}"""`;
1931
- }
1932
- // Value is a string
1933
- else if (typeof value === 'string') {
1934
- // Enum (doesn't need quotation marks)
1935
- if (allowed[key].isEnum) {
1936
- additionalResult += value;
1937
- }
1938
- // String
1939
- else {
1940
- additionalResult += `"""${value.replace(/"/g, '\\"')}"""`;
1941
- }
1942
- }
1943
- // Value is a simple boolean or a number
1944
- else if (typeof value === 'boolean' || typeof value === 'number') {
1945
- additionalResult += value;
1946
- }
1947
- // Others
1948
- else {
1949
- additionalResult += this.prepareArguments(value, {
1950
- allowed: allowed[key],
1951
- level: level + 1,
1952
- parent: currentKey + '.',
1953
- schemaArgs,
1954
- usedArgs,
1955
- }).argsString;
1956
- }
1957
- // Push deeper part into result array
1958
- result.push(additionalResult);
1959
- }
1960
- // Encapsulation of the object result
1961
- if (result.length) {
1962
- // Complete result, encapsulated via round brackets
1963
- if (level === 1) {
1964
- return { argsString: '(' + result.join(', ') + ')', schemaArgs, usedArgs };
1965
- }
1966
- // Deeper result part, encapsulated via curly brackets
1967
- else {
1968
- return { argsString: '{' + result.join(', ') + '}', schemaArgs, usedArgs };
1969
- }
1970
- }
1971
- }
1972
- // Prepare and process other / unknown values as JSON
1973
- else {
1974
- return { argsString: JSON.stringify(args), schemaArgs, usedArgs };
1975
- }
1976
- }
1977
- /**
1978
- * Prepare fields for GraphQL request
1979
- */
1980
- prepareFields(fields, options = {}) {
1981
- // Config
1982
- const { allowed, parent, schemaFields, spaces, tab, usedFields } = Object.assign({ allowed: null, parent: '', schemaFields: [], spaces: 2, tab: 1, usedFields: [] }, options);
1983
- // Init fields string
1984
- let fieldsString = '';
1985
- // Check fields
1986
- if (!fields) {
1987
- return { fieldsString, schemaFields, usedFields };
1988
- }
1989
- // Process string
1990
- if (typeof fields === 'string') {
1991
- if (allowed &&
1992
- ((typeof allowed === 'string' && allowed !== fields) || (typeof allowed === 'object' && !allowed[fields]))) {
1993
- return { fieldsString, schemaFields, usedFields };
1994
- }
1995
- return { fieldsString: '\n' + ' '.repeat(spaces).repeat(tab) + fields, schemaFields, usedFields };
1996
- }
1997
- // Process array
1998
- else if (Array.isArray(fields)) {
1999
- for (const item of fields) {
2000
- if (typeof item === 'object') {
2001
- fieldsString =
2002
- fieldsString +
2003
- this.prepareFields(item, {
2004
- allowed,
2005
- parent,
2006
- spaces,
2007
- schemaFields,
2008
- tab: tab + 1,
2009
- usedFields,
2010
- }).fieldsString;
2011
- continue;
2012
- }
2013
- const currentPath = parent + item;
2014
- schemaFields.push(currentPath);
2015
- if (allowed && !(allowed === null || allowed === void 0 ? void 0 : allowed[item])) {
2016
- continue;
2017
- }
2018
- usedFields.push(currentPath);
2019
- fieldsString =
2020
- fieldsString +
2021
- this.prepareFields(item, {
2022
- allowed: typeof (allowed === null || allowed === void 0 ? void 0 : allowed[item]) === 'object' && !((allowed === null || allowed === void 0 ? void 0 : allowed[item]) instanceof GraphQLType) ? allowed === null || allowed === void 0 ? void 0 : allowed[item] : item,
2023
- parent: currentPath + '.',
2024
- spaces,
2025
- schemaFields,
2026
- tab: tab + 1,
2027
- usedFields,
2028
- }).fieldsString;
2029
- }
2030
- }
2031
- // Process object
2032
- else if (typeof fields === 'object') {
2033
- for (const [key, val] of Object.entries(fields)) {
2034
- const currentPath = parent + key;
2035
- schemaFields.push(currentPath);
2036
- if (allowed && !allowed[key]) {
2037
- continue;
2038
- }
2039
- usedFields.push(currentPath);
2040
- if (typeof val !== 'object' || !Object.keys(val).length) {
2041
- fieldsString = fieldsString + '\n' + ' '.repeat(spaces).repeat(tab) + key;
2042
- }
2043
- else {
2044
- fieldsString =
2045
- fieldsString +
2046
- '\n' +
2047
- ' '.repeat(spaces).repeat(tab) +
2048
- key +
2049
- ' ' +
2050
- '{' +
2051
- this.prepareFields(val, {
2052
- allowed: typeof (allowed === null || allowed === void 0 ? void 0 : allowed[key]) === 'object' && !((allowed === null || allowed === void 0 ? void 0 : allowed[key]) instanceof GraphQLType) ? allowed === null || allowed === void 0 ? void 0 : allowed[key] : key,
2053
- parent: currentPath + '.',
2054
- spaces,
2055
- schemaFields,
2056
- tab: tab + 1,
2057
- usedFields,
2058
- }).fieldsString +
2059
- '\n' +
2060
- ' '.repeat(spaces).repeat(tab) +
2061
- '}';
2062
- }
2063
- }
2064
- }
2065
- // Return result
2066
- return { fieldsString, schemaFields, usedFields };
2067
- }
2068
- }
2069
- GraphQLService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: GraphQLService, deps: [{ token: i1$2.Apollo }, { token: GraphQLMetaService }], target: i0.ɵɵFactoryTarget.Injectable });
2070
- GraphQLService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: GraphQLService, providedIn: 'root' });
2071
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: GraphQLService, decorators: [{
2072
- type: Injectable,
2073
- args: [{
2074
- providedIn: 'root',
2075
- }]
2076
- }], ctorParameters: function () { return [{ type: i1$2.Apollo }, { type: GraphQLMetaService }]; } });
2077
-
2078
- /**
2079
- * Loader service for loading indication
2080
- */
2081
- class LoaderService {
2082
- constructor() {
2083
- this.isLoading = new BehaviorSubject(false);
2084
- }
2085
- start() {
2086
- this.isLoading.next(true);
2087
- }
2088
- stop() {
2089
- this.isLoading.next(false);
2090
- }
2091
- getAsObservable() {
2092
- return this.isLoading.asObservable();
2093
- }
2094
- }
2095
- LoaderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: LoaderService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2096
- LoaderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: LoaderService, providedIn: 'root' });
2097
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: LoaderService, decorators: [{
2098
- type: Injectable,
2099
- args: [{
2100
- providedIn: 'root',
2101
- }]
2102
- }] });
2103
-
2104
- /**
2105
- * GraphQL plus service, for extra error handling and loading indication
2106
- */
2107
- class GraphQLPlusService extends GraphQLService {
2108
- /**
2109
- * Include services
2110
- */
2111
- constructor(apollo, graphqlMetaService, loaderService) {
2112
- super(apollo, graphqlMetaService);
2113
- this.apollo = apollo;
2114
- this.graphqlMetaService = graphqlMetaService;
2115
- this.loaderService = loaderService;
2116
- }
2117
- graphQl(graphql, options = {}) {
2118
- this.handleLoader('start', options);
2119
- return new Observable((subscriber) => {
2120
- super.graphQl(graphql, options).subscribe((response) => {
2121
- if (response && response.errors) {
2122
- this.handleError(response.errors, options.excludedErrors);
2123
- subscriber.error(response);
2124
- this.handleLoader('stop', options);
2125
- subscriber.complete();
2126
- }
2127
- subscriber.next(response);
2128
- this.handleLoader('stop', options);
2129
- if (options.type !== GraphQLRequestType.SUBSCRIPTION) {
2130
- subscriber.complete();
2131
- }
2132
- }, (error) => {
2133
- if (!options.ignoreErrors) {
2134
- this.handleError(error, options.excludedErrors);
2135
- }
2136
- subscriber.error(error);
2137
- this.handleLoader('stop', options);
2138
- subscriber.complete();
2139
- });
2140
- });
2141
- }
2142
- handleLoader(state, options) {
2143
- if (options.loading) {
2144
- if (state === 'start') {
2145
- this.loaderService.start();
2146
- }
2147
- else if (state === 'stop') {
2148
- this.loaderService.stop();
2149
- }
2150
- }
2151
- }
2152
- handleError(error, excludedErrors = null) {
2153
- if (excludedErrors) {
2154
- if (Array.isArray(excludedErrors)) {
2155
- excludedErrors.forEach((excludedError) => {
2156
- if (error.message.includes(excludedError.toLowerCase())) {
2157
- return;
2158
- }
2159
- });
2160
- }
2161
- else if (error.message.toLowerCase().includes(excludedErrors === null || excludedErrors === void 0 ? void 0 : excludedErrors.toLowerCase())) {
2162
- return;
2163
- }
2164
- }
2165
- this.displayError(error);
2166
- }
2167
- displayError(error) {
2168
- console.error(error);
2169
- }
2170
- }
2171
- GraphQLPlusService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: GraphQLPlusService, deps: [{ token: i1$2.Apollo }, { token: GraphQLMetaService }, { token: LoaderService }], target: i0.ɵɵFactoryTarget.Injectable });
2172
- GraphQLPlusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: GraphQLPlusService, providedIn: 'root' });
2173
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: GraphQLPlusService, decorators: [{
2174
- type: Injectable,
2175
- args: [{
2176
- providedIn: 'root',
2177
- }]
2178
- }], ctorParameters: function () { return [{ type: i1$2.Apollo }, { type: GraphQLMetaService }, { type: LoaderService }]; } });
2179
-
2180
- /**
2181
- * Scroll service for autoscroll to specific fragments
2182
- */
2183
- class ScrollService {
2184
- /**
2185
- * Initializer
2186
- */
2187
- constructor(router, moduleConfig, imageService) {
2188
- this.router = router;
2189
- this.moduleConfig = moduleConfig;
2190
- this.imageService = imageService;
2191
- /**
2192
- * Is a scroll listener set
2193
- *
2194
- * @protected
2195
- */
2196
- this.scrollListener = false;
2197
- /**
2198
- * Current scroll timer;
2199
- *
2200
- * @protected
2201
- */
2202
- this.scrollTimer = -1;
2203
- const config = Object.assign({ scrollDetectionOffset: 200, scrollOffset: 100, scrollSamplingRate: 100 }, moduleConfig);
2204
- this.detectionOffset = config.scrollDetectionOffset;
2205
- this.scrollOffset = config.scrollOffset;
2206
- this.scrollSamplingRate = config.scrollSamplingRate;
2207
- }
2208
- /**
2209
- * Scroll to structureElement with specific ID
2210
- */
2211
- scrollTo(id, options = {}) {
2212
- return __awaiter(this, void 0, void 0, function* () {
2213
- // Prepare config
2214
- const config = Object.assign({ checkUrl: false, loadImagesBefore: true, resetStyles: false, setOverflow: true, stopPropagation: true }, options);
2215
- // Check current URL
2216
- if (config.checkUrl && this.router.url !== '/' && !this.router.url.startsWith('/#')) {
2217
- yield this.router.navigate(['/'], { fragment: id });
2218
- return !config.stopPropagation;
2219
- }
2220
- // Check if target element exits
2221
- const el = document.getElementById(id);
2222
- if (!el) {
2223
- console.error('Missing scroll element with ID:', id);
2224
- return !config.stopPropagation;
2225
- }
2226
- // Check if body overflow is visible
2227
- // This is necessary for scroll handling
2228
- const body = document.querySelector('body');
2229
- let undoOverflowChanges = false;
2230
- const scrollBodyStyles = JSON.parse(JSON.stringify(window.getComputedStyle(body)));
2231
- if (config.setOverflow && (scrollBodyStyles.overflowX !== 'visible' || scrollBodyStyles.overflowY !== 'visible')) {
2232
- // Set body overflow to visible
2233
- console.warn('Style of body element for overflowX and overflowY will be set to "visible" for scrolling!');
2234
- body.style.overflowX = 'visible';
2235
- body.style.overflowY = 'visible';
2236
- undoOverflowChanges = true;
2237
- }
2238
- // Load images before scrolling (once)
2239
- if (config.loadImagesBefore) {
2240
- yield this.imageService.preLoadImages();
2241
- }
2242
- // Get get bounding rect of target element
2243
- const cords = el.getBoundingClientRect();
2244
- // Scroll to element
2245
- window.scrollBy({ top: cords.top - this.scrollOffset, behavior: 'smooth' });
2246
- yield this.scrollDone({
2247
- doneFunction: () => {
2248
- // Undo changes
2249
- if (undoOverflowChanges && config.resetStyles) {
2250
- body.style.overflowX = scrollBodyStyles.overflowX;
2251
- body.style.overflowY = scrollBodyStyles.overflowY;
2252
- console.warn('Original style of body element for overflowX and overflowY is set.');
2253
- }
2254
- },
2255
- });
2256
- // Return stop propagation configuration
2257
- return !config.stopPropagation;
2258
- });
2259
- }
2260
- /**
2261
- * Get last active structureElement
2262
- */
2263
- getLastActiveElement(list) {
2264
- const currentScrollPosition = window.scrollY;
2265
- const elementsWithId = document.querySelectorAll('[id]');
2266
- let lastId = null;
2267
- let lastPosition = 0 - this.detectionOffset - 1;
2268
- elementsWithId.forEach((element) => {
2269
- const cords = element.getBoundingClientRect();
2270
- const top = cords.top + window.pageYOffset - this.detectionOffset;
2271
- if ((!list || !list.length || list.includes(element.id)) && // In list
2272
- top < currentScrollPosition && // In active area
2273
- lastPosition < top // Higher than the last one
2274
- ) {
2275
- lastId = element.id;
2276
- lastPosition = top;
2277
- }
2278
- });
2279
- return lastId;
2280
- }
2281
- /**
2282
- * Check if ID is active
2283
- */
2284
- isActive(id, list, isFirst) {
2285
- const lastActiveElement = this.getLastActiveElement(list);
2286
- return id === lastActiveElement || (lastActiveElement === null && isFirst);
2287
- }
2288
- /**
2289
- * Scroll done promise
2290
- */
2291
- scrollDone(options = {}) {
2292
- return __awaiter(this, void 0, void 0, function* () {
2293
- // Init configuration
2294
- const config = Object.assign({ doneFunction: undefined }, options);
2295
- // Wait for scroll done
2296
- yield this.scrollDoneDetection();
2297
- // Get result
2298
- if (config.doneFunction) {
2299
- return config.doneFunction();
2300
- }
2301
- });
2302
- }
2303
- /**
2304
- * Scroll done detecton
2305
- *
2306
- * @protected
2307
- */
2308
- scrollDoneDetection() {
2309
- // Return current scroll promise (Singelton)
2310
- if (this.scrollPromise) {
2311
- return this.scrollPromise;
2312
- }
2313
- // Create current scroll promise
2314
- this.scrollPromise = new Promise((resolve) => {
2315
- this.scrollPromiseResolve = resolve;
2316
- if (this.scrollTimer !== -1) {
2317
- window.clearTimeout(this.scrollTimer);
2318
- }
2319
- this.scrollTimer = window.setTimeout(() => {
2320
- window.removeEventListener('scroll', this.scrollDoneDetection.bind(this));
2321
- this.scrollPromise = undefined;
2322
- resolve();
2323
- }, this.scrollSamplingRate);
2324
- });
2325
- // Lisitening to scroll event;
2326
- window.addEventListener('scroll', this.scrollDoneDetection.bind(this));
2327
- // Return promise
2328
- return this.scrollPromise;
2329
- }
2330
- }
2331
- ScrollService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: ScrollService, deps: [{ token: i1$1.Router }, { token: BASE_MODULE_CONFIG }, { token: ImageService }], target: i0.ɵɵFactoryTarget.Injectable });
2332
- ScrollService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: ScrollService, providedIn: 'root' });
2333
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: ScrollService, decorators: [{
2334
- type: Injectable,
2335
- args: [{
2336
- providedIn: 'root',
2337
- }]
2338
- }], ctorParameters: function () {
2339
- return [{ type: i1$1.Router }, { type: undefined, decorators: [{
2340
- type: Inject,
2341
- args: [BASE_MODULE_CONFIG]
2342
- }] }, { type: ImageService }];
2343
- } });
2344
-
2345
- /**
2346
- * SEO service for setting HTML meta data
2347
- */
2348
- class SEOService {
2349
- constructor(titleService, metaTagService) {
2350
- this.titleService = titleService;
2351
- this.metaTagService = metaTagService;
2352
- }
2353
- initPageForSEO(input) {
2354
- this.setGeneralData(input);
2355
- this.setTwitterData(input);
2356
- this.setTwitterData(input);
2357
- this.setFacebookData(input);
2358
- if (input.keywords) {
2359
- this.setPageKeywords(input.keywords);
2360
- }
2361
- }
2362
- /**
2363
- * Set general metadata
2364
- *
2365
- * @param data
2366
- * @private
2367
- */
2368
- setGeneralData(data) {
2369
- this.titleService.setTitle(data.title);
2370
- this.metaTagService.updateTag({ name: 'description', content: data.description });
2371
- }
2372
- /**
2373
- * Set metadata for twitter
2374
- *
2375
- * @param data
2376
- * @private
2377
- */
2378
- setTwitterData(data) {
2379
- this.metaTagService.updateTag({ name: 'twitter:title', content: data.title });
2380
- this.metaTagService.updateTag({ name: 'twitter:description', content: data.description });
2381
- this.metaTagService.updateTag({
2382
- property: 'twitter:url',
2383
- content: data.url ? data.url : window.location.href,
2384
- });
2385
- if (data.image) {
2386
- this.metaTagService.updateTag({
2387
- property: 'twitter:image',
2388
- content: data.image,
2389
- });
2390
- this.metaTagService.updateTag({
2391
- property: 'twitter:card',
2392
- content: 'summary_large_image',
2393
- });
2394
- }
2395
- }
2396
- /**
2397
- * Set metadata for facebook
2398
- *
2399
- * @param data
2400
- * @private
2401
- */
2402
- setFacebookData(data) {
2403
- this.metaTagService.updateTag({ property: 'og:title', content: data.title });
2404
- this.metaTagService.updateTag({ property: 'og:description', content: data.description });
2405
- this.metaTagService.updateTag({
2406
- property: 'og:type',
2407
- content: 'website',
2408
- });
2409
- this.metaTagService.updateTag({
2410
- property: 'og:url',
2411
- content: data.url ? data.url : window.location.href,
2412
- });
2413
- if (data.image) {
2414
- this.metaTagService.updateTag({
2415
- property: 'og:image',
2416
- content: data.image,
2417
- });
2418
- }
2419
- }
2420
- /**
2421
- * Set page keywords
2422
- *
2423
- * @param keywords
2424
- * @private
2425
- */
2426
- setPageKeywords(keywords) {
2427
- this.metaTagService.updateTag({ name: 'keywords', content: keywords });
2428
- }
2429
- }
2430
- SEOService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: SEOService, deps: [{ token: i1.Title }, { token: i1.Meta }], target: i0.ɵɵFactoryTarget.Injectable });
2431
- SEOService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: SEOService, providedIn: 'root' });
2432
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: SEOService, decorators: [{
2433
- type: Injectable,
2434
- args: [{
2435
- providedIn: 'root',
2436
- }]
2437
- }], ctorParameters: function () { return [{ type: i1.Title }, { type: i1.Meta }]; } });
2438
-
2439
- /**
2440
- * Custom validator to check that two fields match
2441
- * (inspirated by https://jasonwatmore.com/post/2018/11/07/angular-7-reactive-forms-validation-example)
2442
- */
2443
- function MustMatch(controlName, matchingControlName) {
2444
- return (formGroup) => {
2445
- const control = formGroup.controls[controlName];
2446
- const matchingControl = formGroup.controls[matchingControlName];
2447
- if (matchingControl.errors && !matchingControl.errors.mustMatch) {
2448
- // return if another validator has already found an error on the matchingControl
2449
- return;
2450
- }
2451
- // set error on matchingControl if validation fails
2452
- if (control.value !== matchingControl.value) {
2453
- matchingControl.setErrors({ mustMatch: true });
2454
- }
2455
- else {
2456
- matchingControl.setErrors(null);
2457
- }
2458
- };
2459
- }
2460
-
2461
- /**
2462
- * Exports for public API
2463
- */
2464
-
2465
- /**
2466
- * Generated bundle index. Do not edit.
2467
- */
2468
-
2469
- export { AuthGuard, AuthService, BASE_MODULE_CONFIG, BaseModule, BasicUser, CanDeactivateGuard, ComparisonOperatorEnum, ContextMenuDirective, EllipsesPipe, FullscreenService, GraphQLEnum, GraphQLMeta, GraphQLMetaService, GraphQLPlusService, GraphQLRequestType, GraphQLService, GraphQLType, Helper, ImageService, LazyLoadDirective, LoaderService, LogicalOperatorEnum, LogoutGuard, MatchHeightDirective, MustMatch, ResizableDirective, SEOService, SafeHtmlPipe, ScrollService, SortOrderEnum, Standard, StorageService, WsService, apolloOptionsFactory };
2470
- //# sourceMappingURL=lenne.tech-ng-base-src-lib-base.mjs.map