@senior-gestao-empresarial/angular-components 6.9.0 → 6.9.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 +49 -29
- 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 +5 -9
- package/esm2015/components/websocket/websocket.service.js +49 -34
- package/esm5/components/websocket/websocket.service.js +56 -36
- package/fesm2015/senior-gestao-empresarial-angular-components.js +43 -28
- package/fesm2015/senior-gestao-empresarial-angular-components.js.map +1 -1
- package/fesm5/senior-gestao-empresarial-angular-components.js +50 -30
- 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
|
@@ -3,7 +3,7 @@ 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, timer, iif, fromEvent,
|
|
6
|
+
import { Subject, throwError, interval, of, race, timer, iif, fromEvent, ReplaySubject } from 'rxjs';
|
|
7
7
|
import { takeUntil, filter, catchError, map, takeWhile, switchMap, take, finalize, first } from 'rxjs/operators';
|
|
8
8
|
import * as moment_ from 'moment';
|
|
9
9
|
import { FormField, FieldType } from '@seniorsistemas/angular-components';
|
|
@@ -6984,8 +6984,6 @@ var WebsocketService = /** @class */ (function () {
|
|
|
6984
6984
|
/** @private */
|
|
6985
6985
|
this.isConnecting = false;
|
|
6986
6986
|
/** @private */
|
|
6987
|
-
this.isReconnecting = false;
|
|
6988
|
-
/** @private */
|
|
6989
6987
|
this.primitiveManagers = new Map();
|
|
6990
6988
|
/** @private */
|
|
6991
6989
|
this.connect$ = new Subject();
|
|
@@ -7032,11 +7030,12 @@ var WebsocketService = /** @class */ (function () {
|
|
|
7032
7030
|
var domain = _a.domain, service = _a.service, primitive = _a.primitive;
|
|
7033
7031
|
var key = this.getPrimitiveManagerKey(domain, service, primitive);
|
|
7034
7032
|
return this.onConnect().pipe(switchMap(function () {
|
|
7035
|
-
return _this.primitiveManagers.has(key) &&
|
|
7033
|
+
return _this.primitiveManagers.has(key) &&
|
|
7034
|
+
_this.primitiveManagers.get(key).isSubscribed
|
|
7036
7035
|
? of(void 0).pipe(take(1))
|
|
7037
7036
|
: _this.subscribe$.pipe(filter(function (primitiveManager) {
|
|
7038
7037
|
return _this.getPrimitiveManagerKey(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive) === key;
|
|
7039
|
-
}), take(1),
|
|
7038
|
+
}), take(1), map(function () { return void 0; }));
|
|
7040
7039
|
}));
|
|
7041
7040
|
};
|
|
7042
7041
|
/**
|
|
@@ -7067,21 +7066,29 @@ var WebsocketService = /** @class */ (function () {
|
|
|
7067
7066
|
primitive: primitive,
|
|
7068
7067
|
stompSubscriptions: [],
|
|
7069
7068
|
event$: new Subject(),
|
|
7070
|
-
isSubscribed: false
|
|
7069
|
+
isSubscribed: false
|
|
7071
7070
|
};
|
|
7072
7071
|
this.primitiveManagers.set(key, primitiveManager);
|
|
7073
7072
|
if (this.isConnected) {
|
|
7074
7073
|
this.createStompSubscriptions(primitiveManager);
|
|
7075
|
-
return primitiveManager.event
|
|
7074
|
+
return primitiveManager.event$
|
|
7075
|
+
.asObservable()
|
|
7076
|
+
.pipe(finalize(function () {
|
|
7077
|
+
return _this.disconnectPrimitiveOnFinalize(primitiveManager);
|
|
7078
|
+
}));
|
|
7076
7079
|
}
|
|
7077
7080
|
else {
|
|
7078
|
-
if (!this.
|
|
7081
|
+
if (!this.isConnecting) {
|
|
7079
7082
|
this.connect();
|
|
7080
7083
|
}
|
|
7081
7084
|
this.connect$.pipe(first()).subscribe(function () {
|
|
7082
7085
|
_this.createStompSubscriptions(primitiveManager);
|
|
7083
7086
|
});
|
|
7084
|
-
return primitiveManager.event
|
|
7087
|
+
return primitiveManager.event$
|
|
7088
|
+
.asObservable()
|
|
7089
|
+
.pipe(finalize(function () {
|
|
7090
|
+
return _this.disconnectPrimitiveOnFinalize(primitiveManager);
|
|
7091
|
+
}));
|
|
7085
7092
|
}
|
|
7086
7093
|
};
|
|
7087
7094
|
/** @private */
|
|
@@ -7090,7 +7097,10 @@ var WebsocketService = /** @class */ (function () {
|
|
|
7090
7097
|
var stompSubscriptionWithToken = this.createStompSubscription(withTokenUrl, primitiveManager);
|
|
7091
7098
|
var withoutTokenUrl = this.getSubscriptionUrlWithoutToken(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
7092
7099
|
var stompSubscriptionWithoutToken = this.createStompSubscription(withoutTokenUrl, primitiveManager);
|
|
7093
|
-
primitiveManager.stompSubscriptions = [
|
|
7100
|
+
primitiveManager.stompSubscriptions = [
|
|
7101
|
+
stompSubscriptionWithToken,
|
|
7102
|
+
stompSubscriptionWithoutToken
|
|
7103
|
+
];
|
|
7094
7104
|
primitiveManager.isSubscribed = true;
|
|
7095
7105
|
this.subscribe$.next(primitiveManager);
|
|
7096
7106
|
};
|
|
@@ -7101,7 +7111,6 @@ var WebsocketService = /** @class */ (function () {
|
|
|
7101
7111
|
this.isConnecting = true;
|
|
7102
7112
|
this._stompClient.connect({}, function () {
|
|
7103
7113
|
_this.isConnecting = false;
|
|
7104
|
-
_this.isReconnecting = false;
|
|
7105
7114
|
_this.isConnected = true;
|
|
7106
7115
|
if (_this.wasConnected) {
|
|
7107
7116
|
_this.reconnectPrimitives();
|
|
@@ -7115,19 +7124,26 @@ var WebsocketService = /** @class */ (function () {
|
|
|
7115
7124
|
}, function (error) {
|
|
7116
7125
|
_this.isConnected = false;
|
|
7117
7126
|
_this.error$.next(error);
|
|
7118
|
-
_this.
|
|
7119
|
-
|
|
7120
|
-
|
|
7121
|
-
|
|
7122
|
-
|
|
7123
|
-
|
|
7127
|
+
race(_this.disconnect$.pipe(take(1), map(function () { return ({ wasDisconnected: true }); })), timer(WebsocketService_1.RECONNECT_INTERVAL).pipe(take(1), switchMap(function () {
|
|
7128
|
+
return iif(function () { return document.hidden; }, fromEvent(document, 'visibilitychange').pipe(first()), of(void 0));
|
|
7129
|
+
}), map(function () { return ({ wasDisconnected: false }); })))
|
|
7130
|
+
.pipe(take(1))
|
|
7131
|
+
.subscribe({
|
|
7132
|
+
next: function (_a) {
|
|
7133
|
+
var wasDisconnected = _a.wasDisconnected;
|
|
7134
|
+
if (!wasDisconnected &&
|
|
7135
|
+
!(_this.isConnected || _this.isConnecting)) {
|
|
7136
|
+
_this.connect();
|
|
7137
|
+
}
|
|
7138
|
+
}
|
|
7139
|
+
});
|
|
7124
7140
|
});
|
|
7125
7141
|
};
|
|
7126
7142
|
WebsocketService.prototype.disconnect = function () {
|
|
7127
7143
|
var e_1, _a, e_2, _b, e_3, _c;
|
|
7128
|
-
|
|
7129
|
-
if (observersCount > 0)
|
|
7144
|
+
if (this.getObserversCount() > 0) {
|
|
7130
7145
|
return;
|
|
7146
|
+
}
|
|
7131
7147
|
try {
|
|
7132
7148
|
for (var _d = __values(this.primitiveManagers.values()), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
7133
7149
|
var primitiveManager = _e.value;
|
|
@@ -7176,19 +7192,25 @@ var WebsocketService = /** @class */ (function () {
|
|
|
7176
7192
|
};
|
|
7177
7193
|
/** @private */
|
|
7178
7194
|
WebsocketService.prototype.getSubscriptionUrlWithToken = function (domain, service, primitive) {
|
|
7179
|
-
var tenant = WebsocketService_1.TOKEN
|
|
7180
|
-
|
|
7195
|
+
var tenant = WebsocketService_1.TOKEN
|
|
7196
|
+
? WebsocketService_1.TOKEN.username.split('@')[1]
|
|
7197
|
+
: null;
|
|
7198
|
+
var token = WebsocketService_1.TOKEN
|
|
7199
|
+
? WebsocketService_1.TOKEN.access_token
|
|
7200
|
+
: null;
|
|
7181
7201
|
return "/topic/" + tenant + "/" + token + "/" + domain + "/" + service + "/" + primitive;
|
|
7182
7202
|
};
|
|
7183
7203
|
/** @private */
|
|
7184
7204
|
WebsocketService.prototype.getSubscriptionUrlWithoutToken = function (domain, service, primitive) {
|
|
7185
|
-
var tenant = WebsocketService_1.TOKEN
|
|
7205
|
+
var tenant = WebsocketService_1.TOKEN
|
|
7206
|
+
? WebsocketService_1.TOKEN.username.split('@')[1]
|
|
7207
|
+
: null;
|
|
7186
7208
|
return "/topic/" + tenant + "/" + domain + "/" + service + "/" + primitive;
|
|
7187
7209
|
};
|
|
7188
7210
|
/** @private */
|
|
7189
7211
|
WebsocketService.prototype.createStompSubscription = function (destination, primitiveManager) {
|
|
7190
7212
|
return this._stompClient.subscribe(destination, function (message) {
|
|
7191
|
-
var event = JSON.parse(message.body ||
|
|
7213
|
+
var event = JSON.parse(message.body || '{}');
|
|
7192
7214
|
primitiveManager.event$.next(event);
|
|
7193
7215
|
});
|
|
7194
7216
|
};
|
|
@@ -7264,22 +7286,20 @@ var WebsocketService = /** @class */ (function () {
|
|
|
7264
7286
|
return domain + "/" + service + "/" + primitive;
|
|
7265
7287
|
};
|
|
7266
7288
|
var WebsocketService_1;
|
|
7267
|
-
/** @private */
|
|
7268
7289
|
WebsocketService.RECONNECT_INTERVAL = 3000;
|
|
7269
|
-
/** @private */
|
|
7270
7290
|
WebsocketService.CONNECTION_TIMEOUT = 15000;
|
|
7271
7291
|
/** @private */
|
|
7272
|
-
WebsocketService.BASE_URL_COOKIE =
|
|
7292
|
+
WebsocketService.BASE_URL_COOKIE = 'com.senior.base.url';
|
|
7273
7293
|
/** @private */
|
|
7274
|
-
WebsocketService.TOKEN_COOKIE =
|
|
7294
|
+
WebsocketService.TOKEN_COOKIE = 'com.senior.token';
|
|
7275
7295
|
/** @private */
|
|
7276
|
-
WebsocketService.TOKEN = JSON.parse(get(WebsocketService_1.TOKEN_COOKIE) ||
|
|
7296
|
+
WebsocketService.TOKEN = JSON.parse(get(WebsocketService_1.TOKEN_COOKIE) || '{}');
|
|
7277
7297
|
/** @private */
|
|
7278
|
-
WebsocketService.WEBSOCKET_URL = get(WebsocketService_1.BASE_URL_COOKIE) +
|
|
7298
|
+
WebsocketService.WEBSOCKET_URL = get(WebsocketService_1.BASE_URL_COOKIE) + '/websocket/';
|
|
7279
7299
|
WebsocketService.ɵprov = ɵɵdefineInjectable({ factory: function WebsocketService_Factory() { return new WebsocketService(); }, token: WebsocketService, providedIn: "root" });
|
|
7280
7300
|
WebsocketService = WebsocketService_1 = __decorate([
|
|
7281
7301
|
Injectable({
|
|
7282
|
-
providedIn:
|
|
7302
|
+
providedIn: 'root'
|
|
7283
7303
|
})
|
|
7284
7304
|
], WebsocketService);
|
|
7285
7305
|
return WebsocketService;
|