@senior-gestao-empresarial/angular-components 6.8.0 → 6.9.1
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/senior-gestao-empresarial-angular-components.umd.js +80 -105
- package/bundles/senior-gestao-empresarial-angular-components.umd.js.map +1 -1
- package/bundles/senior-gestao-empresarial-angular-components.umd.min.js +1 -1
- package/bundles/senior-gestao-empresarial-angular-components.umd.min.js.map +1 -1
- package/components/websocket/websocket.service.d.ts +11 -24
- package/esm2015/components/websocket/websocket.service.js +63 -88
- package/esm5/components/websocket/websocket.service.js +87 -112
- package/fesm2015/senior-gestao-empresarial-angular-components.js +58 -83
- package/fesm2015/senior-gestao-empresarial-angular-components.js.map +1 -1
- package/fesm5/senior-gestao-empresarial-angular-components.js +82 -107
- package/fesm5/senior-gestao-empresarial-angular-components.js.map +1 -1
- package/package.json +1 -1
- package/senior-gestao-empresarial-angular-components.metadata.json +1 -1
|
@@ -3,8 +3,8 @@ import { Input, Component, NgModule, Injectable, Inject, ɵɵdefineInjectable,
|
|
|
3
3
|
import { CommonModule } from '@angular/common';
|
|
4
4
|
import { BreadcrumbModule as BreadcrumbModule$1 } from 'primeng/breadcrumb';
|
|
5
5
|
import { NavigationEnd, PRIMARY_OUTLET, ActivatedRoute, Router, RouterModule } from '@angular/router';
|
|
6
|
-
import { Subject, throwError, interval, of, ReplaySubject } from 'rxjs';
|
|
7
|
-
import { takeUntil, filter, catchError, map, takeWhile, switchMap,
|
|
6
|
+
import { Subject, throwError, interval, of, race, timer, iif, fromEvent, ReplaySubject } from 'rxjs';
|
|
7
|
+
import { takeUntil, filter, catchError, map, takeWhile, switchMap, take, finalize, first } from 'rxjs/operators';
|
|
8
8
|
import * as moment_ from 'moment';
|
|
9
9
|
import { FormField, FieldType } from '@seniorsistemas/angular-components';
|
|
10
10
|
import { HttpParams, HttpClient } from '@angular/common/http';
|
|
@@ -6554,12 +6554,10 @@ NpsService = __decorate([
|
|
|
6554
6554
|
var WebsocketService_1;
|
|
6555
6555
|
let WebsocketService = WebsocketService_1 = class WebsocketService {
|
|
6556
6556
|
constructor() {
|
|
6557
|
-
/** @private */
|
|
6558
|
-
this.focused = true;
|
|
6559
6557
|
/** @private */
|
|
6560
6558
|
this.wasConnected = false;
|
|
6561
6559
|
/** @private */
|
|
6562
|
-
this.
|
|
6560
|
+
this.isConnected = false;
|
|
6563
6561
|
/** @private */
|
|
6564
6562
|
this.isConnecting = false;
|
|
6565
6563
|
/** @private */
|
|
@@ -6572,21 +6570,18 @@ let WebsocketService = WebsocketService_1 = class WebsocketService {
|
|
|
6572
6570
|
this.reconnect$ = new Subject();
|
|
6573
6571
|
/** @private */
|
|
6574
6572
|
this.error$ = new Subject();
|
|
6575
|
-
|
|
6576
|
-
window.onblur = this.onBlur;
|
|
6573
|
+
this.subscribe$ = new Subject();
|
|
6577
6574
|
this.connect();
|
|
6578
6575
|
}
|
|
6579
6576
|
/**
|
|
6580
|
-
* Observable responsável por emitir uma notificação quando a conexão websocket é estabelecida.
|
|
6581
|
-
* @return Um `Observable<void>` que emite uma notificação quando a conexão websocket é estabelecida.
|
|
6577
|
+
* Observable responsável por emitir uma notificação quando a conexão websocket é estabelecida pela primeira vez.
|
|
6578
|
+
* @return Um `Observable<void>` que emite uma notificação quando a conexão websocket é estabelecida pela primeira vez.
|
|
6582
6579
|
*/
|
|
6583
6580
|
onConnect() {
|
|
6584
|
-
|
|
6585
|
-
|
|
6586
|
-
|
|
6587
|
-
|
|
6588
|
-
}, 0);
|
|
6589
|
-
return this.connect$.pipe(first());
|
|
6581
|
+
if (this.isConnected || this.wasConnected) {
|
|
6582
|
+
return of(undefined).pipe(take(1));
|
|
6583
|
+
}
|
|
6584
|
+
return this.connect$.asObservable().pipe(take(1));
|
|
6590
6585
|
}
|
|
6591
6586
|
/**
|
|
6592
6587
|
* Observable responsável por emitir uma notificação quando a conexão é desconectada.
|
|
@@ -6603,15 +6598,15 @@ let WebsocketService = WebsocketService_1 = class WebsocketService {
|
|
|
6603
6598
|
return this.reconnect$.asObservable();
|
|
6604
6599
|
}
|
|
6605
6600
|
/**
|
|
6606
|
-
* Observable responsável por emitir uma notificação após o subscribe do evento.
|
|
6607
|
-
* @return Um `Observable<void>` que emite uma notificação após o subscribe do evento.
|
|
6601
|
+
* Observable responsável por emitir uma notificação após o subscribe do evento pela primeira vez.
|
|
6602
|
+
* @return Um `Observable<void>` que emite uma notificação após o subscribe do evento pela primeira vez.
|
|
6608
6603
|
*/
|
|
6609
6604
|
onSubscribe({ domain, service, primitive }) {
|
|
6610
|
-
const
|
|
6611
|
-
|
|
6612
|
-
|
|
6613
|
-
|
|
6614
|
-
|
|
6605
|
+
const key = this.getPrimitiveManagerKey(domain, service, primitive);
|
|
6606
|
+
return this.onConnect().pipe(switchMap(() => this.primitiveManagers.has(key) &&
|
|
6607
|
+
this.primitiveManagers.get(key).isSubscribed
|
|
6608
|
+
? of(void 0).pipe(take(1))
|
|
6609
|
+
: this.subscribe$.pipe(filter((primitiveManager) => this.getPrimitiveManagerKey(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive) === key), take(1), map(() => void 0))));
|
|
6615
6610
|
}
|
|
6616
6611
|
/**
|
|
6617
6612
|
* Observable responsável por emitir uma notificação quando ocorre algum erro.
|
|
@@ -6640,10 +6635,10 @@ let WebsocketService = WebsocketService_1 = class WebsocketService {
|
|
|
6640
6635
|
primitive: primitive,
|
|
6641
6636
|
stompSubscriptions: [],
|
|
6642
6637
|
event$: new Subject(),
|
|
6643
|
-
|
|
6638
|
+
isSubscribed: false
|
|
6644
6639
|
};
|
|
6645
6640
|
this.primitiveManagers.set(key, primitiveManager);
|
|
6646
|
-
if (this.isConnected
|
|
6641
|
+
if (this.isConnected) {
|
|
6647
6642
|
this.createStompSubscriptions(primitiveManager);
|
|
6648
6643
|
return primitiveManager.event$
|
|
6649
6644
|
.asObservable()
|
|
@@ -6667,19 +6662,23 @@ let WebsocketService = WebsocketService_1 = class WebsocketService {
|
|
|
6667
6662
|
const stompSubscriptionWithToken = this.createStompSubscription(withTokenUrl, primitiveManager);
|
|
6668
6663
|
const withoutTokenUrl = this.getSubscriptionUrlWithoutToken(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
6669
6664
|
const stompSubscriptionWithoutToken = this.createStompSubscription(withoutTokenUrl, primitiveManager);
|
|
6670
|
-
primitiveManager.stompSubscriptions = [
|
|
6671
|
-
|
|
6665
|
+
primitiveManager.stompSubscriptions = [
|
|
6666
|
+
stompSubscriptionWithToken,
|
|
6667
|
+
stompSubscriptionWithoutToken
|
|
6668
|
+
];
|
|
6669
|
+
primitiveManager.isSubscribed = true;
|
|
6670
|
+
this.subscribe$.next(primitiveManager);
|
|
6672
6671
|
}
|
|
6673
6672
|
/** @private */
|
|
6674
6673
|
connect() {
|
|
6675
6674
|
this.createStompClient();
|
|
6676
6675
|
this.isConnecting = true;
|
|
6677
|
-
this._stompClient.activate();
|
|
6678
6676
|
this._stompClient.connect({}, () => {
|
|
6679
6677
|
this.isConnecting = false;
|
|
6680
|
-
this.
|
|
6678
|
+
this.isConnected = true;
|
|
6681
6679
|
if (this.wasConnected) {
|
|
6682
6680
|
this.reconnectPrimitives();
|
|
6681
|
+
this.connect$.next();
|
|
6683
6682
|
this.reconnect$.next();
|
|
6684
6683
|
}
|
|
6685
6684
|
else {
|
|
@@ -6687,23 +6686,24 @@ let WebsocketService = WebsocketService_1 = class WebsocketService {
|
|
|
6687
6686
|
this.connect$.next();
|
|
6688
6687
|
}
|
|
6689
6688
|
}, (error) => {
|
|
6690
|
-
this.
|
|
6689
|
+
this.isConnected = false;
|
|
6691
6690
|
this.error$.next(error);
|
|
6692
|
-
this.
|
|
6691
|
+
race(this.disconnect$.pipe(take(1), map(() => ({ wasDisconnected: true }))), timer(WebsocketService_1.RECONNECT_INTERVAL).pipe(take(1), switchMap(() => iif(() => document.hidden, fromEvent(document, 'visibilitychange').pipe(first()), of(void 0))), map(() => ({ wasDisconnected: false }))))
|
|
6692
|
+
.pipe(take(1))
|
|
6693
|
+
.subscribe({
|
|
6694
|
+
next: ({ wasDisconnected }) => {
|
|
6695
|
+
if (!wasDisconnected &&
|
|
6696
|
+
!(this.isConnected || this.isConnecting)) {
|
|
6697
|
+
this.connect();
|
|
6698
|
+
}
|
|
6699
|
+
}
|
|
6700
|
+
});
|
|
6693
6701
|
});
|
|
6694
6702
|
}
|
|
6695
|
-
/** @private */
|
|
6696
|
-
onFocus() {
|
|
6697
|
-
this.focused = true;
|
|
6698
|
-
}
|
|
6699
|
-
/** @private */
|
|
6700
|
-
onBlur() {
|
|
6701
|
-
this.focused = false;
|
|
6702
|
-
}
|
|
6703
6703
|
disconnect() {
|
|
6704
|
-
|
|
6705
|
-
if (observersCount > 0)
|
|
6704
|
+
if (this.getObserversCount() > 0) {
|
|
6706
6705
|
return;
|
|
6706
|
+
}
|
|
6707
6707
|
for (const primitiveManager of this.primitiveManagers.values()) {
|
|
6708
6708
|
for (const stompSubscription of primitiveManager.stompSubscriptions) {
|
|
6709
6709
|
stompSubscription.unsubscribe();
|
|
@@ -6711,39 +6711,36 @@ let WebsocketService = WebsocketService_1 = class WebsocketService {
|
|
|
6711
6711
|
}
|
|
6712
6712
|
for (const primitiveManager of this.primitiveManagers.values()) {
|
|
6713
6713
|
primitiveManager.event$.complete();
|
|
6714
|
-
primitiveManager.subscribe$.complete();
|
|
6715
6714
|
}
|
|
6716
6715
|
this.primitiveManagers.clear();
|
|
6717
6716
|
this._stompClient.disconnect();
|
|
6718
6717
|
this._stompClient.deactivate();
|
|
6719
|
-
this.
|
|
6718
|
+
this.isConnected = false;
|
|
6720
6719
|
this.isConnecting = false;
|
|
6721
6720
|
this.wasConnected = false;
|
|
6722
6721
|
this.disconnect$.next();
|
|
6723
6722
|
}
|
|
6724
6723
|
/** @private */
|
|
6725
|
-
isConnected() {
|
|
6726
|
-
return this.connected;
|
|
6727
|
-
}
|
|
6728
|
-
/** @private */
|
|
6729
|
-
setConnected(connected) {
|
|
6730
|
-
this.connected = connected;
|
|
6731
|
-
}
|
|
6732
|
-
/** @private */
|
|
6733
6724
|
getSubscriptionUrlWithToken(domain, service, primitive) {
|
|
6734
|
-
const tenant = WebsocketService_1.TOKEN
|
|
6735
|
-
|
|
6725
|
+
const tenant = WebsocketService_1.TOKEN
|
|
6726
|
+
? WebsocketService_1.TOKEN.username.split('@')[1]
|
|
6727
|
+
: null;
|
|
6728
|
+
const token = WebsocketService_1.TOKEN
|
|
6729
|
+
? WebsocketService_1.TOKEN.access_token
|
|
6730
|
+
: null;
|
|
6736
6731
|
return `/topic/${tenant}/${token}/${domain}/${service}/${primitive}`;
|
|
6737
6732
|
}
|
|
6738
6733
|
/** @private */
|
|
6739
6734
|
getSubscriptionUrlWithoutToken(domain, service, primitive) {
|
|
6740
|
-
const tenant = WebsocketService_1.TOKEN
|
|
6735
|
+
const tenant = WebsocketService_1.TOKEN
|
|
6736
|
+
? WebsocketService_1.TOKEN.username.split('@')[1]
|
|
6737
|
+
: null;
|
|
6741
6738
|
return `/topic/${tenant}/${domain}/${service}/${primitive}`;
|
|
6742
6739
|
}
|
|
6743
6740
|
/** @private */
|
|
6744
6741
|
createStompSubscription(destination, primitiveManager) {
|
|
6745
6742
|
return this._stompClient.subscribe(destination, (message) => {
|
|
6746
|
-
const event = JSON.parse(message.body ||
|
|
6743
|
+
const event = JSON.parse(message.body || '{}');
|
|
6747
6744
|
primitiveManager.event$.next(event);
|
|
6748
6745
|
});
|
|
6749
6746
|
}
|
|
@@ -6751,30 +6748,11 @@ let WebsocketService = WebsocketService_1 = class WebsocketService {
|
|
|
6751
6748
|
createStompClient() {
|
|
6752
6749
|
const ws = new SockJS(`${WebsocketService_1.WEBSOCKET_URL}subscription`, null, { timeout: WebsocketService_1.CONNECTION_TIMEOUT });
|
|
6753
6750
|
this._stompClient = Stomp.over(ws);
|
|
6754
|
-
|
|
6755
|
-
this._stompClient.debug = () => { }; // Para remover os logs.
|
|
6756
|
-
}
|
|
6757
|
-
/** @private */
|
|
6758
|
-
reconnect() {
|
|
6759
|
-
if (this.connected)
|
|
6760
|
-
this._stompClient.disconnect();
|
|
6761
|
-
setTimeout(() => {
|
|
6762
|
-
if (this.getObserversCount() === 0)
|
|
6763
|
-
return;
|
|
6764
|
-
if (this.focused) {
|
|
6765
|
-
this.connect();
|
|
6766
|
-
}
|
|
6767
|
-
else {
|
|
6768
|
-
this.reconnect();
|
|
6769
|
-
}
|
|
6770
|
-
}, WebsocketService_1.RECONNECT_TIMER);
|
|
6751
|
+
this._stompClient.debug = () => null;
|
|
6771
6752
|
}
|
|
6772
6753
|
/** @private */
|
|
6773
6754
|
reconnectPrimitives() {
|
|
6774
6755
|
for (const primitiveManager of this.primitiveManagers.values()) {
|
|
6775
|
-
for (const stompSubscription of primitiveManager.stompSubscriptions) {
|
|
6776
|
-
stompSubscription.unsubscribe();
|
|
6777
|
-
}
|
|
6778
6756
|
this.createStompSubscriptions(primitiveManager);
|
|
6779
6757
|
}
|
|
6780
6758
|
}
|
|
@@ -6793,7 +6771,6 @@ let WebsocketService = WebsocketService_1 = class WebsocketService {
|
|
|
6793
6771
|
if (hasObservers)
|
|
6794
6772
|
return;
|
|
6795
6773
|
primitiveManager.event$.complete();
|
|
6796
|
-
primitiveManager.subscribe$.complete();
|
|
6797
6774
|
for (const stompSubscription of primitiveManager.stompSubscriptions) {
|
|
6798
6775
|
stompSubscription.unsubscribe();
|
|
6799
6776
|
}
|
|
@@ -6806,22 +6783,20 @@ let WebsocketService = WebsocketService_1 = class WebsocketService {
|
|
|
6806
6783
|
return `${domain}/${service}/${primitive}`;
|
|
6807
6784
|
}
|
|
6808
6785
|
};
|
|
6809
|
-
|
|
6810
|
-
WebsocketService.RECONNECT_TIMER = 3000;
|
|
6811
|
-
/** @private */
|
|
6786
|
+
WebsocketService.RECONNECT_INTERVAL = 3000;
|
|
6812
6787
|
WebsocketService.CONNECTION_TIMEOUT = 15000;
|
|
6813
6788
|
/** @private */
|
|
6814
|
-
WebsocketService.BASE_URL_COOKIE =
|
|
6789
|
+
WebsocketService.BASE_URL_COOKIE = 'com.senior.base.url';
|
|
6815
6790
|
/** @private */
|
|
6816
|
-
WebsocketService.TOKEN_COOKIE =
|
|
6791
|
+
WebsocketService.TOKEN_COOKIE = 'com.senior.token';
|
|
6817
6792
|
/** @private */
|
|
6818
|
-
WebsocketService.TOKEN = JSON.parse(get(WebsocketService_1.TOKEN_COOKIE) ||
|
|
6793
|
+
WebsocketService.TOKEN = JSON.parse(get(WebsocketService_1.TOKEN_COOKIE) || '{}');
|
|
6819
6794
|
/** @private */
|
|
6820
|
-
WebsocketService.WEBSOCKET_URL = get(WebsocketService_1.BASE_URL_COOKIE) +
|
|
6795
|
+
WebsocketService.WEBSOCKET_URL = get(WebsocketService_1.BASE_URL_COOKIE) + '/websocket/';
|
|
6821
6796
|
WebsocketService.ɵprov = ɵɵdefineInjectable({ factory: function WebsocketService_Factory() { return new WebsocketService(); }, token: WebsocketService, providedIn: "root" });
|
|
6822
6797
|
WebsocketService = WebsocketService_1 = __decorate([
|
|
6823
6798
|
Injectable({
|
|
6824
|
-
providedIn:
|
|
6799
|
+
providedIn: 'root'
|
|
6825
6800
|
})
|
|
6826
6801
|
], WebsocketService);
|
|
6827
6802
|
|