@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:
@@ -333,111 +470,6 @@ AnatolyHttpInterceptor.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: A
333
470
  type: Injectable
334
471
  }], function () { return [{ type: LoadingService }, { type: LoggingService }]; }, null); })();
335
472
 
336
- /*
337
- <file>
338
- Project:
339
- @osovitny/anatoly
340
-
341
- Authors:
342
- Vadim Osovitny vadim@osovitny.com
343
- Anatoly Osovitny anatoly@osovitny.com
344
-
345
- Created:
346
- 29 June 2020
347
-
348
- Copyright (c) 2016-2022 Osovitny Inc. All rights reserved.
349
- </file>
350
- */
351
- class Convert {
352
- static pad(number) {
353
- if (number < 10) {
354
- return '0' + number;
355
- }
356
- return number;
357
- }
358
- static toLocalizedDateTime(value) {
359
- if (value) {
360
- return new Date(Date.UTC(value.getFullYear(), value.getMonth(), value.getDate(), value.getHours(), value.getMinutes(), value.getSeconds(), value.getMilliseconds()));
361
- }
362
- return null;
363
- }
364
- static enumToString(enumeration, value) {
365
- for (let k in enumeration)
366
- if (enumeration[k] == value)
367
- return k;
368
- return null;
369
- }
370
- static enumToArray(enumeration, notIncludes) {
371
- const notIncludeFiler = (value) => {
372
- if (isNaN(Number(value))) {
373
- return false;
374
- }
375
- if (notIncludes) {
376
- for (let i in notIncludes) {
377
- if (notIncludes[i] == value)
378
- return false;
379
- }
380
- }
381
- return true;
382
- };
383
- return Object.keys(enumeration)
384
- .filter(notIncludeFiler)
385
- .map(key => ({
386
- value: key,
387
- text: enumeration[key]
388
- }));
389
- }
390
- static stringToArray(str, separator = ',') {
391
- if (str) {
392
- return str.split(separator).filter(element => element);
393
- }
394
- return [];
395
- }
396
- static stringToIntArray(str, separator = ',') {
397
- if (str) {
398
- return str.split(separator).filter(element => element).map(value => parseInt(value));
399
- }
400
- return [];
401
- }
402
- static company2String(comp) {
403
- let company = JSON.parse(comp);
404
- if (company) {
405
- return `${company.name} ${company.phone} ${company.email} ${company.websiteUrl}`;
406
- }
407
- }
408
- static address2String(adr) {
409
- let address = JSON.parse(adr);
410
- return `${address.street} ${address.street2} ${address.city} ${address.stateOrRegion} ${address.zipcode} ${address.country}`;
411
- }
412
- static dateToString(date) {
413
- return date.getFullYear() +
414
- '-' + this.pad(date.getMonth() + 1) +
415
- '-' + this.pad(date.getDate()) +
416
- ' ' + this.pad(date.getHours()) +
417
- ':' + this.pad(date.getMinutes()) +
418
- ':' + this.pad(date.getSeconds());
419
- }
420
- static utcDateToLocalDate(d) {
421
- let date = new Date(d);
422
- return new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds()));
423
- }
424
- static stringToBoolean(value) {
425
- switch (value.toLowerCase().trim()) {
426
- case "true":
427
- case "yes":
428
- case "1":
429
- return true;
430
- case "false":
431
- case "no":
432
- case "0":
433
- case null:
434
- return false;
435
- default:
436
- return Boolean(value);
437
- }
438
- }
439
- }
440
-
441
473
  /*
442
474
  <file>
443
475
  Project:
@@ -1226,6 +1258,56 @@ NotificationService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: Noti
1226
1258
  args: [{ providedIn: 'root' }]
1227
1259
  }], function () { return [{ type: i1$2.ToastrService }]; }, null); })();
1228
1260
 
1261
+ /*
1262
+ <file>
1263
+ Project:
1264
+ @osovitny/anatoly
1265
+
1266
+ Authors:
1267
+ Vadim Osovitny vadim@osovitny.com
1268
+ Anatoly Osovitny anatoly@osovitny.com
1269
+
1270
+ Created:
1271
+ 17 Apr 2023
1272
+
1273
+ Copyright (c) 2016-2022 Osovitny Inc. All rights reserved.
1274
+ </file>
1275
+ */
1276
+ class Stopwatch {
1277
+ constructor(name) {
1278
+ this.name = name;
1279
+ this.startTime = 0;
1280
+ this.stopTime = 0;
1281
+ this.running = false;
1282
+ this.performance = !!window.performance;
1283
+ console.log(this.name + ' started.');
1284
+ }
1285
+ currentTime() {
1286
+ return this.performance ? window.performance.now() : new Date().getTime();
1287
+ }
1288
+ start() {
1289
+ this.startTime = this.currentTime();
1290
+ this.running = true;
1291
+ }
1292
+ stop() {
1293
+ this.stopTime = this.currentTime();
1294
+ this.running = false;
1295
+ }
1296
+ getElapsedMilliseconds() {
1297
+ if (this.running) {
1298
+ this.stopTime = this.currentTime();
1299
+ }
1300
+ return this.stopTime - this.startTime;
1301
+ }
1302
+ getElapsedSeconds() {
1303
+ return this.getElapsedMilliseconds() / 1000;
1304
+ }
1305
+ printElapsedAsMilliseconds() {
1306
+ let elapsed = this.getElapsedMilliseconds();
1307
+ console.log(`${this.name} stopped. Execution time: ${elapsed} ms`);
1308
+ }
1309
+ }
1310
+
1229
1311
  /*
1230
1312
  <file>
1231
1313
  Project:
@@ -1333,10 +1415,7 @@ BaseApiService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: BaseApiSe
1333
1415
  */
1334
1416
  class WebStorageService {
1335
1417
  constructor(storage) {
1336
- this.storage =
1337
- storage === 'local' || storage === 'localStorage'
1338
- ? localStorage
1339
- : sessionStorage;
1418
+ this.storage = storage === 'local' || storage === 'localStorage' ? localStorage : sessionStorage;
1340
1419
  }
1341
1420
  setItem(key, value) {
1342
1421
  this.storage.setItem(key, value);
@@ -1357,6 +1436,9 @@ class WebStorageService {
1357
1436
  remove(key) {
1358
1437
  this.storage.removeItem(key);
1359
1438
  }
1439
+ clear() {
1440
+ this.storage.clear();
1441
+ }
1360
1442
  }
1361
1443
  class LocalStorageService extends WebStorageService {
1362
1444
  constructor() {
@@ -1395,9 +1477,10 @@ SessionStorageService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: Se
1395
1477
  </file>
1396
1478
  */
1397
1479
  class AppContextService extends BaseApiService {
1398
- constructor(http, sessionStorage) {
1480
+ constructor(http, localStorage, sessionStorage) {
1399
1481
  super(http);
1400
1482
  this.http = http;
1483
+ this.localStorage = localStorage;
1401
1484
  this.sessionStorage = sessionStorage;
1402
1485
  //Consts
1403
1486
  this.storageKeyName = 'appContext';
@@ -1493,6 +1576,17 @@ class AppContextService extends BaseApiService {
1493
1576
  clearCurrent() {
1494
1577
  this.sessionStorage.remove(this.storageKeyName);
1495
1578
  }
1579
+ //Storage
1580
+ clearLocalStorage() {
1581
+ this.localStorage.clear();
1582
+ }
1583
+ clearSessionStorage() {
1584
+ this.sessionStorage.clear();
1585
+ }
1586
+ clearStorage() {
1587
+ this.clearLocalStorage();
1588
+ this.clearSessionStorage();
1589
+ }
1496
1590
  //Properties
1497
1591
  get current() {
1498
1592
  this.updateCurrentIfExpired();
@@ -1502,11 +1596,11 @@ class AppContextService extends BaseApiService {
1502
1596
  this.setCurrentFromSession(value);
1503
1597
  }
1504
1598
  }
1505
- AppContextService.ɵfac = function AppContextService_Factory(t) { return new (t || AppContextService)(i0.ɵɵinject(i1$3.HttpClient), i0.ɵɵinject(SessionStorageService)); };
1599
+ AppContextService.ɵfac = function AppContextService_Factory(t) { return new (t || AppContextService)(i0.ɵɵinject(i1$3.HttpClient), i0.ɵɵinject(LocalStorageService), i0.ɵɵinject(SessionStorageService)); };
1506
1600
  AppContextService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AppContextService, factory: AppContextService.ɵfac });
1507
1601
  (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AppContextService, [{
1508
1602
  type: Injectable
1509
- }], function () { return [{ type: i1$3.HttpClient }, { type: SessionStorageService }]; }, null); })();
1603
+ }], function () { return [{ type: i1$3.HttpClient }, { type: LocalStorageService }, { type: SessionStorageService }]; }, null); })();
1510
1604
 
1511
1605
  /*
1512
1606
  <file>
@@ -1692,38 +1786,6 @@ GoogleAnalyticsService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: G
1692
1786
  type: Injectable
1693
1787
  }], function () { return [{ type: i1.Router }]; }, null); })();
1694
1788
 
1695
- /*
1696
- <file>
1697
- Project:
1698
- @osovitny/anatoly
1699
-
1700
- Authors:
1701
- Vadim Osovitny vadim@osovitny.com
1702
- Anatoly Osovitny anatoly@osovitny.com
1703
-
1704
- Created:
1705
- 10 Sep 2022
1706
-
1707
- Code:
1708
- https://www.npmjs.com/package/js-beautify
1709
- https://beautifier.io
1710
-
1711
- Copyright (c) 2016-2022 Osovitny Inc. All rights reserved.
1712
- </file>
1713
- */
1714
- class XmlFormatter {
1715
- static toPrettyXML(s, options) {
1716
- if (!options) {
1717
- options = {
1718
- indent_size: 2,
1719
- indent_char: " ",
1720
- wrap_line_length: 110
1721
- };
1722
- }
1723
- return js_beautify.html(s, options);
1724
- }
1725
- }
1726
-
1727
1789
  /*
1728
1790
  <file>
1729
1791
  Project:
@@ -5667,5 +5729,5 @@ AnatolyModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModu
5667
5729
  * Generated bundle index. Do not edit.
5668
5730
  */
5669
5731
 
5670
- 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 };
5732
+ 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 };
5671
5733
  //# sourceMappingURL=osovitny-anatoly.mjs.map