@osovitny/anatoly 2.0.25 → 2.0.27

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 (60) hide show
  1. package/bundles/osovitny-anatoly.umd.js +1807 -1640
  2. package/bundles/osovitny-anatoly.umd.js.map +1 -1
  3. package/bundles/osovitny-anatoly.umd.min.js +2 -2
  4. package/bundles/osovitny-anatoly.umd.min.js.map +1 -1
  5. package/esm2015/lib/core/convert.js +1 -5
  6. package/esm2015/lib/core/core.module.js +7 -8
  7. package/esm2015/lib/core/go/base-go.service.js +4 -4
  8. package/esm2015/lib/core/interceptors/httpInterceptor.js +2 -2
  9. package/esm2015/lib/core/localization/localization.service.js +3 -3
  10. package/esm2015/lib/core/localization/localizationSettings.module.js +3 -3
  11. package/esm2015/lib/core/notifications/alerts.js +5 -3
  12. package/esm2015/lib/core/notifications/services/notification-service.js +1 -1
  13. package/esm2015/lib/core/services/appcontext.service.js +12 -12
  14. package/esm2015/lib/core/services/idle.service.js +65 -0
  15. package/esm2015/lib/core/services/web-storage.service.js +65 -0
  16. package/esm2015/lib/data/consts.js +2 -2
  17. package/esm2015/lib/data/data.module.js +6 -6
  18. package/esm2015/lib/data/services/notifications/notifications-api-service.js +45 -0
  19. package/esm2015/lib/ui/components/billing/buyaccess-button.component.js +9 -9
  20. package/esm2015/lib/ui/components/billing/upgrade-plan-button.component.js +7 -7
  21. package/esm2015/lib/ui/components/html-editor/base-html-editor.component.js +19 -19
  22. package/esm2015/lib/ui/components/loading/loading.component.js +49 -0
  23. package/esm2015/lib/ui/components/spinner/spinner.component.js +73 -0
  24. package/esm2015/lib/ui/pipes/filesize.pipe.js +41 -0
  25. package/esm2015/lib/ui/pipes/replace-text.pipe.js +36 -0
  26. package/esm2015/lib/ui/pipes/safeHtml.pipe.js +36 -0
  27. package/esm2015/lib/ui/ui.module.js +19 -13
  28. package/esm2015/public-api.js +57 -9
  29. package/fesm2015/osovitny-anatoly.js +1577 -1412
  30. package/fesm2015/osovitny-anatoly.js.map +1 -1
  31. package/lib/core/convert.d.ts +0 -4
  32. package/lib/core/go/base-go.service.d.ts +1 -1
  33. package/lib/core/services/appcontext.service.d.ts +2 -2
  34. package/lib/core/services/idle.service.d.ts +13 -0
  35. package/lib/core/services/web-storage.service.d.ts +17 -0
  36. package/lib/data/services/notifications/notifications-api-service.d.ts +9 -0
  37. package/lib/ui/components/billing/buyaccess-button.component.d.ts +3 -3
  38. package/lib/ui/components/billing/upgrade-plan-button.component.d.ts +1 -1
  39. package/lib/ui/components/html-editor/base-html-editor.component.d.ts +2 -2
  40. package/lib/ui/components/loading/loading.component.d.ts +10 -0
  41. package/lib/ui/components/spinner/spinner.component.d.ts +22 -0
  42. package/lib/ui/pipes/filesize.pipe.d.ts +5 -0
  43. package/lib/ui/pipes/replace-text.pipe.d.ts +4 -0
  44. package/lib/ui/pipes/safeHtml.pipe.d.ts +7 -0
  45. package/lib/ui/ui.module.d.ts +2 -3
  46. package/osovitny-anatoly.metadata.json +1 -1
  47. package/package.json +1 -1
  48. package/public-api.d.ts +53 -8
  49. package/esm2015/lib/core/alerts.js +0 -145
  50. package/esm2015/lib/core/consts/index.js +0 -21
  51. package/esm2015/lib/core/index.js +0 -37
  52. package/esm2015/lib/core/localization/index.js +0 -26
  53. package/esm2015/lib/data/index.js +0 -26
  54. package/esm2015/lib/ui/index.js +0 -43
  55. package/lib/core/alerts.d.ts +0 -12
  56. package/lib/core/consts/index.d.ts +0 -2
  57. package/lib/core/index.d.ts +0 -13
  58. package/lib/core/localization/index.d.ts +0 -4
  59. package/lib/data/index.d.ts +0 -5
  60. package/lib/ui/index.d.ts +0 -16
@@ -1,18 +1,19 @@
1
- import Swal from 'sweetalert2';
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';
4
- import { HttpClient, HttpResponse } from '@angular/common/http';
5
- import { map, tap } from 'rxjs/operators';
6
- import { BehaviorSubject } from 'rxjs';
7
- import { ToastrService } from 'ngx-toastr';
8
- import { v4 } from 'uuid';
1
+ import { Injectable, ɵɵdefineInjectable, ɵɵinject, Pipe, NgModule, APP_INITIALIZER, Injector, Optional, SkipSelf, Component, Input, ViewEncapsulation, Inject, Directive, ElementRef } from '@angular/core';
2
+ import { ActivatedRoute, Router, NavigationStart, NavigationEnd, NavigationCancel, NavigationError } from '@angular/router';
3
+ import { HttpResponse, HttpClient } from '@angular/common/http';
4
+ import { tap, map } from 'rxjs/operators';
5
+ import { BehaviorSubject, Subject, merge, fromEvent, timer } from 'rxjs';
9
6
  import { TranslateService, TranslateModule, TranslateLoader } from '@ngx-translate/core';
10
7
  import { isValid, format, formatDistanceToNow, formatDistance } from 'date-fns';
11
8
  import enUS from 'date-fns/locale/en-US';
12
- import { ActivatedRoute, Router } from '@angular/router';
9
+ import { LOCATION_INITIALIZED, CommonModule, DOCUMENT } from '@angular/common';
10
+ import { TranslateHttpLoader } from '@ngx-translate/http-loader';
11
+ import Swal from 'sweetalert2';
12
+ import { ToastrService } from 'ngx-toastr';
13
+ import { v4 } from 'uuid';
13
14
  import { NgControl, ReactiveFormsModule, FormsModule } from '@angular/forms';
15
+ import { DomSanitizer } from '@angular/platform-browser';
14
16
  import { FroalaEditorModule, FroalaViewModule } from 'angular-froala-wysiwyg';
15
- import { TranslateHttpLoader } from '@ngx-translate/http-loader';
16
17
 
17
18
  /*
18
19
  <file>
@@ -67,14 +68,31 @@ const Urls = {
67
68
  Anatoly Osovitny
68
69
 
69
70
  Created:
70
- 26 Jun 2020
71
+ 17 Jun 2018
71
72
 
72
73
  Version:
73
74
  1.0
74
75
 
75
76
  Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
76
77
  </file>
77
- */
78
+ */
79
+ class BaseGoService {
80
+ constructor(route, router) {
81
+ this.route = route;
82
+ this.router = router;
83
+ }
84
+ locationReload() {
85
+ // this.router.navigate([this.route.url]);
86
+ window.location.reload();
87
+ }
88
+ }
89
+ BaseGoService.decorators = [
90
+ { type: Injectable }
91
+ ];
92
+ BaseGoService.ctorParameters = () => [
93
+ { type: ActivatedRoute },
94
+ { type: Router }
95
+ ];
78
96
 
79
97
  /*
80
98
  <file>
@@ -110,7 +128,7 @@ function throwIfAlreadyLoaded(parentModule, moduleName) {
110
128
  Anatoly Osovitny
111
129
 
112
130
  Created:
113
- 4 Mar 2020
131
+ 26 Jun 2020
114
132
 
115
133
  Version:
116
134
  1.0
@@ -118,131 +136,46 @@ function throwIfAlreadyLoaded(parentModule, moduleName) {
118
136
  Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
119
137
  </file>
120
138
  */
121
- class Alerts {
122
- static Info(text) {
123
- Swal.fire({
124
- title: 'Information',
125
- text,
126
- icon: 'info',
127
- confirmButtonText: 'OK',
128
- });
129
- }
130
- static Warning(text) {
131
- Swal.fire({
132
- title: 'Warning',
133
- text,
134
- icon: 'warning',
135
- confirmButtonText: 'OK',
136
- });
137
- }
138
- static Error(text) {
139
- Swal.fire({
140
- title: 'Error',
141
- text,
142
- icon: 'error',
143
- confirmButtonText: 'OK',
144
- });
145
- }
146
- static NotImplemented() {
147
- this.Warning('Not Implemented Yet');
148
- }
149
- static ErrorOccurred() {
150
- this.Error('Sorry, an unexpected error occurred');
151
- }
152
- static AreYouSure(text, title, confirmButtonText, cancelButtonText, successAction, cancelAction) {
153
- if (typeof title === 'undefined' || title == null)
154
- title = 'Are you sure?';
155
- Swal.fire({
156
- title,
157
- text,
158
- icon: 'warning',
159
- confirmButtonText,
160
- cancelButtonText,
161
- showCancelButton: true,
162
- }).then((result) => {
163
- if (result.value) {
164
- if (successAction) {
165
- successAction();
166
- }
167
- }
168
- // result.dismiss can be 'cancel', 'overlay', 'close', and 'timer'
169
- else if (result.dismiss === Swal.DismissReason.cancel ||
170
- result.dismiss === Swal.DismissReason.close) {
171
- if (cancelAction) {
172
- cancelAction();
173
- }
174
- }
175
- });
139
+ class LoadingService extends BehaviorSubject {
140
+ constructor() {
141
+ super(false);
142
+ this.counter = 0;
143
+ //Public
144
+ this.isFreezed = false;
176
145
  }
177
- static Success(text, title, successAction) {
178
- if (typeof title === 'undefined' || title == null)
179
- title = 'Success';
180
- if (!text) {
181
- text = 'Operation was successful';
182
- }
183
- Swal.fire({
184
- title,
185
- text,
186
- icon: 'success',
187
- confirmButtonText: 'OK',
188
- }).then(() => {
189
- if (successAction) {
190
- successAction();
146
+ show() {
147
+ this.counter++;
148
+ let that = this;
149
+ setTimeout(() => {
150
+ if (that.counter > 0) {
151
+ that.next(true);
191
152
  }
192
- });
193
- }
194
- static Cancel(text) {
195
- if (!text) {
196
- text = 'Operation has been cancled';
197
- }
198
- Swal.fire({
199
- title: 'Cancelled',
200
- text,
201
- icon: 'info',
202
- });
153
+ }, 1000);
203
154
  }
204
- // Notifications
205
- static NotificationCancel(text, title) {
206
- if (typeof title === 'undefined' || title == null) {
207
- title = 'Canceled';
155
+ hide() {
156
+ if (this.counter <= 0) {
157
+ return;
208
158
  }
209
- if (!text) {
210
- text = 'Operation has been canceled';
159
+ this.counter--;
160
+ if (this.counter == 0) {
161
+ this.next(false);
211
162
  }
212
- const toast = Swal.mixin({
213
- toast: true,
214
- position: 'top-end',
215
- showConfirmButton: false,
216
- timer: 3000,
217
- timerProgressBar: true,
218
- });
219
- toast.fire({
220
- title,
221
- text,
222
- icon: 'info',
223
- });
224
163
  }
225
- static NotificationSuccess(text, title) {
226
- if (typeof title === 'undefined' || title == null) {
227
- title = 'Success';
228
- }
229
- if (!text) {
230
- text = 'Operation was successful';
231
- }
232
- const toast = Swal.mixin({
233
- toast: true,
234
- position: 'top-end',
235
- showConfirmButton: false,
236
- timer: 3000,
237
- timerProgressBar: true,
238
- });
239
- toast.fire({
240
- title,
241
- text,
242
- icon: 'success',
243
- });
164
+ freeze(timeout = 1000) {
165
+ this.isFreezed = true;
166
+ let that = this;
167
+ setTimeout(() => {
168
+ this.isFreezed = false;
169
+ }, timeout);
244
170
  }
245
- }
171
+ }
172
+ LoadingService.ɵprov = ɵɵdefineInjectable({ factory: function LoadingService_Factory() { return new LoadingService(); }, token: LoadingService, providedIn: "root" });
173
+ LoadingService.decorators = [
174
+ { type: Injectable, args: [{
175
+ providedIn: "root",
176
+ },] }
177
+ ];
178
+ LoadingService.ctorParameters = () => [];
246
179
 
247
180
  /*
248
181
  <file>
@@ -289,7 +222,7 @@ LoggingService.ctorParameters = () => [];
289
222
  Anatoly Osovitny
290
223
 
291
224
  Created:
292
- 13 Nov 2017
225
+ 25 March 2020
293
226
 
294
227
  Version:
295
228
  1.0
@@ -297,68 +230,85 @@ LoggingService.ctorParameters = () => [];
297
230
  Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
298
231
  </file>
299
232
  */
300
- class BaseApiService {
301
- constructor(http) {
302
- this.http = http;
303
- this.baseUrl = '';
304
- }
305
- serializeParams(data) {
306
- return data ? '?' + $.param(data) : '';
233
+ class AnatolyHttpInterceptor {
234
+ constructor(loadingService, loggingService) {
235
+ this.loadingService = loadingService;
236
+ this.loggingService = loggingService;
237
+ this.longRunningExceptionsList = [];
238
+ this.autoCDNSASTokenUrls = ['chunks', 'resources'];
239
+ this.externalSiteUrls = ['azurewebsites.net'];
307
240
  }
308
- // api
309
- get(action, data, responseType) {
310
- if (!responseType) {
311
- responseType = 'json';
241
+ intercept(req, next) {
242
+ const isCDNEnabled = AppCoreSettings.IsCDNEnabled;
243
+ const cdnSasToken = AppCoreSettings.CDNSASToken;
244
+ const isLoadingFreezed = this.loadingService.isFreezed;
245
+ let loadingRequired = !isLoadingFreezed;
246
+ const authorizationTokenRequired = true;
247
+ const url = req.url.toLowerCase();
248
+ const originalUrl = req.url;
249
+ let isExternalSite = false;
250
+ if (!isLoadingFreezed) {
251
+ for (const i of this.longRunningExceptionsList) {
252
+ if (url.indexOf(this.longRunningExceptionsList[i]) >= 0) {
253
+ loadingRequired = false;
254
+ break;
255
+ }
256
+ }
312
257
  }
313
- const url = `${this.baseUrl}/${action}${this.serializeParams(data)}`;
314
- return this.http
315
- .get(url, { responseType })
316
- .pipe(map((res) => res));
317
- }
318
- post(action, data, responseType) {
319
- if (!responseType) {
320
- responseType = 'text';
258
+ if (isCDNEnabled) {
259
+ for (const i of this.autoCDNSASTokenUrls) {
260
+ if (url.indexOf(this.autoCDNSASTokenUrls[i]) >= 0) {
261
+ req = req.clone({ url: originalUrl + cdnSasToken });
262
+ break;
263
+ }
264
+ }
321
265
  }
322
- const url = `${this.baseUrl}/${action}`;
323
- return this.http.post(url, data, { responseType });
324
- }
325
- postQS(action, data, responseType) {
326
- if (!responseType) {
327
- responseType = 'text';
266
+ for (const i of this.externalSiteUrls) {
267
+ if (url.indexOf(this.externalSiteUrls[i]) >= 0) {
268
+ isExternalSite = true;
269
+ break;
270
+ }
328
271
  }
329
- const url = `${this.baseUrl}/${action}${this.serializeParams(data)}`;
330
- return this.http.post(url, null, { responseType });
331
- }
332
- delete(action, data, responseType) {
333
- if (!responseType) {
334
- responseType = 'text';
272
+ // VadimOS: IE11-fix
273
+ if (url.indexOf('/api/') > -1) {
274
+ let newUrl = '';
275
+ const t = new Date().getTime().toString();
276
+ if (url.indexOf('?') > -1) {
277
+ newUrl = originalUrl + '&t=' + t;
278
+ }
279
+ else {
280
+ newUrl = originalUrl + '?t=' + t;
281
+ }
282
+ req = req.clone({ url: newUrl });
335
283
  }
336
- const url = `${this.baseUrl}/${action}${this.serializeParams(data)}`;
337
- return this.http.delete(url, { responseType });
338
- }
339
- // gets
340
- getById(id) {
341
- return this.get('getById', { id });
342
- }
343
- getAll(data) {
344
- return this.get('getall', data).pipe(map((res) => res));
284
+ req = req.clone({ headers: req.headers.set('Accept', 'application/json') });
285
+ this.onRequestStart(loadingRequired);
286
+ return next.handle(req).pipe(tap((event) => {
287
+ if (event instanceof HttpResponse) {
288
+ this.onRequestEnd(loadingRequired);
289
+ }
290
+ }, (err) => {
291
+ this.onRequestEnd(loadingRequired);
292
+ this.loggingService.logError(err);
293
+ }));
345
294
  }
346
- getJsonFile(fileName, jsonUrl, jsonVersion) {
347
- if (!jsonUrl) {
348
- jsonUrl = '/dist/jsons';
295
+ onRequestStart(loadingRequired) {
296
+ if (loadingRequired) {
297
+ this.loadingService.show();
349
298
  }
350
- if (!jsonVersion) {
351
- jsonVersion = '1.0';
299
+ }
300
+ onRequestEnd(loadingRequired) {
301
+ if (loadingRequired) {
302
+ this.loadingService.hide();
352
303
  }
353
- const url = jsonUrl + '/' + fileName + '?' + jsonVersion;
354
- return this.http.get(url).pipe(map((res) => res));
355
304
  }
356
305
  }
357
- BaseApiService.decorators = [
306
+ AnatolyHttpInterceptor.decorators = [
358
307
  { type: Injectable }
359
308
  ];
360
- BaseApiService.ctorParameters = () => [
361
- { type: HttpClient }
309
+ AnatolyHttpInterceptor.ctorParameters = () => [
310
+ { type: LoadingService },
311
+ { type: LoggingService }
362
312
  ];
363
313
 
364
314
  /*
@@ -371,7 +321,7 @@ BaseApiService.ctorParameters = () => [
371
321
  Anatoly Osovitny
372
322
 
373
323
  Created:
374
- 13 Nov 2017
324
+ 29 June 2020
375
325
 
376
326
  Version:
377
327
  1.0
@@ -379,54 +329,115 @@ BaseApiService.ctorParameters = () => [
379
329
  Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
380
330
  </file>
381
331
  */
382
- class AppContextService extends BaseApiService {
383
- constructor(http) {
384
- super(http);
385
- this.http = http;
386
- this.current = null;
387
- this.successes = [];
388
- this.subscription = null;
389
- this.baseUrl = "/api/appContext";
390
- }
391
- getCurrent(success) {
392
- if (typeof success == "undefined") {
393
- return;
332
+ class Convert {
333
+ static toLocalizedDateTime(value) {
334
+ if (value) {
335
+ return new Date(Date.UTC(value.getFullYear(), value.getMonth(), value.getDate(), value.getHours(), value.getMinutes(), value.getSeconds(), value.getMilliseconds()));
394
336
  }
395
- if (this.current != null) {
396
- success(this.current);
397
- return;
337
+ return null;
338
+ }
339
+ }
340
+
341
+ /*
342
+ <file>
343
+ Project:
344
+ @osovitny/anatoly
345
+
346
+ Authors:
347
+ Vadim Osovitny
348
+ Anatoly Osovitny
349
+
350
+ Created:
351
+ 05 May 2020
352
+
353
+ Version:
354
+ 1.0
355
+
356
+ Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
357
+ </file>
358
+ */
359
+ class LocalizationService {
360
+ constructor(translate) {
361
+ this.translate = translate;
362
+ this.setSupportedLanguages(['en']);
363
+ }
364
+ format(str, args) {
365
+ // tslint:disable-next-line:variable-name
366
+ return str.replace(/{(\d+)}/g, (match, number) => typeof args[number] !== 'undefined' ? args[number] : match);
367
+ }
368
+ ;
369
+ configureTranslationSettings(translate) {
370
+ const languageToSet = 'en';
371
+ translate.setDefaultLang(languageToSet);
372
+ return languageToSet;
373
+ }
374
+ getBrowserLanguage() {
375
+ return this.translate.getBrowserLang();
376
+ }
377
+ getDatefnsLocale() {
378
+ let dfnLocale;
379
+ switch (this.getBrowserLanguage()) {
380
+ case 'en':
381
+ dfnLocale = { locale: enUS };
382
+ break;
383
+ default:
384
+ dfnLocale = { locale: enUS };
398
385
  }
399
- this.successes.push(success);
400
- if (this.subscription != null) {
401
- return;
386
+ return dfnLocale;
387
+ }
388
+ setDefaultLanguage(lang) {
389
+ this.translate.setDefaultLang(lang);
390
+ }
391
+ setSupportedLanguages(languages) {
392
+ this.translate.addLangs(languages);
393
+ }
394
+ updateLanguage(language) {
395
+ this.translate.use(language);
396
+ }
397
+ getLocalizedValue(key, params) {
398
+ const value = this.translate.instant(key);
399
+ if (!params || params.length === 0) {
400
+ return value;
402
401
  }
403
- this.subscription = this.get("GetCurrentContext", null).subscribe((data) => {
404
- this.dataReceived(data);
405
- }, (e) => { });
402
+ return this.format(value, params);
406
403
  }
407
- dataReceived(data) {
408
- this.current = data;
409
- for (var i = 0; i < this.successes.length; i++) {
410
- var success = this.successes[i];
411
- success(data);
404
+ getLocalizedDate(key) {
405
+ if (isValid(new Date(key))) {
406
+ return format(new Date(key), AppCoreSettings.DATE_FORMATS.angular, this.dateFnsLocale);
412
407
  }
413
- this.successes = [];
414
- this.subscription.unsubscribe();
415
- this.subscription = null;
416
- this.current = null;
408
+ return 'Invalid Date';
417
409
  }
418
- isUserSignedIn() {
419
- return ContextInitState.isUserSignedIn;
410
+ getLocalizedDateTime(key) {
411
+ // To Do Manoj: Test in IE and make TimeZone specific changes accordingly
412
+ const dateValue = new Date(key);
413
+ if (isValid(dateValue)) {
414
+ const localDate = Convert.toLocalizedDateTime(dateValue);
415
+ return format(localDate, AppCoreSettings.DATE_FORMATS.angularWithTime, this.dateFnsLocale);
416
+ }
417
+ return 'Invalid Date';
420
418
  }
421
- isUserAdmin() {
422
- return ContextInitState.isUserAdmin;
419
+ getLocalizedDistanceToNowInWords(date) {
420
+ // https://date-fns.org/v1.30.1/docs/distanceInWords
421
+ if (isValid(new Date(date))) {
422
+ return formatDistanceToNow(new Date(date), this.dateFnsLocale);
423
+ }
424
+ return 'Invalid Date';
425
+ }
426
+ getLocalizedDistanceInWords(endedDate, startedDate) {
427
+ if (isValid(new Date(endedDate)) && isValid(new Date(startedDate))) {
428
+ return formatDistance(new Date(endedDate), new Date(startedDate), this.dateFnsLocale);
429
+ }
430
+ return 'Invalid Date';
423
431
  }
424
432
  }
425
- AppContextService.decorators = [
426
- { type: Injectable }
433
+ LocalizationService.ɵprov = ɵɵdefineInjectable({ factory: function LocalizationService_Factory() { return new LocalizationService(ɵɵinject(TranslateService)); }, token: LocalizationService, providedIn: "root" });
434
+ LocalizationService.decorators = [
435
+ { type: Injectable, args: [{
436
+ providedIn: 'root'
437
+ },] }
427
438
  ];
428
- AppContextService.ctorParameters = () => [
429
- { type: HttpClient }
439
+ LocalizationService.ctorParameters = () => [
440
+ { type: TranslateService }
430
441
  ];
431
442
 
432
443
  /*
@@ -439,7 +450,7 @@ AppContextService.ctorParameters = () => [
439
450
  Anatoly Osovitny
440
451
 
441
452
  Created:
442
- 26 Jun 2020
453
+ 10 May 2020
443
454
 
444
455
  Version:
445
456
  1.0
@@ -447,46 +458,48 @@ AppContextService.ctorParameters = () => [
447
458
  Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
448
459
  </file>
449
460
  */
450
- class LoadingService extends BehaviorSubject {
451
- constructor() {
452
- super(false);
453
- this.counter = 0;
454
- //Public
455
- this.isFreezed = false;
456
- }
457
- show() {
458
- this.counter++;
459
- let that = this;
460
- setTimeout(() => {
461
- if (that.counter > 0) {
462
- that.next(true);
463
- }
464
- }, 1000);
461
+ class LocalizePipe {
462
+ constructor(localizeService) {
463
+ this.localizeService = localizeService;
465
464
  }
466
- hide() {
467
- if (this.counter <= 0) {
465
+ transform(inputData, type, param2) {
466
+ if (!inputData) {
468
467
  return;
469
468
  }
470
- this.counter--;
471
- if (this.counter == 0) {
472
- this.next(false);
469
+ if (!type) {
470
+ type = 't';
473
471
  }
474
- }
475
- freeze(timeout = 1000) {
476
- this.isFreezed = true;
477
- let that = this;
478
- setTimeout(() => {
479
- this.isFreezed = false;
480
- }, timeout);
472
+ // Translate
473
+ if (type === 't') {
474
+ return this.localizeService.getLocalizedValue(inputData);
475
+ }
476
+ // Date
477
+ if (type === 'd') {
478
+ return this.localizeService.getLocalizedDate(inputData);
479
+ }
480
+ // DateTime
481
+ if (type === 'dt') {
482
+ return this.localizeService.getLocalizedDateTime(inputData);
483
+ }
484
+ // DistanceToNowInWords
485
+ if (type === 'dis2now') {
486
+ return this.localizeService.getLocalizedDistanceToNowInWords(inputData);
487
+ }
488
+ // DistanceInWords
489
+ if (type === 'dis') {
490
+ return this.localizeService.getLocalizedDistanceInWords(inputData, param2);
491
+ }
492
+ return inputData;
481
493
  }
482
494
  }
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",
495
+ LocalizePipe.decorators = [
496
+ { type: Pipe, args: [{
497
+ name: 'localize'
487
498
  },] }
488
499
  ];
489
- LoadingService.ctorParameters = () => [];
500
+ LocalizePipe.ctorParameters = () => [
501
+ { type: LocalizationService }
502
+ ];
490
503
 
491
504
  /*
492
505
  <file>
@@ -498,7 +511,7 @@ LoadingService.ctorParameters = () => [];
498
511
  Anatoly Osovitny
499
512
 
500
513
  Created:
501
- 26 Jun 2020
514
+ 05 May 2020
502
515
 
503
516
  Version:
504
517
  1.0
@@ -506,11 +519,48 @@ LoadingService.ctorParameters = () => [];
506
519
  Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
507
520
  </file>
508
521
  */
509
- class Guid {
510
- static newGuid() {
511
- return v4();
522
+ function customTranslateLoaderFactory(http) {
523
+ return new TranslateHttpLoader(http, AppCoreSettings.resourcesUrl + "/", '.json');
524
+ }
525
+ function localizationInitializerFactory(translate, localizationService, injector) {
526
+ return () => new Promise((resolve) => {
527
+ let locationInitialized = injector.get(LOCATION_INITIALIZED, Promise.resolve(null));
528
+ locationInitialized.then(() => {
529
+ let languageToSet = localizationService.configureTranslationSettings(translate);
530
+ translate.use(languageToSet).subscribe(() => {
531
+ }, () => {
532
+ resolve(null);
533
+ }, () => {
534
+ resolve(null);
535
+ });
536
+ });
537
+ });
538
+ }
539
+ const TranslateModuleAtRoot = TranslateModule.forRoot({
540
+ loader: {
541
+ provide: TranslateLoader,
542
+ useFactory: customTranslateLoaderFactory,
543
+ deps: [HttpClient]
512
544
  }
513
- }
545
+ });
546
+ class LocalizationSettingsModule {
547
+ }
548
+ LocalizationSettingsModule.decorators = [
549
+ { type: NgModule, args: [{
550
+ imports: [
551
+ TranslateModuleAtRoot
552
+ ],
553
+ providers: [
554
+ {
555
+ provide: APP_INITIALIZER,
556
+ useFactory: localizationInitializerFactory,
557
+ deps: [TranslateService, LocalizationService, Injector],
558
+ multi: true
559
+ }
560
+ ],
561
+ exports: []
562
+ },] }
563
+ ];
514
564
 
515
565
  /*
516
566
  <file>
@@ -522,7 +572,7 @@ class Guid {
522
572
  Anatoly Osovitny
523
573
 
524
574
  Created:
525
- 2 Jun 2020
575
+ 12 May 2020
526
576
 
527
577
  Version:
528
578
  1.0
@@ -530,23 +580,269 @@ class Guid {
530
580
  Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
531
581
  </file>
532
582
  */
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
- }
583
+ class LocalizationModule {
584
+ }
585
+ LocalizationModule.decorators = [
586
+ { type: NgModule, args: [{
587
+ imports: [
588
+ TranslateModule
589
+ ],
590
+ exports: [
591
+ TranslateModule,
592
+ LocalizePipe
593
+ ],
594
+ declarations: [
595
+ LocalizePipe
596
+ ],
597
+ providers: []
598
+ },] }
599
+ ];
600
+
601
+ /*
602
+ <file>
603
+ Project:
604
+ @osovitny/anatoly
605
+
606
+ Authors:
607
+ Vadim Osovitny
608
+ Anatoly Osovitny
609
+
610
+ Created:
611
+ 26 Jun 2020
612
+
613
+ Version:
614
+ 1.0
615
+
616
+ Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
617
+ </file>
618
+ */
619
+ class GlobalErrorHandler {
620
+ constructor(injector) {
621
+ this.injector = injector;
622
+ }
623
+ handleError(error) {
624
+ const loggingService = this.injector.get(LoggingService);
625
+ loggingService.logError(error);
626
+ // IMPORTANT: Rethrow the error otherwise it gets swallowed
627
+ throw error;
628
+ }
629
+ }
630
+ GlobalErrorHandler.decorators = [
631
+ { type: Injectable }
632
+ ];
633
+ GlobalErrorHandler.ctorParameters = () => [
634
+ { type: Injector }
635
+ ];
636
+
637
+ /*
638
+ <file>
639
+ Project:
640
+ @osovitny/anatoly
641
+
642
+ Authors:
643
+ Vadim Osovitny
644
+ Anatoly Osovitny
645
+
646
+ Created:
647
+ 13 Nov 2017
648
+
649
+ Version:
650
+ 1.0
651
+
652
+ Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
653
+ </file>
654
+ */
655
+ class BaseApiService {
656
+ constructor(http) {
657
+ this.http = http;
658
+ this.baseUrl = '';
659
+ }
660
+ serializeParams(data) {
661
+ return data ? '?' + $.param(data) : '';
662
+ }
663
+ // api
664
+ get(action, data, responseType) {
665
+ if (!responseType) {
666
+ responseType = 'json';
667
+ }
668
+ const url = `${this.baseUrl}/${action}${this.serializeParams(data)}`;
669
+ return this.http
670
+ .get(url, { responseType })
671
+ .pipe(map((res) => res));
672
+ }
673
+ post(action, data, responseType) {
674
+ if (!responseType) {
675
+ responseType = 'text';
676
+ }
677
+ const url = `${this.baseUrl}/${action}`;
678
+ return this.http.post(url, data, { responseType });
679
+ }
680
+ postQS(action, data, responseType) {
681
+ if (!responseType) {
682
+ responseType = 'text';
683
+ }
684
+ const url = `${this.baseUrl}/${action}${this.serializeParams(data)}`;
685
+ return this.http.post(url, null, { responseType });
686
+ }
687
+ delete(action, data, responseType) {
688
+ if (!responseType) {
689
+ responseType = 'text';
690
+ }
691
+ const url = `${this.baseUrl}/${action}${this.serializeParams(data)}`;
692
+ return this.http.delete(url, { responseType });
693
+ }
694
+ // gets
695
+ getById(id) {
696
+ return this.get('getById', { id });
697
+ }
698
+ getAll(data) {
699
+ return this.get('getall', data).pipe(map((res) => res));
700
+ }
701
+ getJsonFile(fileName, jsonUrl, jsonVersion) {
702
+ if (!jsonUrl) {
703
+ jsonUrl = '/dist/jsons';
704
+ }
705
+ if (!jsonVersion) {
706
+ jsonVersion = '1.0';
707
+ }
708
+ const url = jsonUrl + '/' + fileName + '?' + jsonVersion;
709
+ return this.http.get(url).pipe(map((res) => res));
710
+ }
711
+ }
712
+ BaseApiService.decorators = [
713
+ { type: Injectable }
714
+ ];
715
+ BaseApiService.ctorParameters = () => [
716
+ { type: HttpClient }
717
+ ];
718
+
719
+ /*
720
+ <file>
721
+ Project:
722
+ @osovitny/anatoly
723
+
724
+ Authors:
725
+ Vadim Osovitny
726
+ Anatoly Osovitny
727
+
728
+ Created:
729
+ 13 Nov 2017
730
+
731
+ Version:
732
+ 1.0
733
+
734
+ Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
735
+ </file>
736
+ */
737
+ class AppContextService extends BaseApiService {
738
+ constructor(http) {
739
+ super(http);
740
+ this.http = http;
741
+ this.current = null;
742
+ this.successes = [];
743
+ this.subscription = null;
744
+ this.baseUrl = '/api/appContext';
745
+ }
746
+ getCurrent(success) {
747
+ if (typeof success == 'undefined') {
748
+ return;
749
+ }
750
+ if (this.current != null) {
751
+ success(this.current);
752
+ return;
753
+ }
754
+ this.successes.push(success);
755
+ if (this.subscription != null) {
756
+ return;
757
+ }
758
+ this.subscription = this.get('GetCurrentContext', null).subscribe((data) => {
759
+ this.dataReceived(data);
760
+ }, (e) => { });
761
+ }
762
+ dataReceived(data) {
763
+ this.current = data;
764
+ for (let i = 0; i < this.successes.length; i++) {
765
+ let success = this.successes[i];
766
+ success(data);
767
+ }
768
+ this.successes = [];
769
+ this.subscription.unsubscribe();
770
+ this.subscription = null;
771
+ this.current = null;
772
+ }
773
+ isUserSignedIn() {
774
+ return ContextInitState.isUserSignedIn;
775
+ }
776
+ isUserAdmin() {
777
+ return ContextInitState.isUserAdmin;
778
+ }
779
+ }
780
+ AppContextService.decorators = [
781
+ { type: Injectable }
782
+ ];
783
+ AppContextService.ctorParameters = () => [
784
+ { type: HttpClient }
785
+ ];
786
+
787
+ /*
788
+ <file>
789
+ Project:
790
+ @osovitny/anatoly
791
+
792
+ Authors:
793
+ Vadim Osovitny
794
+ Anatoly Osovitny
795
+
796
+ Created:
797
+ 26 Jun 2020
798
+
799
+ Version:
800
+ 1.0
801
+
802
+ Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
803
+ </file>
804
+ */
805
+ class Guid {
806
+ static newGuid() {
807
+ return v4();
808
+ }
809
+ }
810
+
811
+ /*
812
+ <file>
813
+ Project:
814
+ @osovitny/anatoly
815
+
816
+ Authors:
817
+ Vadim Osovitny
818
+ Anatoly Osovitny
819
+
820
+ Created:
821
+ 2 Jun 2020
822
+
823
+ Version:
824
+ 1.0
825
+
826
+ Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
827
+ </file>
828
+ */
829
+ // SignalR
830
+ // import * as signalR from '@microsoft/signalr';
831
+ // import { NotificationsApiService } from '../../../data/services/notifications/notifications-api-service';
832
+ class NotificationService {
833
+ constructor(toastrService) {
834
+ this.toastrService = toastrService;
835
+ // SignalR
836
+ // private hubConnection: signalR.HubConnection;
837
+ // private socketUrl: string;
838
+ // Notifications
839
+ this._sessionNotifications = new BehaviorSubject([]);
840
+ this._serverNotifications = new BehaviorSubject([]);
841
+ // Public
842
+ this.sessionNotifications$ = this._sessionNotifications.asObservable();
843
+ this.serverNotifications$ = this._serverNotifications.asObservable();
844
+ // this.onInit();
845
+ }
550
846
  /*
551
847
  onInit() {
552
848
  if (AppCoreSettings.AzureAD) {
@@ -718,177 +1014,43 @@ class NotificationService {
718
1014
  }
719
1015
  // ServerNotifications
720
1016
  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';
1017
+ return this._serverNotifications.getValue();
869
1018
  }
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';
1019
+ set serverNotifications(val) {
1020
+ this._serverNotifications.next(val);
876
1021
  }
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';
1022
+ }
1023
+ NotificationService.ɵprov = ɵɵdefineInjectable({ factory: function NotificationService_Factory() { return new NotificationService(ɵɵinject(ToastrService)); }, token: NotificationService, providedIn: "root" });
1024
+ NotificationService.decorators = [
1025
+ { type: Injectable, args: [{ providedIn: 'root' },] }
1026
+ ];
1027
+ NotificationService.ctorParameters = () => [
1028
+ { type: ToastrService }
1029
+ ];
1030
+
1031
+ let InjectorInstance;
1032
+ class AnatolyCoreModule {
1033
+ constructor(injector, parentModule) {
1034
+ this.injector = injector;
1035
+ throwIfAlreadyLoaded(parentModule, 'AnatolyCoreModule');
1036
+ InjectorInstance = this.injector;
882
1037
  }
883
1038
  }
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'
1039
+ AnatolyCoreModule.decorators = [
1040
+ { type: NgModule, args: [{
1041
+ imports: [CommonModule],
1042
+ exports: [],
1043
+ providers: [
1044
+ LoggingService,
1045
+ NotificationService,
1046
+ AppContextService,
1047
+ LoadingService
1048
+ ],
888
1049
  },] }
889
1050
  ];
890
- LocalizationService.ctorParameters = () => [
891
- { type: TranslateService }
1051
+ AnatolyCoreModule.ctorParameters = () => [
1052
+ { type: Injector },
1053
+ { type: AnatolyCoreModule, decorators: [{ type: Optional }, { type: SkipSelf }] }
892
1054
  ];
893
1055
 
894
1056
  /*
@@ -982,7 +1144,7 @@ class Utils {
982
1144
  Anatoly Osovitny
983
1145
 
984
1146
  Created:
985
- 26 Jun 2020
1147
+ 3 March 2020
986
1148
 
987
1149
  Version:
988
1150
  1.0
@@ -990,192 +1152,94 @@ class Utils {
990
1152
  Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
991
1153
  </file>
992
1154
  */
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 = [];
1155
+ class Alerts {
1156
+ static success(text, params, title, successAction) {
1157
+ text = Utils.getLocalizedValue(text, params, 'OperationSuccessFull');
1158
+ title = Utils.getLocalizedValue(title, null, 'Success');
1159
+ Swal.fire({
1160
+ text,
1161
+ title,
1162
+ icon: 'success',
1163
+ confirmButtonText: Utils.getLocalizedValue('Ok')
1164
+ })
1165
+ .then(() => {
1166
+ if (successAction) {
1167
+ successAction();
1168
+ }
1169
+ });
1006
1170
  }
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;
1171
+ static info(text, params, title) {
1172
+ text = Utils.getLocalizedValue(text, params);
1173
+ title = Utils.getLocalizedValue(title, null, 'Info');
1174
+ Swal.fire({
1175
+ text,
1176
+ title,
1177
+ icon: 'info',
1178
+ confirmButtonText: Utils.getLocalizedValue('Ok')
1179
+ });
1031
1180
  }
1032
- locationReload() {
1033
- //this.router.navigate([this.route.url]);
1034
- window.location.reload();
1181
+ static warning(text, params, title) {
1182
+ text = Utils.getLocalizedValue(text, params);
1183
+ title = Utils.getLocalizedValue(title, null, 'Warning');
1184
+ Swal.fire({
1185
+ text,
1186
+ title,
1187
+ icon: 'warning',
1188
+ confirmButtonText: Utils.getLocalizedValue('Ok')
1189
+ });
1035
1190
  }
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;
1191
+ static error(text, params, title) {
1192
+ text = Utils.getLocalizedValue(text, params, 'ErrorOccured');
1193
+ title = Utils.getLocalizedValue(title, null, 'Error');
1194
+ Swal.fire({
1195
+ text,
1196
+ title,
1197
+ icon: 'error',
1198
+ confirmButtonText: Utils.getLocalizedValue('Ok')
1199
+ });
1066
1200
  }
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;
1201
+ static cancel(text, params, title) {
1202
+ text = Utils.getLocalizedValue(text, params, 'OperationCancelled');
1203
+ title = Utils.getLocalizedValue(title, null, 'Cancelled');
1204
+ Swal.fire({
1205
+ text,
1206
+ title,
1207
+ icon: 'info'
1208
+ });
1072
1209
  }
1073
- }
1074
- GlobalErrorHandler.decorators = [
1075
- { type: Injectable }
1076
- ];
1077
- GlobalErrorHandler.ctorParameters = () => [
1078
- { type: Injector }
1079
- ];
1080
-
1081
- /*
1082
- <file>
1083
- Project:
1084
- @osovitny/anatoly
1085
-
1086
- Authors:
1087
- Vadim Osovitny
1088
- Anatoly Osovitny
1089
-
1090
- Created:
1091
- 25 March 2020
1092
-
1093
- Version:
1094
- 1.0
1095
-
1096
- Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
1097
- </file>
1098
- */
1099
- class AnatolyHttpInterceptor {
1100
- constructor(loadingService, loggingService) {
1101
- this.loadingService = loadingService;
1102
- this.loggingService = loggingService;
1103
- this.longRunningExceptionsList = [];
1104
- this.autoCDNSASTokenUrls = ['chunks', 'resources'];
1105
- this.externalSiteUrls = ['azurewebsites.net'];
1210
+ static notImplemented() {
1211
+ this.warning('Not Implemented Yet');
1106
1212
  }
1107
- intercept(req, next) {
1108
- const isCDNEnabled = AppCoreSettings.IsCDNEnabled;
1109
- const cdnSasToken = AppCoreSettings.CDNSASToken;
1110
- const isLoadingFreezed = this.loadingService.isFreezed;
1111
- let loadingRequired = !isLoadingFreezed;
1112
- const authorizationTokenRequired = true;
1113
- const url = req.url.toLowerCase();
1114
- const originalUrl = req.url;
1115
- let isExternalSite = false;
1116
- if (!isLoadingFreezed) {
1117
- for (const i of this.longRunningExceptionsList) {
1118
- if (url.indexOf(this.longRunningExceptionsList[i]) >= 0) {
1119
- loadingRequired = false;
1120
- break;
1121
- }
1122
- }
1123
- }
1124
- if (isCDNEnabled) {
1125
- for (const i of this.autoCDNSASTokenUrls) {
1126
- if (url.indexOf(this.autoCDNSASTokenUrls[i]) >= 0) {
1127
- req = req.clone({ url: originalUrl + cdnSasToken });
1128
- break;
1129
- }
1130
- }
1131
- }
1132
- for (const i of this.externalSiteUrls) {
1133
- if (url.indexOf(this.externalSiteUrls[i]) >= 0) {
1134
- isExternalSite = true;
1135
- break;
1136
- }
1137
- }
1138
- // VadimOS: IE11-fix
1139
- if (url.indexOf('/api/') > -1) {
1140
- let newUrl = '';
1141
- const t = new Date().getTime().toString();
1142
- if (url.indexOf('?') > -1) {
1143
- newUrl = originalUrl + '&t=' + t;
1144
- }
1145
- else {
1146
- newUrl = originalUrl + '?t=' + t;
1213
+ ;
1214
+ static areYouSure(text, title, confirmButtonText, cancelButtonText, successAction, cancelAction) {
1215
+ text = Utils.getLocalizedValue(text);
1216
+ title = Utils.getLocalizedValue(title, null, 'AreYouSure');
1217
+ confirmButtonText = Utils.getLocalizedValue(confirmButtonText, null, 'AreYouSure-ConfirmButtonText');
1218
+ cancelButtonText = Utils.getLocalizedValue(cancelButtonText, null, 'AreYouSure-CancelButtonText');
1219
+ Swal.fire({
1220
+ text,
1221
+ title,
1222
+ icon: 'warning',
1223
+ confirmButtonText,
1224
+ cancelButtonText,
1225
+ showCancelButton: true
1226
+ })
1227
+ .then((result) => {
1228
+ if (result.value) {
1229
+ if (successAction) {
1230
+ successAction();
1231
+ }
1147
1232
  }
1148
- req = req.clone({ url: newUrl });
1149
- }
1150
- req = req.clone({ headers: req.headers.set('Accept', 'application/json') });
1151
- this.onRequestStart(loadingRequired);
1152
- return next.handle(req).pipe(tap((event) => {
1153
- if (event instanceof HttpResponse) {
1154
- this.onRequestEnd(loadingRequired);
1233
+ // result.dismiss can be 'cancel', 'overlay', 'close', and 'timer'
1234
+ else if (result.dismiss == Swal.DismissReason.cancel || result.dismiss == Swal.DismissReason.close) {
1235
+ if (cancelAction) {
1236
+ cancelAction();
1237
+ }
1155
1238
  }
1156
- }, (err) => {
1157
- this.onRequestEnd(loadingRequired);
1158
- this.loggingService.logError(err);
1159
- }));
1160
- }
1161
- onRequestStart(loadingRequired) {
1162
- if (loadingRequired) {
1163
- this.loadingService.show();
1164
- }
1165
- }
1166
- onRequestEnd(loadingRequired) {
1167
- if (loadingRequired) {
1168
- this.loadingService.hide();
1169
- }
1239
+ });
1170
1240
  }
1171
- }
1172
- AnatolyHttpInterceptor.decorators = [
1173
- { type: Injectable }
1174
- ];
1175
- AnatolyHttpInterceptor.ctorParameters = () => [
1176
- { type: LoadingService },
1177
- { type: LoggingService }
1178
- ];
1241
+ ;
1242
+ }
1179
1243
 
1180
1244
  /*
1181
1245
  <file>
@@ -1187,7 +1251,7 @@ AnatolyHttpInterceptor.ctorParameters = () => [
1187
1251
  Anatoly Osovitny
1188
1252
 
1189
1253
  Created:
1190
- 26 Jun 2020
1254
+ 2 Jun 2020
1191
1255
 
1192
1256
  Version:
1193
1257
  1.0
@@ -1206,7 +1270,7 @@ AnatolyHttpInterceptor.ctorParameters = () => [
1206
1270
  Anatoly Osovitny
1207
1271
 
1208
1272
  Created:
1209
- 29 Apr 2018
1273
+ 26 Jun 2020
1210
1274
 
1211
1275
  Version:
1212
1276
  1.0
@@ -1214,46 +1278,46 @@ AnatolyHttpInterceptor.ctorParameters = () => [
1214
1278
  Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
1215
1279
  </file>
1216
1280
  */
1217
- class BaseGridReadService extends BehaviorSubject {
1218
- constructor(http) {
1219
- super([]);
1220
- this.http = http;
1221
- this.baseReadUrl = "";
1222
- this.data = [];
1281
+ class IdleService {
1282
+ constructor() {
1283
+ this.expired$ = new Subject();
1223
1284
  }
1224
- serializeParams(data) {
1225
- return data ? "?" + $.param(data) : "";
1285
+ startWatching(timeOutSeconds) {
1286
+ this.idle$ = merge(fromEvent(document, "mousemove"), fromEvent(document, "click"), fromEvent(document, "mousedown"), fromEvent(document, "keypress"), fromEvent(document, "DOMMouseScroll"), fromEvent(document, "mousewheel"), fromEvent(document, "touchmove"), fromEvent(document, "MSPointerMove"), fromEvent(window, "mousemove"), fromEvent(window, "resize"));
1287
+ this.timeOutMilliSeconds = timeOutSeconds * 1000;
1288
+ this.idleSubscription = this.idle$.subscribe((res) => {
1289
+ this.resetTimer();
1290
+ });
1291
+ this.startTimer();
1292
+ return this.expired$;
1226
1293
  }
1227
- read(params, success, error) {
1228
- if (this.data.length) {
1229
- return super.next(this.data);
1230
- }
1231
- var url = this.baseReadUrl;
1232
- if (typeof params === "undefined") {
1233
- params = this.savedReadParams;
1234
- }
1235
- if (params) {
1236
- url = this.baseReadUrl + `${this.serializeParams(params)}`;
1237
- this.savedReadParams = params;
1238
- }
1239
- this.http
1240
- .get(url)
1241
- .pipe(map((res) => res))
1242
- .subscribe((data) => {
1243
- super.next(data);
1244
- if (success)
1245
- success();
1246
- }, (e) => {
1247
- if (error)
1248
- error(e);
1294
+ startTimer() {
1295
+ this.timer$ = timer(this.timeOutMilliSeconds, this.timeOutMilliSeconds).subscribe((res) => {
1296
+ this.expired$.next(true);
1297
+ });
1298
+ }
1299
+ resetTimer() {
1300
+ this.timer$.unsubscribe();
1301
+ this.startTimer();
1302
+ }
1303
+ stopTimer() {
1304
+ this.timer$.unsubscribe();
1305
+ this.idleSubscription.unsubscribe();
1306
+ }
1307
+ restartIdleTimer() {
1308
+ this.timer$.unsubscribe();
1309
+ this.idleSubscription.unsubscribe();
1310
+ this.idleSubscription = this.idle$.subscribe((res) => {
1311
+ this.resetTimer();
1249
1312
  });
1313
+ this.startTimer();
1250
1314
  }
1251
1315
  }
1252
- BaseGridReadService.decorators = [
1253
- { type: Injectable }
1254
- ];
1255
- BaseGridReadService.ctorParameters = () => [
1256
- { type: HttpClient }
1316
+ IdleService.ɵprov = ɵɵdefineInjectable({ factory: function IdleService_Factory() { return new IdleService(); }, token: IdleService, providedIn: "root" });
1317
+ IdleService.decorators = [
1318
+ { type: Injectable, args: [{
1319
+ providedIn: "root",
1320
+ },] }
1257
1321
  ];
1258
1322
 
1259
1323
  /*
@@ -1266,7 +1330,7 @@ BaseGridReadService.ctorParameters = () => [
1266
1330
  Anatoly Osovitny
1267
1331
 
1268
1332
  Created:
1269
- 29 Apr 2018
1333
+ 26 Jun 2020
1270
1334
 
1271
1335
  Version:
1272
1336
  1.0
@@ -1274,57 +1338,48 @@ BaseGridReadService.ctorParameters = () => [
1274
1338
  Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
1275
1339
  </file>
1276
1340
  */
1277
- class BaseGridEditService extends BaseGridReadService {
1278
- constructor(http) {
1279
- super(http);
1280
- this.http = http;
1281
- this.baseUrl = "";
1341
+ class WebStorageService {
1342
+ constructor(storage) {
1343
+ this.currentClientKey = AppCoreSettings.SERVICES_CONF.selectedClientID;
1344
+ this.storage =
1345
+ storage === 'local' || storage === 'localStorage'
1346
+ ? localStorage
1347
+ : sessionStorage;
1282
1348
  }
1283
- reset() {
1284
- this.data = [];
1349
+ setItem(key, value) {
1350
+ this.storage.setItem(this.currentClientKey + key, value);
1285
1351
  }
1286
- resetItem(dataItem) {
1287
- if (!dataItem) {
1288
- return;
1289
- }
1290
- //find orignal data item
1291
- const originalDataItem = this.data.find((item) => item.Id === dataItem.Id);
1292
- //revert changes
1293
- Object.assign(originalDataItem, dataItem);
1294
- super.next(this.data);
1352
+ setObject(key, value) {
1353
+ this.storage.setItem(this.currentClientKey + key, JSON.stringify(value));
1295
1354
  }
1296
- save(data, isNew, sucess) {
1297
- const action = isNew ? "add" : "update";
1298
- this.reset();
1299
- this.post(action, data).subscribe(() => { }, () => {
1300
- this.read();
1301
- }, () => {
1302
- this.read();
1303
- if (sucess)
1304
- sucess();
1305
- });
1355
+ getItem(key) {
1356
+ return this.storage.getItem(this.currentClientKey + key);
1306
1357
  }
1307
- remove(data, sucess) {
1308
- this.reset();
1309
- this.post("remove", data).subscribe(() => { }, () => {
1310
- this.read();
1311
- }, () => {
1312
- this.read();
1313
- if (sucess)
1314
- sucess();
1315
- });
1358
+ getObject(key) {
1359
+ return JSON.parse(this.storage.getItem(this.currentClientKey + key) || '{}');
1316
1360
  }
1317
- post(action, data) {
1318
- var url = this.baseUrl + `${action}${this.serializeParams(data)}`;
1319
- return this.http.post(url, data).pipe(map((res) => res));
1361
+ remove(key) {
1362
+ this.storage.removeItem(this.currentClientKey + key);
1320
1363
  }
1321
1364
  }
1322
- BaseGridEditService.decorators = [
1365
+ class LocalStorageService extends WebStorageService {
1366
+ constructor() {
1367
+ super('localStorage');
1368
+ }
1369
+ }
1370
+ LocalStorageService.decorators = [
1323
1371
  { type: Injectable }
1324
1372
  ];
1325
- BaseGridEditService.ctorParameters = () => [
1326
- { type: HttpClient }
1327
- ];
1373
+ LocalStorageService.ctorParameters = () => [];
1374
+ class SessionStorageService extends WebStorageService {
1375
+ constructor() {
1376
+ super('sessionStorage');
1377
+ }
1378
+ }
1379
+ SessionStorageService.decorators = [
1380
+ { type: Injectable }
1381
+ ];
1382
+ SessionStorageService.ctorParameters = () => [];
1328
1383
 
1329
1384
  /*
1330
1385
  <file>
@@ -1336,7 +1391,7 @@ BaseGridEditService.ctorParameters = () => [
1336
1391
  Anatoly Osovitny
1337
1392
 
1338
1393
  Created:
1339
- 30 April 2020
1394
+ 26 Jun 2020
1340
1395
 
1341
1396
  Version:
1342
1397
  1.0
@@ -1344,11 +1399,21 @@ BaseGridEditService.ctorParameters = () => [
1344
1399
  Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
1345
1400
  </file>
1346
1401
  */
1347
- const consts = {
1348
- billingApiPath: "api/billing",
1349
- // Notifications API
1350
- notificationsApiPath: 'api/notifications',
1351
- };
1402
+ class Subs {
1403
+ constructor() {
1404
+ this.subs = [];
1405
+ }
1406
+ add(...subscriptions) {
1407
+ this.subs = this.subs.concat(subscriptions);
1408
+ }
1409
+ set sink(subscription) {
1410
+ this.subs.push(subscription);
1411
+ }
1412
+ unsubscribe() {
1413
+ this.subs.forEach((sub) => sub && sub.unsubscribe());
1414
+ this.subs = [];
1415
+ }
1416
+ }
1352
1417
 
1353
1418
  /*
1354
1419
  <file>
@@ -1360,7 +1425,7 @@ const consts = {
1360
1425
  Anatoly Osovitny
1361
1426
 
1362
1427
  Created:
1363
- 12 Nov 2017
1428
+ 29 Apr 2018
1364
1429
 
1365
1430
  Version:
1366
1431
  1.0
@@ -1368,82 +1433,46 @@ const consts = {
1368
1433
  Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
1369
1434
  </file>
1370
1435
  */
1371
- class BillingApiService extends BaseApiService {
1436
+ class BaseGridReadService extends BehaviorSubject {
1372
1437
  constructor(http) {
1373
- super(http);
1438
+ super([]);
1374
1439
  this.http = http;
1375
- this.baseUrl = consts.billingApiPath;
1440
+ this.baseReadUrl = "";
1441
+ this.data = [];
1376
1442
  }
1377
- requestNewSubscription(requestedPlan, success, error) {
1378
- this.postQS("requestNewSubscription", { requestedPlan: requestedPlan }).subscribe((data) => { }, (e) => {
1379
- if (error)
1380
- error();
1381
- }, () => {
1382
- if (success)
1383
- success();
1384
- });
1443
+ serializeParams(data) {
1444
+ return data ? "?" + $.param(data) : "";
1385
1445
  }
1386
- cancelRequestedSubscription(success, error) {
1387
- this.postQS("cancelRequestedSubscription", null).subscribe((data) => { }, (e) => {
1388
- if (error)
1389
- error();
1390
- }, () => {
1446
+ read(params, success, error) {
1447
+ if (this.data.length) {
1448
+ return super.next(this.data);
1449
+ }
1450
+ var url = this.baseReadUrl;
1451
+ if (typeof params === "undefined") {
1452
+ params = this.savedReadParams;
1453
+ }
1454
+ if (params) {
1455
+ url = this.baseReadUrl + `${this.serializeParams(params)}`;
1456
+ this.savedReadParams = params;
1457
+ }
1458
+ this.http
1459
+ .get(url)
1460
+ .pipe(map((res) => res))
1461
+ .subscribe((data) => {
1462
+ super.next(data);
1391
1463
  if (success)
1392
1464
  success();
1393
- });
1394
- }
1395
- buyAccess(requestedPlan, success, error) {
1396
- this.postQS("buyAccess", { requestedPlan: requestedPlan }).subscribe((data) => { }, (e) => {
1465
+ }, (e) => {
1397
1466
  if (error)
1398
- error();
1399
- }, () => {
1400
- if (success)
1401
- success();
1467
+ error(e);
1402
1468
  });
1403
1469
  }
1404
1470
  }
1405
- BillingApiService.decorators = [
1471
+ BaseGridReadService.decorators = [
1406
1472
  { type: Injectable }
1407
1473
  ];
1408
- BillingApiService.ctorParameters = () => [
1409
- { type: HttpClient }
1410
- ];
1411
-
1412
- /*
1413
- <file>
1414
- Project:
1415
- @osovitny/anatoly
1416
-
1417
- Authors:
1418
- Vadim Osovitny
1419
- Anatoly Osovitny
1420
-
1421
- Created:
1422
- 4 Mar 2020
1423
-
1424
- Version:
1425
- 1.0
1426
-
1427
- Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
1428
- </file>
1429
- */
1430
- class AnatolyDataModule {
1431
- constructor(parentModule) {
1432
- throwIfAlreadyLoaded(parentModule, 'AnatolyDataModule');
1433
- }
1434
- }
1435
- AnatolyDataModule.decorators = [
1436
- { type: NgModule, args: [{
1437
- imports: [
1438
- CommonModule
1439
- ],
1440
- providers: [
1441
- BillingApiService
1442
- ],
1443
- },] }
1444
- ];
1445
- AnatolyDataModule.ctorParameters = () => [
1446
- { type: AnatolyDataModule, decorators: [{ type: Optional }, { type: SkipSelf }] }
1474
+ BaseGridReadService.ctorParameters = () => [
1475
+ { type: HttpClient }
1447
1476
  ];
1448
1477
 
1449
1478
  /*
@@ -1456,26 +1485,7 @@ AnatolyDataModule.ctorParameters = () => [
1456
1485
  Anatoly Osovitny
1457
1486
 
1458
1487
  Created:
1459
- 4 Mar 2020
1460
-
1461
- Version:
1462
- 1.0
1463
-
1464
- Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
1465
- </file>
1466
- */
1467
-
1468
- /*
1469
- <file>
1470
- Project:
1471
- @osovitny/anatoly
1472
-
1473
- Authors:
1474
- Vadim Osovitny
1475
- Anatoly Osovitny
1476
-
1477
- Created:
1478
- 14 Aug 2018
1488
+ 29 Apr 2018
1479
1489
 
1480
1490
  Version:
1481
1491
  1.0
@@ -1483,55 +1493,57 @@ AnatolyDataModule.ctorParameters = () => [
1483
1493
  Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
1484
1494
  </file>
1485
1495
  */
1486
- class BuyAccessButtonComponent {
1487
- constructor(appcontext, api) {
1488
- this.appcontext = appcontext;
1489
- this.api = api;
1490
- this.contextUpdated = false;
1491
- this.isUserSignedIn = false;
1492
- this.currentPlan = 0;
1493
- this.currentPlanTitle = "";
1496
+ class BaseGridEditService extends BaseGridReadService {
1497
+ constructor(http) {
1498
+ super(http);
1499
+ this.http = http;
1500
+ this.baseUrl = "";
1494
1501
  }
1495
- ngOnInit() {
1496
- if (!this.appcontext.isUserSignedIn()) {
1497
- this.contextUpdated = true;
1502
+ reset() {
1503
+ this.data = [];
1504
+ }
1505
+ resetItem(dataItem) {
1506
+ if (!dataItem) {
1498
1507
  return;
1499
1508
  }
1500
- this.appcontext.getCurrent((current) => {
1501
- this.isUserSignedIn = current.isUserSignedIn;
1502
- if (this.isUserSignedIn) {
1503
- this.currentPlan = current.account.billingPlan;
1504
- this.currentPlanTitle = current.account.billingPlanAsString;
1505
- }
1506
- this.contextUpdated = true;
1509
+ //find orignal data item
1510
+ const originalDataItem = this.data.find((item) => item.Id === dataItem.Id);
1511
+ //revert changes
1512
+ Object.assign(originalDataItem, dataItem);
1513
+ super.next(this.data);
1514
+ }
1515
+ save(data, isNew, sucess) {
1516
+ const action = isNew ? "add" : "update";
1517
+ this.reset();
1518
+ this.post(action, data).subscribe(() => { }, () => {
1519
+ this.read();
1520
+ }, () => {
1521
+ this.read();
1522
+ if (sucess)
1523
+ sucess();
1507
1524
  });
1508
1525
  }
1509
- onBuyPlan() {
1510
- const text = `Requested plan: ${this.plantitle} `;
1511
- const that = this;
1512
- Alerts.AreYouSure(text, "Buying access", "Confirm change", "Cancel", () => {
1513
- that.api.buyAccess(that.plan, () => {
1514
- Alerts.Success("Access Granted", null, () => {
1515
- window.location.reload();
1516
- });
1517
- });
1526
+ remove(data, sucess) {
1527
+ this.reset();
1528
+ this.post("remove", data).subscribe(() => { }, () => {
1529
+ this.read();
1530
+ }, () => {
1531
+ this.read();
1532
+ if (sucess)
1533
+ sucess();
1518
1534
  });
1519
1535
  }
1536
+ post(action, data) {
1537
+ var url = this.baseUrl + `${action}${this.serializeParams(data)}`;
1538
+ return this.http.post(url, data).pipe(map((res) => res));
1539
+ }
1520
1540
  }
1521
- BuyAccessButtonComponent.decorators = [
1522
- { type: Component, args: [{
1523
- selector: "anatoly-buyaccess-button",
1524
- template: "<div *ngIf=\"contextUpdated\">\r\n <div *ngIf=\"!isUserSignedIn\">\r\n <anatoly-signup-button classbtn=\"btn btn-block btn-primary\"></anatoly-signup-button>\r\n </div>\r\n\r\n <div *ngIf=\"isUserSignedIn\">\r\n <button class=\"btn btn-block btn-success selectPlan\" *ngIf=\"plan == currentPlan\">\r\n Your Plan\r\n </button>\r\n\r\n <button class=\"btn btn-block btn-warning selectPlan\" *ngIf=\"plan != currentPlan && currentPlan == 1\" (click)=\"onBuyPlan()\">\r\n Buy Now\r\n </button>\r\n </div>\r\n</div>\r\n"
1525
- },] }
1526
- ];
1527
- BuyAccessButtonComponent.ctorParameters = () => [
1528
- { type: AppContextService },
1529
- { type: BillingApiService }
1541
+ BaseGridEditService.decorators = [
1542
+ { type: Injectable }
1530
1543
  ];
1531
- BuyAccessButtonComponent.propDecorators = {
1532
- plan: [{ type: Input }],
1533
- plantitle: [{ type: Input }]
1534
- };
1544
+ BaseGridEditService.ctorParameters = () => [
1545
+ { type: HttpClient }
1546
+ ];
1535
1547
 
1536
1548
  /*
1537
1549
  <file>
@@ -1543,7 +1555,7 @@ BuyAccessButtonComponent.propDecorators = {
1543
1555
  Anatoly Osovitny
1544
1556
 
1545
1557
  Created:
1546
- 1 Jun 2018
1558
+ 30 April 2020
1547
1559
 
1548
1560
  Version:
1549
1561
  1.0
@@ -1551,45 +1563,10 @@ BuyAccessButtonComponent.propDecorators = {
1551
1563
  Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
1552
1564
  </file>
1553
1565
  */
1554
- class SubscribePlanButtonComponent {
1555
- constructor(appcontext) {
1556
- this.appcontext = appcontext;
1557
- this.contextUpdated = false;
1558
- this.isUserSignedIn = false;
1559
- this.currentPlan = 0;
1560
- this.currentPlanTitle = "";
1561
- this.requestedPlan = 0;
1562
- this.requestedPlanTitle = "";
1563
- }
1564
- ngOnInit() {
1565
- if (!this.appcontext.isUserSignedIn()) {
1566
- this.contextUpdated = true;
1567
- return;
1568
- }
1569
- this.appcontext.getCurrent((current) => {
1570
- this.isUserSignedIn = current.isUserSignedIn;
1571
- if (this.isUserSignedIn) {
1572
- this.currentPlan = current.account.billingPlan;
1573
- this.currentPlanTitle = current.account.billingPlanAsString;
1574
- this.requestedPlan = current.account.requestedBillingPlan;
1575
- this.requestedPlanTitle = current.account.requestedBillingPlanAsString;
1576
- }
1577
- this.contextUpdated = true;
1578
- });
1579
- }
1580
- }
1581
- SubscribePlanButtonComponent.decorators = [
1582
- { type: Component, args: [{
1583
- selector: "anatoly-subscribe-plan-button",
1584
- template: "<div *ngIf=\"contextUpdated\">\r\n <div *ngIf=\"!isUserSignedIn\">\r\n <anatoly-signup-button classbtn=\"btn btn-block btn-primary\"></anatoly-signup-button>\r\n </div>\r\n\r\n <div *ngIf=\"isUserSignedIn\">\r\n <button class=\"btn btn-block btn-success selectPlan\" *ngIf=\"plan == currentPlan\">\r\n Your Plan\r\n </button>\r\n\r\n <button class=\"btn btn-block btn-warning selectPlan\" *ngIf=\"requestedPlan != null && requestedPlan != 0 && plan == requestedPlan\">\r\n Requested\r\n </button>\r\n\r\n <anatoly-upgrade-plan-button *ngIf=\"plan != currentPlan && plan != requestedPlan\"\r\n [currentplantitle]=\"currentPlanTitle\"\r\n [requestedplan]=plan\r\n [requestedplantitle]=\"plantitle\">\r\n </anatoly-upgrade-plan-button>\r\n </div>\r\n</div>\r\n"
1585
- },] }
1586
- ];
1587
- SubscribePlanButtonComponent.ctorParameters = () => [
1588
- { type: AppContextService }
1589
- ];
1590
- SubscribePlanButtonComponent.propDecorators = {
1591
- plan: [{ type: Input }],
1592
- plantitle: [{ type: Input }]
1566
+ const consts = {
1567
+ billingApiPath: 'api/billing',
1568
+ // Notifications API
1569
+ notificationsApiPath: 'api/notifications',
1593
1570
  };
1594
1571
 
1595
1572
  /*
@@ -1602,7 +1579,7 @@ SubscribePlanButtonComponent.propDecorators = {
1602
1579
  Anatoly Osovitny
1603
1580
 
1604
1581
  Created:
1605
- 12 Nov 2017
1582
+ 30 April 2020
1606
1583
 
1607
1584
  Version:
1608
1585
  1.0
@@ -1610,37 +1587,25 @@ SubscribePlanButtonComponent.propDecorators = {
1610
1587
  Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
1611
1588
  </file>
1612
1589
  */
1613
- // Services
1614
- class UpgradePlanButtonComponent {
1615
- constructor(api) {
1616
- this.api = api;
1590
+ class NotificationsApiService extends BaseApiService {
1591
+ constructor(http) {
1592
+ super(http);
1593
+ this.http = http;
1594
+ this.baseUrl = consts.notificationsApiPath;
1617
1595
  }
1618
- onUpgradePlan() {
1619
- const text = `Current plan: ${this.currentplantitle} New plan: ${this.requestedplantitle}`;
1620
- const that = this;
1621
- Alerts.AreYouSure(text, "Change billing plan", "Confirm change", "Cancel", () => {
1622
- that.api.requestNewSubscription(that.requestedplan, () => {
1623
- Alerts.Success("Your request for changing plan has been sent.", null, () => {
1624
- window.location.reload();
1625
- });
1626
- });
1627
- });
1596
+ retrieveNotifications() {
1597
+ return this.get('retrieveNotifications');
1628
1598
  }
1629
1599
  }
1630
- UpgradePlanButtonComponent.decorators = [
1631
- { type: Component, args: [{
1632
- selector: "anatoly-upgrade-plan-button",
1633
- template: "<button class=\"btn btn-block btn-primary\" (click)=\"onUpgradePlan()\">\r\n Upgrade\r\n</button>\r\n"
1600
+ NotificationsApiService.ɵprov = ɵɵdefineInjectable({ factory: function NotificationsApiService_Factory() { return new NotificationsApiService(ɵɵinject(HttpClient)); }, token: NotificationsApiService, providedIn: "root" });
1601
+ NotificationsApiService.decorators = [
1602
+ { type: Injectable, args: [{
1603
+ providedIn: 'root'
1634
1604
  },] }
1635
1605
  ];
1636
- UpgradePlanButtonComponent.ctorParameters = () => [
1637
- { type: BillingApiService }
1638
- ];
1639
- UpgradePlanButtonComponent.propDecorators = {
1640
- currentplantitle: [{ type: Input }],
1641
- requestedplan: [{ type: Input }],
1642
- requestedplantitle: [{ type: Input }]
1643
- };
1606
+ NotificationsApiService.ctorParameters = () => [
1607
+ { type: HttpClient }
1608
+ ];
1644
1609
 
1645
1610
  /*
1646
1611
  <file>
@@ -1652,7 +1617,7 @@ UpgradePlanButtonComponent.propDecorators = {
1652
1617
  Anatoly Osovitny
1653
1618
 
1654
1619
  Created:
1655
- 4 Jul 2018
1620
+ 12 Nov 2017
1656
1621
 
1657
1622
  Version:
1658
1623
  1.0
@@ -1660,19 +1625,46 @@ UpgradePlanButtonComponent.propDecorators = {
1660
1625
  Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
1661
1626
  </file>
1662
1627
  */
1663
- class SignInButtonComponent {
1664
- constructor() { }
1628
+ class BillingApiService extends BaseApiService {
1629
+ constructor(http) {
1630
+ super(http);
1631
+ this.http = http;
1632
+ this.baseUrl = consts.billingApiPath;
1633
+ }
1634
+ requestNewSubscription(requestedPlan, success, error) {
1635
+ this.postQS("requestNewSubscription", { requestedPlan: requestedPlan }).subscribe((data) => { }, (e) => {
1636
+ if (error)
1637
+ error();
1638
+ }, () => {
1639
+ if (success)
1640
+ success();
1641
+ });
1642
+ }
1643
+ cancelRequestedSubscription(success, error) {
1644
+ this.postQS("cancelRequestedSubscription", null).subscribe((data) => { }, (e) => {
1645
+ if (error)
1646
+ error();
1647
+ }, () => {
1648
+ if (success)
1649
+ success();
1650
+ });
1651
+ }
1652
+ buyAccess(requestedPlan, success, error) {
1653
+ this.postQS("buyAccess", { requestedPlan: requestedPlan }).subscribe((data) => { }, (e) => {
1654
+ if (error)
1655
+ error();
1656
+ }, () => {
1657
+ if (success)
1658
+ success();
1659
+ });
1660
+ }
1665
1661
  }
1666
- SignInButtonComponent.decorators = [
1667
- { type: Component, args: [{
1668
- selector: "anatoly-signin-button",
1669
- template: "<a href=\"identity/signIn\" class=\"{{classbtn}}\">Sign In</a>\r\n"
1670
- },] }
1662
+ BillingApiService.decorators = [
1663
+ { type: Injectable }
1671
1664
  ];
1672
- SignInButtonComponent.ctorParameters = () => [];
1673
- SignInButtonComponent.propDecorators = {
1674
- classbtn: [{ type: Input }]
1675
- };
1665
+ BillingApiService.ctorParameters = () => [
1666
+ { type: HttpClient }
1667
+ ];
1676
1668
 
1677
1669
  /*
1678
1670
  <file>
@@ -1684,7 +1676,7 @@ SignInButtonComponent.propDecorators = {
1684
1676
  Anatoly Osovitny
1685
1677
 
1686
1678
  Created:
1687
- 4 Jul 2018
1679
+ 4 Mar 2020
1688
1680
 
1689
1681
  Version:
1690
1682
  1.0
@@ -1692,19 +1684,24 @@ SignInButtonComponent.propDecorators = {
1692
1684
  Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
1693
1685
  </file>
1694
1686
  */
1695
- class SignOutButtonComponent {
1696
- constructor() { }
1687
+ class AnatolyDataModule {
1688
+ constructor(parentModule) {
1689
+ throwIfAlreadyLoaded(parentModule, 'AnatolyDataModule');
1690
+ }
1697
1691
  }
1698
- SignOutButtonComponent.decorators = [
1699
- { type: Component, args: [{
1700
- selector: "anatoly-signout-button",
1701
- template: "<a href=\"identity/signOut\" class=\"{{classbtn}}\">Sign Out</a>\r\n"
1692
+ AnatolyDataModule.decorators = [
1693
+ { type: NgModule, args: [{
1694
+ imports: [
1695
+ CommonModule
1696
+ ],
1697
+ providers: [
1698
+ BillingApiService
1699
+ ],
1702
1700
  },] }
1703
1701
  ];
1704
- SignOutButtonComponent.ctorParameters = () => [];
1705
- SignOutButtonComponent.propDecorators = {
1706
- classbtn: [{ type: Input }]
1707
- };
1702
+ AnatolyDataModule.ctorParameters = () => [
1703
+ { type: AnatolyDataModule, decorators: [{ type: Optional }, { type: SkipSelf }] }
1704
+ ];
1708
1705
 
1709
1706
  /*
1710
1707
  <file>
@@ -1716,7 +1713,7 @@ SignOutButtonComponent.propDecorators = {
1716
1713
  Anatoly Osovitny
1717
1714
 
1718
1715
  Created:
1719
- 4 Jul 2018
1716
+ 14 Aug 2018
1720
1717
 
1721
1718
  Version:
1722
1719
  1.0
@@ -1724,16 +1721,54 @@ SignOutButtonComponent.propDecorators = {
1724
1721
  Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
1725
1722
  </file>
1726
1723
  */
1727
- class SignUpButtonComponent {
1724
+ class BuyAccessButtonComponent {
1725
+ constructor(appcontext, api) {
1726
+ this.appcontext = appcontext;
1727
+ this.api = api;
1728
+ this.contextUpdated = false;
1729
+ this.isUserSignedIn = false;
1730
+ this.currentPlan = 0;
1731
+ this.currentPlanTitle = '';
1732
+ }
1733
+ ngOnInit() {
1734
+ if (!this.appcontext.isUserSignedIn()) {
1735
+ this.contextUpdated = true;
1736
+ return;
1737
+ }
1738
+ this.appcontext.getCurrent((current) => {
1739
+ this.isUserSignedIn = current.isUserSignedIn;
1740
+ if (this.isUserSignedIn) {
1741
+ this.currentPlan = current.account.billingPlan;
1742
+ this.currentPlanTitle = current.account.billingPlanAsString;
1743
+ }
1744
+ this.contextUpdated = true;
1745
+ });
1746
+ }
1747
+ onBuyPlan() {
1748
+ const text = `Requested plan: ${this.plantitle} `;
1749
+ const that = this;
1750
+ Alerts.areYouSure(text, 'Buying access', 'Confirm change', 'Cancel', () => {
1751
+ that.api.buyAccess(that.plan, () => {
1752
+ Alerts.success('Access Granted', null, null, () => {
1753
+ window.location.reload();
1754
+ });
1755
+ });
1756
+ });
1757
+ }
1728
1758
  }
1729
- SignUpButtonComponent.decorators = [
1759
+ BuyAccessButtonComponent.decorators = [
1730
1760
  { type: Component, args: [{
1731
- selector: "anatoly-signup-button",
1732
- template: "<a href=\"identity/signup\" class=\"{{classbtn}}\">Sign Up</a>\r\n"
1761
+ selector: 'anatoly-buyaccess-button',
1762
+ template: "<div *ngIf=\"contextUpdated\">\r\n <div *ngIf=\"!isUserSignedIn\">\r\n <anatoly-signup-button classbtn=\"btn btn-block btn-primary\"></anatoly-signup-button>\r\n </div>\r\n\r\n <div *ngIf=\"isUserSignedIn\">\r\n <button class=\"btn btn-block btn-success selectPlan\" *ngIf=\"plan == currentPlan\">\r\n Your Plan\r\n </button>\r\n\r\n <button class=\"btn btn-block btn-warning selectPlan\" *ngIf=\"plan != currentPlan && currentPlan == 1\" (click)=\"onBuyPlan()\">\r\n Buy Now\r\n </button>\r\n </div>\r\n</div>\r\n"
1733
1763
  },] }
1734
1764
  ];
1735
- SignUpButtonComponent.propDecorators = {
1736
- classbtn: [{ type: Input }]
1765
+ BuyAccessButtonComponent.ctorParameters = () => [
1766
+ { type: AppContextService },
1767
+ { type: BillingApiService }
1768
+ ];
1769
+ BuyAccessButtonComponent.propDecorators = {
1770
+ plan: [{ type: Input }],
1771
+ plantitle: [{ type: Input }]
1737
1772
  };
1738
1773
 
1739
1774
  /*
@@ -1746,7 +1781,7 @@ SignUpButtonComponent.propDecorators = {
1746
1781
  Anatoly Osovitny
1747
1782
 
1748
1783
  Created:
1749
- 23 Apr 2018
1784
+ 1 Jun 2018
1750
1785
 
1751
1786
  Version:
1752
1787
  1.0
@@ -1754,21 +1789,45 @@ SignUpButtonComponent.propDecorators = {
1754
1789
  Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
1755
1790
  </file>
1756
1791
  */
1757
- class ContentHeaderComponent {
1792
+ class SubscribePlanButtonComponent {
1793
+ constructor(appcontext) {
1794
+ this.appcontext = appcontext;
1795
+ this.contextUpdated = false;
1796
+ this.isUserSignedIn = false;
1797
+ this.currentPlan = 0;
1798
+ this.currentPlanTitle = "";
1799
+ this.requestedPlan = 0;
1800
+ this.requestedPlanTitle = "";
1801
+ }
1758
1802
  ngOnInit() {
1759
- if (this.title == null) {
1760
- this.title = "";
1803
+ if (!this.appcontext.isUserSignedIn()) {
1804
+ this.contextUpdated = true;
1805
+ return;
1761
1806
  }
1807
+ this.appcontext.getCurrent((current) => {
1808
+ this.isUserSignedIn = current.isUserSignedIn;
1809
+ if (this.isUserSignedIn) {
1810
+ this.currentPlan = current.account.billingPlan;
1811
+ this.currentPlanTitle = current.account.billingPlanAsString;
1812
+ this.requestedPlan = current.account.requestedBillingPlan;
1813
+ this.requestedPlanTitle = current.account.requestedBillingPlanAsString;
1814
+ }
1815
+ this.contextUpdated = true;
1816
+ });
1762
1817
  }
1763
1818
  }
1764
- ContentHeaderComponent.decorators = [
1819
+ SubscribePlanButtonComponent.decorators = [
1765
1820
  { type: Component, args: [{
1766
- selector: "anatoly-content-header",
1767
- template: "<h2 class=\"page-header\">\r\n {{title}}\r\n <!--<small>Optional {{title}}</small>-->\r\n</h2>\r\n"
1821
+ selector: "anatoly-subscribe-plan-button",
1822
+ template: "<div *ngIf=\"contextUpdated\">\r\n <div *ngIf=\"!isUserSignedIn\">\r\n <anatoly-signup-button classbtn=\"btn btn-block btn-primary\"></anatoly-signup-button>\r\n </div>\r\n\r\n <div *ngIf=\"isUserSignedIn\">\r\n <button class=\"btn btn-block btn-success selectPlan\" *ngIf=\"plan == currentPlan\">\r\n Your Plan\r\n </button>\r\n\r\n <button class=\"btn btn-block btn-warning selectPlan\" *ngIf=\"requestedPlan != null && requestedPlan != 0 && plan == requestedPlan\">\r\n Requested\r\n </button>\r\n\r\n <anatoly-upgrade-plan-button *ngIf=\"plan != currentPlan && plan != requestedPlan\"\r\n [currentplantitle]=\"currentPlanTitle\"\r\n [requestedplan]=plan\r\n [requestedplantitle]=\"plantitle\">\r\n </anatoly-upgrade-plan-button>\r\n </div>\r\n</div>\r\n"
1768
1823
  },] }
1769
1824
  ];
1770
- ContentHeaderComponent.propDecorators = {
1771
- title: [{ type: Input }]
1825
+ SubscribePlanButtonComponent.ctorParameters = () => [
1826
+ { type: AppContextService }
1827
+ ];
1828
+ SubscribePlanButtonComponent.propDecorators = {
1829
+ plan: [{ type: Input }],
1830
+ plantitle: [{ type: Input }]
1772
1831
  };
1773
1832
 
1774
1833
  /*
@@ -1781,7 +1840,7 @@ ContentHeaderComponent.propDecorators = {
1781
1840
  Anatoly Osovitny
1782
1841
 
1783
1842
  Created:
1784
- 28 Aug 2018
1843
+ 12 Nov 2017
1785
1844
 
1786
1845
  Version:
1787
1846
  1.0
@@ -1789,14 +1848,37 @@ ContentHeaderComponent.propDecorators = {
1789
1848
  Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
1790
1849
  </file>
1791
1850
  */
1792
- class BaseComponent {
1793
- getQSId() {
1794
- var id = Utils.getValueByNameInQS("id");
1795
- if (typeof id === 'undefined' || id == '')
1796
- return null;
1797
- return id;
1851
+ // Services
1852
+ class UpgradePlanButtonComponent {
1853
+ constructor(api) {
1854
+ this.api = api;
1798
1855
  }
1799
- }
1856
+ onUpgradePlan() {
1857
+ const text = `Current plan: ${this.currentplantitle} New plan: ${this.requestedplantitle}`;
1858
+ const that = this;
1859
+ Alerts.areYouSure(text, 'Change billing plan', 'Confirm change', 'Cancel', () => {
1860
+ that.api.requestNewSubscription(that.requestedplan, () => {
1861
+ Alerts.success('Your request for changing plan has been sent.', null, null, () => {
1862
+ window.location.reload();
1863
+ });
1864
+ });
1865
+ });
1866
+ }
1867
+ }
1868
+ UpgradePlanButtonComponent.decorators = [
1869
+ { type: Component, args: [{
1870
+ selector: 'anatoly-upgrade-plan-button',
1871
+ template: "<button class=\"btn btn-block btn-primary\" (click)=\"onUpgradePlan()\">\r\n Upgrade\r\n</button>\r\n"
1872
+ },] }
1873
+ ];
1874
+ UpgradePlanButtonComponent.ctorParameters = () => [
1875
+ { type: BillingApiService }
1876
+ ];
1877
+ UpgradePlanButtonComponent.propDecorators = {
1878
+ currentplantitle: [{ type: Input }],
1879
+ requestedplan: [{ type: Input }],
1880
+ requestedplantitle: [{ type: Input }]
1881
+ };
1800
1882
 
1801
1883
  /*
1802
1884
  <file>
@@ -1808,7 +1890,7 @@ class BaseComponent {
1808
1890
  Anatoly Osovitny
1809
1891
 
1810
1892
  Created:
1811
- 20 Nov 2017
1893
+ 23 Apr 2018
1812
1894
 
1813
1895
  Version:
1814
1896
  1.0
@@ -1816,58 +1898,21 @@ class BaseComponent {
1816
1898
  Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
1817
1899
  </file>
1818
1900
  */
1819
- class BaseEditComponent extends BaseComponent {
1820
- constructor() {
1821
- super();
1822
- this.formSubmitted = false;
1823
- }
1824
- isActionAdding() {
1825
- var id = Utils.getValueByNameInQS("id");
1826
- if (typeof id === 'undefined' || id == '')
1827
- return true;
1828
- return false;
1829
- }
1830
- getEntityId() {
1831
- return this.getQSId();
1832
- }
1833
- isControlValid(name, formGroup = null) {
1834
- return !this.isControlInvalid(name, formGroup);
1835
- }
1836
- isControlInvalid(name, formGroup = null) {
1837
- if (typeof name === 'undefined' || name == '') {
1838
- return false;
1839
- }
1840
- let fg = (formGroup) ? formGroup : this.formGroup;
1841
- if (!fg) {
1842
- return false;
1843
- }
1844
- if (fg.get(name)) {
1845
- return (this.formSubmitted && fg.get(name).invalid) ||
1846
- (fg.get(name).touched && fg.get(name).invalid);
1901
+ class ContentHeaderComponent {
1902
+ ngOnInit() {
1903
+ if (this.title == null) {
1904
+ this.title = "";
1847
1905
  }
1848
- return false;
1849
- }
1850
- //FormGroup functions
1851
- getFormValue(name, formGroup = null) {
1852
- let fg = (formGroup) ? formGroup : this.formGroup;
1853
- return fg.controls[name].value;
1854
- }
1855
- setFormValue(name, value, formGroup = null) {
1856
- let fg = (formGroup) ? formGroup : this.formGroup;
1857
- fg.controls[name].setValue(value);
1858
- }
1859
- getFormGroupValue(groupName, name, formGroup = null) {
1860
- let fg = (formGroup) ? formGroup : this.formGroup;
1861
- return fg.controls[groupName].get(name).value;
1862
- }
1863
- setFormGroupValue(groupName, name, value, formGroup = null) {
1864
- let fg = (formGroup) ? formGroup : this.formGroup;
1865
- fg.controls[groupName].get(name).setValue(value);
1866
1906
  }
1867
1907
  }
1868
- BaseEditComponent.propDecorators = {
1869
- formGroup: [{ type: Input }],
1870
- formSubmitted: [{ type: Input }]
1908
+ ContentHeaderComponent.decorators = [
1909
+ { type: Component, args: [{
1910
+ selector: "anatoly-content-header",
1911
+ template: "<h2 class=\"page-header\">\r\n {{title}}\r\n <!--<small>Optional {{title}}</small>-->\r\n</h2>\r\n"
1912
+ },] }
1913
+ ];
1914
+ ContentHeaderComponent.propDecorators = {
1915
+ title: [{ type: Input }]
1871
1916
  };
1872
1917
 
1873
1918
  /*
@@ -1959,6 +2004,105 @@ const DefaultEditorOptions = {
1959
2004
  imageUploadParams: { uploadType: "", uploadParentId: "" },
1960
2005
  };
1961
2006
 
2007
+ /*
2008
+ <file>
2009
+ Project:
2010
+ @osovitny/anatoly
2011
+
2012
+ Authors:
2013
+ Vadim Osovitny
2014
+ Anatoly Osovitny
2015
+
2016
+ Created:
2017
+ 28 Aug 2018
2018
+
2019
+ Version:
2020
+ 1.0
2021
+
2022
+ Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
2023
+ </file>
2024
+ */
2025
+ class BaseComponent {
2026
+ getQSId() {
2027
+ var id = Utils.getValueByNameInQS("id");
2028
+ if (typeof id === 'undefined' || id == '')
2029
+ return null;
2030
+ return id;
2031
+ }
2032
+ }
2033
+
2034
+ /*
2035
+ <file>
2036
+ Project:
2037
+ @osovitny/anatoly
2038
+
2039
+ Authors:
2040
+ Vadim Osovitny
2041
+ Anatoly Osovitny
2042
+
2043
+ Created:
2044
+ 20 Nov 2017
2045
+
2046
+ Version:
2047
+ 1.0
2048
+
2049
+ Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
2050
+ </file>
2051
+ */
2052
+ class BaseEditComponent extends BaseComponent {
2053
+ constructor() {
2054
+ super();
2055
+ this.formSubmitted = false;
2056
+ }
2057
+ isActionAdding() {
2058
+ var id = Utils.getValueByNameInQS("id");
2059
+ if (typeof id === 'undefined' || id == '')
2060
+ return true;
2061
+ return false;
2062
+ }
2063
+ getEntityId() {
2064
+ return this.getQSId();
2065
+ }
2066
+ isControlValid(name, formGroup = null) {
2067
+ return !this.isControlInvalid(name, formGroup);
2068
+ }
2069
+ isControlInvalid(name, formGroup = null) {
2070
+ if (typeof name === 'undefined' || name == '') {
2071
+ return false;
2072
+ }
2073
+ let fg = (formGroup) ? formGroup : this.formGroup;
2074
+ if (!fg) {
2075
+ return false;
2076
+ }
2077
+ if (fg.get(name)) {
2078
+ return (this.formSubmitted && fg.get(name).invalid) ||
2079
+ (fg.get(name).touched && fg.get(name).invalid);
2080
+ }
2081
+ return false;
2082
+ }
2083
+ //FormGroup functions
2084
+ getFormValue(name, formGroup = null) {
2085
+ let fg = (formGroup) ? formGroup : this.formGroup;
2086
+ return fg.controls[name].value;
2087
+ }
2088
+ setFormValue(name, value, formGroup = null) {
2089
+ let fg = (formGroup) ? formGroup : this.formGroup;
2090
+ fg.controls[name].setValue(value);
2091
+ }
2092
+ getFormGroupValue(groupName, name, formGroup = null) {
2093
+ let fg = (formGroup) ? formGroup : this.formGroup;
2094
+ return fg.controls[groupName].get(name).value;
2095
+ }
2096
+ setFormGroupValue(groupName, name, value, formGroup = null) {
2097
+ let fg = (formGroup) ? formGroup : this.formGroup;
2098
+ fg.controls[groupName].get(name).setValue(value);
2099
+ }
2100
+ }
2101
+ BaseEditComponent.propDecorators = {
2102
+ formGroup: [{ type: Input }],
2103
+ formSubmitted: [{ type: Input }]
2104
+ };
2105
+
1962
2106
  /*
1963
2107
  <file>
1964
2108
  Project:
@@ -1982,17 +2126,17 @@ class BaseHtmlEditorComponent extends BaseEditComponent {
1982
2126
  super();
1983
2127
  this.froalaEditorInitialized = false;
1984
2128
  this.afterInitializedActions = [];
1985
- //Inputs
1986
- this.editorLabelText = "Html";
2129
+ // Inputs
2130
+ this.editorLabelText = 'Html';
1987
2131
  this.editorOptions = {};
1988
2132
  }
1989
2133
  ngOnInit() {
1990
2134
  let opt = this.editorOptions;
1991
- if (typeof this.editorOptions == "string") {
2135
+ if (typeof this.editorOptions == 'string') {
1992
2136
  opt = JSON.parse(this.editorOptions);
1993
2137
  }
1994
2138
  let newOptions = $.extend({}, DefaultEditorOptions, opt);
1995
- let key = AppCoreSettings.froalaEditorKey;
2139
+ const key = AppCoreSettings.froalaEditorKey;
1996
2140
  if (key) {
1997
2141
  newOptions = $.extend({}, newOptions, JSON.parse('{ "key": "' + key + '" }'));
1998
2142
  }
@@ -2002,18 +2146,18 @@ class BaseHtmlEditorComponent extends BaseEditComponent {
2002
2146
  this.options = newOptions;
2003
2147
  }
2004
2148
  ngAfterViewInit() {
2005
- let that = this;
2149
+ const that = this;
2006
2150
  setTimeout(function () {
2007
2151
  that.froalaEditorInitialized = true;
2008
2152
  that.onInitialized();
2009
2153
  }, 300);
2010
2154
  }
2011
2155
  onInitialized() {
2012
- let actions = this.afterInitializedActions;
2013
- //Clear actions
2156
+ const actions = this.afterInitializedActions;
2157
+ // Clear actions
2014
2158
  this.afterInitializedActions = [];
2015
2159
  if (actions) {
2016
- for (var i = 0; i < actions.length; i++) {
2160
+ for (let i = 0; i < actions.length; i++) {
2017
2161
  actions[i]();
2018
2162
  }
2019
2163
  }
@@ -2023,9 +2167,9 @@ class BaseHtmlEditorComponent extends BaseEditComponent {
2023
2167
  return this.froalaEditor.getEditor();
2024
2168
  return null;
2025
2169
  }
2026
- //Public Funcs
2170
+ // Public Funcs
2027
2171
  doAfterInitialized(action) {
2028
- let that = this;
2172
+ const that = this;
2029
2173
  if (!this.froalaEditorInitialized) {
2030
2174
  this.afterInitializedActions.push(() => {
2031
2175
  action(that);
@@ -2041,8 +2185,8 @@ class BaseHtmlEditorComponent extends BaseEditComponent {
2041
2185
  }
2042
2186
  setUploadParams(uploadType, uploadParentId) {
2043
2187
  this.doAfterInitialized(function (that) {
2044
- var editor = that.getEditor();
2045
- if (typeof editor == "undefined" || editor == null) {
2188
+ const editor = that.getEditor();
2189
+ if (typeof editor == 'undefined' || editor == null) {
2046
2190
  return;
2047
2191
  }
2048
2192
  editor.opts.imageUploadParams.uploadType = uploadType;
@@ -2055,6 +2199,46 @@ BaseHtmlEditorComponent.propDecorators = {
2055
2199
  editorOptions: [{ type: Input }]
2056
2200
  };
2057
2201
 
2202
+ /*
2203
+ <file>
2204
+ Project:
2205
+ @osovitny/anatoly
2206
+
2207
+ Authors:
2208
+ Vadim Osovitny
2209
+ Anatoly Osovitny
2210
+
2211
+ Created:
2212
+ 12 Dec 2017
2213
+
2214
+ Version:
2215
+ 1.0
2216
+
2217
+ Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
2218
+ </file>
2219
+ */
2220
+ class FormsHtmlEditorComponent extends BaseHtmlEditorComponent {
2221
+ constructor() {
2222
+ super();
2223
+ this.editorFormKey = "html";
2224
+ }
2225
+ setFormValueAfterInitialized(name, value) {
2226
+ this.doAfterInitialized(function (that) {
2227
+ that.setFormValue(name, value);
2228
+ });
2229
+ }
2230
+ }
2231
+ FormsHtmlEditorComponent.decorators = [
2232
+ { type: Component, args: [{
2233
+ selector: "anatoly-forms-html-editor",
2234
+ template: "<div [formGroup]=\"formGroup\">\r\n <div class=\"form-group\" [ngClass]=\"{'has-error': isControlInvalid(editorFormKey) }\">\r\n <label class=\"control-label\">{{ editorLabelText }}</label>\r\n <textarea [formControlName]=\"editorFormKey\"\r\n [froalaEditor]=\"options\" (froalaInit)=\"initializeControl($event)\">\r\n </textarea>\r\n <anatoly-item-validation-summary [formGroup]=\"formGroup\"\r\n [formSubmitted]=\"formSubmitted\"\r\n [controlName]=\"editorFormKey\"\r\n [controlTitle]=\"editorLabelText\">\r\n </anatoly-item-validation-summary>\r\n </div>\r\n</div>\r\n"
2235
+ },] }
2236
+ ];
2237
+ FormsHtmlEditorComponent.ctorParameters = () => [];
2238
+ FormsHtmlEditorComponent.propDecorators = {
2239
+ editorFormKey: [{ type: Input }]
2240
+ };
2241
+
2058
2242
  /*
2059
2243
  <file>
2060
2244
  Project:
@@ -2112,7 +2296,7 @@ HtmlEditorComponent.ctorParameters = () => [];
2112
2296
  Anatoly Osovitny
2113
2297
 
2114
2298
  Created:
2115
- 12 Dec 2017
2299
+ 4 Jul 2018
2116
2300
 
2117
2301
  Version:
2118
2302
  1.0
@@ -2120,26 +2304,18 @@ HtmlEditorComponent.ctorParameters = () => [];
2120
2304
  Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
2121
2305
  </file>
2122
2306
  */
2123
- class FormsHtmlEditorComponent extends BaseHtmlEditorComponent {
2124
- constructor() {
2125
- super();
2126
- this.editorFormKey = "html";
2127
- }
2128
- setFormValueAfterInitialized(name, value) {
2129
- this.doAfterInitialized(function (that) {
2130
- that.setFormValue(name, value);
2131
- });
2132
- }
2307
+ class SignInButtonComponent {
2308
+ constructor() { }
2133
2309
  }
2134
- FormsHtmlEditorComponent.decorators = [
2310
+ SignInButtonComponent.decorators = [
2135
2311
  { type: Component, args: [{
2136
- selector: "anatoly-forms-html-editor",
2137
- template: "<div [formGroup]=\"formGroup\">\r\n <div class=\"form-group\" [ngClass]=\"{'has-error': isControlInvalid(editorFormKey) }\">\r\n <label class=\"control-label\">{{ editorLabelText }}</label>\r\n <textarea [formControlName]=\"editorFormKey\"\r\n [froalaEditor]=\"options\" (froalaInit)=\"initializeControl($event)\">\r\n </textarea>\r\n <anatoly-item-validation-summary [formGroup]=\"formGroup\"\r\n [formSubmitted]=\"formSubmitted\"\r\n [controlName]=\"editorFormKey\"\r\n [controlTitle]=\"editorLabelText\">\r\n </anatoly-item-validation-summary>\r\n </div>\r\n</div>\r\n"
2312
+ selector: "anatoly-signin-button",
2313
+ template: "<a href=\"identity/signIn\" class=\"{{classbtn}}\">Sign In</a>\r\n"
2138
2314
  },] }
2139
2315
  ];
2140
- FormsHtmlEditorComponent.ctorParameters = () => [];
2141
- FormsHtmlEditorComponent.propDecorators = {
2142
- editorFormKey: [{ type: Input }]
2316
+ SignInButtonComponent.ctorParameters = () => [];
2317
+ SignInButtonComponent.propDecorators = {
2318
+ classbtn: [{ type: Input }]
2143
2319
  };
2144
2320
 
2145
2321
  /*
@@ -2152,7 +2328,7 @@ FormsHtmlEditorComponent.propDecorators = {
2152
2328
  Anatoly Osovitny
2153
2329
 
2154
2330
  Created:
2155
- 8 Dec 2017
2331
+ 4 Jul 2018
2156
2332
 
2157
2333
  Version:
2158
2334
  1.0
@@ -2160,102 +2336,19 @@ FormsHtmlEditorComponent.propDecorators = {
2160
2336
  Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
2161
2337
  </file>
2162
2338
  */
2163
- class ValidationSummaryComponent extends BaseEditComponent {
2164
- constructor() {
2165
- super();
2166
- }
2167
- getFormValidationMessages() {
2168
- let messages = [];
2169
- Object.keys(this.formGroup.controls).forEach(k => {
2170
- var control = this.formGroup.controls[k];
2171
- if (control.controls != null) {
2172
- Object.keys(control.controls).forEach(k => {
2173
- var child = control.controls[k];
2174
- this.getValidationMessages(child, this.getControlName(child, k)).forEach(m => messages.push(m));
2175
- });
2176
- }
2177
- else {
2178
- this.getValidationMessages(control, this.getControlName(control, k)).forEach(m => messages.push(m));
2179
- }
2180
- });
2181
- return messages;
2182
- }
2183
- getValidationMessages(state, thingName) {
2184
- let thing = state.path || thingName;
2185
- let messages = [];
2186
- if (state.errors) {
2187
- for (let errorName in state.errors) {
2188
- if (state.errors.hasOwnProperty(errorName)) {
2189
- switch (errorName) {
2190
- case 'required':
2191
- messages.push(`${thing} is required`);
2192
- break;
2193
- case 'minlength':
2194
- messages.push(`${thing} must be at least ${state.errors["minlength"].requiredLength} characters`);
2195
- break;
2196
- case 'pattern':
2197
- messages.push(`${thing} contains illegal characters`);
2198
- break;
2199
- case 'format':
2200
- messages.push(`${thing} format mismatch`);
2201
- break;
2202
- case 'maxlength':
2203
- messages.push(`${thing} must have maximum ${state.errors["maxlength"].requiredLength} characters`);
2204
- break;
2205
- case 'specialcharacters':
2206
- messages.push(`${thing} contains special characters`);
2207
- break;
2208
- }
2209
- }
2210
- }
2211
- }
2212
- return messages;
2213
- }
2214
- /**
2215
- * Get Control Name
2216
- * @param control
2217
- * @param thingName
2218
- */
2219
- getControlName(control, thingName) {
2220
- let value = this.getControlTitle(control);
2221
- return value ? value : thingName;
2222
- }
2223
- /**
2224
- * Retrieve tilte of control
2225
- * @param control
2226
- */
2227
- getControlTitle(control) {
2228
- if (control === null || control === void 0 ? void 0 : control.nativeElement) {
2229
- let controlTitle = this.getTitleAttribute(control.nativeElement);
2230
- if (controlTitle) {
2231
- return controlTitle;
2232
- }
2233
- }
2234
- return undefined;
2235
- }
2236
- /**
2237
- * Return title attribute of form control
2238
- */
2239
- getTitleAttribute(nativeElement) {
2240
- var _a, _b, _c, _d, _e, _f;
2241
- let title;
2242
- switch (nativeElement.tagName) {
2243
- // For Kendo time and date picker element title is assigned to the 4th child control.
2244
- case "KENDO-TIMEPICKER":
2245
- case "KENDO-DATEPICKER":
2246
- title = (_d = (_c = (_b = (_a = nativeElement.children[0]) === null || _a === void 0 ? void 0 : _a.children[0]) === null || _b === void 0 ? void 0 : _b.children[0]) === null || _c === void 0 ? void 0 : _c.children[0]) === null || _d === void 0 ? void 0 : _d.getAttribute('title');
2247
- break;
2248
- // For Kendo numaric element title is assigned to the 2nd child control.
2249
- case "KENDO-NUMERICTEXTBOX":
2250
- title = (_f = (_e = nativeElement.children[0]) === null || _e === void 0 ? void 0 : _e.children[0]) === null || _f === void 0 ? void 0 : _f.getAttribute('title');
2251
- break;
2252
- default:
2253
- title = nativeElement.getAttribute('title');
2254
- break;
2255
- }
2256
- return title;
2257
- }
2258
- }
2339
+ class SignOutButtonComponent {
2340
+ constructor() { }
2341
+ }
2342
+ SignOutButtonComponent.decorators = [
2343
+ { type: Component, args: [{
2344
+ selector: "anatoly-signout-button",
2345
+ template: "<a href=\"identity/signOut\" class=\"{{classbtn}}\">Sign Out</a>\r\n"
2346
+ },] }
2347
+ ];
2348
+ SignOutButtonComponent.ctorParameters = () => [];
2349
+ SignOutButtonComponent.propDecorators = {
2350
+ classbtn: [{ type: Input }]
2351
+ };
2259
2352
 
2260
2353
  /*
2261
2354
  <file>
@@ -2267,7 +2360,7 @@ class ValidationSummaryComponent extends BaseEditComponent {
2267
2360
  Anatoly Osovitny
2268
2361
 
2269
2362
  Created:
2270
- 7 Dec 2017
2363
+ 4 Jul 2018
2271
2364
 
2272
2365
  Version:
2273
2366
  1.0
@@ -2275,48 +2368,62 @@ class ValidationSummaryComponent extends BaseEditComponent {
2275
2368
  Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
2276
2369
  </file>
2277
2370
  */
2278
- class FormValidationSummaryComponent extends ValidationSummaryComponent {
2279
- constructor() {
2280
- super();
2281
- this.visible = false;
2282
- this.customerrors = [];
2283
- /*
2284
- 0 - only FormValidation messages
2285
- 1 - only Custom messages
2286
- 2 - all
2287
- */
2288
- this.viewtype = 0;
2371
+ class SignUpButtonComponent {
2372
+ }
2373
+ SignUpButtonComponent.decorators = [
2374
+ { type: Component, args: [{
2375
+ selector: "anatoly-signup-button",
2376
+ template: "<a href=\"identity/signup\" class=\"{{classbtn}}\">Sign Up</a>\r\n"
2377
+ },] }
2378
+ ];
2379
+ SignUpButtonComponent.propDecorators = {
2380
+ classbtn: [{ type: Input }]
2381
+ };
2382
+
2383
+ /*
2384
+ <file>
2385
+ Project:
2386
+ @osovitny/anatoly
2387
+
2388
+ Authors:
2389
+ Vadim Osovitny
2390
+ Anatoly Osovitny
2391
+
2392
+ Created:
2393
+ 9 May 2020
2394
+
2395
+ Version:
2396
+ 1.0
2397
+
2398
+ Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
2399
+ </file>
2400
+ */
2401
+ class LoadingComponent {
2402
+ constructor(loadingService) {
2403
+ this.loadingService = loadingService;
2404
+ // Private
2405
+ this.subs = new Subs();
2406
+ // Public
2407
+ this.show = false;
2289
2408
  }
2290
- getErrors() {
2291
- if (this.viewtype == 1) {
2292
- return this.customerrors;
2293
- }
2294
- let formValidationMessages = this.getFormValidationMessages();
2295
- if (this.viewtype == 0) {
2296
- return formValidationMessages;
2297
- }
2298
- var messages = [];
2299
- if (formValidationMessages.length > 0) {
2300
- messages.push(...formValidationMessages);
2301
- }
2302
- if (this.customerrors.length > 0) {
2303
- messages.push(...this.customerrors);
2304
- }
2305
- return messages;
2409
+ ngOnInit() {
2410
+ this.subs.sink = this.loadingService.subscribe((state) => {
2411
+ this.show = state;
2412
+ });
2413
+ }
2414
+ ngOnDestroy() {
2415
+ this.subs.unsubscribe();
2306
2416
  }
2307
2417
  }
2308
- FormValidationSummaryComponent.decorators = [
2418
+ LoadingComponent.decorators = [
2309
2419
  { type: Component, args: [{
2310
- selector: "anatoly-form-validation-summary",
2311
- template: "<div class=\"callout callout-danger\" *ngIf=\"visible\">\r\n <h6 class=\"box-title\">There are problems with the form</h6>\r\n <ul>\r\n <li *ngFor=\"let error of getErrors()\"><span>{{error}}</span></li>\r\n </ul>\r\n</div>\r\n\r\n"
2420
+ selector: 'anatoly-loading',
2421
+ template: "<div *ngIf=\"show\">\r\n <span id=\"pnlLoading\" class=\"k-icon k-i-loading\"></span>\r\n</div>\r\n"
2312
2422
  },] }
2313
2423
  ];
2314
- FormValidationSummaryComponent.ctorParameters = () => [];
2315
- FormValidationSummaryComponent.propDecorators = {
2316
- visible: [{ type: Input }],
2317
- customerrors: [{ type: Input }],
2318
- viewtype: [{ type: Input }]
2319
- };
2424
+ LoadingComponent.ctorParameters = () => [
2425
+ { type: LoadingService }
2426
+ ];
2320
2427
 
2321
2428
  /*
2322
2429
  <file>
@@ -2328,7 +2435,7 @@ FormValidationSummaryComponent.propDecorators = {
2328
2435
  Anatoly Osovitny
2329
2436
 
2330
2437
  Created:
2331
- 6 Dec 2017
2438
+ 16 May 2020
2332
2439
 
2333
2440
  Version:
2334
2441
  1.0
@@ -2336,21 +2443,55 @@ FormValidationSummaryComponent.propDecorators = {
2336
2443
  Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
2337
2444
  </file>
2338
2445
  */
2339
- class ItemValidationSummaryComponent extends ValidationSummaryComponent {
2340
- constructor() {
2341
- super();
2446
+ const SpinnerSpinKit = {
2447
+ spinnerLine: 'spinner-line-material',
2448
+ // ToDo
2449
+ ChasingDots: 'spinner-chasing-dots',
2450
+ CubeGrid: 'spinner-cube-grid',
2451
+ DoubleBounce: 'spinner-double-bounce',
2452
+ RotatingPlane: 'spinner-rotationg-plane',
2453
+ SpinnerPulse: 'spinner-spinner-pulse',
2454
+ ThreeBounce: 'spinner-three-bounce',
2455
+ WanderingCubes: 'spinner-wandering-cubes',
2456
+ Wave: 'spinner-wave'
2457
+ };
2458
+ class SpinnerComponent {
2459
+ constructor(router, document) {
2460
+ this.router = router;
2461
+ this.document = document;
2462
+ this.isSpinnerVisible = true;
2463
+ this.spinnerSpinKit = SpinnerSpinKit;
2464
+ this.backgroundColor = '#007CB0';
2465
+ this.spinner = SpinnerSpinKit.spinnerLine;
2466
+ this.router.events.subscribe(event => {
2467
+ if (event instanceof NavigationStart) {
2468
+ this.isSpinnerVisible = true;
2469
+ }
2470
+ else if (event instanceof NavigationEnd || event instanceof NavigationCancel || event instanceof NavigationError) {
2471
+ this.isSpinnerVisible = false;
2472
+ }
2473
+ }, () => {
2474
+ this.isSpinnerVisible = false;
2475
+ });
2476
+ }
2477
+ ngOnDestroy() {
2478
+ this.isSpinnerVisible = false;
2342
2479
  }
2343
2480
  }
2344
- ItemValidationSummaryComponent.decorators = [
2481
+ SpinnerComponent.decorators = [
2345
2482
  { type: Component, args: [{
2346
- selector: "anatoly-item-validation-summary",
2347
- template: "<ul class=\"list-unstyled\" *ngIf=\"isControlInvalid(controlName)\">\r\n <li *ngFor=\"let error of getValidationMessages(formGroup.get(controlName), controlTitle)\">\r\n <span class=\"help-block\">{{ error }}</span>\r\n </li>\r\n</ul>\r\n\r\n"
2483
+ selector: 'spinner',
2484
+ template: "<div id=\"spinner-loader\" *ngIf=\"isSpinnerVisible\">\r\n <div class=\"loader-bg\">\r\n <div class=\"spinner-line-material\" [class.colored]=\"!backgroundColor\" *ngIf=\"spinner === spinnerSpinKit.spinnerLine\">\r\n <div class=\"spinner-child spinner-bounce1\" [style.background-color]='backgroundColor'></div>\r\n </div>\r\n </div>\r\n</div>\r\n",
2485
+ encapsulation: ViewEncapsulation.None
2348
2486
  },] }
2349
2487
  ];
2350
- ItemValidationSummaryComponent.ctorParameters = () => [];
2351
- ItemValidationSummaryComponent.propDecorators = {
2352
- controlName: [{ type: Input }],
2353
- controlTitle: [{ type: Input }]
2488
+ SpinnerComponent.ctorParameters = () => [
2489
+ { type: Router },
2490
+ { type: Document, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
2491
+ ];
2492
+ SpinnerComponent.propDecorators = {
2493
+ backgroundColor: [{ type: Input }],
2494
+ spinner: [{ type: Input }]
2354
2495
  };
2355
2496
 
2356
2497
  /*
@@ -2409,49 +2550,19 @@ NativeElementDirective.ctorParameters = () => [
2409
2550
  Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
2410
2551
  </file>
2411
2552
  */
2412
- const FroalaEditorModuleWithProviders = FroalaEditorModule.forRoot();
2413
- const FroalaViewModuleWithProviders = FroalaViewModule.forRoot();
2414
- class AnatolyUIModule {
2553
+ class ReplaceTextPipe {
2554
+ transform(inputData, search, replacement) {
2555
+ if (inputData) {
2556
+ return inputData.replace(new RegExp(search, "g"), replacement);
2557
+ }
2558
+ else {
2559
+ return inputData;
2560
+ }
2561
+ }
2415
2562
  }
2416
- AnatolyUIModule.decorators = [
2417
- { type: NgModule, args: [{
2418
- imports: [
2419
- CommonModule,
2420
- ReactiveFormsModule,
2421
- FormsModule,
2422
- FroalaEditorModuleWithProviders,
2423
- FroalaViewModuleWithProviders,
2424
- ],
2425
- exports: [
2426
- SubscribePlanButtonComponent,
2427
- UpgradePlanButtonComponent,
2428
- BuyAccessButtonComponent,
2429
- SignInButtonComponent,
2430
- SignUpButtonComponent,
2431
- SignOutButtonComponent,
2432
- FormValidationSummaryComponent,
2433
- ItemValidationSummaryComponent,
2434
- HtmlEditorComponent,
2435
- FormsHtmlEditorComponent,
2436
- ContentHeaderComponent,
2437
- // Directives
2438
- NativeElementDirective
2439
- ],
2440
- declarations: [
2441
- SubscribePlanButtonComponent,
2442
- UpgradePlanButtonComponent,
2443
- BuyAccessButtonComponent,
2444
- SignInButtonComponent,
2445
- SignUpButtonComponent,
2446
- SignOutButtonComponent,
2447
- FormValidationSummaryComponent,
2448
- ItemValidationSummaryComponent,
2449
- HtmlEditorComponent,
2450
- FormsHtmlEditorComponent,
2451
- ContentHeaderComponent,
2452
- // Directives
2453
- NativeElementDirective
2454
- ]
2563
+ ReplaceTextPipe.decorators = [
2564
+ { type: Pipe, args: [{
2565
+ name: "replaceText",
2455
2566
  },] }
2456
2567
  ];
2457
2568
 
@@ -2472,7 +2583,27 @@ AnatolyUIModule.decorators = [
2472
2583
 
2473
2584
  Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
2474
2585
  </file>
2475
- */
2586
+ */
2587
+ class FileSizePipe {
2588
+ constructor() {
2589
+ this.units = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB'];
2590
+ }
2591
+ transform(bytes = 0, precision = 0) {
2592
+ if (isNaN(parseFloat(String(bytes))) || !isFinite(bytes))
2593
+ return '';
2594
+ let unit = 0;
2595
+ while (bytes >= 1024) {
2596
+ bytes /= 1024;
2597
+ unit++;
2598
+ }
2599
+ return bytes.toFixed(+precision) + ' ' + this.units[unit];
2600
+ }
2601
+ }
2602
+ FileSizePipe.decorators = [
2603
+ { type: Pipe, args: [{
2604
+ name: 'filesize',
2605
+ },] }
2606
+ ];
2476
2607
 
2477
2608
  /*
2478
2609
  <file>
@@ -2484,7 +2615,7 @@ AnatolyUIModule.decorators = [
2484
2615
  Anatoly Osovitny
2485
2616
 
2486
2617
  Created:
2487
- 10 May 2020
2618
+ 27 Oct 2019
2488
2619
 
2489
2620
  Version:
2490
2621
  1.0
@@ -2492,47 +2623,19 @@ AnatolyUIModule.decorators = [
2492
2623
  Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
2493
2624
  </file>
2494
2625
  */
2495
- class LocalizePipe {
2496
- constructor(localizeService) {
2497
- this.localizeService = localizeService;
2626
+ class SafeHtmlPipe {
2627
+ constructor(sanitized) {
2628
+ this.sanitized = sanitized;
2498
2629
  }
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;
2630
+ transform(value) {
2631
+ return this.sanitized.bypassSecurityTrustHtml(value);
2527
2632
  }
2528
2633
  }
2529
- LocalizePipe.decorators = [
2530
- { type: Pipe, args: [{
2531
- name: 'localize'
2532
- },] }
2634
+ SafeHtmlPipe.decorators = [
2635
+ { type: Pipe, args: [{ name: 'safeHtml' },] }
2533
2636
  ];
2534
- LocalizePipe.ctorParameters = () => [
2535
- { type: LocalizationService }
2637
+ SafeHtmlPipe.ctorParameters = () => [
2638
+ { type: DomSanitizer }
2536
2639
  ];
2537
2640
 
2538
2641
  /*
@@ -2545,7 +2648,122 @@ LocalizePipe.ctorParameters = () => [
2545
2648
  Anatoly Osovitny
2546
2649
 
2547
2650
  Created:
2548
- 12 May 2020
2651
+ 8 Dec 2017
2652
+
2653
+ Version:
2654
+ 1.0
2655
+
2656
+ Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
2657
+ </file>
2658
+ */
2659
+ class ValidationSummaryComponent extends BaseEditComponent {
2660
+ constructor() {
2661
+ super();
2662
+ }
2663
+ getFormValidationMessages() {
2664
+ let messages = [];
2665
+ Object.keys(this.formGroup.controls).forEach(k => {
2666
+ var control = this.formGroup.controls[k];
2667
+ if (control.controls != null) {
2668
+ Object.keys(control.controls).forEach(k => {
2669
+ var child = control.controls[k];
2670
+ this.getValidationMessages(child, this.getControlName(child, k)).forEach(m => messages.push(m));
2671
+ });
2672
+ }
2673
+ else {
2674
+ this.getValidationMessages(control, this.getControlName(control, k)).forEach(m => messages.push(m));
2675
+ }
2676
+ });
2677
+ return messages;
2678
+ }
2679
+ getValidationMessages(state, thingName) {
2680
+ let thing = state.path || thingName;
2681
+ let messages = [];
2682
+ if (state.errors) {
2683
+ for (let errorName in state.errors) {
2684
+ if (state.errors.hasOwnProperty(errorName)) {
2685
+ switch (errorName) {
2686
+ case 'required':
2687
+ messages.push(`${thing} is required`);
2688
+ break;
2689
+ case 'minlength':
2690
+ messages.push(`${thing} must be at least ${state.errors["minlength"].requiredLength} characters`);
2691
+ break;
2692
+ case 'pattern':
2693
+ messages.push(`${thing} contains illegal characters`);
2694
+ break;
2695
+ case 'format':
2696
+ messages.push(`${thing} format mismatch`);
2697
+ break;
2698
+ case 'maxlength':
2699
+ messages.push(`${thing} must have maximum ${state.errors["maxlength"].requiredLength} characters`);
2700
+ break;
2701
+ case 'specialcharacters':
2702
+ messages.push(`${thing} contains special characters`);
2703
+ break;
2704
+ }
2705
+ }
2706
+ }
2707
+ }
2708
+ return messages;
2709
+ }
2710
+ /**
2711
+ * Get Control Name
2712
+ * @param control
2713
+ * @param thingName
2714
+ */
2715
+ getControlName(control, thingName) {
2716
+ let value = this.getControlTitle(control);
2717
+ return value ? value : thingName;
2718
+ }
2719
+ /**
2720
+ * Retrieve tilte of control
2721
+ * @param control
2722
+ */
2723
+ getControlTitle(control) {
2724
+ if (control === null || control === void 0 ? void 0 : control.nativeElement) {
2725
+ let controlTitle = this.getTitleAttribute(control.nativeElement);
2726
+ if (controlTitle) {
2727
+ return controlTitle;
2728
+ }
2729
+ }
2730
+ return undefined;
2731
+ }
2732
+ /**
2733
+ * Return title attribute of form control
2734
+ */
2735
+ getTitleAttribute(nativeElement) {
2736
+ var _a, _b, _c, _d, _e, _f;
2737
+ let title;
2738
+ switch (nativeElement.tagName) {
2739
+ // For Kendo time and date picker element title is assigned to the 4th child control.
2740
+ case "KENDO-TIMEPICKER":
2741
+ case "KENDO-DATEPICKER":
2742
+ title = (_d = (_c = (_b = (_a = nativeElement.children[0]) === null || _a === void 0 ? void 0 : _a.children[0]) === null || _b === void 0 ? void 0 : _b.children[0]) === null || _c === void 0 ? void 0 : _c.children[0]) === null || _d === void 0 ? void 0 : _d.getAttribute('title');
2743
+ break;
2744
+ // For Kendo numaric element title is assigned to the 2nd child control.
2745
+ case "KENDO-NUMERICTEXTBOX":
2746
+ title = (_f = (_e = nativeElement.children[0]) === null || _e === void 0 ? void 0 : _e.children[0]) === null || _f === void 0 ? void 0 : _f.getAttribute('title');
2747
+ break;
2748
+ default:
2749
+ title = nativeElement.getAttribute('title');
2750
+ break;
2751
+ }
2752
+ return title;
2753
+ }
2754
+ }
2755
+
2756
+ /*
2757
+ <file>
2758
+ Project:
2759
+ @osovitny/anatoly
2760
+
2761
+ Authors:
2762
+ Vadim Osovitny
2763
+ Anatoly Osovitny
2764
+
2765
+ Created:
2766
+ 7 Dec 2017
2549
2767
 
2550
2768
  Version:
2551
2769
  1.0
@@ -2553,23 +2771,48 @@ LocalizePipe.ctorParameters = () => [
2553
2771
  Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
2554
2772
  </file>
2555
2773
  */
2556
- class LocalizationModule {
2774
+ class FormValidationSummaryComponent extends ValidationSummaryComponent {
2775
+ constructor() {
2776
+ super();
2777
+ this.visible = false;
2778
+ this.customerrors = [];
2779
+ /*
2780
+ 0 - only FormValidation messages
2781
+ 1 - only Custom messages
2782
+ 2 - all
2783
+ */
2784
+ this.viewtype = 0;
2785
+ }
2786
+ getErrors() {
2787
+ if (this.viewtype == 1) {
2788
+ return this.customerrors;
2789
+ }
2790
+ let formValidationMessages = this.getFormValidationMessages();
2791
+ if (this.viewtype == 0) {
2792
+ return formValidationMessages;
2793
+ }
2794
+ var messages = [];
2795
+ if (formValidationMessages.length > 0) {
2796
+ messages.push(...formValidationMessages);
2797
+ }
2798
+ if (this.customerrors.length > 0) {
2799
+ messages.push(...this.customerrors);
2800
+ }
2801
+ return messages;
2802
+ }
2557
2803
  }
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: []
2804
+ FormValidationSummaryComponent.decorators = [
2805
+ { type: Component, args: [{
2806
+ selector: "anatoly-form-validation-summary",
2807
+ template: "<div class=\"callout callout-danger\" *ngIf=\"visible\">\r\n <h6 class=\"box-title\">There are problems with the form</h6>\r\n <ul>\r\n <li *ngFor=\"let error of getErrors()\"><span>{{error}}</span></li>\r\n </ul>\r\n</div>\r\n\r\n"
2571
2808
  },] }
2572
- ];
2809
+ ];
2810
+ FormValidationSummaryComponent.ctorParameters = () => [];
2811
+ FormValidationSummaryComponent.propDecorators = {
2812
+ visible: [{ type: Input }],
2813
+ customerrors: [{ type: Input }],
2814
+ viewtype: [{ type: Input }]
2815
+ };
2573
2816
 
2574
2817
  /*
2575
2818
  <file>
@@ -2581,7 +2824,7 @@ LocalizationModule.decorators = [
2581
2824
  Anatoly Osovitny
2582
2825
 
2583
2826
  Created:
2584
- 05 May 2020
2827
+ 6 Dec 2017
2585
2828
 
2586
2829
  Version:
2587
2830
  1.0
@@ -2589,48 +2832,22 @@ LocalizationModule.decorators = [
2589
2832
  Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
2590
2833
  </file>
2591
2834
  */
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]
2835
+ class ItemValidationSummaryComponent extends ValidationSummaryComponent {
2836
+ constructor() {
2837
+ super();
2614
2838
  }
2615
- });
2616
- class LocalizationSettingsModule {
2617
2839
  }
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: []
2840
+ ItemValidationSummaryComponent.decorators = [
2841
+ { type: Component, args: [{
2842
+ selector: "anatoly-item-validation-summary",
2843
+ template: "<ul class=\"list-unstyled\" *ngIf=\"isControlInvalid(controlName)\">\r\n <li *ngFor=\"let error of getValidationMessages(formGroup.get(controlName), controlTitle)\">\r\n <span class=\"help-block\">{{ error }}</span>\r\n </li>\r\n</ul>\r\n\r\n"
2632
2844
  },] }
2633
- ];
2845
+ ];
2846
+ ItemValidationSummaryComponent.ctorParameters = () => [];
2847
+ ItemValidationSummaryComponent.propDecorators = {
2848
+ controlName: [{ type: Input }],
2849
+ controlTitle: [{ type: Input }]
2850
+ };
2634
2851
 
2635
2852
  /*
2636
2853
  <file>
@@ -2649,112 +2866,60 @@ LocalizationSettingsModule.decorators = [
2649
2866
 
2650
2867
  Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
2651
2868
  </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
2869
  */
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
- }
2870
+ const FroalaEditorModuleWithProviders = FroalaEditorModule.forRoot();
2871
+ const FroalaViewModuleWithProviders = FroalaViewModule.forRoot();
2872
+ class AnatolyUIModule {
2873
+ }
2874
+ AnatolyUIModule.decorators = [
2875
+ { type: NgModule, args: [{
2876
+ imports: [
2877
+ CommonModule,
2878
+ ReactiveFormsModule,
2879
+ FormsModule,
2880
+ FroalaEditorModuleWithProviders,
2881
+ FroalaViewModuleWithProviders,
2882
+ ],
2883
+ exports: [
2884
+ SubscribePlanButtonComponent,
2885
+ UpgradePlanButtonComponent,
2886
+ BuyAccessButtonComponent,
2887
+ SignInButtonComponent,
2888
+ SignUpButtonComponent,
2889
+ SignOutButtonComponent,
2890
+ FormValidationSummaryComponent,
2891
+ ItemValidationSummaryComponent,
2892
+ HtmlEditorComponent,
2893
+ FormsHtmlEditorComponent,
2894
+ ContentHeaderComponent,
2895
+ SpinnerComponent,
2896
+ LoadingComponent,
2897
+ NativeElementDirective,
2898
+ SafeHtmlPipe,
2899
+ ReplaceTextPipe,
2900
+ FileSizePipe
2901
+ ],
2902
+ declarations: [
2903
+ SubscribePlanButtonComponent,
2904
+ UpgradePlanButtonComponent,
2905
+ BuyAccessButtonComponent,
2906
+ SignInButtonComponent,
2907
+ SignUpButtonComponent,
2908
+ SignOutButtonComponent,
2909
+ FormValidationSummaryComponent,
2910
+ ItemValidationSummaryComponent,
2911
+ HtmlEditorComponent,
2912
+ FormsHtmlEditorComponent,
2913
+ ContentHeaderComponent,
2914
+ SpinnerComponent,
2915
+ LoadingComponent,
2916
+ NativeElementDirective,
2917
+ SafeHtmlPipe,
2918
+ ReplaceTextPipe,
2919
+ FileSizePipe
2920
+ ]
2921
+ },] }
2922
+ ];
2758
2923
 
2759
2924
  /*
2760
2925
  * Public API Surface of anatoly
@@ -2764,5 +2929,5 @@ class Alerts$1 {
2764
2929
  * Generated bundle index. Do not edit.
2765
2930
  */
2766
2931
 
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 };
2932
+ export { Alerts, AnatolyCoreModule, AnatolyDataModule, AnatolyHttpInterceptor, AnatolyUIModule, AppContextService, AppCoreSettings, BaseApiService, BaseComponent, BaseEditComponent, BaseGoService, BaseGridEditService, BaseGridReadService, BaseHtmlEditorComponent, BillingApiService, BuyAccessButtonComponent, ContentHeaderComponent, ContextInitState, Convert, DefaultEditorOptions, FileSizePipe, FormValidationSummaryComponent, FormsHtmlEditorComponent, FroalaEditorModuleWithProviders, FroalaViewModuleWithProviders, GlobalErrorHandler, Guid, HtmlEditorComponent, IdleService, InjectorInstance, ItemValidationSummaryComponent, LoadingComponent, LoadingService, LocalStorageService, LocalizationModule, LocalizationService, LocalizationSettingsModule, LocalizePipe, LoggingService, NativeElementDirective, NotificationService, NotificationsApiService, ReplaceTextPipe, SafeHtmlPipe, SessionStorageService, SignInButtonComponent, SignOutButtonComponent, SignUpButtonComponent, SpinnerComponent, Subs, SubscribePlanButtonComponent, TranslateModuleAtRoot, UpgradePlanButtonComponent, Urls, Utils, ValidationSummaryComponent, consts, customTranslateLoaderFactory, localizationInitializerFactory, throwIfAlreadyLoaded };
2768
2933
  //# sourceMappingURL=osovitny-anatoly.js.map