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