@senior-gestao-empresarial/angular-components 4.22.0 → 4.22.1
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 +43 -31
- package/bundles/senior-gestao-empresarial-angular-components.umd.js.map +1 -1
- package/bundles/senior-gestao-empresarial-angular-components.umd.min.js +1 -1
- package/bundles/senior-gestao-empresarial-angular-components.umd.min.js.map +1 -1
- package/components/websocket/websocket.service.d.ts +7 -4
- package/esm2015/components/websocket/websocket.service.js +32 -30
- package/esm5/components/websocket/websocket.service.js +45 -33
- package/fesm2015/senior-gestao-empresarial-angular-components.js +31 -29
- package/fesm2015/senior-gestao-empresarial-angular-components.js.map +1 -1
- package/fesm5/senior-gestao-empresarial-angular-components.js +44 -32
- package/fesm5/senior-gestao-empresarial-angular-components.js.map +1 -1
- package/package.json +1 -1
- package/senior-gestao-empresarial-angular-components.metadata.json +1 -1
|
@@ -6617,7 +6617,6 @@
|
|
|
6617
6617
|
this.connected = false;
|
|
6618
6618
|
this.isConnecting = false;
|
|
6619
6619
|
this.stompSubscriptions = new Map();
|
|
6620
|
-
// private primitiveSubjects: Map<string, Subject<any>> = new Map<string, Subject<any>>();
|
|
6621
6620
|
this.primitiveManagers = new Map();
|
|
6622
6621
|
this.disconnectSubject = new rxjs.Subject();
|
|
6623
6622
|
this.connect$ = new rxjs.Subject();
|
|
@@ -6627,7 +6626,7 @@
|
|
|
6627
6626
|
}
|
|
6628
6627
|
WebsocketService_1 = WebsocketService;
|
|
6629
6628
|
/**
|
|
6630
|
-
* Observable
|
|
6629
|
+
* Observable responsável por emitir uma notificação quando a conexão websocket é estabelecida.
|
|
6631
6630
|
* @return Um `Observable<void>` que emite uma notificação quando a conexão websocket é estabelecida ou já está em andamento.
|
|
6632
6631
|
*/
|
|
6633
6632
|
WebsocketService.prototype.onConnect = function () {
|
|
@@ -6640,7 +6639,7 @@
|
|
|
6640
6639
|
return this.connect$.asObservable();
|
|
6641
6640
|
};
|
|
6642
6641
|
/**
|
|
6643
|
-
* Observable
|
|
6642
|
+
* Observable responsável por emitir uma notificação quando a conexão é finalizada.
|
|
6644
6643
|
* @return Um `Observable<void>` que emite uma notificação quando a conexão é finalizada.
|
|
6645
6644
|
*/
|
|
6646
6645
|
WebsocketService.prototype.onDisconnect = function () {
|
|
@@ -6667,14 +6666,7 @@
|
|
|
6667
6666
|
publishedEvents: [],
|
|
6668
6667
|
};
|
|
6669
6668
|
if (this.isConnected()) {
|
|
6670
|
-
|
|
6671
|
-
this.primitiveManagers.set(primitive, primitiveManager);
|
|
6672
|
-
var stompSubscription = this._stompClient.subscribe(url, function (message) {
|
|
6673
|
-
var event = JSON.parse(message.body || "{}");
|
|
6674
|
-
_this.addPublishedEvent(primitiveManager, event);
|
|
6675
|
-
primitiveManager.subject.next(event);
|
|
6676
|
-
});
|
|
6677
|
-
this.stompSubscriptions.set(primitive, stompSubscription);
|
|
6669
|
+
this.createStompSubscriptions(domain, service, primitive, primitiveManager);
|
|
6678
6670
|
return primitiveManager.subject.asObservable();
|
|
6679
6671
|
}
|
|
6680
6672
|
else {
|
|
@@ -6682,22 +6674,15 @@
|
|
|
6682
6674
|
this.connect();
|
|
6683
6675
|
}
|
|
6684
6676
|
this.onConnect()
|
|
6685
|
-
.pipe(operators.
|
|
6677
|
+
.pipe(operators.first())
|
|
6686
6678
|
.subscribe(function () {
|
|
6687
|
-
|
|
6688
|
-
_this.primitiveManagers.set(primitive, primitiveManager);
|
|
6689
|
-
var stompSubscription = _this._stompClient.subscribe(url, function (message) {
|
|
6690
|
-
var event = JSON.parse(message.body || "{}");
|
|
6691
|
-
_this.addPublishedEvent(primitiveManager, event);
|
|
6692
|
-
primitiveManager.subject.next(event);
|
|
6693
|
-
});
|
|
6694
|
-
_this.stompSubscriptions.set(primitive, stompSubscription);
|
|
6679
|
+
_this.createStompSubscriptions(domain, service, primitive, primitiveManager);
|
|
6695
6680
|
});
|
|
6696
6681
|
return primitiveManager.subject.asObservable();
|
|
6697
6682
|
}
|
|
6698
6683
|
};
|
|
6699
6684
|
/**
|
|
6700
|
-
* Retorna todos os eventos ouvidos
|
|
6685
|
+
* Retorna todos os eventos ouvidos pela primitiva com os respectivos identificadores.
|
|
6701
6686
|
* @typeParam `<T>` Tipo do evento retornado pela primitiva.
|
|
6702
6687
|
* @param primitive Primitiva que será "observada" pelo client.
|
|
6703
6688
|
* @param identifiers Array com os indentificadores interessados.
|
|
@@ -6732,9 +6717,7 @@
|
|
|
6732
6717
|
WebsocketService.prototype.addPublishedEvent = function (primitiveManager, event) {
|
|
6733
6718
|
var _this = this;
|
|
6734
6719
|
var identifier = this.getIdentifierFromEvent(primitiveManager.identifierPath, event);
|
|
6735
|
-
var eventIndex = primitiveManager.publishedEvents.findIndex(function (x) {
|
|
6736
|
-
return _this.getIdentifierFromEvent(primitiveManager.identifierPath, x) === identifier;
|
|
6737
|
-
});
|
|
6720
|
+
var eventIndex = primitiveManager.publishedEvents.findIndex(function (x) { return _this.getIdentifierFromEvent(primitiveManager.identifierPath, x) === identifier; });
|
|
6738
6721
|
if (eventIndex !== -1) {
|
|
6739
6722
|
primitiveManager.publishedEvents[eventIndex] = __assign(__assign({}, primitiveManager.publishedEvents[eventIndex]), event);
|
|
6740
6723
|
}
|
|
@@ -6742,6 +6725,14 @@
|
|
|
6742
6725
|
primitiveManager.publishedEvents.push(event);
|
|
6743
6726
|
}
|
|
6744
6727
|
};
|
|
6728
|
+
WebsocketService.prototype.createStompSubscriptions = function (domain, service, primitive, primitiveManager) {
|
|
6729
|
+
var withTokenUrl = this.getSubscriptionUrlWithToken(domain, service, primitive);
|
|
6730
|
+
this.primitiveManagers.set(primitive, primitiveManager);
|
|
6731
|
+
var stompSubscriptionWithToken = this.createStompSubscription(withTokenUrl, primitiveManager);
|
|
6732
|
+
var withoutTokenUrl = this.getSubscriptionUrlWithoutToken(domain, service, primitive);
|
|
6733
|
+
var stompSubscriptionWithoutToken = this.createStompSubscription(withoutTokenUrl, primitiveManager);
|
|
6734
|
+
this.stompSubscriptions.set(primitive, [stompSubscriptionWithToken, stompSubscriptionWithoutToken]);
|
|
6735
|
+
};
|
|
6745
6736
|
WebsocketService.prototype.getIdentifierFromEvent = function (identifierPath, event) {
|
|
6746
6737
|
var e_2, _a;
|
|
6747
6738
|
var properties = identifierPath.split(".");
|
|
@@ -6767,9 +6758,7 @@
|
|
|
6767
6758
|
this.isConnecting = true;
|
|
6768
6759
|
this._stompClient.connect({}, function () {
|
|
6769
6760
|
_this.setConnected(true);
|
|
6770
|
-
// console.log('setou false isConnecting');
|
|
6771
6761
|
_this.isConnecting = false;
|
|
6772
|
-
// console.log('connectou dentro do connect cb');
|
|
6773
6762
|
_this.publishOnConnect();
|
|
6774
6763
|
}, function () {
|
|
6775
6764
|
_this.setConnected(false);
|
|
@@ -6803,8 +6792,21 @@
|
|
|
6803
6792
|
finally { if (e_3) throw e_3.error; }
|
|
6804
6793
|
}
|
|
6805
6794
|
if (observersCount === 0) {
|
|
6806
|
-
this.stompSubscriptions.forEach(function (
|
|
6807
|
-
|
|
6795
|
+
this.stompSubscriptions.forEach(function (stompSubscriptions) {
|
|
6796
|
+
var e_5, _a;
|
|
6797
|
+
try {
|
|
6798
|
+
for (var stompSubscriptions_1 = __values(stompSubscriptions), stompSubscriptions_1_1 = stompSubscriptions_1.next(); !stompSubscriptions_1_1.done; stompSubscriptions_1_1 = stompSubscriptions_1.next()) {
|
|
6799
|
+
var stompSubscription = stompSubscriptions_1_1.value;
|
|
6800
|
+
stompSubscription.unsubscribe();
|
|
6801
|
+
}
|
|
6802
|
+
}
|
|
6803
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
6804
|
+
finally {
|
|
6805
|
+
try {
|
|
6806
|
+
if (stompSubscriptions_1_1 && !stompSubscriptions_1_1.done && (_a = stompSubscriptions_1.return)) _a.call(stompSubscriptions_1);
|
|
6807
|
+
}
|
|
6808
|
+
finally { if (e_5) throw e_5.error; }
|
|
6809
|
+
}
|
|
6808
6810
|
});
|
|
6809
6811
|
try {
|
|
6810
6812
|
for (var _e = __values(this.primitiveManagers.values()), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
@@ -6834,11 +6836,23 @@
|
|
|
6834
6836
|
WebsocketService.prototype.setConnected = function (connected) {
|
|
6835
6837
|
this.connected = connected;
|
|
6836
6838
|
};
|
|
6837
|
-
WebsocketService.prototype.
|
|
6839
|
+
WebsocketService.prototype.getSubscriptionUrlWithToken = function (domain, service, primitive) {
|
|
6838
6840
|
var tenant = WebsocketService_1.TOKEN ? WebsocketService_1.TOKEN.username.split("@")[1] : null;
|
|
6839
6841
|
var token = WebsocketService_1.TOKEN ? WebsocketService_1.TOKEN.access_token : null;
|
|
6840
6842
|
return "/topic/" + tenant + "/" + token + "/" + domain + "/" + service + "/" + primitive;
|
|
6841
6843
|
};
|
|
6844
|
+
WebsocketService.prototype.getSubscriptionUrlWithoutToken = function (domain, service, primitive) {
|
|
6845
|
+
var tenant = WebsocketService_1.TOKEN ? WebsocketService_1.TOKEN.username.split("@")[1] : null;
|
|
6846
|
+
return "/topic/" + tenant + "/" + domain + "/" + service + "/" + primitive;
|
|
6847
|
+
};
|
|
6848
|
+
WebsocketService.prototype.createStompSubscription = function (destination, primitiveManager) {
|
|
6849
|
+
var _this = this;
|
|
6850
|
+
return this._stompClient.subscribe(destination, function (message) {
|
|
6851
|
+
var event = JSON.parse(message.body || "{}");
|
|
6852
|
+
_this.addPublishedEvent(primitiveManager, event);
|
|
6853
|
+
primitiveManager.subject.next(event);
|
|
6854
|
+
});
|
|
6855
|
+
};
|
|
6842
6856
|
WebsocketService.prototype.createStompClient = function () {
|
|
6843
6857
|
var ws = new SockJS(WebsocketService_1.WEBSOCKET_URL + "subscription", null, { timeout: WebsocketService_1.CONNECTION_TIMEOUT });
|
|
6844
6858
|
this._stompClient = stompjs.Stomp.over(ws);
|
|
@@ -6856,12 +6870,10 @@
|
|
|
6856
6870
|
this._stompClient.disconnect();
|
|
6857
6871
|
var baseUrl = this.getBaseUrl();
|
|
6858
6872
|
if (this.baseUrl !== null && baseUrl != this.baseUrl) {
|
|
6859
|
-
// //console.log('ws disconnected: base url changed', this.baseUrl, ' -> ', baseUrl || 'null');
|
|
6860
6873
|
return;
|
|
6861
6874
|
}
|
|
6862
6875
|
var username = this.getUserName();
|
|
6863
6876
|
if (this.username !== null && username != this.username) {
|
|
6864
|
-
// //console.log('ws disconnected: username changed', this.username, ' -> ', username || 'null');
|
|
6865
6877
|
return;
|
|
6866
6878
|
}
|
|
6867
6879
|
setTimeout(function () {
|