@falcon-ng/tailwind 0.0.2 → 0.0.3

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 (206) hide show
  1. package/esm2020/falcon-ng-tailwind.mjs +5 -0
  2. package/esm2020/lib/base-control.mjs +50 -0
  3. package/esm2020/lib/base-form-component.mjs +234 -0
  4. package/esm2020/lib/component/auto-complete/auto-complete.component.mjs +33 -0
  5. package/esm2020/lib/component/bottom-sheet/bottom-sheet.component.mjs +29 -0
  6. package/esm2020/lib/component/button/button.component.mjs +27 -0
  7. package/esm2020/lib/component/button-toggle/button-toggle.component.mjs +32 -0
  8. package/esm2020/lib/component/checkbox/checkbox.component.mjs +18 -0
  9. package/esm2020/lib/component/chips/chip.component.mjs +109 -0
  10. package/esm2020/lib/component/date-picker/date-picker.component.mjs +17 -0
  11. package/esm2020/lib/component/dialog/dialog.component.mjs +21 -0
  12. package/esm2020/lib/component/pagination/pagination.component.mjs +95 -0
  13. package/esm2020/lib/component/progress-bar/progress-bar.component.mjs +20 -0
  14. package/esm2020/lib/component/progress-spinner/progress-spinner.component.mjs +26 -0
  15. package/esm2020/lib/component/radio/radio.component.mjs +31 -0
  16. package/esm2020/lib/component/rich-text-editor/rich-text-editor.component.mjs +15 -0
  17. package/esm2020/lib/component/select/select.component.mjs +35 -0
  18. package/esm2020/lib/component/slide-toggle/slide-toggle.component.mjs +14 -0
  19. package/esm2020/lib/component/slider/slider.component.mjs +15 -0
  20. package/esm2020/lib/component/snack-bar/snack-bar.component.mjs +11 -0
  21. package/esm2020/lib/component/table/table.component.mjs +74 -0
  22. package/esm2020/lib/component/textarea/textarea.component.mjs +16 -0
  23. package/esm2020/lib/component/textbox/textbox.component.mjs +17 -0
  24. package/esm2020/lib/control-builder/control-builder.component.mjs +18 -0
  25. package/esm2020/lib/control-type/select.mjs +8 -0
  26. package/esm2020/lib/control-type/textarea.mjs +8 -0
  27. package/esm2020/lib/control-type/textbox.mjs +8 -0
  28. package/esm2020/lib/falcon-core.module.mjs +232 -0
  29. package/esm2020/lib/model/constant.mjs +32 -0
  30. package/esm2020/lib/model/enum.mjs +2 -0
  31. package/esm2020/lib/model/environments.mjs +3 -0
  32. package/esm2020/lib/model/interface.mjs +2 -0
  33. package/esm2020/lib/model/ivalidator.mjs +2 -0
  34. package/esm2020/lib/module/angularmaterial.module.mjs +189 -0
  35. package/esm2020/lib/reactive-field.directive.mjs +28 -0
  36. package/esm2020/lib/service/appsetting.service.mjs +55 -0
  37. package/esm2020/lib/service/http/generic-http-client.mjs +197 -0
  38. package/esm2020/lib/service/http/igeneric-http-client.mjs +10 -0
  39. package/esm2020/lib/service/logger.service.mjs +78 -0
  40. package/esm2020/lib/service/open-id/TokenHelperService.mjs +71 -0
  41. package/esm2020/lib/service/open-id/auth-guard.service.mjs +30 -0
  42. package/esm2020/lib/service/open-id/auth.service.mjs +154 -0
  43. package/esm2020/public-api.mjs +50 -0
  44. package/fesm2015/falcon-ng-tailwind.mjs +1906 -0
  45. package/fesm2015/falcon-ng-tailwind.mjs.map +1 -0
  46. package/fesm2020/falcon-ng-tailwind.mjs +1880 -0
  47. package/fesm2020/falcon-ng-tailwind.mjs.map +1 -0
  48. package/index.d.ts +5 -0
  49. package/lib/base-control.d.ts +104 -0
  50. package/lib/base-form-component.d.ts +169 -0
  51. package/lib/component/auto-complete/auto-complete.component.d.ts +17 -0
  52. package/lib/component/bottom-sheet/bottom-sheet.component.d.ts +11 -0
  53. package/lib/component/button/button.component.d.ts +12 -0
  54. package/lib/component/button-toggle/button-toggle.component.d.ts +14 -0
  55. package/lib/component/checkbox/checkbox.component.d.ts +10 -0
  56. package/lib/component/chips/chip.component.d.ts +35 -0
  57. package/lib/component/date-picker/date-picker.component.d.ts +9 -0
  58. package/lib/component/dialog/dialog.component.d.ts +8 -0
  59. package/lib/component/pagination/pagination.component.d.ts +20 -0
  60. package/lib/component/progress-bar/progress-bar.component.d.ts +11 -0
  61. package/lib/component/progress-spinner/progress-spinner.component.d.ts +12 -0
  62. package/lib/component/radio/radio.component.d.ts +14 -0
  63. package/lib/component/rich-text-editor/rich-text-editor.component.d.ts +9 -0
  64. package/lib/component/select/select.component.d.ts +15 -0
  65. package/lib/component/slide-toggle/slide-toggle.component.d.ts +9 -0
  66. package/lib/component/slider/slider.component.d.ts +9 -0
  67. package/lib/component/snack-bar/snack-bar.component.d.ts +5 -0
  68. package/lib/component/table/table.component.d.ts +21 -0
  69. package/lib/component/textarea/textarea.component.d.ts +9 -0
  70. package/lib/component/textbox/textbox.component.d.ts +9 -0
  71. package/lib/control-builder/control-builder.component.d.ts +9 -0
  72. package/{src/lib/control-type/Chip.ts → lib/control-type/select.d.ts} +2 -3
  73. package/{src/lib/control-type/Radio.ts → lib/control-type/textarea.d.ts} +2 -3
  74. package/lib/control-type/textbox.d.ts +5 -0
  75. package/lib/falcon-core.module.d.ts +35 -0
  76. package/lib/model/constant.d.ts +5 -0
  77. package/lib/model/enum.d.ts +144 -0
  78. package/{src/lib/model/environments.ts → lib/model/environments.d.ts} +5 -7
  79. package/{src/lib/model/interface.ts → lib/model/interface.d.ts} +80 -91
  80. package/{src/lib/model/ivalidator.ts → lib/model/ivalidator.d.ts} +3 -3
  81. package/lib/module/angularmaterial.module.d.ts +49 -0
  82. package/lib/reactive-field.directive.d.ts +14 -0
  83. package/lib/service/appsetting.service.d.ts +22 -0
  84. package/lib/service/http/generic-http-client.d.ts +121 -0
  85. package/lib/service/http/igeneric-http-client.d.ts +92 -0
  86. package/lib/service/logger.service.d.ts +18 -0
  87. package/lib/service/open-id/TokenHelperService.d.ts +11 -0
  88. package/lib/service/open-id/auth-guard.service.d.ts +11 -0
  89. package/lib/service/open-id/auth.service.d.ts +36 -0
  90. package/package.json +22 -2
  91. package/{src/public-api.ts → public-api.d.ts} +8 -6
  92. package/ng-package.json +0 -7
  93. package/src/lib/base-control.ts +0 -142
  94. package/src/lib/base-form-component.ts +0 -363
  95. package/src/lib/component/auto-complete/auto-complete.component.html +0 -39
  96. package/src/lib/component/auto-complete/auto-complete.component.scss +0 -0
  97. package/src/lib/component/auto-complete/auto-complete.component.spec.ts +0 -23
  98. package/src/lib/component/auto-complete/auto-complete.component.ts +0 -31
  99. package/src/lib/component/bottom-sheet/bottom-sheet.component.html +0 -9
  100. package/src/lib/component/bottom-sheet/bottom-sheet.component.scss +0 -0
  101. package/src/lib/component/bottom-sheet/bottom-sheet.component.spec.ts +0 -23
  102. package/src/lib/component/bottom-sheet/bottom-sheet.component.ts +0 -19
  103. package/src/lib/component/button/button.component.css +0 -0
  104. package/src/lib/component/button/button.component.html +0 -54
  105. package/src/lib/component/button/button.component.spec.ts +0 -23
  106. package/src/lib/component/button/button.component.ts +0 -17
  107. package/src/lib/component/button-toggle/button-toggle.component.html +0 -21
  108. package/src/lib/component/button-toggle/button-toggle.component.scss +0 -0
  109. package/src/lib/component/button-toggle/button-toggle.component.spec.ts +0 -23
  110. package/src/lib/component/button-toggle/button-toggle.component.ts +0 -26
  111. package/src/lib/component/checkbox/checkbox.component.html +0 -6
  112. package/src/lib/component/checkbox/checkbox.component.scss +0 -0
  113. package/src/lib/component/checkbox/checkbox.component.spec.ts +0 -23
  114. package/src/lib/component/checkbox/checkbox.component.ts +0 -17
  115. package/src/lib/component/chips/chip.component.html +0 -75
  116. package/src/lib/component/chips/chip.component.scss +0 -3
  117. package/src/lib/component/chips/chip.component.spec.ts +0 -23
  118. package/src/lib/component/chips/chip.component.ts +0 -125
  119. package/src/lib/component/date-picker/date-picker.component.html +0 -18
  120. package/src/lib/component/date-picker/date-picker.component.scss +0 -0
  121. package/src/lib/component/date-picker/date-picker.component.spec.ts +0 -23
  122. package/src/lib/component/date-picker/date-picker.component.ts +0 -13
  123. package/src/lib/component/dialog/dialog.component.html +0 -12
  124. package/src/lib/component/dialog/dialog.component.scss +0 -3
  125. package/src/lib/component/dialog/dialog.component.spec.ts +0 -23
  126. package/src/lib/component/dialog/dialog.component.ts +0 -12
  127. package/src/lib/component/pagination/pagination.component.html +0 -10
  128. package/src/lib/component/pagination/pagination.component.scss +0 -0
  129. package/src/lib/component/pagination/pagination.component.spec.ts +0 -23
  130. package/src/lib/component/pagination/pagination.component.ts +0 -86
  131. package/src/lib/component/progress-bar/progress-bar.component.html +0 -1
  132. package/src/lib/component/progress-bar/progress-bar.component.scss +0 -0
  133. package/src/lib/component/progress-bar/progress-bar.component.spec.ts +0 -23
  134. package/src/lib/component/progress-bar/progress-bar.component.ts +0 -15
  135. package/src/lib/component/progress-spinner/progress-spinner.component.html +0 -7
  136. package/src/lib/component/progress-spinner/progress-spinner.component.scss +0 -0
  137. package/src/lib/component/progress-spinner/progress-spinner.component.spec.ts +0 -23
  138. package/src/lib/component/progress-spinner/progress-spinner.component.ts +0 -16
  139. package/src/lib/component/radio/radio.component.html +0 -13
  140. package/src/lib/component/radio/radio.component.scss +0 -14
  141. package/src/lib/component/radio/radio.component.spec.ts +0 -23
  142. package/src/lib/component/radio/radio.component.ts +0 -29
  143. package/src/lib/component/rich-text-editor/rich-text-editor.component.html +0 -10
  144. package/src/lib/component/rich-text-editor/rich-text-editor.component.scss +0 -0
  145. package/src/lib/component/rich-text-editor/rich-text-editor.component.spec.ts +0 -23
  146. package/src/lib/component/rich-text-editor/rich-text-editor.component.ts +0 -13
  147. package/src/lib/component/select/select.component.html +0 -25
  148. package/src/lib/component/select/select.component.scss +0 -0
  149. package/src/lib/component/select/select.component.spec.ts +0 -23
  150. package/src/lib/component/select/select.component.ts +0 -32
  151. package/src/lib/component/slide-toggle/slide-toggle.component.html +0 -7
  152. package/src/lib/component/slide-toggle/slide-toggle.component.scss +0 -0
  153. package/src/lib/component/slide-toggle/slide-toggle.component.spec.ts +0 -23
  154. package/src/lib/component/slide-toggle/slide-toggle.component.ts +0 -13
  155. package/src/lib/component/slider/slider.component.html +0 -11
  156. package/src/lib/component/slider/slider.component.scss +0 -0
  157. package/src/lib/component/slider/slider.component.spec.ts +0 -23
  158. package/src/lib/component/slider/slider.component.ts +0 -13
  159. package/src/lib/component/snack-bar/snack-bar.component.html +0 -1
  160. package/src/lib/component/snack-bar/snack-bar.component.scss +0 -0
  161. package/src/lib/component/snack-bar/snack-bar.component.spec.ts +0 -23
  162. package/src/lib/component/snack-bar/snack-bar.component.ts +0 -10
  163. package/src/lib/component/table/table.component.html +0 -82
  164. package/src/lib/component/table/table.component.scss +0 -17
  165. package/src/lib/component/table/table.component.spec.ts +0 -23
  166. package/src/lib/component/table/table.component.ts +0 -54
  167. package/src/lib/component/textarea/textarea.component.html +0 -22
  168. package/src/lib/component/textarea/textarea.component.scss +0 -3
  169. package/src/lib/component/textarea/textarea.component.spec.ts +0 -23
  170. package/src/lib/component/textarea/textarea.component.ts +0 -13
  171. package/src/lib/component/textbox/textbox.component.html +0 -27
  172. package/src/lib/component/textbox/textbox.component.scss +0 -3
  173. package/src/lib/component/textbox/textbox.component.spec.ts +0 -23
  174. package/src/lib/component/textbox/textbox.component.ts +0 -13
  175. package/src/lib/control-builder/control-builder.component.html +0 -5
  176. package/src/lib/control-builder/control-builder.component.scss +0 -0
  177. package/src/lib/control-builder/control-builder.component.ts +0 -14
  178. package/src/lib/control-type/AutoComplete.ts +0 -6
  179. package/src/lib/control-type/Button.ts +0 -6
  180. package/src/lib/control-type/ButtonToggle.ts +0 -6
  181. package/src/lib/control-type/CheckBox.ts +0 -6
  182. package/src/lib/control-type/DatePicker.ts +0 -6
  183. package/src/lib/control-type/Divider.ts +0 -6
  184. package/src/lib/control-type/Editor.ts +0 -6
  185. package/src/lib/control-type/RichTextEditor.ts +0 -6
  186. package/src/lib/control-type/SlideToggle.ts +0 -6
  187. package/src/lib/control-type/Slider.ts +0 -6
  188. package/src/lib/control-type/select.ts +0 -6
  189. package/src/lib/control-type/textarea.ts +0 -6
  190. package/src/lib/control-type/textbox.ts +0 -6
  191. package/src/lib/falcon-core.module.ts +0 -141
  192. package/src/lib/model/constant.ts +0 -32
  193. package/src/lib/model/enum.ts +0 -151
  194. package/src/lib/module/angularmaterial.module.ts +0 -98
  195. package/src/lib/reactive-field.directive.ts +0 -24
  196. package/src/lib/service/appsetting.service.ts +0 -57
  197. package/src/lib/service/http/generic-http-client.ts +0 -205
  198. package/src/lib/service/http/httpInterceptor.ts +0 -36
  199. package/src/lib/service/http/igeneric-http-client.ts +0 -110
  200. package/src/lib/service/logger.service.ts +0 -75
  201. package/src/lib/service/open-id/TokenHelperService.ts +0 -76
  202. package/src/lib/service/open-id/auth-guard.service.ts +0 -25
  203. package/src/lib/service/open-id/auth.service.ts +0 -179
  204. package/tsconfig.lib.json +0 -15
  205. package/tsconfig.lib.prod.json +0 -10
  206. package/tsconfig.spec.json +0 -14
@@ -1,205 +0,0 @@
1
- import {
2
- HttpClient,
3
- HttpRequest,
4
- HttpEventType,
5
- HttpEvent,
6
- HttpStatusCode
7
- } from '@angular/common/http';
8
- import { Observable, from } from 'rxjs';
9
- import { IGenericHttpClient } from './igeneric-http-client';
10
- import { Injectable } from '@angular/core';
11
- import {IRequestOptions, SnackbarModel} from '../../model/interface';
12
- import { LoggerService } from '../logger.service';
13
- import {EnvironmentViewModel} from "../../model/environments";
14
- import {HttpMethod} from "../../model/enum";
15
- import {MatSnackBar} from "@angular/material/snack-bar";
16
- @Injectable({
17
- providedIn: 'root'
18
- })
19
- export class GenericHttpClient<T> implements IGenericHttpClient<T>{
20
- private snackBarViewModel: SnackbarModel = {} as SnackbarModel;
21
- private isHttpError: boolean = false;
22
-
23
- constructor(private httpClient: HttpClient, private environment: EnvironmentViewModel,
24
- private _snackBar: MatSnackBar, private logger: LoggerService) { }
25
-
26
-
27
- /**
28
- * @description
29
- * Generic Http GET method to Get the response and bind to the view model
30
- * @param {string} destinationUrl endPoint it doesn't need / in front of the end point.
31
- * @param {IRequestOptions} options options of the request like headers, body, etc.
32
- * @returns {Observable<T>}
33
- * @usageNotes
34
- * The following snippet shows how to use this method
35
- * ```ts
36
- * this.genericHttpService.Get("get_url").subscribe(data => {
37
- * console.log('success');
38
- * }, error => {
39
- * console.log(error);
40
- * });
41
- * ```
42
- */
43
- public get(destinationUrl: string, options?: IRequestOptions | any): Observable<T> {
44
- return this.request<T>(HttpMethod.Get, destinationUrl, options);
45
- }
46
-
47
- /**
48
- * @description
49
- * Generic Http post method to post the view model and bind the return view model
50
- * @param {string} destinationUrl endPoint it doesn't need / in front of the end point.
51
- * @param {IRequestOptions} options options of the request like headers, body, etc.
52
- * @returns {Observable<T>}
53
- * @usageNotes
54
- * The following snippet shows how to use this method
55
- * ```ts
56
- * this.genericHttpClientService.Post(post-url,post-view-model).subscribe(item => {
57
- * console.log(item);
58
- * },
59
- * err => {
60
- * console.log(err);
61
- * });
62
- * ```
63
- */
64
- public post(destinationUrl: string, options?: IRequestOptions | any): Observable<T> {
65
- return this.request<T>(HttpMethod.Post, destinationUrl, options);
66
- }
67
-
68
- /**
69
- * @description
70
- * Generic Http Put method to post the view model and bind the return view model
71
- * @param {string} destinationUrl endPoint it doesn't need / in front of the end point.
72
- * @param {IRequestOptions} options options of the request like headers, body, etc.
73
- * @returns {Observable<T>}
74
- * @usageNotes
75
- * The following snippet shows how to use this method
76
- * ```ts
77
- * this.genericHttpClientService.Put(post-url, post-view-model).subscribe(item => {
78
- * console.log(item);
79
- * },
80
- * err => {
81
- * console.log(err);
82
- * });
83
- * ```
84
- */
85
- public put(destinationUrl: string, options?: IRequestOptions | any): Observable<T> {
86
- return this.request<T>(HttpMethod.Put, destinationUrl, options);
87
- }
88
-
89
- /**
90
- * @description
91
- * Generic Http post method to post the view model and bind the return view model
92
- * @param {string} destinationUrl endPoint it doesn't need / in front of the end point.
93
- * @param {IRequestOptions} options options of the request like headers, body, etc.
94
- * @returns {Observable<T>}
95
- * @usageNotes
96
- * The following snippet shows how to use this method
97
- * ```ts
98
- * this.genericHttpClientService.Post(post-url,post-view-model).subscribe(item => {
99
- * console.log(item);
100
- * },
101
- * err => {
102
- * console.log(err);
103
- * });
104
- * ```
105
- */
106
- public patch(destinationUrl: string, options?: IRequestOptions | any): Observable<T> {
107
- return this.request<T>(HttpMethod.Patch, destinationUrl, options);
108
- }
109
-
110
- /**
111
- * @description
112
- * Generic Http Delete method to Delete the item and bind the return view model
113
- * @param {string} destinationUrl endPoint it doesn't need / in front of the end point.
114
- * @param {IRequestOptions} options options of the request like headers, body, etc.
115
- * @returns {Observable<T>}
116
- * @usageNotes
117
- * The following snippet shows how to use this method
118
- * ```ts
119
- * this.genericHttpClientService.Delete(this.deleteUserUrl).subscribe(item => {
120
- * console.log('success');
121
- * }, error => {
122
- * console.log(error);
123
- * });
124
- * ```
125
- */
126
- public delete(destinationUrl: string, options?: IRequestOptions | any): Observable<T> {
127
- return this.request<T>(HttpMethod.Delete, destinationUrl, options);
128
- }
129
-
130
- /**
131
- * @description
132
- * Http request method to accept different method type and params
133
- * @param {string} method Http methods - GET, POST, PUT, DELETE.
134
- * @param {string} destinationUrl endPoint it doesn't need / in front of the end point.
135
- * @param {IRequestOptions} options options of the request like headers, body, etc.
136
- * @returns {Observable<T>}
137
- * @usageNotes
138
- * The following snippet shows how to use this method
139
- * ```ts
140
- * this.request<T>(HttpMethod.Delete, destinationUrl, options);
141
- * ```
142
- */
143
- private request<T>(method: string, url: string, options?: IRequestOptions): Observable<T> {
144
- return Observable.create((observer: any) => {
145
- let destinationUrl = '';
146
- if (this.environment.baseUrl != undefined)
147
- destinationUrl = (this.environment.baseUrl) + url
148
- else
149
- destinationUrl = url
150
- this.httpClient.request<T>(new HttpRequest(method, destinationUrl, options)).subscribe(
151
- (response: any) => {
152
- const responsTye = response as HttpEvent<any>
153
- switch (responsTye.type) {
154
- case HttpEventType.Sent:
155
- this.logger.info('Http Client : Sent ->', 'Request sent!');
156
- break;
157
- case HttpEventType.ResponseHeader:
158
- this.logger.info('Http Client : ResponseHeader ->', 'Response header received!');
159
- break;
160
- case HttpEventType.DownloadProgress:
161
- const kbLoaded = Math.round(responsTye.loaded / 1024);
162
- this.logger.info('Http Client : DownloadProgress ->', `Download in progress! ${kbLoaded}Kb loaded`);
163
- break;
164
- case HttpEventType.Response:
165
- observer.next(response.body);
166
- this.logger.info('Http Client : Response -> 😺 Done!', responsTye.body);
167
- }
168
- },
169
- (error) => {
170
- switch (error.status) {
171
- case HttpStatusCode.Forbidden:
172
- // observer.complete();
173
- this.snackBarViewModel.messageText = 'Access to the requested resource is forbidden.';
174
- this.snackBarViewModel.actionText = 'Forbidden';
175
- this.isHttpError = true;
176
- break;
177
- case HttpStatusCode.BadRequest:
178
- this.snackBarViewModel.messageText = 'Server cannot or will not process the request.';
179
- this.snackBarViewModel.actionText = 'Bad Request';
180
- this.isHttpError = true;
181
- break;
182
- case HttpStatusCode.Unauthorized:
183
- this.snackBarViewModel.messageText = 'Request has not been applied because it lacks valid authentication credentials.';
184
- this.snackBarViewModel.actionText = 'Unauthorized';
185
- this.isHttpError = true;
186
- break;
187
- case HttpStatusCode.InternalServerError:
188
- this.snackBarViewModel.messageText = 'Server encountered an unexpected condition.';
189
- this.snackBarViewModel.actionText = 'Internal server error';
190
- this.isHttpError = true;
191
- break;
192
- case 0:
193
- this.snackBarViewModel.messageText = 'Not connected to the service.';
194
- this.snackBarViewModel.actionText = 'Service not available';
195
- this.isHttpError = true;
196
- break;
197
- }
198
- observer.error(error);
199
- if ((this.environment.snackBarEnable != undefined && this.environment.snackBarEnable) && this.isHttpError)
200
- this._snackBar.open(this.snackBarViewModel.messageText, this.snackBarViewModel.actionText);
201
- }
202
- );
203
- });
204
- }
205
- }
@@ -1,36 +0,0 @@
1
- //import { Injectable } from '@angular/core';
2
- //import { HttpRequest, HttpHandler, HttpEvent, HttpInterceptor } from '@angular/common/http';
3
- //import { Observable, of } from 'rxjs';
4
- //import { AuthService } from '../open-id/auth.service';
5
- //import { LoggerService } from '../logger.service';
6
- //
7
- //@Injectable({
8
- // providedIn: 'root'
9
- //})
10
- //export class HttpFalconInterceptor implements HttpInterceptor {
11
- // constructor(public authService: AuthService, private logger: LoggerService) { }
12
- // intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
13
- // // Get the auth token from the service.
14
- // const authToken = this.authService.getAuthorizationHeaderValue();
15
- // this.logger.info("Auth bearer token ", authToken);
16
- //
17
- // if (authToken) {
18
- // request = request.clone({
19
- // setHeaders: {
20
- // 'Content-Type': 'application/json',
21
- // Authorization: authToken
22
- // }
23
- // });
24
- // }
25
- //
26
- // /**
27
- // * continues request execution
28
- // */
29
- // return next.handle(request);
30
- // // return next.handle(request).pipe(catchError((error, caught) => {
31
- // // //intercept the respons error and displace it to the console
32
- // // this.logger.error(error);
33
- // // return of(error);
34
- // // }) as any);
35
- // }
36
- //}
@@ -1,110 +0,0 @@
1
- import { Observable } from 'rxjs';
2
- import { Injectable } from '@angular/core';
3
- import { IRequestOptions } from '../../model/interface';
4
- @Injectable()
5
- export abstract class IGenericHttpClient<T> {
6
- /**
7
- * @description
8
- * Generic Http GET method to Get the response and bind to the view model
9
- * @param {string} destinationUrl endPoint it doesn't need / in front of the end point.
10
- * @param {IRequestOptions} options options of the request like headers, body, etc.
11
- * @returns {Observable<T>}
12
- * @usageNotes
13
- * The following snippet shows how to use this method
14
- * ```ts
15
- * this.genericHttpService.HttpGet("get_url").subscribe(data => {
16
- * console.log('success');
17
- * }, error => {
18
- * console.log(error);
19
- * });
20
- * ```
21
- */
22
- abstract get(
23
- destinationUrl: string,
24
- options?: IRequestOptions | any
25
- ): Observable<T>;
26
-
27
- /**
28
- * @description
29
- * Generic Http post method to post the view model and bind the return view model
30
- * @param {string} destinationUrl endPoint it doesn't need / in front of the end point.
31
- * @param {IRequestOptions} options options of the request like headers, body, etc.
32
- * @returns {Observable<T>}
33
- * @usageNotes
34
- * The following snippet shows how to use this method
35
- * ```ts
36
- * this.genericHttpService.Post(post_url,post-view-model").subscribe(data => {
37
- * console.log('data is not success');
38
- * }, error => {
39
- * console.log(error);
40
- * });
41
- * ```
42
- */
43
- abstract post(
44
- destinationUrl: string,
45
- options?: IRequestOptions | any
46
- ): Observable<T>;
47
-
48
- /**
49
- * @description
50
- * Generic Http put method to post the view model and bind the return view model
51
- * @param {string} destinationUrl endPoint it doesn't need / in front of the end point.
52
- * @param {IRequestOptions} options options of the request like headers, body, etc.
53
- * @returns {Observable<T>}
54
- * @usageNotes
55
- * The following snippet shows how to use this method
56
- * ```ts
57
- * this.genericHttpService.Put(put_url,post-view-model).subscribe(data => {
58
- * console.log('data is not success');
59
- * }, error => {
60
- * console.log(error);
61
- * });
62
- * ```
63
- */
64
- abstract put(
65
- destinationUrl: string,
66
- options?: IRequestOptions | any
67
- ): Observable<T>;
68
-
69
- /**
70
- * @description
71
- * Generic Http patch method to patch the view model and bind the return view model
72
- * @param {string} destinationUrl endPoint it doesn't need / in front of the end point.
73
- * @param {IRequestOptions} options options of the request like headers, body, etc.
74
- * @returns {Observable<T>}
75
- * @usageNotes
76
- * The following snippet shows how to use this method
77
- * ```ts
78
- * this.genericHttpService.Patch(put_url,post-view-model).subscribe(data => {
79
- * console.log('data is not success');
80
- * }, error => {
81
- * console.log(error);
82
- * });
83
- * ```
84
- */
85
- abstract patch(
86
- destinationUrl: string,
87
- options?: IRequestOptions | any
88
- ): Observable<T>;
89
-
90
- /**
91
- * @description
92
- * Generic Http Delete method to Delete the item and bind the return view model
93
- * @param {string} destinationUrl endPoint it doesn't need / in front of the end point.
94
- * @param {IRequestOptions} options options of the request like headers, body, etc.
95
- * @returns {Observable<T>}
96
- * @usageNotes
97
- * The following snippet shows how to use this method
98
- * ```ts
99
- * this.genericHttpClientService.Delete(this.deleteUserUrl).subscribe(item => {
100
- * console.log('success');
101
- * }, error => {
102
- * console.log(error);
103
- * });
104
- * ```
105
- */
106
- abstract delete(
107
- destinationUrl: string,
108
- options?: IRequestOptions | any
109
- ): Observable<T>;
110
- }
@@ -1,75 +0,0 @@
1
- import { Injectable } from '@angular/core';
2
- import { AppSettingService } from './appsetting.service';
3
- import {LoggingLevel} from "../model/enum";
4
- import {IAppSettingViewModel} from "../model/interface";
5
-
6
- @Injectable({
7
- providedIn: 'root'
8
- })
9
- export class LoggerService {
10
- private initialized: boolean = false;
11
- private _level: LoggingLevel = LoggingLevel.Warnings;
12
- constructor() { }
13
-
14
- async initialize(appSettings: IAppSettingViewModel): Promise<void> {
15
- if (this.initialized) return;
16
- this._level = appSettings.loggingLevel as LoggingLevel;
17
- this.initialized = true;
18
- }
19
-
20
- private log(message: any, level = LoggingLevel.Warnings, ...optionalParams: any[]) {
21
- if (this.shouldLog(level)) {
22
- switch (level) {
23
- case LoggingLevel.Errors:
24
- console.error(message, optionalParams);
25
- break;
26
- case LoggingLevel.Warnings:
27
- console.warn(message, optionalParams);
28
- break;
29
- case LoggingLevel.Info:
30
- console.info(message, optionalParams);
31
- break;
32
- default:
33
- console.debug(message, optionalParams);
34
- }
35
- }
36
- }
37
-
38
- private shouldLog(level: LoggingLevel) {
39
- if (this._level === LoggingLevel.None) {
40
- return false;
41
- } else if (this._level === LoggingLevel.Errors) {
42
- return level === LoggingLevel.Errors;
43
- } else if (this._level === LoggingLevel.Warnings) {
44
- return level === LoggingLevel.Errors || level === LoggingLevel.Warnings;
45
- } else if (this._level === LoggingLevel.Info) {
46
- return level === LoggingLevel.Errors || level === LoggingLevel.Warnings || level === LoggingLevel.Info;
47
- } else {
48
- return true;
49
- }
50
- }
51
-
52
- error(message: any, ...optionalParams: any[]) {
53
- this.log(message, LoggingLevel.Errors, optionalParams);
54
- }
55
-
56
- warning(message: any, ...optionalParams: any[]) {
57
- this.log(message, LoggingLevel.Warnings, optionalParams);
58
- }
59
-
60
- info(message: any, ...optionalParams: any[]) {
61
- this.log(message, LoggingLevel.Info, optionalParams);
62
- }
63
-
64
- verbose(message: any, ...optionalParams: any[]) {
65
- this.log(message, LoggingLevel.Verbose, optionalParams);
66
- }
67
- }
68
- export function loggerServiceFactory(loggerService: LoggerService, appSettings: AppSettingService) {
69
- return async () => {
70
- appSettings.isServiceReady.subscribe(item => {
71
- if (item)
72
- loggerService.initialize(appSettings.getAppsettingValue() as IAppSettingViewModel);
73
- });
74
- }
75
- };
@@ -1,76 +0,0 @@
1
- import { Injectable } from '@angular/core';
2
-
3
- @Injectable({
4
- providedIn: 'root'
5
- })
6
- export class TokenHelperService {
7
- constructor() { }
8
-
9
- getTokenExpirationDate(dataIdToken: any): Date {
10
- if (!dataIdToken.hasOwnProperty('exp')) {
11
- return new Date();
12
- }
13
-
14
- const date = new Date(0); // The 0 here is the key, which sets the date to the epoch
15
- date.setUTCSeconds(dataIdToken.exp);
16
-
17
- return date;
18
- }
19
-
20
- getPayloadFromToken(token: any, encode: boolean) {
21
- let data = {};
22
- if (typeof token !== 'undefined') {
23
- const encoded = token.split('.')[1];
24
- if (encode) {
25
- return encoded;
26
- }
27
- data = JSON.parse(this.urlBase64Decode(encoded));
28
- }
29
-
30
- return data;
31
- }
32
-
33
- getHeaderFromToken(token: any, encode: boolean) {
34
- let data = {};
35
- if (typeof token !== 'undefined') {
36
- const encoded = token.split('.')[0];
37
- if (encode) {
38
- return encoded;
39
- }
40
- data = JSON.parse(this.urlBase64Decode(encoded));
41
- }
42
-
43
- return data;
44
- }
45
-
46
- getSignatureFromToken(token: any, encode: boolean) {
47
- let data = {};
48
- if (typeof token !== 'undefined') {
49
- const encoded = token.split('.')[2];
50
- if (encode) {
51
- return encoded;
52
- }
53
- data = JSON.parse(this.urlBase64Decode(encoded));
54
- }
55
-
56
- return data;
57
- }
58
-
59
- urlBase64Decode(str: string) {
60
- let output = str.replace('-', '+').replace('_', '/');
61
- switch (output.length % 4) {
62
- case 0:
63
- break;
64
- case 2:
65
- output += '==';
66
- break;
67
- case 3:
68
- output += '=';
69
- break;
70
- default:
71
- throw Error('Illegal base64url string!');
72
- }
73
-
74
- return window.atob(output);
75
- }
76
- }
@@ -1,25 +0,0 @@
1
- import { Injectable } from '@angular/core';
2
- import { AuthService } from './auth.service';
3
- import { CanActivate, RouterStateSnapshot, ActivatedRouteSnapshot } from '@angular/router';
4
- import { Observable } from 'rxjs';
5
-
6
- @Injectable({
7
- providedIn: 'root'
8
- })
9
- export class AuthGuardService implements CanActivate{
10
-
11
- constructor(private authService : AuthService) { }
12
-
13
- canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) : boolean | Observable<boolean> | Promise<boolean> {
14
- return new Promise<boolean>(resolve => {
15
- this.authService.isServiceReady().then(() => {
16
- if (this.authService.isLoggedIn()) {
17
- resolve(true);
18
- } else {
19
- this.authService.startAuthentication(state.url);
20
- resolve(false);
21
- }
22
- })
23
- });
24
- }
25
- }