@senior-gestao-empresarial/angular-components 6.11.5-f1ae0f56-eaa0-41bd-bf14-efca8153a452 → 6.12.0-bea9aaec-b4b5-4e5b-b8eb-155b7aa8d5aa
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 +414 -251
- 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/permissions/index.d.ts +1 -0
- package/components/permissions/verify-module-permissions-service.d.ts +18 -0
- package/components/permissions/verify-module-permissions.d.ts +16 -0
- package/components/websocket/models/primitive-manager.d.ts +19 -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/permissions/index.js +2 -1
- package/esm2015/components/permissions/verify-module-permissions-service.js +26 -0
- package/esm2015/components/permissions/verify-module-permissions.js +51 -0
- package/esm2015/components/websocket/models/primitive-manager.js +39 -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 +233 -191
- package/esm2015/senior-gestao-empresarial-angular-components.js +4 -2
- package/esm5/components/permissions/index.js +2 -1
- package/esm5/components/permissions/verify-module-permissions-service.js +28 -0
- package/esm5/components/permissions/verify-module-permissions.js +53 -0
- package/esm5/components/websocket/models/primitive-manager.js +58 -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 +259 -252
- package/esm5/senior-gestao-empresarial-angular-components.js +4 -2
- package/fesm2015/senior-gestao-empresarial-angular-components.js +360 -190
- package/fesm2015/senior-gestao-empresarial-angular-components.js.map +1 -1
- package/fesm5/senior-gestao-empresarial-angular-components.js +411 -251
- 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 -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, 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 } 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,354 @@ NpsService = __decorate([
|
|
|
6768
6768
|
})
|
|
6769
6769
|
], NpsService);
|
|
6770
6770
|
|
|
6771
|
-
var
|
|
6772
|
-
let
|
|
6773
|
-
|
|
6774
|
-
|
|
6775
|
-
|
|
6776
|
-
|
|
6777
|
-
|
|
6778
|
-
|
|
6779
|
-
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
|
|
6771
|
+
var UserInformationService_1;
|
|
6772
|
+
let UserInformationService = UserInformationService_1 = class UserInformationService {
|
|
6773
|
+
getAuthToken() {
|
|
6774
|
+
const cookieValue = get(UserInformationService_1.TOKEN_COOKIE_KEY) || '{}';
|
|
6775
|
+
const authToken = JSON.parse(cookieValue);
|
|
6776
|
+
return authToken.access_token;
|
|
6777
|
+
}
|
|
6778
|
+
getTenantDomain() {
|
|
6779
|
+
const cookieValue = get(UserInformationService_1.TOKEN_COOKIE_KEY) || '{}';
|
|
6780
|
+
const authToken = JSON.parse(cookieValue);
|
|
6781
|
+
return authToken.username.split('@')[1];
|
|
6782
|
+
}
|
|
6783
|
+
getWebSocketUrl() {
|
|
6784
|
+
let baseUrl = get(UserInformationService_1.BASE_URL_COOKIE_KEY);
|
|
6785
|
+
if (!baseUrl.endsWith('/')) {
|
|
6786
|
+
baseUrl += '/';
|
|
6787
|
+
}
|
|
6788
|
+
return baseUrl + 'websocket';
|
|
6789
|
+
}
|
|
6790
|
+
};
|
|
6791
|
+
UserInformationService.BASE_URL_COOKIE_KEY = 'com.senior.base.url';
|
|
6792
|
+
UserInformationService.TOKEN_COOKIE_KEY = 'com.senior.token';
|
|
6793
|
+
UserInformationService.ɵprov = ɵɵdefineInjectable({ factory: function UserInformationService_Factory() { return new UserInformationService(); }, token: UserInformationService, providedIn: "root" });
|
|
6794
|
+
UserInformationService = UserInformationService_1 = __decorate([
|
|
6795
|
+
Injectable({
|
|
6796
|
+
providedIn: 'root'
|
|
6797
|
+
})
|
|
6798
|
+
], UserInformationService);
|
|
6799
|
+
|
|
6800
|
+
class PrimitiveManager {
|
|
6801
|
+
constructor(domain, service, primitive) {
|
|
6802
|
+
this.domain = domain;
|
|
6803
|
+
this.service = service;
|
|
6804
|
+
this.primitive = primitive;
|
|
6805
|
+
this.stompSubscriptions = [];
|
|
6806
|
+
this.event$ = new Subject();
|
|
6807
|
+
this.subscribed$ = new BehaviorSubject(false);
|
|
6808
|
+
}
|
|
6809
|
+
unsubscribe() {
|
|
6810
|
+
this.event$.complete();
|
|
6811
|
+
for (const stompSubscription of this.stompSubscriptions) {
|
|
6812
|
+
stompSubscription.unsubscribe();
|
|
6813
|
+
}
|
|
6814
|
+
this.subscribed$.complete();
|
|
6815
|
+
}
|
|
6816
|
+
fireEvent(event) {
|
|
6817
|
+
this.event$.next(event);
|
|
6818
|
+
}
|
|
6819
|
+
subscribe(...subscriptions) {
|
|
6820
|
+
this.stompSubscriptions.push(...subscriptions);
|
|
6821
|
+
this.subscribed$.next(true);
|
|
6822
|
+
}
|
|
6823
|
+
getEventObservable() {
|
|
6824
|
+
return this.event$.asObservable();
|
|
6825
|
+
}
|
|
6826
|
+
getSubscriptionObservable() {
|
|
6827
|
+
return this.subscribed$.asObservable();
|
|
6828
|
+
}
|
|
6829
|
+
hasObservers() {
|
|
6830
|
+
// @IMPORTANT: Replace .observers.length === 1 with .observed in rxjs 7.0+
|
|
6831
|
+
return this.event$.observers.length > 1;
|
|
6832
|
+
}
|
|
6833
|
+
getObserversCount() {
|
|
6834
|
+
return this.event$.observers.length;
|
|
6835
|
+
}
|
|
6836
|
+
}
|
|
6837
|
+
|
|
6838
|
+
const RECONNECT_INTERVAL_MILLISECONDS = 3000;
|
|
6839
|
+
const CONNECTION_TIMEOUT_MILLISECONDS = 5000;
|
|
6840
|
+
let WebsocketService = class WebsocketService {
|
|
6841
|
+
constructor(userInformationService) {
|
|
6842
|
+
this.userInformationService = userInformationService;
|
|
6783
6843
|
this.connected$ = new BehaviorSubject(false);
|
|
6784
|
-
|
|
6785
|
-
this.
|
|
6786
|
-
/** @private */
|
|
6787
|
-
this.reconnect$ = new Subject();
|
|
6788
|
-
/** @private */
|
|
6844
|
+
this.disconnected$ = new Subject();
|
|
6845
|
+
this.reconnected$ = new Subject();
|
|
6789
6846
|
this.error$ = new Subject();
|
|
6790
6847
|
this.subscribed$ = new Subject();
|
|
6848
|
+
this.primitiveManagers = new Map();
|
|
6849
|
+
this.debugEnable = false;
|
|
6850
|
+
this.lostConnection = false;
|
|
6791
6851
|
}
|
|
6792
6852
|
/**
|
|
6793
|
-
*
|
|
6794
|
-
* @return Um `Observable<void>` que emite uma notificação quando a conexão websocket é estabelecida pela primeira vez.
|
|
6853
|
+
* Enables stompjs debug logs and additional info
|
|
6795
6854
|
*/
|
|
6796
|
-
|
|
6797
|
-
|
|
6855
|
+
enableDebugLogs() {
|
|
6856
|
+
this.debugEnable = true;
|
|
6798
6857
|
}
|
|
6799
6858
|
/**
|
|
6800
|
-
*
|
|
6801
|
-
* @return Um `Observable<void>` que emite uma notificação quando a conexão é desconectada.
|
|
6859
|
+
* Manually starts the connection
|
|
6802
6860
|
*/
|
|
6803
|
-
|
|
6804
|
-
|
|
6861
|
+
connect() {
|
|
6862
|
+
if (this.isConnected() || this.isConnecting()) {
|
|
6863
|
+
return;
|
|
6864
|
+
}
|
|
6865
|
+
this.lostConnection = false;
|
|
6866
|
+
const stompConfig = {
|
|
6867
|
+
webSocketFactory: () => {
|
|
6868
|
+
return new SockJS(this.getSubscriptionUrl(), null, {
|
|
6869
|
+
timeout: CONNECTION_TIMEOUT_MILLISECONDS
|
|
6870
|
+
});
|
|
6871
|
+
},
|
|
6872
|
+
connectionTimeout: CONNECTION_TIMEOUT_MILLISECONDS,
|
|
6873
|
+
reconnectDelay: RECONNECT_INTERVAL_MILLISECONDS,
|
|
6874
|
+
debug: this.debug.bind(this),
|
|
6875
|
+
onConnect: this.handleOnConnected.bind(this),
|
|
6876
|
+
onDisconnect: this.handleOnDisconnect.bind(this),
|
|
6877
|
+
onWebSocketClose: this.handleOnWebSocketClose.bind(this),
|
|
6878
|
+
onStompError: this.handleOnStompError.bind(this),
|
|
6879
|
+
onWebSocketError: this.handleOnWebSocketError.bind(this)
|
|
6880
|
+
};
|
|
6881
|
+
this.debug('Connecting the Webscoket');
|
|
6882
|
+
this.stompClient = new Client(stompConfig);
|
|
6883
|
+
this.stompClient.activate();
|
|
6805
6884
|
}
|
|
6806
6885
|
/**
|
|
6807
|
-
*
|
|
6808
|
-
* @return Um `Observable<void>` que emite uma notificação quando a conexão é reconectada.
|
|
6886
|
+
* Manually disconnect the websocket. The reconnect loop will be stopped.
|
|
6809
6887
|
*/
|
|
6810
|
-
|
|
6811
|
-
return this
|
|
6888
|
+
disconnect() {
|
|
6889
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6890
|
+
for (const primitiveManager of this.primitiveManagers.values()) {
|
|
6891
|
+
primitiveManager.unsubscribe();
|
|
6892
|
+
}
|
|
6893
|
+
this.primitiveManagers.clear();
|
|
6894
|
+
if (this.stompClient) {
|
|
6895
|
+
yield this.stompClient.deactivate();
|
|
6896
|
+
this.stompClient = null;
|
|
6897
|
+
}
|
|
6898
|
+
this.connected$.next(false);
|
|
6899
|
+
});
|
|
6812
6900
|
}
|
|
6813
6901
|
/**
|
|
6814
|
-
*
|
|
6815
|
-
* @return
|
|
6902
|
+
* Check if the websocket is connected
|
|
6903
|
+
* @return `boolean` representing if the websocket is connected
|
|
6816
6904
|
*/
|
|
6817
|
-
|
|
6818
|
-
|
|
6819
|
-
|
|
6820
|
-
|
|
6821
|
-
|
|
6822
|
-
|
|
6823
|
-
|
|
6824
|
-
|
|
6825
|
-
|
|
6826
|
-
|
|
6905
|
+
isConnected() {
|
|
6906
|
+
if (!this.stompClient) {
|
|
6907
|
+
return false;
|
|
6908
|
+
}
|
|
6909
|
+
return this.stompClient.connected;
|
|
6910
|
+
}
|
|
6911
|
+
/**
|
|
6912
|
+
* Check if the websocket is tring to connect
|
|
6913
|
+
* @return `boolean` representing if the websocket status
|
|
6914
|
+
*/
|
|
6915
|
+
isConnecting() {
|
|
6916
|
+
if (!this.stompClient) {
|
|
6917
|
+
return false;
|
|
6918
|
+
}
|
|
6919
|
+
return !this.stompClient.connected && this.stompClient.active;
|
|
6920
|
+
}
|
|
6921
|
+
/**
|
|
6922
|
+
* Event responsable to emit an event when the connection is established.
|
|
6923
|
+
* Do not forget to unsubscribe the observable when you don't need it anymore.
|
|
6924
|
+
* @return `Observable<boolean>`
|
|
6925
|
+
*/
|
|
6926
|
+
onConnect() {
|
|
6927
|
+
return this.connected$.asObservable()
|
|
6928
|
+
.pipe(filter(p => p === true));
|
|
6929
|
+
}
|
|
6930
|
+
/**
|
|
6931
|
+
* Event responsable to emit an event when the connection is closed.
|
|
6932
|
+
* Do not forget to unsubscribe the observable when you don't need it anymore.
|
|
6933
|
+
* @return `Observable<void>`
|
|
6934
|
+
*/
|
|
6935
|
+
onDisconnect() {
|
|
6936
|
+
return this.disconnected$.asObservable();
|
|
6937
|
+
}
|
|
6938
|
+
/**
|
|
6939
|
+
* Event responsable to emit an event when the connection is reestablished.
|
|
6940
|
+
* Do not forget to unsubscribe the observable when you don't need it anymore.
|
|
6941
|
+
* @return `Observable<void>`
|
|
6942
|
+
*/
|
|
6943
|
+
onReconnect() {
|
|
6944
|
+
return this.reconnected$.asObservable();
|
|
6827
6945
|
}
|
|
6828
6946
|
/**
|
|
6829
|
-
*
|
|
6830
|
-
*
|
|
6947
|
+
* Event responsable to emit an event when an error ocurred.
|
|
6948
|
+
* Do not forget to unsubscribe the observable when you don't need it anymore.
|
|
6949
|
+
* @return `Observable<FrameImpl>`
|
|
6831
6950
|
*/
|
|
6832
6951
|
onError() {
|
|
6833
6952
|
return this.error$.asObservable();
|
|
6834
6953
|
}
|
|
6835
6954
|
/**
|
|
6836
|
-
*
|
|
6837
|
-
*
|
|
6838
|
-
* @
|
|
6839
|
-
* @param {
|
|
6840
|
-
* @
|
|
6841
|
-
* @return Um Observable<T> que emite notificações toda vez que o respectivo evento é publicado.
|
|
6955
|
+
* Event responsible to emit an event when a primitive is called.
|
|
6956
|
+
* Do not forget to unsubscribe the observable when you don't need it anymore.
|
|
6957
|
+
* @typeParam `<T>` Object type that will be used in the observable for the `data` property.
|
|
6958
|
+
* @param {OnEventOptions} options Configurations for the event.
|
|
6959
|
+
* @return `Observable<PrimitiveEvent<T>>` Observable that emits an event when the service calls the primitive.
|
|
6842
6960
|
*/
|
|
6843
6961
|
onEvent(options) {
|
|
6844
|
-
this.connect();
|
|
6845
6962
|
const { domain, service, primitive } = options;
|
|
6846
|
-
const key = this.
|
|
6963
|
+
const key = this.buildPrimitiveManagerKey(domain, service, primitive);
|
|
6847
6964
|
if (this.primitiveManagers.has(key)) {
|
|
6848
|
-
return this.primitiveManagers.get(key).
|
|
6965
|
+
return this.primitiveManagers.get(key).getEventObservable();
|
|
6849
6966
|
}
|
|
6850
|
-
const primitiveManager =
|
|
6851
|
-
domain: domain,
|
|
6852
|
-
service: service,
|
|
6853
|
-
primitive: primitive,
|
|
6854
|
-
stompSubscriptions: [],
|
|
6855
|
-
event$: new Subject(),
|
|
6856
|
-
subscribed$: new BehaviorSubject(false)
|
|
6857
|
-
};
|
|
6967
|
+
const primitiveManager = new PrimitiveManager(domain, service, primitive);
|
|
6858
6968
|
this.primitiveManagers.set(key, primitiveManager);
|
|
6969
|
+
this.connect();
|
|
6859
6970
|
this.onConnect()
|
|
6860
6971
|
.pipe(take(1))
|
|
6861
6972
|
.subscribe(() => {
|
|
6862
6973
|
this.createStompSubscriptions(primitiveManager);
|
|
6863
6974
|
});
|
|
6864
|
-
return primitiveManager
|
|
6865
|
-
.
|
|
6866
|
-
.pipe(finalize(() => this.
|
|
6975
|
+
return primitiveManager
|
|
6976
|
+
.getEventObservable()
|
|
6977
|
+
.pipe(finalize(() => this.unsubscribePrimitiveOnFinalize(primitiveManager)));
|
|
6867
6978
|
}
|
|
6868
|
-
/**
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
|
|
6876
|
-
|
|
6877
|
-
|
|
6878
|
-
|
|
6879
|
-
this.
|
|
6979
|
+
/**
|
|
6980
|
+
* Event responsible to emit an event when a subscription is created for the primitive.
|
|
6981
|
+
* Do not forget to unsubscribe the observable when you don't need it anymore.
|
|
6982
|
+
* @param {OnEventOptions} options Configurations for the event.
|
|
6983
|
+
* Observable responsável por emitir uma notificação após o subscribe do evento pela primeira vez.
|
|
6984
|
+
* @return `Observable<boolean>` Observable that emits an event when the service calls the primitive.
|
|
6985
|
+
*/
|
|
6986
|
+
onSubscribe(options) {
|
|
6987
|
+
const { domain, service, primitive } = options;
|
|
6988
|
+
const key = this.buildPrimitiveManagerKey(domain, service, primitive);
|
|
6989
|
+
this.connect();
|
|
6990
|
+
return this.onConnect().pipe(take(1), switchMap(() => {
|
|
6991
|
+
if (this.primitiveManagers.has(key)) {
|
|
6992
|
+
return this.primitiveManagers
|
|
6993
|
+
.get(key)
|
|
6994
|
+
.getSubscriptionObservable()
|
|
6995
|
+
.pipe(take(1));
|
|
6996
|
+
}
|
|
6997
|
+
return this.subscribed$.asObservable().pipe(filter((primitiveManager) => {
|
|
6998
|
+
return this.buildPrimitiveManagerKey(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive) === key;
|
|
6999
|
+
}), map(() => true), take(1));
|
|
7000
|
+
}));
|
|
6880
7001
|
}
|
|
6881
|
-
|
|
6882
|
-
|
|
6883
|
-
if (this.isConnected || this.isConnecting)
|
|
7002
|
+
debug(message, ...optionalParams) {
|
|
7003
|
+
if (!this.debugEnable) {
|
|
6884
7004
|
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
|
-
});
|
|
7005
|
+
}
|
|
7006
|
+
console.log('WS debug: ' + message, ...optionalParams);
|
|
6914
7007
|
}
|
|
6915
|
-
|
|
6916
|
-
|
|
7008
|
+
info(message) {
|
|
7009
|
+
console.info('WS info: ' + message);
|
|
7010
|
+
}
|
|
7011
|
+
handleOnConnected(data) {
|
|
7012
|
+
this.debug('Webscoket connected', data);
|
|
7013
|
+
this.connected$.next(true);
|
|
7014
|
+
if (this.lostConnection) {
|
|
7015
|
+
this.info('Webscoket reconnected, recriating subscriptions');
|
|
7016
|
+
this.handleReconnection();
|
|
7017
|
+
}
|
|
7018
|
+
}
|
|
7019
|
+
handleOnDisconnect(data) {
|
|
7020
|
+
this.debug('Webscoket disconnected', data);
|
|
7021
|
+
this.disconnected$.next();
|
|
7022
|
+
}
|
|
7023
|
+
handleOnWebSocketClose(data) {
|
|
7024
|
+
if (data.wasClean) {
|
|
6917
7025
|
return;
|
|
6918
7026
|
}
|
|
6919
|
-
|
|
6920
|
-
|
|
6921
|
-
|
|
6922
|
-
|
|
7027
|
+
this.lostConnection = true;
|
|
7028
|
+
}
|
|
7029
|
+
handleOnStompError(data) {
|
|
7030
|
+
debugger;
|
|
7031
|
+
this.handleError('StompError', data);
|
|
7032
|
+
if (this.isAuthenticationError(data)) {
|
|
7033
|
+
this.info('Authentication error, recriating subscriptions');
|
|
7034
|
+
this.handleReconnection();
|
|
6923
7035
|
}
|
|
6924
|
-
|
|
6925
|
-
|
|
7036
|
+
}
|
|
7037
|
+
isAuthenticationError(data) {
|
|
7038
|
+
var _a;
|
|
7039
|
+
const errorMessage = (_a = data === null || data === void 0 ? void 0 : data.headers) === null || _a === void 0 ? void 0 : _a.message;
|
|
7040
|
+
if (!errorMessage) {
|
|
7041
|
+
return false;
|
|
6926
7042
|
}
|
|
6927
|
-
|
|
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}`;
|
|
7043
|
+
return errorMessage.toLowerCase().indexOf('forbiddenexception') !== -1;
|
|
6952
7044
|
}
|
|
6953
|
-
|
|
6954
|
-
|
|
6955
|
-
|
|
6956
|
-
|
|
6957
|
-
|
|
6958
|
-
|
|
7045
|
+
handleOnWebSocketError(data) {
|
|
7046
|
+
this.handleError('WebSocketError', data);
|
|
7047
|
+
}
|
|
7048
|
+
handleError(origin, data) {
|
|
7049
|
+
console.error(origin, data);
|
|
7050
|
+
this.error$.next(data);
|
|
6959
7051
|
}
|
|
6960
|
-
|
|
6961
|
-
|
|
6962
|
-
|
|
6963
|
-
this.
|
|
6964
|
-
this._stompClient.debug = () => null;
|
|
7052
|
+
handleReconnection() {
|
|
7053
|
+
this.lostConnection = false;
|
|
7054
|
+
this.reconnectPrimitives();
|
|
7055
|
+
this.reconnected$.next();
|
|
6965
7056
|
}
|
|
6966
|
-
/** @private */
|
|
6967
7057
|
reconnectPrimitives() {
|
|
6968
7058
|
for (const primitiveManager of this.primitiveManagers.values()) {
|
|
6969
7059
|
this.createStompSubscriptions(primitiveManager);
|
|
6970
7060
|
}
|
|
6971
7061
|
}
|
|
6972
|
-
|
|
6973
|
-
|
|
6974
|
-
|
|
6975
|
-
|
|
6976
|
-
observersCount += primitiveManager.event$.observers.length;
|
|
6977
|
-
}
|
|
6978
|
-
return observersCount;
|
|
7062
|
+
buildSubscriptionUrlWithToken(domain, service, primitive) {
|
|
7063
|
+
const authToken = this.userInformationService.getAuthToken();
|
|
7064
|
+
const tenant = this.userInformationService.getTenantDomain();
|
|
7065
|
+
return `/topic/${tenant}/${authToken}/${domain}/${service}/${primitive}`;
|
|
6979
7066
|
}
|
|
6980
|
-
|
|
6981
|
-
|
|
6982
|
-
|
|
6983
|
-
|
|
6984
|
-
|
|
7067
|
+
getSubscriptionUrlWithoutToken(domain, service, primitive) {
|
|
7068
|
+
const tenant = this.userInformationService.getTenantDomain();
|
|
7069
|
+
return `/topic/${tenant}/${domain}/${service}/${primitive}`;
|
|
7070
|
+
}
|
|
7071
|
+
buildPrimitiveManagerKey(domain, service, primitive) {
|
|
7072
|
+
return `${domain}/${service}/${primitive}`;
|
|
7073
|
+
}
|
|
7074
|
+
unsubscribePrimitiveOnFinalize(primitiveManager) {
|
|
7075
|
+
if (primitiveManager.hasObservers()) {
|
|
6985
7076
|
return;
|
|
6986
|
-
primitiveManager.event$.complete();
|
|
6987
|
-
for (const stompSubscription of primitiveManager.stompSubscriptions) {
|
|
6988
|
-
stompSubscription.unsubscribe();
|
|
6989
7077
|
}
|
|
6990
|
-
primitiveManager.
|
|
6991
|
-
const key = this.
|
|
7078
|
+
primitiveManager.unsubscribe();
|
|
7079
|
+
const key = this.buildPrimitiveManagerKey(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
6992
7080
|
this.primitiveManagers.delete(key);
|
|
6993
|
-
this.
|
|
7081
|
+
this.disconnectIfNoMoreObservables();
|
|
6994
7082
|
}
|
|
6995
|
-
|
|
6996
|
-
|
|
6997
|
-
|
|
7083
|
+
disconnectIfNoMoreObservables() {
|
|
7084
|
+
if (this.getObserversCount() === 0) {
|
|
7085
|
+
this.debug('Manually disconnecting because there are no more observers');
|
|
7086
|
+
this.disconnect();
|
|
7087
|
+
}
|
|
7088
|
+
}
|
|
7089
|
+
getObserversCount() {
|
|
7090
|
+
let observersCount = 0;
|
|
7091
|
+
this.primitiveManagers.forEach(primitiveManager => {
|
|
7092
|
+
observersCount += primitiveManager.getObserversCount();
|
|
7093
|
+
});
|
|
7094
|
+
return observersCount;
|
|
7095
|
+
}
|
|
7096
|
+
createStompSubscription(destination, primitiveManager) {
|
|
7097
|
+
return this.stompClient.subscribe(destination, (message) => {
|
|
7098
|
+
const event = JSON.parse(message.body || '{}');
|
|
7099
|
+
primitiveManager.fireEvent(event);
|
|
7100
|
+
});
|
|
7101
|
+
}
|
|
7102
|
+
createStompSubscriptions(primitiveManager) {
|
|
7103
|
+
const subscriptionUrlWithToken = this.buildSubscriptionUrlWithToken(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
7104
|
+
const subscriptionUrlWithoutToken = this.getSubscriptionUrlWithoutToken(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
7105
|
+
const stompSubscriptionWithToken = this.createStompSubscription(subscriptionUrlWithToken, primitiveManager);
|
|
7106
|
+
const stompSubscriptionWithoutToken = this.createStompSubscription(subscriptionUrlWithoutToken, primitiveManager);
|
|
7107
|
+
primitiveManager.subscribe(stompSubscriptionWithToken, stompSubscriptionWithoutToken);
|
|
7108
|
+
this.subscribed$.next(primitiveManager);
|
|
7109
|
+
}
|
|
7110
|
+
getSubscriptionUrl() {
|
|
7111
|
+
return `${this.userInformationService.getWebSocketUrl()}/subscription`;
|
|
6998
7112
|
}
|
|
6999
7113
|
};
|
|
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([
|
|
7114
|
+
WebsocketService.ctorParameters = () => [
|
|
7115
|
+
{ type: UserInformationService }
|
|
7116
|
+
];
|
|
7117
|
+
WebsocketService.ɵprov = ɵɵdefineInjectable({ factory: function WebsocketService_Factory() { return new WebsocketService(ɵɵinject(UserInformationService)); }, token: WebsocketService, providedIn: "root" });
|
|
7118
|
+
WebsocketService = __decorate([
|
|
7012
7119
|
Injectable({
|
|
7013
7120
|
providedIn: 'root'
|
|
7014
7121
|
})
|
|
@@ -7078,6 +7185,69 @@ VerifyModulePermission = VerifyModulePermission_1 = __decorate([
|
|
|
7078
7185
|
})
|
|
7079
7186
|
], VerifyModulePermission);
|
|
7080
7187
|
|
|
7188
|
+
var VerifyModulePermissionsService_1;
|
|
7189
|
+
let VerifyModulePermissionsService = VerifyModulePermissionsService_1 = class VerifyModulePermissionsService {
|
|
7190
|
+
constructor(http) {
|
|
7191
|
+
this.http = http;
|
|
7192
|
+
}
|
|
7193
|
+
consultaModulos(request) {
|
|
7194
|
+
return this.http.post(VerifyModulePermissionsService_1.QUERY_MODULES_URL, request);
|
|
7195
|
+
}
|
|
7196
|
+
};
|
|
7197
|
+
VerifyModulePermissionsService.QUERY_MODULES_URL = "erpx_fnd/empresa/queries/consultaModulos";
|
|
7198
|
+
VerifyModulePermissionsService.ctorParameters = () => [
|
|
7199
|
+
{ type: HttpClient }
|
|
7200
|
+
];
|
|
7201
|
+
VerifyModulePermissionsService.ɵprov = ɵɵdefineInjectable({ factory: function VerifyModulePermissionsService_Factory() { return new VerifyModulePermissionsService(ɵɵinject(HttpClient)); }, token: VerifyModulePermissionsService, providedIn: "any" });
|
|
7202
|
+
VerifyModulePermissionsService = VerifyModulePermissionsService_1 = __decorate([
|
|
7203
|
+
Injectable({
|
|
7204
|
+
providedIn: "any"
|
|
7205
|
+
})
|
|
7206
|
+
], VerifyModulePermissionsService);
|
|
7207
|
+
|
|
7208
|
+
var VerifyModulePermissions_1;
|
|
7209
|
+
let VerifyModulePermissions = VerifyModulePermissions_1 = class VerifyModulePermissions {
|
|
7210
|
+
constructor(verifyModulePermissionsService) {
|
|
7211
|
+
this.verifyModulePermissionsService = verifyModulePermissionsService;
|
|
7212
|
+
}
|
|
7213
|
+
/**
|
|
7214
|
+
* Method to verify if user has permission on a specific module
|
|
7215
|
+
* @param modules Modules to verify the permission
|
|
7216
|
+
* @param requestPermission Indicative if must be call the primitive
|
|
7217
|
+
* @returns An boolean Observable
|
|
7218
|
+
*/
|
|
7219
|
+
hasPermissions(modules, requestPermission) {
|
|
7220
|
+
const moduleSubject = VerifyModulePermissions_1.subjectsPerModuleMap.get(modules);
|
|
7221
|
+
if (!moduleSubject || requestPermission) {
|
|
7222
|
+
const newModuleSubject = new ReplaySubject(1);
|
|
7223
|
+
VerifyModulePermissions_1.subjectsPerModuleMap.set(modules, newModuleSubject);
|
|
7224
|
+
this.verifyModulePermissionsService
|
|
7225
|
+
.consultaModulos({ modulo: modules, somenteAtivo: true })
|
|
7226
|
+
.pipe(take(1))
|
|
7227
|
+
.subscribe(response => {
|
|
7228
|
+
const hasPermissions = (response === null || response === void 0 ? void 0 : response.modulos) || [];
|
|
7229
|
+
newModuleSubject.next(hasPermissions);
|
|
7230
|
+
}, (err) => {
|
|
7231
|
+
VerifyModulePermissions_1.subjectsPerModuleMap.delete(modules);
|
|
7232
|
+
newModuleSubject.error(err);
|
|
7233
|
+
newModuleSubject.unsubscribe();
|
|
7234
|
+
});
|
|
7235
|
+
return newModuleSubject.asObservable();
|
|
7236
|
+
}
|
|
7237
|
+
return moduleSubject.asObservable();
|
|
7238
|
+
}
|
|
7239
|
+
};
|
|
7240
|
+
VerifyModulePermissions.ctorParameters = () => [
|
|
7241
|
+
{ type: VerifyModulePermissionsService }
|
|
7242
|
+
];
|
|
7243
|
+
VerifyModulePermissions.subjectsPerModuleMap = new Map();
|
|
7244
|
+
VerifyModulePermissions.ɵprov = ɵɵdefineInjectable({ factory: function VerifyModulePermissions_Factory() { return new VerifyModulePermissions(ɵɵinject(VerifyModulePermissionsService)); }, token: VerifyModulePermissions, providedIn: "root" });
|
|
7245
|
+
VerifyModulePermissions = VerifyModulePermissions_1 = __decorate([
|
|
7246
|
+
Injectable({
|
|
7247
|
+
providedIn: "root"
|
|
7248
|
+
})
|
|
7249
|
+
], VerifyModulePermissions);
|
|
7250
|
+
|
|
7081
7251
|
var ModulesEnum;
|
|
7082
7252
|
(function (ModulesEnum) {
|
|
7083
7253
|
ModulesEnum["CONTROLADORIA"] = "CONTROLADORIA";
|
|
@@ -7096,5 +7266,5 @@ var ModulesEnum;
|
|
|
7096
7266
|
* Generated bundle index. Do not edit.
|
|
7097
7267
|
*/
|
|
7098
7268
|
|
|
7099
|
-
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, WebsocketService, naturezaReceitaPisCofins, ɵ0, ErpLookupsService as ɵa, EnumAnaSin as ɵb, EnumNatCtb as ɵc, StorageService as ɵd,
|
|
7269
|
+
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, UserInformationService as ɵe, VerifyModulePermissionService as ɵf, VerifyModulePermissionsService as ɵg };
|
|
7100
7270
|
//# sourceMappingURL=senior-gestao-empresarial-angular-components.js.map
|