@osovitny/anatoly 2.1.9 → 2.1.11
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.
- package/bundles/osovitny-anatoly.umd.js +120 -83
- package/bundles/osovitny-anatoly.umd.js.map +1 -1
- package/esm2015/lib/core/consts/settings.js +1 -4
- package/esm2015/lib/core/consts/urls.js +1 -4
- package/esm2015/lib/core/services/appcontext.service.js +59 -22
- package/esm2015/lib/core/utils.js +1 -1
- package/esm2015/lib/ui/components/billing/buyaccess-button.component.js +6 -9
- package/fesm2015/osovitny-anatoly.js +123 -96
- package/fesm2015/osovitny-anatoly.js.map +1 -1
- package/lib/core/services/appcontext.service.d.ts +12 -5
- package/lib/ui/components/billing/buyaccess-button.component.d.ts +2 -2
- package/osovitny-anatoly.metadata.json +1 -1
- package/package.json +1 -1
|
@@ -45,9 +45,6 @@
|
|
|
45
45
|
Created:
|
|
46
46
|
26 Jun 2020
|
|
47
47
|
|
|
48
|
-
Version:
|
|
49
|
-
1.0
|
|
50
|
-
|
|
51
48
|
Copyright (c) 2016-2021 Osovitny Inc. All rights reserved.
|
|
52
49
|
</file>
|
|
53
50
|
*/
|
|
@@ -65,9 +62,6 @@
|
|
|
65
62
|
Created:
|
|
66
63
|
5 May 2020
|
|
67
64
|
|
|
68
|
-
Version:
|
|
69
|
-
1.0
|
|
70
|
-
|
|
71
65
|
Copyright (c) 2020 Deloitte Tax. All rights reserved.
|
|
72
66
|
</file>
|
|
73
67
|
*/
|
|
@@ -1592,44 +1586,127 @@
|
|
|
1592
1586
|
{ type: i1.HttpClient }
|
|
1593
1587
|
]; };
|
|
1594
1588
|
|
|
1589
|
+
var WebStorageService = /** @class */ (function () {
|
|
1590
|
+
function WebStorageService(storage) {
|
|
1591
|
+
this.storage =
|
|
1592
|
+
storage === 'local' || storage === 'localStorage'
|
|
1593
|
+
? localStorage
|
|
1594
|
+
: sessionStorage;
|
|
1595
|
+
}
|
|
1596
|
+
WebStorageService.prototype.setItem = function (key, value) {
|
|
1597
|
+
this.storage.setItem(key, value);
|
|
1598
|
+
};
|
|
1599
|
+
WebStorageService.prototype.setObject = function (key, value) {
|
|
1600
|
+
this.storage.setItem(key, JSON.stringify(value));
|
|
1601
|
+
};
|
|
1602
|
+
WebStorageService.prototype.getItem = function (key) {
|
|
1603
|
+
return this.storage.getItem(key);
|
|
1604
|
+
};
|
|
1605
|
+
WebStorageService.prototype.getObject = function (key) {
|
|
1606
|
+
var value = this.storage.getItem(key);
|
|
1607
|
+
if (!value) {
|
|
1608
|
+
return null;
|
|
1609
|
+
}
|
|
1610
|
+
return JSON.parse(value);
|
|
1611
|
+
};
|
|
1612
|
+
WebStorageService.prototype.remove = function (key) {
|
|
1613
|
+
this.storage.removeItem(key);
|
|
1614
|
+
};
|
|
1615
|
+
return WebStorageService;
|
|
1616
|
+
}());
|
|
1617
|
+
var LocalStorageService = /** @class */ (function (_super) {
|
|
1618
|
+
__extends(LocalStorageService, _super);
|
|
1619
|
+
function LocalStorageService() {
|
|
1620
|
+
return _super.call(this, 'localStorage') || this;
|
|
1621
|
+
}
|
|
1622
|
+
return LocalStorageService;
|
|
1623
|
+
}(WebStorageService));
|
|
1624
|
+
LocalStorageService.decorators = [
|
|
1625
|
+
{ type: i0.Injectable }
|
|
1626
|
+
];
|
|
1627
|
+
LocalStorageService.ctorParameters = function () { return []; };
|
|
1628
|
+
var SessionStorageService = /** @class */ (function (_super) {
|
|
1629
|
+
__extends(SessionStorageService, _super);
|
|
1630
|
+
function SessionStorageService() {
|
|
1631
|
+
return _super.call(this, 'sessionStorage') || this;
|
|
1632
|
+
}
|
|
1633
|
+
return SessionStorageService;
|
|
1634
|
+
}(WebStorageService));
|
|
1635
|
+
SessionStorageService.decorators = [
|
|
1636
|
+
{ type: i0.Injectable }
|
|
1637
|
+
];
|
|
1638
|
+
SessionStorageService.ctorParameters = function () { return []; };
|
|
1639
|
+
|
|
1595
1640
|
var AppContextService = /** @class */ (function (_super) {
|
|
1596
1641
|
__extends(AppContextService, _super);
|
|
1597
|
-
function AppContextService(http) {
|
|
1642
|
+
function AppContextService(http, sessionStorage) {
|
|
1598
1643
|
var _this = _super.call(this, http) || this;
|
|
1599
1644
|
_this.http = http;
|
|
1600
|
-
_this.
|
|
1601
|
-
|
|
1645
|
+
_this.sessionStorage = sessionStorage;
|
|
1646
|
+
//Consts
|
|
1647
|
+
_this.storageKeyName = 'appContext';
|
|
1602
1648
|
_this.subscription = null;
|
|
1649
|
+
_this.successes = [];
|
|
1603
1650
|
_this.baseUrl = '/api/appContext';
|
|
1604
1651
|
return _this;
|
|
1605
1652
|
}
|
|
1606
|
-
AppContextService.prototype.
|
|
1607
|
-
var
|
|
1608
|
-
if (
|
|
1653
|
+
AppContextService.prototype.updateCurrentIfExpired = function () {
|
|
1654
|
+
var context = this.sessionStorage.getObject(this.storageKeyName);
|
|
1655
|
+
if (!context) {
|
|
1609
1656
|
return;
|
|
1610
1657
|
}
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1658
|
+
var lu = context.lastRequested;
|
|
1659
|
+
if (lu) {
|
|
1660
|
+
var now = new Date();
|
|
1661
|
+
var lastRequested = new Date(context.lastRequested);
|
|
1662
|
+
var in2Mins = new Date(lastRequested.getFullYear(), lastRequested.getMonth(), lastRequested.getDate(), lastRequested.getHours(), lastRequested.getMinutes() + 2, 0, 0);
|
|
1663
|
+
if (in2Mins.getTime() < now.getTime()) {
|
|
1664
|
+
this.updateCurrent();
|
|
1665
|
+
}
|
|
1618
1666
|
}
|
|
1619
|
-
this.subscription = this.get('getCurrentContext', null).subscribe(function (data) {
|
|
1620
|
-
_this.dataReceived(data);
|
|
1621
|
-
}, function (e) { });
|
|
1622
1667
|
};
|
|
1623
1668
|
AppContextService.prototype.dataReceived = function (data) {
|
|
1624
1669
|
this.current = data;
|
|
1625
1670
|
for (var i = 0; i < this.successes.length; i++) {
|
|
1626
1671
|
var success = this.successes[i];
|
|
1627
|
-
success
|
|
1672
|
+
if (success) {
|
|
1673
|
+
success(data);
|
|
1674
|
+
}
|
|
1628
1675
|
}
|
|
1629
1676
|
this.successes = [];
|
|
1630
1677
|
this.subscription.unsubscribe();
|
|
1631
1678
|
this.subscription = null;
|
|
1632
|
-
|
|
1679
|
+
};
|
|
1680
|
+
AppContextService.prototype.getCurrent = function (success, getCachedIfExist) {
|
|
1681
|
+
var _this = this;
|
|
1682
|
+
if (success === void 0) { success = null; }
|
|
1683
|
+
if (getCachedIfExist === void 0) { getCachedIfExist = true; }
|
|
1684
|
+
var current = this.current;
|
|
1685
|
+
if (getCachedIfExist && current != null) {
|
|
1686
|
+
if (success) {
|
|
1687
|
+
success(current);
|
|
1688
|
+
}
|
|
1689
|
+
return;
|
|
1690
|
+
}
|
|
1691
|
+
if (success) {
|
|
1692
|
+
this.successes.push(success);
|
|
1693
|
+
}
|
|
1694
|
+
if (this.subscription != null) {
|
|
1695
|
+
return;
|
|
1696
|
+
}
|
|
1697
|
+
var now = new Date();
|
|
1698
|
+
console.log('Requesting a new AppContext at ' + now);
|
|
1699
|
+
this.subscription = this.get('getCurrentContext', null).subscribe(function (data) {
|
|
1700
|
+
_this.dataReceived(data);
|
|
1701
|
+
}, function (e) {
|
|
1702
|
+
});
|
|
1703
|
+
};
|
|
1704
|
+
AppContextService.prototype.updateCurrent = function (success) {
|
|
1705
|
+
if (success === void 0) { success = null; }
|
|
1706
|
+
this.getCurrent(success, false);
|
|
1707
|
+
};
|
|
1708
|
+
AppContextService.prototype.clearCurrent = function () {
|
|
1709
|
+
this.sessionStorage.remove(this.storageKeyName);
|
|
1633
1710
|
};
|
|
1634
1711
|
AppContextService.prototype.isUserSignedIn = function () {
|
|
1635
1712
|
return ContextInitState.isUserSignedIn;
|
|
@@ -1637,13 +1714,27 @@
|
|
|
1637
1714
|
AppContextService.prototype.isUserAdmin = function () {
|
|
1638
1715
|
return ContextInitState.isUserAdmin;
|
|
1639
1716
|
};
|
|
1717
|
+
Object.defineProperty(AppContextService.prototype, "current", {
|
|
1718
|
+
//Properties
|
|
1719
|
+
//current
|
|
1720
|
+
get: function () {
|
|
1721
|
+
this.updateCurrentIfExpired();
|
|
1722
|
+
return this.sessionStorage.getObject(this.storageKeyName);
|
|
1723
|
+
},
|
|
1724
|
+
set: function (value) {
|
|
1725
|
+
this.sessionStorage.setObject(this.storageKeyName, value);
|
|
1726
|
+
},
|
|
1727
|
+
enumerable: false,
|
|
1728
|
+
configurable: true
|
|
1729
|
+
});
|
|
1640
1730
|
return AppContextService;
|
|
1641
1731
|
}(BaseApiService));
|
|
1642
1732
|
AppContextService.decorators = [
|
|
1643
1733
|
{ type: i0.Injectable }
|
|
1644
1734
|
];
|
|
1645
1735
|
AppContextService.ctorParameters = function () { return [
|
|
1646
|
-
{ type: i1.HttpClient }
|
|
1736
|
+
{ type: i1.HttpClient },
|
|
1737
|
+
{ type: SessionStorageService }
|
|
1647
1738
|
]; };
|
|
1648
1739
|
|
|
1649
1740
|
/*
|
|
@@ -1718,57 +1809,6 @@
|
|
|
1718
1809
|
},] }
|
|
1719
1810
|
];
|
|
1720
1811
|
|
|
1721
|
-
var WebStorageService = /** @class */ (function () {
|
|
1722
|
-
function WebStorageService(storage) {
|
|
1723
|
-
this.storage =
|
|
1724
|
-
storage === 'local' || storage === 'localStorage'
|
|
1725
|
-
? localStorage
|
|
1726
|
-
: sessionStorage;
|
|
1727
|
-
}
|
|
1728
|
-
WebStorageService.prototype.setItem = function (key, value) {
|
|
1729
|
-
this.storage.setItem(key, value);
|
|
1730
|
-
};
|
|
1731
|
-
WebStorageService.prototype.setObject = function (key, value) {
|
|
1732
|
-
this.storage.setItem(key, JSON.stringify(value));
|
|
1733
|
-
};
|
|
1734
|
-
WebStorageService.prototype.getItem = function (key) {
|
|
1735
|
-
return this.storage.getItem(key);
|
|
1736
|
-
};
|
|
1737
|
-
WebStorageService.prototype.getObject = function (key) {
|
|
1738
|
-
var value = this.storage.getItem(key);
|
|
1739
|
-
if (!value) {
|
|
1740
|
-
return null;
|
|
1741
|
-
}
|
|
1742
|
-
return JSON.parse(value);
|
|
1743
|
-
};
|
|
1744
|
-
WebStorageService.prototype.remove = function (key) {
|
|
1745
|
-
this.storage.removeItem(key);
|
|
1746
|
-
};
|
|
1747
|
-
return WebStorageService;
|
|
1748
|
-
}());
|
|
1749
|
-
var LocalStorageService = /** @class */ (function (_super) {
|
|
1750
|
-
__extends(LocalStorageService, _super);
|
|
1751
|
-
function LocalStorageService() {
|
|
1752
|
-
return _super.call(this, 'localStorage') || this;
|
|
1753
|
-
}
|
|
1754
|
-
return LocalStorageService;
|
|
1755
|
-
}(WebStorageService));
|
|
1756
|
-
LocalStorageService.decorators = [
|
|
1757
|
-
{ type: i0.Injectable }
|
|
1758
|
-
];
|
|
1759
|
-
LocalStorageService.ctorParameters = function () { return []; };
|
|
1760
|
-
var SessionStorageService = /** @class */ (function (_super) {
|
|
1761
|
-
__extends(SessionStorageService, _super);
|
|
1762
|
-
function SessionStorageService() {
|
|
1763
|
-
return _super.call(this, 'sessionStorage') || this;
|
|
1764
|
-
}
|
|
1765
|
-
return SessionStorageService;
|
|
1766
|
-
}(WebStorageService));
|
|
1767
|
-
SessionStorageService.decorators = [
|
|
1768
|
-
{ type: i0.Injectable }
|
|
1769
|
-
];
|
|
1770
|
-
SessionStorageService.ctorParameters = function () { return []; };
|
|
1771
|
-
|
|
1772
1812
|
/*
|
|
1773
1813
|
<file>
|
|
1774
1814
|
Project:
|
|
@@ -2498,15 +2538,12 @@
|
|
|
2498
2538
|
Created:
|
|
2499
2539
|
14 Aug 2018
|
|
2500
2540
|
|
|
2501
|
-
Version:
|
|
2502
|
-
1.0
|
|
2503
|
-
|
|
2504
2541
|
Copyright (c) 2016-2021 Osovitny Inc. All rights reserved.
|
|
2505
2542
|
</file>
|
|
2506
2543
|
*/
|
|
2507
2544
|
var BuyAccessButtonComponent = /** @class */ (function () {
|
|
2508
|
-
function BuyAccessButtonComponent(
|
|
2509
|
-
this.
|
|
2545
|
+
function BuyAccessButtonComponent(appContext, api) {
|
|
2546
|
+
this.appContext = appContext;
|
|
2510
2547
|
this.api = api;
|
|
2511
2548
|
this.contextUpdated = false;
|
|
2512
2549
|
this.isUserSignedIn = false;
|
|
@@ -2515,11 +2552,11 @@
|
|
|
2515
2552
|
}
|
|
2516
2553
|
BuyAccessButtonComponent.prototype.ngOnInit = function () {
|
|
2517
2554
|
var _this = this;
|
|
2518
|
-
if (!this.
|
|
2555
|
+
if (!this.appContext.isUserSignedIn()) {
|
|
2519
2556
|
this.contextUpdated = true;
|
|
2520
2557
|
return;
|
|
2521
2558
|
}
|
|
2522
|
-
this.
|
|
2559
|
+
this.appContext.getCurrent(function (current) {
|
|
2523
2560
|
_this.isUserSignedIn = current.isUserSignedIn;
|
|
2524
2561
|
if (_this.isUserSignedIn) {
|
|
2525
2562
|
_this.currentPlan = current.account.billingPlan;
|