@senior-gestao-empresarial/angular-components 4.22.0 → 4.22.1-706afb94-1b58-4cb7-9006-8d9033881f51
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 +49 -38
- 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 +10 -7
- package/esm2015/components/websocket/websocket.service.js +38 -37
- package/esm5/components/websocket/websocket.service.js +51 -40
- package/fesm2015/senior-gestao-empresarial-angular-components.js +37 -36
- package/fesm2015/senior-gestao-empresarial-angular-components.js.map +1 -1
- package/fesm5/senior-gestao-empresarial-angular-components.js +50 -39
- 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,8 +6626,8 @@
|
|
|
6627
6626
|
}
|
|
6628
6627
|
WebsocketService_1 = WebsocketService;
|
|
6629
6628
|
/**
|
|
6630
|
-
* Observable
|
|
6631
|
-
* @return Um `Observable<void>` que emite uma notificação quando a conexão websocket é estabelecida
|
|
6629
|
+
* Observable responsável por emitir uma notificação quando a conexão websocket é estabelecida.
|
|
6630
|
+
* @return Um `Observable<void>` que emite uma notificação quando a conexão websocket é estabelecida.
|
|
6632
6631
|
*/
|
|
6633
6632
|
WebsocketService.prototype.onConnect = function () {
|
|
6634
6633
|
var _this = this;
|
|
@@ -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 () {
|
|
@@ -6652,29 +6651,22 @@
|
|
|
6652
6651
|
* @param domain Dominio da primitva.
|
|
6653
6652
|
* @param service Service da primitiva.
|
|
6654
6653
|
* @param primitive Primitiva que será "observada" pelo client.
|
|
6655
|
-
* @param identifierPath Caminho até a propriedade considerada o
|
|
6654
|
+
* @param identifierPath Caminho até a propriedade considerada o identificador do registro.
|
|
6656
6655
|
* @return Um `observable` que emite notificações toda vez que o respectivo evento é publicado no sistema.
|
|
6657
6656
|
*/
|
|
6658
6657
|
WebsocketService.prototype.onEvent = function (domain, service, primitive, identifierPath) {
|
|
6659
6658
|
var _this = this;
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
return primitiveManager.subject.asObservable();
|
|
6659
|
+
if (this.primitiveManagers.has(primitive)) {
|
|
6660
|
+
return this.primitiveManagers.get(primitive).subject.asObservable();
|
|
6663
6661
|
}
|
|
6664
|
-
primitiveManager = {
|
|
6662
|
+
var primitiveManager = {
|
|
6665
6663
|
subject: new rxjs.Subject(),
|
|
6666
6664
|
identifierPath: identifierPath,
|
|
6667
6665
|
publishedEvents: [],
|
|
6668
6666
|
};
|
|
6667
|
+
this.primitiveManagers.set(primitive, primitiveManager);
|
|
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,25 +6674,18 @@
|
|
|
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
|
-
* @param identifiers Array com os
|
|
6688
|
+
* @param identifiers Array com os identificadores interessados.
|
|
6704
6689
|
* @return Array contendo o último evento recebido de cada identificador fornecido.
|
|
6705
6690
|
*/
|
|
6706
6691
|
WebsocketService.prototype.getPublishedEvents = function (primitive, identifiers) {
|
|
@@ -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,13 @@
|
|
|
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
|
+
var stompSubscriptionWithToken = this.createStompSubscription(withTokenUrl, primitiveManager);
|
|
6731
|
+
var withoutTokenUrl = this.getSubscriptionUrlWithoutToken(domain, service, primitive);
|
|
6732
|
+
var stompSubscriptionWithoutToken = this.createStompSubscription(withoutTokenUrl, primitiveManager);
|
|
6733
|
+
this.stompSubscriptions.set(primitive, [stompSubscriptionWithToken, stompSubscriptionWithoutToken]);
|
|
6734
|
+
};
|
|
6745
6735
|
WebsocketService.prototype.getIdentifierFromEvent = function (identifierPath, event) {
|
|
6746
6736
|
var e_2, _a;
|
|
6747
6737
|
var properties = identifierPath.split(".");
|
|
@@ -6767,9 +6757,7 @@
|
|
|
6767
6757
|
this.isConnecting = true;
|
|
6768
6758
|
this._stompClient.connect({}, function () {
|
|
6769
6759
|
_this.setConnected(true);
|
|
6770
|
-
// console.log('setou false isConnecting');
|
|
6771
6760
|
_this.isConnecting = false;
|
|
6772
|
-
// console.log('connectou dentro do connect cb');
|
|
6773
6761
|
_this.publishOnConnect();
|
|
6774
6762
|
}, function () {
|
|
6775
6763
|
_this.setConnected(false);
|
|
@@ -6803,8 +6791,21 @@
|
|
|
6803
6791
|
finally { if (e_3) throw e_3.error; }
|
|
6804
6792
|
}
|
|
6805
6793
|
if (observersCount === 0) {
|
|
6806
|
-
this.stompSubscriptions.forEach(function (
|
|
6807
|
-
|
|
6794
|
+
this.stompSubscriptions.forEach(function (stompSubscriptions) {
|
|
6795
|
+
var e_5, _a;
|
|
6796
|
+
try {
|
|
6797
|
+
for (var stompSubscriptions_1 = __values(stompSubscriptions), stompSubscriptions_1_1 = stompSubscriptions_1.next(); !stompSubscriptions_1_1.done; stompSubscriptions_1_1 = stompSubscriptions_1.next()) {
|
|
6798
|
+
var stompSubscription = stompSubscriptions_1_1.value;
|
|
6799
|
+
stompSubscription.unsubscribe();
|
|
6800
|
+
}
|
|
6801
|
+
}
|
|
6802
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
6803
|
+
finally {
|
|
6804
|
+
try {
|
|
6805
|
+
if (stompSubscriptions_1_1 && !stompSubscriptions_1_1.done && (_a = stompSubscriptions_1.return)) _a.call(stompSubscriptions_1);
|
|
6806
|
+
}
|
|
6807
|
+
finally { if (e_5) throw e_5.error; }
|
|
6808
|
+
}
|
|
6808
6809
|
});
|
|
6809
6810
|
try {
|
|
6810
6811
|
for (var _e = __values(this.primitiveManagers.values()), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
@@ -6834,11 +6835,23 @@
|
|
|
6834
6835
|
WebsocketService.prototype.setConnected = function (connected) {
|
|
6835
6836
|
this.connected = connected;
|
|
6836
6837
|
};
|
|
6837
|
-
WebsocketService.prototype.
|
|
6838
|
+
WebsocketService.prototype.getSubscriptionUrlWithToken = function (domain, service, primitive) {
|
|
6838
6839
|
var tenant = WebsocketService_1.TOKEN ? WebsocketService_1.TOKEN.username.split("@")[1] : null;
|
|
6839
6840
|
var token = WebsocketService_1.TOKEN ? WebsocketService_1.TOKEN.access_token : null;
|
|
6840
6841
|
return "/topic/" + tenant + "/" + token + "/" + domain + "/" + service + "/" + primitive;
|
|
6841
6842
|
};
|
|
6843
|
+
WebsocketService.prototype.getSubscriptionUrlWithoutToken = function (domain, service, primitive) {
|
|
6844
|
+
var tenant = WebsocketService_1.TOKEN ? WebsocketService_1.TOKEN.username.split("@")[1] : null;
|
|
6845
|
+
return "/topic/" + tenant + "/" + domain + "/" + service + "/" + primitive;
|
|
6846
|
+
};
|
|
6847
|
+
WebsocketService.prototype.createStompSubscription = function (destination, primitiveManager) {
|
|
6848
|
+
var _this = this;
|
|
6849
|
+
return this._stompClient.subscribe(destination, function (message) {
|
|
6850
|
+
var event = JSON.parse(message.body || "{}");
|
|
6851
|
+
_this.addPublishedEvent(primitiveManager, event);
|
|
6852
|
+
primitiveManager.subject.next(event);
|
|
6853
|
+
});
|
|
6854
|
+
};
|
|
6842
6855
|
WebsocketService.prototype.createStompClient = function () {
|
|
6843
6856
|
var ws = new SockJS(WebsocketService_1.WEBSOCKET_URL + "subscription", null, { timeout: WebsocketService_1.CONNECTION_TIMEOUT });
|
|
6844
6857
|
this._stompClient = stompjs.Stomp.over(ws);
|
|
@@ -6856,12 +6869,10 @@
|
|
|
6856
6869
|
this._stompClient.disconnect();
|
|
6857
6870
|
var baseUrl = this.getBaseUrl();
|
|
6858
6871
|
if (this.baseUrl !== null && baseUrl != this.baseUrl) {
|
|
6859
|
-
// //console.log('ws disconnected: base url changed', this.baseUrl, ' -> ', baseUrl || 'null');
|
|
6860
6872
|
return;
|
|
6861
6873
|
}
|
|
6862
6874
|
var username = this.getUserName();
|
|
6863
6875
|
if (this.username !== null && username != this.username) {
|
|
6864
|
-
// //console.log('ws disconnected: username changed', this.username, ' -> ', username || 'null');
|
|
6865
6876
|
return;
|
|
6866
6877
|
}
|
|
6867
6878
|
setTimeout(function () {
|