@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
|
@@ -4,7 +4,7 @@ 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
6
|
import { Subject, throwError, interval, of, ReplaySubject } from 'rxjs';
|
|
7
|
-
import { takeUntil, filter, catchError, map, takeWhile, switchMap, take } from 'rxjs/operators';
|
|
7
|
+
import { takeUntil, filter, catchError, map, takeWhile, switchMap, first, take } 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';
|
|
@@ -6022,7 +6022,6 @@ let WebsocketService = WebsocketService_1 = class WebsocketService {
|
|
|
6022
6022
|
this.connected = false;
|
|
6023
6023
|
this.isConnecting = false;
|
|
6024
6024
|
this.stompSubscriptions = new Map();
|
|
6025
|
-
// private primitiveSubjects: Map<string, Subject<any>> = new Map<string, Subject<any>>();
|
|
6026
6025
|
this.primitiveManagers = new Map();
|
|
6027
6026
|
this.disconnectSubject = new Subject();
|
|
6028
6027
|
this.connect$ = new Subject();
|
|
@@ -6031,7 +6030,7 @@ let WebsocketService = WebsocketService_1 = class WebsocketService {
|
|
|
6031
6030
|
this.connect();
|
|
6032
6031
|
}
|
|
6033
6032
|
/**
|
|
6034
|
-
* Observable
|
|
6033
|
+
* Observable responsável por emitir uma notificação quando a conexão websocket é estabelecida.
|
|
6035
6034
|
* @return Um `Observable<void>` que emite uma notificação quando a conexão websocket é estabelecida ou já está em andamento.
|
|
6036
6035
|
*/
|
|
6037
6036
|
onConnect() {
|
|
@@ -6043,7 +6042,7 @@ let WebsocketService = WebsocketService_1 = class WebsocketService {
|
|
|
6043
6042
|
return this.connect$.asObservable();
|
|
6044
6043
|
}
|
|
6045
6044
|
/**
|
|
6046
|
-
* Observable
|
|
6045
|
+
* Observable responsável por emitir uma notificação quando a conexão é finalizada.
|
|
6047
6046
|
* @return Um `Observable<void>` que emite uma notificação quando a conexão é finalizada.
|
|
6048
6047
|
*/
|
|
6049
6048
|
onDisconnect() {
|
|
@@ -6069,14 +6068,7 @@ let WebsocketService = WebsocketService_1 = class WebsocketService {
|
|
|
6069
6068
|
publishedEvents: [],
|
|
6070
6069
|
};
|
|
6071
6070
|
if (this.isConnected()) {
|
|
6072
|
-
|
|
6073
|
-
this.primitiveManagers.set(primitive, primitiveManager);
|
|
6074
|
-
const stompSubscription = this._stompClient.subscribe(url, (message) => {
|
|
6075
|
-
const event = JSON.parse(message.body || "{}");
|
|
6076
|
-
this.addPublishedEvent(primitiveManager, event);
|
|
6077
|
-
primitiveManager.subject.next(event);
|
|
6078
|
-
});
|
|
6079
|
-
this.stompSubscriptions.set(primitive, stompSubscription);
|
|
6071
|
+
this.createStompSubscriptions(domain, service, primitive, primitiveManager);
|
|
6080
6072
|
return primitiveManager.subject.asObservable();
|
|
6081
6073
|
}
|
|
6082
6074
|
else {
|
|
@@ -6084,22 +6076,15 @@ let WebsocketService = WebsocketService_1 = class WebsocketService {
|
|
|
6084
6076
|
this.connect();
|
|
6085
6077
|
}
|
|
6086
6078
|
this.onConnect()
|
|
6087
|
-
.pipe(
|
|
6079
|
+
.pipe(first())
|
|
6088
6080
|
.subscribe(() => {
|
|
6089
|
-
|
|
6090
|
-
this.primitiveManagers.set(primitive, primitiveManager);
|
|
6091
|
-
const stompSubscription = this._stompClient.subscribe(url, (message) => {
|
|
6092
|
-
const event = JSON.parse(message.body || "{}");
|
|
6093
|
-
this.addPublishedEvent(primitiveManager, event);
|
|
6094
|
-
primitiveManager.subject.next(event);
|
|
6095
|
-
});
|
|
6096
|
-
this.stompSubscriptions.set(primitive, stompSubscription);
|
|
6081
|
+
this.createStompSubscriptions(domain, service, primitive, primitiveManager);
|
|
6097
6082
|
});
|
|
6098
6083
|
return primitiveManager.subject.asObservable();
|
|
6099
6084
|
}
|
|
6100
6085
|
}
|
|
6101
6086
|
/**
|
|
6102
|
-
* Retorna todos os eventos ouvidos
|
|
6087
|
+
* Retorna todos os eventos ouvidos pela primitiva com os respectivos identificadores.
|
|
6103
6088
|
* @typeParam `<T>` Tipo do evento retornado pela primitiva.
|
|
6104
6089
|
* @param primitive Primitiva que será "observada" pelo client.
|
|
6105
6090
|
* @param identifiers Array com os indentificadores interessados.
|
|
@@ -6126,6 +6111,14 @@ let WebsocketService = WebsocketService_1 = class WebsocketService {
|
|
|
6126
6111
|
primitiveManager.publishedEvents.push(event);
|
|
6127
6112
|
}
|
|
6128
6113
|
}
|
|
6114
|
+
createStompSubscriptions(domain, service, primitive, primitiveManager) {
|
|
6115
|
+
const withTokenUrl = this.getSubscriptionUrlWithToken(domain, service, primitive);
|
|
6116
|
+
this.primitiveManagers.set(primitive, primitiveManager);
|
|
6117
|
+
const stompSubscriptionWithToken = this.createStompSubscription(withTokenUrl, primitiveManager);
|
|
6118
|
+
const withoutTokenUrl = this.getSubscriptionUrlWithoutToken(domain, service, primitive);
|
|
6119
|
+
const stompSubscriptionWithoutToken = this.createStompSubscription(withoutTokenUrl, primitiveManager);
|
|
6120
|
+
this.stompSubscriptions.set(primitive, [stompSubscriptionWithToken, stompSubscriptionWithoutToken]);
|
|
6121
|
+
}
|
|
6129
6122
|
getIdentifierFromEvent(identifierPath, event) {
|
|
6130
6123
|
const properties = identifierPath.split(".");
|
|
6131
6124
|
let identifier = event;
|
|
@@ -6139,9 +6132,7 @@ let WebsocketService = WebsocketService_1 = class WebsocketService {
|
|
|
6139
6132
|
this.isConnecting = true;
|
|
6140
6133
|
this._stompClient.connect({}, () => {
|
|
6141
6134
|
this.setConnected(true);
|
|
6142
|
-
// console.log('setou false isConnecting');
|
|
6143
6135
|
this.isConnecting = false;
|
|
6144
|
-
// console.log('connectou dentro do connect cb');
|
|
6145
6136
|
this.publishOnConnect();
|
|
6146
6137
|
}, () => {
|
|
6147
6138
|
this.setConnected(false);
|
|
@@ -6164,8 +6155,10 @@ let WebsocketService = WebsocketService_1 = class WebsocketService {
|
|
|
6164
6155
|
observersCount += primitiveManager.subject.observers.length;
|
|
6165
6156
|
}
|
|
6166
6157
|
if (observersCount === 0) {
|
|
6167
|
-
this.stompSubscriptions.forEach(
|
|
6168
|
-
stompSubscription
|
|
6158
|
+
this.stompSubscriptions.forEach(stompSubscriptions => {
|
|
6159
|
+
for (const stompSubscription of stompSubscriptions) {
|
|
6160
|
+
stompSubscription.unsubscribe();
|
|
6161
|
+
}
|
|
6169
6162
|
});
|
|
6170
6163
|
for (const primitiveManager of this.primitiveManagers.values()) {
|
|
6171
6164
|
primitiveManager.subject.complete();
|
|
@@ -6185,11 +6178,22 @@ let WebsocketService = WebsocketService_1 = class WebsocketService {
|
|
|
6185
6178
|
setConnected(connected) {
|
|
6186
6179
|
this.connected = connected;
|
|
6187
6180
|
}
|
|
6188
|
-
|
|
6181
|
+
getSubscriptionUrlWithToken(domain, service, primitive) {
|
|
6189
6182
|
const tenant = WebsocketService_1.TOKEN ? WebsocketService_1.TOKEN.username.split("@")[1] : null;
|
|
6190
6183
|
const token = WebsocketService_1.TOKEN ? WebsocketService_1.TOKEN.access_token : null;
|
|
6191
6184
|
return `/topic/${tenant}/${token}/${domain}/${service}/${primitive}`;
|
|
6192
6185
|
}
|
|
6186
|
+
getSubscriptionUrlWithoutToken(domain, service, primitive) {
|
|
6187
|
+
const tenant = WebsocketService_1.TOKEN ? WebsocketService_1.TOKEN.username.split("@")[1] : null;
|
|
6188
|
+
return `/topic/${tenant}/${domain}/${service}/${primitive}`;
|
|
6189
|
+
}
|
|
6190
|
+
createStompSubscription(destination, primitiveManager) {
|
|
6191
|
+
return this._stompClient.subscribe(destination, (message) => {
|
|
6192
|
+
const event = JSON.parse(message.body || "{}");
|
|
6193
|
+
this.addPublishedEvent(primitiveManager, event);
|
|
6194
|
+
primitiveManager.subject.next(event);
|
|
6195
|
+
});
|
|
6196
|
+
}
|
|
6193
6197
|
createStompClient() {
|
|
6194
6198
|
const ws = new SockJS(`${WebsocketService_1.WEBSOCKET_URL}subscription`, null, { timeout: WebsocketService_1.CONNECTION_TIMEOUT });
|
|
6195
6199
|
this._stompClient = Stomp.over(ws);
|
|
@@ -6206,12 +6210,10 @@ let WebsocketService = WebsocketService_1 = class WebsocketService {
|
|
|
6206
6210
|
this._stompClient.disconnect();
|
|
6207
6211
|
const baseUrl = this.getBaseUrl();
|
|
6208
6212
|
if (this.baseUrl !== null && baseUrl != this.baseUrl) {
|
|
6209
|
-
// //console.log('ws disconnected: base url changed', this.baseUrl, ' -> ', baseUrl || 'null');
|
|
6210
6213
|
return;
|
|
6211
6214
|
}
|
|
6212
6215
|
const username = this.getUserName();
|
|
6213
6216
|
if (this.username !== null && username != this.username) {
|
|
6214
|
-
// //console.log('ws disconnected: username changed', this.username, ' -> ', username || 'null');
|
|
6215
6217
|
return;
|
|
6216
6218
|
}
|
|
6217
6219
|
setTimeout(() => {
|