@senior-gestao-empresarial/angular-components 6.12.0 → 7.0.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 +454 -255
- package/bundles/senior-gestao-empresarial-angular-components.umd.js.map +1 -1
- package/bundles/senior-gestao-empresarial-angular-components.umd.min.js +2 -2
- package/bundles/senior-gestao-empresarial-angular-components.umd.min.js.map +1 -1
- package/components/utils/async-lock.d.ts +6 -0
- package/components/websocket/index.d.ts +2 -0
- package/components/websocket/models/index.d.ts +1 -0
- package/components/websocket/models/primitive-manager.d.ts +19 -0
- package/components/websocket/protocols/index.d.ts +2 -0
- package/components/websocket/protocols/on-event-options.d.ts +8 -0
- package/components/websocket/protocols/primitive-event.d.ts +10 -0
- package/components/websocket/user-information.service.d.ts +7 -0
- package/components/websocket/websocket.service.d.ts +78 -74
- package/esm2015/components/utils/async-lock.js +34 -0
- package/esm2015/components/websocket/index.js +2 -1
- package/esm2015/components/websocket/models/index.js +2 -0
- package/esm2015/components/websocket/models/primitive-manager.js +39 -0
- package/esm2015/components/websocket/protocols/index.js +1 -0
- package/esm2015/components/websocket/protocols/on-event-options.js +1 -0
- package/esm2015/components/websocket/protocols/primitive-event.js +1 -0
- package/esm2015/components/websocket/user-information.service.js +34 -0
- package/esm2015/components/websocket/websocket.service.js +269 -195
- package/esm2015/senior-gestao-empresarial-angular-components.js +4 -3
- package/esm5/components/utils/async-lock.js +43 -0
- package/esm5/components/websocket/index.js +2 -1
- package/esm5/components/websocket/models/index.js +2 -0
- package/esm5/components/websocket/models/primitive-manager.js +58 -0
- package/esm5/components/websocket/protocols/index.js +1 -0
- package/esm5/components/websocket/protocols/on-event-options.js +1 -0
- package/esm5/components/websocket/protocols/primitive-event.js +1 -0
- package/esm5/components/websocket/user-information.service.js +38 -0
- package/esm5/components/websocket/websocket.service.js +326 -255
- package/esm5/senior-gestao-empresarial-angular-components.js +4 -3
- package/fesm2015/senior-gestao-empresarial-angular-components.js +364 -193
- package/fesm2015/senior-gestao-empresarial-angular-components.js.map +1 -1
- package/fesm5/senior-gestao-empresarial-angular-components.js +451 -254
- package/fesm5/senior-gestao-empresarial-angular-components.js.map +1 -1
- package/package.json +3 -3
- package/senior-gestao-empresarial-angular-components.d.ts +3 -2
- 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, BehaviorSubject,
|
|
7
|
-
import { takeUntil, filter, catchError, map, takeWhile, switchMap, take, finalize
|
|
6
|
+
import { Subject, throwError, interval, of, BehaviorSubject, ReplaySubject } from 'rxjs';
|
|
7
|
+
import { takeUntil, filter, catchError, map, takeWhile, switchMap, take, finalize } 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';
|
|
@@ -13,9 +13,9 @@ import { TranslateService } from '@ngx-translate/core';
|
|
|
13
13
|
import { HttpInterceptorModule } from '@seniorsistemas/platform-components';
|
|
14
14
|
import { user } from '@seniorsistemas/senior-platform-data';
|
|
15
15
|
import { FormControl, FormGroup } from '@angular/forms';
|
|
16
|
-
import {
|
|
17
|
-
import { get } from 'js-cookie';
|
|
16
|
+
import { Client, FrameImpl } from '@stomp/stompjs';
|
|
18
17
|
import * as SockJS from 'sockjs-client';
|
|
18
|
+
import { get } from 'js-cookie';
|
|
19
19
|
|
|
20
20
|
let BreadcrumbComponent = class BreadcrumbComponent {
|
|
21
21
|
constructor(activatedRoute, router) {
|
|
@@ -6768,247 +6768,418 @@ NpsService = __decorate([
|
|
|
6768
6768
|
})
|
|
6769
6769
|
], NpsService);
|
|
6770
6770
|
|
|
6771
|
-
|
|
6772
|
-
let WebsocketService = WebsocketService_1 = class WebsocketService {
|
|
6771
|
+
class AsyncLock {
|
|
6773
6772
|
constructor() {
|
|
6774
|
-
|
|
6775
|
-
this.
|
|
6776
|
-
|
|
6777
|
-
|
|
6778
|
-
|
|
6779
|
-
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
|
|
6773
|
+
this.queue = [];
|
|
6774
|
+
this.acquired = false;
|
|
6775
|
+
}
|
|
6776
|
+
acquire() {
|
|
6777
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6778
|
+
if (!this.acquired) {
|
|
6779
|
+
this.acquired = true;
|
|
6780
|
+
return Promise.resolve();
|
|
6781
|
+
}
|
|
6782
|
+
else {
|
|
6783
|
+
return new Promise((resolve, _) => {
|
|
6784
|
+
this.queue.push(resolve);
|
|
6785
|
+
});
|
|
6786
|
+
}
|
|
6787
|
+
});
|
|
6788
|
+
}
|
|
6789
|
+
release() {
|
|
6790
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6791
|
+
if (this.queue.length === 0 && this.acquired) {
|
|
6792
|
+
this.acquired = false;
|
|
6793
|
+
return Promise.resolve();
|
|
6794
|
+
}
|
|
6795
|
+
const continuation = this.queue.shift();
|
|
6796
|
+
return new Promise((res) => {
|
|
6797
|
+
continuation();
|
|
6798
|
+
res();
|
|
6799
|
+
});
|
|
6800
|
+
});
|
|
6801
|
+
}
|
|
6802
|
+
}
|
|
6803
|
+
|
|
6804
|
+
var UserInformationService_1;
|
|
6805
|
+
let UserInformationService = UserInformationService_1 = class UserInformationService {
|
|
6806
|
+
getAuthToken() {
|
|
6807
|
+
const cookieValue = get(UserInformationService_1.TOKEN_COOKIE_KEY) || '{}';
|
|
6808
|
+
const authToken = JSON.parse(cookieValue);
|
|
6809
|
+
return authToken.access_token;
|
|
6810
|
+
}
|
|
6811
|
+
getTenantDomain() {
|
|
6812
|
+
const cookieValue = get(UserInformationService_1.TOKEN_COOKIE_KEY) || '{}';
|
|
6813
|
+
const authToken = JSON.parse(cookieValue);
|
|
6814
|
+
return authToken.username.split('@')[1];
|
|
6815
|
+
}
|
|
6816
|
+
getWebSocketUrl() {
|
|
6817
|
+
let baseUrl = get(UserInformationService_1.BASE_URL_COOKIE_KEY);
|
|
6818
|
+
if (baseUrl && !baseUrl.endsWith('/')) {
|
|
6819
|
+
baseUrl += '/';
|
|
6820
|
+
}
|
|
6821
|
+
return baseUrl + 'websocket';
|
|
6822
|
+
}
|
|
6823
|
+
};
|
|
6824
|
+
UserInformationService.BASE_URL_COOKIE_KEY = 'com.senior.base.url';
|
|
6825
|
+
UserInformationService.TOKEN_COOKIE_KEY = 'com.senior.token';
|
|
6826
|
+
UserInformationService.ɵprov = ɵɵdefineInjectable({ factory: function UserInformationService_Factory() { return new UserInformationService(); }, token: UserInformationService, providedIn: "root" });
|
|
6827
|
+
UserInformationService = UserInformationService_1 = __decorate([
|
|
6828
|
+
Injectable({
|
|
6829
|
+
providedIn: 'root'
|
|
6830
|
+
})
|
|
6831
|
+
], UserInformationService);
|
|
6832
|
+
|
|
6833
|
+
class PrimitiveManager {
|
|
6834
|
+
constructor(domain, service, primitive) {
|
|
6835
|
+
this.domain = domain;
|
|
6836
|
+
this.service = service;
|
|
6837
|
+
this.primitive = primitive;
|
|
6838
|
+
this.stompSubscriptions = [];
|
|
6839
|
+
this.event$ = new Subject();
|
|
6840
|
+
this.subscribed$ = new BehaviorSubject(false);
|
|
6841
|
+
}
|
|
6842
|
+
unsubscribe() {
|
|
6843
|
+
this.event$.complete();
|
|
6844
|
+
for (const stompSubscription of this.stompSubscriptions) {
|
|
6845
|
+
stompSubscription.unsubscribe();
|
|
6846
|
+
}
|
|
6847
|
+
this.subscribed$.complete();
|
|
6848
|
+
}
|
|
6849
|
+
fireEvent(event) {
|
|
6850
|
+
this.event$.next(event);
|
|
6851
|
+
}
|
|
6852
|
+
subscribe(...subscriptions) {
|
|
6853
|
+
this.stompSubscriptions.push(...subscriptions);
|
|
6854
|
+
this.subscribed$.next(true);
|
|
6855
|
+
}
|
|
6856
|
+
getEventObservable() {
|
|
6857
|
+
return this.event$.asObservable();
|
|
6858
|
+
}
|
|
6859
|
+
getSubscriptionObservable() {
|
|
6860
|
+
return this.subscribed$.asObservable();
|
|
6861
|
+
}
|
|
6862
|
+
hasObservers() {
|
|
6863
|
+
// @IMPORTANT: Replace .observers.length === 1 with .observed in rxjs 7.0+
|
|
6864
|
+
return this.event$.observers.length !== 1;
|
|
6865
|
+
}
|
|
6866
|
+
getObserversCount() {
|
|
6867
|
+
return this.event$.observers.length;
|
|
6868
|
+
}
|
|
6869
|
+
}
|
|
6870
|
+
|
|
6871
|
+
const RECONNECT_INTERVAL_MILLISECONDS = 3000;
|
|
6872
|
+
const CONNECTION_TIMEOUT_MILLISECONDS = 5000;
|
|
6873
|
+
let WebsocketService = class WebsocketService {
|
|
6874
|
+
constructor(userInformationService) {
|
|
6875
|
+
this.userInformationService = userInformationService;
|
|
6783
6876
|
this.connected$ = new BehaviorSubject(false);
|
|
6784
|
-
|
|
6785
|
-
this.
|
|
6786
|
-
/** @private */
|
|
6787
|
-
this.reconnect$ = new Subject();
|
|
6788
|
-
/** @private */
|
|
6877
|
+
this.disconnected$ = new Subject();
|
|
6878
|
+
this.reconnected$ = new Subject();
|
|
6789
6879
|
this.error$ = new Subject();
|
|
6790
6880
|
this.subscribed$ = new Subject();
|
|
6881
|
+
this.primitiveManagers = new Map();
|
|
6882
|
+
this.connectionLock = new AsyncLock();
|
|
6883
|
+
this.debugEnable = false;
|
|
6884
|
+
this.lostConnection = false;
|
|
6791
6885
|
}
|
|
6792
6886
|
/**
|
|
6793
|
-
*
|
|
6794
|
-
* @return Um `Observable<void>` que emite uma notificação quando a conexão websocket é estabelecida pela primeira vez.
|
|
6887
|
+
* Enables stompjs debug logs and additional info
|
|
6795
6888
|
*/
|
|
6796
|
-
|
|
6797
|
-
|
|
6889
|
+
enableDebugLogs() {
|
|
6890
|
+
this.debugEnable = true;
|
|
6798
6891
|
}
|
|
6799
6892
|
/**
|
|
6800
|
-
*
|
|
6801
|
-
* @return Um `Observable<void>` que emite uma notificação quando a conexão é desconectada.
|
|
6893
|
+
* Manually starts the connection
|
|
6802
6894
|
*/
|
|
6803
|
-
|
|
6804
|
-
return this
|
|
6895
|
+
connect() {
|
|
6896
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6897
|
+
yield this.connectionLock.acquire();
|
|
6898
|
+
try {
|
|
6899
|
+
if (this.isConnected() || this.isConnecting()) {
|
|
6900
|
+
return;
|
|
6901
|
+
}
|
|
6902
|
+
this.lostConnection = false;
|
|
6903
|
+
const stompConfig = {
|
|
6904
|
+
webSocketFactory: () => {
|
|
6905
|
+
return new SockJS(this.getSubscriptionUrl(), null, {
|
|
6906
|
+
timeout: CONNECTION_TIMEOUT_MILLISECONDS
|
|
6907
|
+
});
|
|
6908
|
+
},
|
|
6909
|
+
connectionTimeout: CONNECTION_TIMEOUT_MILLISECONDS,
|
|
6910
|
+
reconnectDelay: RECONNECT_INTERVAL_MILLISECONDS,
|
|
6911
|
+
debug: this.debug.bind(this),
|
|
6912
|
+
onConnect: this.handleOnConnected.bind(this),
|
|
6913
|
+
onDisconnect: this.handleOnDisconnect.bind(this),
|
|
6914
|
+
onWebSocketClose: this.handleOnWebSocketClose.bind(this),
|
|
6915
|
+
onStompError: this.handleOnStompError.bind(this),
|
|
6916
|
+
onWebSocketError: this.handleOnWebSocketError.bind(this)
|
|
6917
|
+
};
|
|
6918
|
+
this.debug('Connecting the Webscoket');
|
|
6919
|
+
this.stompClient = new Client(stompConfig);
|
|
6920
|
+
this.stompClient.activate();
|
|
6921
|
+
}
|
|
6922
|
+
finally {
|
|
6923
|
+
yield this.connectionLock.release();
|
|
6924
|
+
}
|
|
6925
|
+
});
|
|
6805
6926
|
}
|
|
6806
6927
|
/**
|
|
6807
|
-
*
|
|
6808
|
-
* @return Um `Observable<void>` que emite uma notificação quando a conexão é reconectada.
|
|
6928
|
+
* Manually disconnect the websocket. The reconnect loop will be stopped.
|
|
6809
6929
|
*/
|
|
6810
|
-
|
|
6811
|
-
return this
|
|
6930
|
+
disconnect() {
|
|
6931
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6932
|
+
if (!this.isConnected()) {
|
|
6933
|
+
return;
|
|
6934
|
+
}
|
|
6935
|
+
yield this.connectionLock.acquire();
|
|
6936
|
+
try {
|
|
6937
|
+
for (const primitiveManager of this.primitiveManagers.values()) {
|
|
6938
|
+
primitiveManager.unsubscribe();
|
|
6939
|
+
}
|
|
6940
|
+
this.primitiveManagers.clear();
|
|
6941
|
+
this.connected$.next(false);
|
|
6942
|
+
if (this.stompClient) {
|
|
6943
|
+
yield this.stompClient.deactivate();
|
|
6944
|
+
}
|
|
6945
|
+
}
|
|
6946
|
+
finally {
|
|
6947
|
+
yield this.connectionLock.release();
|
|
6948
|
+
}
|
|
6949
|
+
});
|
|
6812
6950
|
}
|
|
6813
6951
|
/**
|
|
6814
|
-
*
|
|
6815
|
-
* @return
|
|
6952
|
+
* Check if the websocket is connected
|
|
6953
|
+
* @return `boolean` representing if the websocket is connected
|
|
6816
6954
|
*/
|
|
6817
|
-
|
|
6818
|
-
|
|
6819
|
-
|
|
6820
|
-
|
|
6821
|
-
|
|
6822
|
-
|
|
6823
|
-
|
|
6824
|
-
|
|
6825
|
-
|
|
6826
|
-
|
|
6955
|
+
isConnected() {
|
|
6956
|
+
if (!this.stompClient) {
|
|
6957
|
+
return false;
|
|
6958
|
+
}
|
|
6959
|
+
return this.stompClient.connected;
|
|
6960
|
+
}
|
|
6961
|
+
/**
|
|
6962
|
+
* Check if the websocket is tring to connect
|
|
6963
|
+
* @return `boolean` representing if the websocket status
|
|
6964
|
+
*/
|
|
6965
|
+
isConnecting() {
|
|
6966
|
+
if (!this.stompClient) {
|
|
6967
|
+
return false;
|
|
6968
|
+
}
|
|
6969
|
+
return !this.stompClient.connected && this.stompClient.active;
|
|
6970
|
+
}
|
|
6971
|
+
/**
|
|
6972
|
+
* Event responsable to emit an event when the connection is established.
|
|
6973
|
+
* Do not forget to unsubscribe the observable when you don't need it anymore.
|
|
6974
|
+
* @return `Observable<boolean>`
|
|
6975
|
+
*/
|
|
6976
|
+
onConnect() {
|
|
6977
|
+
return this.connected$.asObservable()
|
|
6978
|
+
.pipe(filter(p => p === true));
|
|
6979
|
+
}
|
|
6980
|
+
/**
|
|
6981
|
+
* Event responsable to emit an event when the connection is closed.
|
|
6982
|
+
* Do not forget to unsubscribe the observable when you don't need it anymore.
|
|
6983
|
+
* @return `Observable<void>`
|
|
6984
|
+
*/
|
|
6985
|
+
onDisconnect() {
|
|
6986
|
+
return this.disconnected$.asObservable();
|
|
6827
6987
|
}
|
|
6828
6988
|
/**
|
|
6829
|
-
*
|
|
6830
|
-
*
|
|
6989
|
+
* Event responsable to emit an event when the connection is reestablished.
|
|
6990
|
+
* Do not forget to unsubscribe the observable when you don't need it anymore.
|
|
6991
|
+
* @return `Observable<void>`
|
|
6992
|
+
*/
|
|
6993
|
+
onReconnect() {
|
|
6994
|
+
return this.reconnected$.asObservable();
|
|
6995
|
+
}
|
|
6996
|
+
/**
|
|
6997
|
+
* Event responsable to emit an event when an error ocurred.
|
|
6998
|
+
* Do not forget to unsubscribe the observable when you don't need it anymore.
|
|
6999
|
+
* @return `Observable<FrameImpl>`
|
|
6831
7000
|
*/
|
|
6832
7001
|
onError() {
|
|
6833
7002
|
return this.error$.asObservable();
|
|
6834
7003
|
}
|
|
6835
7004
|
/**
|
|
6836
|
-
*
|
|
6837
|
-
*
|
|
6838
|
-
* @
|
|
6839
|
-
* @param {
|
|
6840
|
-
* @
|
|
6841
|
-
* @return Um Observable<T> que emite notificações toda vez que o respectivo evento é publicado.
|
|
7005
|
+
* Event responsible to emit an event when a primitive is called.
|
|
7006
|
+
* Do not forget to unsubscribe the observable when you don't need it anymore.
|
|
7007
|
+
* @typeParam `<T>` Object type that will be used in the observable for the `data` property.
|
|
7008
|
+
* @param {OnEventOptions} options Configurations for the event.
|
|
7009
|
+
* @return `Observable<PrimitiveEvent<T>>` Observable that emits an event when the service calls the primitive.
|
|
6842
7010
|
*/
|
|
6843
7011
|
onEvent(options) {
|
|
6844
|
-
this.connect();
|
|
6845
7012
|
const { domain, service, primitive } = options;
|
|
6846
|
-
const key = this.
|
|
7013
|
+
const key = this.buildPrimitiveManagerKey(domain, service, primitive);
|
|
6847
7014
|
if (this.primitiveManagers.has(key)) {
|
|
6848
|
-
return this.primitiveManagers.get(key).
|
|
7015
|
+
return this.primitiveManagers.get(key).getEventObservable();
|
|
6849
7016
|
}
|
|
6850
|
-
const primitiveManager =
|
|
6851
|
-
domain: domain,
|
|
6852
|
-
service: service,
|
|
6853
|
-
primitive: primitive,
|
|
6854
|
-
stompSubscriptions: [],
|
|
6855
|
-
event$: new Subject(),
|
|
6856
|
-
subscribed$: new BehaviorSubject(false)
|
|
6857
|
-
};
|
|
7017
|
+
const primitiveManager = new PrimitiveManager(domain, service, primitive);
|
|
6858
7018
|
this.primitiveManagers.set(key, primitiveManager);
|
|
6859
|
-
this.
|
|
6860
|
-
.
|
|
6861
|
-
|
|
6862
|
-
|
|
7019
|
+
this.connect().then(() => {
|
|
7020
|
+
this.onConnect()
|
|
7021
|
+
.pipe(take(1))
|
|
7022
|
+
.subscribe(() => {
|
|
7023
|
+
this.createStompSubscriptions(primitiveManager);
|
|
7024
|
+
});
|
|
6863
7025
|
});
|
|
6864
|
-
return primitiveManager
|
|
6865
|
-
.
|
|
6866
|
-
.pipe(finalize(() => this.
|
|
7026
|
+
return primitiveManager
|
|
7027
|
+
.getEventObservable()
|
|
7028
|
+
.pipe(finalize(() => this.unsubscribePrimitiveOnFinalize(primitiveManager)));
|
|
6867
7029
|
}
|
|
6868
|
-
/**
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
|
|
6876
|
-
|
|
6877
|
-
|
|
6878
|
-
|
|
6879
|
-
|
|
7030
|
+
/**
|
|
7031
|
+
* Event responsible to emit an event when a subscription is created for the primitive.
|
|
7032
|
+
* Do not forget to unsubscribe the observable when you don't need it anymore.
|
|
7033
|
+
* @param {OnEventOptions} options Configurations for the event.
|
|
7034
|
+
* Observable responsável por emitir uma notificação após o subscribe do evento pela primeira vez.
|
|
7035
|
+
* @return `Observable<boolean>` Observable that emits an event when the service calls the primitive.
|
|
7036
|
+
*/
|
|
7037
|
+
onSubscribe(options) {
|
|
7038
|
+
const { domain, service, primitive } = options;
|
|
7039
|
+
const key = this.buildPrimitiveManagerKey(domain, service, primitive);
|
|
7040
|
+
return this.onConnect().pipe(take(1), switchMap(() => {
|
|
7041
|
+
if (this.primitiveManagers.has(key)) {
|
|
7042
|
+
return this.primitiveManagers
|
|
7043
|
+
.get(key)
|
|
7044
|
+
.getSubscriptionObservable()
|
|
7045
|
+
.pipe(take(1));
|
|
7046
|
+
}
|
|
7047
|
+
return this.subscribed$.asObservable().pipe(filter((primitiveManager) => {
|
|
7048
|
+
return this.buildPrimitiveManagerKey(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive) === key;
|
|
7049
|
+
}), map(() => true), take(1));
|
|
7050
|
+
}));
|
|
6880
7051
|
}
|
|
6881
|
-
|
|
6882
|
-
|
|
6883
|
-
if (this.isConnected || this.isConnecting)
|
|
7052
|
+
debug(message, ...optionalParams) {
|
|
7053
|
+
if (!this.debugEnable) {
|
|
6884
7054
|
return;
|
|
6885
|
-
|
|
6886
|
-
|
|
6887
|
-
this._stompClient.connect({}, () => {
|
|
6888
|
-
this.isConnecting = false;
|
|
6889
|
-
this.isConnected = true;
|
|
6890
|
-
if (this.wasConnected) {
|
|
6891
|
-
this.reconnectPrimitives();
|
|
6892
|
-
this.connected$.next(true);
|
|
6893
|
-
this.reconnect$.next();
|
|
6894
|
-
}
|
|
6895
|
-
else {
|
|
6896
|
-
this.wasConnected = true;
|
|
6897
|
-
this.connected$.next(true);
|
|
6898
|
-
}
|
|
6899
|
-
}, (error) => {
|
|
6900
|
-
this.isConnected = false;
|
|
6901
|
-
this.connected$.next(false);
|
|
6902
|
-
this.error$.next(error);
|
|
6903
|
-
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 }))))
|
|
6904
|
-
.pipe(take(1))
|
|
6905
|
-
.subscribe({
|
|
6906
|
-
next: ({ wasDisconnected }) => {
|
|
6907
|
-
if (!wasDisconnected &&
|
|
6908
|
-
!(this.isConnected || this.isConnecting)) {
|
|
6909
|
-
this.connect();
|
|
6910
|
-
}
|
|
6911
|
-
}
|
|
6912
|
-
});
|
|
6913
|
-
});
|
|
7055
|
+
}
|
|
7056
|
+
console.log('WS debug: ' + message, ...optionalParams);
|
|
6914
7057
|
}
|
|
6915
|
-
|
|
6916
|
-
|
|
7058
|
+
info(message) {
|
|
7059
|
+
console.info('WS info: ' + message);
|
|
7060
|
+
}
|
|
7061
|
+
handleOnConnected() {
|
|
7062
|
+
this.info('Webscoket connected');
|
|
7063
|
+
this.connected$.next(true);
|
|
7064
|
+
if (this.lostConnection) {
|
|
7065
|
+
this.info('Webscoket reconnected, recriating subscriptions');
|
|
7066
|
+
this.handleReconnection();
|
|
7067
|
+
}
|
|
7068
|
+
}
|
|
7069
|
+
handleOnDisconnect() {
|
|
7070
|
+
this.info('Webscoket disconnected');
|
|
7071
|
+
this.connected$.next(false);
|
|
7072
|
+
this.disconnected$.next();
|
|
7073
|
+
}
|
|
7074
|
+
handleOnWebSocketClose(data) {
|
|
7075
|
+
if (data.reason && data.reason.toLowerCase().indexOf("go away") !== -1) {
|
|
7076
|
+
this.lostConnection = true;
|
|
7077
|
+
this.handleError('AuthenticationError', new FrameImpl({
|
|
7078
|
+
command: data.type,
|
|
7079
|
+
headers: {
|
|
7080
|
+
message: data.reason
|
|
7081
|
+
}
|
|
7082
|
+
}));
|
|
6917
7083
|
return;
|
|
6918
7084
|
}
|
|
6919
|
-
|
|
6920
|
-
|
|
6921
|
-
stompSubscription.unsubscribe();
|
|
6922
|
-
}
|
|
7085
|
+
if (data.wasClean) {
|
|
7086
|
+
return;
|
|
6923
7087
|
}
|
|
6924
|
-
|
|
6925
|
-
|
|
7088
|
+
this.lostConnection = true;
|
|
7089
|
+
}
|
|
7090
|
+
handleOnStompError(data) {
|
|
7091
|
+
this.handleError('StompError', data);
|
|
7092
|
+
if (this.isAuthenticationError(data)) {
|
|
7093
|
+
this.info('Authentication error, recriating subscriptions');
|
|
7094
|
+
this.handleReconnection();
|
|
6926
7095
|
}
|
|
6927
|
-
this.primitiveManagers.clear();
|
|
6928
|
-
this._stompClient.disconnect();
|
|
6929
|
-
this._stompClient.deactivate();
|
|
6930
|
-
this.isConnected = false;
|
|
6931
|
-
this.isConnecting = false;
|
|
6932
|
-
this.wasConnected = false;
|
|
6933
|
-
this.connected$.next(false);
|
|
6934
|
-
this.disconnect$.next();
|
|
6935
|
-
}
|
|
6936
|
-
/** @private */
|
|
6937
|
-
getSubscriptionUrlWithToken(domain, service, primitive) {
|
|
6938
|
-
const tenant = WebsocketService_1.TOKEN
|
|
6939
|
-
? WebsocketService_1.TOKEN.username.split('@')[1]
|
|
6940
|
-
: null;
|
|
6941
|
-
const token = WebsocketService_1.TOKEN
|
|
6942
|
-
? WebsocketService_1.TOKEN.access_token
|
|
6943
|
-
: null;
|
|
6944
|
-
return `/topic/${tenant}/${token}/${domain}/${service}/${primitive}`;
|
|
6945
|
-
}
|
|
6946
|
-
/** @private */
|
|
6947
|
-
getSubscriptionUrlWithoutToken(domain, service, primitive) {
|
|
6948
|
-
const tenant = WebsocketService_1.TOKEN
|
|
6949
|
-
? WebsocketService_1.TOKEN.username.split('@')[1]
|
|
6950
|
-
: null;
|
|
6951
|
-
return `/topic/${tenant}/${domain}/${service}/${primitive}`;
|
|
6952
7096
|
}
|
|
6953
|
-
|
|
6954
|
-
|
|
6955
|
-
|
|
6956
|
-
|
|
6957
|
-
|
|
6958
|
-
}
|
|
7097
|
+
isAuthenticationError(data) {
|
|
7098
|
+
var _a;
|
|
7099
|
+
const errorMessage = (_a = data === null || data === void 0 ? void 0 : data.headers) === null || _a === void 0 ? void 0 : _a.message;
|
|
7100
|
+
if (!errorMessage) {
|
|
7101
|
+
return false;
|
|
7102
|
+
}
|
|
7103
|
+
return errorMessage.toLowerCase().indexOf('forbiddenexception') !== -1;
|
|
7104
|
+
}
|
|
7105
|
+
handleOnWebSocketError(data) {
|
|
7106
|
+
this.handleError('WebSocketError', data);
|
|
7107
|
+
}
|
|
7108
|
+
handleError(origin, data) {
|
|
7109
|
+
console.error(origin, data);
|
|
7110
|
+
this.error$.next(data);
|
|
6959
7111
|
}
|
|
6960
|
-
|
|
6961
|
-
|
|
6962
|
-
|
|
6963
|
-
this.
|
|
6964
|
-
this._stompClient.debug = () => null;
|
|
7112
|
+
handleReconnection() {
|
|
7113
|
+
this.lostConnection = false;
|
|
7114
|
+
this.reconnectPrimitives();
|
|
7115
|
+
this.reconnected$.next();
|
|
6965
7116
|
}
|
|
6966
|
-
/** @private */
|
|
6967
7117
|
reconnectPrimitives() {
|
|
6968
7118
|
for (const primitiveManager of this.primitiveManagers.values()) {
|
|
6969
7119
|
this.createStompSubscriptions(primitiveManager);
|
|
6970
7120
|
}
|
|
6971
7121
|
}
|
|
6972
|
-
|
|
7122
|
+
buildSubscriptionUrlWithToken(domain, service, primitive) {
|
|
7123
|
+
const authToken = this.userInformationService.getAuthToken();
|
|
7124
|
+
const tenant = this.userInformationService.getTenantDomain();
|
|
7125
|
+
return `/topic/${tenant}/${authToken}/${domain}/${service}/${primitive}`;
|
|
7126
|
+
}
|
|
7127
|
+
getSubscriptionUrlWithoutToken(domain, service, primitive) {
|
|
7128
|
+
const tenant = this.userInformationService.getTenantDomain();
|
|
7129
|
+
return `/topic/${tenant}/${domain}/${service}/${primitive}`;
|
|
7130
|
+
}
|
|
7131
|
+
buildPrimitiveManagerKey(domain, service, primitive) {
|
|
7132
|
+
return `${domain}/${service}/${primitive}`;
|
|
7133
|
+
}
|
|
7134
|
+
unsubscribePrimitiveOnFinalize(primitiveManager) {
|
|
7135
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
7136
|
+
if (primitiveManager.hasObservers()) {
|
|
7137
|
+
return;
|
|
7138
|
+
}
|
|
7139
|
+
primitiveManager.unsubscribe();
|
|
7140
|
+
const key = this.buildPrimitiveManagerKey(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
7141
|
+
this.primitiveManagers.delete(key);
|
|
7142
|
+
yield this.disconnectIfNoMoreObservables();
|
|
7143
|
+
});
|
|
7144
|
+
}
|
|
7145
|
+
disconnectIfNoMoreObservables() {
|
|
7146
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
7147
|
+
if (this.getObserversCount() === 0) {
|
|
7148
|
+
this.debug('Manually disconnecting because there are no more observers');
|
|
7149
|
+
yield this.disconnect();
|
|
7150
|
+
}
|
|
7151
|
+
});
|
|
7152
|
+
}
|
|
6973
7153
|
getObserversCount() {
|
|
6974
7154
|
let observersCount = 0;
|
|
6975
|
-
|
|
6976
|
-
observersCount += primitiveManager.
|
|
6977
|
-
}
|
|
7155
|
+
this.primitiveManagers.forEach(primitiveManager => {
|
|
7156
|
+
observersCount += primitiveManager.getObserversCount();
|
|
7157
|
+
});
|
|
6978
7158
|
return observersCount;
|
|
6979
7159
|
}
|
|
6980
|
-
|
|
6981
|
-
|
|
6982
|
-
|
|
6983
|
-
|
|
6984
|
-
|
|
6985
|
-
return;
|
|
6986
|
-
primitiveManager.event$.complete();
|
|
6987
|
-
for (const stompSubscription of primitiveManager.stompSubscriptions) {
|
|
6988
|
-
stompSubscription.unsubscribe();
|
|
6989
|
-
}
|
|
6990
|
-
primitiveManager.subscribed$.complete();
|
|
6991
|
-
const key = this.getPrimitiveManagerKey(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
6992
|
-
this.primitiveManagers.delete(key);
|
|
6993
|
-
this.disconnect();
|
|
7160
|
+
createStompSubscription(destination, primitiveManager) {
|
|
7161
|
+
return this.stompClient.subscribe(destination, (message) => {
|
|
7162
|
+
const event = JSON.parse(message.body || '{}');
|
|
7163
|
+
primitiveManager.fireEvent(event);
|
|
7164
|
+
});
|
|
6994
7165
|
}
|
|
6995
|
-
|
|
6996
|
-
|
|
6997
|
-
|
|
7166
|
+
createStompSubscriptions(primitiveManager) {
|
|
7167
|
+
const subscriptionUrlWithToken = this.buildSubscriptionUrlWithToken(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
7168
|
+
const subscriptionUrlWithoutToken = this.getSubscriptionUrlWithoutToken(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
7169
|
+
const stompSubscriptionWithToken = this.createStompSubscription(subscriptionUrlWithToken, primitiveManager);
|
|
7170
|
+
const stompSubscriptionWithoutToken = this.createStompSubscription(subscriptionUrlWithoutToken, primitiveManager);
|
|
7171
|
+
primitiveManager.subscribe(stompSubscriptionWithToken, stompSubscriptionWithoutToken);
|
|
7172
|
+
this.subscribed$.next(primitiveManager);
|
|
7173
|
+
}
|
|
7174
|
+
getSubscriptionUrl() {
|
|
7175
|
+
return `${this.userInformationService.getWebSocketUrl()}/subscription`;
|
|
6998
7176
|
}
|
|
6999
7177
|
};
|
|
7000
|
-
WebsocketService.
|
|
7001
|
-
|
|
7002
|
-
|
|
7003
|
-
WebsocketService
|
|
7004
|
-
|
|
7005
|
-
WebsocketService.TOKEN_COOKIE = 'com.senior.token';
|
|
7006
|
-
/** @private */
|
|
7007
|
-
WebsocketService.TOKEN = JSON.parse(get(WebsocketService_1.TOKEN_COOKIE) || '{}');
|
|
7008
|
-
/** @private */
|
|
7009
|
-
WebsocketService.WEBSOCKET_URL = get(WebsocketService_1.BASE_URL_COOKIE) + '/websocket/';
|
|
7010
|
-
WebsocketService.ɵprov = ɵɵdefineInjectable({ factory: function WebsocketService_Factory() { return new WebsocketService(); }, token: WebsocketService, providedIn: "root" });
|
|
7011
|
-
WebsocketService = WebsocketService_1 = __decorate([
|
|
7178
|
+
WebsocketService.ctorParameters = () => [
|
|
7179
|
+
{ type: UserInformationService }
|
|
7180
|
+
];
|
|
7181
|
+
WebsocketService.ɵprov = ɵɵdefineInjectable({ factory: function WebsocketService_Factory() { return new WebsocketService(ɵɵinject(UserInformationService)); }, token: WebsocketService, providedIn: "root" });
|
|
7182
|
+
WebsocketService = __decorate([
|
|
7012
7183
|
Injectable({
|
|
7013
7184
|
providedIn: 'root'
|
|
7014
7185
|
})
|
|
@@ -7159,5 +7330,5 @@ var ModulesEnum;
|
|
|
7159
7330
|
* Generated bundle index. Do not edit.
|
|
7160
7331
|
*/
|
|
7161
7332
|
|
|
7162
|
-
export { AgreementLookup, BankLookup, BeneficioFiscalLookup, BreadcrumbComponent, BreadcrumbModule, Breakpoints, ContaInternaFilialLookup, CountryLookup, CplTriNotaSaidaE001EndLookup, CplTriNotaSaidaE001PesLookup, CplTriNotaSaidaE001TnsLookup, CplTriNotaSaidaE007UfsLookup, CplTriNotaSaidaE008RaiLookup, CplTriNotaSaidaE015MedLookup, CplTriNotaSaidaE020SnfLookup, CplTriNotaSaidaE024MsgLookup, CplTriNotaSaidaE028CpgLookup, CplTriNotaSaidaE032EdcLookup, CplTriNotaSaidaE051DisLookup, CplTriNotaSaidaE066FpgLookup, CplTriNotaSaidaE070EmpLookup, CplTriNotaSaidaE070FilLookup, CplTriNotaSaidaE075DerLookup, CplTriNotaSaidaE080SerLookup, CplTriNotaSaidaNaturezaReceitaPisCofinsLookup, CplTriNotaSaidaNcmLookup, CplTriNotaSaidaNfEntradaLookup, CplTriNotaSaidaNfSaidaLookup, CurrencyLookup, DocumentoLookup, E001EndLookup, E001PesLookup, E001TnsLookup, E001TnsSupEstLookup, E002TptLookup, E007UfsLookup, E008CepLookup, E008RaiLookup, E012FamLookup, E015MedLookup, E020SnfLookup, E021MotLookup, E023CrpLookup, E024MsgLookup, E027EqiLookup, E027StrLookup, E028CpgLookup, E030AgeLookup, E030BanLookup, E031MoeLookup, E032EdcLookup, E035OcrLookup, E036InsLookup, E039PorLookup, E043MpcLookup, E043PcmLookup, E044CcuFinRatDepLookup, E044CcuLookup, E045PlaLookup, E046HpdLookup, E047NtgLookup, E048FctLookup, E048SfcLookup, E051DisLookup, E066FpgLookup, E067FinLookup, E069GreLookup, E070EmpLookup, E070EntLookup, E070FilLookup, E073PesLookup, E073VeiLookup, E075DerLookup, E080SerLookup, E081TabLookup, E082TprLookup, E085PesLookup, E089DocLookup, E090HrpComGerLookup, E090PesLookup, E091PlfFinRatLookup, E095PesLookup, E099UsuComGerLookup, E099UsuSupCprLookup, E140InsLookup, E140NfsLookup, E200LotLookup, E200SerLookup, E205DepLookup, E210DxpE075DerLookup, E210DxpLookup, E301TcrLookup, E403FprLookup, E420IcpLookup, E420IpcLookup, E420OcpLookup, E501TcpLookup, E600CcoLookup, E640LotLookup, EntityPersonProductLookup, EnumLogicalOperator, EquipmentLookup, ErpLookups, ErpLookupsModule, ErpPolling, ExportUtils, FiltersStorageService, FormUtilsService, HTTP_STATUS_CODE, LigacaoItemFornecedorLookup, LookupValidationUtils, ModulesEnum, NcmLookup, NotaFiscalEntradaLookup, NpsService, ParametersLookup, ProdutoServicoLookup, QuantidadeDisponivelDemandaLookup, RequisicaoLookup, SegmentoLookup, TypeTaxesLookup, UnidadeMedidaLookup, UtilsModule, VerifyModulePermission, VerifyModulePermissions, WebsocketService, naturezaReceitaPisCofins, ɵ0, ErpLookupsService as ɵa, EnumAnaSin as ɵb, EnumNatCtb as ɵc, StorageService as ɵd,
|
|
7333
|
+
export { AgreementLookup, BankLookup, BeneficioFiscalLookup, BreadcrumbComponent, BreadcrumbModule, Breakpoints, ContaInternaFilialLookup, CountryLookup, CplTriNotaSaidaE001EndLookup, CplTriNotaSaidaE001PesLookup, CplTriNotaSaidaE001TnsLookup, CplTriNotaSaidaE007UfsLookup, CplTriNotaSaidaE008RaiLookup, CplTriNotaSaidaE015MedLookup, CplTriNotaSaidaE020SnfLookup, CplTriNotaSaidaE024MsgLookup, CplTriNotaSaidaE028CpgLookup, CplTriNotaSaidaE032EdcLookup, CplTriNotaSaidaE051DisLookup, CplTriNotaSaidaE066FpgLookup, CplTriNotaSaidaE070EmpLookup, CplTriNotaSaidaE070FilLookup, CplTriNotaSaidaE075DerLookup, CplTriNotaSaidaE080SerLookup, CplTriNotaSaidaNaturezaReceitaPisCofinsLookup, CplTriNotaSaidaNcmLookup, CplTriNotaSaidaNfEntradaLookup, CplTriNotaSaidaNfSaidaLookup, CurrencyLookup, DocumentoLookup, E001EndLookup, E001PesLookup, E001TnsLookup, E001TnsSupEstLookup, E002TptLookup, E007UfsLookup, E008CepLookup, E008RaiLookup, E012FamLookup, E015MedLookup, E020SnfLookup, E021MotLookup, E023CrpLookup, E024MsgLookup, E027EqiLookup, E027StrLookup, E028CpgLookup, E030AgeLookup, E030BanLookup, E031MoeLookup, E032EdcLookup, E035OcrLookup, E036InsLookup, E039PorLookup, E043MpcLookup, E043PcmLookup, E044CcuFinRatDepLookup, E044CcuLookup, E045PlaLookup, E046HpdLookup, E047NtgLookup, E048FctLookup, E048SfcLookup, E051DisLookup, E066FpgLookup, E067FinLookup, E069GreLookup, E070EmpLookup, E070EntLookup, E070FilLookup, E073PesLookup, E073VeiLookup, E075DerLookup, E080SerLookup, E081TabLookup, E082TprLookup, E085PesLookup, E089DocLookup, E090HrpComGerLookup, E090PesLookup, E091PlfFinRatLookup, E095PesLookup, E099UsuComGerLookup, E099UsuSupCprLookup, E140InsLookup, E140NfsLookup, E200LotLookup, E200SerLookup, E205DepLookup, E210DxpE075DerLookup, E210DxpLookup, E301TcrLookup, E403FprLookup, E420IcpLookup, E420IpcLookup, E420OcpLookup, E501TcpLookup, E600CcoLookup, E640LotLookup, EntityPersonProductLookup, EnumLogicalOperator, EquipmentLookup, ErpLookups, ErpLookupsModule, ErpPolling, ExportUtils, FiltersStorageService, FormUtilsService, HTTP_STATUS_CODE, LigacaoItemFornecedorLookup, LookupValidationUtils, ModulesEnum, NcmLookup, NotaFiscalEntradaLookup, NpsService, ParametersLookup, PrimitiveManager, ProdutoServicoLookup, QuantidadeDisponivelDemandaLookup, RequisicaoLookup, SegmentoLookup, TypeTaxesLookup, UnidadeMedidaLookup, UtilsModule, VerifyModulePermission, VerifyModulePermissions, WebsocketService, naturezaReceitaPisCofins, ɵ0, ErpLookupsService as ɵa, EnumAnaSin as ɵb, EnumNatCtb as ɵc, StorageService as ɵd, UserInformationService as ɵe, VerifyModulePermissionService as ɵf, VerifyModulePermissionsService as ɵg };
|
|
7163
7334
|
//# sourceMappingURL=senior-gestao-empresarial-angular-components.js.map
|