@senior-gestao-empresarial/angular-components 6.7.1 → 6.9.0
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 +63 -87
- 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 +16 -16
- package/esm2015/components/websocket/websocket.service.js +48 -68
- package/esm5/components/websocket/websocket.service.js +66 -90
- package/fesm2015/senior-gestao-empresarial-angular-components.js +47 -67
- package/fesm2015/senior-gestao-empresarial-angular-components.js.map +1 -1
- package/fesm5/senior-gestao-empresarial-angular-components.js +65 -89
- 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,8 +3,8 @@ 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, ReplaySubject } from 'rxjs';
|
|
7
|
-
import { takeUntil, filter, catchError, map, takeWhile, switchMap,
|
|
6
|
+
import { Subject, throwError, interval, of, timer, iif, fromEvent, EMPTY, ReplaySubject } from 'rxjs';
|
|
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';
|
|
10
10
|
import { HttpParams, HttpClient } from '@angular/common/http';
|
|
@@ -6977,15 +6977,15 @@ var NpsService = /** @class */ (function () {
|
|
|
6977
6977
|
|
|
6978
6978
|
var WebsocketService = /** @class */ (function () {
|
|
6979
6979
|
function WebsocketService() {
|
|
6980
|
-
/** @private */
|
|
6981
|
-
this.focused = true;
|
|
6982
6980
|
/** @private */
|
|
6983
6981
|
this.wasConnected = false;
|
|
6984
6982
|
/** @private */
|
|
6985
|
-
this.
|
|
6983
|
+
this.isConnected = false;
|
|
6986
6984
|
/** @private */
|
|
6987
6985
|
this.isConnecting = false;
|
|
6988
6986
|
/** @private */
|
|
6987
|
+
this.isReconnecting = false;
|
|
6988
|
+
/** @private */
|
|
6989
6989
|
this.primitiveManagers = new Map();
|
|
6990
6990
|
/** @private */
|
|
6991
6991
|
this.connect$ = new Subject();
|
|
@@ -6995,23 +6995,19 @@ var WebsocketService = /** @class */ (function () {
|
|
|
6995
6995
|
this.reconnect$ = new Subject();
|
|
6996
6996
|
/** @private */
|
|
6997
6997
|
this.error$ = new Subject();
|
|
6998
|
-
|
|
6999
|
-
window.onblur = this.onBlur;
|
|
6998
|
+
this.subscribe$ = new Subject();
|
|
7000
6999
|
this.connect();
|
|
7001
7000
|
}
|
|
7002
7001
|
WebsocketService_1 = WebsocketService;
|
|
7003
7002
|
/**
|
|
7004
|
-
* Observable responsável por emitir uma notificação quando a conexão websocket é estabelecida.
|
|
7005
|
-
* @return Um `Observable<void>` que emite uma notificação quando a conexão websocket é estabelecida.
|
|
7003
|
+
* Observable responsável por emitir uma notificação quando a conexão websocket é estabelecida pela primeira vez.
|
|
7004
|
+
* @return Um `Observable<void>` que emite uma notificação quando a conexão websocket é estabelecida pela primeira vez.
|
|
7006
7005
|
*/
|
|
7007
7006
|
WebsocketService.prototype.onConnect = function () {
|
|
7008
|
-
|
|
7009
|
-
|
|
7010
|
-
|
|
7011
|
-
|
|
7012
|
-
}
|
|
7013
|
-
}, 0);
|
|
7014
|
-
return this.connect$.pipe(first());
|
|
7007
|
+
if (this.isConnected || this.wasConnected) {
|
|
7008
|
+
return of(undefined).pipe(take(1));
|
|
7009
|
+
}
|
|
7010
|
+
return this.connect$.asObservable().pipe(take(1));
|
|
7015
7011
|
};
|
|
7016
7012
|
/**
|
|
7017
7013
|
* Observable responsável por emitir uma notificação quando a conexão é desconectada.
|
|
@@ -7027,6 +7023,22 @@ var WebsocketService = /** @class */ (function () {
|
|
|
7027
7023
|
WebsocketService.prototype.onReconnect = function () {
|
|
7028
7024
|
return this.reconnect$.asObservable();
|
|
7029
7025
|
};
|
|
7026
|
+
/**
|
|
7027
|
+
* Observable responsável por emitir uma notificação após o subscribe do evento pela primeira vez.
|
|
7028
|
+
* @return Um `Observable<void>` que emite uma notificação após o subscribe do evento pela primeira vez.
|
|
7029
|
+
*/
|
|
7030
|
+
WebsocketService.prototype.onSubscribe = function (_a) {
|
|
7031
|
+
var _this = this;
|
|
7032
|
+
var domain = _a.domain, service = _a.service, primitive = _a.primitive;
|
|
7033
|
+
var key = this.getPrimitiveManagerKey(domain, service, primitive);
|
|
7034
|
+
return this.onConnect().pipe(switchMap(function () {
|
|
7035
|
+
return _this.primitiveManagers.has(key) && _this.primitiveManagers.get(key).isSubscribed
|
|
7036
|
+
? of(void 0).pipe(take(1))
|
|
7037
|
+
: _this.subscribe$.pipe(filter(function (primitiveManager) {
|
|
7038
|
+
return _this.getPrimitiveManagerKey(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive) === key;
|
|
7039
|
+
}), take(1), (map(function () { return void 0; })));
|
|
7040
|
+
}));
|
|
7041
|
+
};
|
|
7030
7042
|
/**
|
|
7031
7043
|
* Observable responsável por emitir uma notificação quando ocorre algum erro.
|
|
7032
7044
|
* @return Um `Observable<FrameImpl>` que emite uma notificação quando ocorre algum erro.
|
|
@@ -7047,28 +7059,29 @@ var WebsocketService = /** @class */ (function () {
|
|
|
7047
7059
|
var domain = options.domain, service = options.service, primitive = options.primitive;
|
|
7048
7060
|
var key = this.getPrimitiveManagerKey(domain, service, primitive);
|
|
7049
7061
|
if (this.primitiveManagers.has(key)) {
|
|
7050
|
-
return this.primitiveManagers.get(key).
|
|
7062
|
+
return this.primitiveManagers.get(key).event$.asObservable();
|
|
7051
7063
|
}
|
|
7052
7064
|
var primitiveManager = {
|
|
7053
7065
|
domain: domain,
|
|
7054
7066
|
service: service,
|
|
7055
7067
|
primitive: primitive,
|
|
7056
7068
|
stompSubscriptions: [],
|
|
7057
|
-
|
|
7069
|
+
event$: new Subject(),
|
|
7070
|
+
isSubscribed: false,
|
|
7058
7071
|
};
|
|
7059
7072
|
this.primitiveManagers.set(key, primitiveManager);
|
|
7060
|
-
if (this.isConnected
|
|
7073
|
+
if (this.isConnected) {
|
|
7061
7074
|
this.createStompSubscriptions(primitiveManager);
|
|
7062
|
-
return primitiveManager.
|
|
7075
|
+
return primitiveManager.event$.asObservable().pipe(finalize(function () { return _this.disconnectPrimitiveOnFinalize(primitiveManager); }));
|
|
7063
7076
|
}
|
|
7064
7077
|
else {
|
|
7065
|
-
if (!this.isConnecting) {
|
|
7078
|
+
if (!this.isReconnecting && !this.isConnecting) {
|
|
7066
7079
|
this.connect();
|
|
7067
7080
|
}
|
|
7068
7081
|
this.connect$.pipe(first()).subscribe(function () {
|
|
7069
7082
|
_this.createStompSubscriptions(primitiveManager);
|
|
7070
7083
|
});
|
|
7071
|
-
return primitiveManager.
|
|
7084
|
+
return primitiveManager.event$.asObservable().pipe(finalize(function () { return _this.disconnectPrimitiveOnFinalize(primitiveManager); }));
|
|
7072
7085
|
}
|
|
7073
7086
|
};
|
|
7074
7087
|
/** @private */
|
|
@@ -7078,18 +7091,21 @@ var WebsocketService = /** @class */ (function () {
|
|
|
7078
7091
|
var withoutTokenUrl = this.getSubscriptionUrlWithoutToken(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
7079
7092
|
var stompSubscriptionWithoutToken = this.createStompSubscription(withoutTokenUrl, primitiveManager);
|
|
7080
7093
|
primitiveManager.stompSubscriptions = [stompSubscriptionWithToken, stompSubscriptionWithoutToken];
|
|
7094
|
+
primitiveManager.isSubscribed = true;
|
|
7095
|
+
this.subscribe$.next(primitiveManager);
|
|
7081
7096
|
};
|
|
7082
7097
|
/** @private */
|
|
7083
7098
|
WebsocketService.prototype.connect = function () {
|
|
7084
7099
|
var _this = this;
|
|
7085
7100
|
this.createStompClient();
|
|
7086
7101
|
this.isConnecting = true;
|
|
7087
|
-
this._stompClient.activate();
|
|
7088
7102
|
this._stompClient.connect({}, function () {
|
|
7089
7103
|
_this.isConnecting = false;
|
|
7090
|
-
_this.
|
|
7104
|
+
_this.isReconnecting = false;
|
|
7105
|
+
_this.isConnected = true;
|
|
7091
7106
|
if (_this.wasConnected) {
|
|
7092
7107
|
_this.reconnectPrimitives();
|
|
7108
|
+
_this.connect$.next();
|
|
7093
7109
|
_this.reconnect$.next();
|
|
7094
7110
|
}
|
|
7095
7111
|
else {
|
|
@@ -7097,19 +7113,16 @@ var WebsocketService = /** @class */ (function () {
|
|
|
7097
7113
|
_this.connect$.next();
|
|
7098
7114
|
}
|
|
7099
7115
|
}, function (error) {
|
|
7100
|
-
_this.
|
|
7116
|
+
_this.isConnected = false;
|
|
7101
7117
|
_this.error$.next(error);
|
|
7102
|
-
_this.
|
|
7118
|
+
_this.isReconnecting = true;
|
|
7119
|
+
timer(WebsocketService_1.RECONNECT_INTERVAL)
|
|
7120
|
+
.pipe(switchMap(function () {
|
|
7121
|
+
return iif(function () { return document.hidden; }, fromEvent(document, "visibilitychange").pipe(first()), EMPTY);
|
|
7122
|
+
}))
|
|
7123
|
+
.subscribe({ complete: function () { return _this.connect(); } });
|
|
7103
7124
|
});
|
|
7104
7125
|
};
|
|
7105
|
-
/** @private */
|
|
7106
|
-
WebsocketService.prototype.onFocus = function () {
|
|
7107
|
-
this.focused = true;
|
|
7108
|
-
};
|
|
7109
|
-
/** @private */
|
|
7110
|
-
WebsocketService.prototype.onBlur = function () {
|
|
7111
|
-
this.focused = false;
|
|
7112
|
-
};
|
|
7113
7126
|
WebsocketService.prototype.disconnect = function () {
|
|
7114
7127
|
var e_1, _a, e_2, _b, e_3, _c;
|
|
7115
7128
|
var observersCount = this.getObserversCount();
|
|
@@ -7143,7 +7156,7 @@ var WebsocketService = /** @class */ (function () {
|
|
|
7143
7156
|
try {
|
|
7144
7157
|
for (var _h = __values(this.primitiveManagers.values()), _j = _h.next(); !_j.done; _j = _h.next()) {
|
|
7145
7158
|
var primitiveManager = _j.value;
|
|
7146
|
-
primitiveManager.
|
|
7159
|
+
primitiveManager.event$.complete();
|
|
7147
7160
|
}
|
|
7148
7161
|
}
|
|
7149
7162
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
@@ -7156,20 +7169,12 @@ var WebsocketService = /** @class */ (function () {
|
|
|
7156
7169
|
this.primitiveManagers.clear();
|
|
7157
7170
|
this._stompClient.disconnect();
|
|
7158
7171
|
this._stompClient.deactivate();
|
|
7159
|
-
this.
|
|
7172
|
+
this.isConnected = false;
|
|
7160
7173
|
this.isConnecting = false;
|
|
7161
7174
|
this.wasConnected = false;
|
|
7162
7175
|
this.disconnect$.next();
|
|
7163
7176
|
};
|
|
7164
7177
|
/** @private */
|
|
7165
|
-
WebsocketService.prototype.isConnected = function () {
|
|
7166
|
-
return this.connected;
|
|
7167
|
-
};
|
|
7168
|
-
/** @private */
|
|
7169
|
-
WebsocketService.prototype.setConnected = function (connected) {
|
|
7170
|
-
this.connected = connected;
|
|
7171
|
-
};
|
|
7172
|
-
/** @private */
|
|
7173
7178
|
WebsocketService.prototype.getSubscriptionUrlWithToken = function (domain, service, primitive) {
|
|
7174
7179
|
var tenant = WebsocketService_1.TOKEN ? WebsocketService_1.TOKEN.username.split("@")[1] : null;
|
|
7175
7180
|
var token = WebsocketService_1.TOKEN ? WebsocketService_1.TOKEN.access_token : null;
|
|
@@ -7184,100 +7189,71 @@ var WebsocketService = /** @class */ (function () {
|
|
|
7184
7189
|
WebsocketService.prototype.createStompSubscription = function (destination, primitiveManager) {
|
|
7185
7190
|
return this._stompClient.subscribe(destination, function (message) {
|
|
7186
7191
|
var event = JSON.parse(message.body || "{}");
|
|
7187
|
-
primitiveManager.
|
|
7192
|
+
primitiveManager.event$.next(event);
|
|
7188
7193
|
});
|
|
7189
7194
|
};
|
|
7190
7195
|
/** @private */
|
|
7191
7196
|
WebsocketService.prototype.createStompClient = function () {
|
|
7192
7197
|
var ws = new SockJS(WebsocketService_1.WEBSOCKET_URL + "subscription", null, { timeout: WebsocketService_1.CONNECTION_TIMEOUT });
|
|
7193
7198
|
this._stompClient = Stomp.over(ws);
|
|
7194
|
-
|
|
7195
|
-
this._stompClient.debug = function () { }; // Para remover os logs.
|
|
7196
|
-
};
|
|
7197
|
-
/** @private */
|
|
7198
|
-
WebsocketService.prototype.reconnect = function () {
|
|
7199
|
-
var _this = this;
|
|
7200
|
-
if (this.connected)
|
|
7201
|
-
this._stompClient.disconnect();
|
|
7202
|
-
setTimeout(function () {
|
|
7203
|
-
if (_this.getObserversCount() === 0)
|
|
7204
|
-
return;
|
|
7205
|
-
if (_this.focused) {
|
|
7206
|
-
_this.connect();
|
|
7207
|
-
}
|
|
7208
|
-
else {
|
|
7209
|
-
_this.reconnect();
|
|
7210
|
-
}
|
|
7211
|
-
}, WebsocketService_1.RECONNECT_TIMER);
|
|
7199
|
+
this._stompClient.debug = function () { return null; };
|
|
7212
7200
|
};
|
|
7213
7201
|
/** @private */
|
|
7214
7202
|
WebsocketService.prototype.reconnectPrimitives = function () {
|
|
7215
|
-
var e_4, _a
|
|
7203
|
+
var e_4, _a;
|
|
7216
7204
|
try {
|
|
7217
|
-
for (var
|
|
7218
|
-
var primitiveManager =
|
|
7219
|
-
try {
|
|
7220
|
-
for (var _e = (e_5 = void 0, __values(primitiveManager.stompSubscriptions)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
7221
|
-
var stompSubscription = _f.value;
|
|
7222
|
-
stompSubscription.unsubscribe();
|
|
7223
|
-
}
|
|
7224
|
-
}
|
|
7225
|
-
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
7226
|
-
finally {
|
|
7227
|
-
try {
|
|
7228
|
-
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
7229
|
-
}
|
|
7230
|
-
finally { if (e_5) throw e_5.error; }
|
|
7231
|
-
}
|
|
7205
|
+
for (var _b = __values(this.primitiveManagers.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
7206
|
+
var primitiveManager = _c.value;
|
|
7232
7207
|
this.createStompSubscriptions(primitiveManager);
|
|
7233
7208
|
}
|
|
7234
7209
|
}
|
|
7235
7210
|
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
7236
7211
|
finally {
|
|
7237
7212
|
try {
|
|
7238
|
-
if (
|
|
7213
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
7239
7214
|
}
|
|
7240
7215
|
finally { if (e_4) throw e_4.error; }
|
|
7241
7216
|
}
|
|
7242
7217
|
};
|
|
7243
7218
|
/** @private */
|
|
7244
7219
|
WebsocketService.prototype.getObserversCount = function () {
|
|
7245
|
-
var
|
|
7220
|
+
var e_5, _a;
|
|
7246
7221
|
var observersCount = 0;
|
|
7247
7222
|
try {
|
|
7248
7223
|
for (var _b = __values(this.primitiveManagers.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
7249
7224
|
var primitiveManager = _c.value;
|
|
7250
|
-
observersCount += primitiveManager.
|
|
7225
|
+
observersCount += primitiveManager.event$.observers.length;
|
|
7251
7226
|
}
|
|
7252
7227
|
}
|
|
7253
|
-
catch (
|
|
7228
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
7254
7229
|
finally {
|
|
7255
7230
|
try {
|
|
7256
7231
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
7257
7232
|
}
|
|
7258
|
-
finally { if (
|
|
7233
|
+
finally { if (e_5) throw e_5.error; }
|
|
7259
7234
|
}
|
|
7260
7235
|
return observersCount;
|
|
7261
7236
|
};
|
|
7262
7237
|
/** @private */
|
|
7263
7238
|
WebsocketService.prototype.disconnectPrimitiveOnFinalize = function (primitiveManager) {
|
|
7264
|
-
var
|
|
7239
|
+
var e_6, _a;
|
|
7265
7240
|
// @IMPORTANT: Replace .observers.length === 1 with .observed in rxjs 7.0+
|
|
7266
|
-
var hasObservers = !(primitiveManager.
|
|
7241
|
+
var hasObservers = !(primitiveManager.event$.observers.length === 1);
|
|
7267
7242
|
if (hasObservers)
|
|
7268
7243
|
return;
|
|
7244
|
+
primitiveManager.event$.complete();
|
|
7269
7245
|
try {
|
|
7270
7246
|
for (var _b = __values(primitiveManager.stompSubscriptions), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
7271
7247
|
var stompSubscription = _c.value;
|
|
7272
7248
|
stompSubscription.unsubscribe();
|
|
7273
7249
|
}
|
|
7274
7250
|
}
|
|
7275
|
-
catch (
|
|
7251
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
7276
7252
|
finally {
|
|
7277
7253
|
try {
|
|
7278
7254
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
7279
7255
|
}
|
|
7280
|
-
finally { if (
|
|
7256
|
+
finally { if (e_6) throw e_6.error; }
|
|
7281
7257
|
}
|
|
7282
7258
|
var key = this.getPrimitiveManagerKey(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
7283
7259
|
this.primitiveManagers.delete(key);
|
|
@@ -7289,7 +7265,7 @@ var WebsocketService = /** @class */ (function () {
|
|
|
7289
7265
|
};
|
|
7290
7266
|
var WebsocketService_1;
|
|
7291
7267
|
/** @private */
|
|
7292
|
-
WebsocketService.
|
|
7268
|
+
WebsocketService.RECONNECT_INTERVAL = 3000;
|
|
7293
7269
|
/** @private */
|
|
7294
7270
|
WebsocketService.CONNECTION_TIMEOUT = 15000;
|
|
7295
7271
|
/** @private */
|