@senior-gestao-empresarial/angular-components 4.21.1 → 4.22.0-c6f90211-2bfd-46c1-b41f-98ce3aba88b5
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 +50 -35
- 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/permissions/protocols/query-module.d.ts +1 -0
- package/components/permissions/verify-module-permission.d.ts +2 -1
- package/components/websocket/websocket.service.d.ts +6 -4
- package/esm2015/components/permissions/protocols/query-module.js +1 -1
- package/esm2015/components/permissions/verify-module-permission.js +7 -5
- package/esm2015/components/websocket/websocket.service.js +33 -30
- package/esm5/components/permissions/protocols/query-module.js +1 -1
- package/esm5/components/permissions/verify-module-permission.js +7 -5
- package/esm5/components/websocket/websocket.service.js +46 -33
- package/fesm2015/senior-gestao-empresarial-angular-components.js +38 -33
- package/fesm2015/senior-gestao-empresarial-angular-components.js.map +1 -1
- package/fesm5/senior-gestao-empresarial-angular-components.js +51 -36
- 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,23 @@
|
|
|
6742
6725
|
primitiveManager.publishedEvents.push(event);
|
|
6743
6726
|
}
|
|
6744
6727
|
};
|
|
6728
|
+
WebsocketService.prototype.createStompSubscriptions = function (domain, service, primitive, primitiveManager) {
|
|
6729
|
+
var _this = this;
|
|
6730
|
+
var withUserUrl = this.getSubscriptionWithUserUrl(domain, service, primitive);
|
|
6731
|
+
this.primitiveManagers.set(primitive, primitiveManager);
|
|
6732
|
+
var stompSubscriptionWithUser = this._stompClient.subscribe(withUserUrl, function (message) {
|
|
6733
|
+
var event = JSON.parse(message.body || "{}");
|
|
6734
|
+
_this.addPublishedEvent(primitiveManager, event);
|
|
6735
|
+
primitiveManager.subject.next(event);
|
|
6736
|
+
});
|
|
6737
|
+
var withoutUserUrl = this.getSubscriptionWithoutUserUrl(domain, service, primitive);
|
|
6738
|
+
var stompSubscriptionWithoutUser = this._stompClient.subscribe(withoutUserUrl, function (message) {
|
|
6739
|
+
var event = JSON.parse(message.body || "{}");
|
|
6740
|
+
_this.addPublishedEvent(primitiveManager, event);
|
|
6741
|
+
primitiveManager.subject.next(event);
|
|
6742
|
+
});
|
|
6743
|
+
this.stompSubscriptions.set(primitive, [stompSubscriptionWithUser, stompSubscriptionWithoutUser]);
|
|
6744
|
+
};
|
|
6745
6745
|
WebsocketService.prototype.getIdentifierFromEvent = function (identifierPath, event) {
|
|
6746
6746
|
var e_2, _a;
|
|
6747
6747
|
var properties = identifierPath.split(".");
|
|
@@ -6767,9 +6767,7 @@
|
|
|
6767
6767
|
this.isConnecting = true;
|
|
6768
6768
|
this._stompClient.connect({}, function () {
|
|
6769
6769
|
_this.setConnected(true);
|
|
6770
|
-
// console.log('setou false isConnecting');
|
|
6771
6770
|
_this.isConnecting = false;
|
|
6772
|
-
// console.log('connectou dentro do connect cb');
|
|
6773
6771
|
_this.publishOnConnect();
|
|
6774
6772
|
}, function () {
|
|
6775
6773
|
_this.setConnected(false);
|
|
@@ -6803,8 +6801,21 @@
|
|
|
6803
6801
|
finally { if (e_3) throw e_3.error; }
|
|
6804
6802
|
}
|
|
6805
6803
|
if (observersCount === 0) {
|
|
6806
|
-
this.stompSubscriptions.forEach(function (
|
|
6807
|
-
|
|
6804
|
+
this.stompSubscriptions.forEach(function (stompSubscriptions) {
|
|
6805
|
+
var e_5, _a;
|
|
6806
|
+
try {
|
|
6807
|
+
for (var stompSubscriptions_1 = __values(stompSubscriptions), stompSubscriptions_1_1 = stompSubscriptions_1.next(); !stompSubscriptions_1_1.done; stompSubscriptions_1_1 = stompSubscriptions_1.next()) {
|
|
6808
|
+
var stompSubscription = stompSubscriptions_1_1.value;
|
|
6809
|
+
stompSubscription.unsubscribe();
|
|
6810
|
+
}
|
|
6811
|
+
}
|
|
6812
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
6813
|
+
finally {
|
|
6814
|
+
try {
|
|
6815
|
+
if (stompSubscriptions_1_1 && !stompSubscriptions_1_1.done && (_a = stompSubscriptions_1.return)) _a.call(stompSubscriptions_1);
|
|
6816
|
+
}
|
|
6817
|
+
finally { if (e_5) throw e_5.error; }
|
|
6818
|
+
}
|
|
6808
6819
|
});
|
|
6809
6820
|
try {
|
|
6810
6821
|
for (var _e = __values(this.primitiveManagers.values()), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
@@ -6834,11 +6845,15 @@
|
|
|
6834
6845
|
WebsocketService.prototype.setConnected = function (connected) {
|
|
6835
6846
|
this.connected = connected;
|
|
6836
6847
|
};
|
|
6837
|
-
WebsocketService.prototype.
|
|
6848
|
+
WebsocketService.prototype.getSubscriptionWithUserUrl = function (domain, service, primitive) {
|
|
6838
6849
|
var tenant = WebsocketService_1.TOKEN ? WebsocketService_1.TOKEN.username.split("@")[1] : null;
|
|
6839
6850
|
var token = WebsocketService_1.TOKEN ? WebsocketService_1.TOKEN.access_token : null;
|
|
6840
6851
|
return "/topic/" + tenant + "/" + token + "/" + domain + "/" + service + "/" + primitive;
|
|
6841
6852
|
};
|
|
6853
|
+
WebsocketService.prototype.getSubscriptionWithoutUserUrl = function (domain, service, primitive) {
|
|
6854
|
+
var tenant = WebsocketService_1.TOKEN ? WebsocketService_1.TOKEN.username.split("@")[1] : null;
|
|
6855
|
+
return "/topic/" + tenant + "/" + domain + "/" + service + "/" + primitive;
|
|
6856
|
+
};
|
|
6842
6857
|
WebsocketService.prototype.createStompClient = function () {
|
|
6843
6858
|
var ws = new SockJS(WebsocketService_1.WEBSOCKET_URL + "subscription", null, { timeout: WebsocketService_1.CONNECTION_TIMEOUT });
|
|
6844
6859
|
this._stompClient = stompjs.Stomp.over(ws);
|
|
@@ -6856,12 +6871,10 @@
|
|
|
6856
6871
|
this._stompClient.disconnect();
|
|
6857
6872
|
var baseUrl = this.getBaseUrl();
|
|
6858
6873
|
if (this.baseUrl !== null && baseUrl != this.baseUrl) {
|
|
6859
|
-
// //console.log('ws disconnected: base url changed', this.baseUrl, ' -> ', baseUrl || 'null');
|
|
6860
6874
|
return;
|
|
6861
6875
|
}
|
|
6862
6876
|
var username = this.getUserName();
|
|
6863
6877
|
if (this.username !== null && username != this.username) {
|
|
6864
|
-
// //console.log('ws disconnected: username changed', this.username, ' -> ', username || 'null');
|
|
6865
6878
|
return;
|
|
6866
6879
|
}
|
|
6867
6880
|
setTimeout(function () {
|
|
@@ -6922,18 +6935,20 @@
|
|
|
6922
6935
|
/**
|
|
6923
6936
|
* Method to verify if user has permission on a specific module
|
|
6924
6937
|
* @param module Module to verify the permission
|
|
6938
|
+
* @param requestPermission Indicative if must be call the primitive
|
|
6925
6939
|
* @returns An boolean Observable
|
|
6926
6940
|
*/
|
|
6927
|
-
VerifyModulePermission.prototype.hasPermission = function (module) {
|
|
6941
|
+
VerifyModulePermission.prototype.hasPermission = function (module, requestPermission) {
|
|
6928
6942
|
var moduleSubject = VerifyModulePermission_1.subjectsPerModuleMap.get(module);
|
|
6929
|
-
if (!moduleSubject) {
|
|
6943
|
+
if (!moduleSubject || requestPermission) {
|
|
6930
6944
|
var newModuleSubject_1 = new rxjs.ReplaySubject(1);
|
|
6931
6945
|
VerifyModulePermission_1.subjectsPerModuleMap.set(module, newModuleSubject_1);
|
|
6932
6946
|
this.verifyModulePermissionService
|
|
6933
|
-
.queryModule({ modulo: module })
|
|
6947
|
+
.queryModule({ modulo: module, somenteAtivo: true })
|
|
6934
6948
|
.pipe(operators.take(1))
|
|
6935
6949
|
.subscribe(function (response) {
|
|
6936
|
-
var
|
|
6950
|
+
var _a;
|
|
6951
|
+
var hasPermission = ((_a = response === null || response === void 0 ? void 0 : response.modulos) === null || _a === void 0 ? void 0 : _a.length) > 0;
|
|
6937
6952
|
newModuleSubject_1.next(hasPermission);
|
|
6938
6953
|
}, function (err) {
|
|
6939
6954
|
VerifyModulePermission_1.subjectsPerModuleMap.delete(module);
|