info-library 2.10.59 → 2.10.61

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.
@@ -1529,7 +1529,7 @@
1529
1529
  this._modal = _modal;
1530
1530
  this._key = 'token';
1531
1531
  this._keySessao = 'sessao';
1532
- this._sessionTime = null;
1532
+ this._sessionActive = true;
1533
1533
  }
1534
1534
  /**
1535
1535
  * @return {?}
@@ -1550,13 +1550,17 @@
1550
1550
  */
1551
1551
  InfoAuthenticationService.prototype.canActivate = function (activatedRouteSnapshot, routerStateSnapshot) {
1552
1552
  var _this = this;
1553
- if (!this.isLogged()) {
1553
+ if (!this.isLogged() || !this._sessionActive) {
1554
1554
  this.logout();
1555
1555
  return true;
1556
1556
  }
1557
1557
  /** @type {?} */
1558
1558
  var url = activatedRouteSnapshot.data['URL'] || routerStateSnapshot.url;
1559
- this.refreshSessionTime();
1559
+ setTimeout(( /**
1560
+ * @return {?}
1561
+ */function () {
1562
+ _this.refreshSessionTime();
1563
+ }), 1000);
1560
1564
  this.definePaginaAtiva(url);
1561
1565
  return this.getPermission(url, true)
1562
1566
  .pipe(operators.map(( /**
@@ -1618,51 +1622,57 @@
1618
1622
  */
1619
1623
  InfoAuthenticationService.prototype.refreshSessionTime = function () {
1620
1624
  var _this = this;
1625
+ if (!this._sessionActive)
1626
+ return;
1621
1627
  clearInterval(this._sessionTimeInterval);
1622
- if (this._sessao.TempoInatividade <= 0) {
1623
- this._sessionTime = null;
1624
- }
1625
- else {
1626
- this._sessionTime = this._sessao.TempoInatividade;
1627
- if (this._sessao.TempoInatividade <= 0) {
1628
- this._sessionTime = null;
1628
+ if (this._sessao.TempoInatividade == null || this._sessao.TempoInatividade <= 0)
1629
+ return;
1630
+ /** @type {?} */
1631
+ var tempoSessao = this._sessao.TempoInatividade;
1632
+ localStorage.setItem('ms', new Date().valueOf().toString());
1633
+ this._sessionTimeInterval = setInterval(( /**
1634
+ * @return {?}
1635
+ */function () {
1636
+ if (tempoSessao > 0) {
1637
+ tempoSessao--;
1629
1638
  return;
1630
1639
  }
1631
- this._sessionTimeInterval = setInterval(( /**
1632
- * @return {?}
1633
- */function () {
1634
- if (_this._sessionTime == null) {
1635
- _this._sessionTime = _this._sessao.TempoInatividade;
1636
- if (_this._sessionTime == null || _this._sessionTime <= 0) {
1637
- _this.refreshSessionTime();
1638
- return;
1639
- }
1640
- }
1641
- if (_this._sessionTime > 0)
1642
- _this._sessionTime--;
1643
- else {
1644
- clearInterval(_this._sessionTimeInterval);
1645
- /** @type {?} */
1646
- var ref = _this._modal.open(RefreshSessionTimeModalComponent, {
1647
- data: null,
1648
- disableClose: true,
1649
- width: '400px'
1650
- });
1651
- ref.afterClosed().subscribe(( /**
1652
- * @param {?} r
1653
- * @return {?}
1654
- */function (r) {
1655
- clearInterval(_this._sessionTimeInterval);
1656
- if (r == null)
1657
- _this.logout();
1658
- else if (r.modalAction == InfoModalAction.Yes)
1659
- _this.refreshSessionTime();
1660
- else
1661
- _this.logout();
1662
- }));
1663
- }
1664
- }), 1000);
1665
- }
1640
+ /** @type {?} */
1641
+ var tempoRestante = Math.round(_this._sessao.TempoInatividade - ((new Date().valueOf() - parseInt(localStorage.getItem('ms'))) / 1000));
1642
+ if (!isNaN(tempoRestante) && tempoRestante > 0) {
1643
+ tempoSessao = tempoRestante;
1644
+ return;
1645
+ }
1646
+ clearInterval(_this._sessionTimeInterval);
1647
+ _this._sessionActive = false;
1648
+ if (isNaN(tempoRestante))
1649
+ _this.logout();
1650
+ else
1651
+ _this.showMessage();
1652
+ }), 1000);
1653
+ };
1654
+ /**
1655
+ * @return {?}
1656
+ */
1657
+ InfoAuthenticationService.prototype.showMessage = function () {
1658
+ var _this = this;
1659
+ /** @type {?} */
1660
+ var ref = this._modal.open(RefreshSessionTimeModalComponent, {
1661
+ data: null,
1662
+ disableClose: true,
1663
+ width: '500px'
1664
+ });
1665
+ ref.afterClosed().subscribe(( /**
1666
+ * @param {?} r
1667
+ * @return {?}
1668
+ */function (r) {
1669
+ if (r != null && (r.modalAction == InfoModalAction.Yes || (_this._sessao.TempoInatividade - ((new Date().valueOf() - parseInt(localStorage.getItem('ms'))) / 1000)) > 0)) {
1670
+ _this._sessionActive = true;
1671
+ _this.refreshSessionTime();
1672
+ }
1673
+ else
1674
+ _this.logout();
1675
+ }));
1666
1676
  };
1667
1677
  /**
1668
1678
  * @param {?} usuario
@@ -2085,7 +2095,7 @@
2085
2095
  * @type {?}
2086
2096
  * @private
2087
2097
  */
2088
- InfoAuthenticationService.prototype._sessionTime;
2098
+ InfoAuthenticationService.prototype._sessionActive;
2089
2099
  /**
2090
2100
  * @type {?}
2091
2101
  * @private
@@ -2541,7 +2551,7 @@
2541
2551
  * @return {?}
2542
2552
  */function () {
2543
2553
  if (_this.selectedValue != null)
2544
- if (_this._data == null || (_this._data != null && _this._data.length == 0)) {
2554
+ if ((_this._data == null || (_this._data != null && _this._data.length == 0)) && !_this.loading) {
2545
2555
  _this.writeValue(null);
2546
2556
  _this.selectedValue = null;
2547
2557
  }