@osovitny/anatoly 2.0.22 → 2.0.25

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 (62) hide show
  1. package/bundles/osovitny-anatoly.umd.js +1077 -347
  2. package/bundles/osovitny-anatoly.umd.js.map +1 -1
  3. package/bundles/osovitny-anatoly.umd.min.js +2 -3
  4. package/bundles/osovitny-anatoly.umd.min.js.map +1 -1
  5. package/esm2015/lib/core/alerts.js +52 -52
  6. package/esm2015/lib/core/consts/index.js +2 -1
  7. package/esm2015/lib/core/consts/urls.js +22 -0
  8. package/esm2015/lib/core/convert.js +31 -0
  9. package/esm2015/lib/core/core.module.js +7 -3
  10. package/esm2015/lib/core/index.js +5 -5
  11. package/esm2015/lib/core/localization/index.js +26 -0
  12. package/esm2015/lib/core/localization/localization.module.js +41 -0
  13. package/esm2015/lib/core/localization/localization.service.js +115 -0
  14. package/esm2015/lib/core/localization/localizationSettings.module.js +70 -0
  15. package/esm2015/lib/core/localization/localize.pipe.js +65 -0
  16. package/esm2015/lib/core/notifications/alerts.js +107 -0
  17. package/esm2015/lib/core/notifications/interfaces/notification.js +19 -0
  18. package/esm2015/lib/core/notifications/services/notification-service.js +230 -0
  19. package/esm2015/lib/core/subs.js +1 -1
  20. package/esm2015/lib/core/utils.js +47 -14
  21. package/esm2015/lib/data/base/base-api.service.js +26 -30
  22. package/esm2015/lib/data/consts.js +24 -0
  23. package/esm2015/lib/data/data.module.js +16 -5
  24. package/esm2015/lib/data/index.js +6 -6
  25. package/esm2015/lib/data/services/billing-api.service.js +4 -5
  26. package/esm2015/lib/ui/index.js +4 -4
  27. package/esm2015/lib/ui/ui.module.js +25 -25
  28. package/esm2015/lib/ui/validation/form-validation-summary.component.js +64 -0
  29. package/esm2015/lib/ui/validation/item-validation-summary.component.js +38 -0
  30. package/esm2015/lib/ui/validation/validation-summary.component.js +117 -0
  31. package/esm2015/public-api.js +6 -1
  32. package/fesm2015/osovitny-anatoly.js +1027 -305
  33. package/fesm2015/osovitny-anatoly.js.map +1 -1
  34. package/lib/core/consts/index.d.ts +1 -0
  35. package/lib/core/consts/urls.d.ts +3 -0
  36. package/lib/core/convert.d.ts +7 -0
  37. package/lib/core/index.d.ts +4 -4
  38. package/lib/core/localization/index.d.ts +4 -0
  39. package/lib/core/localization/localization.module.d.ts +2 -0
  40. package/lib/core/localization/localization.service.d.ts +18 -0
  41. package/lib/core/localization/localizationSettings.module.d.ts +10 -0
  42. package/lib/core/localization/localize.pipe.d.ts +7 -0
  43. package/lib/core/notifications/alerts.d.ts +9 -0
  44. package/lib/core/notifications/interfaces/notification.d.ts +10 -0
  45. package/lib/core/notifications/services/notification-service.d.ts +22 -0
  46. package/lib/core/subs.d.ts +1 -1
  47. package/lib/core/utils.d.ts +4 -0
  48. package/lib/data/base/base-api.service.d.ts +2 -3
  49. package/lib/data/consts.d.ts +4 -0
  50. package/lib/data/data.module.d.ts +1 -0
  51. package/lib/data/index.d.ts +5 -5
  52. package/lib/ui/index.d.ts +3 -3
  53. package/lib/ui/ui.module.d.ts +2 -2
  54. package/lib/ui/{components/validation → validation}/validation-summary.component.d.ts +1 -1
  55. package/osovitny-anatoly.metadata.json +1 -1
  56. package/package.json +1 -1
  57. package/public-api.d.ts +5 -0
  58. package/esm2015/lib/ui/components/validation/form-validation-summary.component.js +0 -64
  59. package/esm2015/lib/ui/components/validation/item-validation-summary.component.js +0 -38
  60. package/esm2015/lib/ui/components/validation/validation-summary.component.js +0 -117
  61. /package/lib/ui/{components/validation → validation}/form-validation-summary.component.d.ts +0 -0
  62. /package/lib/ui/{components/validation → validation}/item-validation-summary.component.d.ts +0 -0
@@ -1,13 +1,18 @@
1
1
  import Swal from 'sweetalert2';
2
- import { v4 } from 'uuid';
3
- import { Injectable, ɵɵdefineInjectable, Injector, NgModule, Optional, SkipSelf, Component, Input, Directive, ElementRef } from '@angular/core';
4
- import { ActivatedRoute, Router } from '@angular/router';
2
+ import { ɵɵdefineInjectable, Injectable, ɵɵinject, NgModule, Injector, Optional, SkipSelf, Component, Input, Directive, ElementRef, Pipe, APP_INITIALIZER } from '@angular/core';
3
+ import { CommonModule, LOCATION_INITIALIZED } from '@angular/common';
5
4
  import { HttpClient, HttpResponse } from '@angular/common/http';
6
5
  import { map, tap } from 'rxjs/operators';
7
6
  import { BehaviorSubject } from 'rxjs';
8
- import { CommonModule } from '@angular/common';
7
+ import { ToastrService } from 'ngx-toastr';
8
+ import { v4 } from 'uuid';
9
+ import { TranslateService, TranslateModule, TranslateLoader } from '@ngx-translate/core';
10
+ import { isValid, format, formatDistanceToNow, formatDistance } from 'date-fns';
11
+ import enUS from 'date-fns/locale/en-US';
12
+ import { ActivatedRoute, Router } from '@angular/router';
9
13
  import { NgControl, ReactiveFormsModule, FormsModule } from '@angular/forms';
10
14
  import { FroalaEditorModule, FroalaViewModule } from 'angular-froala-wysiwyg';
15
+ import { TranslateHttpLoader } from '@ngx-translate/http-loader';
11
16
 
12
17
  /*
13
18
  <file>
@@ -30,6 +35,28 @@ import { FroalaEditorModule, FroalaViewModule } from 'angular-froala-wysiwyg';
30
35
  const ContextInitState = JSON.parse((document.getElementById('contextInitState')).getAttribute('data-contextinitstate'));
31
36
  const AppCoreSettings = JSON.parse((document.getElementById('appCoreSettings')).getAttribute('data-appcoresettings'));
32
37
 
38
+ /*
39
+ <file>
40
+ Project:
41
+ MICE
42
+
43
+ Authors:
44
+ Vadim Osovitny vaosovitny@deloitte.com
45
+
46
+ Created:
47
+ 5 May 2020
48
+
49
+ Version:
50
+ 1.0
51
+
52
+ Copyright (c) 2020 Deloitte Tax. All rights reserved.
53
+ </file>
54
+ */
55
+ const Urls = {
56
+ // SignalR Notifications
57
+ notificationsSocketUrl: '/hubs/notifications'
58
+ };
59
+
33
60
  /*
34
61
  <file>
35
62
  Project:
@@ -94,43 +121,43 @@ function throwIfAlreadyLoaded(parentModule, moduleName) {
94
121
  class Alerts {
95
122
  static Info(text) {
96
123
  Swal.fire({
97
- title: "Information",
98
- text: text,
99
- icon: "info",
100
- confirmButtonText: "OK",
124
+ title: 'Information',
125
+ text,
126
+ icon: 'info',
127
+ confirmButtonText: 'OK',
101
128
  });
102
129
  }
103
130
  static Warning(text) {
104
131
  Swal.fire({
105
- title: "Warning",
106
- text: text,
107
- icon: "warning",
108
- confirmButtonText: "OK",
132
+ title: 'Warning',
133
+ text,
134
+ icon: 'warning',
135
+ confirmButtonText: 'OK',
109
136
  });
110
137
  }
111
138
  static Error(text) {
112
139
  Swal.fire({
113
- title: "Error",
114
- text: text,
115
- icon: "error",
116
- confirmButtonText: "OK",
140
+ title: 'Error',
141
+ text,
142
+ icon: 'error',
143
+ confirmButtonText: 'OK',
117
144
  });
118
145
  }
119
146
  static NotImplemented() {
120
- this.Warning("Not Implemented Yet");
147
+ this.Warning('Not Implemented Yet');
121
148
  }
122
149
  static ErrorOccurred() {
123
- this.Error("Sorry, an unexpected error occurred");
150
+ this.Error('Sorry, an unexpected error occurred');
124
151
  }
125
152
  static AreYouSure(text, title, confirmButtonText, cancelButtonText, successAction, cancelAction) {
126
- if (typeof title == "undefined" || title == null)
127
- title = "Are you sure?";
153
+ if (typeof title === 'undefined' || title == null)
154
+ title = 'Are you sure?';
128
155
  Swal.fire({
129
- title: title,
130
- text: text,
131
- icon: "warning",
132
- confirmButtonText: confirmButtonText,
133
- cancelButtonText: cancelButtonText,
156
+ title,
157
+ text,
158
+ icon: 'warning',
159
+ confirmButtonText,
160
+ cancelButtonText,
134
161
  showCancelButton: true,
135
162
  }).then((result) => {
136
163
  if (result.value) {
@@ -139,8 +166,8 @@ class Alerts {
139
166
  }
140
167
  }
141
168
  // result.dismiss can be 'cancel', 'overlay', 'close', and 'timer'
142
- else if (result.dismiss == Swal.DismissReason.cancel ||
143
- result.dismiss == Swal.DismissReason.close) {
169
+ else if (result.dismiss === Swal.DismissReason.cancel ||
170
+ result.dismiss === Swal.DismissReason.close) {
144
171
  if (cancelAction) {
145
172
  cancelAction();
146
173
  }
@@ -148,17 +175,17 @@ class Alerts {
148
175
  });
149
176
  }
150
177
  static Success(text, title, successAction) {
151
- if (typeof title == "undefined" || title == null)
152
- title = "Success";
178
+ if (typeof title === 'undefined' || title == null)
179
+ title = 'Success';
153
180
  if (!text) {
154
- text = "Operation was successful";
181
+ text = 'Operation was successful';
155
182
  }
156
183
  Swal.fire({
157
- title: title,
158
- text: text,
159
- icon: "success",
160
- confirmButtonText: "OK",
161
- }).then(function () {
184
+ title,
185
+ text,
186
+ icon: 'success',
187
+ confirmButtonText: 'OK',
188
+ }).then(() => {
162
189
  if (successAction) {
163
190
  successAction();
164
191
  }
@@ -166,202 +193,57 @@ class Alerts {
166
193
  }
167
194
  static Cancel(text) {
168
195
  if (!text) {
169
- text = "Operation has been cancled";
196
+ text = 'Operation has been cancled';
170
197
  }
171
198
  Swal.fire({
172
- title: "Cancelled",
173
- text: text,
174
- icon: "info",
199
+ title: 'Cancelled',
200
+ text,
201
+ icon: 'info',
175
202
  });
176
203
  }
177
- //Notifications
204
+ // Notifications
178
205
  static NotificationCancel(text, title) {
179
- if (typeof title == "undefined" || title == null) {
180
- title = "Canceled";
206
+ if (typeof title === 'undefined' || title == null) {
207
+ title = 'Canceled';
181
208
  }
182
209
  if (!text) {
183
- text = "Operation has been canceled";
210
+ text = 'Operation has been canceled';
184
211
  }
185
212
  const toast = Swal.mixin({
186
213
  toast: true,
187
- position: "top-end",
214
+ position: 'top-end',
188
215
  showConfirmButton: false,
189
216
  timer: 3000,
190
217
  timerProgressBar: true,
191
218
  });
192
219
  toast.fire({
193
- title: title,
194
- text: text,
195
- icon: "info",
220
+ title,
221
+ text,
222
+ icon: 'info',
196
223
  });
197
224
  }
198
225
  static NotificationSuccess(text, title) {
199
- if (typeof title == "undefined" || title == null) {
200
- title = "Success";
226
+ if (typeof title === 'undefined' || title == null) {
227
+ title = 'Success';
201
228
  }
202
229
  if (!text) {
203
- text = "Operation was successful";
230
+ text = 'Operation was successful';
204
231
  }
205
232
  const toast = Swal.mixin({
206
233
  toast: true,
207
- position: "top-end",
234
+ position: 'top-end',
208
235
  showConfirmButton: false,
209
236
  timer: 3000,
210
237
  timerProgressBar: true,
211
238
  });
212
239
  toast.fire({
213
- title: title,
214
- text: text,
215
- icon: "success",
240
+ title,
241
+ text,
242
+ icon: 'success',
216
243
  });
217
244
  }
218
245
  }
219
246
 
220
- /*
221
- <file>
222
- Project:
223
- @osovitny/anatoly
224
-
225
- Authors:
226
- Vadim Osovitny
227
- Anatoly Osovitny
228
-
229
- Created:
230
- 26 Jun 2020
231
-
232
- Version:
233
- 1.0
234
-
235
- Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
236
- </file>
237
- */
238
- class Utils {
239
- static getValueByNameInQS(name) {
240
- return Utils.getValueByName(location.search, name);
241
- }
242
- static getValueByName(url, name) {
243
- name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
244
- var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), results = regex.exec(url);
245
- return results === null
246
- ? ""
247
- : decodeURIComponent(results[1].replace(/\+/g, " "));
248
- }
249
- static copyToClipBoard(event, val) {
250
- event.preventDefault();
251
- let selBox = document.createElement("textarea");
252
- selBox.style.position = "fixed";
253
- selBox.style.left = "0";
254
- selBox.style.top = "0";
255
- selBox.style.opacity = "0";
256
- selBox.value = val;
257
- document.body.appendChild(selBox);
258
- selBox.focus();
259
- selBox.select();
260
- document.execCommand("copy");
261
- document.body.removeChild(selBox);
262
- }
263
- static downloadFile(name, url) {
264
- var link = document.createElement("a");
265
- link.download = name;
266
- link.href = url;
267
- link.click();
268
- }
269
- }
270
-
271
- /*
272
- <file>
273
- Project:
274
- @osovitny/anatoly
275
-
276
- Authors:
277
- Vadim Osovitny
278
- Anatoly Osovitny
279
-
280
- Created:
281
- 26 Jun 2020
282
-
283
- Version:
284
- 1.0
285
-
286
- Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
287
- </file>
288
- */
289
- class Subs {
290
- constructor() {
291
- this.subs = [];
292
- }
293
- add(...subscriptions) {
294
- this.subs = this.subs.concat(subscriptions);
295
- }
296
- set sink(subscription) {
297
- this.subs.push(subscription);
298
- }
299
- unsubscribe() {
300
- this.subs.forEach((sub) => sub && sub.unsubscribe());
301
- this.subs = [];
302
- }
303
- }
304
-
305
- /*
306
- <file>
307
- Project:
308
- @osovitny/anatoly
309
-
310
- Authors:
311
- Vadim Osovitny
312
- Anatoly Osovitny
313
-
314
- Created:
315
- 26 Jun 2020
316
-
317
- Version:
318
- 1.0
319
-
320
- Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
321
- </file>
322
- */
323
- class Guid {
324
- static newGuid() {
325
- return v4();
326
- }
327
- }
328
-
329
- /*
330
- <file>
331
- Project:
332
- @osovitny/anatoly
333
-
334
- Authors:
335
- Vadim Osovitny
336
- Anatoly Osovitny
337
-
338
- Created:
339
- 17 Jun 2018
340
-
341
- Version:
342
- 1.0
343
-
344
- Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
345
- </file>
346
- */
347
- class BaseGoService {
348
- constructor(route, router) {
349
- this.route = route;
350
- this.router = router;
351
- }
352
- locationReload() {
353
- //this.router.navigate([this.route.url]);
354
- window.location.reload();
355
- }
356
- }
357
- BaseGoService.decorators = [
358
- { type: Injectable }
359
- ];
360
- BaseGoService.ctorParameters = () => [
361
- { type: ActivatedRoute },
362
- { type: Router }
363
- ];
364
-
365
247
  /*
366
248
  <file>
367
249
  Project:
@@ -397,42 +279,6 @@ LoggingService.decorators = [
397
279
  ];
398
280
  LoggingService.ctorParameters = () => [];
399
281
 
400
- /*
401
- <file>
402
- Project:
403
- @osovitny/anatoly
404
-
405
- Authors:
406
- Vadim Osovitny
407
- Anatoly Osovitny
408
-
409
- Created:
410
- 26 Jun 2020
411
-
412
- Version:
413
- 1.0
414
-
415
- Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
416
- </file>
417
- */
418
- class GlobalErrorHandler {
419
- constructor(injector) {
420
- this.injector = injector;
421
- }
422
- handleError(error) {
423
- const loggingService = this.injector.get(LoggingService);
424
- loggingService.logError(error);
425
- // IMPORTANT: Rethrow the error otherwise it gets swallowed
426
- throw error;
427
- }
428
- }
429
- GlobalErrorHandler.decorators = [
430
- { type: Injectable }
431
- ];
432
- GlobalErrorHandler.ctorParameters = () => [
433
- { type: Injector }
434
- ];
435
-
436
282
  /*
437
283
  <file>
438
284
  Project:
@@ -454,63 +300,59 @@ GlobalErrorHandler.ctorParameters = () => [
454
300
  class BaseApiService {
455
301
  constructor(http) {
456
302
  this.http = http;
457
- this.baseUrl = "";
303
+ this.baseUrl = '';
458
304
  }
459
305
  serializeParams(data) {
460
- return data ? "?" + $.param(data) : "";
306
+ return data ? '?' + $.param(data) : '';
461
307
  }
462
- //api
308
+ // api
463
309
  get(action, data, responseType) {
464
310
  if (!responseType) {
465
- responseType = "json";
311
+ responseType = 'json';
466
312
  }
467
- var url = `${this.baseUrl}/${action}${this.serializeParams(data)}`;
313
+ const url = `${this.baseUrl}/${action}${this.serializeParams(data)}`;
468
314
  return this.http
469
- .get(url, { responseType: responseType })
315
+ .get(url, { responseType })
470
316
  .pipe(map((res) => res));
471
317
  }
472
318
  post(action, data, responseType) {
473
319
  if (!responseType) {
474
- responseType = "text";
320
+ responseType = 'text';
475
321
  }
476
- var url = `${this.baseUrl}/${action}`;
477
- return this.http.post(url, data, { responseType: responseType });
322
+ const url = `${this.baseUrl}/${action}`;
323
+ return this.http.post(url, data, { responseType });
478
324
  }
479
325
  postQS(action, data, responseType) {
480
326
  if (!responseType) {
481
- responseType = "text";
327
+ responseType = 'text';
482
328
  }
483
- var url = `${this.baseUrl}/${action}${this.serializeParams(data)}`;
484
- return this.http.post(url, null, { responseType: responseType });
329
+ const url = `${this.baseUrl}/${action}${this.serializeParams(data)}`;
330
+ return this.http.post(url, null, { responseType });
485
331
  }
486
332
  delete(action, data, responseType) {
487
333
  if (!responseType) {
488
- responseType = "text";
334
+ responseType = 'text';
489
335
  }
490
- var url = `${this.baseUrl}/${action}${this.serializeParams(data)}`;
491
- return this.http.delete(url, { responseType: responseType });
336
+ const url = `${this.baseUrl}/${action}${this.serializeParams(data)}`;
337
+ return this.http.delete(url, { responseType });
492
338
  }
493
- //gets
339
+ // gets
494
340
  getById(id) {
495
- return this.get("getById", { id: id });
341
+ return this.get('getById', { id });
496
342
  }
497
343
  getAll(data) {
498
- return this.get("getall", data).pipe(map((res) => res));
344
+ return this.get('getall', data).pipe(map((res) => res));
499
345
  }
500
346
  getJsonFile(fileName, jsonUrl, jsonVersion) {
501
347
  if (!jsonUrl) {
502
- jsonUrl = "/dist/jsons";
348
+ jsonUrl = '/dist/jsons';
503
349
  }
504
350
  if (!jsonVersion) {
505
- jsonVersion = "1.0";
351
+ jsonVersion = '1.0';
506
352
  }
507
- var url = jsonUrl + "/" + fileName + "?" + jsonVersion;
353
+ const url = jsonUrl + '/' + fileName + '?' + jsonVersion;
508
354
  return this.http.get(url).pipe(map((res) => res));
509
355
  }
510
- getNewGuid() {
511
- var url = `${this.baseUrl}/getNewGuid`;
512
- return this.http.get(url, { responseType: "text" });
513
- }
514
356
  }
515
357
  BaseApiService.decorators = [
516
358
  { type: Injectable }
@@ -630,21 +472,611 @@ class LoadingService extends BehaviorSubject {
630
472
  this.next(false);
631
473
  }
632
474
  }
633
- freeze(timeout = 1000) {
634
- this.isFreezed = true;
635
- let that = this;
636
- setTimeout(() => {
637
- this.isFreezed = false;
638
- }, timeout);
475
+ freeze(timeout = 1000) {
476
+ this.isFreezed = true;
477
+ let that = this;
478
+ setTimeout(() => {
479
+ this.isFreezed = false;
480
+ }, timeout);
481
+ }
482
+ }
483
+ LoadingService.ɵprov = ɵɵdefineInjectable({ factory: function LoadingService_Factory() { return new LoadingService(); }, token: LoadingService, providedIn: "root" });
484
+ LoadingService.decorators = [
485
+ { type: Injectable, args: [{
486
+ providedIn: "root",
487
+ },] }
488
+ ];
489
+ LoadingService.ctorParameters = () => [];
490
+
491
+ /*
492
+ <file>
493
+ Project:
494
+ @osovitny/anatoly
495
+
496
+ Authors:
497
+ Vadim Osovitny
498
+ Anatoly Osovitny
499
+
500
+ Created:
501
+ 26 Jun 2020
502
+
503
+ Version:
504
+ 1.0
505
+
506
+ Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
507
+ </file>
508
+ */
509
+ class Guid {
510
+ static newGuid() {
511
+ return v4();
512
+ }
513
+ }
514
+
515
+ /*
516
+ <file>
517
+ Project:
518
+ @osovitny/anatoly
519
+
520
+ Authors:
521
+ Vadim Osovitny
522
+ Anatoly Osovitny
523
+
524
+ Created:
525
+ 2 Jun 2020
526
+
527
+ Version:
528
+ 1.0
529
+
530
+ Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
531
+ </file>
532
+ */
533
+ // SignalR
534
+ // import * as signalR from '@microsoft/signalr';
535
+ // import { NotificationsApiService } from '../../../data/services/notifications/notifications-api-service';
536
+ class NotificationService {
537
+ constructor(toastrService) {
538
+ this.toastrService = toastrService;
539
+ // SignalR
540
+ // private hubConnection: signalR.HubConnection;
541
+ // private socketUrl: string;
542
+ // Notifications
543
+ this._sessionNotifications = new BehaviorSubject([]);
544
+ this._serverNotifications = new BehaviorSubject([]);
545
+ // Public
546
+ this.sessionNotifications$ = this._sessionNotifications.asObservable();
547
+ this.serverNotifications$ = this._serverNotifications.asObservable();
548
+ // this.onInit();
549
+ }
550
+ /*
551
+ onInit() {
552
+ if (AppCoreSettings.AzureAD) {
553
+ this.authService.getAuthToken().subscribe((token: string) => {
554
+ this.startSignalRConnection(token);
555
+ });
556
+
557
+ return;
558
+ }
559
+
560
+ this.startSignalRConnection();
561
+ }
562
+
563
+ ngOnDestroy() {
564
+ this.stopSignalRConnection();
565
+ }
566
+
567
+ // SignalR
568
+ private startSignalRConnection(accessToken?) {
569
+ const cskii = AppCoreSettings.selectedClientID;
570
+ // tslint:disable-next-line:variable-name
571
+ const cskii_upn = AppCoreSettings.CSKII_UPN;
572
+ // tslint:disable-next-line:variable-name
573
+ const cli_sessionguid = AppCoreSettings.CLI_SessionGUID;
574
+
575
+ const url = this.socketUrl + '?cskii=' + cskii + '&cskii_upn=' + cskii_upn + '&cli_sessionguid=' + cli_sessionguid;
576
+
577
+ if (accessToken) {
578
+ this.hubConnection = new signalR.HubConnectionBuilder()
579
+ .withUrl(url, {
580
+ skipNegotiation: false,
581
+ transport: signalR.HttpTransportType.WebSockets,
582
+ accessTokenFactory: () => accessToken
583
+ })
584
+ .withAutomaticReconnect()
585
+ .configureLogging(signalR.LogLevel.Debug)
586
+ .build();
587
+ }
588
+ else {
589
+ this.hubConnection = new signalR.HubConnectionBuilder()
590
+ .withUrl(this.socketUrl, {
591
+ skipNegotiation: true,
592
+ transport: signalR.HttpTransportType.WebSockets
593
+ })
594
+ .withAutomaticReconnect()
595
+ .configureLogging(signalR.LogLevel.Debug)
596
+ .build();
597
+ }
598
+
599
+ this.hubConnection
600
+ .start()
601
+ .then(() => this.signalRConnection_onSuccess())
602
+ .catch(err => {
603
+ console.error('Connection failed to SignalR Notification Hub')
604
+ })
605
+ }
606
+
607
+ private signalRConnection_onSuccess() {
608
+ this.addReceiveMessageDataListener();
609
+
610
+ this.notificationsApiService.retrieveNotifications().subscribe(data => {
611
+ this.serverNotifications = data;
612
+ });
613
+ }
614
+
615
+ stopSignalRConnection() {
616
+ if (this.hubConnection) {
617
+ this.hubConnection.stop();
618
+ this.hubConnection = null;
619
+ }
620
+ }
621
+
622
+ private addReceiveMessageDataListener = () => {
623
+ this.hubConnection.on('ReceiveMessage', (message) => {
624
+ if (message) {
625
+ if (message.type === 'error') {
626
+ this.error(message.text, null, null, false);
627
+ }
628
+ else {
629
+ this.success(message.text, null, null, false);
630
+ }
631
+
632
+ const notification = {
633
+ id: message.id,
634
+ isNew: message.isNew,
635
+ isSession: true,
636
+ text: message.text,
637
+ type: message.type,
638
+ createdDate: message.createdDate
639
+ };
640
+
641
+ this.addSessionNotificationToList(notification);
642
+ }
643
+ });
644
+ }
645
+ */
646
+ addSessionNotification(text, type) {
647
+ const id = Guid.newGuid();
648
+ const notification = { id, isNew: true, isSession: true, text, type, createdDate: new Date(Date.now()).toISOString() };
649
+ this.addSessionNotificationToList(notification);
650
+ }
651
+ addSessionNotificationToList(notification) {
652
+ this.sessionNotifications = [
653
+ notification,
654
+ ...this.sessionNotifications,
655
+ ];
656
+ }
657
+ // Public API
658
+ removeNotification(id, isSession) {
659
+ if (isSession) {
660
+ this.sessionNotifications = this.sessionNotifications.filter(notifications => notifications.id !== id);
661
+ }
662
+ else {
663
+ this.serverNotifications = this.serverNotifications.filter(notifications => notifications.id !== id);
664
+ }
665
+ }
666
+ success(text, params, title, createSessionNotification = true) {
667
+ text = Utils.getLocalizedValue(text, params, 'OperationSuccessFull');
668
+ title = Utils.getLocalizedValue(title);
669
+ this.toastrService.success(text, title, {
670
+ timeOut: 3000,
671
+ progressBar: true
672
+ });
673
+ if (createSessionNotification) {
674
+ this.addSessionNotification(text, 'success');
675
+ }
676
+ }
677
+ info(text, params, title) {
678
+ text = Utils.getLocalizedValue(text, params);
679
+ title = Utils.getLocalizedValue(title);
680
+ this.toastrService.info(text, title, {
681
+ timeOut: 3000,
682
+ progressBar: true
683
+ });
684
+ }
685
+ warning(text, params, title) {
686
+ text = Utils.getLocalizedValue(text, params);
687
+ title = Utils.getLocalizedValue(title);
688
+ this.toastrService.warning(text, title, {
689
+ timeOut: 3000,
690
+ progressBar: true
691
+ });
692
+ }
693
+ error(text, params, title, createSessionNotification = true) {
694
+ text = Utils.getLocalizedValue(text, params, 'ErrorOccured');
695
+ title = Utils.getLocalizedValue(title);
696
+ this.toastrService.error(text, title, {
697
+ timeOut: 3000,
698
+ progressBar: true
699
+ });
700
+ if (createSessionNotification) {
701
+ this.addSessionNotification(text, 'error');
702
+ }
703
+ }
704
+ cancel(text, params, title) {
705
+ text = Utils.getLocalizedValue(text, params, 'OperationCancelled');
706
+ title = Utils.getLocalizedValue(title);
707
+ this.toastrService.info(text, title, {
708
+ timeOut: 3000,
709
+ progressBar: true
710
+ });
711
+ }
712
+ // SessionNotifications
713
+ get sessionNotifications() {
714
+ return this._sessionNotifications.getValue();
715
+ }
716
+ set sessionNotifications(val) {
717
+ this._sessionNotifications.next(val);
718
+ }
719
+ // ServerNotifications
720
+ get serverNotifications() {
721
+ return this._serverNotifications.getValue();
722
+ }
723
+ set serverNotifications(val) {
724
+ this._serverNotifications.next(val);
725
+ }
726
+ }
727
+ NotificationService.ɵprov = ɵɵdefineInjectable({ factory: function NotificationService_Factory() { return new NotificationService(ɵɵinject(ToastrService)); }, token: NotificationService, providedIn: "root" });
728
+ NotificationService.decorators = [
729
+ { type: Injectable, args: [{ providedIn: 'root' },] }
730
+ ];
731
+ NotificationService.ctorParameters = () => [
732
+ { type: ToastrService }
733
+ ];
734
+
735
+ const providers = [
736
+ LoggingService,
737
+ NotificationService,
738
+ AppContextService,
739
+ LoadingService
740
+ ];
741
+ let InjectorInstance;
742
+ class AnatolyCoreModule {
743
+ constructor(injector, parentModule) {
744
+ this.injector = injector;
745
+ throwIfAlreadyLoaded(parentModule, 'AnatolyCoreModule');
746
+ InjectorInstance = this.injector;
747
+ }
748
+ }
749
+ AnatolyCoreModule.decorators = [
750
+ { type: NgModule, args: [{
751
+ imports: [CommonModule],
752
+ exports: [],
753
+ providers: [...providers],
754
+ },] }
755
+ ];
756
+ AnatolyCoreModule.ctorParameters = () => [
757
+ { type: Injector },
758
+ { type: AnatolyCoreModule, decorators: [{ type: Optional }, { type: SkipSelf }] }
759
+ ];
760
+
761
+ /*
762
+ <file>
763
+ Project:
764
+ @osovitny/anatoly
765
+
766
+ Authors:
767
+ Vadim Osovitny
768
+ Anatoly Osovitny
769
+
770
+ Created:
771
+ 29 June 2020
772
+
773
+ Version:
774
+ 1.0
775
+
776
+ Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
777
+ </file>
778
+ */
779
+ class Convert {
780
+ /**
781
+ * Convert date time lo local time zone value.
782
+ * @param value
783
+ */
784
+ static toLocalizedDateTime(value) {
785
+ if (value) {
786
+ return new Date(Date.UTC(value.getFullYear(), value.getMonth(), value.getDate(), value.getHours(), value.getMinutes(), value.getSeconds(), value.getMilliseconds()));
787
+ }
788
+ return null;
789
+ }
790
+ }
791
+
792
+ /*
793
+ <file>
794
+ Project:
795
+ @osovitny/anatoly
796
+
797
+ Authors:
798
+ Vadim Osovitny
799
+ Anatoly Osovitny
800
+
801
+ Created:
802
+ 05 May 2020
803
+
804
+ Version:
805
+ 1.0
806
+
807
+ Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
808
+ </file>
809
+ */
810
+ class LocalizationService {
811
+ constructor(translate) {
812
+ this.translate = translate;
813
+ this.setSupportedLanguages(['en']);
814
+ }
815
+ format(str, args) {
816
+ // tslint:disable-next-line:variable-name
817
+ return str.replace(/{(\d+)}/g, (match, number) => typeof args[number] !== 'undefined' ? args[number] : match);
818
+ }
819
+ ;
820
+ configureTranslationSettings(translate) {
821
+ const languageToSet = 'en';
822
+ translate.setDefaultLang(languageToSet);
823
+ return languageToSet;
824
+ }
825
+ getBrowserLanguage() {
826
+ return this.translate.getBrowserLang();
827
+ }
828
+ getDatefnsLocale() {
829
+ let dfnLocale;
830
+ switch (this.getBrowserLanguage()) {
831
+ case 'en':
832
+ dfnLocale = { locale: enUS };
833
+ break;
834
+ default:
835
+ dfnLocale = { locale: enUS };
836
+ }
837
+ return dfnLocale;
838
+ }
839
+ setDefaultLanguage(lang) {
840
+ this.translate.setDefaultLang(lang);
841
+ }
842
+ setSupportedLanguages(languages) {
843
+ this.translate.addLangs(languages);
844
+ }
845
+ updateLanguage(language) {
846
+ this.translate.use(language);
847
+ }
848
+ getLocalizedValue(key, params) {
849
+ const value = this.translate.instant(key);
850
+ if (!params || params.length === 0) {
851
+ return value;
852
+ }
853
+ return this.format(value, params);
854
+ }
855
+ getLocalizedDate(key) {
856
+ if (isValid(new Date(key))) {
857
+ return format(new Date(key), AppCoreSettings.DATE_FORMATS.angular, this.dateFnsLocale);
858
+ }
859
+ return 'Invalid Date';
860
+ }
861
+ getLocalizedDateTime(key) {
862
+ // To Do Manoj: Test in IE and make TimeZone specific changes accordingly
863
+ const dateValue = new Date(key);
864
+ if (isValid(dateValue)) {
865
+ const localDate = Convert.toLocalizedDateTime(dateValue);
866
+ return format(localDate, AppCoreSettings.DATE_FORMATS.angularWithTime, this.dateFnsLocale);
867
+ }
868
+ return 'Invalid Date';
869
+ }
870
+ getLocalizedDistanceToNowInWords(date) {
871
+ // https://date-fns.org/v1.30.1/docs/distanceInWords
872
+ if (isValid(new Date(date))) {
873
+ return formatDistanceToNow(new Date(date), this.dateFnsLocale);
874
+ }
875
+ return 'Invalid Date';
876
+ }
877
+ getLocalizedDistanceInWords(endedDate, startedDate) {
878
+ if (isValid(new Date(endedDate)) && isValid(new Date(startedDate))) {
879
+ return formatDistance(new Date(endedDate), new Date(startedDate), this.dateFnsLocale);
880
+ }
881
+ return 'Invalid Date';
882
+ }
883
+ }
884
+ LocalizationService.ɵprov = ɵɵdefineInjectable({ factory: function LocalizationService_Factory() { return new LocalizationService(ɵɵinject(TranslateService)); }, token: LocalizationService, providedIn: "root" });
885
+ LocalizationService.decorators = [
886
+ { type: Injectable, args: [{
887
+ providedIn: 'root'
888
+ },] }
889
+ ];
890
+ LocalizationService.ctorParameters = () => [
891
+ { type: TranslateService }
892
+ ];
893
+
894
+ /*
895
+ <file>
896
+ Project:
897
+ @osovitny/anatoly
898
+
899
+ Authors:
900
+ Vadim Osovitny
901
+ Anatoly Osovitny
902
+
903
+ Created:
904
+ 19 March 2020
905
+
906
+ Version:
907
+ 1.0
908
+
909
+ Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
910
+ </file>
911
+ */
912
+ class Utils {
913
+ static getValueByNameInQS(name) {
914
+ return Utils.getValueByName(location.search, name);
915
+ }
916
+ static getValueByName(url, name) {
917
+ name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
918
+ // tslint:disable-next-line:one-variable-per-declaration
919
+ const regex = new RegExp('[\\?&]' + name + '=([^&#]*)'), results = regex.exec(url);
920
+ return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
921
+ }
922
+ static copyToClipBoard(event, val) {
923
+ event.preventDefault();
924
+ const selBox = document.createElement('textarea');
925
+ selBox.style.position = 'fixed';
926
+ selBox.style.left = '0';
927
+ selBox.style.top = '0';
928
+ selBox.style.opacity = '0';
929
+ selBox.value = val;
930
+ document.body.appendChild(selBox);
931
+ selBox.focus();
932
+ selBox.select();
933
+ document.execCommand('copy');
934
+ document.body.removeChild(selBox);
935
+ }
936
+ static downloadFile(name, url) {
937
+ const link = document.createElement('a');
938
+ link.download = name;
939
+ link.href = url;
940
+ link.click();
941
+ }
942
+ // Localization
943
+ // @dynamic
944
+ static get localizationService() {
945
+ const ns = InjectorInstance.get(LocalizationService);
946
+ return ns;
947
+ }
948
+ static getLocalizedValue(key, params, defaultKey) {
949
+ // VadimOS: DON'T CHANGE THIS CODE. NEED TO BE REVIEWED AND APPROVED BY VADIMOS
950
+ // defaultKey definition:
951
+ // if key is empty and defaultKey is defined => get localization for defaultKey
952
+ // Example: cancel()
953
+ if (!key && defaultKey) {
954
+ return this.localizationService.getLocalizedValue(defaultKey);
955
+ }
956
+ // VadimOS:
957
+ // if key is not empty value MUST be in localization table, othewise we will return key
958
+ if (key) {
959
+ const value = this.localizationService.getLocalizedValue(key, params);
960
+ return value;
961
+ }
962
+ return key;
963
+ }
964
+ static downloadBlobFile(value, fileName) {
965
+ if (window.navigator.msSaveOrOpenBlob) {
966
+ window.navigator.msSaveOrOpenBlob(value, fileName);
967
+ }
968
+ else {
969
+ const downloadURL = window.URL.createObjectURL(value);
970
+ Utils.downloadFile(fileName, downloadURL);
971
+ }
972
+ }
973
+ }
974
+
975
+ /*
976
+ <file>
977
+ Project:
978
+ @osovitny/anatoly
979
+
980
+ Authors:
981
+ Vadim Osovitny
982
+ Anatoly Osovitny
983
+
984
+ Created:
985
+ 26 Jun 2020
986
+
987
+ Version:
988
+ 1.0
989
+
990
+ Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
991
+ </file>
992
+ */
993
+ class Subs {
994
+ constructor() {
995
+ this.subs = [];
996
+ }
997
+ add(...subscriptions) {
998
+ this.subs = this.subs.concat(subscriptions);
999
+ }
1000
+ set sink(subscription) {
1001
+ this.subs.push(subscription);
1002
+ }
1003
+ unsubscribe() {
1004
+ this.subs.forEach((sub) => sub && sub.unsubscribe());
1005
+ this.subs = [];
1006
+ }
1007
+ }
1008
+
1009
+ /*
1010
+ <file>
1011
+ Project:
1012
+ @osovitny/anatoly
1013
+
1014
+ Authors:
1015
+ Vadim Osovitny
1016
+ Anatoly Osovitny
1017
+
1018
+ Created:
1019
+ 17 Jun 2018
1020
+
1021
+ Version:
1022
+ 1.0
1023
+
1024
+ Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
1025
+ </file>
1026
+ */
1027
+ class BaseGoService {
1028
+ constructor(route, router) {
1029
+ this.route = route;
1030
+ this.router = router;
1031
+ }
1032
+ locationReload() {
1033
+ //this.router.navigate([this.route.url]);
1034
+ window.location.reload();
1035
+ }
1036
+ }
1037
+ BaseGoService.decorators = [
1038
+ { type: Injectable }
1039
+ ];
1040
+ BaseGoService.ctorParameters = () => [
1041
+ { type: ActivatedRoute },
1042
+ { type: Router }
1043
+ ];
1044
+
1045
+ /*
1046
+ <file>
1047
+ Project:
1048
+ @osovitny/anatoly
1049
+
1050
+ Authors:
1051
+ Vadim Osovitny
1052
+ Anatoly Osovitny
1053
+
1054
+ Created:
1055
+ 26 Jun 2020
1056
+
1057
+ Version:
1058
+ 1.0
1059
+
1060
+ Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
1061
+ </file>
1062
+ */
1063
+ class GlobalErrorHandler {
1064
+ constructor(injector) {
1065
+ this.injector = injector;
1066
+ }
1067
+ handleError(error) {
1068
+ const loggingService = this.injector.get(LoggingService);
1069
+ loggingService.logError(error);
1070
+ // IMPORTANT: Rethrow the error otherwise it gets swallowed
1071
+ throw error;
639
1072
  }
640
1073
  }
641
- LoadingService.ɵprov = ɵɵdefineInjectable({ factory: function LoadingService_Factory() { return new LoadingService(); }, token: LoadingService, providedIn: "root" });
642
- LoadingService.decorators = [
643
- { type: Injectable, args: [{
644
- providedIn: "root",
645
- },] }
1074
+ GlobalErrorHandler.decorators = [
1075
+ { type: Injectable }
646
1076
  ];
647
- LoadingService.ctorParameters = () => [];
1077
+ GlobalErrorHandler.ctorParameters = () => [
1078
+ { type: Injector }
1079
+ ];
648
1080
 
649
1081
  /*
650
1082
  <file>
@@ -745,30 +1177,6 @@ AnatolyHttpInterceptor.ctorParameters = () => [
745
1177
  { type: LoggingService }
746
1178
  ];
747
1179
 
748
- const providers = [
749
- LoggingService,
750
- AppContextService,
751
- LoadingService
752
- ];
753
- let InjectorInstance;
754
- class AnatolyCoreModule {
755
- constructor(injector, parentModule) {
756
- this.injector = injector;
757
- throwIfAlreadyLoaded(parentModule, 'AnatolyCoreModule');
758
- InjectorInstance = this.injector;
759
- }
760
- }
761
- AnatolyCoreModule.decorators = [
762
- { type: NgModule, args: [{
763
- imports: [CommonModule],
764
- providers: [...providers],
765
- },] }
766
- ];
767
- AnatolyCoreModule.ctorParameters = () => [
768
- { type: Injector },
769
- { type: AnatolyCoreModule, decorators: [{ type: Optional }, { type: SkipSelf }] }
770
- ];
771
-
772
1180
  /*
773
1181
  <file>
774
1182
  Project:
@@ -918,6 +1326,30 @@ BaseGridEditService.ctorParameters = () => [
918
1326
  { type: HttpClient }
919
1327
  ];
920
1328
 
1329
+ /*
1330
+ <file>
1331
+ Project:
1332
+ @osovitny/anatoly
1333
+
1334
+ Authors:
1335
+ Vadim Osovitny
1336
+ Anatoly Osovitny
1337
+
1338
+ Created:
1339
+ 30 April 2020
1340
+
1341
+ Version:
1342
+ 1.0
1343
+
1344
+ Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
1345
+ </file>
1346
+ */
1347
+ const consts = {
1348
+ billingApiPath: "api/billing",
1349
+ // Notifications API
1350
+ notificationsApiPath: 'api/notifications',
1351
+ };
1352
+
921
1353
  /*
922
1354
  <file>
923
1355
  Project:
@@ -940,12 +1372,10 @@ class BillingApiService extends BaseApiService {
940
1372
  constructor(http) {
941
1373
  super(http);
942
1374
  this.http = http;
943
- this.baseUrl += "billing/";
1375
+ this.baseUrl = consts.billingApiPath;
944
1376
  }
945
1377
  requestNewSubscription(requestedPlan, success, error) {
946
- this.postQS("requestNewSubscription", {
947
- requestedPlan: requestedPlan,
948
- }).subscribe((data) => { }, (e) => {
1378
+ this.postQS("requestNewSubscription", { requestedPlan: requestedPlan }).subscribe((data) => { }, (e) => {
949
1379
  if (error)
950
1380
  error();
951
1381
  }, () => {
@@ -998,12 +1428,22 @@ BillingApiService.ctorParameters = () => [
998
1428
  </file>
999
1429
  */
1000
1430
  class AnatolyDataModule {
1431
+ constructor(parentModule) {
1432
+ throwIfAlreadyLoaded(parentModule, 'AnatolyDataModule');
1433
+ }
1001
1434
  }
1002
1435
  AnatolyDataModule.decorators = [
1003
1436
  { type: NgModule, args: [{
1004
- imports: [CommonModule],
1005
- providers: [BillingApiService],
1437
+ imports: [
1438
+ CommonModule
1439
+ ],
1440
+ providers: [
1441
+ BillingApiService
1442
+ ],
1006
1443
  },] }
1444
+ ];
1445
+ AnatolyDataModule.ctorParameters = () => [
1446
+ { type: AnatolyDataModule, decorators: [{ type: Optional }, { type: SkipSelf }] }
1007
1447
  ];
1008
1448
 
1009
1449
  /*
@@ -1994,7 +2434,7 @@ AnatolyUIModule.decorators = [
1994
2434
  HtmlEditorComponent,
1995
2435
  FormsHtmlEditorComponent,
1996
2436
  ContentHeaderComponent,
1997
- //Directives
2437
+ // Directives
1998
2438
  NativeElementDirective
1999
2439
  ],
2000
2440
  declarations: [
@@ -2009,7 +2449,7 @@ AnatolyUIModule.decorators = [
2009
2449
  HtmlEditorComponent,
2010
2450
  FormsHtmlEditorComponent,
2011
2451
  ContentHeaderComponent,
2012
- //Directives
2452
+ // Directives
2013
2453
  NativeElementDirective
2014
2454
  ]
2015
2455
  },] }
@@ -2034,6 +2474,288 @@ AnatolyUIModule.decorators = [
2034
2474
  </file>
2035
2475
  */
2036
2476
 
2477
+ /*
2478
+ <file>
2479
+ Project:
2480
+ @osovitny/anatoly
2481
+
2482
+ Authors:
2483
+ Vadim Osovitny
2484
+ Anatoly Osovitny
2485
+
2486
+ Created:
2487
+ 10 May 2020
2488
+
2489
+ Version:
2490
+ 1.0
2491
+
2492
+ Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
2493
+ </file>
2494
+ */
2495
+ class LocalizePipe {
2496
+ constructor(localizeService) {
2497
+ this.localizeService = localizeService;
2498
+ }
2499
+ transform(inputData, type, param2) {
2500
+ if (!inputData) {
2501
+ return;
2502
+ }
2503
+ if (!type) {
2504
+ type = 't';
2505
+ }
2506
+ // Translate
2507
+ if (type === 't') {
2508
+ return this.localizeService.getLocalizedValue(inputData);
2509
+ }
2510
+ // Date
2511
+ if (type === 'd') {
2512
+ return this.localizeService.getLocalizedDate(inputData);
2513
+ }
2514
+ // DateTime
2515
+ if (type === 'dt') {
2516
+ return this.localizeService.getLocalizedDateTime(inputData);
2517
+ }
2518
+ // DistanceToNowInWords
2519
+ if (type === 'dis2now') {
2520
+ return this.localizeService.getLocalizedDistanceToNowInWords(inputData);
2521
+ }
2522
+ // DistanceInWords
2523
+ if (type === 'dis') {
2524
+ return this.localizeService.getLocalizedDistanceInWords(inputData, param2);
2525
+ }
2526
+ return inputData;
2527
+ }
2528
+ }
2529
+ LocalizePipe.decorators = [
2530
+ { type: Pipe, args: [{
2531
+ name: 'localize'
2532
+ },] }
2533
+ ];
2534
+ LocalizePipe.ctorParameters = () => [
2535
+ { type: LocalizationService }
2536
+ ];
2537
+
2538
+ /*
2539
+ <file>
2540
+ Project:
2541
+ @osovitny/anatoly
2542
+
2543
+ Authors:
2544
+ Vadim Osovitny
2545
+ Anatoly Osovitny
2546
+
2547
+ Created:
2548
+ 12 May 2020
2549
+
2550
+ Version:
2551
+ 1.0
2552
+
2553
+ Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
2554
+ </file>
2555
+ */
2556
+ class LocalizationModule {
2557
+ }
2558
+ LocalizationModule.decorators = [
2559
+ { type: NgModule, args: [{
2560
+ imports: [
2561
+ TranslateModule
2562
+ ],
2563
+ exports: [
2564
+ TranslateModule,
2565
+ LocalizePipe
2566
+ ],
2567
+ declarations: [
2568
+ LocalizePipe
2569
+ ],
2570
+ providers: []
2571
+ },] }
2572
+ ];
2573
+
2574
+ /*
2575
+ <file>
2576
+ Project:
2577
+ @osovitny/anatoly
2578
+
2579
+ Authors:
2580
+ Vadim Osovitny
2581
+ Anatoly Osovitny
2582
+
2583
+ Created:
2584
+ 05 May 2020
2585
+
2586
+ Version:
2587
+ 1.0
2588
+
2589
+ Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
2590
+ </file>
2591
+ */
2592
+ function customTranslateLoaderFactory(http) {
2593
+ return new TranslateHttpLoader(http, AppCoreSettings.resourcesUrl + "/", '.json');
2594
+ }
2595
+ function localizationInitializerFactory(translate, localizationService, injector) {
2596
+ return () => new Promise((resolve) => {
2597
+ let locationInitialized = injector.get(LOCATION_INITIALIZED, Promise.resolve(null));
2598
+ locationInitialized.then(() => {
2599
+ let languageToSet = localizationService.configureTranslationSettings(translate);
2600
+ translate.use(languageToSet).subscribe(() => {
2601
+ }, () => {
2602
+ resolve(null);
2603
+ }, () => {
2604
+ resolve(null);
2605
+ });
2606
+ });
2607
+ });
2608
+ }
2609
+ const TranslateModuleAtRoot = TranslateModule.forRoot({
2610
+ loader: {
2611
+ provide: TranslateLoader,
2612
+ useFactory: customTranslateLoaderFactory,
2613
+ deps: [HttpClient]
2614
+ }
2615
+ });
2616
+ class LocalizationSettingsModule {
2617
+ }
2618
+ LocalizationSettingsModule.decorators = [
2619
+ { type: NgModule, args: [{
2620
+ imports: [
2621
+ TranslateModuleAtRoot
2622
+ ],
2623
+ providers: [
2624
+ {
2625
+ provide: APP_INITIALIZER,
2626
+ useFactory: localizationInitializerFactory,
2627
+ deps: [TranslateService, LocalizationService, Injector],
2628
+ multi: true
2629
+ }
2630
+ ],
2631
+ exports: []
2632
+ },] }
2633
+ ];
2634
+
2635
+ /*
2636
+ <file>
2637
+ Project:
2638
+ @osovitny/anatoly
2639
+
2640
+ Authors:
2641
+ Vadim Osovitny
2642
+ Anatoly Osovitny
2643
+
2644
+ Created:
2645
+ 26 Jun 2020
2646
+
2647
+ Version:
2648
+ 1.0
2649
+
2650
+ Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
2651
+ </file>
2652
+ */
2653
+
2654
+ /*
2655
+ <file>
2656
+ Project:
2657
+ @osovitny/anatoly
2658
+
2659
+ Authors:
2660
+ Vadim Osovitny
2661
+ Anatoly Osovitny
2662
+
2663
+ Created:
2664
+ 3 March 2020
2665
+
2666
+ Version:
2667
+ 1.0
2668
+
2669
+ Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
2670
+ </file>
2671
+ */
2672
+ class Alerts$1 {
2673
+ static success(text, params, title, successAction) {
2674
+ text = Utils.getLocalizedValue(text, params, 'OperationSuccessFull');
2675
+ title = Utils.getLocalizedValue(title, null, 'Success');
2676
+ Swal.fire({
2677
+ text,
2678
+ title,
2679
+ icon: 'success',
2680
+ confirmButtonText: Utils.getLocalizedValue('Ok')
2681
+ })
2682
+ .then(() => {
2683
+ if (successAction) {
2684
+ successAction();
2685
+ }
2686
+ });
2687
+ }
2688
+ static info(text, params, title) {
2689
+ text = Utils.getLocalizedValue(text, params);
2690
+ title = Utils.getLocalizedValue(title, null, 'Info');
2691
+ Swal.fire({
2692
+ text,
2693
+ title,
2694
+ icon: 'info',
2695
+ confirmButtonText: Utils.getLocalizedValue('Ok')
2696
+ });
2697
+ }
2698
+ static warning(text, params, title) {
2699
+ text = Utils.getLocalizedValue(text, params);
2700
+ title = Utils.getLocalizedValue(title, null, 'Warning');
2701
+ Swal.fire({
2702
+ text,
2703
+ title,
2704
+ icon: 'warning',
2705
+ confirmButtonText: Utils.getLocalizedValue('Ok')
2706
+ });
2707
+ }
2708
+ static error(text, params, title) {
2709
+ text = Utils.getLocalizedValue(text, params, 'ErrorOccured');
2710
+ title = Utils.getLocalizedValue(title, null, 'Error');
2711
+ Swal.fire({
2712
+ text,
2713
+ title,
2714
+ icon: 'error',
2715
+ confirmButtonText: Utils.getLocalizedValue('Ok')
2716
+ });
2717
+ }
2718
+ static cancel(text, params, title) {
2719
+ text = Utils.getLocalizedValue(text, params, 'OperationCancelled');
2720
+ title = Utils.getLocalizedValue(title, null, 'Cancelled');
2721
+ Swal.fire({
2722
+ text,
2723
+ title,
2724
+ icon: 'info'
2725
+ });
2726
+ }
2727
+ static notImplemented() {
2728
+ this.warning('Not Implemented Yet');
2729
+ }
2730
+ ;
2731
+ static areYouSure(text, title, confirmButtonText, cancelButtonText, successAction, cancelAction) {
2732
+ text = Utils.getLocalizedValue(text);
2733
+ title = Utils.getLocalizedValue(title, null, 'AreYouSure');
2734
+ Swal.fire({
2735
+ text,
2736
+ title,
2737
+ icon: 'warning',
2738
+ confirmButtonText: Utils.getLocalizedValue(confirmButtonText),
2739
+ cancelButtonText: Utils.getLocalizedValue(cancelButtonText),
2740
+ showCancelButton: true
2741
+ })
2742
+ .then((result) => {
2743
+ if (result.value) {
2744
+ if (successAction) {
2745
+ successAction();
2746
+ }
2747
+ }
2748
+ // result.dismiss can be 'cancel', 'overlay', 'close', and 'timer'
2749
+ else if (result.dismiss == Swal.DismissReason.cancel || result.dismiss == Swal.DismissReason.close) {
2750
+ if (cancelAction) {
2751
+ cancelAction();
2752
+ }
2753
+ }
2754
+ });
2755
+ }
2756
+ ;
2757
+ }
2758
+
2037
2759
  /*
2038
2760
  * Public API Surface of anatoly
2039
2761
  */
@@ -2042,5 +2764,5 @@ AnatolyUIModule.decorators = [
2042
2764
  * Generated bundle index. Do not edit.
2043
2765
  */
2044
2766
 
2045
- export { Alerts, AnatolyCoreModule, AnatolyDataModule, AnatolyHttpInterceptor, AnatolyUIModule, AppContextService, AppCoreSettings, BaseApiService, BaseComponent, BaseEditComponent, BaseGoService, BaseGridEditService, BaseGridReadService, BillingApiService, BuyAccessButtonComponent, ContentHeaderComponent, ContextInitState, FormValidationSummaryComponent, FormsHtmlEditorComponent, GlobalErrorHandler, Guid, HtmlEditorComponent, ItemValidationSummaryComponent, LoadingService, LoggingService, NativeElementDirective, SignInButtonComponent, SignOutButtonComponent, SignUpButtonComponent, Subs, SubscribePlanButtonComponent, UpgradePlanButtonComponent, Utils, ValidationSummaryComponent, throwIfAlreadyLoaded };
2767
+ export { Alerts$1 as Alerts, AnatolyCoreModule, AnatolyDataModule, AnatolyHttpInterceptor, AnatolyUIModule, AppContextService, AppCoreSettings, BaseApiService, BaseComponent, BaseEditComponent, BaseGoService, BaseGridEditService, BaseGridReadService, BillingApiService, BuyAccessButtonComponent, ContentHeaderComponent, ContextInitState, FormValidationSummaryComponent, FormsHtmlEditorComponent, GlobalErrorHandler, Guid, HtmlEditorComponent, ItemValidationSummaryComponent, LoadingService, LocalizationModule, LocalizationService, LocalizationSettingsModule, LocalizePipe, LoggingService, NativeElementDirective, SignInButtonComponent, SignOutButtonComponent, SignUpButtonComponent, Subs, SubscribePlanButtonComponent, UpgradePlanButtonComponent, Utils, ValidationSummaryComponent, throwIfAlreadyLoaded };
2046
2768
  //# sourceMappingURL=osovitny-anatoly.js.map