@senior-gestao-empresarial/angular-components 6.9.3 → 6.10.0
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 +30 -39
- 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 +2 -3
- package/esm2015/components/websocket/websocket.service.js +31 -34
- package/esm5/components/websocket/websocket.service.js +32 -41
- package/fesm2015/senior-gestao-empresarial-angular-components.js +30 -33
- package/fesm2015/senior-gestao-empresarial-angular-components.js.map +1 -1
- package/fesm5/senior-gestao-empresarial-angular-components.js +31 -40
- 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,7 +3,7 @@ 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, race, timer, iif, fromEvent, ReplaySubject } from 'rxjs';
|
|
6
|
+
import { Subject, throwError, interval, of, BehaviorSubject, race, timer, iif, fromEvent, ReplaySubject } from 'rxjs';
|
|
7
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';
|
|
@@ -6606,25 +6606,21 @@ let WebsocketService = WebsocketService_1 = class WebsocketService {
|
|
|
6606
6606
|
/** @private */
|
|
6607
6607
|
this.primitiveManagers = new Map();
|
|
6608
6608
|
/** @private */
|
|
6609
|
-
this.
|
|
6609
|
+
this.connected$ = new BehaviorSubject(false);
|
|
6610
6610
|
/** @private */
|
|
6611
6611
|
this.disconnect$ = new Subject();
|
|
6612
6612
|
/** @private */
|
|
6613
6613
|
this.reconnect$ = new Subject();
|
|
6614
6614
|
/** @private */
|
|
6615
6615
|
this.error$ = new Subject();
|
|
6616
|
-
this.
|
|
6617
|
-
this.connect();
|
|
6616
|
+
this.subscribed$ = new Subject();
|
|
6618
6617
|
}
|
|
6619
6618
|
/**
|
|
6620
6619
|
* Observable responsável por emitir uma notificação quando a conexão websocket é estabelecida pela primeira vez.
|
|
6621
6620
|
* @return Um `Observable<void>` que emite uma notificação quando a conexão websocket é estabelecida pela primeira vez.
|
|
6622
6621
|
*/
|
|
6623
6622
|
onConnect() {
|
|
6624
|
-
|
|
6625
|
-
return of(undefined).pipe(take(1));
|
|
6626
|
-
}
|
|
6627
|
-
return this.connect$.asObservable().pipe(take(1));
|
|
6623
|
+
return this.connected$.asObservable().pipe(filter(Boolean), map(() => undefined), take(1));
|
|
6628
6624
|
}
|
|
6629
6625
|
/**
|
|
6630
6626
|
* Observable responsável por emitir uma notificação quando a conexão é desconectada.
|
|
@@ -6646,10 +6642,14 @@ let WebsocketService = WebsocketService_1 = class WebsocketService {
|
|
|
6646
6642
|
*/
|
|
6647
6643
|
onSubscribe({ domain, service, primitive }) {
|
|
6648
6644
|
const key = this.getPrimitiveManagerKey(domain, service, primitive);
|
|
6649
|
-
return this.onConnect().pipe(switchMap(() =>
|
|
6650
|
-
this.primitiveManagers.
|
|
6651
|
-
|
|
6652
|
-
|
|
6645
|
+
return this.onConnect().pipe(switchMap(() => {
|
|
6646
|
+
if (this.primitiveManagers.has(key))
|
|
6647
|
+
return this.primitiveManagers
|
|
6648
|
+
.get(key)
|
|
6649
|
+
.subscribed$.asObservable()
|
|
6650
|
+
.pipe(map(() => undefined), take(1));
|
|
6651
|
+
return this.subscribed$.asObservable().pipe(filter((primitiveManager) => this.getPrimitiveManagerKey(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive) === key), map(() => undefined), take(1));
|
|
6652
|
+
}));
|
|
6653
6653
|
}
|
|
6654
6654
|
/**
|
|
6655
6655
|
* Observable responsável por emitir uma notificação quando ocorre algum erro.
|
|
@@ -6667,6 +6667,7 @@ let WebsocketService = WebsocketService_1 = class WebsocketService {
|
|
|
6667
6667
|
* @return Um Observable<T> que emite notificações toda vez que o respectivo evento é publicado.
|
|
6668
6668
|
*/
|
|
6669
6669
|
onEvent(options) {
|
|
6670
|
+
this.connect();
|
|
6670
6671
|
const { domain, service, primitive } = options;
|
|
6671
6672
|
const key = this.getPrimitiveManagerKey(domain, service, primitive);
|
|
6672
6673
|
if (this.primitiveManagers.has(key)) {
|
|
@@ -6678,26 +6679,17 @@ let WebsocketService = WebsocketService_1 = class WebsocketService {
|
|
|
6678
6679
|
primitive: primitive,
|
|
6679
6680
|
stompSubscriptions: [],
|
|
6680
6681
|
event$: new Subject(),
|
|
6681
|
-
|
|
6682
|
+
subscribed$: new BehaviorSubject(false)
|
|
6682
6683
|
};
|
|
6683
6684
|
this.primitiveManagers.set(key, primitiveManager);
|
|
6684
|
-
|
|
6685
|
+
this.onConnect()
|
|
6686
|
+
.pipe(take(1))
|
|
6687
|
+
.subscribe(() => {
|
|
6685
6688
|
this.createStompSubscriptions(primitiveManager);
|
|
6686
|
-
|
|
6687
|
-
|
|
6688
|
-
|
|
6689
|
-
|
|
6690
|
-
else {
|
|
6691
|
-
if (!this.isConnecting) {
|
|
6692
|
-
this.connect();
|
|
6693
|
-
}
|
|
6694
|
-
this.connect$.pipe(first()).subscribe(() => {
|
|
6695
|
-
this.createStompSubscriptions(primitiveManager);
|
|
6696
|
-
});
|
|
6697
|
-
return primitiveManager.event$
|
|
6698
|
-
.asObservable()
|
|
6699
|
-
.pipe(finalize(() => this.disconnectPrimitiveOnFinalize(primitiveManager)));
|
|
6700
|
-
}
|
|
6689
|
+
});
|
|
6690
|
+
return primitiveManager.event$
|
|
6691
|
+
.asObservable()
|
|
6692
|
+
.pipe(finalize(() => this.disconnectPrimitiveOnFinalize(primitiveManager)));
|
|
6701
6693
|
}
|
|
6702
6694
|
/** @private */
|
|
6703
6695
|
createStompSubscriptions(primitiveManager) {
|
|
@@ -6709,11 +6701,13 @@ let WebsocketService = WebsocketService_1 = class WebsocketService {
|
|
|
6709
6701
|
stompSubscriptionWithToken,
|
|
6710
6702
|
stompSubscriptionWithoutToken
|
|
6711
6703
|
];
|
|
6712
|
-
primitiveManager.
|
|
6713
|
-
this.
|
|
6704
|
+
primitiveManager.subscribed$.next(true);
|
|
6705
|
+
this.subscribed$.next(primitiveManager);
|
|
6714
6706
|
}
|
|
6715
6707
|
/** @private */
|
|
6716
6708
|
connect() {
|
|
6709
|
+
if (this.isConnected || this.isConnecting)
|
|
6710
|
+
return;
|
|
6717
6711
|
this.createStompClient();
|
|
6718
6712
|
this.isConnecting = true;
|
|
6719
6713
|
this._stompClient.connect({}, () => {
|
|
@@ -6721,15 +6715,16 @@ let WebsocketService = WebsocketService_1 = class WebsocketService {
|
|
|
6721
6715
|
this.isConnected = true;
|
|
6722
6716
|
if (this.wasConnected) {
|
|
6723
6717
|
this.reconnectPrimitives();
|
|
6724
|
-
this.
|
|
6718
|
+
this.connected$.next(true);
|
|
6725
6719
|
this.reconnect$.next();
|
|
6726
6720
|
}
|
|
6727
6721
|
else {
|
|
6728
6722
|
this.wasConnected = true;
|
|
6729
|
-
this.
|
|
6723
|
+
this.connected$.next(true);
|
|
6730
6724
|
}
|
|
6731
6725
|
}, (error) => {
|
|
6732
6726
|
this.isConnected = false;
|
|
6727
|
+
this.connected$.next(false);
|
|
6733
6728
|
this.error$.next(error);
|
|
6734
6729
|
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 }))))
|
|
6735
6730
|
.pipe(take(1))
|
|
@@ -6761,6 +6756,7 @@ let WebsocketService = WebsocketService_1 = class WebsocketService {
|
|
|
6761
6756
|
this.isConnected = false;
|
|
6762
6757
|
this.isConnecting = false;
|
|
6763
6758
|
this.wasConnected = false;
|
|
6759
|
+
this.connected$.next(false);
|
|
6764
6760
|
this.disconnect$.next();
|
|
6765
6761
|
}
|
|
6766
6762
|
/** @private */
|
|
@@ -6817,6 +6813,7 @@ let WebsocketService = WebsocketService_1 = class WebsocketService {
|
|
|
6817
6813
|
for (const stompSubscription of primitiveManager.stompSubscriptions) {
|
|
6818
6814
|
stompSubscription.unsubscribe();
|
|
6819
6815
|
}
|
|
6816
|
+
primitiveManager.subscribed$.complete();
|
|
6820
6817
|
const key = this.getPrimitiveManagerKey(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
6821
6818
|
this.primitiveManagers.delete(key);
|
|
6822
6819
|
this.disconnect();
|