@smartbit4all/ng-client 1.0.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 (202) hide show
  1. package/README.md +386 -0
  2. package/esm2020/lib/session/api/api/api.mjs +4 -0
  3. package/esm2020/lib/session/api/api/session.service.mjs +306 -0
  4. package/esm2020/lib/session/api/configuration.mjs +91 -0
  5. package/esm2020/lib/session/api/encoder.mjs +19 -0
  6. package/esm2020/lib/session/api/index.mjs +3 -0
  7. package/esm2020/lib/session/api/model/accountInfo.mjs +13 -0
  8. package/esm2020/lib/session/api/model/apiError.mjs +13 -0
  9. package/esm2020/lib/session/api/model/authenticationProviderData.mjs +13 -0
  10. package/esm2020/lib/session/api/model/getAuthenticationProvidersResponse.mjs +2 -0
  11. package/esm2020/lib/session/api/model/models.mjs +9 -0
  12. package/esm2020/lib/session/api/model/refreshSessionRequest.mjs +13 -0
  13. package/esm2020/lib/session/api/model/session.mjs +2 -0
  14. package/esm2020/lib/session/api/model/sessionInfoData.mjs +2 -0
  15. package/esm2020/lib/session/api/model/userActivityLog.mjs +13 -0
  16. package/esm2020/lib/session/api/param.mjs +2 -0
  17. package/esm2020/lib/session/api/variables.mjs +9 -0
  18. package/esm2020/lib/session/cookie-service/smart-cookie.service.mjs +225 -0
  19. package/esm2020/lib/session/dev-tool/smart-dev-tool-dialog/smart-dev-tool-dialog.component.mjs +90 -0
  20. package/esm2020/lib/session/dev-tool/smart-dev-tool-dialog/smart-dev-tool-dialog.service.mjs +43 -0
  21. package/esm2020/lib/session/dev-tool/smart-dev-tool-floating-button/smart-dev-tool-floating-button.component.mjs +40 -0
  22. package/esm2020/lib/session/dev-tool/smart-dev-tool.interceptor.mjs +52 -0
  23. package/esm2020/lib/session/dev-tool/smart-dev-tool.service.mjs +161 -0
  24. package/esm2020/lib/session/projects.mjs +12 -0
  25. package/esm2020/lib/session/smart-error-catching.interceptor.mjs +71 -0
  26. package/esm2020/lib/session/smart-header-maintainer.interceptor.mjs +36 -0
  27. package/esm2020/lib/session/smart-session-handler.service.mjs +6 -0
  28. package/esm2020/lib/session/smart-session.module.mjs +74 -0
  29. package/esm2020/lib/session/smart-session.service.mjs +204 -0
  30. package/esm2020/lib/session/smart-timer/smart-session-timer.component.mjs +35 -0
  31. package/esm2020/lib/session/smart-timer/smart-session-timer.service.mjs +51 -0
  32. package/esm2020/lib/smart-ng-client.module.mjs +20 -0
  33. package/esm2020/lib/smart-ng-client.service.mjs +19 -0
  34. package/esm2020/lib/view-context/api/api/api.mjs +4 -0
  35. package/esm2020/lib/view-context/api/api/view.service.mjs +401 -0
  36. package/esm2020/lib/view-context/api/api.module.mjs +40 -0
  37. package/esm2020/lib/view-context/api/configuration.mjs +91 -0
  38. package/esm2020/lib/view-context/api/encoder.mjs +19 -0
  39. package/esm2020/lib/view-context/api/index.mjs +7 -0
  40. package/esm2020/lib/view-context/api/model/closeResult.mjs +17 -0
  41. package/esm2020/lib/view-context/api/model/componentConstraint.mjs +2 -0
  42. package/esm2020/lib/view-context/api/model/messageData.mjs +2 -0
  43. package/esm2020/lib/view-context/api/model/messageOption.mjs +2 -0
  44. package/esm2020/lib/view-context/api/model/messageOptionType.mjs +17 -0
  45. package/esm2020/lib/view-context/api/model/messageResult.mjs +2 -0
  46. package/esm2020/lib/view-context/api/model/messageType.mjs +18 -0
  47. package/esm2020/lib/view-context/api/model/models.mjs +29 -0
  48. package/esm2020/lib/view-context/api/model/openPendingData.mjs +2 -0
  49. package/esm2020/lib/view-context/api/model/smartLinkData.mjs +2 -0
  50. package/esm2020/lib/view-context/api/model/uiAction.mjs +2 -0
  51. package/esm2020/lib/view-context/api/model/uiActionButtonDescriptor.mjs +13 -0
  52. package/esm2020/lib/view-context/api/model/uiActionButtonIconPos.mjs +16 -0
  53. package/esm2020/lib/view-context/api/model/uiActionButtonType.mjs +21 -0
  54. package/esm2020/lib/view-context/api/model/uiActionDescriptor.mjs +2 -0
  55. package/esm2020/lib/view-context/api/model/uiActionDialogDescriptor.mjs +2 -0
  56. package/esm2020/lib/view-context/api/model/uiActionFeedbackType.mjs +16 -0
  57. package/esm2020/lib/view-context/api/model/uiActionInputType.mjs +18 -0
  58. package/esm2020/lib/view-context/api/model/uiActionRequest.mjs +13 -0
  59. package/esm2020/lib/view-context/api/model/view.mjs +2 -0
  60. package/esm2020/lib/view-context/api/model/viewApiError.mjs +13 -0
  61. package/esm2020/lib/view-context/api/model/viewConstraint.mjs +2 -0
  62. package/esm2020/lib/view-context/api/model/viewContext.mjs +2 -0
  63. package/esm2020/lib/view-context/api/model/viewContextData.mjs +2 -0
  64. package/esm2020/lib/view-context/api/model/viewContextUpdate.mjs +2 -0
  65. package/esm2020/lib/view-context/api/model/viewData.mjs +2 -0
  66. package/esm2020/lib/view-context/api/model/viewState.mjs +21 -0
  67. package/esm2020/lib/view-context/api/model/viewStateUpdate.mjs +2 -0
  68. package/esm2020/lib/view-context/api/model/viewType.mjs +17 -0
  69. package/esm2020/lib/view-context/api/param.mjs +2 -0
  70. package/esm2020/lib/view-context/api/variables.mjs +9 -0
  71. package/esm2020/lib/view-context/message-dialog/message-dialog.component.mjs +63 -0
  72. package/esm2020/lib/view-context/projects.mjs +17 -0
  73. package/esm2020/lib/view-context/smart-ui-action/components/success-snack-bar/success-snack-bar.component.mjs +30 -0
  74. package/esm2020/lib/view-context/smart-ui-action/dialogs/ui-action-confirm-dialog/ui-action-confirm-dialog.component.mjs +53 -0
  75. package/esm2020/lib/view-context/smart-ui-action/dialogs/ui-action-confirm-dialog/ui-action-confirm-dialog.service.mjs +47 -0
  76. package/esm2020/lib/view-context/smart-ui-action/dialogs/ui-action-input-dialog/ui-action-input-dialog.component.mjs +112 -0
  77. package/esm2020/lib/view-context/smart-ui-action/dialogs/ui-action-input-dialog/ui-action-input-dialog.service.mjs +51 -0
  78. package/esm2020/lib/view-context/smart-ui-action/ui-action-toolbar.component.mjs +81 -0
  79. package/esm2020/lib/view-context/smart-ui-action/ui-action.descriptor.service.mjs +113 -0
  80. package/esm2020/lib/view-context/smart-ui-action/ui-action.model.mjs +7 -0
  81. package/esm2020/lib/view-context/smart-ui-action/ui-action.service.mjs +149 -0
  82. package/esm2020/lib/view-context/smart-view-context-error-dialog/smart-view-context-error-dialog.component.mjs +24 -0
  83. package/esm2020/lib/view-context/smart-view-context-error-dialog/smart-view-context-error-dialog.service.mjs +44 -0
  84. package/esm2020/lib/view-context/smart-view-context.interceptor.mjs +28 -0
  85. package/esm2020/lib/view-context/smart-view-context.model.mjs +2 -0
  86. package/esm2020/lib/view-context/smart-view-context.module.mjs +84 -0
  87. package/esm2020/lib/view-context/smart-view-context.service.mjs +310 -0
  88. package/esm2020/lib/view-context/smart-view-redirect/smart-view-redirect.mjs +33 -0
  89. package/esm2020/lib/view-context/value-api/api.module.mjs +40 -0
  90. package/esm2020/lib/view-context/value-api/configuration.mjs +91 -0
  91. package/esm2020/lib/view-context/value-api/index.mjs +6 -0
  92. package/esm2020/lib/view-context/value-api/model/models.mjs +2 -0
  93. package/esm2020/lib/view-context/value-api/model/valueSetData.mjs +13 -0
  94. package/esm2020/lib/view-context/value-api/param.mjs +2 -0
  95. package/esm2020/lib/view-context/value-api/variables.mjs +9 -0
  96. package/esm2020/projects.mjs +8 -0
  97. package/esm2020/smartbit4all-ng-client.mjs +5 -0
  98. package/fesm2015/smartbit4all-ng-client.mjs +3418 -0
  99. package/fesm2015/smartbit4all-ng-client.mjs.map +1 -0
  100. package/fesm2020/smartbit4all-ng-client.mjs +3423 -0
  101. package/fesm2020/smartbit4all-ng-client.mjs.map +1 -0
  102. package/lib/session/api/api/api.d.ts +3 -0
  103. package/lib/session/api/api/session.service.d.ts +107 -0
  104. package/lib/session/api/configuration.d.ts +104 -0
  105. package/lib/session/api/encoder.d.ts +11 -0
  106. package/lib/session/api/index.d.ts +2 -0
  107. package/lib/session/api/model/accountInfo.d.ts +22 -0
  108. package/lib/session/api/model/apiError.d.ts +15 -0
  109. package/lib/session/api/model/authenticationProviderData.d.ts +17 -0
  110. package/lib/session/api/model/getAuthenticationProvidersResponse.d.ts +15 -0
  111. package/lib/session/api/model/models.d.ts +8 -0
  112. package/lib/session/api/model/refreshSessionRequest.d.ts +14 -0
  113. package/lib/session/api/model/session.d.ts +32 -0
  114. package/lib/session/api/model/sessionInfoData.d.ts +22 -0
  115. package/lib/session/api/model/userActivityLog.d.ts +33 -0
  116. package/lib/session/api/param.d.ts +37 -0
  117. package/lib/session/api/variables.d.ts +8 -0
  118. package/lib/session/cookie-service/smart-cookie.service.d.ts +129 -0
  119. package/lib/session/dev-tool/smart-dev-tool-dialog/smart-dev-tool-dialog.component.d.ts +28 -0
  120. package/lib/session/dev-tool/smart-dev-tool-dialog/smart-dev-tool-dialog.service.d.ts +18 -0
  121. package/lib/session/dev-tool/smart-dev-tool-floating-button/smart-dev-tool-floating-button.component.d.ts +15 -0
  122. package/lib/session/dev-tool/smart-dev-tool.interceptor.d.ts +18 -0
  123. package/lib/session/dev-tool/smart-dev-tool.service.d.ts +55 -0
  124. package/lib/session/projects.d.ts +8 -0
  125. package/lib/session/smart-error-catching.interceptor.d.ts +13 -0
  126. package/lib/session/smart-header-maintainer.interceptor.d.ts +11 -0
  127. package/lib/session/smart-session-handler.service.d.ts +11 -0
  128. package/lib/session/smart-session.module.d.ts +15 -0
  129. package/lib/session/smart-session.service.d.ts +50 -0
  130. package/lib/session/smart-timer/smart-session-timer.component.d.ts +14 -0
  131. package/lib/session/smart-timer/smart-session-timer.service.d.ts +21 -0
  132. package/lib/smart-ng-client.module.d.ts +8 -0
  133. package/lib/smart-ng-client.service.d.ts +10 -0
  134. package/lib/view-context/api/api/api.d.ts +3 -0
  135. package/lib/view-context/api/api/view.service.d.ts +147 -0
  136. package/lib/view-context/api/api.module.d.ts +11 -0
  137. package/lib/view-context/api/configuration.d.ts +104 -0
  138. package/lib/view-context/api/encoder.d.ts +11 -0
  139. package/lib/view-context/api/index.d.ts +6 -0
  140. package/lib/view-context/api/model/closeResult.d.ts +17 -0
  141. package/lib/view-context/api/model/componentConstraint.d.ts +25 -0
  142. package/lib/view-context/api/model/messageData.d.ts +27 -0
  143. package/lib/view-context/api/model/messageOption.d.ts +18 -0
  144. package/lib/view-context/api/model/messageOptionType.d.ts +17 -0
  145. package/lib/view-context/api/model/messageResult.d.ts +16 -0
  146. package/lib/view-context/api/model/messageType.d.ts +18 -0
  147. package/lib/view-context/api/model/models.d.ts +28 -0
  148. package/lib/view-context/api/model/openPendingData.d.ts +22 -0
  149. package/lib/view-context/api/model/smartLinkData.d.ts +21 -0
  150. package/lib/view-context/api/model/uiAction.d.ts +26 -0
  151. package/lib/view-context/api/model/uiActionButtonDescriptor.d.ts +18 -0
  152. package/lib/view-context/api/model/uiActionButtonIconPos.d.ts +19 -0
  153. package/lib/view-context/api/model/uiActionButtonType.d.ts +24 -0
  154. package/lib/view-context/api/model/uiActionDescriptor.d.ts +32 -0
  155. package/lib/view-context/api/model/uiActionDialogDescriptor.d.ts +22 -0
  156. package/lib/view-context/api/model/uiActionFeedbackType.d.ts +19 -0
  157. package/lib/view-context/api/model/uiActionInputType.d.ts +18 -0
  158. package/lib/view-context/api/model/uiActionRequest.d.ts +27 -0
  159. package/lib/view-context/api/model/view.d.ts +36 -0
  160. package/lib/view-context/api/model/viewApiError.d.ts +18 -0
  161. package/lib/view-context/api/model/viewConstraint.d.ts +18 -0
  162. package/lib/view-context/api/model/viewContext.d.ts +22 -0
  163. package/lib/view-context/api/model/viewContextData.d.ts +19 -0
  164. package/lib/view-context/api/model/viewContextUpdate.d.ts +22 -0
  165. package/lib/view-context/api/model/viewData.d.ts +25 -0
  166. package/lib/view-context/api/model/viewState.d.ts +21 -0
  167. package/lib/view-context/api/model/viewStateUpdate.d.ts +22 -0
  168. package/lib/view-context/api/model/viewType.d.ts +17 -0
  169. package/lib/view-context/api/param.d.ts +37 -0
  170. package/lib/view-context/api/variables.d.ts +8 -0
  171. package/lib/view-context/message-dialog/message-dialog.component.d.ts +17 -0
  172. package/lib/view-context/projects.d.ts +13 -0
  173. package/lib/view-context/smart-ui-action/components/success-snack-bar/success-snack-bar.component.d.ts +13 -0
  174. package/lib/view-context/smart-ui-action/dialogs/ui-action-confirm-dialog/ui-action-confirm-dialog.component.d.ts +25 -0
  175. package/lib/view-context/smart-ui-action/dialogs/ui-action-confirm-dialog/ui-action-confirm-dialog.service.d.ts +18 -0
  176. package/lib/view-context/smart-ui-action/dialogs/ui-action-input-dialog/ui-action-input-dialog.component.d.ts +28 -0
  177. package/lib/view-context/smart-ui-action/dialogs/ui-action-input-dialog/ui-action-input-dialog.service.d.ts +25 -0
  178. package/lib/view-context/smart-ui-action/ui-action-toolbar.component.d.ts +24 -0
  179. package/lib/view-context/smart-ui-action/ui-action.descriptor.service.d.ts +21 -0
  180. package/lib/view-context/smart-ui-action/ui-action.model.d.ts +30 -0
  181. package/lib/view-context/smart-ui-action/ui-action.service.d.ts +21 -0
  182. package/lib/view-context/smart-view-context-error-dialog/smart-view-context-error-dialog.component.d.ts +13 -0
  183. package/lib/view-context/smart-view-context-error-dialog/smart-view-context-error-dialog.service.d.ts +17 -0
  184. package/lib/view-context/smart-view-context.interceptor.d.ts +13 -0
  185. package/lib/view-context/smart-view-context.model.d.ts +30 -0
  186. package/lib/view-context/smart-view-context.module.d.ts +20 -0
  187. package/lib/view-context/smart-view-context.service.d.ts +60 -0
  188. package/lib/view-context/smart-view-redirect/smart-view-redirect.d.ts +14 -0
  189. package/lib/view-context/value-api/api.module.d.ts +11 -0
  190. package/lib/view-context/value-api/configuration.d.ts +104 -0
  191. package/lib/view-context/value-api/index.d.ts +5 -0
  192. package/lib/view-context/value-api/model/models.d.ts +1 -0
  193. package/lib/view-context/value-api/model/valueSetData.d.ts +39 -0
  194. package/lib/view-context/value-api/param.d.ts +37 -0
  195. package/lib/view-context/value-api/variables.d.ts +8 -0
  196. package/package.json +38 -0
  197. package/projects.d.ts +4 -0
  198. package/smartbit4all-ng-client-1.0.0.tgz +0 -0
  199. package/smartbit4all-ng-client.d.ts +5 -0
  200. package/src/lib/session/api/README.md +226 -0
  201. package/src/lib/view-context/api/README.md +226 -0
  202. package/src/lib/view-context/value-api/README.md +226 -0
@@ -0,0 +1,3423 @@
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, Injectable, Optional, Inject, PLATFORM_ID, NgModule, SkipSelf, Component, Pipe, CUSTOM_ELEMENTS_SCHEMA, ViewChild, Input } from '@angular/core';
3
+ import { Subject, takeUntil, map, catchError, throwError, from } from 'rxjs';
4
+ import * as i1 from '@angular/common/http';
5
+ import { HttpHeaders, HttpContext, HttpEventType, HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
6
+ import * as i5 from '@angular/common';
7
+ import { isPlatformBrowser, DOCUMENT, DatePipe, CommonModule } from '@angular/common';
8
+ import * as i2 from '@angular/material/button';
9
+ import { MatButtonModule } from '@angular/material/button';
10
+ import * as i3 from '@angular/material/icon';
11
+ import { MatIconModule } from '@angular/material/icon';
12
+ import * as i3$1 from '@smartbit4all/navigation';
13
+ import * as i4 from '@smartbit4all/dialog';
14
+ import { SmartdialogService, SmartdialogModule } from '@smartbit4all/dialog';
15
+ import { MatCommonModule } from '@angular/material/core';
16
+ import * as i4$2 from '@angular/material/expansion';
17
+ import { MatExpansionModule } from '@angular/material/expansion';
18
+ import { BrowserModule } from '@angular/platform-browser';
19
+ import * as i4$1 from '@smartbit4all/icon';
20
+ import { SmartIconModule } from '@smartbit4all/icon';
21
+ import * as i1$1 from '@angular/material/dialog';
22
+ import * as i2$1 from '@angular/router';
23
+ import { catchError as catchError$1, switchMap } from 'rxjs/operators';
24
+ import * as i3$2 from '@angular/material/snack-bar';
25
+ import { MAT_SNACK_BAR_DATA, MatSnackBarModule } from '@angular/material/snack-bar';
26
+ import { Validators } from '@angular/forms';
27
+ import * as i5$1 from '@smartbit4all/form';
28
+ import { SmartFormWidgetType, SmartFormWidgetDirection, SmartValidatorName, SmartformModule } from '@smartbit4all/form';
29
+
30
+ /**
31
+ * Custom HttpParameterCodec
32
+ * Workaround for https://github.com/angular/angular/issues/18261
33
+ */
34
+ class CustomHttpParameterCodec$1 {
35
+ encodeKey(k) {
36
+ return encodeURIComponent(k);
37
+ }
38
+ encodeValue(v) {
39
+ return encodeURIComponent(v);
40
+ }
41
+ decodeKey(k) {
42
+ return decodeURIComponent(k);
43
+ }
44
+ decodeValue(v) {
45
+ return decodeURIComponent(v);
46
+ }
47
+ }
48
+
49
+ const BASE_PATH$1 = new InjectionToken('basePath');
50
+ const COLLECTION_FORMATS$1 = {
51
+ 'csv': ',',
52
+ 'tsv': ' ',
53
+ 'ssv': ' ',
54
+ 'pipes': '|'
55
+ };
56
+
57
+ class Configuration$1 {
58
+ constructor(configurationParameters = {}) {
59
+ this.apiKeys = configurationParameters.apiKeys;
60
+ this.username = configurationParameters.username;
61
+ this.password = configurationParameters.password;
62
+ this.accessToken = configurationParameters.accessToken;
63
+ this.basePath = configurationParameters.basePath;
64
+ this.withCredentials = configurationParameters.withCredentials;
65
+ this.encoder = configurationParameters.encoder;
66
+ if (configurationParameters.encodeParam) {
67
+ this.encodeParam = configurationParameters.encodeParam;
68
+ }
69
+ else {
70
+ this.encodeParam = param => this.defaultEncodeParam(param);
71
+ }
72
+ if (configurationParameters.credentials) {
73
+ this.credentials = configurationParameters.credentials;
74
+ }
75
+ else {
76
+ this.credentials = {};
77
+ }
78
+ }
79
+ /**
80
+ * Select the correct content-type to use for a request.
81
+ * Uses {@link Configuration#isJsonMime} to determine the correct content-type.
82
+ * If no content type is found return the first found type if the contentTypes is not empty
83
+ * @param contentTypes - the array of content types that are available for selection
84
+ * @returns the selected content-type or <code>undefined</code> if no selection could be made.
85
+ */
86
+ selectHeaderContentType(contentTypes) {
87
+ if (contentTypes.length === 0) {
88
+ return undefined;
89
+ }
90
+ const type = contentTypes.find((x) => this.isJsonMime(x));
91
+ if (type === undefined) {
92
+ return contentTypes[0];
93
+ }
94
+ return type;
95
+ }
96
+ /**
97
+ * Select the correct accept content-type to use for a request.
98
+ * Uses {@link Configuration#isJsonMime} to determine the correct accept content-type.
99
+ * If no content type is found return the first found type if the contentTypes is not empty
100
+ * @param accepts - the array of content types that are available for selection.
101
+ * @returns the selected content-type or <code>undefined</code> if no selection could be made.
102
+ */
103
+ selectHeaderAccept(accepts) {
104
+ if (accepts.length === 0) {
105
+ return undefined;
106
+ }
107
+ const type = accepts.find((x) => this.isJsonMime(x));
108
+ if (type === undefined) {
109
+ return accepts[0];
110
+ }
111
+ return type;
112
+ }
113
+ /**
114
+ * Check if the given MIME is a JSON MIME.
115
+ * JSON MIME examples:
116
+ * application/json
117
+ * application/json; charset=UTF8
118
+ * APPLICATION/JSON
119
+ * application/vnd.company+json
120
+ * @param mime - MIME (Multipurpose Internet Mail Extensions)
121
+ * @return True if the given MIME is JSON, false otherwise.
122
+ */
123
+ isJsonMime(mime) {
124
+ const jsonMime = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
125
+ return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
126
+ }
127
+ lookupCredential(key) {
128
+ const value = this.credentials[key];
129
+ return typeof value === 'function'
130
+ ? value()
131
+ : value;
132
+ }
133
+ defaultEncodeParam(param) {
134
+ // This implementation exists as fallback for missing configuration
135
+ // and for backwards compatibility to older typescript-angular generator versions.
136
+ // It only works for the 'simple' parameter style.
137
+ // Date-handling only works for the 'date-time' format.
138
+ // All other styles and Date-formats are probably handled incorrectly.
139
+ //
140
+ // But: if that's all you need (i.e.: the most common use-case): no need for customization!
141
+ const value = param.dataFormat === 'date-time'
142
+ ? param.value.toISOString()
143
+ : param.value;
144
+ return encodeURIComponent(String(value));
145
+ }
146
+ }
147
+
148
+ /**
149
+ * Session api
150
+ * Session api...
151
+ *
152
+ * The version of the OpenAPI document: 1.0.0
153
+ * Contact: info@it4all.hu
154
+ *
155
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
156
+ * https://openapi-generator.tech
157
+ * Do not edit the class manually.
158
+ */
159
+ class SessionService {
160
+ constructor(httpClient, basePath, configuration) {
161
+ this.httpClient = httpClient;
162
+ this.basePath = 'http://localhost';
163
+ this.defaultHeaders = new HttpHeaders();
164
+ this.configuration = new Configuration$1();
165
+ if (configuration) {
166
+ this.configuration = configuration;
167
+ }
168
+ if (typeof this.configuration.basePath !== 'string') {
169
+ if (Array.isArray(basePath) && basePath.length > 0) {
170
+ basePath = basePath[0];
171
+ }
172
+ if (typeof basePath !== 'string') {
173
+ basePath = this.basePath;
174
+ }
175
+ this.configuration.basePath = basePath;
176
+ }
177
+ this.encoder = this.configuration.encoder || new CustomHttpParameterCodec$1();
178
+ }
179
+ // @ts-ignore
180
+ addToHttpParams(httpParams, value, key) {
181
+ if (typeof value === "object" && value instanceof Date === false) {
182
+ httpParams = this.addToHttpParamsRecursive(httpParams, value);
183
+ }
184
+ else {
185
+ httpParams = this.addToHttpParamsRecursive(httpParams, value, key);
186
+ }
187
+ return httpParams;
188
+ }
189
+ addToHttpParamsRecursive(httpParams, value, key) {
190
+ if (value == null) {
191
+ return httpParams;
192
+ }
193
+ if (typeof value === "object") {
194
+ if (Array.isArray(value)) {
195
+ value.forEach(elem => httpParams = this.addToHttpParamsRecursive(httpParams, elem, key));
196
+ }
197
+ else if (value instanceof Date) {
198
+ if (key != null) {
199
+ httpParams = httpParams.append(key, value.toISOString().substr(0, 10));
200
+ }
201
+ else {
202
+ throw Error("key may not be null if value is Date");
203
+ }
204
+ }
205
+ else {
206
+ Object.keys(value).forEach(k => httpParams = this.addToHttpParamsRecursive(httpParams, value[k], key != null ? `${key}.${k}` : k));
207
+ }
208
+ }
209
+ else if (key != null) {
210
+ httpParams = httpParams.append(key, value);
211
+ }
212
+ else {
213
+ throw Error("key may not be null if value is not object or array");
214
+ }
215
+ return httpParams;
216
+ }
217
+ getAuthenticationProviders(observe = 'body', reportProgress = false, options) {
218
+ let localVarHeaders = this.defaultHeaders;
219
+ let localVarHttpHeaderAcceptSelected = options && options.httpHeaderAccept;
220
+ if (localVarHttpHeaderAcceptSelected === undefined) {
221
+ // to determine the Accept header
222
+ const httpHeaderAccepts = [
223
+ 'application/json'
224
+ ];
225
+ localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
226
+ }
227
+ if (localVarHttpHeaderAcceptSelected !== undefined) {
228
+ localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
229
+ }
230
+ let localVarHttpContext = options && options.context;
231
+ if (localVarHttpContext === undefined) {
232
+ localVarHttpContext = new HttpContext();
233
+ }
234
+ let responseType_ = 'json';
235
+ if (localVarHttpHeaderAcceptSelected) {
236
+ if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
237
+ responseType_ = 'text';
238
+ }
239
+ else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
240
+ responseType_ = 'json';
241
+ }
242
+ else {
243
+ responseType_ = 'blob';
244
+ }
245
+ }
246
+ let localVarPath = `/authenticationProviders`;
247
+ return this.httpClient.request('get', `${this.configuration.basePath}${localVarPath}`, {
248
+ context: localVarHttpContext,
249
+ responseType: responseType_,
250
+ withCredentials: this.configuration.withCredentials,
251
+ headers: localVarHeaders,
252
+ observe: observe,
253
+ reportProgress: reportProgress
254
+ });
255
+ }
256
+ getSession(observe = 'body', reportProgress = false, options) {
257
+ let localVarHeaders = this.defaultHeaders;
258
+ let localVarHttpHeaderAcceptSelected = options && options.httpHeaderAccept;
259
+ if (localVarHttpHeaderAcceptSelected === undefined) {
260
+ // to determine the Accept header
261
+ const httpHeaderAccepts = [
262
+ 'application/json'
263
+ ];
264
+ localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
265
+ }
266
+ if (localVarHttpHeaderAcceptSelected !== undefined) {
267
+ localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
268
+ }
269
+ let localVarHttpContext = options && options.context;
270
+ if (localVarHttpContext === undefined) {
271
+ localVarHttpContext = new HttpContext();
272
+ }
273
+ let responseType_ = 'json';
274
+ if (localVarHttpHeaderAcceptSelected) {
275
+ if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
276
+ responseType_ = 'text';
277
+ }
278
+ else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
279
+ responseType_ = 'json';
280
+ }
281
+ else {
282
+ responseType_ = 'blob';
283
+ }
284
+ }
285
+ let localVarPath = `/session`;
286
+ return this.httpClient.request('get', `${this.configuration.basePath}${localVarPath}`, {
287
+ context: localVarHttpContext,
288
+ responseType: responseType_,
289
+ withCredentials: this.configuration.withCredentials,
290
+ headers: localVarHeaders,
291
+ observe: observe,
292
+ reportProgress: reportProgress
293
+ });
294
+ }
295
+ refreshSession(refreshSessionRequest, observe = 'body', reportProgress = false, options) {
296
+ if (refreshSessionRequest === null || refreshSessionRequest === undefined) {
297
+ throw new Error('Required parameter refreshSessionRequest was null or undefined when calling refreshSession.');
298
+ }
299
+ let localVarHeaders = this.defaultHeaders;
300
+ let localVarHttpHeaderAcceptSelected = options && options.httpHeaderAccept;
301
+ if (localVarHttpHeaderAcceptSelected === undefined) {
302
+ // to determine the Accept header
303
+ const httpHeaderAccepts = [
304
+ 'application/json'
305
+ ];
306
+ localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
307
+ }
308
+ if (localVarHttpHeaderAcceptSelected !== undefined) {
309
+ localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
310
+ }
311
+ let localVarHttpContext = options && options.context;
312
+ if (localVarHttpContext === undefined) {
313
+ localVarHttpContext = new HttpContext();
314
+ }
315
+ // to determine the Content-Type header
316
+ const consumes = [
317
+ 'application/json'
318
+ ];
319
+ const httpContentTypeSelected = this.configuration.selectHeaderContentType(consumes);
320
+ if (httpContentTypeSelected !== undefined) {
321
+ localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected);
322
+ }
323
+ let responseType_ = 'json';
324
+ if (localVarHttpHeaderAcceptSelected) {
325
+ if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
326
+ responseType_ = 'text';
327
+ }
328
+ else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
329
+ responseType_ = 'json';
330
+ }
331
+ else {
332
+ responseType_ = 'blob';
333
+ }
334
+ }
335
+ let localVarPath = `/refresh`;
336
+ return this.httpClient.request('post', `${this.configuration.basePath}${localVarPath}`, {
337
+ context: localVarHttpContext,
338
+ body: refreshSessionRequest,
339
+ responseType: responseType_,
340
+ withCredentials: this.configuration.withCredentials,
341
+ headers: localVarHeaders,
342
+ observe: observe,
343
+ reportProgress: reportProgress
344
+ });
345
+ }
346
+ setLocale(locale, observe = 'body', reportProgress = false, options) {
347
+ if (locale === null || locale === undefined) {
348
+ throw new Error('Required parameter locale was null or undefined when calling setLocale.');
349
+ }
350
+ let localVarHeaders = this.defaultHeaders;
351
+ let localVarHttpHeaderAcceptSelected = options && options.httpHeaderAccept;
352
+ if (localVarHttpHeaderAcceptSelected === undefined) {
353
+ // to determine the Accept header
354
+ const httpHeaderAccepts = [
355
+ 'application/json'
356
+ ];
357
+ localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
358
+ }
359
+ if (localVarHttpHeaderAcceptSelected !== undefined) {
360
+ localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
361
+ }
362
+ let localVarHttpContext = options && options.context;
363
+ if (localVarHttpContext === undefined) {
364
+ localVarHttpContext = new HttpContext();
365
+ }
366
+ let responseType_ = 'json';
367
+ if (localVarHttpHeaderAcceptSelected) {
368
+ if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
369
+ responseType_ = 'text';
370
+ }
371
+ else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
372
+ responseType_ = 'json';
373
+ }
374
+ else {
375
+ responseType_ = 'blob';
376
+ }
377
+ }
378
+ let localVarPath = `/locale/${this.configuration.encodeParam({ name: "locale", value: locale, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined })}`;
379
+ return this.httpClient.request('post', `${this.configuration.basePath}${localVarPath}`, {
380
+ context: localVarHttpContext,
381
+ responseType: responseType_,
382
+ withCredentials: this.configuration.withCredentials,
383
+ headers: localVarHeaders,
384
+ observe: observe,
385
+ reportProgress: reportProgress
386
+ });
387
+ }
388
+ startSession(observe = 'body', reportProgress = false, options) {
389
+ let localVarHeaders = this.defaultHeaders;
390
+ let localVarHttpHeaderAcceptSelected = options && options.httpHeaderAccept;
391
+ if (localVarHttpHeaderAcceptSelected === undefined) {
392
+ // to determine the Accept header
393
+ const httpHeaderAccepts = [
394
+ 'application/json'
395
+ ];
396
+ localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
397
+ }
398
+ if (localVarHttpHeaderAcceptSelected !== undefined) {
399
+ localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
400
+ }
401
+ let localVarHttpContext = options && options.context;
402
+ if (localVarHttpContext === undefined) {
403
+ localVarHttpContext = new HttpContext();
404
+ }
405
+ let responseType_ = 'json';
406
+ if (localVarHttpHeaderAcceptSelected) {
407
+ if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
408
+ responseType_ = 'text';
409
+ }
410
+ else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
411
+ responseType_ = 'json';
412
+ }
413
+ else {
414
+ responseType_ = 'blob';
415
+ }
416
+ }
417
+ let localVarPath = `/session`;
418
+ return this.httpClient.request('put', `${this.configuration.basePath}${localVarPath}`, {
419
+ context: localVarHttpContext,
420
+ responseType: responseType_,
421
+ withCredentials: this.configuration.withCredentials,
422
+ headers: localVarHeaders,
423
+ observe: observe,
424
+ reportProgress: reportProgress
425
+ });
426
+ }
427
+ }
428
+ SessionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SessionService, deps: [{ token: i1.HttpClient }, { token: BASE_PATH$1, optional: true }, { token: Configuration$1, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
429
+ SessionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SessionService, providedIn: 'root' });
430
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SessionService, decorators: [{
431
+ type: Injectable,
432
+ args: [{
433
+ providedIn: 'root'
434
+ }]
435
+ }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: undefined, decorators: [{
436
+ type: Optional
437
+ }, {
438
+ type: Inject,
439
+ args: [BASE_PATH$1]
440
+ }] }, { type: Configuration$1, decorators: [{
441
+ type: Optional
442
+ }] }]; } });
443
+
444
+ const SessionAPIS = [SessionService];
445
+
446
+ /**
447
+ * Session api
448
+ * Session api...
449
+ *
450
+ * The version of the OpenAPI document: 1.0.0
451
+ * Contact: info@it4all.hu
452
+ *
453
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
454
+ * https://openapi-generator.tech
455
+ * Do not edit the class manually.
456
+ */
457
+
458
+ /**
459
+ * Session api
460
+ * Session api...
461
+ *
462
+ * The version of the OpenAPI document: 1.0.0
463
+ * Contact: info@it4all.hu
464
+ *
465
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
466
+ * https://openapi-generator.tech
467
+ * Do not edit the class manually.
468
+ */
469
+
470
+ /**
471
+ * Session api
472
+ * Session api...
473
+ *
474
+ * The version of the OpenAPI document: 1.0.0
475
+ * Contact: info@it4all.hu
476
+ *
477
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
478
+ * https://openapi-generator.tech
479
+ * Do not edit the class manually.
480
+ */
481
+
482
+ /**
483
+ * Session api
484
+ * Session api...
485
+ *
486
+ * The version of the OpenAPI document: 1.0.0
487
+ * Contact: info@it4all.hu
488
+ *
489
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
490
+ * https://openapi-generator.tech
491
+ * Do not edit the class manually.
492
+ */
493
+
494
+ /**
495
+ * Session api
496
+ * Session api...
497
+ *
498
+ * The version of the OpenAPI document: 1.0.0
499
+ * Contact: info@it4all.hu
500
+ *
501
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
502
+ * https://openapi-generator.tech
503
+ * Do not edit the class manually.
504
+ */
505
+
506
+ // This service is based on the `ng2-cookies` package which sadly is not a service and does
507
+ class SmartCookieService {
508
+ constructor(document,
509
+ // Get the `PLATFORM_ID` so we can check if we're in a browser.
510
+ platformId) {
511
+ this.document = document;
512
+ this.platformId = platformId;
513
+ this.documentIsAccessible = isPlatformBrowser(this.platformId);
514
+ }
515
+ /**
516
+ * Get cookie Regular Expression
517
+ *
518
+ * @param name Cookie name
519
+ * @returns property RegExp
520
+ *
521
+ * @author: Stepan Suvorov
522
+ * @since: 1.0.0
523
+ */
524
+ static getCookieRegExp(name) {
525
+ const escapedName = name.replace(/([\[\]\{\}\(\)\|\=\;\+\?\,\.\*\^\$])/gi, "\\$1");
526
+ return new RegExp("(?:^" + escapedName + "|;\\s*" + escapedName + ")=(.*?)(?:;|$)", "g");
527
+ }
528
+ /**
529
+ * Gets the unencoded version of an encoded component of a Uniform Resource Identifier (URI).
530
+ *
531
+ * @param encodedURIComponent A value representing an encoded URI component.
532
+ *
533
+ * @returns The unencoded version of an encoded component of a Uniform Resource Identifier (URI).
534
+ *
535
+ * @author: Stepan Suvorov
536
+ * @since: 1.0.0
537
+ */
538
+ static safeDecodeURIComponent(encodedURIComponent) {
539
+ try {
540
+ return decodeURIComponent(encodedURIComponent);
541
+ }
542
+ catch {
543
+ // probably it is not uri encoded. return as is
544
+ return encodedURIComponent;
545
+ }
546
+ }
547
+ /**
548
+ * Return `true` if {@link Document} is accessible, otherwise return `false`
549
+ *
550
+ * @param name Cookie name
551
+ * @returns boolean - whether cookie with specified name exists
552
+ *
553
+ * @author: Stepan Suvorov
554
+ * @since: 1.0.0
555
+ */
556
+ check(name) {
557
+ if (!this.documentIsAccessible) {
558
+ return false;
559
+ }
560
+ name = encodeURIComponent(name);
561
+ const regExp = SmartCookieService.getCookieRegExp(name);
562
+ return regExp.test(this.document.cookie);
563
+ }
564
+ /**
565
+ * Get cookies by name
566
+ *
567
+ * @param name Cookie name
568
+ * @returns property value
569
+ *
570
+ * @author: Stepan Suvorov
571
+ * @since: 1.0.0
572
+ */
573
+ get(name) {
574
+ if (this.documentIsAccessible && this.check(name)) {
575
+ name = encodeURIComponent(name);
576
+ const regExp = SmartCookieService.getCookieRegExp(name);
577
+ const result = regExp.exec(this.document.cookie);
578
+ let results = result.input.split(";");
579
+ let value;
580
+ results.forEach((r) => {
581
+ let values = r.split(`${name}=`);
582
+ if (values[1] !== "null") {
583
+ value = values[1];
584
+ }
585
+ });
586
+ return value ?? "";
587
+ }
588
+ else {
589
+ return "";
590
+ }
591
+ }
592
+ /**
593
+ * Get all cookies in JSON format
594
+ *
595
+ * @returns all the cookies in json
596
+ *
597
+ * @author: Stepan Suvorov
598
+ * @since: 1.0.0
599
+ */
600
+ getAll() {
601
+ if (!this.documentIsAccessible) {
602
+ return {};
603
+ }
604
+ const cookies = {};
605
+ const document = this.document;
606
+ if (document.cookie && document.cookie !== "") {
607
+ document.cookie.split(";").forEach((currentCookie) => {
608
+ const [cookieName, cookieValue] = currentCookie.split("=");
609
+ cookies[SmartCookieService.safeDecodeURIComponent(cookieName.replace(/^ /, ""))] =
610
+ SmartCookieService.safeDecodeURIComponent(cookieValue);
611
+ });
612
+ }
613
+ return cookies;
614
+ }
615
+ set(name, value, expiresOrOptions, path, domain, secure, sameSite) {
616
+ if (!this.documentIsAccessible) {
617
+ return;
618
+ }
619
+ if (typeof expiresOrOptions === "number" ||
620
+ expiresOrOptions instanceof Date ||
621
+ path ||
622
+ domain ||
623
+ secure ||
624
+ sameSite) {
625
+ const optionsBody = {
626
+ expires: expiresOrOptions,
627
+ path,
628
+ domain,
629
+ secure,
630
+ sameSite: sameSite ? sameSite : "Lax",
631
+ };
632
+ this.set(name, value, optionsBody);
633
+ return;
634
+ }
635
+ let cookieString = encodeURIComponent(name) + "=" + encodeURIComponent(value) + ";";
636
+ const options = expiresOrOptions ? expiresOrOptions : {};
637
+ if (options.expires) {
638
+ if (typeof options.expires === "number") {
639
+ const dateExpires = new Date(new Date().getTime() + options.expires * 1000 * 60 * 60 * 24);
640
+ cookieString += "expires=" + dateExpires.toUTCString() + ";";
641
+ }
642
+ else {
643
+ cookieString += "expires=" + options.expires.toUTCString() + ";";
644
+ }
645
+ }
646
+ if (options.path) {
647
+ cookieString += "path=" + options.path + ";";
648
+ }
649
+ else {
650
+ cookieString += "path=/;";
651
+ }
652
+ if (options.domain) {
653
+ cookieString += "domain=" + options.domain + ";";
654
+ }
655
+ if (options.secure === false && options.sameSite === "None") {
656
+ options.secure = true;
657
+ console.warn(`[ngx-cookie-service] Cookie ${name} was forced with secure flag because sameSite=None.` +
658
+ `More details : https://github.com/stevermeister/ngx-cookie-service/issues/86#issuecomment-597720130`);
659
+ }
660
+ if (options.secure) {
661
+ cookieString += "secure;";
662
+ }
663
+ if (!options.sameSite) {
664
+ options.sameSite = "Lax";
665
+ }
666
+ cookieString += "sameSite=" + options.sameSite + ";";
667
+ this.document.cookie = cookieString;
668
+ }
669
+ /**
670
+ * Delete cookie by name
671
+ *
672
+ * @param name Cookie name
673
+ * @param path Cookie path
674
+ * @param domain Cookie domain
675
+ * @param secure Cookie secure flag
676
+ * @param sameSite Cookie sameSite flag - https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite
677
+ *
678
+ * @author: Stepan Suvorov
679
+ * @since: 1.0.0
680
+ */
681
+ delete(name, path, domain, secure, sameSite = "Lax") {
682
+ if (!this.documentIsAccessible) {
683
+ return;
684
+ }
685
+ const expiresDate = new Date("Thu, 01 Jan 1970 00:00:01 GMT");
686
+ this.set(name, "", { expires: expiresDate, path, domain, secure, sameSite });
687
+ }
688
+ /**
689
+ * Delete all cookies
690
+ *
691
+ * @param path Cookie path
692
+ * @param domain Cookie domain
693
+ * @param secure Is the Cookie secure
694
+ * @param sameSite Is the cookie same site
695
+ *
696
+ * @author: Stepan Suvorov
697
+ * @since: 1.0.0
698
+ */
699
+ deleteAll(path, domain, secure, sameSite = "Lax") {
700
+ if (!this.documentIsAccessible) {
701
+ return;
702
+ }
703
+ const cookies = this.getAll();
704
+ for (const cookieName in cookies) {
705
+ if (cookies.hasOwnProperty(cookieName)) {
706
+ this.delete(cookieName, path, domain, secure, sameSite);
707
+ }
708
+ }
709
+ }
710
+ }
711
+ SmartCookieService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartCookieService, deps: [{ token: DOCUMENT }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable });
712
+ SmartCookieService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartCookieService, providedIn: "root" });
713
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartCookieService, decorators: [{
714
+ type: Injectable,
715
+ args: [{
716
+ providedIn: "root",
717
+ }]
718
+ }], ctorParameters: function () { return [{ type: Document, decorators: [{
719
+ type: Inject,
720
+ args: [DOCUMENT]
721
+ }] }, { type: undefined, decorators: [{
722
+ type: Inject,
723
+ args: [PLATFORM_ID]
724
+ }] }]; } });
725
+
726
+ class SmartSessionService {
727
+ constructor(apiService, cookieService) {
728
+ this.apiService = apiService;
729
+ this.cookieService = cookieService;
730
+ this.isAuthenticated = false;
731
+ this.authenticationStateChanged = new Subject();
732
+ this.headerParams = new Array();
733
+ this.headersUpdated = new Subject();
734
+ // Locale
735
+ this.localStorageLocaleName = "locale";
736
+ this.localeChanged = new Subject();
737
+ this.sessionExpiracyChanged = new Subject();
738
+ }
739
+ get sessionInfoData() {
740
+ return this._sessionInfoData;
741
+ }
742
+ set sessionInfoData(sessionInfoData) {
743
+ let expiracyChanged = this.sessionInfoData?.expiration !== sessionInfoData?.expiration;
744
+ this._sessionInfoData = sessionInfoData;
745
+ if (expiracyChanged) {
746
+ this.sessionExpiracyChanged.next();
747
+ }
748
+ }
749
+ setSessionHandlerService(smartSessionHandlerService) {
750
+ this.sessionHandlerService = smartSessionHandlerService;
751
+ }
752
+ async handleSessionError(sessionError) {
753
+ if (this.sessionHandlerService) {
754
+ await this.sessionHandlerService.handleSessionError(sessionError);
755
+ }
756
+ throw new Error(`sessionHandlerService was not initialized. Error: ${sessionError.code}`);
757
+ }
758
+ addHeaderParam(headerParam) {
759
+ this.headerParams.push(headerParam);
760
+ this.headersUpdated.next();
761
+ }
762
+ setUpTokenForSessionService() {
763
+ if (this.headerParams.find((header) => header.headerName === "Authorization")) {
764
+ let index = this.headerParams.findIndex((header) => header.headerName === "Authorization");
765
+ this.headerParams[index].value = `Bearer ${this.token}`;
766
+ }
767
+ else {
768
+ this.addHeaderParam({ headerName: "Authorization", value: `Bearer ${this.token}` });
769
+ }
770
+ }
771
+ setUrl(url) {
772
+ this.basePath = url;
773
+ }
774
+ getBasePath() {
775
+ if (!this.basePath) {
776
+ throw new Error("BasePath has not been set in SmartSessionService!");
777
+ }
778
+ return this.basePath;
779
+ }
780
+ setCookieName(name) {
781
+ this.cookieName = name;
782
+ }
783
+ saveTokenToLocalStorage() {
784
+ if (this.sessionInfoData && this.cookieName) {
785
+ localStorage.setItem("token", this.sessionInfoData.sid);
786
+ if (this.sessionInfoData.refreshToken &&
787
+ this.sessionInfoData.refreshToken !== localStorage.getItem("refreshToken")) {
788
+ localStorage.setItem("refreshToken", this.sessionInfoData.refreshToken);
789
+ }
790
+ this.cookieService.set(this.cookieName, this.token);
791
+ }
792
+ }
793
+ setAuthenticationStatus() {
794
+ if (this.sessionInfoData && this.sessionInfoData.authentications) {
795
+ this.isAuthenticated = this.sessionInfoData.authentications.length > 0;
796
+ }
797
+ this.authenticationStateChanged.next(this.isAuthenticated);
798
+ }
799
+ checkStatements() {
800
+ if (!this.basePath) {
801
+ throw new Error("The url of the backend api has not been set!");
802
+ }
803
+ else if (!this.cookieName) {
804
+ throw new Error("The name of the cookie required by the backend has not been set!");
805
+ }
806
+ }
807
+ async initialize() {
808
+ this.checkStatements();
809
+ let tokenFromLocalStorage = localStorage.getItem("token");
810
+ let tokenFromCookies = this.cookieService.get(this.cookieName);
811
+ if (tokenFromLocalStorage &&
812
+ tokenFromCookies &&
813
+ tokenFromLocalStorage === tokenFromCookies) {
814
+ this.token = tokenFromLocalStorage;
815
+ this.setUpTokenForSessionService();
816
+ try {
817
+ await this.getSession();
818
+ }
819
+ catch (err) {
820
+ await this.startSession();
821
+ }
822
+ }
823
+ else {
824
+ await this.clearAndStartNewSession();
825
+ }
826
+ if (this.sessionInfoData && this.sessionInfoData.locale) {
827
+ localStorage.setItem(this.localStorageLocaleName, this.sessionInfoData.locale);
828
+ this.localeChanged.next();
829
+ }
830
+ }
831
+ async startSession() {
832
+ let sessionInfo = await this.apiService.startSession().toPromise();
833
+ if (sessionInfo) {
834
+ this.sessionInfoData = sessionInfo;
835
+ this.token = sessionInfo.sid;
836
+ this.saveTokenToLocalStorage();
837
+ this.setAuthenticationStatus();
838
+ this.setUpTokenForSessionService();
839
+ }
840
+ return this.sessionInfoData;
841
+ }
842
+ async getSession() {
843
+ let sessionInfo = await this.apiService.getSession().toPromise();
844
+ if (sessionInfo) {
845
+ this.sessionInfoData = sessionInfo;
846
+ this.token = sessionInfo.sid;
847
+ this.saveTokenToLocalStorage();
848
+ this.setAuthenticationStatus();
849
+ }
850
+ return this.sessionInfoData;
851
+ }
852
+ async refreshSession() {
853
+ let refreshToken = localStorage.getItem("refreshToken");
854
+ if (!refreshToken) {
855
+ return await this.startSession();
856
+ }
857
+ let sessionInfo = await this.apiService
858
+ .refreshSession({
859
+ refreshToken,
860
+ })
861
+ .toPromise()
862
+ .catch(async (error) => {
863
+ if (error.error &&
864
+ error.error.code &&
865
+ error.error.code === "session.refreshtoken.invalid") {
866
+ await this.startSession();
867
+ }
868
+ });
869
+ if (sessionInfo) {
870
+ this.sessionInfoData = sessionInfo;
871
+ this.token = sessionInfo.sid;
872
+ this.saveTokenToLocalStorage();
873
+ this.setAuthenticationStatus();
874
+ this.setUpTokenForSessionService();
875
+ }
876
+ return this.sessionInfoData;
877
+ }
878
+ async getAuthenticationProviders() {
879
+ let providers = await this.apiService
880
+ .getAuthenticationProviders()
881
+ .toPromise();
882
+ this.providers = providers?.authenticationProviders;
883
+ return this.providers;
884
+ }
885
+ async getIsAuthenticated() {
886
+ if (this.sessionInfoData) {
887
+ return this.isAuthenticated;
888
+ }
889
+ await this.getSession();
890
+ return this.isAuthenticated;
891
+ }
892
+ async clearAndStartNewSession() {
893
+ sessionStorage.clear();
894
+ localStorage.clear();
895
+ this.headerParams = [];
896
+ this.cookieService.delete(this.cookieName);
897
+ await this.startSession();
898
+ }
899
+ getLocale() {
900
+ if (this.sessionInfoData && this.sessionInfoData.locale) {
901
+ if (localStorage.getItem(this.localStorageLocaleName) !== this.sessionInfoData.locale) {
902
+ localStorage.setItem(this.localStorageLocaleName, this.sessionInfoData.locale);
903
+ }
904
+ return this.sessionInfoData.locale;
905
+ }
906
+ throw new Error("There is no SessionInfoData or locale is undefined.");
907
+ }
908
+ async changeLocale(locale) {
909
+ this.sessionInfoData = await this.apiService.setLocale(locale).toPromise();
910
+ if (this.sessionInfoData && this.sessionInfoData.locale) {
911
+ localStorage.setItem(this.localStorageLocaleName, this.sessionInfoData.locale);
912
+ this.localeChanged.next();
913
+ }
914
+ }
915
+ }
916
+ SmartSessionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartSessionService, deps: [{ token: SessionService }, { token: SmartCookieService }], target: i0.ɵɵFactoryTarget.Injectable });
917
+ SmartSessionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartSessionService, providedIn: "root" });
918
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartSessionService, decorators: [{
919
+ type: Injectable,
920
+ args: [{
921
+ providedIn: "root",
922
+ }]
923
+ }], ctorParameters: function () { return [{ type: SessionService }, { type: SmartCookieService }]; } });
924
+
925
+ /**
926
+ * Custom HttpParameterCodec
927
+ * Workaround for https://github.com/angular/angular/issues/18261
928
+ */
929
+ class CustomHttpParameterCodec {
930
+ encodeKey(k) {
931
+ return encodeURIComponent(k);
932
+ }
933
+ encodeValue(v) {
934
+ return encodeURIComponent(v);
935
+ }
936
+ decodeKey(k) {
937
+ return decodeURIComponent(k);
938
+ }
939
+ decodeValue(v) {
940
+ return decodeURIComponent(v);
941
+ }
942
+ }
943
+
944
+ const BASE_PATH = new InjectionToken('basePath');
945
+ const COLLECTION_FORMATS = {
946
+ 'csv': ',',
947
+ 'tsv': ' ',
948
+ 'ssv': ' ',
949
+ 'pipes': '|'
950
+ };
951
+
952
+ class Configuration {
953
+ constructor(configurationParameters = {}) {
954
+ this.apiKeys = configurationParameters.apiKeys;
955
+ this.username = configurationParameters.username;
956
+ this.password = configurationParameters.password;
957
+ this.accessToken = configurationParameters.accessToken;
958
+ this.basePath = configurationParameters.basePath;
959
+ this.withCredentials = configurationParameters.withCredentials;
960
+ this.encoder = configurationParameters.encoder;
961
+ if (configurationParameters.encodeParam) {
962
+ this.encodeParam = configurationParameters.encodeParam;
963
+ }
964
+ else {
965
+ this.encodeParam = param => this.defaultEncodeParam(param);
966
+ }
967
+ if (configurationParameters.credentials) {
968
+ this.credentials = configurationParameters.credentials;
969
+ }
970
+ else {
971
+ this.credentials = {};
972
+ }
973
+ }
974
+ /**
975
+ * Select the correct content-type to use for a request.
976
+ * Uses {@link Configuration#isJsonMime} to determine the correct content-type.
977
+ * If no content type is found return the first found type if the contentTypes is not empty
978
+ * @param contentTypes - the array of content types that are available for selection
979
+ * @returns the selected content-type or <code>undefined</code> if no selection could be made.
980
+ */
981
+ selectHeaderContentType(contentTypes) {
982
+ if (contentTypes.length === 0) {
983
+ return undefined;
984
+ }
985
+ const type = contentTypes.find((x) => this.isJsonMime(x));
986
+ if (type === undefined) {
987
+ return contentTypes[0];
988
+ }
989
+ return type;
990
+ }
991
+ /**
992
+ * Select the correct accept content-type to use for a request.
993
+ * Uses {@link Configuration#isJsonMime} to determine the correct accept content-type.
994
+ * If no content type is found return the first found type if the contentTypes is not empty
995
+ * @param accepts - the array of content types that are available for selection.
996
+ * @returns the selected content-type or <code>undefined</code> if no selection could be made.
997
+ */
998
+ selectHeaderAccept(accepts) {
999
+ if (accepts.length === 0) {
1000
+ return undefined;
1001
+ }
1002
+ const type = accepts.find((x) => this.isJsonMime(x));
1003
+ if (type === undefined) {
1004
+ return accepts[0];
1005
+ }
1006
+ return type;
1007
+ }
1008
+ /**
1009
+ * Check if the given MIME is a JSON MIME.
1010
+ * JSON MIME examples:
1011
+ * application/json
1012
+ * application/json; charset=UTF8
1013
+ * APPLICATION/JSON
1014
+ * application/vnd.company+json
1015
+ * @param mime - MIME (Multipurpose Internet Mail Extensions)
1016
+ * @return True if the given MIME is JSON, false otherwise.
1017
+ */
1018
+ isJsonMime(mime) {
1019
+ const jsonMime = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
1020
+ return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
1021
+ }
1022
+ lookupCredential(key) {
1023
+ const value = this.credentials[key];
1024
+ return typeof value === 'function'
1025
+ ? value()
1026
+ : value;
1027
+ }
1028
+ defaultEncodeParam(param) {
1029
+ // This implementation exists as fallback for missing configuration
1030
+ // and for backwards compatibility to older typescript-angular generator versions.
1031
+ // It only works for the 'simple' parameter style.
1032
+ // Date-handling only works for the 'date-time' format.
1033
+ // All other styles and Date-formats are probably handled incorrectly.
1034
+ //
1035
+ // But: if that's all you need (i.e.: the most common use-case): no need for customization!
1036
+ const value = param.dataFormat === 'date-time'
1037
+ ? param.value.toISOString()
1038
+ : param.value;
1039
+ return encodeURIComponent(String(value));
1040
+ }
1041
+ }
1042
+
1043
+ /**
1044
+ * View API
1045
+ * View API
1046
+ *
1047
+ * The version of the OpenAPI document: 1.0.0
1048
+ * Contact: info@it4all.hu
1049
+ *
1050
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
1051
+ * https://openapi-generator.tech
1052
+ * Do not edit the class manually.
1053
+ */
1054
+ class ViewService {
1055
+ constructor(httpClient, basePath, configuration) {
1056
+ this.httpClient = httpClient;
1057
+ this.basePath = 'http://localhost';
1058
+ this.defaultHeaders = new HttpHeaders();
1059
+ this.configuration = new Configuration();
1060
+ if (configuration) {
1061
+ this.configuration = configuration;
1062
+ }
1063
+ if (typeof this.configuration.basePath !== 'string') {
1064
+ if (Array.isArray(basePath) && basePath.length > 0) {
1065
+ basePath = basePath[0];
1066
+ }
1067
+ if (typeof basePath !== 'string') {
1068
+ basePath = this.basePath;
1069
+ }
1070
+ this.configuration.basePath = basePath;
1071
+ }
1072
+ this.encoder = this.configuration.encoder || new CustomHttpParameterCodec();
1073
+ }
1074
+ // @ts-ignore
1075
+ addToHttpParams(httpParams, value, key) {
1076
+ if (typeof value === "object" && value instanceof Date === false) {
1077
+ httpParams = this.addToHttpParamsRecursive(httpParams, value);
1078
+ }
1079
+ else {
1080
+ httpParams = this.addToHttpParamsRecursive(httpParams, value, key);
1081
+ }
1082
+ return httpParams;
1083
+ }
1084
+ addToHttpParamsRecursive(httpParams, value, key) {
1085
+ if (value == null) {
1086
+ return httpParams;
1087
+ }
1088
+ if (typeof value === "object") {
1089
+ if (Array.isArray(value)) {
1090
+ value.forEach(elem => httpParams = this.addToHttpParamsRecursive(httpParams, elem, key));
1091
+ }
1092
+ else if (value instanceof Date) {
1093
+ if (key != null) {
1094
+ httpParams = httpParams.append(key, value.toISOString().substr(0, 10));
1095
+ }
1096
+ else {
1097
+ throw Error("key may not be null if value is Date");
1098
+ }
1099
+ }
1100
+ else {
1101
+ Object.keys(value).forEach(k => httpParams = this.addToHttpParamsRecursive(httpParams, value[k], key != null ? `${key}.${k}` : k));
1102
+ }
1103
+ }
1104
+ else if (key != null) {
1105
+ httpParams = httpParams.append(key, value);
1106
+ }
1107
+ else {
1108
+ throw Error("key may not be null if value is not object or array");
1109
+ }
1110
+ return httpParams;
1111
+ }
1112
+ createViewContext(observe = 'body', reportProgress = false, options) {
1113
+ let localVarHeaders = this.defaultHeaders;
1114
+ let localVarHttpHeaderAcceptSelected = options && options.httpHeaderAccept;
1115
+ if (localVarHttpHeaderAcceptSelected === undefined) {
1116
+ // to determine the Accept header
1117
+ const httpHeaderAccepts = [
1118
+ 'application/json'
1119
+ ];
1120
+ localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
1121
+ }
1122
+ if (localVarHttpHeaderAcceptSelected !== undefined) {
1123
+ localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
1124
+ }
1125
+ let localVarHttpContext = options && options.context;
1126
+ if (localVarHttpContext === undefined) {
1127
+ localVarHttpContext = new HttpContext();
1128
+ }
1129
+ let responseType_ = 'json';
1130
+ if (localVarHttpHeaderAcceptSelected) {
1131
+ if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
1132
+ responseType_ = 'text';
1133
+ }
1134
+ else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
1135
+ responseType_ = 'json';
1136
+ }
1137
+ else {
1138
+ responseType_ = 'blob';
1139
+ }
1140
+ }
1141
+ let localVarPath = `/context`;
1142
+ return this.httpClient.request('post', `${this.configuration.basePath}${localVarPath}`, {
1143
+ context: localVarHttpContext,
1144
+ responseType: responseType_,
1145
+ withCredentials: this.configuration.withCredentials,
1146
+ headers: localVarHeaders,
1147
+ observe: observe,
1148
+ reportProgress: reportProgress
1149
+ });
1150
+ }
1151
+ downloadItem(uuid, item, observe = 'body', reportProgress = false, options) {
1152
+ if (uuid === null || uuid === undefined) {
1153
+ throw new Error('Required parameter uuid was null or undefined when calling downloadItem.');
1154
+ }
1155
+ if (item === null || item === undefined) {
1156
+ throw new Error('Required parameter item was null or undefined when calling downloadItem.');
1157
+ }
1158
+ let localVarHeaders = this.defaultHeaders;
1159
+ let localVarHttpHeaderAcceptSelected = options && options.httpHeaderAccept;
1160
+ if (localVarHttpHeaderAcceptSelected === undefined) {
1161
+ // to determine the Accept header
1162
+ const httpHeaderAccepts = [
1163
+ 'application/octet-stream'
1164
+ ];
1165
+ localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
1166
+ }
1167
+ if (localVarHttpHeaderAcceptSelected !== undefined) {
1168
+ localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
1169
+ }
1170
+ let localVarHttpContext = options && options.context;
1171
+ if (localVarHttpContext === undefined) {
1172
+ localVarHttpContext = new HttpContext();
1173
+ }
1174
+ let localVarPath = `/view/${this.configuration.encodeParam({ name: "uuid", value: uuid, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: "uuid" })}/download/${this.configuration.encodeParam({ name: "item", value: item, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined })}`;
1175
+ return this.httpClient.request('get', `${this.configuration.basePath}${localVarPath}`, {
1176
+ context: localVarHttpContext,
1177
+ responseType: "blob",
1178
+ withCredentials: this.configuration.withCredentials,
1179
+ headers: localVarHeaders,
1180
+ observe: observe,
1181
+ reportProgress: reportProgress
1182
+ });
1183
+ }
1184
+ getViewConstraint(uuid, observe = 'body', reportProgress = false, options) {
1185
+ if (uuid === null || uuid === undefined) {
1186
+ throw new Error('Required parameter uuid was null or undefined when calling getViewConstraint.');
1187
+ }
1188
+ let localVarHeaders = this.defaultHeaders;
1189
+ let localVarHttpHeaderAcceptSelected = options && options.httpHeaderAccept;
1190
+ if (localVarHttpHeaderAcceptSelected === undefined) {
1191
+ // to determine the Accept header
1192
+ const httpHeaderAccepts = [
1193
+ 'application/json'
1194
+ ];
1195
+ localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
1196
+ }
1197
+ if (localVarHttpHeaderAcceptSelected !== undefined) {
1198
+ localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
1199
+ }
1200
+ let localVarHttpContext = options && options.context;
1201
+ if (localVarHttpContext === undefined) {
1202
+ localVarHttpContext = new HttpContext();
1203
+ }
1204
+ let responseType_ = 'json';
1205
+ if (localVarHttpHeaderAcceptSelected) {
1206
+ if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
1207
+ responseType_ = 'text';
1208
+ }
1209
+ else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
1210
+ responseType_ = 'json';
1211
+ }
1212
+ else {
1213
+ responseType_ = 'blob';
1214
+ }
1215
+ }
1216
+ let localVarPath = `/view/${this.configuration.encodeParam({ name: "uuid", value: uuid, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: "uuid" })}/constraint`;
1217
+ return this.httpClient.request('get', `${this.configuration.basePath}${localVarPath}`, {
1218
+ context: localVarHttpContext,
1219
+ responseType: responseType_,
1220
+ withCredentials: this.configuration.withCredentials,
1221
+ headers: localVarHeaders,
1222
+ observe: observe,
1223
+ reportProgress: reportProgress
1224
+ });
1225
+ }
1226
+ getViewContext(uuid, observe = 'body', reportProgress = false, options) {
1227
+ if (uuid === null || uuid === undefined) {
1228
+ throw new Error('Required parameter uuid was null or undefined when calling getViewContext.');
1229
+ }
1230
+ let localVarHeaders = this.defaultHeaders;
1231
+ let localVarHttpHeaderAcceptSelected = options && options.httpHeaderAccept;
1232
+ if (localVarHttpHeaderAcceptSelected === undefined) {
1233
+ // to determine the Accept header
1234
+ const httpHeaderAccepts = [
1235
+ 'application/json'
1236
+ ];
1237
+ localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
1238
+ }
1239
+ if (localVarHttpHeaderAcceptSelected !== undefined) {
1240
+ localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
1241
+ }
1242
+ let localVarHttpContext = options && options.context;
1243
+ if (localVarHttpContext === undefined) {
1244
+ localVarHttpContext = new HttpContext();
1245
+ }
1246
+ let responseType_ = 'json';
1247
+ if (localVarHttpHeaderAcceptSelected) {
1248
+ if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
1249
+ responseType_ = 'text';
1250
+ }
1251
+ else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
1252
+ responseType_ = 'json';
1253
+ }
1254
+ else {
1255
+ responseType_ = 'blob';
1256
+ }
1257
+ }
1258
+ let localVarPath = `/context/${this.configuration.encodeParam({ name: "uuid", value: uuid, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: "uuid" })}`;
1259
+ return this.httpClient.request('get', `${this.configuration.basePath}${localVarPath}`, {
1260
+ context: localVarHttpContext,
1261
+ responseType: responseType_,
1262
+ withCredentials: this.configuration.withCredentials,
1263
+ headers: localVarHeaders,
1264
+ observe: observe,
1265
+ reportProgress: reportProgress
1266
+ });
1267
+ }
1268
+ message(viewUuid, messageUuid, messageResult, observe = 'body', reportProgress = false, options) {
1269
+ if (viewUuid === null || viewUuid === undefined) {
1270
+ throw new Error('Required parameter viewUuid was null or undefined when calling message.');
1271
+ }
1272
+ if (messageUuid === null || messageUuid === undefined) {
1273
+ throw new Error('Required parameter messageUuid was null or undefined when calling message.');
1274
+ }
1275
+ if (messageResult === null || messageResult === undefined) {
1276
+ throw new Error('Required parameter messageResult was null or undefined when calling message.');
1277
+ }
1278
+ let localVarHeaders = this.defaultHeaders;
1279
+ let localVarHttpHeaderAcceptSelected = options && options.httpHeaderAccept;
1280
+ if (localVarHttpHeaderAcceptSelected === undefined) {
1281
+ // to determine the Accept header
1282
+ const httpHeaderAccepts = [];
1283
+ localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
1284
+ }
1285
+ if (localVarHttpHeaderAcceptSelected !== undefined) {
1286
+ localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
1287
+ }
1288
+ let localVarHttpContext = options && options.context;
1289
+ if (localVarHttpContext === undefined) {
1290
+ localVarHttpContext = new HttpContext();
1291
+ }
1292
+ // to determine the Content-Type header
1293
+ const consumes = [
1294
+ 'application/json'
1295
+ ];
1296
+ const httpContentTypeSelected = this.configuration.selectHeaderContentType(consumes);
1297
+ if (httpContentTypeSelected !== undefined) {
1298
+ localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected);
1299
+ }
1300
+ let responseType_ = 'json';
1301
+ if (localVarHttpHeaderAcceptSelected) {
1302
+ if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
1303
+ responseType_ = 'text';
1304
+ }
1305
+ else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
1306
+ responseType_ = 'json';
1307
+ }
1308
+ else {
1309
+ responseType_ = 'blob';
1310
+ }
1311
+ }
1312
+ let localVarPath = `/message/${this.configuration.encodeParam({ name: "viewUuid", value: viewUuid, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: "uuid" })}/${this.configuration.encodeParam({ name: "messageUuid", value: messageUuid, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: "uuid" })}`;
1313
+ return this.httpClient.request('post', `${this.configuration.basePath}${localVarPath}`, {
1314
+ context: localVarHttpContext,
1315
+ body: messageResult,
1316
+ responseType: responseType_,
1317
+ withCredentials: this.configuration.withCredentials,
1318
+ headers: localVarHeaders,
1319
+ observe: observe,
1320
+ reportProgress: reportProgress
1321
+ });
1322
+ }
1323
+ showPublishedView(channel, uuid, observe = 'body', reportProgress = false, options) {
1324
+ if (channel === null || channel === undefined) {
1325
+ throw new Error('Required parameter channel was null or undefined when calling showPublishedView.');
1326
+ }
1327
+ if (uuid === null || uuid === undefined) {
1328
+ throw new Error('Required parameter uuid was null or undefined when calling showPublishedView.');
1329
+ }
1330
+ let localVarHeaders = this.defaultHeaders;
1331
+ let localVarHttpHeaderAcceptSelected = options && options.httpHeaderAccept;
1332
+ if (localVarHttpHeaderAcceptSelected === undefined) {
1333
+ // to determine the Accept header
1334
+ const httpHeaderAccepts = [];
1335
+ localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
1336
+ }
1337
+ if (localVarHttpHeaderAcceptSelected !== undefined) {
1338
+ localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
1339
+ }
1340
+ let localVarHttpContext = options && options.context;
1341
+ if (localVarHttpContext === undefined) {
1342
+ localVarHttpContext = new HttpContext();
1343
+ }
1344
+ let responseType_ = 'json';
1345
+ if (localVarHttpHeaderAcceptSelected) {
1346
+ if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
1347
+ responseType_ = 'text';
1348
+ }
1349
+ else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
1350
+ responseType_ = 'json';
1351
+ }
1352
+ else {
1353
+ responseType_ = 'blob';
1354
+ }
1355
+ }
1356
+ let localVarPath = `/smartlink/${this.configuration.encodeParam({ name: "channel", value: channel, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined })}/${this.configuration.encodeParam({ name: "uuid", value: uuid, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: "uuid" })}`;
1357
+ return this.httpClient.request('put', `${this.configuration.basePath}${localVarPath}`, {
1358
+ context: localVarHttpContext,
1359
+ responseType: responseType_,
1360
+ withCredentials: this.configuration.withCredentials,
1361
+ headers: localVarHeaders,
1362
+ observe: observe,
1363
+ reportProgress: reportProgress
1364
+ });
1365
+ }
1366
+ updateViewContext(viewContextUpdate, observe = 'body', reportProgress = false, options) {
1367
+ if (viewContextUpdate === null || viewContextUpdate === undefined) {
1368
+ throw new Error('Required parameter viewContextUpdate was null or undefined when calling updateViewContext.');
1369
+ }
1370
+ let localVarHeaders = this.defaultHeaders;
1371
+ let localVarHttpHeaderAcceptSelected = options && options.httpHeaderAccept;
1372
+ if (localVarHttpHeaderAcceptSelected === undefined) {
1373
+ // to determine the Accept header
1374
+ const httpHeaderAccepts = [
1375
+ 'application/json'
1376
+ ];
1377
+ localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
1378
+ }
1379
+ if (localVarHttpHeaderAcceptSelected !== undefined) {
1380
+ localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
1381
+ }
1382
+ let localVarHttpContext = options && options.context;
1383
+ if (localVarHttpContext === undefined) {
1384
+ localVarHttpContext = new HttpContext();
1385
+ }
1386
+ // to determine the Content-Type header
1387
+ const consumes = [
1388
+ 'application/json'
1389
+ ];
1390
+ const httpContentTypeSelected = this.configuration.selectHeaderContentType(consumes);
1391
+ if (httpContentTypeSelected !== undefined) {
1392
+ localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected);
1393
+ }
1394
+ let responseType_ = 'json';
1395
+ if (localVarHttpHeaderAcceptSelected) {
1396
+ if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
1397
+ responseType_ = 'text';
1398
+ }
1399
+ else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
1400
+ responseType_ = 'json';
1401
+ }
1402
+ else {
1403
+ responseType_ = 'blob';
1404
+ }
1405
+ }
1406
+ let localVarPath = `/context`;
1407
+ return this.httpClient.request('put', `${this.configuration.basePath}${localVarPath}`, {
1408
+ context: localVarHttpContext,
1409
+ body: viewContextUpdate,
1410
+ responseType: responseType_,
1411
+ withCredentials: this.configuration.withCredentials,
1412
+ headers: localVarHeaders,
1413
+ observe: observe,
1414
+ reportProgress: reportProgress
1415
+ });
1416
+ }
1417
+ }
1418
+ ViewService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: ViewService, deps: [{ token: i1.HttpClient }, { token: BASE_PATH, optional: true }, { token: Configuration, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
1419
+ ViewService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: ViewService, providedIn: 'root' });
1420
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: ViewService, decorators: [{
1421
+ type: Injectable,
1422
+ args: [{
1423
+ providedIn: 'root'
1424
+ }]
1425
+ }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: undefined, decorators: [{
1426
+ type: Optional
1427
+ }, {
1428
+ type: Inject,
1429
+ args: [BASE_PATH]
1430
+ }] }, { type: Configuration, decorators: [{
1431
+ type: Optional
1432
+ }] }]; } });
1433
+
1434
+ const APIS = [ViewService];
1435
+
1436
+ /**
1437
+ * View API
1438
+ * View API
1439
+ *
1440
+ * The version of the OpenAPI document: 1.0.0
1441
+ * Contact: info@it4all.hu
1442
+ *
1443
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
1444
+ * https://openapi-generator.tech
1445
+ * Do not edit the class manually.
1446
+ */
1447
+ const CloseResult = {
1448
+ Approved: 'approved',
1449
+ Pending: 'pending',
1450
+ Rejected: 'rejected'
1451
+ };
1452
+
1453
+ /**
1454
+ * View API
1455
+ * View API
1456
+ *
1457
+ * The version of the OpenAPI document: 1.0.0
1458
+ * Contact: info@it4all.hu
1459
+ *
1460
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
1461
+ * https://openapi-generator.tech
1462
+ * Do not edit the class manually.
1463
+ */
1464
+ const MessageOptionType = {
1465
+ Confirm: 'confirm',
1466
+ Reject: 'reject',
1467
+ Cancel: 'cancel'
1468
+ };
1469
+
1470
+ /**
1471
+ * View API
1472
+ * View API
1473
+ *
1474
+ * The version of the OpenAPI document: 1.0.0
1475
+ * Contact: info@it4all.hu
1476
+ *
1477
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
1478
+ * https://openapi-generator.tech
1479
+ * Do not edit the class manually.
1480
+ */
1481
+ const MessageType = {
1482
+ Info: 'info',
1483
+ Question: 'question',
1484
+ Warning: 'warning',
1485
+ Error: 'error'
1486
+ };
1487
+
1488
+ /**
1489
+ * View API
1490
+ * View API
1491
+ *
1492
+ * The version of the OpenAPI document: 1.0.0
1493
+ * Contact: info@it4all.hu
1494
+ *
1495
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
1496
+ * https://openapi-generator.tech
1497
+ * Do not edit the class manually.
1498
+ */
1499
+
1500
+ /**
1501
+ * View API
1502
+ * View API
1503
+ *
1504
+ * The version of the OpenAPI document: 1.0.0
1505
+ * Contact: info@it4all.hu
1506
+ *
1507
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
1508
+ * https://openapi-generator.tech
1509
+ * Do not edit the class manually.
1510
+ */
1511
+ const UiActionButtonIconPos = {
1512
+ Pre: 'PRE',
1513
+ Post: 'POST'
1514
+ };
1515
+
1516
+ /**
1517
+ * View API
1518
+ * View API
1519
+ *
1520
+ * The version of the OpenAPI document: 1.0.0
1521
+ * Contact: info@it4all.hu
1522
+ *
1523
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
1524
+ * https://openapi-generator.tech
1525
+ * Do not edit the class manually.
1526
+ */
1527
+ const UiActionButtonType = {
1528
+ Normal: 'NORMAL',
1529
+ Flat: 'FLAT',
1530
+ Stroked: 'STROKED',
1531
+ Raised: 'RAISED',
1532
+ Icon: 'ICON',
1533
+ MiniFab: 'MINI_FAB',
1534
+ Fab: 'FAB'
1535
+ };
1536
+
1537
+ /**
1538
+ * View API
1539
+ * View API
1540
+ *
1541
+ * The version of the OpenAPI document: 1.0.0
1542
+ * Contact: info@it4all.hu
1543
+ *
1544
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
1545
+ * https://openapi-generator.tech
1546
+ * Do not edit the class manually.
1547
+ */
1548
+ const UiActionFeedbackType = {
1549
+ None: 'NONE',
1550
+ Snackbar: 'SNACKBAR'
1551
+ };
1552
+
1553
+ /**
1554
+ * View API
1555
+ * View API
1556
+ *
1557
+ * The version of the OpenAPI document: 1.0.0
1558
+ * Contact: info@it4all.hu
1559
+ *
1560
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
1561
+ * https://openapi-generator.tech
1562
+ * Do not edit the class manually.
1563
+ */
1564
+ const UiActionInputType = {
1565
+ None: 'none',
1566
+ Textfield: 'textfield',
1567
+ Textarea: 'textarea',
1568
+ UserSelect: 'user_select'
1569
+ };
1570
+
1571
+ /**
1572
+ * View API
1573
+ * View API
1574
+ *
1575
+ * The version of the OpenAPI document: 1.0.0
1576
+ * Contact: info@it4all.hu
1577
+ *
1578
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
1579
+ * https://openapi-generator.tech
1580
+ * Do not edit the class manually.
1581
+ */
1582
+
1583
+ /**
1584
+ * View API
1585
+ * View API
1586
+ *
1587
+ * The version of the OpenAPI document: 1.0.0
1588
+ * Contact: info@it4all.hu
1589
+ *
1590
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
1591
+ * https://openapi-generator.tech
1592
+ * Do not edit the class manually.
1593
+ */
1594
+
1595
+ /**
1596
+ * View API
1597
+ * View API
1598
+ *
1599
+ * The version of the OpenAPI document: 1.0.0
1600
+ * Contact: info@it4all.hu
1601
+ *
1602
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
1603
+ * https://openapi-generator.tech
1604
+ * Do not edit the class manually.
1605
+ */
1606
+ const ViewState = {
1607
+ OpenPending: 'open_pending',
1608
+ ToOpen: 'to_open',
1609
+ Opened: 'opened',
1610
+ ClosePending: 'close_pending',
1611
+ CloseApproved: 'close_approved',
1612
+ ToClose: 'to_close',
1613
+ Closed: 'closed'
1614
+ };
1615
+
1616
+ /**
1617
+ * View API
1618
+ * View API
1619
+ *
1620
+ * The version of the OpenAPI document: 1.0.0
1621
+ * Contact: info@it4all.hu
1622
+ *
1623
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
1624
+ * https://openapi-generator.tech
1625
+ * Do not edit the class manually.
1626
+ */
1627
+ const ViewType = {
1628
+ Normal: 'normal',
1629
+ Dialog: 'dialog',
1630
+ Embedded: 'embedded'
1631
+ };
1632
+
1633
+ class ViewContextApiModule {
1634
+ constructor(parentModule, http) {
1635
+ if (parentModule) {
1636
+ throw new Error("ApiModule is already loaded. Import in your base AppModule only.");
1637
+ }
1638
+ if (!http) {
1639
+ throw new Error("You need to import the HttpClientModule in your AppModule! \n" +
1640
+ "See also https://github.com/angular/angular/issues/20575");
1641
+ }
1642
+ }
1643
+ static forRoot(configurationFactory) {
1644
+ return {
1645
+ ngModule: ViewContextApiModule,
1646
+ providers: [{ provide: Configuration, useFactory: configurationFactory }],
1647
+ };
1648
+ }
1649
+ }
1650
+ ViewContextApiModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: ViewContextApiModule, deps: [{ token: ViewContextApiModule, optional: true, skipSelf: true }, { token: i1.HttpClient, optional: true }], target: i0.ɵɵFactoryTarget.NgModule });
1651
+ ViewContextApiModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: ViewContextApiModule });
1652
+ ViewContextApiModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: ViewContextApiModule, providers: [], imports: [[]] });
1653
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: ViewContextApiModule, decorators: [{
1654
+ type: NgModule,
1655
+ args: [{
1656
+ imports: [],
1657
+ declarations: [],
1658
+ exports: [],
1659
+ providers: [],
1660
+ }]
1661
+ }], ctorParameters: function () { return [{ type: ViewContextApiModule, decorators: [{
1662
+ type: Optional
1663
+ }, {
1664
+ type: SkipSelf
1665
+ }] }, { type: i1.HttpClient, decorators: [{
1666
+ type: Optional
1667
+ }] }]; } });
1668
+
1669
+ class MessageDialogComponent {
1670
+ constructor(viewContext) {
1671
+ this.viewContext = viewContext;
1672
+ }
1673
+ ngOnInit() {
1674
+ this.getMessageData();
1675
+ }
1676
+ ngOnDestroy() {
1677
+ if (!this.messageData.options || !this.messageData.options.length) {
1678
+ this.viewContext.message(this.messageData, {
1679
+ selectedOption: {
1680
+ code: MessageOptionType.Cancel,
1681
+ label: "",
1682
+ },
1683
+ });
1684
+ }
1685
+ }
1686
+ async getMessageData() {
1687
+ let messageDialogName = this.viewContext.messageDialogname;
1688
+ let viewData = await this.viewContext.getViewContextDataByPageName(messageDialogName);
1689
+ this.messageData = viewData.message;
1690
+ }
1691
+ getColor(option) {
1692
+ switch (option.type) {
1693
+ case MessageOptionType.Cancel:
1694
+ return "accent";
1695
+ case MessageOptionType.Confirm:
1696
+ return "primary";
1697
+ case MessageOptionType.Reject:
1698
+ return "warn";
1699
+ default:
1700
+ return "accent";
1701
+ }
1702
+ }
1703
+ getType(option) {
1704
+ switch (option.type) {
1705
+ case MessageOptionType.Confirm:
1706
+ case MessageOptionType.Reject:
1707
+ return "mat-raised-button";
1708
+ default:
1709
+ return "mat-button";
1710
+ }
1711
+ }
1712
+ onClick(selectedOption) {
1713
+ this.viewContext.message(this.messageData, {
1714
+ selectedOption,
1715
+ });
1716
+ }
1717
+ }
1718
+ MessageDialogComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: MessageDialogComponent, deps: [{ token: SmartViewContextService }], target: i0.ɵɵFactoryTarget.Component });
1719
+ MessageDialogComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: MessageDialogComponent, selector: "app-message-dialog", ngImport: i0, template: "<div class=\"taskDialogContainer\" *ngIf=\"messageData\">\n\t<h2>\n\t\t{{ messageData.header }}\n\t</h2>\n\t<p>{{ messageData.text }}</p>\n\t<div class=\"buttonsContainer\">\n\t\t<button\n\t\t\t*ngFor=\"let option of messageData.options\"\n\t\t\tmat-button\n\t\t\tclass=\"taskDialogButton\"\n\t\t\t[ngClass]=\"getType(option)\"\n\t\t\tcolor=\"{{ getColor(option) }}\"\n\t\t\t(click)=\"onClick(option)\"\n\t\t>\n\t\t\t<mat-icon *ngIf=\"option.icon\">\n\t\t\t\t{{ option.icon }}\n\t\t\t</mat-icon>\n\t\t\t{{ option.label }}\n\t\t</button>\n\t</div>\n</div>\n", styles: [".taskDialogContainer{width:400px;display:flex;flex-direction:column;gap:.5rem}.spacer{flex:1}.buttonsContainer{display:flex;flex-direction:row;gap:.5rem;justify-content:flex-end}.taskDialogButton{min-width:100px}h2,p{margin:0!important}\n"], components: [{ type: i2.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }], directives: [{ type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i5.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }] });
1720
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: MessageDialogComponent, decorators: [{
1721
+ type: Component,
1722
+ args: [{ selector: "app-message-dialog", template: "<div class=\"taskDialogContainer\" *ngIf=\"messageData\">\n\t<h2>\n\t\t{{ messageData.header }}\n\t</h2>\n\t<p>{{ messageData.text }}</p>\n\t<div class=\"buttonsContainer\">\n\t\t<button\n\t\t\t*ngFor=\"let option of messageData.options\"\n\t\t\tmat-button\n\t\t\tclass=\"taskDialogButton\"\n\t\t\t[ngClass]=\"getType(option)\"\n\t\t\tcolor=\"{{ getColor(option) }}\"\n\t\t\t(click)=\"onClick(option)\"\n\t\t>\n\t\t\t<mat-icon *ngIf=\"option.icon\">\n\t\t\t\t{{ option.icon }}\n\t\t\t</mat-icon>\n\t\t\t{{ option.label }}\n\t\t</button>\n\t</div>\n</div>\n", styles: [".taskDialogContainer{width:400px;display:flex;flex-direction:column;gap:.5rem}.spacer{flex:1}.buttonsContainer{display:flex;flex-direction:row;gap:.5rem;justify-content:flex-end}.taskDialogButton{min-width:100px}h2,p{margin:0!important}\n"] }]
1723
+ }], ctorParameters: function () { return [{ type: SmartViewContextService }]; } });
1724
+
1725
+ class SmartViewContextService {
1726
+ constructor(view, session, navigation, dialog) {
1727
+ this.view = view;
1728
+ this.session = session;
1729
+ this.navigation = navigation;
1730
+ this.dialog = dialog;
1731
+ this.tabIdName = "viewContextUuid";
1732
+ this.tabIdhttpHeaderName = "viewContextUuid";
1733
+ this.viewHandlers = new Array();
1734
+ this.openedViewUuids = new Array();
1735
+ this.uuidOfPageHasBeenChanged = new Subject();
1736
+ this.viewContextHasBeenSynced = new Subject();
1737
+ this.openSmartLink = new Subject();
1738
+ this.isOpeningSmartLink = false;
1739
+ this.dialogRefs = [];
1740
+ this.translateServiceChanged = new Subject();
1741
+ }
1742
+ set translateService(translateService) {
1743
+ this._translateService = translateService;
1744
+ this.translateServiceChanged.next();
1745
+ this.translateServiceChanged.complete();
1746
+ }
1747
+ get translateService() {
1748
+ if (this._translateService) {
1749
+ return this._translateService;
1750
+ }
1751
+ return undefined;
1752
+ }
1753
+ setActionDescriptors(actionDescriptors) {
1754
+ this.actionDescriptors = actionDescriptors;
1755
+ }
1756
+ getActionDescriptors() {
1757
+ if (!this.actionDescriptors) {
1758
+ console.error("No action descriptors has been set to ViewContext.");
1759
+ }
1760
+ return this.actionDescriptors;
1761
+ }
1762
+ setViewHandlers(viewHandlers) {
1763
+ this.viewHandlers = viewHandlers;
1764
+ }
1765
+ setViewApiErrors(viewApiErrors) {
1766
+ this.smartViewContextApiErrors = viewApiErrors;
1767
+ }
1768
+ setMessageDialogName(messageDialogName) {
1769
+ this.messageDialogname = messageDialogName;
1770
+ this.viewHandlers.push({
1771
+ name: messageDialogName,
1772
+ component: MessageDialogComponent,
1773
+ });
1774
+ }
1775
+ setUpUrlForViewService() {
1776
+ this.view.configuration.basePath = this.url;
1777
+ }
1778
+ setUrl(url) {
1779
+ this.url = url + "/view";
1780
+ this.setUpUrlForViewService();
1781
+ }
1782
+ async getAndSyncViewContext(uuid) {
1783
+ if (!uuid) {
1784
+ uuid = this.getUuidOfPage(this.tabIdName);
1785
+ }
1786
+ await this.getViewContext(uuid).then(() => {
1787
+ this.syncView();
1788
+ });
1789
+ }
1790
+ async getViewContext(uuid) {
1791
+ this.viewContext = await this.view.getViewContext(uuid).toPromise();
1792
+ if (!this.viewContext) {
1793
+ throw new Error("ViewContext does not exist with the given uuid.");
1794
+ }
1795
+ return this.viewContext;
1796
+ }
1797
+ async getViewContextDataByPageName(pageName) {
1798
+ if (!this.viewContext) {
1799
+ let viewContextUuid = sessionStorage.getItem(this.tabIdName);
1800
+ if (!viewContextUuid) {
1801
+ throw new Error("View context is not initialized!");
1802
+ }
1803
+ await this.getViewContext(viewContextUuid);
1804
+ }
1805
+ let pageUuid = this.getUuidOfPage(pageName);
1806
+ let viewContextByPageName = this.viewContext?.views.find((view) => view.uuid === pageUuid);
1807
+ if (!viewContextByPageName) {
1808
+ throw new Error(`The ViewData of ${pageName} is not found!`);
1809
+ }
1810
+ return viewContextByPageName;
1811
+ }
1812
+ async updateViewContext(viewContextUpdate) {
1813
+ this.viewContext = await this.view.updateViewContext(viewContextUpdate).toPromise();
1814
+ return this.viewContext;
1815
+ }
1816
+ clearSessionStorage() {
1817
+ sessionStorage.clear();
1818
+ }
1819
+ setTabId(tabId) {
1820
+ sessionStorage.setItem(this.tabIdName, tabId);
1821
+ this.session.addHeaderParam({ headerName: this.tabIdhttpHeaderName, value: tabId });
1822
+ }
1823
+ async startViewContext() {
1824
+ this.clearSessionStorage();
1825
+ let newViewContext = await this.view
1826
+ .createViewContext()
1827
+ .toPromise();
1828
+ if (!newViewContext) {
1829
+ throw new Error("No ViewContext was created");
1830
+ }
1831
+ this.viewContext = newViewContext;
1832
+ this.setTabId(newViewContext.uuid);
1833
+ return this.viewContext;
1834
+ }
1835
+ async initialize(uuid) {
1836
+ if (this.viewHandlers.length === 0) {
1837
+ throw new Error("There aren't any viewHandlers in SmartViewContextService! Provide some to use its functions.");
1838
+ }
1839
+ if (!this.messageDialogname) {
1840
+ throw new Error("The messageDialogName provided by the backend has not been set.");
1841
+ }
1842
+ if (uuid) {
1843
+ let subscription = this.session.headersUpdated.subscribe(async () => {
1844
+ subscription.unsubscribe();
1845
+ try {
1846
+ await this.getViewContext(uuid);
1847
+ this.setTabId(uuid);
1848
+ }
1849
+ catch (err) {
1850
+ await this.startViewContext();
1851
+ }
1852
+ });
1853
+ this.setTabId(uuid);
1854
+ }
1855
+ else {
1856
+ await this.startViewContext();
1857
+ }
1858
+ return this.viewContext;
1859
+ }
1860
+ openView(view) {
1861
+ let viewHandler = this.viewHandlers.find((handler) => handler.name === view.viewName);
1862
+ if (!viewHandler) {
1863
+ throw new Error(`SmartViewHandlerModel was not found by view name: ${view.viewName}`);
1864
+ }
1865
+ if (view.type === ViewType.Dialog) {
1866
+ if (!viewHandler.component) {
1867
+ throw new Error(`Component is undefined in SmartViewHandlerModel with name: ${view.viewName}`);
1868
+ }
1869
+ let dialogRef = this.dialog.openComponentAsDialog(viewHandler.component, viewHandler.name);
1870
+ if (view.viewName === this.messageDialogname) {
1871
+ if (view.message?.options && view.message.options.length) {
1872
+ dialogRef.disableClose = true;
1873
+ }
1874
+ }
1875
+ this.dialogRefs.push({
1876
+ uuid: view.uuid,
1877
+ dialogRef,
1878
+ });
1879
+ }
1880
+ else if (view.type === ViewType.Normal) {
1881
+ if (viewHandler.route === undefined) {
1882
+ throw new Error(`Route is undefined in SmartViewHandlerModel with name: ${view.viewName}`);
1883
+ }
1884
+ this.navigation.navigateTo(viewHandler.route.split("/"));
1885
+ }
1886
+ else {
1887
+ throw new Error("The type of the view and its viewHandler is not the same!");
1888
+ }
1889
+ view.state = ViewState.Opened;
1890
+ this.openedViewUuids.push(view.uuid);
1891
+ sessionStorage.setItem(view.viewName, view.uuid);
1892
+ this.uuidOfPageHasBeenChanged.next(view.viewName);
1893
+ this.updateViewContext({
1894
+ updates: [
1895
+ {
1896
+ state: ViewState.Opened,
1897
+ uuid: view.uuid,
1898
+ },
1899
+ ],
1900
+ uuid: this.viewContext?.uuid,
1901
+ });
1902
+ }
1903
+ closeView(view) {
1904
+ let viewHandler = this.viewHandlers.find((handler) => handler.name === view.viewName);
1905
+ if (!viewHandler) {
1906
+ throw new Error(`SmartViewHandlerModel was not found by view name: ${view.viewName}`);
1907
+ }
1908
+ if (view.type === ViewType.Dialog) {
1909
+ let dialogRef = this.dialogRefs.find((dialogRef) => dialogRef.uuid === view.uuid);
1910
+ if (dialogRef) {
1911
+ dialogRef.dialogRef.close();
1912
+ let index = this.dialogRefs.indexOf(dialogRef);
1913
+ this.dialogRefs.splice(index, 1);
1914
+ }
1915
+ else {
1916
+ throw new Error("DialogRef is not found by uuid.");
1917
+ }
1918
+ }
1919
+ else if (view.type === ViewType.Normal) {
1920
+ // TODO: close normal page???
1921
+ // this.navigation.navigateTo(viewHandler.route.split("/"));
1922
+ }
1923
+ else {
1924
+ throw new Error("The type of the view and its viewHandler is not the same!");
1925
+ }
1926
+ view.state = ViewState.Closed;
1927
+ this.openedViewUuids.slice(this.openedViewUuids.indexOf(view.uuid), 1);
1928
+ sessionStorage.removeItem(view.viewName);
1929
+ this.updateViewContext({
1930
+ updates: [
1931
+ {
1932
+ state: ViewState.Closed,
1933
+ uuid: view.uuid,
1934
+ },
1935
+ ],
1936
+ uuid: this.viewContext?.uuid,
1937
+ });
1938
+ }
1939
+ async restoreViews(uuid) {
1940
+ if (!this.viewContext) {
1941
+ await this.getViewContext(uuid);
1942
+ }
1943
+ this.viewContext.views.map((view) => {
1944
+ this.openView(view);
1945
+ });
1946
+ }
1947
+ syncView() {
1948
+ this.viewContext?.views.map((view) => {
1949
+ switch (view.state) {
1950
+ case ViewState.ToOpen:
1951
+ this.openView(view);
1952
+ break;
1953
+ case ViewState.ToClose:
1954
+ this.closeView(view);
1955
+ break;
1956
+ }
1957
+ });
1958
+ this.viewContextHasBeenSynced.next();
1959
+ }
1960
+ getUuidOfPage(pageName) {
1961
+ let uuid = sessionStorage.getItem(pageName);
1962
+ if (!uuid) {
1963
+ throw new Error(`The uuid of ${pageName} is not available.`);
1964
+ }
1965
+ return uuid;
1966
+ }
1967
+ async message(messageData, messageResult) {
1968
+ await this.view
1969
+ .message(messageData.viewUuid ?? "", messageData.uuid, messageResult)
1970
+ .toPromise();
1971
+ await this.getAndSyncViewContext();
1972
+ }
1973
+ getSmartViewContextApiErrorByCode(code) {
1974
+ if (!this.smartViewContextApiErrors) {
1975
+ return {
1976
+ code,
1977
+ message: "An error has occured.",
1978
+ buttonLabel: "Ok",
1979
+ dialogTitle: "Hiba",
1980
+ };
1981
+ }
1982
+ let apiErrorsWithCode = this.smartViewContextApiErrors.viewContextApiErrors.filter((apiError) => {
1983
+ return apiError.code === code;
1984
+ });
1985
+ if (!apiErrorsWithCode || (apiErrorsWithCode && !apiErrorsWithCode.length)) {
1986
+ console.error(`SmartViewContextApiError with code ${code} could not be found.`);
1987
+ return {
1988
+ code,
1989
+ message: "An error has occured.",
1990
+ buttonLabel: "Ok",
1991
+ dialogTitle: "Hiba",
1992
+ };
1993
+ }
1994
+ return apiErrorsWithCode[0];
1995
+ }
1996
+ async getViewConstraint(uuid) {
1997
+ let viewConstraintResponse = await this.view.getViewConstraint(uuid).toPromise();
1998
+ if (!viewConstraintResponse)
1999
+ throw new Error("Could not get ViewConstraint with the given uuid.");
2000
+ return viewConstraintResponse;
2001
+ }
2002
+ async showPublishedView(channel, uuid) {
2003
+ await this.session.initialize();
2004
+ // TODO init view context automatically
2005
+ // await this.initialize();
2006
+ this.isOpeningSmartLink = true;
2007
+ this.openSmartLink.next();
2008
+ await this.openSmartLink.toPromise();
2009
+ await this.view.showPublishedView(channel, uuid).toPromise();
2010
+ await this.getAndSyncViewContext();
2011
+ this.isOpeningSmartLink = false;
2012
+ }
2013
+ async downloadResource(uuid, item) {
2014
+ return await this.view.downloadItem(uuid, item).toPromise();
2015
+ }
2016
+ }
2017
+ SmartViewContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextService, deps: [{ token: ViewService }, { token: SmartSessionService }, { token: i3$1.SmartNavigationService }, { token: i4.SmartdialogService }], target: i0.ɵɵFactoryTarget.Injectable });
2018
+ SmartViewContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextService, providedIn: "root" });
2019
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextService, decorators: [{
2020
+ type: Injectable,
2021
+ args: [{
2022
+ providedIn: "root",
2023
+ }]
2024
+ }], ctorParameters: function () { return [{ type: ViewService }, { type: SmartSessionService }, { type: i3$1.SmartNavigationService }, { type: i4.SmartdialogService }]; } });
2025
+
2026
+ class SmartNgClientService {
2027
+ constructor(session, viewContext) {
2028
+ this.session = session;
2029
+ this.viewContext = viewContext;
2030
+ }
2031
+ }
2032
+ SmartNgClientService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartNgClientService, deps: [{ token: SmartSessionService }, { token: SmartViewContextService }], target: i0.ɵɵFactoryTarget.Injectable });
2033
+ SmartNgClientService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartNgClientService, providedIn: "root" });
2034
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartNgClientService, decorators: [{
2035
+ type: Injectable,
2036
+ args: [{
2037
+ providedIn: "root",
2038
+ }]
2039
+ }], ctorParameters: function () { return [{ type: SmartSessionService }, { type: SmartViewContextService }]; } });
2040
+
2041
+ class SmartDevToolService {
2042
+ constructor(cookieService) {
2043
+ this.cookieService = cookieService;
2044
+ this.smartDevToolName = "smartDevTool";
2045
+ this.isSmartDevToolActiveName = "smartDevToolActive";
2046
+ this.isActive = false;
2047
+ this.smartDevToolHoursName = "smartDevToolHours";
2048
+ this.smartDevToolMaxName = "smartDevToolMaxCalls";
2049
+ this.hoursToSave = 1;
2050
+ this.maxNumOfSavedCalls = 50;
2051
+ this.descriptorChanged = new Subject();
2052
+ this.newErrorsCount = 0;
2053
+ this.newErrorsCountChanged = new Subject();
2054
+ this.setUpLocalStorage();
2055
+ let apiCallsFromLocalStorage = localStorage.getItem(this.smartDevToolName);
2056
+ if (apiCallsFromLocalStorage) {
2057
+ this.descriptor = JSON.parse(apiCallsFromLocalStorage);
2058
+ }
2059
+ else {
2060
+ this.descriptor = { apiCalls: [] };
2061
+ this.save();
2062
+ }
2063
+ window.addEventListener("storage", (event) => {
2064
+ if (event.storageArea === localStorage) {
2065
+ this.isActive = localStorage.getItem(this.isSmartDevToolActiveName) === "true";
2066
+ let hoursToSaveString = localStorage.getItem(this.smartDevToolHoursName);
2067
+ if (hoursToSaveString) {
2068
+ this.hoursToSave = Number.parseInt(hoursToSaveString);
2069
+ }
2070
+ let maxNumOfSavedCalls = localStorage.getItem(this.smartDevToolMaxName);
2071
+ if (maxNumOfSavedCalls) {
2072
+ this.maxNumOfSavedCalls = Number.parseInt(maxNumOfSavedCalls);
2073
+ }
2074
+ }
2075
+ });
2076
+ }
2077
+ setUpLocalStorage() {
2078
+ let keysOfLocalStorage = Object.keys(localStorage);
2079
+ if (!keysOfLocalStorage.includes(this.isSmartDevToolActiveName)) {
2080
+ localStorage.setItem(this.isSmartDevToolActiveName, "true");
2081
+ }
2082
+ }
2083
+ writeResponse(request, response, requestDate, responseDate) {
2084
+ this.sanitizeByLength();
2085
+ this.sanitizeByTime();
2086
+ let requestHeader = this.createObject(request.headers.keys(), request.headers, false);
2087
+ let responseHeader = this.createObject(response.headers.keys(), response.headers, false);
2088
+ let _localStorage = this.createObject(Object.keys(localStorage).filter((key) => key !== this.smartDevToolName), localStorage, true);
2089
+ let _sessionStorage = this.createObject(Object.keys(sessionStorage), sessionStorage, true);
2090
+ let _cookies = this.cookieService.getAll();
2091
+ this.descriptor.apiCalls = [
2092
+ {
2093
+ url: response.url,
2094
+ requestBody: request.body,
2095
+ requestHeader,
2096
+ requestDate,
2097
+ requestMethod: request.method,
2098
+ responseBody: response.body ?? null,
2099
+ responseHeader,
2100
+ responseStatus: response.status,
2101
+ responseStatusText: response.statusText,
2102
+ responseDate,
2103
+ localStorage: _localStorage,
2104
+ sessionStorage: _sessionStorage,
2105
+ cookies: _cookies,
2106
+ },
2107
+ ...this.descriptor.apiCalls,
2108
+ ];
2109
+ if (response.status !== 200) {
2110
+ this.newErrorsCount++;
2111
+ this.newErrorsCountChanged.next();
2112
+ }
2113
+ this.save();
2114
+ }
2115
+ clearErrors() {
2116
+ this.newErrorsCount = 0;
2117
+ this.newErrorsCountChanged.next();
2118
+ }
2119
+ createObject(keys, mapWithValues, useGetItem) {
2120
+ let newObject = {};
2121
+ keys.forEach((key) => {
2122
+ if (useGetItem) {
2123
+ newObject[key] = mapWithValues.getItem(key);
2124
+ }
2125
+ else {
2126
+ newObject[key] = mapWithValues.get(key);
2127
+ }
2128
+ });
2129
+ return newObject;
2130
+ }
2131
+ sanitizeByTime() {
2132
+ let now = new Date();
2133
+ this.descriptor.apiCalls = this.descriptor.apiCalls.filter((apiCall) => {
2134
+ let hoursBetween;
2135
+ if (typeof apiCall.requestDate === "string") {
2136
+ hoursBetween = Math.floor(Math.abs(now.getMilliseconds() - new Date(apiCall.requestDate).getMilliseconds()) / 36e5);
2137
+ }
2138
+ else {
2139
+ hoursBetween = Math.floor(Math.abs(now.getMilliseconds() - apiCall.requestDate.getMilliseconds()) /
2140
+ 36e5);
2141
+ }
2142
+ return hoursBetween < this.hoursToSave;
2143
+ });
2144
+ }
2145
+ sanitizeByLength() {
2146
+ if (this.descriptor?.apiCalls &&
2147
+ this.descriptor.apiCalls.length > this.maxNumOfSavedCalls) {
2148
+ let length = this.descriptor.apiCalls.length;
2149
+ this.descriptor.apiCalls.splice(this.maxNumOfSavedCalls - 1, length - this.maxNumOfSavedCalls);
2150
+ }
2151
+ }
2152
+ save() {
2153
+ try {
2154
+ localStorage.setItem(this.smartDevToolName, JSON.stringify(this.descriptor));
2155
+ this.descriptorChanged.next();
2156
+ }
2157
+ catch (error) {
2158
+ // localStorage.setItem() throws a "QuotaExceededError" DOMException exception if the new value
2159
+ // couldn't be set. (Setting could fail if, e.g., the user has disabled storage for the site,
2160
+ // or if the quota has been exceeded.)
2161
+ this.sanitizeByLength();
2162
+ this.save();
2163
+ }
2164
+ }
2165
+ clear() {
2166
+ this.descriptor = {
2167
+ apiCalls: [],
2168
+ };
2169
+ this.save();
2170
+ }
2171
+ getPureString() {
2172
+ return localStorage.getItem(this.smartDevToolName);
2173
+ }
2174
+ }
2175
+ SmartDevToolService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartDevToolService, deps: [{ token: SmartCookieService }], target: i0.ɵɵFactoryTarget.Injectable });
2176
+ SmartDevToolService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartDevToolService, providedIn: "root" });
2177
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartDevToolService, decorators: [{
2178
+ type: Injectable,
2179
+ args: [{
2180
+ providedIn: "root",
2181
+ }]
2182
+ }], ctorParameters: function () { return [{ type: SmartCookieService }]; } });
2183
+ class SmartDevToolDatePipe extends DatePipe {
2184
+ transform(value, format = "yyyy.MM.dd. H:mm:ss") {
2185
+ return super.transform(value, format);
2186
+ }
2187
+ }
2188
+ SmartDevToolDatePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartDevToolDatePipe, deps: null, target: i0.ɵɵFactoryTarget.Pipe });
2189
+ SmartDevToolDatePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartDevToolDatePipe, name: "smartDevToolDatePipe" });
2190
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartDevToolDatePipe, decorators: [{
2191
+ type: Pipe,
2192
+ args: [{
2193
+ name: "smartDevToolDatePipe",
2194
+ }]
2195
+ }] });
2196
+
2197
+ class SmartDevToolDialogService extends SmartdialogService {
2198
+ constructor(dialog, router, service) {
2199
+ super(dialog, router);
2200
+ this.service = service;
2201
+ this.update = this.service.descriptorChanged;
2202
+ }
2203
+ handleAfterClosed(result) { }
2204
+ openDialog() {
2205
+ const dialogData = {
2206
+ content: {
2207
+ title: ''
2208
+ },
2209
+ size: {},
2210
+ customComponent: SmartDevToolDialogComponent
2211
+ };
2212
+ this.createDialog(dialogData, SmartDevToolDialogComponent);
2213
+ }
2214
+ getData() {
2215
+ return this.service.descriptor;
2216
+ }
2217
+ getPureString() {
2218
+ return this.service.getPureString();
2219
+ }
2220
+ clear() {
2221
+ this.service.clear();
2222
+ }
2223
+ }
2224
+ SmartDevToolDialogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartDevToolDialogService, deps: [{ token: i1$1.MatDialog }, { token: i2$1.Router }, { token: SmartDevToolService }], target: i0.ɵɵFactoryTarget.Injectable });
2225
+ SmartDevToolDialogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartDevToolDialogService, providedIn: 'root' });
2226
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartDevToolDialogService, decorators: [{
2227
+ type: Injectable,
2228
+ args: [{
2229
+ providedIn: 'root'
2230
+ }]
2231
+ }], ctorParameters: function () { return [{ type: i1$1.MatDialog }, { type: i2$1.Router }, { type: SmartDevToolService }]; } });
2232
+
2233
+ class SmartDevToolDialogComponent {
2234
+ constructor(service) {
2235
+ this.service = service;
2236
+ this._destroy$ = new Subject();
2237
+ this.descriptor = this.service.getData();
2238
+ this.service.update.pipe(takeUntil(this._destroy$)).subscribe(() => {
2239
+ this.descriptor = this.service.getData();
2240
+ });
2241
+ this.service.service.clearErrors();
2242
+ }
2243
+ ngOnDestroy() {
2244
+ this._destroy$.next();
2245
+ }
2246
+ clear() {
2247
+ this.service.clear();
2248
+ }
2249
+ getBody(inp) {
2250
+ return this.syntaxHighlight(inp);
2251
+ }
2252
+ syntaxHighlight(json) {
2253
+ if (typeof json != 'string') {
2254
+ json = JSON.stringify(json, undefined, 2);
2255
+ }
2256
+ json = json.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
2257
+ return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
2258
+ var cls = 'number';
2259
+ if (/^"/.test(match)) {
2260
+ if (/:$/.test(match)) {
2261
+ cls = 'key';
2262
+ }
2263
+ else {
2264
+ cls = 'string';
2265
+ }
2266
+ }
2267
+ else if (/true|false/.test(match)) {
2268
+ cls = 'boolean';
2269
+ }
2270
+ else if (/null/.test(match)) {
2271
+ cls = 'null';
2272
+ }
2273
+ return '<span class="' + cls + '">' + match + '</span>';
2274
+ });
2275
+ }
2276
+ copy() {
2277
+ copyToClipboard({
2278
+ value: this.service.getPureString()
2279
+ });
2280
+ }
2281
+ close() {
2282
+ this.service.closeDialog();
2283
+ }
2284
+ }
2285
+ SmartDevToolDialogComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartDevToolDialogComponent, deps: [{ token: SmartDevToolDialogService }], target: i0.ɵɵFactoryTarget.Component });
2286
+ SmartDevToolDialogComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: SmartDevToolDialogComponent, selector: "app-smart-dev-tool-dialog", ngImport: i0, template: "<div class=\"smartDevToolDialogContainer\">\n <div class=\"header\">\n <h2>Developer tool</h2>\n <button mat-icon-button title=\"close\" (click)=\"close()\">\n <smart-icon icon=\"close\"></smart-icon>\n </button>\n </div>\n <div class=\"requestsContainer\">\n <mat-accordion multi>\n <mat-expansion-panel\n class=\"requestCard\"\n [ngClass]=\"apiCall.responseStatus === 200 ? '' : 'hasError'\"\n *ngFor=\"let apiCall of descriptor?.apiCalls; let i = index\"\n >\n <mat-expansion-panel-header>\n <mat-panel-title>\n <div class=\"titlePanel\">\n <span class=\"date\">\n {{ apiCall.responseDate | smartDevToolDatePipe }}\n </span>\n <span class=\"urlText\">\n {{ apiCall.url }}\n </span>\n <div [ngClass]=\"apiCall.requestMethod\">\n {{ apiCall.requestMethod }}\n </div>\n <div [ngClass]=\"'statusCode-' + apiCall.responseStatus.toString()[0]\">\n {{ apiCall.responseStatus }}\n </div>\n </div>\n </mat-panel-title>\n </mat-expansion-panel-header>\n\n <div>\n <div class=\"table\">\n <div class=\"row\">\n <div class=\"mainCol heading\">Request</div>\n <div class=\"mainCol heading\">Response</div>\n </div>\n <div class=\"row\">\n <div class=\"mainCol\">\n <div class=\"heading\">Date</div>\n <div class=\"data\">\n {{ apiCall.requestDate | smartDevToolDatePipe }}\n </div>\n </div>\n <div class=\"mainCol\">\n <div class=\"heading\">Date</div>\n <div class=\"data\">\n {{ apiCall.responseDate | smartDevToolDatePipe }}\n </div>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"mainCol\">\n <div class=\"heading\">Headers</div>\n </div>\n <div class=\"mainCol\">\n <div class=\"heading\">Headers</div>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"mainCol\">\n <pre\n *ngIf=\"apiCall.requestHeader\"\n class=\"data\"\n [innerHTML]=\"getBody(apiCall.requestHeader)\"\n ></pre>\n <div *ngIf=\"!apiCall.requestHeader\" class=\"data\">null</div>\n </div>\n <div class=\"mainCol\">\n <pre\n *ngIf=\"apiCall.responseHeader\"\n class=\"data\"\n [innerHTML]=\"getBody(apiCall.responseHeader)\"\n ></pre>\n <div *ngIf=\"!apiCall.responseHeader\" class=\"data\">null</div>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"mainCol\">\n <div class=\"heading\"></div>\n <div class=\"data\"></div>\n </div>\n <div class=\"mainCol\">\n <div class=\"heading\">Status</div>\n <div class=\"data\">\n {{ apiCall.responseStatus }}\n </div>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"mainCol\">\n <div class=\"heading\"></div>\n <div class=\"data\"></div>\n </div>\n <div class=\"mainCol\">\n <div class=\"heading\">Status text</div>\n <div class=\"data\">\n {{ apiCall.responseStatusText }}\n </div>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"mainCol\">\n <div class=\"heading\">Body</div>\n </div>\n <div class=\"mainCol\">\n <div class=\"heading\">Body</div>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"mainCol\">\n <pre\n *ngIf=\"apiCall.requestBody\"\n class=\"data\"\n [innerHTML]=\"getBody(apiCall.requestBody)\"\n ></pre>\n <div *ngIf=\"!apiCall.requestBody\" class=\"data\">null</div>\n </div>\n <div class=\"mainCol\">\n <pre\n *ngIf=\"apiCall.responseBody\"\n class=\"data\"\n [innerHTML]=\"getBody(apiCall.responseBody)\"\n ></pre>\n <div *ngIf=\"!apiCall.responseBody\" class=\"data\">null</div>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"mainCol\">\n <div class=\"heading\">Session Storage</div>\n </div>\n <div class=\"mainCol\">\n <div class=\"heading\">Local Storage</div>\n </div>\n <div class=\"mainCol\">\n <div class=\"heading\">Cookies</div>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"mainCol\">\n <pre\n *ngIf=\"apiCall.sessionStorage\"\n class=\"data\"\n [innerHTML]=\"getBody(apiCall.sessionStorage)\"\n ></pre>\n <div *ngIf=\"!apiCall.sessionStorage\" class=\"data\">null</div>\n </div>\n <div class=\"mainCol\">\n <pre\n *ngIf=\"apiCall.localStorage\"\n class=\"data\"\n [innerHTML]=\"getBody(apiCall.localStorage)\"\n ></pre>\n <div *ngIf=\"!apiCall.localStorage\" class=\"data\">null</div>\n </div>\n <div class=\"mainCol\">\n <pre\n *ngIf=\"apiCall.cookies\"\n class=\"data\"\n [innerHTML]=\"getBody(apiCall.cookies)\"\n ></pre>\n <div *ngIf=\"!apiCall.cookies\" class=\"data\">null</div>\n </div>\n </div>\n </div>\n </div>\n </mat-expansion-panel>\n </mat-accordion>\n </div>\n <div class=\"buttonsContainer\">\n <button color=\"primary\" mat-raised-button (click)=\"copy()\">Copy</button>\n <button color=\"warn\" mat-raised-button (click)=\"clear()\">Clear</button>\n </div>\n</div>\n", styles: [".smartDevToolDialogContainer{display:flex;flex-direction:column;gap:1rem;width:78vw;height:90vh}.header{display:flex;flex-direction:row;justify-content:space-between}.requestsContainer{display:flex;flex-direction:column;gap:1rem;flex:1;overflow:auto}.requestCard{background-color:var(--primary-lighter-color);padding:.5rem;border-radius:.5rem;display:flex;flex-direction:column}.table{display:flex;flex-direction:column;gap:.25rem}.row{display:flex;flex-direction:row;gap:1rem}.mainCol{flex:1;display:flex;flex-direction:row;gap:.5rem;overflow:auto}.heading{font-weight:700}.data{word-wrap:break-word}.buttonsContainer{display:flex;flex-direction:row;justify-content:space-between}pre{outline:1px solid #000;padding:5px;margin:5px}.string{color:green}.number{color:#ff8c00}.boolean{color:#00f}.null{color:#f0f}.key{color:red}@media only screen and (max-width: 1000px){.row{flex-direction:column;gap:.5rem}.mainCol{flex-direction:column;overflow-x:auto;overflow-y:visible;flex:auto}.requestCard h4{font-size:small;overflow:auto}.smartDevToolDialogContainer{width:calc(80vw - 3rem)}}.hasError{background-color:var(--warn-lighter-color)}.titlePanel{flex:1;display:flex;flex-direction:row;gap:1rem}.urlText{flex:1;text-decoration:underline}.PATCH{color:#d38042}.DELETE{color:#a41e22}.GET{color:#0f6ab4}.POST{color:#10a54a}.PUT{color:#c5862b}.HEAD{color:#ffd20f}.statusCode-2{color:#5fb442}.statusCode-3{color:#5970f6}.statusCode-4{color:#ec6762}.statusCode-5{color:#f2a63b}\n"], components: [{ type: i2.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i4$1.SmartIconComponent, selector: "smart-icon", inputs: ["icon", "color"] }, { type: i4$2.MatExpansionPanel, selector: "mat-expansion-panel", inputs: ["disabled", "expanded", "hideToggle", "togglePosition"], outputs: ["opened", "closed", "expandedChange", "afterExpand", "afterCollapse"], exportAs: ["matExpansionPanel"] }, { type: i4$2.MatExpansionPanelHeader, selector: "mat-expansion-panel-header", inputs: ["tabIndex", "expandedHeight", "collapsedHeight"] }], directives: [{ type: i4$2.MatAccordion, selector: "mat-accordion", inputs: ["multi", "hideToggle", "displayMode", "togglePosition"], exportAs: ["matAccordion"] }, { type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i5.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i4$2.MatExpansionPanelTitle, selector: "mat-panel-title" }, { type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], pipes: { "smartDevToolDatePipe": SmartDevToolDatePipe } });
2287
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartDevToolDialogComponent, decorators: [{
2288
+ type: Component,
2289
+ args: [{ selector: 'app-smart-dev-tool-dialog', template: "<div class=\"smartDevToolDialogContainer\">\n <div class=\"header\">\n <h2>Developer tool</h2>\n <button mat-icon-button title=\"close\" (click)=\"close()\">\n <smart-icon icon=\"close\"></smart-icon>\n </button>\n </div>\n <div class=\"requestsContainer\">\n <mat-accordion multi>\n <mat-expansion-panel\n class=\"requestCard\"\n [ngClass]=\"apiCall.responseStatus === 200 ? '' : 'hasError'\"\n *ngFor=\"let apiCall of descriptor?.apiCalls; let i = index\"\n >\n <mat-expansion-panel-header>\n <mat-panel-title>\n <div class=\"titlePanel\">\n <span class=\"date\">\n {{ apiCall.responseDate | smartDevToolDatePipe }}\n </span>\n <span class=\"urlText\">\n {{ apiCall.url }}\n </span>\n <div [ngClass]=\"apiCall.requestMethod\">\n {{ apiCall.requestMethod }}\n </div>\n <div [ngClass]=\"'statusCode-' + apiCall.responseStatus.toString()[0]\">\n {{ apiCall.responseStatus }}\n </div>\n </div>\n </mat-panel-title>\n </mat-expansion-panel-header>\n\n <div>\n <div class=\"table\">\n <div class=\"row\">\n <div class=\"mainCol heading\">Request</div>\n <div class=\"mainCol heading\">Response</div>\n </div>\n <div class=\"row\">\n <div class=\"mainCol\">\n <div class=\"heading\">Date</div>\n <div class=\"data\">\n {{ apiCall.requestDate | smartDevToolDatePipe }}\n </div>\n </div>\n <div class=\"mainCol\">\n <div class=\"heading\">Date</div>\n <div class=\"data\">\n {{ apiCall.responseDate | smartDevToolDatePipe }}\n </div>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"mainCol\">\n <div class=\"heading\">Headers</div>\n </div>\n <div class=\"mainCol\">\n <div class=\"heading\">Headers</div>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"mainCol\">\n <pre\n *ngIf=\"apiCall.requestHeader\"\n class=\"data\"\n [innerHTML]=\"getBody(apiCall.requestHeader)\"\n ></pre>\n <div *ngIf=\"!apiCall.requestHeader\" class=\"data\">null</div>\n </div>\n <div class=\"mainCol\">\n <pre\n *ngIf=\"apiCall.responseHeader\"\n class=\"data\"\n [innerHTML]=\"getBody(apiCall.responseHeader)\"\n ></pre>\n <div *ngIf=\"!apiCall.responseHeader\" class=\"data\">null</div>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"mainCol\">\n <div class=\"heading\"></div>\n <div class=\"data\"></div>\n </div>\n <div class=\"mainCol\">\n <div class=\"heading\">Status</div>\n <div class=\"data\">\n {{ apiCall.responseStatus }}\n </div>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"mainCol\">\n <div class=\"heading\"></div>\n <div class=\"data\"></div>\n </div>\n <div class=\"mainCol\">\n <div class=\"heading\">Status text</div>\n <div class=\"data\">\n {{ apiCall.responseStatusText }}\n </div>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"mainCol\">\n <div class=\"heading\">Body</div>\n </div>\n <div class=\"mainCol\">\n <div class=\"heading\">Body</div>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"mainCol\">\n <pre\n *ngIf=\"apiCall.requestBody\"\n class=\"data\"\n [innerHTML]=\"getBody(apiCall.requestBody)\"\n ></pre>\n <div *ngIf=\"!apiCall.requestBody\" class=\"data\">null</div>\n </div>\n <div class=\"mainCol\">\n <pre\n *ngIf=\"apiCall.responseBody\"\n class=\"data\"\n [innerHTML]=\"getBody(apiCall.responseBody)\"\n ></pre>\n <div *ngIf=\"!apiCall.responseBody\" class=\"data\">null</div>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"mainCol\">\n <div class=\"heading\">Session Storage</div>\n </div>\n <div class=\"mainCol\">\n <div class=\"heading\">Local Storage</div>\n </div>\n <div class=\"mainCol\">\n <div class=\"heading\">Cookies</div>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"mainCol\">\n <pre\n *ngIf=\"apiCall.sessionStorage\"\n class=\"data\"\n [innerHTML]=\"getBody(apiCall.sessionStorage)\"\n ></pre>\n <div *ngIf=\"!apiCall.sessionStorage\" class=\"data\">null</div>\n </div>\n <div class=\"mainCol\">\n <pre\n *ngIf=\"apiCall.localStorage\"\n class=\"data\"\n [innerHTML]=\"getBody(apiCall.localStorage)\"\n ></pre>\n <div *ngIf=\"!apiCall.localStorage\" class=\"data\">null</div>\n </div>\n <div class=\"mainCol\">\n <pre\n *ngIf=\"apiCall.cookies\"\n class=\"data\"\n [innerHTML]=\"getBody(apiCall.cookies)\"\n ></pre>\n <div *ngIf=\"!apiCall.cookies\" class=\"data\">null</div>\n </div>\n </div>\n </div>\n </div>\n </mat-expansion-panel>\n </mat-accordion>\n </div>\n <div class=\"buttonsContainer\">\n <button color=\"primary\" mat-raised-button (click)=\"copy()\">Copy</button>\n <button color=\"warn\" mat-raised-button (click)=\"clear()\">Clear</button>\n </div>\n</div>\n", styles: [".smartDevToolDialogContainer{display:flex;flex-direction:column;gap:1rem;width:78vw;height:90vh}.header{display:flex;flex-direction:row;justify-content:space-between}.requestsContainer{display:flex;flex-direction:column;gap:1rem;flex:1;overflow:auto}.requestCard{background-color:var(--primary-lighter-color);padding:.5rem;border-radius:.5rem;display:flex;flex-direction:column}.table{display:flex;flex-direction:column;gap:.25rem}.row{display:flex;flex-direction:row;gap:1rem}.mainCol{flex:1;display:flex;flex-direction:row;gap:.5rem;overflow:auto}.heading{font-weight:700}.data{word-wrap:break-word}.buttonsContainer{display:flex;flex-direction:row;justify-content:space-between}pre{outline:1px solid #000;padding:5px;margin:5px}.string{color:green}.number{color:#ff8c00}.boolean{color:#00f}.null{color:#f0f}.key{color:red}@media only screen and (max-width: 1000px){.row{flex-direction:column;gap:.5rem}.mainCol{flex-direction:column;overflow-x:auto;overflow-y:visible;flex:auto}.requestCard h4{font-size:small;overflow:auto}.smartDevToolDialogContainer{width:calc(80vw - 3rem)}}.hasError{background-color:var(--warn-lighter-color)}.titlePanel{flex:1;display:flex;flex-direction:row;gap:1rem}.urlText{flex:1;text-decoration:underline}.PATCH{color:#d38042}.DELETE{color:#a41e22}.GET{color:#0f6ab4}.POST{color:#10a54a}.PUT{color:#c5862b}.HEAD{color:#ffd20f}.statusCode-2{color:#5fb442}.statusCode-3{color:#5970f6}.statusCode-4{color:#ec6762}.statusCode-5{color:#f2a63b}\n"] }]
2290
+ }], ctorParameters: function () { return [{ type: SmartDevToolDialogService }]; } });
2291
+ const copyToClipboard = async ({ target, message, value }) => {
2292
+ try {
2293
+ let copyValue = '';
2294
+ if (!navigator.clipboard) {
2295
+ throw new Error("Browser don't have support for native clipboard.");
2296
+ }
2297
+ if (target) {
2298
+ const node = document.querySelector(target);
2299
+ if (!node || !node.textContent) {
2300
+ throw new Error('Element not found');
2301
+ }
2302
+ value = node.textContent;
2303
+ }
2304
+ if (value) {
2305
+ copyValue = value;
2306
+ }
2307
+ await navigator.clipboard.writeText(copyValue);
2308
+ }
2309
+ catch (error) {
2310
+ console.error(error.toString());
2311
+ }
2312
+ };
2313
+
2314
+ class SmartDevToolFloatingButtonComponent {
2315
+ constructor(service) {
2316
+ this.service = service;
2317
+ this._destroy$ = new Subject();
2318
+ this.adminKeyName = "useDevTool";
2319
+ this.isShown = false;
2320
+ this.errorsCount = "";
2321
+ this.service.service.newErrorsCountChanged.pipe(takeUntil(this._destroy$)).subscribe(() => {
2322
+ this.errorsCount = `${this.service.service.newErrorsCount > 0 ? this.service.service.newErrorsCount : ""}`;
2323
+ });
2324
+ window.addEventListener("storage", (event) => {
2325
+ if (event.storageArea === localStorage) {
2326
+ if (Object.keys(localStorage).includes(this.adminKeyName)) {
2327
+ this.isShown = localStorage.getItem(this.adminKeyName) === "true";
2328
+ }
2329
+ }
2330
+ });
2331
+ this.isShown = localStorage.getItem(this.adminKeyName) === "true";
2332
+ }
2333
+ ngOnDestroy() {
2334
+ this._destroy$.next();
2335
+ }
2336
+ openDevToolDialog() {
2337
+ this.service.openDialog();
2338
+ }
2339
+ }
2340
+ SmartDevToolFloatingButtonComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartDevToolFloatingButtonComponent, deps: [{ token: SmartDevToolDialogService }], target: i0.ɵɵFactoryTarget.Component });
2341
+ SmartDevToolFloatingButtonComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: SmartDevToolFloatingButtonComponent, selector: "smart-session-dev-tool", ngImport: i0, template: "<button\n *ngIf=\"isShown\"\n mat-fab\n [color]=\"errorsCount.length ? 'warn' : 'accent'\"\n class=\"floatingButton\"\n extended\n title=\"devTool\"\n (click)=\"openDevToolDialog()\"\n>\n <smart-icon color=\"white\" icon=\"developer_mode\"></smart-icon>\n {{ errorsCount }}\n</button>\n", styles: [".floatingButton{position:fixed;right:2rem;bottom:2rem}.mat-icon.mat-white{color:#fff}\n"], components: [{ type: i2.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i4$1.SmartIconComponent, selector: "smart-icon", inputs: ["icon", "color"] }], directives: [{ type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
2342
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartDevToolFloatingButtonComponent, decorators: [{
2343
+ type: Component,
2344
+ args: [{ selector: "smart-session-dev-tool", template: "<button\n *ngIf=\"isShown\"\n mat-fab\n [color]=\"errorsCount.length ? 'warn' : 'accent'\"\n class=\"floatingButton\"\n extended\n title=\"devTool\"\n (click)=\"openDevToolDialog()\"\n>\n <smart-icon color=\"white\" icon=\"developer_mode\"></smart-icon>\n {{ errorsCount }}\n</button>\n", styles: [".floatingButton{position:fixed;right:2rem;bottom:2rem}.mat-icon.mat-white{color:#fff}\n"] }]
2345
+ }], ctorParameters: function () { return [{ type: SmartDevToolDialogService }]; } });
2346
+
2347
+ class SmartDevToolInterceptor {
2348
+ constructor(service) {
2349
+ this.service = service;
2350
+ }
2351
+ intercept(request, next) {
2352
+ if (!this.service.isActive) {
2353
+ return next.handle(request);
2354
+ }
2355
+ let requestDate = new Date();
2356
+ return next.handle(request).pipe(map((event) => {
2357
+ if (event.type === HttpEventType.Response) {
2358
+ let responseDate = new Date();
2359
+ this.service.writeResponse(request, event, requestDate, responseDate);
2360
+ }
2361
+ return event;
2362
+ }));
2363
+ }
2364
+ }
2365
+ SmartDevToolInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartDevToolInterceptor, deps: [{ token: SmartDevToolService }], target: i0.ɵɵFactoryTarget.Injectable });
2366
+ SmartDevToolInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartDevToolInterceptor });
2367
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartDevToolInterceptor, decorators: [{
2368
+ type: Injectable
2369
+ }], ctorParameters: function () { return [{ type: SmartDevToolService }]; } });
2370
+ class SmartDevToolErrorInterceptor {
2371
+ constructor(service) {
2372
+ this.service = service;
2373
+ }
2374
+ intercept(request, next) {
2375
+ if (!this.service.isActive) {
2376
+ return next.handle(request);
2377
+ }
2378
+ let requestDate = new Date();
2379
+ return next.handle(request).pipe(catchError((error) => {
2380
+ if (error.status !== 200) {
2381
+ let responseDate = new Date();
2382
+ this.service.writeResponse(request, error, requestDate, responseDate);
2383
+ }
2384
+ return throwError(error);
2385
+ }));
2386
+ }
2387
+ }
2388
+ SmartDevToolErrorInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartDevToolErrorInterceptor, deps: [{ token: SmartDevToolService }], target: i0.ɵɵFactoryTarget.Injectable });
2389
+ SmartDevToolErrorInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartDevToolErrorInterceptor });
2390
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartDevToolErrorInterceptor, decorators: [{
2391
+ type: Injectable
2392
+ }], ctorParameters: function () { return [{ type: SmartDevToolService }]; } });
2393
+
2394
+ var SessionErrorBehaviour;
2395
+ (function (SessionErrorBehaviour) {
2396
+ SessionErrorBehaviour[SessionErrorBehaviour["REFRESH"] = 0] = "REFRESH";
2397
+ SessionErrorBehaviour[SessionErrorBehaviour["RESTART"] = 1] = "RESTART";
2398
+ })(SessionErrorBehaviour || (SessionErrorBehaviour = {}));
2399
+
2400
+ class SmartSessionTimerService {
2401
+ constructor(session) {
2402
+ this.session = session;
2403
+ this._destroy$ = new Subject();
2404
+ this.totalTimeInMinutes = 30;
2405
+ this.sessionExpiration = "sessionExpiracy";
2406
+ this.timeChanged = new Subject();
2407
+ this.onTimerExpired = new Subject();
2408
+ this.session.sessionExpiracyChanged.pipe(takeUntil(this._destroy$)).subscribe(() => {
2409
+ this.restart();
2410
+ });
2411
+ }
2412
+ ngOnDestroy() {
2413
+ this._destroy$.next();
2414
+ this._destroy$.complete();
2415
+ }
2416
+ startTimer() {
2417
+ let sessionInfoData = this.session.sessionInfoData;
2418
+ let expiration = new Date(sessionInfoData.expiration);
2419
+ let now = new Date();
2420
+ this.timeLeftInSeconds = Math.floor((expiration.getTime() - now.getTime()) / 1000);
2421
+ this.timer = setInterval(() => {
2422
+ this.timeLeftInSeconds--;
2423
+ if (this.timeLeftInSeconds === 0) {
2424
+ this.timeout();
2425
+ }
2426
+ this.timeChanged.next();
2427
+ }, 1000);
2428
+ }
2429
+ restart() {
2430
+ clearInterval(this.timer);
2431
+ this.startTimer();
2432
+ }
2433
+ timeout() {
2434
+ clearInterval(this.timer);
2435
+ this.onTimerExpired.next();
2436
+ }
2437
+ }
2438
+ SmartSessionTimerService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartSessionTimerService, deps: [{ token: SmartSessionService }], target: i0.ɵɵFactoryTarget.Injectable });
2439
+ SmartSessionTimerService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartSessionTimerService, providedIn: "root" });
2440
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartSessionTimerService, decorators: [{
2441
+ type: Injectable,
2442
+ args: [{
2443
+ providedIn: "root",
2444
+ }]
2445
+ }], ctorParameters: function () { return [{ type: SmartSessionService }]; } });
2446
+
2447
+ class SmartSessionTimerComponent {
2448
+ constructor(service) {
2449
+ this.service = service;
2450
+ this._destroy$ = new Subject();
2451
+ }
2452
+ ngOnInit() {
2453
+ this.service.startTimer();
2454
+ this.timeInSeconds = this.service.timeLeftInSeconds;
2455
+ this.service.timeChanged.pipe(takeUntil(this._destroy$)).subscribe(() => {
2456
+ this.timeInSeconds = this.service.timeLeftInSeconds;
2457
+ });
2458
+ }
2459
+ ngOnDestroy() {
2460
+ this._destroy$.next();
2461
+ this._destroy$.complete();
2462
+ }
2463
+ formatTime(seconds) {
2464
+ let minutes = Math.floor(seconds / 60);
2465
+ let remainingSeconds = seconds % 60;
2466
+ return `${minutes}:${remainingSeconds < 10 ? "0" : ""}${remainingSeconds}`;
2467
+ }
2468
+ }
2469
+ SmartSessionTimerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartSessionTimerComponent, deps: [{ token: SmartSessionTimerService }], target: i0.ɵɵFactoryTarget.Component });
2470
+ SmartSessionTimerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: SmartSessionTimerComponent, selector: "smart-session-timer", providers: [SmartSessionTimerService], ngImport: i0, template: "<div class=\"smart-session-timer-container\">\n <span class=\"smart-session-timer\" *ngIf=\"timeInSeconds\">\n {{ formatTime(timeInSeconds!) }}\n </span>\n</div>\n", styles: [""], directives: [{ type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
2471
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartSessionTimerComponent, decorators: [{
2472
+ type: Component,
2473
+ args: [{ selector: "smart-session-timer", providers: [SmartSessionTimerService], template: "<div class=\"smart-session-timer-container\">\n <span class=\"smart-session-timer\" *ngIf=\"timeInSeconds\">\n {{ formatTime(timeInSeconds!) }}\n </span>\n</div>\n", styles: [""] }]
2474
+ }], ctorParameters: function () { return [{ type: SmartSessionTimerService }]; } });
2475
+
2476
+ /*
2477
+ * Public API Surface of smart-session
2478
+ */
2479
+
2480
+ class SmartErrorCatchingInterceptor {
2481
+ constructor(session) {
2482
+ this.session = session;
2483
+ this.sessionErrorCodes = [
2484
+ {
2485
+ code: "session.expired",
2486
+ behaviour: SessionErrorBehaviour.REFRESH,
2487
+ },
2488
+ {
2489
+ code: "session.refreshtoken.invalid",
2490
+ behaviour: SessionErrorBehaviour.RESTART,
2491
+ },
2492
+ {
2493
+ code: "session.badrequest.missingtoken",
2494
+ behaviour: SessionErrorBehaviour.RESTART,
2495
+ },
2496
+ {
2497
+ code: "session.security.nocontext",
2498
+ behaviour: SessionErrorBehaviour.RESTART,
2499
+ },
2500
+ {
2501
+ code: "session.invalidsessionuri",
2502
+ behaviour: SessionErrorBehaviour.RESTART,
2503
+ },
2504
+ {
2505
+ code: "session.notinitialized",
2506
+ behaviour: SessionErrorBehaviour.RESTART,
2507
+ },
2508
+ {
2509
+ code: "session.viewcontext.missing",
2510
+ behaviour: SessionErrorBehaviour.RESTART,
2511
+ },
2512
+ ];
2513
+ }
2514
+ intercept(request, next) {
2515
+ return next.handle(request).pipe(catchError$1((error) => {
2516
+ if (error.status === 400 && error.error.code) {
2517
+ let sessionError = this.sessionErrorCodes.find((sessionError) => sessionError.code === error.error.code);
2518
+ if (sessionError) {
2519
+ return this.resolveError(sessionError).pipe(switchMap(() => {
2520
+ this.session.headerParams.map((headerParam) => {
2521
+ request = request.clone({
2522
+ headers: request.headers.set(headerParam.headerName, headerParam.value),
2523
+ });
2524
+ });
2525
+ return next.handle(request);
2526
+ }));
2527
+ }
2528
+ }
2529
+ return throwError(error);
2530
+ }));
2531
+ }
2532
+ resolveError(sessionError) {
2533
+ if (sessionError.behaviour === SessionErrorBehaviour.RESTART) {
2534
+ return from(this.session.handleSessionError(sessionError));
2535
+ }
2536
+ return from(this.session.refreshSession());
2537
+ }
2538
+ }
2539
+ SmartErrorCatchingInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartErrorCatchingInterceptor, deps: [{ token: SmartSessionService }], target: i0.ɵɵFactoryTarget.Injectable });
2540
+ SmartErrorCatchingInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartErrorCatchingInterceptor });
2541
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartErrorCatchingInterceptor, decorators: [{
2542
+ type: Injectable
2543
+ }], ctorParameters: function () { return [{ type: SmartSessionService }]; } });
2544
+
2545
+ class SmartHeaderMaintainerInterceptor {
2546
+ constructor(session) {
2547
+ this.session = session;
2548
+ }
2549
+ intercept(request, next) {
2550
+ const hasHeaders = this.session.headerParams && this.session.headerParams.length;
2551
+ let headers = {};
2552
+ if (hasHeaders) {
2553
+ this.session.headerParams.map((headerParam) => {
2554
+ headers[headerParam.headerName] = headerParam.value;
2555
+ });
2556
+ }
2557
+ let url = request.urlWithParams.replace("http://localhost", this.session.getBasePath());
2558
+ // TODO fix me
2559
+ if (request.urlWithParams.includes("/kerb/sso")) {
2560
+ request = request.clone({
2561
+ url: url,
2562
+ });
2563
+ return next.handle(request);
2564
+ }
2565
+ request = request.clone({
2566
+ url: url,
2567
+ setHeaders: headers,
2568
+ });
2569
+ return next.handle(request);
2570
+ }
2571
+ }
2572
+ SmartHeaderMaintainerInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartHeaderMaintainerInterceptor, deps: [{ token: SmartSessionService }], target: i0.ɵɵFactoryTarget.Injectable });
2573
+ SmartHeaderMaintainerInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartHeaderMaintainerInterceptor });
2574
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartHeaderMaintainerInterceptor, decorators: [{
2575
+ type: Injectable
2576
+ }], ctorParameters: function () { return [{ type: SmartSessionService }]; } });
2577
+
2578
+ class SmartSessionModule {
2579
+ }
2580
+ SmartSessionModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartSessionModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2581
+ SmartSessionModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartSessionModule, declarations: [SmartDevToolDialogComponent,
2582
+ SmartDevToolFloatingButtonComponent,
2583
+ SmartDevToolDatePipe,
2584
+ SmartSessionTimerComponent], imports: [BrowserModule, MatCommonModule, MatExpansionModule, MatButtonModule, SmartIconModule], exports: [SmartDevToolFloatingButtonComponent, SmartSessionTimerComponent] });
2585
+ SmartSessionModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartSessionModule, providers: [
2586
+ SmartCookieService,
2587
+ SmartSessionService,
2588
+ SmartdialogModule,
2589
+ {
2590
+ provide: HTTP_INTERCEPTORS,
2591
+ useClass: SmartErrorCatchingInterceptor,
2592
+ multi: true,
2593
+ },
2594
+ {
2595
+ provide: HTTP_INTERCEPTORS,
2596
+ useClass: SmartHeaderMaintainerInterceptor,
2597
+ multi: true,
2598
+ },
2599
+ { provide: HTTP_INTERCEPTORS, useClass: SmartDevToolInterceptor, multi: true },
2600
+ { provide: HTTP_INTERCEPTORS, useClass: SmartDevToolErrorInterceptor, multi: true },
2601
+ ], imports: [[BrowserModule, MatCommonModule, MatExpansionModule, MatButtonModule, SmartIconModule]] });
2602
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartSessionModule, decorators: [{
2603
+ type: NgModule,
2604
+ args: [{
2605
+ declarations: [
2606
+ SmartDevToolDialogComponent,
2607
+ SmartDevToolFloatingButtonComponent,
2608
+ SmartDevToolDatePipe,
2609
+ SmartSessionTimerComponent,
2610
+ ],
2611
+ imports: [BrowserModule, MatCommonModule, MatExpansionModule, MatButtonModule, SmartIconModule],
2612
+ exports: [SmartDevToolFloatingButtonComponent, SmartSessionTimerComponent],
2613
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
2614
+ providers: [
2615
+ SmartCookieService,
2616
+ SmartSessionService,
2617
+ SmartdialogModule,
2618
+ {
2619
+ provide: HTTP_INTERCEPTORS,
2620
+ useClass: SmartErrorCatchingInterceptor,
2621
+ multi: true,
2622
+ },
2623
+ {
2624
+ provide: HTTP_INTERCEPTORS,
2625
+ useClass: SmartHeaderMaintainerInterceptor,
2626
+ multi: true,
2627
+ },
2628
+ { provide: HTTP_INTERCEPTORS, useClass: SmartDevToolInterceptor, multi: true },
2629
+ { provide: HTTP_INTERCEPTORS, useClass: SmartDevToolErrorInterceptor, multi: true },
2630
+ ],
2631
+ }]
2632
+ }] });
2633
+
2634
+ class SmartViewContextErrorDialogService extends SmartdialogService {
2635
+ constructor(dialog, router, viewContext) {
2636
+ super(dialog, router);
2637
+ this.viewContext = viewContext;
2638
+ }
2639
+ handleAfterClosed(result) { }
2640
+ openDialog() {
2641
+ const dialogData = {
2642
+ content: {
2643
+ title: "",
2644
+ },
2645
+ size: {},
2646
+ customComponent: SmartViewContextErrorDialogComponent,
2647
+ };
2648
+ this.createDialog(dialogData, SmartViewContextErrorDialogComponent);
2649
+ }
2650
+ getSmartViewContextApiError() {
2651
+ if (this.viewApiError?.code) {
2652
+ return this.viewContext.getSmartViewContextApiErrorByCode(this.viewApiError.code);
2653
+ }
2654
+ return {
2655
+ code: this.viewApiError?.code ?? "",
2656
+ message: this.viewApiError?.message ?? "An error has occured",
2657
+ buttonLabel: "Ok",
2658
+ dialogTitle: "Hiba",
2659
+ };
2660
+ }
2661
+ }
2662
+ SmartViewContextErrorDialogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextErrorDialogService, deps: [{ token: i1$1.MatDialog }, { token: i2$1.Router }, { token: SmartViewContextService }], target: i0.ɵɵFactoryTarget.Injectable });
2663
+ SmartViewContextErrorDialogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextErrorDialogService, providedIn: "root" });
2664
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextErrorDialogService, decorators: [{
2665
+ type: Injectable,
2666
+ args: [{
2667
+ providedIn: "root",
2668
+ }]
2669
+ }], ctorParameters: function () { return [{ type: i1$1.MatDialog }, { type: i2$1.Router }, { type: SmartViewContextService }]; } });
2670
+
2671
+ class SmartViewContextErrorDialogComponent {
2672
+ constructor(service) {
2673
+ this.service = service;
2674
+ this.smartViewContextApiError = this.service.getSmartViewContextApiError();
2675
+ }
2676
+ ngOnInit() { }
2677
+ onActionClick() {
2678
+ if (this.smartViewContextApiError.customAction) {
2679
+ this.smartViewContextApiError.customAction();
2680
+ }
2681
+ this.service.closeDialog();
2682
+ }
2683
+ }
2684
+ SmartViewContextErrorDialogComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextErrorDialogComponent, deps: [{ token: SmartViewContextErrorDialogService }], target: i0.ɵɵFactoryTarget.Component });
2685
+ SmartViewContextErrorDialogComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: SmartViewContextErrorDialogComponent, selector: "lib-smart-view-context-error-dialog", ngImport: i0, template: "<div class=\"container\">\n <h3 class=\"color-accent-700\">\n {{ smartViewContextApiError.dialogTitle }}\n </h3>\n <div class=\"content\">\n <p>\n {{ smartViewContextApiError.message }}\n </p>\n </div>\n <div class=\"buttonContainer\">\n <button mat-raised-button color=\"primary\" (click)=\"onActionClick()\">\n {{ smartViewContextApiError.buttonLabel }}\n </button>\n </div>\n</div>\n", styles: [".container{display:flex;flex-direction:column;gap:1em;min-width:25rem;max-width:50vw;height:auto;max-height:75vh}.content{flex:1;overflow:auto}.buttonContainer{display:flex;flex-direction:row;justify-content:flex-end}\n"], components: [{ type: i2.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }] });
2686
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextErrorDialogComponent, decorators: [{
2687
+ type: Component,
2688
+ args: [{ selector: "lib-smart-view-context-error-dialog", template: "<div class=\"container\">\n <h3 class=\"color-accent-700\">\n {{ smartViewContextApiError.dialogTitle }}\n </h3>\n <div class=\"content\">\n <p>\n {{ smartViewContextApiError.message }}\n </p>\n </div>\n <div class=\"buttonContainer\">\n <button mat-raised-button color=\"primary\" (click)=\"onActionClick()\">\n {{ smartViewContextApiError.buttonLabel }}\n </button>\n </div>\n</div>\n", styles: [".container{display:flex;flex-direction:column;gap:1em;min-width:25rem;max-width:50vw;height:auto;max-height:75vh}.content{flex:1;overflow:auto}.buttonContainer{display:flex;flex-direction:row;justify-content:flex-end}\n"] }]
2689
+ }], ctorParameters: function () { return [{ type: SmartViewContextErrorDialogService }]; } });
2690
+
2691
+ class SmartViewContextInterceptor {
2692
+ constructor(viewContextErrorDialog) {
2693
+ this.viewContextErrorDialog = viewContextErrorDialog;
2694
+ }
2695
+ intercept(request, next) {
2696
+ return next.handle(request).pipe(catchError((error) => {
2697
+ if (error.status === 409 &&
2698
+ (error.error.code || error.error.message)) {
2699
+ this.openErrorDialog(error.error);
2700
+ }
2701
+ return throwError(error);
2702
+ }));
2703
+ }
2704
+ openErrorDialog(viewApiError) {
2705
+ this.viewContextErrorDialog.viewApiError = viewApiError;
2706
+ this.viewContextErrorDialog.openDialog();
2707
+ }
2708
+ }
2709
+ SmartViewContextInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextInterceptor, deps: [{ token: SmartViewContextErrorDialogService }], target: i0.ɵɵFactoryTarget.Injectable });
2710
+ SmartViewContextInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextInterceptor });
2711
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextInterceptor, decorators: [{
2712
+ type: Injectable
2713
+ }], ctorParameters: function () { return [{ type: SmartViewContextErrorDialogService }]; } });
2714
+
2715
+ class SmartViewRedirect {
2716
+ constructor(service, navigation, route) {
2717
+ this.service = service;
2718
+ this.navigation = navigation;
2719
+ this.route = route;
2720
+ this.navigation.route = this.route;
2721
+ this.navigation.subscribeToUrlChange((url) => {
2722
+ let channel = this.route.snapshot.paramMap.get(SmartLinkChannelVariableInPath);
2723
+ let uuid = this.route.snapshot.paramMap.get(SmartLinkUuidVariableInPath);
2724
+ if (!channel || !uuid) {
2725
+ throw new Error("channel or uuid is not reachable from the url!");
2726
+ }
2727
+ this.service.showPublishedView(channel, uuid);
2728
+ });
2729
+ }
2730
+ }
2731
+ SmartViewRedirect.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewRedirect, deps: [{ token: SmartViewContextService }, { token: i3$1.SmartNavigationService }, { token: i2$1.ActivatedRoute }], target: i0.ɵɵFactoryTarget.Component });
2732
+ SmartViewRedirect.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: SmartViewRedirect, selector: "app-redirect", ngImport: i0, template: "<div>Smart redirect</div>", isInline: true });
2733
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewRedirect, decorators: [{
2734
+ type: Component,
2735
+ args: [{
2736
+ selector: "app-redirect",
2737
+ template: "<div>Smart redirect</div>",
2738
+ }]
2739
+ }], ctorParameters: function () { return [{ type: SmartViewContextService }, { type: i3$1.SmartNavigationService }, { type: i2$1.ActivatedRoute }]; } });
2740
+ const SmartLinkChannelVariableInPath = "channel";
2741
+ const SmartLinkUuidVariableInPath = "uuid";
2742
+
2743
+ class UiActionDescriptorService {
2744
+ constructor(viewContext) {
2745
+ this.viewContext = viewContext;
2746
+ this._destroy$ = new Subject();
2747
+ this.languageChanged = new Subject();
2748
+ this.keysToTranslate = ["title", "text", "placeholder", "caption", "feedbackText"];
2749
+ this.basicActionDescriptors = new Map([
2750
+ [
2751
+ "UNKOWN",
2752
+ {
2753
+ title: "",
2754
+ type: UiActionButtonType.Normal,
2755
+ color: "accent",
2756
+ icon: "Question",
2757
+ iconColor: `text-primary`,
2758
+ iconPosition: UiActionButtonIconPos.Post,
2759
+ dialog: {
2760
+ title: "",
2761
+ placeholder: "placeholder",
2762
+ actionButton: {
2763
+ caption: "",
2764
+ color: "accent",
2765
+ },
2766
+ cancelButton: {
2767
+ caption: "Mégse",
2768
+ color: "",
2769
+ },
2770
+ },
2771
+ },
2772
+ ],
2773
+ ]);
2774
+ if (this.viewContext.translateService) {
2775
+ this.subscribeToTranslateService();
2776
+ }
2777
+ else {
2778
+ this.viewContext.translateServiceChanged
2779
+ .pipe(takeUntil(this._destroy$))
2780
+ .subscribe(() => {
2781
+ this.subscribeToTranslateService();
2782
+ });
2783
+ }
2784
+ }
2785
+ ngOnDestroy() {
2786
+ this._destroy$.next();
2787
+ this._destroy$.complete();
2788
+ }
2789
+ subscribeToTranslateService() {
2790
+ this.viewContext
2791
+ .translateService.onLangChange.pipe(takeUntil(this._destroy$))
2792
+ .subscribe(() => {
2793
+ this.languageChanged.next();
2794
+ });
2795
+ }
2796
+ async getActionDescriptor(uiAction) {
2797
+ let code = uiAction.code;
2798
+ let actionDescriptorFromDescriptors = this.viewContext.getActionDescriptors()?.get(code);
2799
+ let actionDescriptor = JSON.parse(JSON.stringify(actionDescriptorFromDescriptors));
2800
+ if (!actionDescriptor) {
2801
+ actionDescriptor = this.basicActionDescriptors.get("UNKOWN");
2802
+ actionDescriptor.title = code;
2803
+ }
2804
+ if (!actionDescriptor.dialog) {
2805
+ actionDescriptor = this.setUpUnkownDialogDescriptor(code, actionDescriptor, "dialog");
2806
+ }
2807
+ if (!actionDescriptor.feedbackType && uiAction.submit) {
2808
+ actionDescriptor.feedbackType = UiActionFeedbackType.Snackbar;
2809
+ }
2810
+ if (this.viewContext.translateService && actionDescriptor) {
2811
+ actionDescriptor = await this.translateUiActionDescriptor(actionDescriptor);
2812
+ }
2813
+ return actionDescriptor;
2814
+ }
2815
+ async translateUiActionDescriptor(uiActionDescriptor) {
2816
+ uiActionDescriptor = await this.deepTranslate(uiActionDescriptor);
2817
+ return uiActionDescriptor;
2818
+ }
2819
+ async deepTranslate(model) {
2820
+ Object.keys(model).map(async (key) => {
2821
+ if (model[key] !== undefined &&
2822
+ typeof model[key] === "string" &&
2823
+ model[key].length &&
2824
+ this.keysToTranslate.includes(key)) {
2825
+ model[key] = await this.viewContext.translateService.get(model[key]).toPromise();
2826
+ }
2827
+ else if (model[key] !== undefined && typeof model[key] === "object") {
2828
+ model[key] = await this.deepTranslate(model[key]);
2829
+ }
2830
+ return model;
2831
+ });
2832
+ return model;
2833
+ }
2834
+ setUpUnkownDialogDescriptor(code, uiActionDescriptor, dialogType) {
2835
+ let unkownDescriptor = this.basicActionDescriptors.get("UNKOWN");
2836
+ uiActionDescriptor[dialogType] = unkownDescriptor.dialog;
2837
+ uiActionDescriptor[dialogType].title = code;
2838
+ uiActionDescriptor[dialogType].actionButton.caption = code;
2839
+ return uiActionDescriptor;
2840
+ }
2841
+ }
2842
+ UiActionDescriptorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionDescriptorService, deps: [{ token: SmartViewContextService }], target: i0.ɵɵFactoryTarget.Injectable });
2843
+ UiActionDescriptorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionDescriptorService, providedIn: "root" });
2844
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionDescriptorService, decorators: [{
2845
+ type: Injectable,
2846
+ args: [{
2847
+ providedIn: "root",
2848
+ }]
2849
+ }], ctorParameters: function () { return [{ type: SmartViewContextService }]; } });
2850
+
2851
+ class SuccessSnackBarComponent {
2852
+ constructor(data, viewContext, manager) {
2853
+ this.data = data;
2854
+ this.viewContext = viewContext;
2855
+ this.manager = manager;
2856
+ this.manager.getActionDescriptor(data).then((descriptor) => {
2857
+ if (descriptor.feedbackText) {
2858
+ this.text = descriptor.feedbackText;
2859
+ }
2860
+ else {
2861
+ this.text = this.viewContext.commonFeedbackText ?? "A mentés sikeres volt!";
2862
+ }
2863
+ });
2864
+ }
2865
+ }
2866
+ SuccessSnackBarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SuccessSnackBarComponent, deps: [{ token: MAT_SNACK_BAR_DATA }, { token: SmartViewContextService }, { token: UiActionDescriptorService }], target: i0.ɵɵFactoryTarget.Component });
2867
+ SuccessSnackBarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: SuccessSnackBarComponent, selector: "app-success-snack-bar", ngImport: i0, template: "<span class=\"successSnakBarContainer\" matSnackBarLabel> {{ text }} </span>\n", styles: ["::ng-deep .mat-snack-bar-container{text-align:center;border-radius:2rem}.successSnakBarContainer{color:#fff}\n"] });
2868
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SuccessSnackBarComponent, decorators: [{
2869
+ type: Component,
2870
+ args: [{ selector: "app-success-snack-bar", template: "<span class=\"successSnakBarContainer\" matSnackBarLabel> {{ text }} </span>\n", styles: ["::ng-deep .mat-snack-bar-container{text-align:center;border-radius:2rem}.successSnakBarContainer{color:#fff}\n"] }]
2871
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
2872
+ type: Inject,
2873
+ args: [MAT_SNACK_BAR_DATA]
2874
+ }] }, { type: SmartViewContextService }, { type: UiActionDescriptorService }]; } });
2875
+
2876
+ class UiActionConfirmDialogComponent {
2877
+ constructor(service, manager) {
2878
+ this.service = service;
2879
+ this.manager = manager;
2880
+ this.code = this.service.action.code;
2881
+ this.setUp();
2882
+ }
2883
+ async setUp() {
2884
+ this.descriptor = await this.manager.getActionDescriptor(this.service.action);
2885
+ this.dialogType = this.descriptor.confirmDialog ? "confirmDialog" : "dialog";
2886
+ }
2887
+ ngOnDestroy() {
2888
+ this.service._destroy$.next();
2889
+ this.cancel();
2890
+ }
2891
+ getTitle() {
2892
+ return this.descriptor[this.dialogType].title;
2893
+ }
2894
+ getText() {
2895
+ return this.descriptor[this.dialogType].text ?? "";
2896
+ }
2897
+ getActionButtonLabel() {
2898
+ return this.descriptor[this.dialogType].actionButton.caption;
2899
+ }
2900
+ getActionButtonColor() {
2901
+ return this.descriptor[this.dialogType].actionButton.color;
2902
+ }
2903
+ getCancelButtonLabel() {
2904
+ return this.descriptor[this.dialogType].cancelButton.caption;
2905
+ }
2906
+ getCancelButtonColor() {
2907
+ return this.descriptor[this.dialogType].cancelButton.color;
2908
+ }
2909
+ doAction() {
2910
+ this.service.doAction();
2911
+ }
2912
+ cancel() {
2913
+ this.service.cancel();
2914
+ }
2915
+ }
2916
+ UiActionConfirmDialogComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionConfirmDialogComponent, deps: [{ token: UiActionConfirmDialogService }, { token: UiActionDescriptorService }], target: i0.ɵɵFactoryTarget.Component });
2917
+ UiActionConfirmDialogComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: UiActionConfirmDialogComponent, selector: "app-ui-action-confirm-dialog", ngImport: i0, template: "<div class=\"folderNameDialogContainer\">\n\t<div class=\"headerContainer\">\n\t\t<h3 class=\"color-accent-700\">\n\t\t\t{{ getTitle() }}\n\t\t</h3>\n\t\t<button mat-icon-button title=\"close\" (click)=\"cancel()\">\n\t\t\t<smart-icon [color]=\"'primary'\" [icon]=\"'X'\"></smart-icon>\n\t\t</button>\n\t</div>\n\t<p>\n\t\t{{ getText() }}\n\t</p>\n\t<div class=\"folderNameDialogButtonsContainer\">\n\t\t<button mat-button color=\"accent\" [color]=\"getCancelButtonColor()\" (click)=\"cancel()\">\n\t\t\t{{ getCancelButtonLabel() }}\n\t\t</button>\n\t\t<button mat-raised-button [color]=\"getActionButtonColor()\" (click)=\"doAction()\">\n\t\t\t{{ getActionButtonLabel() }}\n\t\t</button>\n\t</div>\n</div>\n", styles: [".folderNameDialogContainer{width:25rem;display:flex;flex-direction:column;gap:1rem}.headerContainer{display:flex;flex-direction:row;justify-content:space-between}.headerContainer h3{margin:0}.folderNameDialogButtonsContainer{display:flex;flex-direction:row;justify-content:flex-end;gap:.5rem}\n"], components: [{ type: i2.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i4$1.SmartIconComponent, selector: "smart-icon", inputs: ["icon", "color"] }] });
2918
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionConfirmDialogComponent, decorators: [{
2919
+ type: Component,
2920
+ args: [{ selector: "app-ui-action-confirm-dialog", template: "<div class=\"folderNameDialogContainer\">\n\t<div class=\"headerContainer\">\n\t\t<h3 class=\"color-accent-700\">\n\t\t\t{{ getTitle() }}\n\t\t</h3>\n\t\t<button mat-icon-button title=\"close\" (click)=\"cancel()\">\n\t\t\t<smart-icon [color]=\"'primary'\" [icon]=\"'X'\"></smart-icon>\n\t\t</button>\n\t</div>\n\t<p>\n\t\t{{ getText() }}\n\t</p>\n\t<div class=\"folderNameDialogButtonsContainer\">\n\t\t<button mat-button color=\"accent\" [color]=\"getCancelButtonColor()\" (click)=\"cancel()\">\n\t\t\t{{ getCancelButtonLabel() }}\n\t\t</button>\n\t\t<button mat-raised-button [color]=\"getActionButtonColor()\" (click)=\"doAction()\">\n\t\t\t{{ getActionButtonLabel() }}\n\t\t</button>\n\t</div>\n</div>\n", styles: [".folderNameDialogContainer{width:25rem;display:flex;flex-direction:column;gap:1rem}.headerContainer{display:flex;flex-direction:row;justify-content:space-between}.headerContainer h3{margin:0}.folderNameDialogButtonsContainer{display:flex;flex-direction:row;justify-content:flex-end;gap:.5rem}\n"] }]
2921
+ }], ctorParameters: function () { return [{ type: UiActionConfirmDialogService }, { type: UiActionDescriptorService }]; } });
2922
+
2923
+ class UiActionConfirmDialogService extends SmartdialogService {
2924
+ constructor(dialog, router) {
2925
+ super(dialog, router);
2926
+ this._destroy$ = new Subject();
2927
+ this.onAction = new Subject();
2928
+ this.shouldDoAction = false;
2929
+ }
2930
+ openDialog() {
2931
+ this.shouldDoAction = false;
2932
+ this.onAction = new Subject();
2933
+ const dialogData = {
2934
+ content: {
2935
+ title: "",
2936
+ },
2937
+ size: {},
2938
+ customComponent: UiActionConfirmDialogComponent,
2939
+ };
2940
+ this.createDialog(dialogData, UiActionConfirmDialogComponent);
2941
+ }
2942
+ doAction() {
2943
+ this.shouldDoAction = true;
2944
+ this.onAction.complete();
2945
+ this.closeDialog();
2946
+ this.onAction = new Subject();
2947
+ }
2948
+ cancel() {
2949
+ this.onAction.complete();
2950
+ this.closeDialog();
2951
+ this.onAction = new Subject();
2952
+ }
2953
+ }
2954
+ UiActionConfirmDialogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionConfirmDialogService, deps: [{ token: i1$1.MatDialog }, { token: i2$1.Router }], target: i0.ɵɵFactoryTarget.Injectable });
2955
+ UiActionConfirmDialogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionConfirmDialogService, providedIn: "root" });
2956
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionConfirmDialogService, decorators: [{
2957
+ type: Injectable,
2958
+ args: [{
2959
+ providedIn: "root",
2960
+ }]
2961
+ }], ctorParameters: function () { return [{ type: i1$1.MatDialog }, { type: i2$1.Router }]; } });
2962
+
2963
+ class UiActionInputDialogComponent {
2964
+ constructor(service, manager) {
2965
+ this.service = service;
2966
+ this.manager = manager;
2967
+ this.code = this.service.action.code;
2968
+ this.setUp();
2969
+ }
2970
+ ngOnDestroy() {
2971
+ this.service._destroy$.next();
2972
+ this.cancel();
2973
+ }
2974
+ async setUp() {
2975
+ this.descriptor = await this.manager.getActionDescriptor(this.service.action);
2976
+ if (this.descriptor[this.service.inputTypeName]) {
2977
+ this.dialogType = this.service.inputTypeName;
2978
+ }
2979
+ else {
2980
+ this.dialogType = this.descriptor.inputDialog ? "inputDialog" : "dialog";
2981
+ }
2982
+ this.constructForm();
2983
+ }
2984
+ getTitle() {
2985
+ return this.descriptor[this.dialogType].title;
2986
+ }
2987
+ getActionButtonLabel() {
2988
+ return this.descriptor[this.dialogType].actionButton.caption;
2989
+ }
2990
+ getActionButtonColor() {
2991
+ return this.descriptor[this.dialogType].actionButton.color;
2992
+ }
2993
+ getCancelButtonLabel() {
2994
+ return this.descriptor[this.dialogType].cancelButton.caption;
2995
+ }
2996
+ getCancelButtonColor() {
2997
+ return this.descriptor[this.dialogType].cancelButton.color;
2998
+ }
2999
+ constructForm() {
3000
+ let model = {};
3001
+ let inputName;
3002
+ if (this.service.inputTypeName === "inputDialog") {
3003
+ inputName = "input";
3004
+ }
3005
+ else {
3006
+ inputName = "input2";
3007
+ }
3008
+ if (this.service.nodeName) {
3009
+ model[inputName] = this.service.nodeName;
3010
+ }
3011
+ else {
3012
+ model[inputName] = "";
3013
+ }
3014
+ let type;
3015
+ let inputType = `${inputName}Type`;
3016
+ if (this.service.action[inputType] === UiActionInputType.Textfield) {
3017
+ type = SmartFormWidgetType.TEXT_FIELD;
3018
+ }
3019
+ else {
3020
+ type = SmartFormWidgetType.TEXT_BOX;
3021
+ }
3022
+ this.folderForm = {
3023
+ direction: SmartFormWidgetDirection.COL,
3024
+ model,
3025
+ widgets: [
3026
+ {
3027
+ key: inputName,
3028
+ label: "",
3029
+ type,
3030
+ value: "",
3031
+ validators: [
3032
+ {
3033
+ validator: Validators.required,
3034
+ name: SmartValidatorName.required,
3035
+ errorMessage: "Ez a mező kötelező",
3036
+ },
3037
+ ],
3038
+ placeholder: this.descriptor[this.dialogType].placeholder ?? "",
3039
+ showLabel: true,
3040
+ },
3041
+ ],
3042
+ };
3043
+ }
3044
+ save() {
3045
+ let form = this.folderFormChild.submitForm();
3046
+ if (form.invalidFields) {
3047
+ throw new Error("The form is invalid!");
3048
+ }
3049
+ this.service.onSave(form.model);
3050
+ }
3051
+ cancel() {
3052
+ this.service.cancel();
3053
+ }
3054
+ }
3055
+ UiActionInputDialogComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionInputDialogComponent, deps: [{ token: UiActionInputDialogService }, { token: UiActionDescriptorService }], target: i0.ɵɵFactoryTarget.Component });
3056
+ UiActionInputDialogComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: UiActionInputDialogComponent, selector: "smart-ui-action-input-dialog", viewQueries: [{ propertyName: "folderFormChild", first: true, predicate: ["form"], descendants: true }], ngImport: i0, template: "<div class=\"folderNameDialogContainer\">\n\t<div class=\"headerContainer\">\n\t\t<h3 class=\"color-accent-700\">\n\t\t\t{{ getTitle() }}\n\t\t</h3>\n\t\t<button mat-icon-button title=\"close\" (click)=\"cancel()\">\n\t\t\t<smart-icon [color]=\"'primary'\" [icon]=\"'X'\"></smart-icon>\n\t\t</button>\n\t</div>\n\t<smartform #form [smartForm]=\"folderForm\"></smartform>\n\t<div class=\"folderNameDialogButtonsContainer\">\n\t\t<button mat-button color=\"accent\" [color]=\"getCancelButtonColor()\" (click)=\"cancel()\">\n\t\t\t{{ getCancelButtonLabel() }}\n\t\t</button>\n\t\t<button mat-raised-button [color]=\"getActionButtonColor()\" (click)=\"save()\">\n\t\t\t{{ getActionButtonLabel() }}\n\t\t</button>\n\t</div>\n</div>\n", styles: [".folderNameDialogContainer{width:25rem;display:flex;flex-direction:column;gap:1rem}.headerContainer{display:flex;flex-direction:row;justify-content:space-between}.headerContainer h3{margin:0}.folderNameDialogButtonsContainer{display:flex;flex-direction:row;justify-content:flex-end;gap:.5rem}\n"], components: [{ type: i2.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i4$1.SmartIconComponent, selector: "smart-icon", inputs: ["icon", "color"] }, { type: i5$1.SmartformComponent, selector: "smartform", inputs: ["smartForm"] }] });
3057
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionInputDialogComponent, decorators: [{
3058
+ type: Component,
3059
+ args: [{ selector: "smart-ui-action-input-dialog", template: "<div class=\"folderNameDialogContainer\">\n\t<div class=\"headerContainer\">\n\t\t<h3 class=\"color-accent-700\">\n\t\t\t{{ getTitle() }}\n\t\t</h3>\n\t\t<button mat-icon-button title=\"close\" (click)=\"cancel()\">\n\t\t\t<smart-icon [color]=\"'primary'\" [icon]=\"'X'\"></smart-icon>\n\t\t</button>\n\t</div>\n\t<smartform #form [smartForm]=\"folderForm\"></smartform>\n\t<div class=\"folderNameDialogButtonsContainer\">\n\t\t<button mat-button color=\"accent\" [color]=\"getCancelButtonColor()\" (click)=\"cancel()\">\n\t\t\t{{ getCancelButtonLabel() }}\n\t\t</button>\n\t\t<button mat-raised-button [color]=\"getActionButtonColor()\" (click)=\"save()\">\n\t\t\t{{ getActionButtonLabel() }}\n\t\t</button>\n\t</div>\n</div>\n", styles: [".folderNameDialogContainer{width:25rem;display:flex;flex-direction:column;gap:1rem}.headerContainer{display:flex;flex-direction:row;justify-content:space-between}.headerContainer h3{margin:0}.folderNameDialogButtonsContainer{display:flex;flex-direction:row;justify-content:flex-end;gap:.5rem}\n"] }]
3060
+ }], ctorParameters: function () { return [{ type: UiActionInputDialogService }, { type: UiActionDescriptorService }]; }, propDecorators: { folderFormChild: [{
3061
+ type: ViewChild,
3062
+ args: ["form"]
3063
+ }] } });
3064
+
3065
+ class UiActionInputDialogService extends SmartdialogService {
3066
+ constructor(dialog, router) {
3067
+ super(dialog, router);
3068
+ this._destroy$ = new Subject();
3069
+ this.onAction = new Subject();
3070
+ }
3071
+ setDataAndOpenDialog(action, nodeName) {
3072
+ this.action = action;
3073
+ this.nodeName = nodeName;
3074
+ this.openDialog();
3075
+ }
3076
+ openDialog() {
3077
+ this.params = undefined;
3078
+ this.onAction = new Subject();
3079
+ const dialogData = {
3080
+ content: {
3081
+ title: "",
3082
+ },
3083
+ size: {},
3084
+ customComponent: UiActionInputDialogComponent,
3085
+ };
3086
+ this.createDialog(dialogData, UiActionInputDialogComponent);
3087
+ }
3088
+ async onSave(params) {
3089
+ this.params = params;
3090
+ this.onAction.complete();
3091
+ this.closeDialog();
3092
+ this.onAction = new Subject();
3093
+ }
3094
+ cancel() {
3095
+ this.onAction.complete();
3096
+ this.closeDialog();
3097
+ this.onAction = new Subject();
3098
+ }
3099
+ }
3100
+ UiActionInputDialogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionInputDialogService, deps: [{ token: i1$1.MatDialog }, { token: i2$1.Router }], target: i0.ɵɵFactoryTarget.Injectable });
3101
+ UiActionInputDialogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionInputDialogService, providedIn: "root" });
3102
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionInputDialogService, decorators: [{
3103
+ type: Injectable,
3104
+ args: [{
3105
+ providedIn: "root",
3106
+ }]
3107
+ }], ctorParameters: function () { return [{ type: i1$1.MatDialog }, { type: i2$1.Router }]; } });
3108
+
3109
+ class UiActionService {
3110
+ constructor(confirmDialogService, textFieldDialogService, _snackBar) {
3111
+ this.confirmDialogService = confirmDialogService;
3112
+ this.textFieldDialogService = textFieldDialogService;
3113
+ this._snackBar = _snackBar;
3114
+ }
3115
+ async execute(uiAction) {
3116
+ let uiActionRequest;
3117
+ uiActionRequest = {
3118
+ code: uiAction.code,
3119
+ identifier: uiAction.identifier,
3120
+ params: uiAction.params ?? {},
3121
+ };
3122
+ if (uiAction.submit) {
3123
+ this.uiActionModel.serviceToUse.submit.next();
3124
+ try {
3125
+ await this.uiActionModel.serviceToUse.submit.toPromise();
3126
+ this.uiActionModel.serviceToUse.submit = new Subject();
3127
+ this.uiActionModel.serviceToUse.reSubscribeToChange.next();
3128
+ }
3129
+ catch (error) {
3130
+ console.error(error);
3131
+ this.uiActionModel.serviceToUse.submit = new Subject();
3132
+ this.uiActionModel.serviceToUse.reSubscribeToChange.next();
3133
+ return;
3134
+ }
3135
+ }
3136
+ if (uiAction.confirm) {
3137
+ this.confirmDialogService.action = uiAction;
3138
+ this.confirmDialogService.openDialog();
3139
+ await this.confirmDialogService.onAction.toPromise();
3140
+ if (!this.confirmDialogService.shouldDoAction) {
3141
+ return;
3142
+ }
3143
+ }
3144
+ // InputType
3145
+ if (uiAction.inputType) {
3146
+ uiActionRequest = await this.handleInputType(uiAction.inputType, uiAction, uiActionRequest, "inputDialog");
3147
+ if (!uiActionRequest) {
3148
+ return;
3149
+ }
3150
+ await new Promise((resolve) => setTimeout(resolve, 250));
3151
+ }
3152
+ // Input2Type
3153
+ if (uiAction.input2Type) {
3154
+ uiActionRequest = await this.handleInputType(uiAction.input2Type, uiAction, uiActionRequest, "input2Dialog");
3155
+ if (!uiActionRequest) {
3156
+ return;
3157
+ }
3158
+ }
3159
+ if (this.uiActionModel.exception) {
3160
+ let response = await this.uiActionModel.serviceToUse.handleSpecificDemandsAsynchronously(uiAction, uiActionRequest);
3161
+ if (!response.shouldPerformAction || !response.uiActionRequest) {
3162
+ return;
3163
+ }
3164
+ uiActionRequest = response.uiActionRequest;
3165
+ }
3166
+ this.performAction(uiAction, uiActionRequest);
3167
+ }
3168
+ async handleInputType(inputType, uiAction, uiActionRequest, inputTypeName) {
3169
+ switch (inputType) {
3170
+ case UiActionInputType.None:
3171
+ return uiActionRequest;
3172
+ case UiActionInputType.Textarea:
3173
+ case UiActionInputType.Textfield:
3174
+ return await this.handleInputTypeTextField(inputTypeName, uiAction, uiActionRequest);
3175
+ case UiActionInputType.UserSelect:
3176
+ return await this.handleInputTypeUserSelect(inputTypeName, uiAction, uiActionRequest);
3177
+ default:
3178
+ return uiActionRequest;
3179
+ }
3180
+ }
3181
+ async handleInputTypeTextField(inputTypeName, uiAction, uiActionRequest) {
3182
+ let additionalParams = this.uiActionModel.serviceToUse.getAdditionalParams(uiAction);
3183
+ let inputType = inputTypeName === "inputDialog" ? "inputType" : "input2Type";
3184
+ if (uiAction[inputType] === UiActionInputType.Textfield) {
3185
+ this.textFieldDialogService.nodeName = additionalParams.forTextField;
3186
+ }
3187
+ else if (uiAction[inputType] === UiActionInputType.Textarea) {
3188
+ this.textFieldDialogService.nodeName = additionalParams.forTextArea;
3189
+ }
3190
+ this.textFieldDialogService.inputTypeName = inputTypeName;
3191
+ this.textFieldDialogService.action = uiAction;
3192
+ this.textFieldDialogService.openDialog();
3193
+ await this.textFieldDialogService.onAction.toPromise();
3194
+ let params = this.textFieldDialogService.params;
3195
+ if (!params) {
3196
+ console.error("There was no response from InputDialog");
3197
+ return;
3198
+ }
3199
+ uiActionRequest.params = {
3200
+ ...uiActionRequest.params,
3201
+ ...params,
3202
+ };
3203
+ return uiActionRequest;
3204
+ }
3205
+ async handleInputTypeUserSelect(inputTypeName, uiAction, uiActionRequest) {
3206
+ let response = await this.uiActionModel.serviceToUse.handleSpecificDemandsAsynchronously(uiAction, uiActionRequest);
3207
+ if (!response.shouldPerformAction || !response.uiActionRequest) {
3208
+ return;
3209
+ }
3210
+ uiActionRequest = response.uiActionRequest;
3211
+ return uiActionRequest;
3212
+ }
3213
+ async performAction(uiAction, uiActionRequest) {
3214
+ if (!uiActionRequest.params ||
3215
+ (uiActionRequest.params && !Object.keys(uiActionRequest.params).length)) {
3216
+ uiActionRequest.params = {
3217
+ model: this.uiActionModel.serviceToUse.getModel(),
3218
+ };
3219
+ }
3220
+ else if (uiAction.submit) {
3221
+ uiActionRequest.params["model"] = this.uiActionModel.serviceToUse.getModel();
3222
+ }
3223
+ try {
3224
+ await this.uiActionModel.serviceToUse.performUiActionRequest(uiActionRequest);
3225
+ if (this.uiActionModel.descriptor?.feedbackType === UiActionFeedbackType.Snackbar) {
3226
+ this.showSavedSnackbar(uiAction);
3227
+ }
3228
+ }
3229
+ catch (error) {
3230
+ console.error(error);
3231
+ }
3232
+ }
3233
+ showSavedSnackbar(uiAction) {
3234
+ this._snackBar.openFromComponent(SuccessSnackBarComponent, {
3235
+ duration: 5 * 1000,
3236
+ panelClass: ["backgroundColor-accent"],
3237
+ data: uiAction,
3238
+ });
3239
+ }
3240
+ }
3241
+ UiActionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionService, deps: [{ token: UiActionConfirmDialogService }, { token: UiActionInputDialogService }, { token: i3$2.MatSnackBar }], target: i0.ɵɵFactoryTarget.Injectable });
3242
+ UiActionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionService, providedIn: "root" });
3243
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionService, decorators: [{
3244
+ type: Injectable,
3245
+ args: [{
3246
+ providedIn: "root",
3247
+ }]
3248
+ }], ctorParameters: function () { return [{ type: UiActionConfirmDialogService }, { type: UiActionInputDialogService }, { type: i3$2.MatSnackBar }]; } });
3249
+
3250
+ class UiActionToolbarComponent {
3251
+ constructor(service, manager) {
3252
+ this.service = service;
3253
+ this.manager = manager;
3254
+ this._destroy$ = new Subject();
3255
+ this.manager.languageChanged.pipe(takeUntil(this._destroy$)).subscribe(() => {
3256
+ this.setUp();
3257
+ });
3258
+ }
3259
+ ngOnInit() {
3260
+ this.setUp();
3261
+ }
3262
+ ngOnChanges(changes) {
3263
+ let uiActionModels = changes["uiActionModels"].currentValue;
3264
+ if (uiActionModels) {
3265
+ this.uiActionModels = uiActionModels;
3266
+ this.setUp();
3267
+ }
3268
+ }
3269
+ ngOnDestroy() {
3270
+ this._destroy$.next();
3271
+ }
3272
+ async setUp() {
3273
+ this.uiActionModelsWithDescriptions = await Promise.all(this.uiActionModels.map(async (uiActionModel) => {
3274
+ uiActionModel.descriptor = await this.manager.getActionDescriptor(uiActionModel.uiAction);
3275
+ return uiActionModel;
3276
+ }));
3277
+ }
3278
+ onActionClicked(event, uiActionModel) {
3279
+ event.stopPropagation();
3280
+ this.service.uiActionModel = uiActionModel;
3281
+ this.service.execute(uiActionModel.uiAction);
3282
+ }
3283
+ getType(uiActionModel) {
3284
+ switch (uiActionModel.descriptor?.type) {
3285
+ case UiActionButtonType.Normal:
3286
+ return "mat-button";
3287
+ case UiActionButtonType.Flat:
3288
+ return "mat-flat-button";
3289
+ case UiActionButtonType.Raised:
3290
+ return "mat-raised-button";
3291
+ case UiActionButtonType.Stroked:
3292
+ return "mat-stroked-button";
3293
+ case UiActionButtonType.Icon:
3294
+ return "mat-icon-button";
3295
+ case UiActionButtonType.MiniFab:
3296
+ return "mat-mini-fab";
3297
+ case UiActionButtonType.Fab:
3298
+ return "mat-fab";
3299
+ default:
3300
+ console.log(`Unhandled action button type case: ${uiActionModel.descriptor?.type}`);
3301
+ return `mat-button`;
3302
+ }
3303
+ }
3304
+ iconPosition() {
3305
+ return UiActionButtonIconPos;
3306
+ }
3307
+ isOnlyIcon(uiActionModel) {
3308
+ return (uiActionModel.descriptor?.type === UiActionButtonType.Icon ||
3309
+ uiActionModel.descriptor?.type === UiActionButtonType.MiniFab ||
3310
+ uiActionModel.descriptor?.type === UiActionButtonType.Fab);
3311
+ }
3312
+ }
3313
+ UiActionToolbarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionToolbarComponent, deps: [{ token: UiActionService }, { token: UiActionDescriptorService }], target: i0.ɵɵFactoryTarget.Component });
3314
+ UiActionToolbarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: UiActionToolbarComponent, selector: "smart-ui-action-toolbar", inputs: { uiActionModels: "uiActionModels" }, usesOnChanges: true, ngImport: i0, template: "<div class=\"uiActionButtonsContainer\">\n <button\n *ngFor=\"let uiActionModel of uiActionModelsWithDescriptions\"\n mat-button\n [ngClass]=\"getType(uiActionModel)\"\n class=\"{{ uiActionModel.cssClass }}\"\n [color]=\"uiActionModel.descriptor?.color\"\n (click)=\"onActionClicked($event, uiActionModel)\"\n >\n <div *ngIf=\"isOnlyIcon(uiActionModel); then iconOnly; else text\"></div>\n <ng-template #iconOnly>\n <smart-icon\n *ngIf=\"uiActionModel.descriptor?.icon\"\n [icon]=\"uiActionModel.descriptor!.icon!\"\n [color]=\"uiActionModel.descriptor?.iconColor ?? uiActionModel.descriptor?.color\"\n ></smart-icon>\n </ng-template>\n <ng-template #text>\n <smart-icon\n *ngIf=\"\n uiActionModel.descriptor?.icon &&\n uiActionModel.descriptor?.iconPosition === iconPosition().Pre\n \"\n [icon]=\"uiActionModel.descriptor!.icon!\"\n [color]=\"uiActionModel.descriptor?.iconColor ?? uiActionModel.descriptor?.color\"\n ></smart-icon>\n {{ uiActionModel.descriptor?.title }}\n <smart-icon\n *ngIf=\"\n uiActionModel.descriptor?.icon &&\n uiActionModel.descriptor?.iconPosition === iconPosition().Post\n \"\n [icon]=\"uiActionModel.descriptor!.icon!\"\n [color]=\"uiActionModel.descriptor?.iconColor ?? uiActionModel.descriptor?.color\"\n ></smart-icon>\n </ng-template>\n </button>\n</div>\n", styles: [".uiActionButtonsContainer{display:flex;flex-direction:row;gap:1rem;flex-wrap:wrap;min-height:2.25rem}\n"], components: [{ type: i2.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i4$1.SmartIconComponent, selector: "smart-icon", inputs: ["icon", "color"] }], directives: [{ type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i5.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
3315
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: UiActionToolbarComponent, decorators: [{
3316
+ type: Component,
3317
+ args: [{ selector: "smart-ui-action-toolbar", template: "<div class=\"uiActionButtonsContainer\">\n <button\n *ngFor=\"let uiActionModel of uiActionModelsWithDescriptions\"\n mat-button\n [ngClass]=\"getType(uiActionModel)\"\n class=\"{{ uiActionModel.cssClass }}\"\n [color]=\"uiActionModel.descriptor?.color\"\n (click)=\"onActionClicked($event, uiActionModel)\"\n >\n <div *ngIf=\"isOnlyIcon(uiActionModel); then iconOnly; else text\"></div>\n <ng-template #iconOnly>\n <smart-icon\n *ngIf=\"uiActionModel.descriptor?.icon\"\n [icon]=\"uiActionModel.descriptor!.icon!\"\n [color]=\"uiActionModel.descriptor?.iconColor ?? uiActionModel.descriptor?.color\"\n ></smart-icon>\n </ng-template>\n <ng-template #text>\n <smart-icon\n *ngIf=\"\n uiActionModel.descriptor?.icon &&\n uiActionModel.descriptor?.iconPosition === iconPosition().Pre\n \"\n [icon]=\"uiActionModel.descriptor!.icon!\"\n [color]=\"uiActionModel.descriptor?.iconColor ?? uiActionModel.descriptor?.color\"\n ></smart-icon>\n {{ uiActionModel.descriptor?.title }}\n <smart-icon\n *ngIf=\"\n uiActionModel.descriptor?.icon &&\n uiActionModel.descriptor?.iconPosition === iconPosition().Post\n \"\n [icon]=\"uiActionModel.descriptor!.icon!\"\n [color]=\"uiActionModel.descriptor?.iconColor ?? uiActionModel.descriptor?.color\"\n ></smart-icon>\n </ng-template>\n </button>\n</div>\n", styles: [".uiActionButtonsContainer{display:flex;flex-direction:row;gap:1rem;flex-wrap:wrap;min-height:2.25rem}\n"] }]
3318
+ }], ctorParameters: function () { return [{ type: UiActionService }, { type: UiActionDescriptorService }]; }, propDecorators: { uiActionModels: [{
3319
+ type: Input
3320
+ }] } });
3321
+
3322
+ class SmartViewContextModule {
3323
+ }
3324
+ SmartViewContextModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
3325
+ SmartViewContextModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextModule, declarations: [MessageDialogComponent,
3326
+ SmartViewContextErrorDialogComponent,
3327
+ SmartViewRedirect,
3328
+ UiActionToolbarComponent,
3329
+ UiActionInputDialogComponent,
3330
+ UiActionConfirmDialogComponent], imports: [CommonModule,
3331
+ HttpClientModule,
3332
+ MatCommonModule,
3333
+ MatButtonModule,
3334
+ MatIconModule,
3335
+ MatSnackBarModule,
3336
+ SmartIconModule,
3337
+ SmartformModule], exports: [UiActionToolbarComponent, UiActionInputDialogComponent] });
3338
+ SmartViewContextModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextModule, providers: [
3339
+ SmartViewContextService,
3340
+ {
3341
+ provide: HTTP_INTERCEPTORS,
3342
+ useClass: SmartViewContextInterceptor,
3343
+ multi: true,
3344
+ },
3345
+ ], imports: [[
3346
+ CommonModule,
3347
+ HttpClientModule,
3348
+ MatCommonModule,
3349
+ MatButtonModule,
3350
+ MatIconModule,
3351
+ MatSnackBarModule,
3352
+ SmartIconModule,
3353
+ SmartformModule,
3354
+ ]] });
3355
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextModule, decorators: [{
3356
+ type: NgModule,
3357
+ args: [{
3358
+ declarations: [
3359
+ MessageDialogComponent,
3360
+ SmartViewContextErrorDialogComponent,
3361
+ SmartViewRedirect,
3362
+ UiActionToolbarComponent,
3363
+ UiActionInputDialogComponent,
3364
+ UiActionConfirmDialogComponent,
3365
+ ],
3366
+ imports: [
3367
+ CommonModule,
3368
+ HttpClientModule,
3369
+ MatCommonModule,
3370
+ MatButtonModule,
3371
+ MatIconModule,
3372
+ MatSnackBarModule,
3373
+ SmartIconModule,
3374
+ SmartformModule,
3375
+ ],
3376
+ exports: [UiActionToolbarComponent, UiActionInputDialogComponent],
3377
+ providers: [
3378
+ SmartViewContextService,
3379
+ {
3380
+ provide: HTTP_INTERCEPTORS,
3381
+ useClass: SmartViewContextInterceptor,
3382
+ multi: true,
3383
+ },
3384
+ ],
3385
+ }]
3386
+ }] });
3387
+
3388
+ class SmartNgClientModule {
3389
+ }
3390
+ SmartNgClientModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartNgClientModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
3391
+ SmartNgClientModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartNgClientModule, imports: [SmartSessionModule, SmartViewContextModule], exports: [SmartSessionModule, SmartViewContextModule] });
3392
+ SmartNgClientModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartNgClientModule, providers: [SmartNgClientService], imports: [[SmartSessionModule, SmartViewContextModule], SmartSessionModule, SmartViewContextModule] });
3393
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartNgClientModule, decorators: [{
3394
+ type: NgModule,
3395
+ args: [{
3396
+ declarations: [],
3397
+ imports: [SmartSessionModule, SmartViewContextModule],
3398
+ exports: [SmartSessionModule, SmartViewContextModule],
3399
+ providers: [SmartNgClientService],
3400
+ }]
3401
+ }] });
3402
+
3403
+ var UiActionDialogType;
3404
+ (function (UiActionDialogType) {
3405
+ UiActionDialogType["inputDialog"] = "inputDialog";
3406
+ UiActionDialogType["confirmDialog"] = "confirmDialog";
3407
+ UiActionDialogType["dialog"] = "dialog";
3408
+ })(UiActionDialogType || (UiActionDialogType = {}));
3409
+
3410
+ /*
3411
+ * Public API Surface of smart-view-context
3412
+ */
3413
+
3414
+ /*
3415
+ * Public API Surface of smart-ng-client
3416
+ */
3417
+
3418
+ /**
3419
+ * Generated bundle index. Do not edit.
3420
+ */
3421
+
3422
+ export { APIS, BASE_PATH, COLLECTION_FORMATS, CloseResult, Configuration, MessageOptionType, MessageType, SessionAPIS, SessionErrorBehaviour, SessionService, SmartDevToolDatePipe, SmartDevToolFloatingButtonComponent, SmartDevToolService, SmartLinkChannelVariableInPath, SmartLinkUuidVariableInPath, SmartNgClientModule, SmartNgClientService, SmartSessionModule, SmartSessionService, SmartSessionTimerComponent, SmartSessionTimerService, SmartViewContextModule, SmartViewContextService, SmartViewRedirect, UiActionButtonIconPos, UiActionButtonType, UiActionConfirmDialogComponent, UiActionConfirmDialogService, UiActionDescriptorService, UiActionDialogType, UiActionFeedbackType, UiActionInputDialogComponent, UiActionInputDialogService, UiActionInputType, UiActionService, UiActionToolbarComponent, ViewContextApiModule, ViewService, ViewState, ViewType };
3423
+ //# sourceMappingURL=smartbit4all-ng-client.mjs.map