@osovitny/anatoly 2.15.7 → 2.15.9

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.
@@ -1,3 +1,4 @@
1
+ import js_beautify from 'js-beautify';
1
2
  import * as i0 from '@angular/core';
2
3
  import { Injectable, Pipe, APP_INITIALIZER, Injector, NgModule, Inject, Component, Input, EventEmitter, Output, ViewEncapsulation, Directive, ViewChild, HostBinding, HostListener, Optional, SkipSelf } from '@angular/core';
3
4
  import * as i1 from '@angular/router';
@@ -19,7 +20,6 @@ import { v4 } from 'uuid';
19
20
  import * as i1$2 from 'ngx-toastr';
20
21
  import { ToastrModule } from 'ngx-toastr';
21
22
  import * as i1$4 from '@angular/platform-browser';
22
- import js_beautify from 'js-beautify';
23
23
  import * as i1$6 from '@fortawesome/angular-fontawesome';
24
24
  import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
25
25
  import * as i1$7 from '@progress/kendo-angular-pager';
@@ -76,6 +76,143 @@ const Urls = {
76
76
  notificationsSocketUrl: '/hubs/notifications'
77
77
  };
78
78
 
79
+ /*
80
+ <file>
81
+ Project:
82
+ @osovitny/anatoly
83
+
84
+ Authors:
85
+ Vadim Osovitny vadim@osovitny.com
86
+ Anatoly Osovitny anatoly@osovitny.com
87
+
88
+ Created:
89
+ 29 June 2020
90
+
91
+ Copyright (c) 2016-2022 Osovitny Inc. All rights reserved.
92
+ </file>
93
+ */
94
+ class Convert {
95
+ static pad(number) {
96
+ if (number < 10) {
97
+ return '0' + number;
98
+ }
99
+ return number;
100
+ }
101
+ static toLocalizedDateTime(value) {
102
+ if (value) {
103
+ return new Date(Date.UTC(value.getFullYear(), value.getMonth(), value.getDate(), value.getHours(), value.getMinutes(), value.getSeconds(), value.getMilliseconds()));
104
+ }
105
+ return null;
106
+ }
107
+ static enumToString(enumeration, value) {
108
+ for (let k in enumeration)
109
+ if (enumeration[k] == value)
110
+ return k;
111
+ return null;
112
+ }
113
+ static enumToArray(enumeration, notIncludes) {
114
+ const notIncludeFiler = (value) => {
115
+ if (isNaN(Number(value))) {
116
+ return false;
117
+ }
118
+ if (notIncludes) {
119
+ for (let i in notIncludes) {
120
+ if (notIncludes[i] == value)
121
+ return false;
122
+ }
123
+ }
124
+ return true;
125
+ };
126
+ return Object.keys(enumeration)
127
+ .filter(notIncludeFiler)
128
+ .map(key => ({
129
+ value: key,
130
+ text: enumeration[key]
131
+ }));
132
+ }
133
+ static stringToArray(str, separator = ',') {
134
+ if (str) {
135
+ return str.split(separator).filter(element => element);
136
+ }
137
+ return [];
138
+ }
139
+ static stringToIntArray(str, separator = ',') {
140
+ if (str) {
141
+ return str.split(separator).filter(element => element).map(value => parseInt(value));
142
+ }
143
+ return [];
144
+ }
145
+ static company2String(comp) {
146
+ let company = JSON.parse(comp);
147
+ if (company) {
148
+ return `${company.name} ${company.phone} ${company.email} ${company.websiteUrl}`;
149
+ }
150
+ }
151
+ static address2String(adr) {
152
+ let address = JSON.parse(adr);
153
+ return `${address.street} ${address.street2} ${address.city} ${address.stateOrRegion} ${address.zipcode} ${address.country}`;
154
+ }
155
+ static dateToString(date) {
156
+ return date.getFullYear() +
157
+ '-' + this.pad(date.getMonth() + 1) +
158
+ '-' + this.pad(date.getDate()) +
159
+ ' ' + this.pad(date.getHours()) +
160
+ ':' + this.pad(date.getMinutes()) +
161
+ ':' + this.pad(date.getSeconds());
162
+ }
163
+ static utcDateToLocalDate(d) {
164
+ let date = new Date(d);
165
+ return new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds()));
166
+ }
167
+ static stringToBoolean(value) {
168
+ switch (value.toLowerCase().trim()) {
169
+ case "true":
170
+ case "yes":
171
+ case "1":
172
+ return true;
173
+ case "false":
174
+ case "no":
175
+ case "0":
176
+ case null:
177
+ return false;
178
+ default:
179
+ return Boolean(value);
180
+ }
181
+ }
182
+ }
183
+
184
+ /*
185
+ <file>
186
+ Project:
187
+ @osovitny/anatoly
188
+
189
+ Authors:
190
+ Vadim Osovitny vadim@osovitny.com
191
+ Anatoly Osovitny anatoly@osovitny.com
192
+
193
+ Created:
194
+ 10 Sep 2022
195
+
196
+ Code:
197
+ https://www.npmjs.com/package/js-beautify
198
+ https://beautifier.io
199
+
200
+ Copyright (c) 2016-2022 Osovitny Inc. All rights reserved.
201
+ </file>
202
+ */
203
+ class XmlFormatter {
204
+ static toPrettyXML(s, options) {
205
+ if (!options) {
206
+ options = {
207
+ indent_size: 2,
208
+ indent_char: " ",
209
+ wrap_line_length: 110
210
+ };
211
+ }
212
+ return js_beautify.html(s, options);
213
+ }
214
+ }
215
+
79
216
  /*
80
217
  <file>
81
218
  Project:
@@ -341,111 +478,6 @@ AnatolyHttpInterceptor.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: A
341
478
  }], function () { return [{ type: LoadingService }, { type: LoggingService }]; }, null);
342
479
  })();
343
480
 
344
- /*
345
- <file>
346
- Project:
347
- @osovitny/anatoly
348
-
349
- Authors:
350
- Vadim Osovitny vadim@osovitny.com
351
- Anatoly Osovitny anatoly@osovitny.com
352
-
353
- Created:
354
- 29 June 2020
355
-
356
- Copyright (c) 2016-2022 Osovitny Inc. All rights reserved.
357
- </file>
358
- */
359
- class Convert {
360
- static pad(number) {
361
- if (number < 10) {
362
- return '0' + number;
363
- }
364
- return number;
365
- }
366
- static toLocalizedDateTime(value) {
367
- if (value) {
368
- return new Date(Date.UTC(value.getFullYear(), value.getMonth(), value.getDate(), value.getHours(), value.getMinutes(), value.getSeconds(), value.getMilliseconds()));
369
- }
370
- return null;
371
- }
372
- static enumToString(enumeration, value) {
373
- for (let k in enumeration)
374
- if (enumeration[k] == value)
375
- return k;
376
- return null;
377
- }
378
- static enumToArray(enumeration, notIncludes) {
379
- const notIncludeFiler = (value) => {
380
- if (isNaN(Number(value))) {
381
- return false;
382
- }
383
- if (notIncludes) {
384
- for (let i in notIncludes) {
385
- if (notIncludes[i] == value)
386
- return false;
387
- }
388
- }
389
- return true;
390
- };
391
- return Object.keys(enumeration)
392
- .filter(notIncludeFiler)
393
- .map(key => ({
394
- value: key,
395
- text: enumeration[key]
396
- }));
397
- }
398
- static stringToArray(str, separator = ',') {
399
- if (str) {
400
- return str.split(separator).filter(element => element);
401
- }
402
- return [];
403
- }
404
- static stringToIntArray(str, separator = ',') {
405
- if (str) {
406
- return str.split(separator).filter(element => element).map(value => parseInt(value));
407
- }
408
- return [];
409
- }
410
- static company2String(comp) {
411
- let company = JSON.parse(comp);
412
- if (company) {
413
- return `${company.name} ${company.phone} ${company.email} ${company.websiteUrl}`;
414
- }
415
- }
416
- static address2String(adr) {
417
- let address = JSON.parse(adr);
418
- return `${address.street} ${address.street2} ${address.city} ${address.stateOrRegion} ${address.zipcode} ${address.country}`;
419
- }
420
- static dateToString(date) {
421
- return date.getFullYear() +
422
- '-' + this.pad(date.getMonth() + 1) +
423
- '-' + this.pad(date.getDate()) +
424
- ' ' + this.pad(date.getHours()) +
425
- ':' + this.pad(date.getMinutes()) +
426
- ':' + this.pad(date.getSeconds());
427
- }
428
- static utcDateToLocalDate(d) {
429
- let date = new Date(d);
430
- return new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds()));
431
- }
432
- static stringToBoolean(value) {
433
- switch (value.toLowerCase().trim()) {
434
- case "true":
435
- case "yes":
436
- case "1":
437
- return true;
438
- case "false":
439
- case "no":
440
- case "0":
441
- case null:
442
- return false;
443
- default:
444
- return Boolean(value);
445
- }
446
- }
447
- }
448
-
449
481
  /*
450
482
  <file>
451
483
  Project:
@@ -1232,6 +1264,56 @@ NotificationService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: Noti
1232
1264
  }], function () { return [{ type: i1$2.ToastrService }]; }, null);
1233
1265
  })();
1234
1266
 
1267
+ /*
1268
+ <file>
1269
+ Project:
1270
+ @osovitny/anatoly
1271
+
1272
+ Authors:
1273
+ Vadim Osovitny vadim@osovitny.com
1274
+ Anatoly Osovitny anatoly@osovitny.com
1275
+
1276
+ Created:
1277
+ 17 Apr 2023
1278
+
1279
+ Copyright (c) 2016-2022 Osovitny Inc. All rights reserved.
1280
+ </file>
1281
+ */
1282
+ class Stopwatch {
1283
+ constructor(name) {
1284
+ this.name = name;
1285
+ this.startTime = 0;
1286
+ this.stopTime = 0;
1287
+ this.running = false;
1288
+ this.performance = !!window.performance;
1289
+ console.log(this.name + ' started.');
1290
+ }
1291
+ currentTime() {
1292
+ return this.performance ? window.performance.now() : new Date().getTime();
1293
+ }
1294
+ start() {
1295
+ this.startTime = this.currentTime();
1296
+ this.running = true;
1297
+ }
1298
+ stop() {
1299
+ this.stopTime = this.currentTime();
1300
+ this.running = false;
1301
+ }
1302
+ getElapsedMilliseconds() {
1303
+ if (this.running) {
1304
+ this.stopTime = this.currentTime();
1305
+ }
1306
+ return this.stopTime - this.startTime;
1307
+ }
1308
+ getElapsedSeconds() {
1309
+ return this.getElapsedMilliseconds() / 1000;
1310
+ }
1311
+ printElapsedAsMilliseconds() {
1312
+ let elapsed = this.getElapsedMilliseconds();
1313
+ console.log(`${this.name} stopped. Execution time: ${elapsed} ms`);
1314
+ }
1315
+ }
1316
+
1235
1317
  /*
1236
1318
  <file>
1237
1319
  Project:
@@ -1341,10 +1423,7 @@ BaseApiService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: BaseApiSe
1341
1423
  */
1342
1424
  class WebStorageService {
1343
1425
  constructor(storage) {
1344
- this.storage =
1345
- storage === 'local' || storage === 'localStorage'
1346
- ? localStorage
1347
- : sessionStorage;
1426
+ this.storage = storage === 'local' || storage === 'localStorage' ? localStorage : sessionStorage;
1348
1427
  }
1349
1428
  setItem(key, value) {
1350
1429
  this.storage.setItem(key, value);
@@ -1365,6 +1444,9 @@ class WebStorageService {
1365
1444
  remove(key) {
1366
1445
  this.storage.removeItem(key);
1367
1446
  }
1447
+ clear() {
1448
+ this.storage.clear();
1449
+ }
1368
1450
  }
1369
1451
  class LocalStorageService extends WebStorageService {
1370
1452
  constructor() {
@@ -1407,9 +1489,10 @@ SessionStorageService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: Se
1407
1489
  </file>
1408
1490
  */
1409
1491
  class AppContextService extends BaseApiService {
1410
- constructor(http, sessionStorage) {
1492
+ constructor(http, localStorage, sessionStorage) {
1411
1493
  super(http);
1412
1494
  this.http = http;
1495
+ this.localStorage = localStorage;
1413
1496
  this.sessionStorage = sessionStorage;
1414
1497
  //Consts
1415
1498
  this.storageKeyName = 'appContext';
@@ -1505,6 +1588,17 @@ class AppContextService extends BaseApiService {
1505
1588
  clearCurrent() {
1506
1589
  this.sessionStorage.remove(this.storageKeyName);
1507
1590
  }
1591
+ //Storage
1592
+ clearLocalStorage() {
1593
+ this.localStorage.clear();
1594
+ }
1595
+ clearSessionStorage() {
1596
+ this.sessionStorage.clear();
1597
+ }
1598
+ clearStorage() {
1599
+ this.clearLocalStorage();
1600
+ this.clearSessionStorage();
1601
+ }
1508
1602
  //Properties
1509
1603
  get current() {
1510
1604
  this.updateCurrentIfExpired();
@@ -1514,12 +1608,12 @@ class AppContextService extends BaseApiService {
1514
1608
  this.setCurrentFromSession(value);
1515
1609
  }
1516
1610
  }
1517
- AppContextService.ɵfac = function AppContextService_Factory(t) { return new (t || AppContextService)(i0.ɵɵinject(i1$3.HttpClient), i0.ɵɵinject(SessionStorageService)); };
1611
+ AppContextService.ɵfac = function AppContextService_Factory(t) { return new (t || AppContextService)(i0.ɵɵinject(i1$3.HttpClient), i0.ɵɵinject(LocalStorageService), i0.ɵɵinject(SessionStorageService)); };
1518
1612
  AppContextService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AppContextService, factory: AppContextService.ɵfac });
1519
1613
  (function () {
1520
1614
  (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AppContextService, [{
1521
1615
  type: Injectable
1522
- }], function () { return [{ type: i1$3.HttpClient }, { type: SessionStorageService }]; }, null);
1616
+ }], function () { return [{ type: i1$3.HttpClient }, { type: LocalStorageService }, { type: SessionStorageService }]; }, null);
1523
1617
  })();
1524
1618
 
1525
1619
  /*
@@ -1714,38 +1808,6 @@ GoogleAnalyticsService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: G
1714
1808
  }], function () { return [{ type: i1.Router }]; }, null);
1715
1809
  })();
1716
1810
 
1717
- /*
1718
- <file>
1719
- Project:
1720
- @osovitny/anatoly
1721
-
1722
- Authors:
1723
- Vadim Osovitny vadim@osovitny.com
1724
- Anatoly Osovitny anatoly@osovitny.com
1725
-
1726
- Created:
1727
- 10 Sep 2022
1728
-
1729
- Code:
1730
- https://www.npmjs.com/package/js-beautify
1731
- https://beautifier.io
1732
-
1733
- Copyright (c) 2016-2022 Osovitny Inc. All rights reserved.
1734
- </file>
1735
- */
1736
- class XmlFormatter {
1737
- static toPrettyXML(s, options) {
1738
- if (!options) {
1739
- options = {
1740
- indent_size: 2,
1741
- indent_char: " ",
1742
- wrap_line_length: 110
1743
- };
1744
- }
1745
- return js_beautify.html(s, options);
1746
- }
1747
- }
1748
-
1749
1811
  /*
1750
1812
  <file>
1751
1813
  Project:
@@ -5973,5 +6035,5 @@ AnatolyModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModu
5973
6035
  * Generated bundle index. Do not edit.
5974
6036
  */
5975
6037
 
5976
- export { AddressComponent, Alerts, AnatolyCoreModule, AnatolyDataModule, AnatolyHttpInterceptor, AnatolyModule, AnatolyUIModule, AppContextService, AppCoreSettings, BaseApiService, BaseComponent, BaseDialog, BaseEditComponent, BaseGoService, BaseGridEditService, BaseGridReadService, BaseHtmlEditorComponent, BaseList, BasePage, BasePagedPage, BuyAccessButtonComponent, CardBodyComponent, CardComponent, CardFooterComponent, CardHeaderComponent, CheckIconComponent, CompanyComponent, ContactUsDialog, ContactUsForm, Convert, Copy2ClipboardComponent, CoreApiService, DOM, DatapagerComponent, DefaultEditorOptions, DigitalMarketingService, EmailsApiService, FileSizePipe, FormValidationSummaryComponent, FormsHtmlEditorComponent, FroalaEditorModuleWithProviders, FroalaViewModuleWithProviders, GlobalErrorHandler, GoogleAnalyticsService, Guid, HoveringDirective, HtmlEditorComponent, IdleService, InjectorInstance, ItemValidationSummaryComponent, LoadingComponent, LoadingService, LocalStorageService, LocalizationInjectorInstance, LocalizationModule, LocalizationService, LocalizationSettingsModule, LocalizePipe, LoggingService, NativeElementDirective, NodataComponent, NotificationService, NotificationsApiService, PageSpinnerComponent, ReplaceTextPipe, SafeHtmlPipe, SessionStorageService, SignInButtonComponent, SignOutButtonComponent, SignUpButtonComponent, Subs, SubscribePlanButtonComponent, TimezoneDropdownlist, TranslateModuleAtRoot, UrlSlugComponent, Urls, Utils, ValidationSummaryComponent, XmlFormatter, customTranslateLoaderFactory, localizationInitializerFactory, throwIfAlreadyLoaded };
6038
+ export { AddressComponent, Alerts, AnatolyCoreModule, AnatolyDataModule, AnatolyHttpInterceptor, AnatolyModule, AnatolyUIModule, AppContextService, AppCoreSettings, BaseApiService, BaseComponent, BaseDialog, BaseEditComponent, BaseGoService, BaseGridEditService, BaseGridReadService, BaseHtmlEditorComponent, BaseList, BasePage, BasePagedPage, BuyAccessButtonComponent, CardBodyComponent, CardComponent, CardFooterComponent, CardHeaderComponent, CheckIconComponent, CompanyComponent, ContactUsDialog, ContactUsForm, Convert, Copy2ClipboardComponent, CoreApiService, DOM, DatapagerComponent, DefaultEditorOptions, DigitalMarketingService, EmailsApiService, FileSizePipe, FormValidationSummaryComponent, FormsHtmlEditorComponent, FroalaEditorModuleWithProviders, FroalaViewModuleWithProviders, GlobalErrorHandler, GoogleAnalyticsService, Guid, HoveringDirective, HtmlEditorComponent, IdleService, InjectorInstance, ItemValidationSummaryComponent, LoadingComponent, LoadingService, LocalStorageService, LocalizationInjectorInstance, LocalizationModule, LocalizationService, LocalizationSettingsModule, LocalizePipe, LoggingService, NativeElementDirective, NodataComponent, NotificationService, NotificationsApiService, PageSpinnerComponent, ReplaceTextPipe, SafeHtmlPipe, SessionStorageService, SignInButtonComponent, SignOutButtonComponent, SignUpButtonComponent, Stopwatch, Subs, SubscribePlanButtonComponent, TimezoneDropdownlist, TranslateModuleAtRoot, UrlSlugComponent, Urls, Utils, ValidationSummaryComponent, XmlFormatter, customTranslateLoaderFactory, localizationInitializerFactory, throwIfAlreadyLoaded };
5977
6039
  //# sourceMappingURL=osovitny-anatoly.mjs.map