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