@senior-gestao-empresarial/angular-components 6.11.5-f1ae0f56-eaa0-41bd-bf14-efca8153a452 → 6.12.0-29fe646c-2d98-4822-8690-597195a76ad7
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 +514 -255
- package/bundles/senior-gestao-empresarial-angular-components.umd.js.map +1 -1
- package/bundles/senior-gestao-empresarial-angular-components.umd.min.js +2 -2
- package/bundles/senior-gestao-empresarial-angular-components.umd.min.js.map +1 -1
- package/components/permissions/index.d.ts +1 -0
- package/components/permissions/verify-module-permissions-service.d.ts +18 -0
- package/components/permissions/verify-module-permissions.d.ts +16 -0
- package/components/utils/async-lock.d.ts +6 -0
- package/components/websocket/index.d.ts +2 -0
- package/components/websocket/models/index.d.ts +1 -0
- package/components/websocket/models/primitive-manager.d.ts +19 -0
- package/components/websocket/protocols/index.d.ts +2 -0
- package/components/websocket/protocols/on-event-options.d.ts +8 -0
- package/components/websocket/protocols/primitive-event.d.ts +10 -0
- package/components/websocket/user-information.service.d.ts +7 -0
- package/components/websocket/websocket.service.d.ts +78 -74
- package/esm2015/components/permissions/index.js +2 -1
- package/esm2015/components/permissions/verify-module-permissions-service.js +26 -0
- package/esm2015/components/permissions/verify-module-permissions.js +51 -0
- package/esm2015/components/utils/async-lock.js +34 -0
- package/esm2015/components/websocket/index.js +2 -1
- package/esm2015/components/websocket/models/index.js +2 -0
- package/esm2015/components/websocket/models/primitive-manager.js +39 -0
- package/esm2015/components/websocket/protocols/index.js +1 -0
- package/esm2015/components/websocket/protocols/on-event-options.js +1 -0
- package/esm2015/components/websocket/protocols/primitive-event.js +1 -0
- package/esm2015/components/websocket/user-information.service.js +34 -0
- package/esm2015/components/websocket/websocket.service.js +260 -195
- package/esm2015/senior-gestao-empresarial-angular-components.js +4 -2
- package/esm5/components/permissions/index.js +2 -1
- package/esm5/components/permissions/verify-module-permissions-service.js +28 -0
- package/esm5/components/permissions/verify-module-permissions.js +53 -0
- package/esm5/components/utils/async-lock.js +43 -0
- package/esm5/components/websocket/index.js +2 -1
- package/esm5/components/websocket/models/index.js +2 -0
- package/esm5/components/websocket/models/primitive-manager.js +58 -0
- package/esm5/components/websocket/protocols/index.js +1 -0
- package/esm5/components/websocket/protocols/on-event-options.js +1 -0
- package/esm5/components/websocket/protocols/primitive-event.js +1 -0
- package/esm5/components/websocket/user-information.service.js +38 -0
- package/esm5/components/websocket/websocket.service.js +318 -256
- package/esm5/senior-gestao-empresarial-angular-components.js +4 -2
- package/fesm2015/senior-gestao-empresarial-angular-components.js +418 -193
- package/fesm2015/senior-gestao-empresarial-angular-components.js.map +1 -1
- package/fesm5/senior-gestao-empresarial-angular-components.js +510 -255
- package/fesm5/senior-gestao-empresarial-angular-components.js.map +1 -1
- package/package.json +3 -3
- package/senior-gestao-empresarial-angular-components.d.ts +3 -1
- package/senior-gestao-empresarial-angular-components.metadata.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('primeng/breadcrumb'), require('@angular/router'), require('rxjs'), require('rxjs/operators'), require('moment'), require('@seniorsistemas/angular-components'), require('@angular/common/http'), require('primeng/api'), require('@ngx-translate/core'), require('@seniorsistemas/platform-components'), require('@seniorsistemas/senior-platform-data'), require('@angular/forms'), require('@stomp/stompjs'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define('@senior-gestao-empresarial/angular-components', ['exports', '@angular/core', '@angular/common', 'primeng/breadcrumb', '@angular/router', 'rxjs', 'rxjs/operators', 'moment', '@seniorsistemas/angular-components', '@angular/common/http', 'primeng/api', '@ngx-translate/core', '@seniorsistemas/platform-components', '@seniorsistemas/senior-platform-data', '@angular/forms', '@stomp/stompjs', '
|
|
4
|
-
(global = global || self, factory((global['senior-gestao-empresarial'] = global['senior-gestao-empresarial'] || {}, global['senior-gestao-empresarial']['angular-components'] = {}), global.ng.core, global.ng.common, global.breadcrumb, global.ng.router, global.rxjs, global.rxjs.operators, global.moment_, global.angularComponents, global.ng.common.http, global.api, global.core$1, global.platformComponents, global.seniorPlatformData, global.ng.forms, global.stompjs, global.
|
|
5
|
-
}(this, (function (exports, core, common, breadcrumb, router, rxjs, operators, moment_, angularComponents, http, api, core$1, platformComponents, seniorPlatformData, forms, stompjs,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('primeng/breadcrumb'), require('@angular/router'), require('rxjs'), require('rxjs/operators'), require('moment'), require('@seniorsistemas/angular-components'), require('@angular/common/http'), require('primeng/api'), require('@ngx-translate/core'), require('@seniorsistemas/platform-components'), require('@seniorsistemas/senior-platform-data'), require('@angular/forms'), require('@stomp/stompjs'), require('sockjs-client'), require('js-cookie')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('@senior-gestao-empresarial/angular-components', ['exports', '@angular/core', '@angular/common', 'primeng/breadcrumb', '@angular/router', 'rxjs', 'rxjs/operators', 'moment', '@seniorsistemas/angular-components', '@angular/common/http', 'primeng/api', '@ngx-translate/core', '@seniorsistemas/platform-components', '@seniorsistemas/senior-platform-data', '@angular/forms', '@stomp/stompjs', 'sockjs-client', 'js-cookie'], factory) :
|
|
4
|
+
(global = global || self, factory((global['senior-gestao-empresarial'] = global['senior-gestao-empresarial'] || {}, global['senior-gestao-empresarial']['angular-components'] = {}), global.ng.core, global.ng.common, global.breadcrumb, global.ng.router, global.rxjs, global.rxjs.operators, global.moment_, global.angularComponents, global.ng.common.http, global.api, global.core$1, global.platformComponents, global.seniorPlatformData, global.ng.forms, global.stompjs, global.SockJS, global.jsCookie));
|
|
5
|
+
}(this, (function (exports, core, common, breadcrumb, router, rxjs, operators, moment_, angularComponents, http, api, core$1, platformComponents, seniorPlatformData, forms, stompjs, SockJS, jsCookie) { 'use strict';
|
|
6
6
|
|
|
7
7
|
/*! *****************************************************************************
|
|
8
8
|
Copyright (c) Microsoft Corporation.
|
|
@@ -7412,320 +7412,508 @@
|
|
|
7412
7412
|
return NpsService;
|
|
7413
7413
|
}());
|
|
7414
7414
|
|
|
7415
|
+
var AsyncLock = /** @class */ (function () {
|
|
7416
|
+
function AsyncLock() {
|
|
7417
|
+
this.queue = [];
|
|
7418
|
+
this.acquired = false;
|
|
7419
|
+
}
|
|
7420
|
+
AsyncLock.prototype.acquire = function () {
|
|
7421
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
7422
|
+
var _this = this;
|
|
7423
|
+
return __generator(this, function (_a) {
|
|
7424
|
+
if (!this.acquired) {
|
|
7425
|
+
this.acquired = true;
|
|
7426
|
+
return [2 /*return*/, Promise.resolve()];
|
|
7427
|
+
}
|
|
7428
|
+
else {
|
|
7429
|
+
return [2 /*return*/, new Promise(function (resolve, _) {
|
|
7430
|
+
_this.queue.push(resolve);
|
|
7431
|
+
})];
|
|
7432
|
+
}
|
|
7433
|
+
return [2 /*return*/];
|
|
7434
|
+
});
|
|
7435
|
+
});
|
|
7436
|
+
};
|
|
7437
|
+
AsyncLock.prototype.release = function () {
|
|
7438
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
7439
|
+
var continuation;
|
|
7440
|
+
return __generator(this, function (_a) {
|
|
7441
|
+
if (this.queue.length === 0 && this.acquired) {
|
|
7442
|
+
this.acquired = false;
|
|
7443
|
+
return [2 /*return*/, Promise.resolve()];
|
|
7444
|
+
}
|
|
7445
|
+
continuation = this.queue.shift();
|
|
7446
|
+
return [2 /*return*/, new Promise(function (res) {
|
|
7447
|
+
continuation();
|
|
7448
|
+
res();
|
|
7449
|
+
})];
|
|
7450
|
+
});
|
|
7451
|
+
});
|
|
7452
|
+
};
|
|
7453
|
+
return AsyncLock;
|
|
7454
|
+
}());
|
|
7455
|
+
|
|
7456
|
+
var UserInformationService = /** @class */ (function () {
|
|
7457
|
+
function UserInformationService() {
|
|
7458
|
+
}
|
|
7459
|
+
UserInformationService_1 = UserInformationService;
|
|
7460
|
+
UserInformationService.prototype.getAuthToken = function () {
|
|
7461
|
+
var cookieValue = jsCookie.get(UserInformationService_1.TOKEN_COOKIE_KEY) || '{}';
|
|
7462
|
+
var authToken = JSON.parse(cookieValue);
|
|
7463
|
+
return authToken.access_token;
|
|
7464
|
+
};
|
|
7465
|
+
UserInformationService.prototype.getTenantDomain = function () {
|
|
7466
|
+
var cookieValue = jsCookie.get(UserInformationService_1.TOKEN_COOKIE_KEY) || '{}';
|
|
7467
|
+
var authToken = JSON.parse(cookieValue);
|
|
7468
|
+
return authToken.username.split('@')[1];
|
|
7469
|
+
};
|
|
7470
|
+
UserInformationService.prototype.getWebSocketUrl = function () {
|
|
7471
|
+
var baseUrl = jsCookie.get(UserInformationService_1.BASE_URL_COOKIE_KEY);
|
|
7472
|
+
if (!baseUrl.endsWith('/')) {
|
|
7473
|
+
baseUrl += '/';
|
|
7474
|
+
}
|
|
7475
|
+
return baseUrl + 'websocket';
|
|
7476
|
+
};
|
|
7477
|
+
var UserInformationService_1;
|
|
7478
|
+
UserInformationService.BASE_URL_COOKIE_KEY = 'com.senior.base.url';
|
|
7479
|
+
UserInformationService.TOKEN_COOKIE_KEY = 'com.senior.token';
|
|
7480
|
+
UserInformationService.ɵprov = core.ɵɵdefineInjectable({ factory: function UserInformationService_Factory() { return new UserInformationService(); }, token: UserInformationService, providedIn: "root" });
|
|
7481
|
+
UserInformationService = UserInformationService_1 = __decorate([
|
|
7482
|
+
core.Injectable({
|
|
7483
|
+
providedIn: 'root'
|
|
7484
|
+
})
|
|
7485
|
+
], UserInformationService);
|
|
7486
|
+
return UserInformationService;
|
|
7487
|
+
}());
|
|
7488
|
+
|
|
7489
|
+
var PrimitiveManager = /** @class */ (function () {
|
|
7490
|
+
function PrimitiveManager(domain, service, primitive) {
|
|
7491
|
+
this.domain = domain;
|
|
7492
|
+
this.service = service;
|
|
7493
|
+
this.primitive = primitive;
|
|
7494
|
+
this.stompSubscriptions = [];
|
|
7495
|
+
this.event$ = new rxjs.Subject();
|
|
7496
|
+
this.subscribed$ = new rxjs.BehaviorSubject(false);
|
|
7497
|
+
}
|
|
7498
|
+
PrimitiveManager.prototype.unsubscribe = function () {
|
|
7499
|
+
var e_1, _a;
|
|
7500
|
+
this.event$.complete();
|
|
7501
|
+
try {
|
|
7502
|
+
for (var _b = __values(this.stompSubscriptions), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
7503
|
+
var stompSubscription = _c.value;
|
|
7504
|
+
stompSubscription.unsubscribe();
|
|
7505
|
+
}
|
|
7506
|
+
}
|
|
7507
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
7508
|
+
finally {
|
|
7509
|
+
try {
|
|
7510
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
7511
|
+
}
|
|
7512
|
+
finally { if (e_1) throw e_1.error; }
|
|
7513
|
+
}
|
|
7514
|
+
this.subscribed$.complete();
|
|
7515
|
+
};
|
|
7516
|
+
PrimitiveManager.prototype.fireEvent = function (event) {
|
|
7517
|
+
this.event$.next(event);
|
|
7518
|
+
};
|
|
7519
|
+
PrimitiveManager.prototype.subscribe = function () {
|
|
7520
|
+
var _a;
|
|
7521
|
+
var subscriptions = [];
|
|
7522
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
7523
|
+
subscriptions[_i] = arguments[_i];
|
|
7524
|
+
}
|
|
7525
|
+
(_a = this.stompSubscriptions).push.apply(_a, __spread(subscriptions));
|
|
7526
|
+
this.subscribed$.next(true);
|
|
7527
|
+
};
|
|
7528
|
+
PrimitiveManager.prototype.getEventObservable = function () {
|
|
7529
|
+
return this.event$.asObservable();
|
|
7530
|
+
};
|
|
7531
|
+
PrimitiveManager.prototype.getSubscriptionObservable = function () {
|
|
7532
|
+
return this.subscribed$.asObservable();
|
|
7533
|
+
};
|
|
7534
|
+
PrimitiveManager.prototype.hasObservers = function () {
|
|
7535
|
+
// @IMPORTANT: Replace .observers.length === 1 with .observed in rxjs 7.0+
|
|
7536
|
+
return this.event$.observers.length !== 1;
|
|
7537
|
+
};
|
|
7538
|
+
PrimitiveManager.prototype.getObserversCount = function () {
|
|
7539
|
+
return this.event$.observers.length;
|
|
7540
|
+
};
|
|
7541
|
+
return PrimitiveManager;
|
|
7542
|
+
}());
|
|
7543
|
+
|
|
7544
|
+
var RECONNECT_INTERVAL_MILLISECONDS = 3000;
|
|
7545
|
+
var CONNECTION_TIMEOUT_MILLISECONDS = 5000;
|
|
7415
7546
|
var WebsocketService = /** @class */ (function () {
|
|
7416
|
-
function WebsocketService() {
|
|
7417
|
-
|
|
7418
|
-
this.wasConnected = false;
|
|
7419
|
-
/** @private */
|
|
7420
|
-
this.isConnected = false;
|
|
7421
|
-
/** @private */
|
|
7422
|
-
this.isConnecting = false;
|
|
7423
|
-
/** @private */
|
|
7424
|
-
this.primitiveManagers = new Map();
|
|
7425
|
-
/** @private */
|
|
7547
|
+
function WebsocketService(userInformationService) {
|
|
7548
|
+
this.userInformationService = userInformationService;
|
|
7426
7549
|
this.connected$ = new rxjs.BehaviorSubject(false);
|
|
7427
|
-
|
|
7428
|
-
this.
|
|
7429
|
-
/** @private */
|
|
7430
|
-
this.reconnect$ = new rxjs.Subject();
|
|
7431
|
-
/** @private */
|
|
7550
|
+
this.disconnected$ = new rxjs.Subject();
|
|
7551
|
+
this.reconnected$ = new rxjs.Subject();
|
|
7432
7552
|
this.error$ = new rxjs.Subject();
|
|
7433
7553
|
this.subscribed$ = new rxjs.Subject();
|
|
7554
|
+
this.primitiveManagers = new Map();
|
|
7555
|
+
this.connectionLock = new AsyncLock();
|
|
7556
|
+
this.debugEnable = false;
|
|
7557
|
+
this.lostConnection = false;
|
|
7434
7558
|
}
|
|
7435
|
-
WebsocketService_1 = WebsocketService;
|
|
7436
7559
|
/**
|
|
7437
|
-
*
|
|
7438
|
-
* @return Um `Observable<void>` que emite uma notificação quando a conexão websocket é estabelecida pela primeira vez.
|
|
7560
|
+
* Enables stompjs debug logs and additional info
|
|
7439
7561
|
*/
|
|
7440
|
-
WebsocketService.prototype.
|
|
7441
|
-
|
|
7562
|
+
WebsocketService.prototype.enableDebugLogs = function () {
|
|
7563
|
+
this.debugEnable = true;
|
|
7442
7564
|
};
|
|
7443
7565
|
/**
|
|
7444
|
-
*
|
|
7445
|
-
* @return Um `Observable<void>` que emite uma notificação quando a conexão é desconectada.
|
|
7566
|
+
* Manually starts the connection
|
|
7446
7567
|
*/
|
|
7447
|
-
WebsocketService.prototype.
|
|
7448
|
-
return this
|
|
7568
|
+
WebsocketService.prototype.connect = function () {
|
|
7569
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
7570
|
+
var stompConfig;
|
|
7571
|
+
var _this = this;
|
|
7572
|
+
return __generator(this, function (_a) {
|
|
7573
|
+
switch (_a.label) {
|
|
7574
|
+
case 0: return [4 /*yield*/, this.connectionLock.acquire()];
|
|
7575
|
+
case 1:
|
|
7576
|
+
_a.sent();
|
|
7577
|
+
_a.label = 2;
|
|
7578
|
+
case 2:
|
|
7579
|
+
_a.trys.push([2, , 3, 5]);
|
|
7580
|
+
if (this.isConnected() || this.isConnecting()) {
|
|
7581
|
+
return [2 /*return*/];
|
|
7582
|
+
}
|
|
7583
|
+
this.lostConnection = false;
|
|
7584
|
+
stompConfig = {
|
|
7585
|
+
webSocketFactory: function () {
|
|
7586
|
+
return new SockJS(_this.getSubscriptionUrl(), null, {
|
|
7587
|
+
timeout: CONNECTION_TIMEOUT_MILLISECONDS
|
|
7588
|
+
});
|
|
7589
|
+
},
|
|
7590
|
+
connectionTimeout: CONNECTION_TIMEOUT_MILLISECONDS,
|
|
7591
|
+
reconnectDelay: RECONNECT_INTERVAL_MILLISECONDS,
|
|
7592
|
+
debug: this.debug.bind(this),
|
|
7593
|
+
onConnect: this.handleOnConnected.bind(this),
|
|
7594
|
+
onDisconnect: this.handleOnDisconnect.bind(this),
|
|
7595
|
+
onWebSocketClose: this.handleOnWebSocketClose.bind(this),
|
|
7596
|
+
onStompError: this.handleOnStompError.bind(this),
|
|
7597
|
+
onWebSocketError: this.handleOnWebSocketError.bind(this)
|
|
7598
|
+
};
|
|
7599
|
+
this.debug('Connecting the Webscoket');
|
|
7600
|
+
this.stompClient = new stompjs.Client(stompConfig);
|
|
7601
|
+
this.stompClient.activate();
|
|
7602
|
+
return [3 /*break*/, 5];
|
|
7603
|
+
case 3: return [4 /*yield*/, this.connectionLock.release()];
|
|
7604
|
+
case 4:
|
|
7605
|
+
_a.sent();
|
|
7606
|
+
return [7 /*endfinally*/];
|
|
7607
|
+
case 5: return [2 /*return*/];
|
|
7608
|
+
}
|
|
7609
|
+
});
|
|
7610
|
+
});
|
|
7449
7611
|
};
|
|
7450
7612
|
/**
|
|
7451
|
-
*
|
|
7452
|
-
* @return Um `Observable<void>` que emite uma notificação quando a conexão é reconectada.
|
|
7613
|
+
* Manually disconnect the websocket. The reconnect loop will be stopped.
|
|
7453
7614
|
*/
|
|
7454
|
-
WebsocketService.prototype.
|
|
7455
|
-
return this
|
|
7615
|
+
WebsocketService.prototype.disconnect = function () {
|
|
7616
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
7617
|
+
var _a, _b, primitiveManager;
|
|
7618
|
+
var e_1, _c;
|
|
7619
|
+
return __generator(this, function (_d) {
|
|
7620
|
+
switch (_d.label) {
|
|
7621
|
+
case 0:
|
|
7622
|
+
if (!this.isConnected()) {
|
|
7623
|
+
return [2 /*return*/];
|
|
7624
|
+
}
|
|
7625
|
+
return [4 /*yield*/, this.connectionLock.acquire()];
|
|
7626
|
+
case 1:
|
|
7627
|
+
_d.sent();
|
|
7628
|
+
_d.label = 2;
|
|
7629
|
+
case 2:
|
|
7630
|
+
_d.trys.push([2, , 5, 7]);
|
|
7631
|
+
try {
|
|
7632
|
+
for (_a = __values(this.primitiveManagers.values()), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
7633
|
+
primitiveManager = _b.value;
|
|
7634
|
+
primitiveManager.unsubscribe();
|
|
7635
|
+
}
|
|
7636
|
+
}
|
|
7637
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
7638
|
+
finally {
|
|
7639
|
+
try {
|
|
7640
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
7641
|
+
}
|
|
7642
|
+
finally { if (e_1) throw e_1.error; }
|
|
7643
|
+
}
|
|
7644
|
+
this.primitiveManagers.clear();
|
|
7645
|
+
this.connected$.next(false);
|
|
7646
|
+
if (!this.stompClient) return [3 /*break*/, 4];
|
|
7647
|
+
this.stompClient.forceDisconnect();
|
|
7648
|
+
return [4 /*yield*/, this.stompClient.deactivate()];
|
|
7649
|
+
case 3:
|
|
7650
|
+
_d.sent();
|
|
7651
|
+
_d.label = 4;
|
|
7652
|
+
case 4: return [3 /*break*/, 7];
|
|
7653
|
+
case 5: return [4 /*yield*/, this.connectionLock.release()];
|
|
7654
|
+
case 6:
|
|
7655
|
+
_d.sent();
|
|
7656
|
+
return [7 /*endfinally*/];
|
|
7657
|
+
case 7: return [2 /*return*/];
|
|
7658
|
+
}
|
|
7659
|
+
});
|
|
7660
|
+
});
|
|
7456
7661
|
};
|
|
7457
7662
|
/**
|
|
7458
|
-
*
|
|
7459
|
-
* @return
|
|
7663
|
+
* Check if the websocket is connected
|
|
7664
|
+
* @return `boolean` representing if the websocket is connected
|
|
7460
7665
|
*/
|
|
7461
|
-
WebsocketService.prototype.
|
|
7462
|
-
|
|
7463
|
-
|
|
7464
|
-
|
|
7465
|
-
return this.
|
|
7466
|
-
|
|
7467
|
-
|
|
7468
|
-
|
|
7469
|
-
|
|
7470
|
-
|
|
7471
|
-
|
|
7472
|
-
|
|
7473
|
-
|
|
7474
|
-
}
|
|
7666
|
+
WebsocketService.prototype.isConnected = function () {
|
|
7667
|
+
if (!this.stompClient) {
|
|
7668
|
+
return false;
|
|
7669
|
+
}
|
|
7670
|
+
return this.stompClient.connected;
|
|
7671
|
+
};
|
|
7672
|
+
/**
|
|
7673
|
+
* Check if the websocket is tring to connect
|
|
7674
|
+
* @return `boolean` representing if the websocket status
|
|
7675
|
+
*/
|
|
7676
|
+
WebsocketService.prototype.isConnecting = function () {
|
|
7677
|
+
if (!this.stompClient) {
|
|
7678
|
+
return false;
|
|
7679
|
+
}
|
|
7680
|
+
return !this.stompClient.connected && this.stompClient.active;
|
|
7681
|
+
};
|
|
7682
|
+
/**
|
|
7683
|
+
* Event responsable to emit an event when the connection is established.
|
|
7684
|
+
* Do not forget to unsubscribe the observable when you don't need it anymore.
|
|
7685
|
+
* @return `Observable<boolean>`
|
|
7686
|
+
*/
|
|
7687
|
+
WebsocketService.prototype.onConnect = function () {
|
|
7688
|
+
return this.connected$.asObservable()
|
|
7689
|
+
.pipe(operators.filter(function (p) { return p === true; }));
|
|
7690
|
+
};
|
|
7691
|
+
/**
|
|
7692
|
+
* Event responsable to emit an event when the connection is closed.
|
|
7693
|
+
* Do not forget to unsubscribe the observable when you don't need it anymore.
|
|
7694
|
+
* @return `Observable<void>`
|
|
7695
|
+
*/
|
|
7696
|
+
WebsocketService.prototype.onDisconnect = function () {
|
|
7697
|
+
return this.disconnected$.asObservable();
|
|
7698
|
+
};
|
|
7699
|
+
/**
|
|
7700
|
+
* Event responsable to emit an event when the connection is reestablished.
|
|
7701
|
+
* Do not forget to unsubscribe the observable when you don't need it anymore.
|
|
7702
|
+
* @return `Observable<void>`
|
|
7703
|
+
*/
|
|
7704
|
+
WebsocketService.prototype.onReconnect = function () {
|
|
7705
|
+
return this.reconnected$.asObservable();
|
|
7475
7706
|
};
|
|
7476
7707
|
/**
|
|
7477
|
-
*
|
|
7478
|
-
*
|
|
7708
|
+
* Event responsable to emit an event when an error ocurred.
|
|
7709
|
+
* Do not forget to unsubscribe the observable when you don't need it anymore.
|
|
7710
|
+
* @return `Observable<FrameImpl>`
|
|
7479
7711
|
*/
|
|
7480
7712
|
WebsocketService.prototype.onError = function () {
|
|
7481
7713
|
return this.error$.asObservable();
|
|
7482
7714
|
};
|
|
7483
7715
|
/**
|
|
7484
|
-
*
|
|
7485
|
-
*
|
|
7486
|
-
* @
|
|
7487
|
-
* @param {
|
|
7488
|
-
* @
|
|
7489
|
-
* @return Um Observable<T> que emite notificações toda vez que o respectivo evento é publicado.
|
|
7716
|
+
* Event responsible to emit an event when a primitive is called.
|
|
7717
|
+
* Do not forget to unsubscribe the observable when you don't need it anymore.
|
|
7718
|
+
* @typeParam `<T>` Object type that will be used in the observable for the `data` property.
|
|
7719
|
+
* @param {OnEventOptions} options Configurations for the event.
|
|
7720
|
+
* @return `Observable<PrimitiveEvent<T>>` Observable that emits an event when the service calls the primitive.
|
|
7490
7721
|
*/
|
|
7491
7722
|
WebsocketService.prototype.onEvent = function (options) {
|
|
7492
7723
|
var _this = this;
|
|
7493
|
-
this.connect();
|
|
7494
7724
|
var domain = options.domain, service = options.service, primitive = options.primitive;
|
|
7495
|
-
var key = this.
|
|
7725
|
+
var key = this.buildPrimitiveManagerKey(domain, service, primitive);
|
|
7496
7726
|
if (this.primitiveManagers.has(key)) {
|
|
7497
|
-
return this.primitiveManagers.get(key).
|
|
7727
|
+
return this.primitiveManagers.get(key).getEventObservable();
|
|
7498
7728
|
}
|
|
7499
|
-
var primitiveManager =
|
|
7500
|
-
domain: domain,
|
|
7501
|
-
service: service,
|
|
7502
|
-
primitive: primitive,
|
|
7503
|
-
stompSubscriptions: [],
|
|
7504
|
-
event$: new rxjs.Subject(),
|
|
7505
|
-
subscribed$: new rxjs.BehaviorSubject(false)
|
|
7506
|
-
};
|
|
7729
|
+
var primitiveManager = new PrimitiveManager(domain, service, primitive);
|
|
7507
7730
|
this.primitiveManagers.set(key, primitiveManager);
|
|
7508
|
-
this.
|
|
7509
|
-
.
|
|
7510
|
-
|
|
7511
|
-
|
|
7731
|
+
this.connect().then(function () {
|
|
7732
|
+
_this.onConnect()
|
|
7733
|
+
.pipe(operators.take(1))
|
|
7734
|
+
.subscribe(function () {
|
|
7735
|
+
_this.createStompSubscriptions(primitiveManager);
|
|
7736
|
+
});
|
|
7512
7737
|
});
|
|
7513
|
-
return primitiveManager
|
|
7514
|
-
.
|
|
7515
|
-
.pipe(operators.finalize(function () { return _this.
|
|
7516
|
-
};
|
|
7517
|
-
/** @private */
|
|
7518
|
-
WebsocketService.prototype.createStompSubscriptions = function (primitiveManager) {
|
|
7519
|
-
var withTokenUrl = this.getSubscriptionUrlWithToken(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
7520
|
-
var stompSubscriptionWithToken = this.createStompSubscription(withTokenUrl, primitiveManager);
|
|
7521
|
-
var withoutTokenUrl = this.getSubscriptionUrlWithoutToken(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
7522
|
-
var stompSubscriptionWithoutToken = this.createStompSubscription(withoutTokenUrl, primitiveManager);
|
|
7523
|
-
primitiveManager.stompSubscriptions = [
|
|
7524
|
-
stompSubscriptionWithToken,
|
|
7525
|
-
stompSubscriptionWithoutToken
|
|
7526
|
-
];
|
|
7527
|
-
primitiveManager.subscribed$.next(true);
|
|
7528
|
-
this.subscribed$.next(primitiveManager);
|
|
7738
|
+
return primitiveManager
|
|
7739
|
+
.getEventObservable()
|
|
7740
|
+
.pipe(operators.finalize(function () { return _this.unsubscribePrimitiveOnFinalize(primitiveManager); }));
|
|
7529
7741
|
};
|
|
7530
|
-
/**
|
|
7531
|
-
|
|
7742
|
+
/**
|
|
7743
|
+
* Event responsible to emit an event when a subscription is created for the primitive.
|
|
7744
|
+
* Do not forget to unsubscribe the observable when you don't need it anymore.
|
|
7745
|
+
* @param {OnEventOptions} options Configurations for the event.
|
|
7746
|
+
* Observable responsável por emitir uma notificação após o subscribe do evento pela primeira vez.
|
|
7747
|
+
* @return `Observable<boolean>` Observable that emits an event when the service calls the primitive.
|
|
7748
|
+
*/
|
|
7749
|
+
WebsocketService.prototype.onSubscribe = function (options) {
|
|
7532
7750
|
var _this = this;
|
|
7533
|
-
|
|
7534
|
-
|
|
7535
|
-
this.
|
|
7536
|
-
|
|
7537
|
-
|
|
7538
|
-
|
|
7539
|
-
|
|
7540
|
-
|
|
7541
|
-
_this.reconnectPrimitives();
|
|
7542
|
-
_this.connected$.next(true);
|
|
7543
|
-
_this.reconnect$.next();
|
|
7751
|
+
var domain = options.domain, service = options.service, primitive = options.primitive;
|
|
7752
|
+
var key = this.buildPrimitiveManagerKey(domain, service, primitive);
|
|
7753
|
+
return this.onConnect().pipe(operators.take(1), operators.switchMap(function () {
|
|
7754
|
+
if (_this.primitiveManagers.has(key)) {
|
|
7755
|
+
return _this.primitiveManagers
|
|
7756
|
+
.get(key)
|
|
7757
|
+
.getSubscriptionObservable()
|
|
7758
|
+
.pipe(operators.take(1));
|
|
7544
7759
|
}
|
|
7545
|
-
|
|
7546
|
-
_this.
|
|
7547
|
-
|
|
7548
|
-
|
|
7549
|
-
}, function (error) {
|
|
7550
|
-
_this.isConnected = false;
|
|
7551
|
-
_this.connected$.next(false);
|
|
7552
|
-
_this.error$.next(error);
|
|
7553
|
-
rxjs.race(_this.disconnect$.pipe(operators.take(1), operators.map(function () { return ({ wasDisconnected: true }); })), rxjs.timer(WebsocketService_1.RECONNECT_INTERVAL).pipe(operators.take(1), operators.switchMap(function () {
|
|
7554
|
-
return rxjs.iif(function () { return document.hidden; }, rxjs.fromEvent(document, 'visibilitychange').pipe(operators.first()), rxjs.of(void 0));
|
|
7555
|
-
}), operators.map(function () { return ({ wasDisconnected: false }); })))
|
|
7556
|
-
.pipe(operators.take(1))
|
|
7557
|
-
.subscribe({
|
|
7558
|
-
next: function (_a) {
|
|
7559
|
-
var wasDisconnected = _a.wasDisconnected;
|
|
7560
|
-
if (!wasDisconnected &&
|
|
7561
|
-
!(_this.isConnected || _this.isConnecting)) {
|
|
7562
|
-
_this.connect();
|
|
7563
|
-
}
|
|
7564
|
-
}
|
|
7565
|
-
});
|
|
7566
|
-
});
|
|
7760
|
+
return _this.subscribed$.asObservable().pipe(operators.filter(function (primitiveManager) {
|
|
7761
|
+
return _this.buildPrimitiveManagerKey(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive) === key;
|
|
7762
|
+
}), operators.map(function () { return true; }), operators.take(1));
|
|
7763
|
+
}));
|
|
7567
7764
|
};
|
|
7568
|
-
WebsocketService.prototype.
|
|
7569
|
-
var
|
|
7570
|
-
|
|
7571
|
-
|
|
7765
|
+
WebsocketService.prototype.debug = function (message) {
|
|
7766
|
+
var optionalParams = [];
|
|
7767
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
7768
|
+
optionalParams[_i - 1] = arguments[_i];
|
|
7572
7769
|
}
|
|
7573
|
-
|
|
7574
|
-
|
|
7575
|
-
var primitiveManager = _e.value;
|
|
7576
|
-
try {
|
|
7577
|
-
for (var _f = (e_2 = void 0, __values(primitiveManager.stompSubscriptions)), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
7578
|
-
var stompSubscription = _g.value;
|
|
7579
|
-
stompSubscription.unsubscribe();
|
|
7580
|
-
}
|
|
7581
|
-
}
|
|
7582
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
7583
|
-
finally {
|
|
7584
|
-
try {
|
|
7585
|
-
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
7586
|
-
}
|
|
7587
|
-
finally { if (e_2) throw e_2.error; }
|
|
7588
|
-
}
|
|
7589
|
-
}
|
|
7770
|
+
if (!this.debugEnable) {
|
|
7771
|
+
return;
|
|
7590
7772
|
}
|
|
7591
|
-
|
|
7592
|
-
|
|
7593
|
-
|
|
7594
|
-
|
|
7595
|
-
|
|
7596
|
-
|
|
7773
|
+
console.log.apply(console, __spread(['WS debug: ' + message], optionalParams));
|
|
7774
|
+
};
|
|
7775
|
+
WebsocketService.prototype.info = function (message) {
|
|
7776
|
+
console.info('WS info: ' + message);
|
|
7777
|
+
};
|
|
7778
|
+
WebsocketService.prototype.handleOnConnected = function () {
|
|
7779
|
+
this.info('Webscoket connected');
|
|
7780
|
+
this.connected$.next(true);
|
|
7781
|
+
if (this.lostConnection) {
|
|
7782
|
+
this.info('Webscoket reconnected, recriating subscriptions');
|
|
7783
|
+
this.handleReconnection();
|
|
7597
7784
|
}
|
|
7598
|
-
|
|
7599
|
-
|
|
7600
|
-
|
|
7601
|
-
|
|
7602
|
-
|
|
7785
|
+
};
|
|
7786
|
+
WebsocketService.prototype.handleOnDisconnect = function () {
|
|
7787
|
+
this.info('Webscoket disconnected');
|
|
7788
|
+
this.connected$.next(false);
|
|
7789
|
+
this.disconnected$.next();
|
|
7790
|
+
};
|
|
7791
|
+
WebsocketService.prototype.handleOnWebSocketClose = function (data) {
|
|
7792
|
+
if (data.wasClean) {
|
|
7793
|
+
return;
|
|
7603
7794
|
}
|
|
7604
|
-
|
|
7605
|
-
|
|
7606
|
-
|
|
7607
|
-
|
|
7608
|
-
|
|
7609
|
-
|
|
7795
|
+
this.lostConnection = true;
|
|
7796
|
+
};
|
|
7797
|
+
WebsocketService.prototype.handleOnStompError = function (data) {
|
|
7798
|
+
this.handleError('StompError', data);
|
|
7799
|
+
if (this.isAuthenticationError(data)) {
|
|
7800
|
+
this.info('Authentication error, recriating subscriptions');
|
|
7801
|
+
this.handleReconnection();
|
|
7610
7802
|
}
|
|
7611
|
-
this.primitiveManagers.clear();
|
|
7612
|
-
this._stompClient.disconnect();
|
|
7613
|
-
this._stompClient.deactivate();
|
|
7614
|
-
this.isConnected = false;
|
|
7615
|
-
this.isConnecting = false;
|
|
7616
|
-
this.wasConnected = false;
|
|
7617
|
-
this.connected$.next(false);
|
|
7618
|
-
this.disconnect$.next();
|
|
7619
7803
|
};
|
|
7620
|
-
|
|
7621
|
-
|
|
7622
|
-
var
|
|
7623
|
-
|
|
7624
|
-
|
|
7625
|
-
|
|
7626
|
-
|
|
7627
|
-
: null;
|
|
7628
|
-
return "/topic/" + tenant + "/" + token + "/" + domain + "/" + service + "/" + primitive;
|
|
7804
|
+
WebsocketService.prototype.isAuthenticationError = function (data) {
|
|
7805
|
+
var _a;
|
|
7806
|
+
var errorMessage = (_a = data === null || data === void 0 ? void 0 : data.headers) === null || _a === void 0 ? void 0 : _a.message;
|
|
7807
|
+
if (!errorMessage) {
|
|
7808
|
+
return false;
|
|
7809
|
+
}
|
|
7810
|
+
return errorMessage.toLowerCase().indexOf('forbiddenexception') !== -1;
|
|
7629
7811
|
};
|
|
7630
|
-
|
|
7631
|
-
|
|
7632
|
-
var tenant = WebsocketService_1.TOKEN
|
|
7633
|
-
? WebsocketService_1.TOKEN.username.split('@')[1]
|
|
7634
|
-
: null;
|
|
7635
|
-
return "/topic/" + tenant + "/" + domain + "/" + service + "/" + primitive;
|
|
7812
|
+
WebsocketService.prototype.handleOnWebSocketError = function (data) {
|
|
7813
|
+
this.handleError('WebSocketError', data);
|
|
7636
7814
|
};
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
|
|
7640
|
-
var event = JSON.parse(message.body || '{}');
|
|
7641
|
-
primitiveManager.event$.next(event);
|
|
7642
|
-
});
|
|
7815
|
+
WebsocketService.prototype.handleError = function (origin, data) {
|
|
7816
|
+
console.error(origin, data);
|
|
7817
|
+
this.error$.next(data);
|
|
7643
7818
|
};
|
|
7644
|
-
|
|
7645
|
-
|
|
7646
|
-
|
|
7647
|
-
this.
|
|
7648
|
-
this._stompClient.debug = function () { return null; };
|
|
7819
|
+
WebsocketService.prototype.handleReconnection = function () {
|
|
7820
|
+
this.lostConnection = false;
|
|
7821
|
+
this.reconnectPrimitives();
|
|
7822
|
+
this.reconnected$.next();
|
|
7649
7823
|
};
|
|
7650
|
-
/** @private */
|
|
7651
7824
|
WebsocketService.prototype.reconnectPrimitives = function () {
|
|
7652
|
-
var
|
|
7825
|
+
var e_2, _a;
|
|
7653
7826
|
try {
|
|
7654
7827
|
for (var _b = __values(this.primitiveManagers.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
7655
7828
|
var primitiveManager = _c.value;
|
|
7656
7829
|
this.createStompSubscriptions(primitiveManager);
|
|
7657
7830
|
}
|
|
7658
7831
|
}
|
|
7659
|
-
catch (
|
|
7832
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
7660
7833
|
finally {
|
|
7661
7834
|
try {
|
|
7662
7835
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
7663
7836
|
}
|
|
7664
|
-
finally { if (
|
|
7837
|
+
finally { if (e_2) throw e_2.error; }
|
|
7665
7838
|
}
|
|
7666
7839
|
};
|
|
7667
|
-
|
|
7840
|
+
WebsocketService.prototype.buildSubscriptionUrlWithToken = function (domain, service, primitive) {
|
|
7841
|
+
var authToken = this.userInformationService.getAuthToken();
|
|
7842
|
+
var tenant = this.userInformationService.getTenantDomain();
|
|
7843
|
+
return "/topic/" + tenant + "/" + authToken + "/" + domain + "/" + service + "/" + primitive;
|
|
7844
|
+
};
|
|
7845
|
+
WebsocketService.prototype.getSubscriptionUrlWithoutToken = function (domain, service, primitive) {
|
|
7846
|
+
var tenant = this.userInformationService.getTenantDomain();
|
|
7847
|
+
return "/topic/" + tenant + "/" + domain + "/" + service + "/" + primitive;
|
|
7848
|
+
};
|
|
7849
|
+
WebsocketService.prototype.buildPrimitiveManagerKey = function (domain, service, primitive) {
|
|
7850
|
+
return domain + "/" + service + "/" + primitive;
|
|
7851
|
+
};
|
|
7852
|
+
WebsocketService.prototype.unsubscribePrimitiveOnFinalize = function (primitiveManager) {
|
|
7853
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
7854
|
+
var key;
|
|
7855
|
+
return __generator(this, function (_a) {
|
|
7856
|
+
switch (_a.label) {
|
|
7857
|
+
case 0:
|
|
7858
|
+
if (primitiveManager.hasObservers()) {
|
|
7859
|
+
return [2 /*return*/];
|
|
7860
|
+
}
|
|
7861
|
+
primitiveManager.unsubscribe();
|
|
7862
|
+
key = this.buildPrimitiveManagerKey(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
7863
|
+
this.primitiveManagers.delete(key);
|
|
7864
|
+
return [4 /*yield*/, this.disconnectIfNoMoreObservables()];
|
|
7865
|
+
case 1:
|
|
7866
|
+
_a.sent();
|
|
7867
|
+
return [2 /*return*/];
|
|
7868
|
+
}
|
|
7869
|
+
});
|
|
7870
|
+
});
|
|
7871
|
+
};
|
|
7872
|
+
WebsocketService.prototype.disconnectIfNoMoreObservables = function () {
|
|
7873
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
7874
|
+
return __generator(this, function (_a) {
|
|
7875
|
+
switch (_a.label) {
|
|
7876
|
+
case 0:
|
|
7877
|
+
if (!(this.getObserversCount() === 0)) return [3 /*break*/, 2];
|
|
7878
|
+
this.debug('Manually disconnecting because there are no more observers');
|
|
7879
|
+
return [4 /*yield*/, this.disconnect()];
|
|
7880
|
+
case 1:
|
|
7881
|
+
_a.sent();
|
|
7882
|
+
_a.label = 2;
|
|
7883
|
+
case 2: return [2 /*return*/];
|
|
7884
|
+
}
|
|
7885
|
+
});
|
|
7886
|
+
});
|
|
7887
|
+
};
|
|
7668
7888
|
WebsocketService.prototype.getObserversCount = function () {
|
|
7669
|
-
var e_5, _a;
|
|
7670
7889
|
var observersCount = 0;
|
|
7671
|
-
|
|
7672
|
-
|
|
7673
|
-
|
|
7674
|
-
observersCount += primitiveManager.event$.observers.length;
|
|
7675
|
-
}
|
|
7676
|
-
}
|
|
7677
|
-
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
7678
|
-
finally {
|
|
7679
|
-
try {
|
|
7680
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
7681
|
-
}
|
|
7682
|
-
finally { if (e_5) throw e_5.error; }
|
|
7683
|
-
}
|
|
7890
|
+
this.primitiveManagers.forEach(function (primitiveManager) {
|
|
7891
|
+
observersCount += primitiveManager.getObserversCount();
|
|
7892
|
+
});
|
|
7684
7893
|
return observersCount;
|
|
7685
7894
|
};
|
|
7686
|
-
|
|
7687
|
-
|
|
7688
|
-
|
|
7689
|
-
|
|
7690
|
-
|
|
7691
|
-
if (hasObservers)
|
|
7692
|
-
return;
|
|
7693
|
-
primitiveManager.event$.complete();
|
|
7694
|
-
try {
|
|
7695
|
-
for (var _b = __values(primitiveManager.stompSubscriptions), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
7696
|
-
var stompSubscription = _c.value;
|
|
7697
|
-
stompSubscription.unsubscribe();
|
|
7698
|
-
}
|
|
7699
|
-
}
|
|
7700
|
-
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
7701
|
-
finally {
|
|
7702
|
-
try {
|
|
7703
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
7704
|
-
}
|
|
7705
|
-
finally { if (e_6) throw e_6.error; }
|
|
7706
|
-
}
|
|
7707
|
-
primitiveManager.subscribed$.complete();
|
|
7708
|
-
var key = this.getPrimitiveManagerKey(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
7709
|
-
this.primitiveManagers.delete(key);
|
|
7710
|
-
this.disconnect();
|
|
7895
|
+
WebsocketService.prototype.createStompSubscription = function (destination, primitiveManager) {
|
|
7896
|
+
return this.stompClient.subscribe(destination, function (message) {
|
|
7897
|
+
var event = JSON.parse(message.body || '{}');
|
|
7898
|
+
primitiveManager.fireEvent(event);
|
|
7899
|
+
});
|
|
7711
7900
|
};
|
|
7712
|
-
|
|
7713
|
-
|
|
7714
|
-
|
|
7901
|
+
WebsocketService.prototype.createStompSubscriptions = function (primitiveManager) {
|
|
7902
|
+
var subscriptionUrlWithToken = this.buildSubscriptionUrlWithToken(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
7903
|
+
var subscriptionUrlWithoutToken = this.getSubscriptionUrlWithoutToken(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
7904
|
+
var stompSubscriptionWithToken = this.createStompSubscription(subscriptionUrlWithToken, primitiveManager);
|
|
7905
|
+
var stompSubscriptionWithoutToken = this.createStompSubscription(subscriptionUrlWithoutToken, primitiveManager);
|
|
7906
|
+
primitiveManager.subscribe(stompSubscriptionWithToken, stompSubscriptionWithoutToken);
|
|
7907
|
+
this.subscribed$.next(primitiveManager);
|
|
7715
7908
|
};
|
|
7716
|
-
|
|
7717
|
-
|
|
7718
|
-
|
|
7719
|
-
|
|
7720
|
-
|
|
7721
|
-
|
|
7722
|
-
WebsocketService
|
|
7723
|
-
|
|
7724
|
-
WebsocketService.TOKEN = JSON.parse(jsCookie.get(WebsocketService_1.TOKEN_COOKIE) || '{}');
|
|
7725
|
-
/** @private */
|
|
7726
|
-
WebsocketService.WEBSOCKET_URL = jsCookie.get(WebsocketService_1.BASE_URL_COOKIE) + '/websocket/';
|
|
7727
|
-
WebsocketService.ɵprov = core.ɵɵdefineInjectable({ factory: function WebsocketService_Factory() { return new WebsocketService(); }, token: WebsocketService, providedIn: "root" });
|
|
7728
|
-
WebsocketService = WebsocketService_1 = __decorate([
|
|
7909
|
+
WebsocketService.prototype.getSubscriptionUrl = function () {
|
|
7910
|
+
return this.userInformationService.getWebSocketUrl() + "/subscription";
|
|
7911
|
+
};
|
|
7912
|
+
WebsocketService.ctorParameters = function () { return [
|
|
7913
|
+
{ type: UserInformationService }
|
|
7914
|
+
]; };
|
|
7915
|
+
WebsocketService.ɵprov = core.ɵɵdefineInjectable({ factory: function WebsocketService_Factory() { return new WebsocketService(core.ɵɵinject(UserInformationService)); }, token: WebsocketService, providedIn: "root" });
|
|
7916
|
+
WebsocketService = __decorate([
|
|
7729
7917
|
core.Injectable({
|
|
7730
7918
|
providedIn: 'root'
|
|
7731
7919
|
})
|
|
@@ -7801,6 +7989,73 @@
|
|
|
7801
7989
|
return VerifyModulePermission;
|
|
7802
7990
|
}());
|
|
7803
7991
|
|
|
7992
|
+
var VerifyModulePermissionsService = /** @class */ (function () {
|
|
7993
|
+
function VerifyModulePermissionsService(http) {
|
|
7994
|
+
this.http = http;
|
|
7995
|
+
}
|
|
7996
|
+
VerifyModulePermissionsService_1 = VerifyModulePermissionsService;
|
|
7997
|
+
VerifyModulePermissionsService.prototype.consultaModulos = function (request) {
|
|
7998
|
+
return this.http.post(VerifyModulePermissionsService_1.QUERY_MODULES_URL, request);
|
|
7999
|
+
};
|
|
8000
|
+
var VerifyModulePermissionsService_1;
|
|
8001
|
+
VerifyModulePermissionsService.QUERY_MODULES_URL = "erpx_fnd/empresa/queries/consultaModulos";
|
|
8002
|
+
VerifyModulePermissionsService.ctorParameters = function () { return [
|
|
8003
|
+
{ type: http.HttpClient }
|
|
8004
|
+
]; };
|
|
8005
|
+
VerifyModulePermissionsService.ɵprov = core.ɵɵdefineInjectable({ factory: function VerifyModulePermissionsService_Factory() { return new VerifyModulePermissionsService(core.ɵɵinject(http.HttpClient)); }, token: VerifyModulePermissionsService, providedIn: "any" });
|
|
8006
|
+
VerifyModulePermissionsService = VerifyModulePermissionsService_1 = __decorate([
|
|
8007
|
+
core.Injectable({
|
|
8008
|
+
providedIn: "any"
|
|
8009
|
+
})
|
|
8010
|
+
], VerifyModulePermissionsService);
|
|
8011
|
+
return VerifyModulePermissionsService;
|
|
8012
|
+
}());
|
|
8013
|
+
|
|
8014
|
+
var VerifyModulePermissions = /** @class */ (function () {
|
|
8015
|
+
function VerifyModulePermissions(verifyModulePermissionsService) {
|
|
8016
|
+
this.verifyModulePermissionsService = verifyModulePermissionsService;
|
|
8017
|
+
}
|
|
8018
|
+
VerifyModulePermissions_1 = VerifyModulePermissions;
|
|
8019
|
+
/**
|
|
8020
|
+
* Method to verify if user has permission on a specific module
|
|
8021
|
+
* @param modules Modules to verify the permission
|
|
8022
|
+
* @param requestPermission Indicative if must be call the primitive
|
|
8023
|
+
* @returns An boolean Observable
|
|
8024
|
+
*/
|
|
8025
|
+
VerifyModulePermissions.prototype.hasPermissions = function (modules, requestPermission) {
|
|
8026
|
+
var moduleSubject = VerifyModulePermissions_1.subjectsPerModuleMap.get(modules);
|
|
8027
|
+
if (!moduleSubject || requestPermission) {
|
|
8028
|
+
var newModuleSubject_1 = new rxjs.ReplaySubject(1);
|
|
8029
|
+
VerifyModulePermissions_1.subjectsPerModuleMap.set(modules, newModuleSubject_1);
|
|
8030
|
+
this.verifyModulePermissionsService
|
|
8031
|
+
.consultaModulos({ modulo: modules, somenteAtivo: true })
|
|
8032
|
+
.pipe(operators.take(1))
|
|
8033
|
+
.subscribe(function (response) {
|
|
8034
|
+
var hasPermissions = (response === null || response === void 0 ? void 0 : response.modulos) || [];
|
|
8035
|
+
newModuleSubject_1.next(hasPermissions);
|
|
8036
|
+
}, function (err) {
|
|
8037
|
+
VerifyModulePermissions_1.subjectsPerModuleMap.delete(modules);
|
|
8038
|
+
newModuleSubject_1.error(err);
|
|
8039
|
+
newModuleSubject_1.unsubscribe();
|
|
8040
|
+
});
|
|
8041
|
+
return newModuleSubject_1.asObservable();
|
|
8042
|
+
}
|
|
8043
|
+
return moduleSubject.asObservable();
|
|
8044
|
+
};
|
|
8045
|
+
var VerifyModulePermissions_1;
|
|
8046
|
+
VerifyModulePermissions.ctorParameters = function () { return [
|
|
8047
|
+
{ type: VerifyModulePermissionsService }
|
|
8048
|
+
]; };
|
|
8049
|
+
VerifyModulePermissions.subjectsPerModuleMap = new Map();
|
|
8050
|
+
VerifyModulePermissions.ɵprov = core.ɵɵdefineInjectable({ factory: function VerifyModulePermissions_Factory() { return new VerifyModulePermissions(core.ɵɵinject(VerifyModulePermissionsService)); }, token: VerifyModulePermissions, providedIn: "root" });
|
|
8051
|
+
VerifyModulePermissions = VerifyModulePermissions_1 = __decorate([
|
|
8052
|
+
core.Injectable({
|
|
8053
|
+
providedIn: "root"
|
|
8054
|
+
})
|
|
8055
|
+
], VerifyModulePermissions);
|
|
8056
|
+
return VerifyModulePermissions;
|
|
8057
|
+
}());
|
|
8058
|
+
|
|
7804
8059
|
|
|
7805
8060
|
(function (ModulesEnum) {
|
|
7806
8061
|
ModulesEnum["CONTROLADORIA"] = "CONTROLADORIA";
|
|
@@ -7929,6 +8184,7 @@
|
|
|
7929
8184
|
exports.NotaFiscalEntradaLookup = NotaFiscalEntradaLookup;
|
|
7930
8185
|
exports.NpsService = NpsService;
|
|
7931
8186
|
exports.ParametersLookup = ParametersLookup;
|
|
8187
|
+
exports.PrimitiveManager = PrimitiveManager;
|
|
7932
8188
|
exports.ProdutoServicoLookup = ProdutoServicoLookup;
|
|
7933
8189
|
exports.QuantidadeDisponivelDemandaLookup = QuantidadeDisponivelDemandaLookup;
|
|
7934
8190
|
exports.RequisicaoLookup = RequisicaoLookup;
|
|
@@ -7937,12 +8193,15 @@
|
|
|
7937
8193
|
exports.UnidadeMedidaLookup = UnidadeMedidaLookup;
|
|
7938
8194
|
exports.UtilsModule = UtilsModule;
|
|
7939
8195
|
exports.VerifyModulePermission = VerifyModulePermission;
|
|
8196
|
+
exports.VerifyModulePermissions = VerifyModulePermissions;
|
|
7940
8197
|
exports.WebsocketService = WebsocketService;
|
|
7941
8198
|
exports.naturezaReceitaPisCofins = naturezaReceitaPisCofins;
|
|
7942
8199
|
exports.ɵ0 = ɵ0;
|
|
7943
8200
|
exports.ɵa = ErpLookupsService;
|
|
7944
8201
|
exports.ɵd = StorageService;
|
|
7945
|
-
exports.ɵe =
|
|
8202
|
+
exports.ɵe = UserInformationService;
|
|
8203
|
+
exports.ɵf = VerifyModulePermissionService;
|
|
8204
|
+
exports.ɵg = VerifyModulePermissionsService;
|
|
7946
8205
|
|
|
7947
8206
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
7948
8207
|
|