@senior-gestao-empresarial/angular-components 6.11.5 → 6.12.0-67d9099d-c888-4b61-a14e-4c7c373707d6
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 +513 -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 +259 -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 +317 -256
- package/esm5/senior-gestao-empresarial-angular-components.js +4 -2
- package/fesm2015/senior-gestao-empresarial-angular-components.js +417 -193
- package/fesm2015/senior-gestao-empresarial-angular-components.js.map +1 -1
- package/fesm5/senior-gestao-empresarial-angular-components.js +509 -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,507 @@
|
|
|
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 && !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
|
+
return [4 /*yield*/, this.stompClient.deactivate()];
|
|
7648
|
+
case 3:
|
|
7649
|
+
_d.sent();
|
|
7650
|
+
_d.label = 4;
|
|
7651
|
+
case 4: return [3 /*break*/, 7];
|
|
7652
|
+
case 5: return [4 /*yield*/, this.connectionLock.release()];
|
|
7653
|
+
case 6:
|
|
7654
|
+
_d.sent();
|
|
7655
|
+
return [7 /*endfinally*/];
|
|
7656
|
+
case 7: return [2 /*return*/];
|
|
7657
|
+
}
|
|
7658
|
+
});
|
|
7659
|
+
});
|
|
7456
7660
|
};
|
|
7457
7661
|
/**
|
|
7458
|
-
*
|
|
7459
|
-
* @return
|
|
7662
|
+
* Check if the websocket is connected
|
|
7663
|
+
* @return `boolean` representing if the websocket is connected
|
|
7460
7664
|
*/
|
|
7461
|
-
WebsocketService.prototype.
|
|
7462
|
-
|
|
7463
|
-
|
|
7464
|
-
|
|
7465
|
-
return this.
|
|
7466
|
-
|
|
7467
|
-
|
|
7468
|
-
|
|
7469
|
-
|
|
7470
|
-
|
|
7471
|
-
|
|
7472
|
-
|
|
7473
|
-
|
|
7474
|
-
}
|
|
7665
|
+
WebsocketService.prototype.isConnected = function () {
|
|
7666
|
+
if (!this.stompClient) {
|
|
7667
|
+
return false;
|
|
7668
|
+
}
|
|
7669
|
+
return this.stompClient.connected;
|
|
7670
|
+
};
|
|
7671
|
+
/**
|
|
7672
|
+
* Check if the websocket is tring to connect
|
|
7673
|
+
* @return `boolean` representing if the websocket status
|
|
7674
|
+
*/
|
|
7675
|
+
WebsocketService.prototype.isConnecting = function () {
|
|
7676
|
+
if (!this.stompClient) {
|
|
7677
|
+
return false;
|
|
7678
|
+
}
|
|
7679
|
+
return !this.stompClient.connected && this.stompClient.active;
|
|
7680
|
+
};
|
|
7681
|
+
/**
|
|
7682
|
+
* Event responsable to emit an event when the connection is established.
|
|
7683
|
+
* Do not forget to unsubscribe the observable when you don't need it anymore.
|
|
7684
|
+
* @return `Observable<boolean>`
|
|
7685
|
+
*/
|
|
7686
|
+
WebsocketService.prototype.onConnect = function () {
|
|
7687
|
+
return this.connected$.asObservable()
|
|
7688
|
+
.pipe(operators.filter(function (p) { return p === true; }));
|
|
7689
|
+
};
|
|
7690
|
+
/**
|
|
7691
|
+
* Event responsable to emit an event when the connection is closed.
|
|
7692
|
+
* Do not forget to unsubscribe the observable when you don't need it anymore.
|
|
7693
|
+
* @return `Observable<void>`
|
|
7694
|
+
*/
|
|
7695
|
+
WebsocketService.prototype.onDisconnect = function () {
|
|
7696
|
+
return this.disconnected$.asObservable();
|
|
7697
|
+
};
|
|
7698
|
+
/**
|
|
7699
|
+
* Event responsable to emit an event when the connection is reestablished.
|
|
7700
|
+
* Do not forget to unsubscribe the observable when you don't need it anymore.
|
|
7701
|
+
* @return `Observable<void>`
|
|
7702
|
+
*/
|
|
7703
|
+
WebsocketService.prototype.onReconnect = function () {
|
|
7704
|
+
return this.reconnected$.asObservable();
|
|
7475
7705
|
};
|
|
7476
7706
|
/**
|
|
7477
|
-
*
|
|
7478
|
-
*
|
|
7707
|
+
* Event responsable to emit an event when an error ocurred.
|
|
7708
|
+
* Do not forget to unsubscribe the observable when you don't need it anymore.
|
|
7709
|
+
* @return `Observable<FrameImpl>`
|
|
7479
7710
|
*/
|
|
7480
7711
|
WebsocketService.prototype.onError = function () {
|
|
7481
7712
|
return this.error$.asObservable();
|
|
7482
7713
|
};
|
|
7483
7714
|
/**
|
|
7484
|
-
*
|
|
7485
|
-
*
|
|
7486
|
-
* @
|
|
7487
|
-
* @param {
|
|
7488
|
-
* @
|
|
7489
|
-
* @return Um Observable<T> que emite notificações toda vez que o respectivo evento é publicado.
|
|
7715
|
+
* Event responsible to emit an event when a primitive is called.
|
|
7716
|
+
* Do not forget to unsubscribe the observable when you don't need it anymore.
|
|
7717
|
+
* @typeParam `<T>` Object type that will be used in the observable for the `data` property.
|
|
7718
|
+
* @param {OnEventOptions} options Configurations for the event.
|
|
7719
|
+
* @return `Observable<PrimitiveEvent<T>>` Observable that emits an event when the service calls the primitive.
|
|
7490
7720
|
*/
|
|
7491
7721
|
WebsocketService.prototype.onEvent = function (options) {
|
|
7492
7722
|
var _this = this;
|
|
7493
|
-
this.connect();
|
|
7494
7723
|
var domain = options.domain, service = options.service, primitive = options.primitive;
|
|
7495
|
-
var key = this.
|
|
7724
|
+
var key = this.buildPrimitiveManagerKey(domain, service, primitive);
|
|
7496
7725
|
if (this.primitiveManagers.has(key)) {
|
|
7497
|
-
return this.primitiveManagers.get(key).
|
|
7726
|
+
return this.primitiveManagers.get(key).getEventObservable();
|
|
7498
7727
|
}
|
|
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
|
-
};
|
|
7728
|
+
var primitiveManager = new PrimitiveManager(domain, service, primitive);
|
|
7507
7729
|
this.primitiveManagers.set(key, primitiveManager);
|
|
7508
|
-
this.
|
|
7509
|
-
.
|
|
7510
|
-
|
|
7511
|
-
|
|
7730
|
+
this.connect().then(function () {
|
|
7731
|
+
_this.onConnect()
|
|
7732
|
+
.pipe(operators.take(1))
|
|
7733
|
+
.subscribe(function () {
|
|
7734
|
+
_this.createStompSubscriptions(primitiveManager);
|
|
7735
|
+
});
|
|
7512
7736
|
});
|
|
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);
|
|
7737
|
+
return primitiveManager
|
|
7738
|
+
.getEventObservable()
|
|
7739
|
+
.pipe(operators.finalize(function () { return _this.unsubscribePrimitiveOnFinalize(primitiveManager); }));
|
|
7529
7740
|
};
|
|
7530
|
-
/**
|
|
7531
|
-
|
|
7741
|
+
/**
|
|
7742
|
+
* Event responsible to emit an event when a subscription is created for the primitive.
|
|
7743
|
+
* Do not forget to unsubscribe the observable when you don't need it anymore.
|
|
7744
|
+
* @param {OnEventOptions} options Configurations for the event.
|
|
7745
|
+
* Observable responsável por emitir uma notificação após o subscribe do evento pela primeira vez.
|
|
7746
|
+
* @return `Observable<boolean>` Observable that emits an event when the service calls the primitive.
|
|
7747
|
+
*/
|
|
7748
|
+
WebsocketService.prototype.onSubscribe = function (options) {
|
|
7532
7749
|
var _this = this;
|
|
7533
|
-
|
|
7534
|
-
|
|
7535
|
-
this.
|
|
7536
|
-
|
|
7537
|
-
|
|
7538
|
-
|
|
7539
|
-
|
|
7540
|
-
|
|
7541
|
-
_this.reconnectPrimitives();
|
|
7542
|
-
_this.connected$.next(true);
|
|
7543
|
-
_this.reconnect$.next();
|
|
7750
|
+
var domain = options.domain, service = options.service, primitive = options.primitive;
|
|
7751
|
+
var key = this.buildPrimitiveManagerKey(domain, service, primitive);
|
|
7752
|
+
return this.onConnect().pipe(operators.take(1), operators.switchMap(function () {
|
|
7753
|
+
if (_this.primitiveManagers.has(key)) {
|
|
7754
|
+
return _this.primitiveManagers
|
|
7755
|
+
.get(key)
|
|
7756
|
+
.getSubscriptionObservable()
|
|
7757
|
+
.pipe(operators.take(1));
|
|
7544
7758
|
}
|
|
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
|
-
});
|
|
7759
|
+
return _this.subscribed$.asObservable().pipe(operators.filter(function (primitiveManager) {
|
|
7760
|
+
return _this.buildPrimitiveManagerKey(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive) === key;
|
|
7761
|
+
}), operators.map(function () { return true; }), operators.take(1));
|
|
7762
|
+
}));
|
|
7567
7763
|
};
|
|
7568
|
-
WebsocketService.prototype.
|
|
7569
|
-
var
|
|
7570
|
-
|
|
7571
|
-
|
|
7764
|
+
WebsocketService.prototype.debug = function (message) {
|
|
7765
|
+
var optionalParams = [];
|
|
7766
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
7767
|
+
optionalParams[_i - 1] = arguments[_i];
|
|
7572
7768
|
}
|
|
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
|
-
}
|
|
7769
|
+
if (!this.debugEnable) {
|
|
7770
|
+
return;
|
|
7590
7771
|
}
|
|
7591
|
-
|
|
7592
|
-
|
|
7593
|
-
|
|
7594
|
-
|
|
7595
|
-
|
|
7596
|
-
|
|
7772
|
+
console.log.apply(console, __spread(['WS debug: ' + message], optionalParams));
|
|
7773
|
+
};
|
|
7774
|
+
WebsocketService.prototype.info = function (message) {
|
|
7775
|
+
console.info('WS info: ' + message);
|
|
7776
|
+
};
|
|
7777
|
+
WebsocketService.prototype.handleOnConnected = function () {
|
|
7778
|
+
this.info('Webscoket connected');
|
|
7779
|
+
this.connected$.next(true);
|
|
7780
|
+
if (this.lostConnection) {
|
|
7781
|
+
this.info('Webscoket reconnected, recriating subscriptions');
|
|
7782
|
+
this.handleReconnection();
|
|
7597
7783
|
}
|
|
7598
|
-
|
|
7599
|
-
|
|
7600
|
-
|
|
7601
|
-
|
|
7602
|
-
|
|
7784
|
+
};
|
|
7785
|
+
WebsocketService.prototype.handleOnDisconnect = function () {
|
|
7786
|
+
this.info('Webscoket disconnected');
|
|
7787
|
+
this.connected$.next(false);
|
|
7788
|
+
this.disconnected$.next();
|
|
7789
|
+
};
|
|
7790
|
+
WebsocketService.prototype.handleOnWebSocketClose = function (data) {
|
|
7791
|
+
if (data.wasClean) {
|
|
7792
|
+
return;
|
|
7603
7793
|
}
|
|
7604
|
-
|
|
7605
|
-
|
|
7606
|
-
|
|
7607
|
-
|
|
7608
|
-
|
|
7609
|
-
|
|
7794
|
+
this.lostConnection = true;
|
|
7795
|
+
};
|
|
7796
|
+
WebsocketService.prototype.handleOnStompError = function (data) {
|
|
7797
|
+
this.handleError('StompError', data);
|
|
7798
|
+
if (this.isAuthenticationError(data)) {
|
|
7799
|
+
this.info('Authentication error, recriating subscriptions');
|
|
7800
|
+
this.handleReconnection();
|
|
7610
7801
|
}
|
|
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
7802
|
};
|
|
7620
|
-
|
|
7621
|
-
|
|
7622
|
-
var
|
|
7623
|
-
|
|
7624
|
-
|
|
7625
|
-
|
|
7626
|
-
|
|
7627
|
-
: null;
|
|
7628
|
-
return "/topic/" + tenant + "/" + token + "/" + domain + "/" + service + "/" + primitive;
|
|
7803
|
+
WebsocketService.prototype.isAuthenticationError = function (data) {
|
|
7804
|
+
var _a;
|
|
7805
|
+
var errorMessage = (_a = data === null || data === void 0 ? void 0 : data.headers) === null || _a === void 0 ? void 0 : _a.message;
|
|
7806
|
+
if (!errorMessage) {
|
|
7807
|
+
return false;
|
|
7808
|
+
}
|
|
7809
|
+
return errorMessage.toLowerCase().indexOf('forbiddenexception') !== -1;
|
|
7629
7810
|
};
|
|
7630
|
-
|
|
7631
|
-
|
|
7632
|
-
var tenant = WebsocketService_1.TOKEN
|
|
7633
|
-
? WebsocketService_1.TOKEN.username.split('@')[1]
|
|
7634
|
-
: null;
|
|
7635
|
-
return "/topic/" + tenant + "/" + domain + "/" + service + "/" + primitive;
|
|
7811
|
+
WebsocketService.prototype.handleOnWebSocketError = function (data) {
|
|
7812
|
+
this.handleError('WebSocketError', data);
|
|
7636
7813
|
};
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
|
|
7640
|
-
var event = JSON.parse(message.body || '{}');
|
|
7641
|
-
primitiveManager.event$.next(event);
|
|
7642
|
-
});
|
|
7814
|
+
WebsocketService.prototype.handleError = function (origin, data) {
|
|
7815
|
+
console.error(origin, data);
|
|
7816
|
+
this.error$.next(data);
|
|
7643
7817
|
};
|
|
7644
|
-
|
|
7645
|
-
|
|
7646
|
-
|
|
7647
|
-
this.
|
|
7648
|
-
this._stompClient.debug = function () { return null; };
|
|
7818
|
+
WebsocketService.prototype.handleReconnection = function () {
|
|
7819
|
+
this.lostConnection = false;
|
|
7820
|
+
this.reconnectPrimitives();
|
|
7821
|
+
this.reconnected$.next();
|
|
7649
7822
|
};
|
|
7650
|
-
/** @private */
|
|
7651
7823
|
WebsocketService.prototype.reconnectPrimitives = function () {
|
|
7652
|
-
var
|
|
7824
|
+
var e_2, _a;
|
|
7653
7825
|
try {
|
|
7654
7826
|
for (var _b = __values(this.primitiveManagers.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
7655
7827
|
var primitiveManager = _c.value;
|
|
7656
7828
|
this.createStompSubscriptions(primitiveManager);
|
|
7657
7829
|
}
|
|
7658
7830
|
}
|
|
7659
|
-
catch (
|
|
7831
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
7660
7832
|
finally {
|
|
7661
7833
|
try {
|
|
7662
7834
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
7663
7835
|
}
|
|
7664
|
-
finally { if (
|
|
7836
|
+
finally { if (e_2) throw e_2.error; }
|
|
7665
7837
|
}
|
|
7666
7838
|
};
|
|
7667
|
-
|
|
7839
|
+
WebsocketService.prototype.buildSubscriptionUrlWithToken = function (domain, service, primitive) {
|
|
7840
|
+
var authToken = this.userInformationService.getAuthToken();
|
|
7841
|
+
var tenant = this.userInformationService.getTenantDomain();
|
|
7842
|
+
return "/topic/" + tenant + "/" + authToken + "/" + domain + "/" + service + "/" + primitive;
|
|
7843
|
+
};
|
|
7844
|
+
WebsocketService.prototype.getSubscriptionUrlWithoutToken = function (domain, service, primitive) {
|
|
7845
|
+
var tenant = this.userInformationService.getTenantDomain();
|
|
7846
|
+
return "/topic/" + tenant + "/" + domain + "/" + service + "/" + primitive;
|
|
7847
|
+
};
|
|
7848
|
+
WebsocketService.prototype.buildPrimitiveManagerKey = function (domain, service, primitive) {
|
|
7849
|
+
return domain + "/" + service + "/" + primitive;
|
|
7850
|
+
};
|
|
7851
|
+
WebsocketService.prototype.unsubscribePrimitiveOnFinalize = function (primitiveManager) {
|
|
7852
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
7853
|
+
var key;
|
|
7854
|
+
return __generator(this, function (_a) {
|
|
7855
|
+
switch (_a.label) {
|
|
7856
|
+
case 0:
|
|
7857
|
+
if (primitiveManager.hasObservers()) {
|
|
7858
|
+
return [2 /*return*/];
|
|
7859
|
+
}
|
|
7860
|
+
primitiveManager.unsubscribe();
|
|
7861
|
+
key = this.buildPrimitiveManagerKey(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
7862
|
+
this.primitiveManagers.delete(key);
|
|
7863
|
+
return [4 /*yield*/, this.disconnectIfNoMoreObservables()];
|
|
7864
|
+
case 1:
|
|
7865
|
+
_a.sent();
|
|
7866
|
+
return [2 /*return*/];
|
|
7867
|
+
}
|
|
7868
|
+
});
|
|
7869
|
+
});
|
|
7870
|
+
};
|
|
7871
|
+
WebsocketService.prototype.disconnectIfNoMoreObservables = function () {
|
|
7872
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
7873
|
+
return __generator(this, function (_a) {
|
|
7874
|
+
switch (_a.label) {
|
|
7875
|
+
case 0:
|
|
7876
|
+
if (!(this.getObserversCount() === 0)) return [3 /*break*/, 2];
|
|
7877
|
+
this.debug('Manually disconnecting because there are no more observers');
|
|
7878
|
+
return [4 /*yield*/, this.disconnect()];
|
|
7879
|
+
case 1:
|
|
7880
|
+
_a.sent();
|
|
7881
|
+
_a.label = 2;
|
|
7882
|
+
case 2: return [2 /*return*/];
|
|
7883
|
+
}
|
|
7884
|
+
});
|
|
7885
|
+
});
|
|
7886
|
+
};
|
|
7668
7887
|
WebsocketService.prototype.getObserversCount = function () {
|
|
7669
|
-
var e_5, _a;
|
|
7670
7888
|
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
|
-
}
|
|
7889
|
+
this.primitiveManagers.forEach(function (primitiveManager) {
|
|
7890
|
+
observersCount += primitiveManager.getObserversCount();
|
|
7891
|
+
});
|
|
7684
7892
|
return observersCount;
|
|
7685
7893
|
};
|
|
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();
|
|
7894
|
+
WebsocketService.prototype.createStompSubscription = function (destination, primitiveManager) {
|
|
7895
|
+
return this.stompClient.subscribe(destination, function (message) {
|
|
7896
|
+
var event = JSON.parse(message.body || '{}');
|
|
7897
|
+
primitiveManager.fireEvent(event);
|
|
7898
|
+
});
|
|
7711
7899
|
};
|
|
7712
|
-
|
|
7713
|
-
|
|
7714
|
-
|
|
7900
|
+
WebsocketService.prototype.createStompSubscriptions = function (primitiveManager) {
|
|
7901
|
+
var subscriptionUrlWithToken = this.buildSubscriptionUrlWithToken(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
7902
|
+
var subscriptionUrlWithoutToken = this.getSubscriptionUrlWithoutToken(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
7903
|
+
var stompSubscriptionWithToken = this.createStompSubscription(subscriptionUrlWithToken, primitiveManager);
|
|
7904
|
+
var stompSubscriptionWithoutToken = this.createStompSubscription(subscriptionUrlWithoutToken, primitiveManager);
|
|
7905
|
+
primitiveManager.subscribe(stompSubscriptionWithToken, stompSubscriptionWithoutToken);
|
|
7906
|
+
this.subscribed$.next(primitiveManager);
|
|
7715
7907
|
};
|
|
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([
|
|
7908
|
+
WebsocketService.prototype.getSubscriptionUrl = function () {
|
|
7909
|
+
return this.userInformationService.getWebSocketUrl() + "/subscription";
|
|
7910
|
+
};
|
|
7911
|
+
WebsocketService.ctorParameters = function () { return [
|
|
7912
|
+
{ type: UserInformationService }
|
|
7913
|
+
]; };
|
|
7914
|
+
WebsocketService.ɵprov = core.ɵɵdefineInjectable({ factory: function WebsocketService_Factory() { return new WebsocketService(core.ɵɵinject(UserInformationService)); }, token: WebsocketService, providedIn: "root" });
|
|
7915
|
+
WebsocketService = __decorate([
|
|
7729
7916
|
core.Injectable({
|
|
7730
7917
|
providedIn: 'root'
|
|
7731
7918
|
})
|
|
@@ -7801,6 +7988,73 @@
|
|
|
7801
7988
|
return VerifyModulePermission;
|
|
7802
7989
|
}());
|
|
7803
7990
|
|
|
7991
|
+
var VerifyModulePermissionsService = /** @class */ (function () {
|
|
7992
|
+
function VerifyModulePermissionsService(http) {
|
|
7993
|
+
this.http = http;
|
|
7994
|
+
}
|
|
7995
|
+
VerifyModulePermissionsService_1 = VerifyModulePermissionsService;
|
|
7996
|
+
VerifyModulePermissionsService.prototype.consultaModulos = function (request) {
|
|
7997
|
+
return this.http.post(VerifyModulePermissionsService_1.QUERY_MODULES_URL, request);
|
|
7998
|
+
};
|
|
7999
|
+
var VerifyModulePermissionsService_1;
|
|
8000
|
+
VerifyModulePermissionsService.QUERY_MODULES_URL = "erpx_fnd/empresa/queries/consultaModulos";
|
|
8001
|
+
VerifyModulePermissionsService.ctorParameters = function () { return [
|
|
8002
|
+
{ type: http.HttpClient }
|
|
8003
|
+
]; };
|
|
8004
|
+
VerifyModulePermissionsService.ɵprov = core.ɵɵdefineInjectable({ factory: function VerifyModulePermissionsService_Factory() { return new VerifyModulePermissionsService(core.ɵɵinject(http.HttpClient)); }, token: VerifyModulePermissionsService, providedIn: "any" });
|
|
8005
|
+
VerifyModulePermissionsService = VerifyModulePermissionsService_1 = __decorate([
|
|
8006
|
+
core.Injectable({
|
|
8007
|
+
providedIn: "any"
|
|
8008
|
+
})
|
|
8009
|
+
], VerifyModulePermissionsService);
|
|
8010
|
+
return VerifyModulePermissionsService;
|
|
8011
|
+
}());
|
|
8012
|
+
|
|
8013
|
+
var VerifyModulePermissions = /** @class */ (function () {
|
|
8014
|
+
function VerifyModulePermissions(verifyModulePermissionsService) {
|
|
8015
|
+
this.verifyModulePermissionsService = verifyModulePermissionsService;
|
|
8016
|
+
}
|
|
8017
|
+
VerifyModulePermissions_1 = VerifyModulePermissions;
|
|
8018
|
+
/**
|
|
8019
|
+
* Method to verify if user has permission on a specific module
|
|
8020
|
+
* @param modules Modules to verify the permission
|
|
8021
|
+
* @param requestPermission Indicative if must be call the primitive
|
|
8022
|
+
* @returns An boolean Observable
|
|
8023
|
+
*/
|
|
8024
|
+
VerifyModulePermissions.prototype.hasPermissions = function (modules, requestPermission) {
|
|
8025
|
+
var moduleSubject = VerifyModulePermissions_1.subjectsPerModuleMap.get(modules);
|
|
8026
|
+
if (!moduleSubject || requestPermission) {
|
|
8027
|
+
var newModuleSubject_1 = new rxjs.ReplaySubject(1);
|
|
8028
|
+
VerifyModulePermissions_1.subjectsPerModuleMap.set(modules, newModuleSubject_1);
|
|
8029
|
+
this.verifyModulePermissionsService
|
|
8030
|
+
.consultaModulos({ modulo: modules, somenteAtivo: true })
|
|
8031
|
+
.pipe(operators.take(1))
|
|
8032
|
+
.subscribe(function (response) {
|
|
8033
|
+
var hasPermissions = (response === null || response === void 0 ? void 0 : response.modulos) || [];
|
|
8034
|
+
newModuleSubject_1.next(hasPermissions);
|
|
8035
|
+
}, function (err) {
|
|
8036
|
+
VerifyModulePermissions_1.subjectsPerModuleMap.delete(modules);
|
|
8037
|
+
newModuleSubject_1.error(err);
|
|
8038
|
+
newModuleSubject_1.unsubscribe();
|
|
8039
|
+
});
|
|
8040
|
+
return newModuleSubject_1.asObservable();
|
|
8041
|
+
}
|
|
8042
|
+
return moduleSubject.asObservable();
|
|
8043
|
+
};
|
|
8044
|
+
var VerifyModulePermissions_1;
|
|
8045
|
+
VerifyModulePermissions.ctorParameters = function () { return [
|
|
8046
|
+
{ type: VerifyModulePermissionsService }
|
|
8047
|
+
]; };
|
|
8048
|
+
VerifyModulePermissions.subjectsPerModuleMap = new Map();
|
|
8049
|
+
VerifyModulePermissions.ɵprov = core.ɵɵdefineInjectable({ factory: function VerifyModulePermissions_Factory() { return new VerifyModulePermissions(core.ɵɵinject(VerifyModulePermissionsService)); }, token: VerifyModulePermissions, providedIn: "root" });
|
|
8050
|
+
VerifyModulePermissions = VerifyModulePermissions_1 = __decorate([
|
|
8051
|
+
core.Injectable({
|
|
8052
|
+
providedIn: "root"
|
|
8053
|
+
})
|
|
8054
|
+
], VerifyModulePermissions);
|
|
8055
|
+
return VerifyModulePermissions;
|
|
8056
|
+
}());
|
|
8057
|
+
|
|
7804
8058
|
|
|
7805
8059
|
(function (ModulesEnum) {
|
|
7806
8060
|
ModulesEnum["CONTROLADORIA"] = "CONTROLADORIA";
|
|
@@ -7929,6 +8183,7 @@
|
|
|
7929
8183
|
exports.NotaFiscalEntradaLookup = NotaFiscalEntradaLookup;
|
|
7930
8184
|
exports.NpsService = NpsService;
|
|
7931
8185
|
exports.ParametersLookup = ParametersLookup;
|
|
8186
|
+
exports.PrimitiveManager = PrimitiveManager;
|
|
7932
8187
|
exports.ProdutoServicoLookup = ProdutoServicoLookup;
|
|
7933
8188
|
exports.QuantidadeDisponivelDemandaLookup = QuantidadeDisponivelDemandaLookup;
|
|
7934
8189
|
exports.RequisicaoLookup = RequisicaoLookup;
|
|
@@ -7937,12 +8192,15 @@
|
|
|
7937
8192
|
exports.UnidadeMedidaLookup = UnidadeMedidaLookup;
|
|
7938
8193
|
exports.UtilsModule = UtilsModule;
|
|
7939
8194
|
exports.VerifyModulePermission = VerifyModulePermission;
|
|
8195
|
+
exports.VerifyModulePermissions = VerifyModulePermissions;
|
|
7940
8196
|
exports.WebsocketService = WebsocketService;
|
|
7941
8197
|
exports.naturezaReceitaPisCofins = naturezaReceitaPisCofins;
|
|
7942
8198
|
exports.ɵ0 = ɵ0;
|
|
7943
8199
|
exports.ɵa = ErpLookupsService;
|
|
7944
8200
|
exports.ɵd = StorageService;
|
|
7945
|
-
exports.ɵe =
|
|
8201
|
+
exports.ɵe = UserInformationService;
|
|
8202
|
+
exports.ɵf = VerifyModulePermissionService;
|
|
8203
|
+
exports.ɵg = VerifyModulePermissionsService;
|
|
7946
8204
|
|
|
7947
8205
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
7948
8206
|
|