@senior-gestao-empresarial/angular-components 6.12.0 → 7.0.0-730a64d6-86d2-4d71-8f00-64b50fcf1e75
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 +499 -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/lookups/entities/e-006-pai-lookup.d.ts +8 -0
- package/components/lookups/index.d.ts +1 -0
- 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/lookups/entities/e-006-pai-lookup.js +48 -0
- package/esm2015/components/lookups/index.js +2 -1
- 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/lookups/entities/e-006-pai-lookup.js +51 -0
- package/esm5/components/lookups/index.js +2 -1
- 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 +405 -193
- package/fesm2015/senior-gestao-empresarial-angular-components.js.map +1 -1
- package/fesm5/senior-gestao-empresarial-angular-components.js +495 -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) {
|
|
@@ -707,6 +707,47 @@ E007UfsLookup = __decorate([
|
|
|
707
707
|
Injectable()
|
|
708
708
|
], E007UfsLookup);
|
|
709
709
|
|
|
710
|
+
const codPai = "codPai";
|
|
711
|
+
const nomPai = "nomPai";
|
|
712
|
+
let E006PaiLookup = class E006PaiLookup extends ErpLookups {
|
|
713
|
+
constructor(lookupService, translate) {
|
|
714
|
+
super(lookupService, translate, "e006pai", [
|
|
715
|
+
{
|
|
716
|
+
name: codPai,
|
|
717
|
+
type: FieldType.String
|
|
718
|
+
}, {
|
|
719
|
+
name: nomPai,
|
|
720
|
+
type: FieldType.String
|
|
721
|
+
}
|
|
722
|
+
], [
|
|
723
|
+
{
|
|
724
|
+
name: codPai,
|
|
725
|
+
type: FieldType.String
|
|
726
|
+
}, {
|
|
727
|
+
name: nomPai,
|
|
728
|
+
type: FieldType.String
|
|
729
|
+
}
|
|
730
|
+
], [
|
|
731
|
+
{
|
|
732
|
+
name: codPai,
|
|
733
|
+
type: FieldType.Integer
|
|
734
|
+
}, {
|
|
735
|
+
name: nomPai,
|
|
736
|
+
type: FieldType.String
|
|
737
|
+
}
|
|
738
|
+
], "erpx_fnd", "empresa");
|
|
739
|
+
this.lookupService = lookupService;
|
|
740
|
+
this.translate = translate;
|
|
741
|
+
}
|
|
742
|
+
};
|
|
743
|
+
E006PaiLookup.ctorParameters = () => [
|
|
744
|
+
{ type: ErpLookupsService },
|
|
745
|
+
{ type: TranslateService }
|
|
746
|
+
];
|
|
747
|
+
E006PaiLookup = __decorate([
|
|
748
|
+
Injectable()
|
|
749
|
+
], E006PaiLookup);
|
|
750
|
+
|
|
710
751
|
let E008CepLookup =
|
|
711
752
|
/**
|
|
712
753
|
* @deprecated Should use PostalCodeLookup from @seniorsistemas/localization-components instead
|
|
@@ -6768,247 +6809,418 @@ NpsService = __decorate([
|
|
|
6768
6809
|
})
|
|
6769
6810
|
], NpsService);
|
|
6770
6811
|
|
|
6771
|
-
|
|
6772
|
-
let WebsocketService = WebsocketService_1 = class WebsocketService {
|
|
6812
|
+
class AsyncLock {
|
|
6773
6813
|
constructor() {
|
|
6774
|
-
|
|
6775
|
-
this.
|
|
6776
|
-
|
|
6777
|
-
|
|
6778
|
-
|
|
6779
|
-
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
|
|
6814
|
+
this.queue = [];
|
|
6815
|
+
this.acquired = false;
|
|
6816
|
+
}
|
|
6817
|
+
acquire() {
|
|
6818
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6819
|
+
if (!this.acquired) {
|
|
6820
|
+
this.acquired = true;
|
|
6821
|
+
return Promise.resolve();
|
|
6822
|
+
}
|
|
6823
|
+
else {
|
|
6824
|
+
return new Promise((resolve, _) => {
|
|
6825
|
+
this.queue.push(resolve);
|
|
6826
|
+
});
|
|
6827
|
+
}
|
|
6828
|
+
});
|
|
6829
|
+
}
|
|
6830
|
+
release() {
|
|
6831
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6832
|
+
if (this.queue.length === 0 && this.acquired) {
|
|
6833
|
+
this.acquired = false;
|
|
6834
|
+
return Promise.resolve();
|
|
6835
|
+
}
|
|
6836
|
+
const continuation = this.queue.shift();
|
|
6837
|
+
return new Promise((res) => {
|
|
6838
|
+
continuation();
|
|
6839
|
+
res();
|
|
6840
|
+
});
|
|
6841
|
+
});
|
|
6842
|
+
}
|
|
6843
|
+
}
|
|
6844
|
+
|
|
6845
|
+
var UserInformationService_1;
|
|
6846
|
+
let UserInformationService = UserInformationService_1 = class UserInformationService {
|
|
6847
|
+
getAuthToken() {
|
|
6848
|
+
const cookieValue = get(UserInformationService_1.TOKEN_COOKIE_KEY) || '{}';
|
|
6849
|
+
const authToken = JSON.parse(cookieValue);
|
|
6850
|
+
return authToken.access_token;
|
|
6851
|
+
}
|
|
6852
|
+
getTenantDomain() {
|
|
6853
|
+
const cookieValue = get(UserInformationService_1.TOKEN_COOKIE_KEY) || '{}';
|
|
6854
|
+
const authToken = JSON.parse(cookieValue);
|
|
6855
|
+
return authToken.username.split('@')[1];
|
|
6856
|
+
}
|
|
6857
|
+
getWebSocketUrl() {
|
|
6858
|
+
let baseUrl = get(UserInformationService_1.BASE_URL_COOKIE_KEY);
|
|
6859
|
+
if (baseUrl && !baseUrl.endsWith('/')) {
|
|
6860
|
+
baseUrl += '/';
|
|
6861
|
+
}
|
|
6862
|
+
return baseUrl + 'websocket';
|
|
6863
|
+
}
|
|
6864
|
+
};
|
|
6865
|
+
UserInformationService.BASE_URL_COOKIE_KEY = 'com.senior.base.url';
|
|
6866
|
+
UserInformationService.TOKEN_COOKIE_KEY = 'com.senior.token';
|
|
6867
|
+
UserInformationService.ɵprov = ɵɵdefineInjectable({ factory: function UserInformationService_Factory() { return new UserInformationService(); }, token: UserInformationService, providedIn: "root" });
|
|
6868
|
+
UserInformationService = UserInformationService_1 = __decorate([
|
|
6869
|
+
Injectable({
|
|
6870
|
+
providedIn: 'root'
|
|
6871
|
+
})
|
|
6872
|
+
], UserInformationService);
|
|
6873
|
+
|
|
6874
|
+
class PrimitiveManager {
|
|
6875
|
+
constructor(domain, service, primitive) {
|
|
6876
|
+
this.domain = domain;
|
|
6877
|
+
this.service = service;
|
|
6878
|
+
this.primitive = primitive;
|
|
6879
|
+
this.stompSubscriptions = [];
|
|
6880
|
+
this.event$ = new Subject();
|
|
6881
|
+
this.subscribed$ = new BehaviorSubject(false);
|
|
6882
|
+
}
|
|
6883
|
+
unsubscribe() {
|
|
6884
|
+
this.event$.complete();
|
|
6885
|
+
for (const stompSubscription of this.stompSubscriptions) {
|
|
6886
|
+
stompSubscription.unsubscribe();
|
|
6887
|
+
}
|
|
6888
|
+
this.subscribed$.complete();
|
|
6889
|
+
}
|
|
6890
|
+
fireEvent(event) {
|
|
6891
|
+
this.event$.next(event);
|
|
6892
|
+
}
|
|
6893
|
+
subscribe(...subscriptions) {
|
|
6894
|
+
this.stompSubscriptions.push(...subscriptions);
|
|
6895
|
+
this.subscribed$.next(true);
|
|
6896
|
+
}
|
|
6897
|
+
getEventObservable() {
|
|
6898
|
+
return this.event$.asObservable();
|
|
6899
|
+
}
|
|
6900
|
+
getSubscriptionObservable() {
|
|
6901
|
+
return this.subscribed$.asObservable();
|
|
6902
|
+
}
|
|
6903
|
+
hasObservers() {
|
|
6904
|
+
// @IMPORTANT: Replace .observers.length === 1 with .observed in rxjs 7.0+
|
|
6905
|
+
return this.event$.observers.length !== 1;
|
|
6906
|
+
}
|
|
6907
|
+
getObserversCount() {
|
|
6908
|
+
return this.event$.observers.length;
|
|
6909
|
+
}
|
|
6910
|
+
}
|
|
6911
|
+
|
|
6912
|
+
const RECONNECT_INTERVAL_MILLISECONDS = 3000;
|
|
6913
|
+
const CONNECTION_TIMEOUT_MILLISECONDS = 5000;
|
|
6914
|
+
let WebsocketService = class WebsocketService {
|
|
6915
|
+
constructor(userInformationService) {
|
|
6916
|
+
this.userInformationService = userInformationService;
|
|
6783
6917
|
this.connected$ = new BehaviorSubject(false);
|
|
6784
|
-
|
|
6785
|
-
this.
|
|
6786
|
-
/** @private */
|
|
6787
|
-
this.reconnect$ = new Subject();
|
|
6788
|
-
/** @private */
|
|
6918
|
+
this.disconnected$ = new Subject();
|
|
6919
|
+
this.reconnected$ = new Subject();
|
|
6789
6920
|
this.error$ = new Subject();
|
|
6790
6921
|
this.subscribed$ = new Subject();
|
|
6922
|
+
this.primitiveManagers = new Map();
|
|
6923
|
+
this.connectionLock = new AsyncLock();
|
|
6924
|
+
this.debugEnable = false;
|
|
6925
|
+
this.lostConnection = false;
|
|
6791
6926
|
}
|
|
6792
6927
|
/**
|
|
6793
|
-
*
|
|
6794
|
-
* @return Um `Observable<void>` que emite uma notificação quando a conexão websocket é estabelecida pela primeira vez.
|
|
6928
|
+
* Enables stompjs debug logs and additional info
|
|
6795
6929
|
*/
|
|
6796
|
-
|
|
6797
|
-
|
|
6930
|
+
enableDebugLogs() {
|
|
6931
|
+
this.debugEnable = true;
|
|
6798
6932
|
}
|
|
6799
6933
|
/**
|
|
6800
|
-
*
|
|
6801
|
-
* @return Um `Observable<void>` que emite uma notificação quando a conexão é desconectada.
|
|
6934
|
+
* Manually starts the connection
|
|
6802
6935
|
*/
|
|
6803
|
-
|
|
6804
|
-
return this
|
|
6936
|
+
connect() {
|
|
6937
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6938
|
+
yield this.connectionLock.acquire();
|
|
6939
|
+
try {
|
|
6940
|
+
if (this.isConnected() || this.isConnecting()) {
|
|
6941
|
+
return;
|
|
6942
|
+
}
|
|
6943
|
+
this.lostConnection = false;
|
|
6944
|
+
const stompConfig = {
|
|
6945
|
+
webSocketFactory: () => {
|
|
6946
|
+
return new SockJS(this.getSubscriptionUrl(), null, {
|
|
6947
|
+
timeout: CONNECTION_TIMEOUT_MILLISECONDS
|
|
6948
|
+
});
|
|
6949
|
+
},
|
|
6950
|
+
connectionTimeout: CONNECTION_TIMEOUT_MILLISECONDS,
|
|
6951
|
+
reconnectDelay: RECONNECT_INTERVAL_MILLISECONDS,
|
|
6952
|
+
debug: this.debug.bind(this),
|
|
6953
|
+
onConnect: this.handleOnConnected.bind(this),
|
|
6954
|
+
onDisconnect: this.handleOnDisconnect.bind(this),
|
|
6955
|
+
onWebSocketClose: this.handleOnWebSocketClose.bind(this),
|
|
6956
|
+
onStompError: this.handleOnStompError.bind(this),
|
|
6957
|
+
onWebSocketError: this.handleOnWebSocketError.bind(this)
|
|
6958
|
+
};
|
|
6959
|
+
this.debug('Connecting the Webscoket');
|
|
6960
|
+
this.stompClient = new Client(stompConfig);
|
|
6961
|
+
this.stompClient.activate();
|
|
6962
|
+
}
|
|
6963
|
+
finally {
|
|
6964
|
+
yield this.connectionLock.release();
|
|
6965
|
+
}
|
|
6966
|
+
});
|
|
6805
6967
|
}
|
|
6806
6968
|
/**
|
|
6807
|
-
*
|
|
6808
|
-
* @return Um `Observable<void>` que emite uma notificação quando a conexão é reconectada.
|
|
6969
|
+
* Manually disconnect the websocket. The reconnect loop will be stopped.
|
|
6809
6970
|
*/
|
|
6810
|
-
|
|
6811
|
-
return this
|
|
6971
|
+
disconnect() {
|
|
6972
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6973
|
+
if (!this.isConnected()) {
|
|
6974
|
+
return;
|
|
6975
|
+
}
|
|
6976
|
+
yield this.connectionLock.acquire();
|
|
6977
|
+
try {
|
|
6978
|
+
for (const primitiveManager of this.primitiveManagers.values()) {
|
|
6979
|
+
primitiveManager.unsubscribe();
|
|
6980
|
+
}
|
|
6981
|
+
this.primitiveManagers.clear();
|
|
6982
|
+
this.connected$.next(false);
|
|
6983
|
+
if (this.stompClient) {
|
|
6984
|
+
yield this.stompClient.deactivate();
|
|
6985
|
+
}
|
|
6986
|
+
}
|
|
6987
|
+
finally {
|
|
6988
|
+
yield this.connectionLock.release();
|
|
6989
|
+
}
|
|
6990
|
+
});
|
|
6812
6991
|
}
|
|
6813
6992
|
/**
|
|
6814
|
-
*
|
|
6815
|
-
* @return
|
|
6993
|
+
* Check if the websocket is connected
|
|
6994
|
+
* @return `boolean` representing if the websocket is connected
|
|
6816
6995
|
*/
|
|
6817
|
-
|
|
6818
|
-
|
|
6819
|
-
|
|
6820
|
-
|
|
6821
|
-
|
|
6822
|
-
|
|
6823
|
-
|
|
6824
|
-
|
|
6825
|
-
|
|
6826
|
-
|
|
6996
|
+
isConnected() {
|
|
6997
|
+
if (!this.stompClient) {
|
|
6998
|
+
return false;
|
|
6999
|
+
}
|
|
7000
|
+
return this.stompClient.connected;
|
|
7001
|
+
}
|
|
7002
|
+
/**
|
|
7003
|
+
* Check if the websocket is tring to connect
|
|
7004
|
+
* @return `boolean` representing if the websocket status
|
|
7005
|
+
*/
|
|
7006
|
+
isConnecting() {
|
|
7007
|
+
if (!this.stompClient) {
|
|
7008
|
+
return false;
|
|
7009
|
+
}
|
|
7010
|
+
return !this.stompClient.connected && this.stompClient.active;
|
|
7011
|
+
}
|
|
7012
|
+
/**
|
|
7013
|
+
* Event responsable to emit an event when the connection is established.
|
|
7014
|
+
* Do not forget to unsubscribe the observable when you don't need it anymore.
|
|
7015
|
+
* @return `Observable<boolean>`
|
|
7016
|
+
*/
|
|
7017
|
+
onConnect() {
|
|
7018
|
+
return this.connected$.asObservable()
|
|
7019
|
+
.pipe(filter(p => p === true));
|
|
7020
|
+
}
|
|
7021
|
+
/**
|
|
7022
|
+
* Event responsable to emit an event when the connection is closed.
|
|
7023
|
+
* Do not forget to unsubscribe the observable when you don't need it anymore.
|
|
7024
|
+
* @return `Observable<void>`
|
|
7025
|
+
*/
|
|
7026
|
+
onDisconnect() {
|
|
7027
|
+
return this.disconnected$.asObservable();
|
|
7028
|
+
}
|
|
7029
|
+
/**
|
|
7030
|
+
* Event responsable to emit an event when the connection is reestablished.
|
|
7031
|
+
* Do not forget to unsubscribe the observable when you don't need it anymore.
|
|
7032
|
+
* @return `Observable<void>`
|
|
7033
|
+
*/
|
|
7034
|
+
onReconnect() {
|
|
7035
|
+
return this.reconnected$.asObservable();
|
|
6827
7036
|
}
|
|
6828
7037
|
/**
|
|
6829
|
-
*
|
|
6830
|
-
*
|
|
7038
|
+
* Event responsable to emit an event when an error ocurred.
|
|
7039
|
+
* Do not forget to unsubscribe the observable when you don't need it anymore.
|
|
7040
|
+
* @return `Observable<FrameImpl>`
|
|
6831
7041
|
*/
|
|
6832
7042
|
onError() {
|
|
6833
7043
|
return this.error$.asObservable();
|
|
6834
7044
|
}
|
|
6835
7045
|
/**
|
|
6836
|
-
*
|
|
6837
|
-
*
|
|
6838
|
-
* @
|
|
6839
|
-
* @param {
|
|
6840
|
-
* @
|
|
6841
|
-
* @return Um Observable<T> que emite notificações toda vez que o respectivo evento é publicado.
|
|
7046
|
+
* Event responsible to emit an event when a primitive is called.
|
|
7047
|
+
* Do not forget to unsubscribe the observable when you don't need it anymore.
|
|
7048
|
+
* @typeParam `<T>` Object type that will be used in the observable for the `data` property.
|
|
7049
|
+
* @param {OnEventOptions} options Configurations for the event.
|
|
7050
|
+
* @return `Observable<PrimitiveEvent<T>>` Observable that emits an event when the service calls the primitive.
|
|
6842
7051
|
*/
|
|
6843
7052
|
onEvent(options) {
|
|
6844
|
-
this.connect();
|
|
6845
7053
|
const { domain, service, primitive } = options;
|
|
6846
|
-
const key = this.
|
|
7054
|
+
const key = this.buildPrimitiveManagerKey(domain, service, primitive);
|
|
6847
7055
|
if (this.primitiveManagers.has(key)) {
|
|
6848
|
-
return this.primitiveManagers.get(key).
|
|
7056
|
+
return this.primitiveManagers.get(key).getEventObservable();
|
|
6849
7057
|
}
|
|
6850
|
-
const primitiveManager =
|
|
6851
|
-
domain: domain,
|
|
6852
|
-
service: service,
|
|
6853
|
-
primitive: primitive,
|
|
6854
|
-
stompSubscriptions: [],
|
|
6855
|
-
event$: new Subject(),
|
|
6856
|
-
subscribed$: new BehaviorSubject(false)
|
|
6857
|
-
};
|
|
7058
|
+
const primitiveManager = new PrimitiveManager(domain, service, primitive);
|
|
6858
7059
|
this.primitiveManagers.set(key, primitiveManager);
|
|
6859
|
-
this.
|
|
6860
|
-
.
|
|
6861
|
-
|
|
6862
|
-
|
|
7060
|
+
this.connect().then(() => {
|
|
7061
|
+
this.onConnect()
|
|
7062
|
+
.pipe(take(1))
|
|
7063
|
+
.subscribe(() => {
|
|
7064
|
+
this.createStompSubscriptions(primitiveManager);
|
|
7065
|
+
});
|
|
6863
7066
|
});
|
|
6864
|
-
return primitiveManager
|
|
6865
|
-
.
|
|
6866
|
-
.pipe(finalize(() => this.
|
|
7067
|
+
return primitiveManager
|
|
7068
|
+
.getEventObservable()
|
|
7069
|
+
.pipe(finalize(() => this.unsubscribePrimitiveOnFinalize(primitiveManager)));
|
|
6867
7070
|
}
|
|
6868
|
-
/**
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
|
|
6876
|
-
|
|
6877
|
-
|
|
6878
|
-
|
|
6879
|
-
|
|
7071
|
+
/**
|
|
7072
|
+
* Event responsible to emit an event when a subscription is created for the primitive.
|
|
7073
|
+
* Do not forget to unsubscribe the observable when you don't need it anymore.
|
|
7074
|
+
* @param {OnEventOptions} options Configurations for the event.
|
|
7075
|
+
* Observable responsável por emitir uma notificação após o subscribe do evento pela primeira vez.
|
|
7076
|
+
* @return `Observable<boolean>` Observable that emits an event when the service calls the primitive.
|
|
7077
|
+
*/
|
|
7078
|
+
onSubscribe(options) {
|
|
7079
|
+
const { domain, service, primitive } = options;
|
|
7080
|
+
const key = this.buildPrimitiveManagerKey(domain, service, primitive);
|
|
7081
|
+
return this.onConnect().pipe(take(1), switchMap(() => {
|
|
7082
|
+
if (this.primitiveManagers.has(key)) {
|
|
7083
|
+
return this.primitiveManagers
|
|
7084
|
+
.get(key)
|
|
7085
|
+
.getSubscriptionObservable()
|
|
7086
|
+
.pipe(take(1));
|
|
7087
|
+
}
|
|
7088
|
+
return this.subscribed$.asObservable().pipe(filter((primitiveManager) => {
|
|
7089
|
+
return this.buildPrimitiveManagerKey(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive) === key;
|
|
7090
|
+
}), map(() => true), take(1));
|
|
7091
|
+
}));
|
|
6880
7092
|
}
|
|
6881
|
-
|
|
6882
|
-
|
|
6883
|
-
if (this.isConnected || this.isConnecting)
|
|
7093
|
+
debug(message, ...optionalParams) {
|
|
7094
|
+
if (!this.debugEnable) {
|
|
6884
7095
|
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
|
-
});
|
|
7096
|
+
}
|
|
7097
|
+
console.log('WS debug: ' + message, ...optionalParams);
|
|
6914
7098
|
}
|
|
6915
|
-
|
|
6916
|
-
|
|
7099
|
+
info(message) {
|
|
7100
|
+
console.info('WS info: ' + message);
|
|
7101
|
+
}
|
|
7102
|
+
handleOnConnected() {
|
|
7103
|
+
this.info('Webscoket connected');
|
|
7104
|
+
this.connected$.next(true);
|
|
7105
|
+
if (this.lostConnection) {
|
|
7106
|
+
this.info('Webscoket reconnected, recriating subscriptions');
|
|
7107
|
+
this.handleReconnection();
|
|
7108
|
+
}
|
|
7109
|
+
}
|
|
7110
|
+
handleOnDisconnect() {
|
|
7111
|
+
this.info('Webscoket disconnected');
|
|
7112
|
+
this.connected$.next(false);
|
|
7113
|
+
this.disconnected$.next();
|
|
7114
|
+
}
|
|
7115
|
+
handleOnWebSocketClose(data) {
|
|
7116
|
+
if (data.reason && data.reason.toLowerCase().indexOf("go away") !== -1) {
|
|
7117
|
+
this.lostConnection = true;
|
|
7118
|
+
this.handleError('AuthenticationError', new FrameImpl({
|
|
7119
|
+
command: data.type,
|
|
7120
|
+
headers: {
|
|
7121
|
+
message: data.reason
|
|
7122
|
+
}
|
|
7123
|
+
}));
|
|
6917
7124
|
return;
|
|
6918
7125
|
}
|
|
6919
|
-
|
|
6920
|
-
|
|
6921
|
-
stompSubscription.unsubscribe();
|
|
6922
|
-
}
|
|
7126
|
+
if (data.wasClean) {
|
|
7127
|
+
return;
|
|
6923
7128
|
}
|
|
6924
|
-
|
|
6925
|
-
|
|
7129
|
+
this.lostConnection = true;
|
|
7130
|
+
}
|
|
7131
|
+
handleOnStompError(data) {
|
|
7132
|
+
this.handleError('StompError', data);
|
|
7133
|
+
if (this.isAuthenticationError(data)) {
|
|
7134
|
+
this.info('Authentication error, recriating subscriptions');
|
|
7135
|
+
this.handleReconnection();
|
|
6926
7136
|
}
|
|
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
7137
|
}
|
|
6953
|
-
|
|
6954
|
-
|
|
6955
|
-
|
|
6956
|
-
|
|
6957
|
-
|
|
6958
|
-
}
|
|
7138
|
+
isAuthenticationError(data) {
|
|
7139
|
+
var _a;
|
|
7140
|
+
const errorMessage = (_a = data === null || data === void 0 ? void 0 : data.headers) === null || _a === void 0 ? void 0 : _a.message;
|
|
7141
|
+
if (!errorMessage) {
|
|
7142
|
+
return false;
|
|
7143
|
+
}
|
|
7144
|
+
return errorMessage.toLowerCase().indexOf('forbiddenexception') !== -1;
|
|
6959
7145
|
}
|
|
6960
|
-
|
|
6961
|
-
|
|
6962
|
-
|
|
6963
|
-
|
|
6964
|
-
|
|
7146
|
+
handleOnWebSocketError(data) {
|
|
7147
|
+
this.handleError('WebSocketError', data);
|
|
7148
|
+
}
|
|
7149
|
+
handleError(origin, data) {
|
|
7150
|
+
console.error(origin, data);
|
|
7151
|
+
this.error$.next(data);
|
|
7152
|
+
}
|
|
7153
|
+
handleReconnection() {
|
|
7154
|
+
this.lostConnection = false;
|
|
7155
|
+
this.reconnectPrimitives();
|
|
7156
|
+
this.reconnected$.next();
|
|
6965
7157
|
}
|
|
6966
|
-
/** @private */
|
|
6967
7158
|
reconnectPrimitives() {
|
|
6968
7159
|
for (const primitiveManager of this.primitiveManagers.values()) {
|
|
6969
7160
|
this.createStompSubscriptions(primitiveManager);
|
|
6970
7161
|
}
|
|
6971
7162
|
}
|
|
6972
|
-
|
|
7163
|
+
buildSubscriptionUrlWithToken(domain, service, primitive) {
|
|
7164
|
+
const authToken = this.userInformationService.getAuthToken();
|
|
7165
|
+
const tenant = this.userInformationService.getTenantDomain();
|
|
7166
|
+
return `/topic/${tenant}/${authToken}/${domain}/${service}/${primitive}`;
|
|
7167
|
+
}
|
|
7168
|
+
getSubscriptionUrlWithoutToken(domain, service, primitive) {
|
|
7169
|
+
const tenant = this.userInformationService.getTenantDomain();
|
|
7170
|
+
return `/topic/${tenant}/${domain}/${service}/${primitive}`;
|
|
7171
|
+
}
|
|
7172
|
+
buildPrimitiveManagerKey(domain, service, primitive) {
|
|
7173
|
+
return `${domain}/${service}/${primitive}`;
|
|
7174
|
+
}
|
|
7175
|
+
unsubscribePrimitiveOnFinalize(primitiveManager) {
|
|
7176
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
7177
|
+
if (primitiveManager.hasObservers()) {
|
|
7178
|
+
return;
|
|
7179
|
+
}
|
|
7180
|
+
primitiveManager.unsubscribe();
|
|
7181
|
+
const key = this.buildPrimitiveManagerKey(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
7182
|
+
this.primitiveManagers.delete(key);
|
|
7183
|
+
yield this.disconnectIfNoMoreObservables();
|
|
7184
|
+
});
|
|
7185
|
+
}
|
|
7186
|
+
disconnectIfNoMoreObservables() {
|
|
7187
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
7188
|
+
if (this.getObserversCount() === 0) {
|
|
7189
|
+
this.debug('Manually disconnecting because there are no more observers');
|
|
7190
|
+
yield this.disconnect();
|
|
7191
|
+
}
|
|
7192
|
+
});
|
|
7193
|
+
}
|
|
6973
7194
|
getObserversCount() {
|
|
6974
7195
|
let observersCount = 0;
|
|
6975
|
-
|
|
6976
|
-
observersCount += primitiveManager.
|
|
6977
|
-
}
|
|
7196
|
+
this.primitiveManagers.forEach(primitiveManager => {
|
|
7197
|
+
observersCount += primitiveManager.getObserversCount();
|
|
7198
|
+
});
|
|
6978
7199
|
return observersCount;
|
|
6979
7200
|
}
|
|
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();
|
|
7201
|
+
createStompSubscription(destination, primitiveManager) {
|
|
7202
|
+
return this.stompClient.subscribe(destination, (message) => {
|
|
7203
|
+
const event = JSON.parse(message.body || '{}');
|
|
7204
|
+
primitiveManager.fireEvent(event);
|
|
7205
|
+
});
|
|
6994
7206
|
}
|
|
6995
|
-
|
|
6996
|
-
|
|
6997
|
-
|
|
7207
|
+
createStompSubscriptions(primitiveManager) {
|
|
7208
|
+
const subscriptionUrlWithToken = this.buildSubscriptionUrlWithToken(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
7209
|
+
const subscriptionUrlWithoutToken = this.getSubscriptionUrlWithoutToken(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
7210
|
+
const stompSubscriptionWithToken = this.createStompSubscription(subscriptionUrlWithToken, primitiveManager);
|
|
7211
|
+
const stompSubscriptionWithoutToken = this.createStompSubscription(subscriptionUrlWithoutToken, primitiveManager);
|
|
7212
|
+
primitiveManager.subscribe(stompSubscriptionWithToken, stompSubscriptionWithoutToken);
|
|
7213
|
+
this.subscribed$.next(primitiveManager);
|
|
7214
|
+
}
|
|
7215
|
+
getSubscriptionUrl() {
|
|
7216
|
+
return `${this.userInformationService.getWebSocketUrl()}/subscription`;
|
|
6998
7217
|
}
|
|
6999
7218
|
};
|
|
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([
|
|
7219
|
+
WebsocketService.ctorParameters = () => [
|
|
7220
|
+
{ type: UserInformationService }
|
|
7221
|
+
];
|
|
7222
|
+
WebsocketService.ɵprov = ɵɵdefineInjectable({ factory: function WebsocketService_Factory() { return new WebsocketService(ɵɵinject(UserInformationService)); }, token: WebsocketService, providedIn: "root" });
|
|
7223
|
+
WebsocketService = __decorate([
|
|
7012
7224
|
Injectable({
|
|
7013
7225
|
providedIn: 'root'
|
|
7014
7226
|
})
|
|
@@ -7159,5 +7371,5 @@ var ModulesEnum;
|
|
|
7159
7371
|
* Generated bundle index. Do not edit.
|
|
7160
7372
|
*/
|
|
7161
7373
|
|
|
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,
|
|
7374
|
+
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, E006PaiLookup, 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
7375
|
//# sourceMappingURL=senior-gestao-empresarial-angular-components.js.map
|