@osovitny/anatoly 3.16.105 → 3.16.107

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.
@@ -1613,6 +1613,103 @@ class Subs {
1613
1613
  }
1614
1614
  }
1615
1615
 
1616
+ /*
1617
+ <file>
1618
+ Project:
1619
+ @osovitny/anatoly
1620
+
1621
+ Authors:
1622
+ Vadim Osovitny vadim@osovitny.com
1623
+ Anatoly Osovitny anatoly@osovitny.com
1624
+
1625
+ Created:
1626
+ 19 March 2020
1627
+
1628
+ Copyright (c) 2016-2022 Osovitny Inc. All rights reserved.
1629
+ </file>
1630
+ */
1631
+ class Utils {
1632
+ static idExistsInQS() {
1633
+ let id = Utils.getValueByNameInQS("id");
1634
+ if (id)
1635
+ return true;
1636
+ return false;
1637
+ }
1638
+ static getValueByNameInQS(name) {
1639
+ return Utils.getValueByName(location.search, name);
1640
+ }
1641
+ static getValueByName(url, name) {
1642
+ name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
1643
+ // tslint:disable-next-line:one-variable-per-declaration
1644
+ const regex = new RegExp('[\\?&]' + name + '=([^&#]*)'), results = regex.exec(url);
1645
+ return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
1646
+ }
1647
+ static copyToClipBoard(event, val) {
1648
+ event.preventDefault();
1649
+ const selBox = document.createElement('textarea');
1650
+ selBox.style.position = 'fixed';
1651
+ selBox.style.left = '0';
1652
+ selBox.style.top = '0';
1653
+ selBox.style.opacity = '0';
1654
+ selBox.value = val;
1655
+ document.body.appendChild(selBox);
1656
+ selBox.focus();
1657
+ selBox.select();
1658
+ document.execCommand('copy');
1659
+ document.body.removeChild(selBox);
1660
+ }
1661
+ static downloadFile(name, url) {
1662
+ const link = document.createElement('a');
1663
+ link.download = name;
1664
+ link.href = url;
1665
+ link.click();
1666
+ }
1667
+ static downloadBlobFile(value, fileName) {
1668
+ const nav = window.navigator;
1669
+ if (nav.msSaveOrOpenBlob) {
1670
+ nav.msSaveOrOpenBlob(value, fileName);
1671
+ }
1672
+ else {
1673
+ const downloadURL = window.URL.createObjectURL(value);
1674
+ Utils.downloadFile(fileName, downloadURL);
1675
+ }
1676
+ }
1677
+ /*
1678
+ Author:
1679
+ https://medium.com/@mhagemann/the-ultimate-way-to-slugify-a-url-string-in-javascript-b8e4a0d849e1
1680
+ */
1681
+ static slugify(text, prefix = '', postfix = '') {
1682
+ const a = 'àáâäæãåāăąçćčđďèéêëēėęěğǵḧîïíīįìłḿñńǹňôöòóœøōõőṕŕřßśšşșťțûüùúūǘůűųẃẍÿýžźż·/_,:;';
1683
+ const b = 'aaaaaaaaaacccddeeeeeeeegghiiiiiilmnnnnoooooooooprrsssssttuuuuuuuuuwxyyzzz------';
1684
+ const p = new RegExp(a.split('').join('|'), 'g');
1685
+ /*
1686
+ https://css-tricks.com/snippets/javascript/strip-html-tags-in-javascript/
1687
+ https://stackoverflow.com/questions/822452/strip-html-from-text-javascript
1688
+ */
1689
+ text = text.replace(/(<([^>]+)>)/gi, '');
1690
+ let result = text
1691
+ .toString()
1692
+ .toLowerCase()
1693
+ .replace(/\s+/g, '-') // Replace spaces with -
1694
+ .replace(p, c => b.charAt(a.indexOf(c))) // Replace special characters
1695
+ .replace(/&/g, '-and-') // Replace & with 'and'
1696
+ .replace(/[^\w\-]+/g, '') // Remove all non-word characters
1697
+ .replace(/\-\-+/g, '-') // Replace multiple - with single -
1698
+ .replace(/^-+/, '') // Trim - from start of text
1699
+ .replace(/-+$/, ''); // Trim - from end of text
1700
+ return prefix + result + postfix;
1701
+ }
1702
+ static generateRandom(start, end) {
1703
+ return Math.floor(Math.random() * (end - start + 1)) + start;
1704
+ }
1705
+ static isObjectNullOrEmpty(obj) {
1706
+ return !obj || Object.keys(obj).length == 0;
1707
+ }
1708
+ static isString(value) {
1709
+ return typeof value === 'string' || value instanceof String;
1710
+ }
1711
+ }
1712
+
1616
1713
  /*
1617
1714
  <file>
1618
1715
  Project:
@@ -1727,7 +1824,9 @@ class LocalizationService {
1727
1824
  }
1728
1825
  //UTC Operations --------------------------------------------------------------
1729
1826
  getUTCToLocalizedDate(key) {
1730
- let browserTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
1827
+ if (!Utils.isString(key)) {
1828
+ key = key.toString();
1829
+ }
1731
1830
  if (key) {
1732
1831
  if (key.indexOf("T") == -1) {
1733
1832
  key = key.replace(" ", "T");
@@ -1736,6 +1835,7 @@ class LocalizationService {
1736
1835
  key = key + "Z";
1737
1836
  }
1738
1837
  }
1838
+ let browserTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
1739
1839
  if (browserTimeZone) {
1740
1840
  let localDateTime = utcToZonedTime(key, browserTimeZone);
1741
1841
  return format(localDateTime, 'dd.MM.yyyy', this.dateFnsLocale);
@@ -1745,7 +1845,9 @@ class LocalizationService {
1745
1845
  }
1746
1846
  }
1747
1847
  getUTCToLocalizedDateTime(key) {
1748
- let browserTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
1848
+ if (!Utils.isString(key)) {
1849
+ key = key.toString();
1850
+ }
1749
1851
  if (key) {
1750
1852
  if (key.indexOf("T") == -1) {
1751
1853
  key = key.replace(" ", "T");
@@ -1754,6 +1856,7 @@ class LocalizationService {
1754
1856
  key = key + "Z";
1755
1857
  }
1756
1858
  }
1859
+ let browserTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
1757
1860
  if (browserTimeZone) {
1758
1861
  let localDateTime = utcToZonedTime(key, browserTimeZone);
1759
1862
  return format(localDateTime, 'dd.MM.yyyy HH:mm', this.dateFnsLocale);
@@ -1858,15 +1961,15 @@ class LocalizePipe {
1858
1961
  }
1859
1962
  //UTC Operations --------------------------------------------------------------
1860
1963
  //UTC Date
1861
- if (type === 'u2d') {
1964
+ if (type === 'utcd') {
1862
1965
  return this.localizeService.getUTCToLocalizedDate(inputData);
1863
1966
  }
1864
1967
  //UTC DateTime
1865
- if (type === 'u2dt') {
1968
+ if (type === 'utcdt') {
1866
1969
  return this.localizeService.getUTCToLocalizedDateTime(inputData);
1867
1970
  }
1868
1971
  //UTC DistanceToNowInWords
1869
- if (type === 'u2dis2now') {
1972
+ if (type === 'utcdis2now') {
1870
1973
  return this.localizeService.getUTCToLocalizedDistanceToNowInWords(inputData);
1871
1974
  }
1872
1975
  return inputData;
@@ -2122,13 +2225,13 @@ class L10nUtils {
2122
2225
  //Node
2123
2226
  class Alerts {
2124
2227
  static success(text, params, title, successAction) {
2125
- text = L10nUtils.getLocalizedValue(text, params, 'Alerts.OperationSuccessFull');
2126
- title = L10nUtils.getLocalizedValue(title, null, 'Alerts.Success');
2228
+ text = L10nUtils.getLocalizedValue(text, params, 'Notifications.OperationSuccessFull');
2229
+ title = L10nUtils.getLocalizedValue(title, null, 'Notifications.Success');
2127
2230
  Swal.fire({
2128
2231
  text,
2129
2232
  title,
2130
2233
  icon: 'success',
2131
- confirmButtonText: L10nUtils.getLocalizedValue('Alerts.Ok')
2234
+ confirmButtonText: L10nUtils.getLocalizedValue('Notifications.Ok')
2132
2235
  })
2133
2236
  .then(() => {
2134
2237
  if (successAction) {
@@ -2138,37 +2241,37 @@ class Alerts {
2138
2241
  }
2139
2242
  static info(text, params, title) {
2140
2243
  text = L10nUtils.getLocalizedValue(text, params);
2141
- title = L10nUtils.getLocalizedValue(title, null, 'Alerts.Info');
2244
+ title = L10nUtils.getLocalizedValue(title, null, 'Notifications.Info');
2142
2245
  Swal.fire({
2143
2246
  text,
2144
2247
  title,
2145
2248
  icon: 'info',
2146
- confirmButtonText: L10nUtils.getLocalizedValue('Alerts.Ok')
2249
+ confirmButtonText: L10nUtils.getLocalizedValue('Notifications.Ok')
2147
2250
  });
2148
2251
  }
2149
2252
  static warning(text, params, title) {
2150
2253
  text = L10nUtils.getLocalizedValue(text, params);
2151
- title = L10nUtils.getLocalizedValue(title, null, 'Alerts.Warning');
2254
+ title = L10nUtils.getLocalizedValue(title, null, 'Notifications.Warning');
2152
2255
  Swal.fire({
2153
2256
  text,
2154
2257
  title,
2155
2258
  icon: 'warning',
2156
- confirmButtonText: L10nUtils.getLocalizedValue('Alerts.Ok')
2259
+ confirmButtonText: L10nUtils.getLocalizedValue('Notifications.Ok')
2157
2260
  });
2158
2261
  }
2159
2262
  static error(text, params, title) {
2160
- text = L10nUtils.getLocalizedValue(text, params, 'Alerts.ErrorOccured');
2161
- title = L10nUtils.getLocalizedValue(title, null, 'Alerts.Error');
2263
+ text = L10nUtils.getLocalizedValue(text, params, 'Notifications.ErrorOccured');
2264
+ title = L10nUtils.getLocalizedValue(title, null, 'Notifications.Error');
2162
2265
  Swal.fire({
2163
2266
  text,
2164
2267
  title,
2165
2268
  icon: 'error',
2166
- confirmButtonText: L10nUtils.getLocalizedValue('Alerts.Ok')
2269
+ confirmButtonText: L10nUtils.getLocalizedValue('Notifications.Ok')
2167
2270
  });
2168
2271
  }
2169
2272
  static cancel(text, params, title) {
2170
- text = L10nUtils.getLocalizedValue(text, params, 'Alerts.OperationCancelled');
2171
- title = L10nUtils.getLocalizedValue(title, null, 'Alerts.Cancelled');
2273
+ text = L10nUtils.getLocalizedValue(text, params, 'Notifications.OperationCancelled');
2274
+ title = L10nUtils.getLocalizedValue(title, null, 'Notifications.Cancelled');
2172
2275
  Swal.fire({
2173
2276
  text,
2174
2277
  title,
@@ -2176,15 +2279,15 @@ class Alerts {
2176
2279
  });
2177
2280
  }
2178
2281
  static notImplemented() {
2179
- let text = L10nUtils.getLocalizedValue('Alerts.NotImplemented');
2282
+ let text = L10nUtils.getLocalizedValue('Notifications.NotImplemented');
2180
2283
  this.warning(text);
2181
2284
  }
2182
2285
  ;
2183
2286
  static areYouSure(text, title, confirmButtonText, cancelButtonText, successAction, cancelAction) {
2184
2287
  text = L10nUtils.getLocalizedValue(text);
2185
- title = L10nUtils.getLocalizedValue(title, null, 'Alerts.AreYouSure');
2186
- confirmButtonText = L10nUtils.getLocalizedValue(confirmButtonText, null, 'Alerts.AreYouSure-ConfirmButtonText');
2187
- cancelButtonText = L10nUtils.getLocalizedValue(cancelButtonText, null, 'Alerts.AreYouSure-CancelButtonText');
2288
+ title = L10nUtils.getLocalizedValue(title, null, 'Notifications.AreYouSure');
2289
+ confirmButtonText = L10nUtils.getLocalizedValue(confirmButtonText, null, 'Notifications.AreYouSure-ConfirmButtonText');
2290
+ cancelButtonText = L10nUtils.getLocalizedValue(cancelButtonText, null, 'Notifications.AreYouSure-CancelButtonText');
2188
2291
  Swal.fire({
2189
2292
  text,
2190
2293
  title,
@@ -2249,7 +2352,7 @@ class NotificationService {
2249
2352
  }
2250
2353
  //Public
2251
2354
  success(text, params, title, createSessionNotification = true) {
2252
- text = L10nUtils.getLocalizedValue(text, params, 'OperationSuccessFull');
2355
+ text = L10nUtils.getLocalizedValue(text, params, 'Notifications.OperationSuccessFull');
2253
2356
  title = L10nUtils.getLocalizedValue(title);
2254
2357
  this.toastrService.success(text, title, {
2255
2358
  timeOut: 3000,
@@ -2273,7 +2376,7 @@ class NotificationService {
2273
2376
  });
2274
2377
  }
2275
2378
  error(text, params, title, createSessionNotification = true) {
2276
- text = L10nUtils.getLocalizedValue(text, params, 'ErrorOccured');
2379
+ text = L10nUtils.getLocalizedValue(text, params, 'Notifications.ErrorOccured');
2277
2380
  title = L10nUtils.getLocalizedValue(title);
2278
2381
  this.toastrService.error(text, title, {
2279
2382
  timeOut: 3000,
@@ -2281,7 +2384,7 @@ class NotificationService {
2281
2384
  });
2282
2385
  }
2283
2386
  cancel(text, params, title) {
2284
- text = L10nUtils.getLocalizedValue(text, params, 'OperationCancelled');
2387
+ text = L10nUtils.getLocalizedValue(text, params, 'Notifications.OperationCancelled');
2285
2388
  title = L10nUtils.getLocalizedValue(title);
2286
2389
  this.toastrService.info(text, title, {
2287
2390
  timeOut: 3000,
@@ -2548,100 +2651,6 @@ class IdleService {
2548
2651
  }]
2549
2652
  }], null, null); })();
2550
2653
 
2551
- /*
2552
- <file>
2553
- Project:
2554
- @osovitny/anatoly
2555
-
2556
- Authors:
2557
- Vadim Osovitny vadim@osovitny.com
2558
- Anatoly Osovitny anatoly@osovitny.com
2559
-
2560
- Created:
2561
- 19 March 2020
2562
-
2563
- Copyright (c) 2016-2022 Osovitny Inc. All rights reserved.
2564
- </file>
2565
- */
2566
- class Utils {
2567
- static idExistsInQS() {
2568
- let id = Utils.getValueByNameInQS("id");
2569
- if (id)
2570
- return true;
2571
- return false;
2572
- }
2573
- static getValueByNameInQS(name) {
2574
- return Utils.getValueByName(location.search, name);
2575
- }
2576
- static getValueByName(url, name) {
2577
- name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
2578
- // tslint:disable-next-line:one-variable-per-declaration
2579
- const regex = new RegExp('[\\?&]' + name + '=([^&#]*)'), results = regex.exec(url);
2580
- return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
2581
- }
2582
- static copyToClipBoard(event, val) {
2583
- event.preventDefault();
2584
- const selBox = document.createElement('textarea');
2585
- selBox.style.position = 'fixed';
2586
- selBox.style.left = '0';
2587
- selBox.style.top = '0';
2588
- selBox.style.opacity = '0';
2589
- selBox.value = val;
2590
- document.body.appendChild(selBox);
2591
- selBox.focus();
2592
- selBox.select();
2593
- document.execCommand('copy');
2594
- document.body.removeChild(selBox);
2595
- }
2596
- static downloadFile(name, url) {
2597
- const link = document.createElement('a');
2598
- link.download = name;
2599
- link.href = url;
2600
- link.click();
2601
- }
2602
- static downloadBlobFile(value, fileName) {
2603
- const nav = window.navigator;
2604
- if (nav.msSaveOrOpenBlob) {
2605
- nav.msSaveOrOpenBlob(value, fileName);
2606
- }
2607
- else {
2608
- const downloadURL = window.URL.createObjectURL(value);
2609
- Utils.downloadFile(fileName, downloadURL);
2610
- }
2611
- }
2612
- /*
2613
- Author:
2614
- https://medium.com/@mhagemann/the-ultimate-way-to-slugify-a-url-string-in-javascript-b8e4a0d849e1
2615
- */
2616
- static slugify(text, prefix = '', postfix = '') {
2617
- const a = 'àáâäæãåāăąçćčđďèéêëēėęěğǵḧîïíīįìłḿñńǹňôöòóœøōõőṕŕřßśšşșťțûüùúūǘůűųẃẍÿýžźż·/_,:;';
2618
- const b = 'aaaaaaaaaacccddeeeeeeeegghiiiiiilmnnnnoooooooooprrsssssttuuuuuuuuuwxyyzzz------';
2619
- const p = new RegExp(a.split('').join('|'), 'g');
2620
- /*
2621
- https://css-tricks.com/snippets/javascript/strip-html-tags-in-javascript/
2622
- https://stackoverflow.com/questions/822452/strip-html-from-text-javascript
2623
- */
2624
- text = text.replace(/(<([^>]+)>)/gi, '');
2625
- let result = text
2626
- .toString()
2627
- .toLowerCase()
2628
- .replace(/\s+/g, '-') // Replace spaces with -
2629
- .replace(p, c => b.charAt(a.indexOf(c))) // Replace special characters
2630
- .replace(/&/g, '-and-') // Replace & with 'and'
2631
- .replace(/[^\w\-]+/g, '') // Remove all non-word characters
2632
- .replace(/\-\-+/g, '-') // Replace multiple - with single -
2633
- .replace(/^-+/, '') // Trim - from start of text
2634
- .replace(/-+$/, ''); // Trim - from end of text
2635
- return prefix + result + postfix;
2636
- }
2637
- static generateRandom(start, end) {
2638
- return Math.floor(Math.random() * (end - start + 1)) + start;
2639
- }
2640
- static isObjectNullOrEmpty(obj) {
2641
- return !obj || Object.keys(obj).length == 0;
2642
- }
2643
- }
2644
-
2645
2654
  /*
2646
2655
  <file>
2647
2656
  Project: