@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
|
@@ -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, BehaviorSubject,
|
|
7
|
-
import { takeUntil, filter, catchError, map, takeWhile, switchMap, take, finalize
|
|
6
|
+
import { Subject, throwError, interval, of, BehaviorSubject, ReplaySubject } from 'rxjs';
|
|
7
|
+
import { takeUntil, filter, catchError, map, takeWhile, switchMap, take, finalize } 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';
|
|
@@ -13,9 +13,9 @@ import { TranslateService } from '@ngx-translate/core';
|
|
|
13
13
|
import { HttpInterceptorModule } from '@seniorsistemas/platform-components';
|
|
14
14
|
import { user } from '@seniorsistemas/senior-platform-data';
|
|
15
15
|
import { FormControl, FormGroup } from '@angular/forms';
|
|
16
|
-
import {
|
|
17
|
-
import { get } from 'js-cookie';
|
|
16
|
+
import { Client } from '@stomp/stompjs';
|
|
18
17
|
import * as SockJS from 'sockjs-client';
|
|
18
|
+
import { get } from 'js-cookie';
|
|
19
19
|
|
|
20
20
|
var BreadcrumbComponent = /** @class */ (function () {
|
|
21
21
|
function BreadcrumbComponent(activatedRoute, router) {
|
|
@@ -7206,320 +7206,508 @@ var NpsService = /** @class */ (function () {
|
|
|
7206
7206
|
return NpsService;
|
|
7207
7207
|
}());
|
|
7208
7208
|
|
|
7209
|
+
var AsyncLock = /** @class */ (function () {
|
|
7210
|
+
function AsyncLock() {
|
|
7211
|
+
this.queue = [];
|
|
7212
|
+
this.acquired = false;
|
|
7213
|
+
}
|
|
7214
|
+
AsyncLock.prototype.acquire = function () {
|
|
7215
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
7216
|
+
var _this = this;
|
|
7217
|
+
return __generator(this, function (_a) {
|
|
7218
|
+
if (!this.acquired) {
|
|
7219
|
+
this.acquired = true;
|
|
7220
|
+
return [2 /*return*/, Promise.resolve()];
|
|
7221
|
+
}
|
|
7222
|
+
else {
|
|
7223
|
+
return [2 /*return*/, new Promise(function (resolve, _) {
|
|
7224
|
+
_this.queue.push(resolve);
|
|
7225
|
+
})];
|
|
7226
|
+
}
|
|
7227
|
+
return [2 /*return*/];
|
|
7228
|
+
});
|
|
7229
|
+
});
|
|
7230
|
+
};
|
|
7231
|
+
AsyncLock.prototype.release = function () {
|
|
7232
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
7233
|
+
var continuation;
|
|
7234
|
+
return __generator(this, function (_a) {
|
|
7235
|
+
if (this.queue.length === 0 && this.acquired) {
|
|
7236
|
+
this.acquired = false;
|
|
7237
|
+
return [2 /*return*/, Promise.resolve()];
|
|
7238
|
+
}
|
|
7239
|
+
continuation = this.queue.shift();
|
|
7240
|
+
return [2 /*return*/, new Promise(function (res) {
|
|
7241
|
+
continuation();
|
|
7242
|
+
res();
|
|
7243
|
+
})];
|
|
7244
|
+
});
|
|
7245
|
+
});
|
|
7246
|
+
};
|
|
7247
|
+
return AsyncLock;
|
|
7248
|
+
}());
|
|
7249
|
+
|
|
7250
|
+
var UserInformationService = /** @class */ (function () {
|
|
7251
|
+
function UserInformationService() {
|
|
7252
|
+
}
|
|
7253
|
+
UserInformationService_1 = UserInformationService;
|
|
7254
|
+
UserInformationService.prototype.getAuthToken = function () {
|
|
7255
|
+
var cookieValue = get(UserInformationService_1.TOKEN_COOKIE_KEY) || '{}';
|
|
7256
|
+
var authToken = JSON.parse(cookieValue);
|
|
7257
|
+
return authToken.access_token;
|
|
7258
|
+
};
|
|
7259
|
+
UserInformationService.prototype.getTenantDomain = function () {
|
|
7260
|
+
var cookieValue = get(UserInformationService_1.TOKEN_COOKIE_KEY) || '{}';
|
|
7261
|
+
var authToken = JSON.parse(cookieValue);
|
|
7262
|
+
return authToken.username.split('@')[1];
|
|
7263
|
+
};
|
|
7264
|
+
UserInformationService.prototype.getWebSocketUrl = function () {
|
|
7265
|
+
var baseUrl = get(UserInformationService_1.BASE_URL_COOKIE_KEY);
|
|
7266
|
+
if (!baseUrl.endsWith('/')) {
|
|
7267
|
+
baseUrl += '/';
|
|
7268
|
+
}
|
|
7269
|
+
return baseUrl + 'websocket';
|
|
7270
|
+
};
|
|
7271
|
+
var UserInformationService_1;
|
|
7272
|
+
UserInformationService.BASE_URL_COOKIE_KEY = 'com.senior.base.url';
|
|
7273
|
+
UserInformationService.TOKEN_COOKIE_KEY = 'com.senior.token';
|
|
7274
|
+
UserInformationService.ɵprov = ɵɵdefineInjectable({ factory: function UserInformationService_Factory() { return new UserInformationService(); }, token: UserInformationService, providedIn: "root" });
|
|
7275
|
+
UserInformationService = UserInformationService_1 = __decorate([
|
|
7276
|
+
Injectable({
|
|
7277
|
+
providedIn: 'root'
|
|
7278
|
+
})
|
|
7279
|
+
], UserInformationService);
|
|
7280
|
+
return UserInformationService;
|
|
7281
|
+
}());
|
|
7282
|
+
|
|
7283
|
+
var PrimitiveManager = /** @class */ (function () {
|
|
7284
|
+
function PrimitiveManager(domain, service, primitive) {
|
|
7285
|
+
this.domain = domain;
|
|
7286
|
+
this.service = service;
|
|
7287
|
+
this.primitive = primitive;
|
|
7288
|
+
this.stompSubscriptions = [];
|
|
7289
|
+
this.event$ = new Subject();
|
|
7290
|
+
this.subscribed$ = new BehaviorSubject(false);
|
|
7291
|
+
}
|
|
7292
|
+
PrimitiveManager.prototype.unsubscribe = function () {
|
|
7293
|
+
var e_1, _a;
|
|
7294
|
+
this.event$.complete();
|
|
7295
|
+
try {
|
|
7296
|
+
for (var _b = __values(this.stompSubscriptions), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
7297
|
+
var stompSubscription = _c.value;
|
|
7298
|
+
stompSubscription.unsubscribe();
|
|
7299
|
+
}
|
|
7300
|
+
}
|
|
7301
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
7302
|
+
finally {
|
|
7303
|
+
try {
|
|
7304
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
7305
|
+
}
|
|
7306
|
+
finally { if (e_1) throw e_1.error; }
|
|
7307
|
+
}
|
|
7308
|
+
this.subscribed$.complete();
|
|
7309
|
+
};
|
|
7310
|
+
PrimitiveManager.prototype.fireEvent = function (event) {
|
|
7311
|
+
this.event$.next(event);
|
|
7312
|
+
};
|
|
7313
|
+
PrimitiveManager.prototype.subscribe = function () {
|
|
7314
|
+
var _a;
|
|
7315
|
+
var subscriptions = [];
|
|
7316
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
7317
|
+
subscriptions[_i] = arguments[_i];
|
|
7318
|
+
}
|
|
7319
|
+
(_a = this.stompSubscriptions).push.apply(_a, __spread(subscriptions));
|
|
7320
|
+
this.subscribed$.next(true);
|
|
7321
|
+
};
|
|
7322
|
+
PrimitiveManager.prototype.getEventObservable = function () {
|
|
7323
|
+
return this.event$.asObservable();
|
|
7324
|
+
};
|
|
7325
|
+
PrimitiveManager.prototype.getSubscriptionObservable = function () {
|
|
7326
|
+
return this.subscribed$.asObservable();
|
|
7327
|
+
};
|
|
7328
|
+
PrimitiveManager.prototype.hasObservers = function () {
|
|
7329
|
+
// @IMPORTANT: Replace .observers.length === 1 with .observed in rxjs 7.0+
|
|
7330
|
+
return this.event$.observers.length !== 1;
|
|
7331
|
+
};
|
|
7332
|
+
PrimitiveManager.prototype.getObserversCount = function () {
|
|
7333
|
+
return this.event$.observers.length;
|
|
7334
|
+
};
|
|
7335
|
+
return PrimitiveManager;
|
|
7336
|
+
}());
|
|
7337
|
+
|
|
7338
|
+
var RECONNECT_INTERVAL_MILLISECONDS = 3000;
|
|
7339
|
+
var CONNECTION_TIMEOUT_MILLISECONDS = 5000;
|
|
7209
7340
|
var WebsocketService = /** @class */ (function () {
|
|
7210
|
-
function WebsocketService() {
|
|
7211
|
-
|
|
7212
|
-
this.wasConnected = false;
|
|
7213
|
-
/** @private */
|
|
7214
|
-
this.isConnected = false;
|
|
7215
|
-
/** @private */
|
|
7216
|
-
this.isConnecting = false;
|
|
7217
|
-
/** @private */
|
|
7218
|
-
this.primitiveManagers = new Map();
|
|
7219
|
-
/** @private */
|
|
7341
|
+
function WebsocketService(userInformationService) {
|
|
7342
|
+
this.userInformationService = userInformationService;
|
|
7220
7343
|
this.connected$ = new BehaviorSubject(false);
|
|
7221
|
-
|
|
7222
|
-
this.
|
|
7223
|
-
/** @private */
|
|
7224
|
-
this.reconnect$ = new Subject();
|
|
7225
|
-
/** @private */
|
|
7344
|
+
this.disconnected$ = new Subject();
|
|
7345
|
+
this.reconnected$ = new Subject();
|
|
7226
7346
|
this.error$ = new Subject();
|
|
7227
7347
|
this.subscribed$ = new Subject();
|
|
7348
|
+
this.primitiveManagers = new Map();
|
|
7349
|
+
this.connectionLock = new AsyncLock();
|
|
7350
|
+
this.debugEnable = false;
|
|
7351
|
+
this.lostConnection = false;
|
|
7228
7352
|
}
|
|
7229
|
-
WebsocketService_1 = WebsocketService;
|
|
7230
7353
|
/**
|
|
7231
|
-
*
|
|
7232
|
-
* @return Um `Observable<void>` que emite uma notificação quando a conexão websocket é estabelecida pela primeira vez.
|
|
7354
|
+
* Enables stompjs debug logs and additional info
|
|
7233
7355
|
*/
|
|
7234
|
-
WebsocketService.prototype.
|
|
7235
|
-
|
|
7356
|
+
WebsocketService.prototype.enableDebugLogs = function () {
|
|
7357
|
+
this.debugEnable = true;
|
|
7236
7358
|
};
|
|
7237
7359
|
/**
|
|
7238
|
-
*
|
|
7239
|
-
* @return Um `Observable<void>` que emite uma notificação quando a conexão é desconectada.
|
|
7360
|
+
* Manually starts the connection
|
|
7240
7361
|
*/
|
|
7241
|
-
WebsocketService.prototype.
|
|
7242
|
-
return this
|
|
7362
|
+
WebsocketService.prototype.connect = function () {
|
|
7363
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
7364
|
+
var stompConfig;
|
|
7365
|
+
var _this = this;
|
|
7366
|
+
return __generator(this, function (_a) {
|
|
7367
|
+
switch (_a.label) {
|
|
7368
|
+
case 0: return [4 /*yield*/, this.connectionLock.acquire()];
|
|
7369
|
+
case 1:
|
|
7370
|
+
_a.sent();
|
|
7371
|
+
_a.label = 2;
|
|
7372
|
+
case 2:
|
|
7373
|
+
_a.trys.push([2, , 3, 5]);
|
|
7374
|
+
if (this.isConnected() || this.isConnecting()) {
|
|
7375
|
+
return [2 /*return*/];
|
|
7376
|
+
}
|
|
7377
|
+
this.lostConnection = false;
|
|
7378
|
+
stompConfig = {
|
|
7379
|
+
webSocketFactory: function () {
|
|
7380
|
+
return new SockJS(_this.getSubscriptionUrl(), null, {
|
|
7381
|
+
timeout: CONNECTION_TIMEOUT_MILLISECONDS
|
|
7382
|
+
});
|
|
7383
|
+
},
|
|
7384
|
+
connectionTimeout: CONNECTION_TIMEOUT_MILLISECONDS,
|
|
7385
|
+
reconnectDelay: RECONNECT_INTERVAL_MILLISECONDS,
|
|
7386
|
+
debug: this.debug.bind(this),
|
|
7387
|
+
onConnect: this.handleOnConnected.bind(this),
|
|
7388
|
+
onDisconnect: this.handleOnDisconnect.bind(this),
|
|
7389
|
+
onWebSocketClose: this.handleOnWebSocketClose.bind(this),
|
|
7390
|
+
onStompError: this.handleOnStompError.bind(this),
|
|
7391
|
+
onWebSocketError: this.handleOnWebSocketError.bind(this)
|
|
7392
|
+
};
|
|
7393
|
+
this.debug('Connecting the Webscoket');
|
|
7394
|
+
this.stompClient = new Client(stompConfig);
|
|
7395
|
+
this.stompClient.activate();
|
|
7396
|
+
return [3 /*break*/, 5];
|
|
7397
|
+
case 3: return [4 /*yield*/, this.connectionLock.release()];
|
|
7398
|
+
case 4:
|
|
7399
|
+
_a.sent();
|
|
7400
|
+
return [7 /*endfinally*/];
|
|
7401
|
+
case 5: return [2 /*return*/];
|
|
7402
|
+
}
|
|
7403
|
+
});
|
|
7404
|
+
});
|
|
7243
7405
|
};
|
|
7244
7406
|
/**
|
|
7245
|
-
*
|
|
7246
|
-
* @return Um `Observable<void>` que emite uma notificação quando a conexão é reconectada.
|
|
7407
|
+
* Manually disconnect the websocket. The reconnect loop will be stopped.
|
|
7247
7408
|
*/
|
|
7248
|
-
WebsocketService.prototype.
|
|
7249
|
-
return this
|
|
7409
|
+
WebsocketService.prototype.disconnect = function () {
|
|
7410
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
7411
|
+
var _a, _b, primitiveManager;
|
|
7412
|
+
var e_1, _c;
|
|
7413
|
+
return __generator(this, function (_d) {
|
|
7414
|
+
switch (_d.label) {
|
|
7415
|
+
case 0:
|
|
7416
|
+
if (!this.isConnected()) {
|
|
7417
|
+
return [2 /*return*/];
|
|
7418
|
+
}
|
|
7419
|
+
return [4 /*yield*/, this.connectionLock.acquire()];
|
|
7420
|
+
case 1:
|
|
7421
|
+
_d.sent();
|
|
7422
|
+
_d.label = 2;
|
|
7423
|
+
case 2:
|
|
7424
|
+
_d.trys.push([2, , 5, 7]);
|
|
7425
|
+
try {
|
|
7426
|
+
for (_a = __values(this.primitiveManagers.values()), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
7427
|
+
primitiveManager = _b.value;
|
|
7428
|
+
primitiveManager.unsubscribe();
|
|
7429
|
+
}
|
|
7430
|
+
}
|
|
7431
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
7432
|
+
finally {
|
|
7433
|
+
try {
|
|
7434
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
7435
|
+
}
|
|
7436
|
+
finally { if (e_1) throw e_1.error; }
|
|
7437
|
+
}
|
|
7438
|
+
this.primitiveManagers.clear();
|
|
7439
|
+
this.connected$.next(false);
|
|
7440
|
+
if (!this.stompClient) return [3 /*break*/, 4];
|
|
7441
|
+
this.stompClient.forceDisconnect();
|
|
7442
|
+
return [4 /*yield*/, this.stompClient.deactivate()];
|
|
7443
|
+
case 3:
|
|
7444
|
+
_d.sent();
|
|
7445
|
+
_d.label = 4;
|
|
7446
|
+
case 4: return [3 /*break*/, 7];
|
|
7447
|
+
case 5: return [4 /*yield*/, this.connectionLock.release()];
|
|
7448
|
+
case 6:
|
|
7449
|
+
_d.sent();
|
|
7450
|
+
return [7 /*endfinally*/];
|
|
7451
|
+
case 7: return [2 /*return*/];
|
|
7452
|
+
}
|
|
7453
|
+
});
|
|
7454
|
+
});
|
|
7250
7455
|
};
|
|
7251
7456
|
/**
|
|
7252
|
-
*
|
|
7253
|
-
* @return
|
|
7457
|
+
* Check if the websocket is connected
|
|
7458
|
+
* @return `boolean` representing if the websocket is connected
|
|
7254
7459
|
*/
|
|
7255
|
-
WebsocketService.prototype.
|
|
7256
|
-
|
|
7257
|
-
|
|
7258
|
-
|
|
7259
|
-
return this.
|
|
7260
|
-
|
|
7261
|
-
|
|
7262
|
-
|
|
7263
|
-
|
|
7264
|
-
|
|
7265
|
-
|
|
7266
|
-
|
|
7267
|
-
|
|
7268
|
-
}
|
|
7460
|
+
WebsocketService.prototype.isConnected = function () {
|
|
7461
|
+
if (!this.stompClient) {
|
|
7462
|
+
return false;
|
|
7463
|
+
}
|
|
7464
|
+
return this.stompClient.connected;
|
|
7465
|
+
};
|
|
7466
|
+
/**
|
|
7467
|
+
* Check if the websocket is tring to connect
|
|
7468
|
+
* @return `boolean` representing if the websocket status
|
|
7469
|
+
*/
|
|
7470
|
+
WebsocketService.prototype.isConnecting = function () {
|
|
7471
|
+
if (!this.stompClient) {
|
|
7472
|
+
return false;
|
|
7473
|
+
}
|
|
7474
|
+
return !this.stompClient.connected && this.stompClient.active;
|
|
7269
7475
|
};
|
|
7270
7476
|
/**
|
|
7271
|
-
*
|
|
7272
|
-
*
|
|
7477
|
+
* Event responsable to emit an event when the connection is established.
|
|
7478
|
+
* Do not forget to unsubscribe the observable when you don't need it anymore.
|
|
7479
|
+
* @return `Observable<boolean>`
|
|
7480
|
+
*/
|
|
7481
|
+
WebsocketService.prototype.onConnect = function () {
|
|
7482
|
+
return this.connected$.asObservable()
|
|
7483
|
+
.pipe(filter(function (p) { return p === true; }));
|
|
7484
|
+
};
|
|
7485
|
+
/**
|
|
7486
|
+
* Event responsable to emit an event when the connection is closed.
|
|
7487
|
+
* Do not forget to unsubscribe the observable when you don't need it anymore.
|
|
7488
|
+
* @return `Observable<void>`
|
|
7489
|
+
*/
|
|
7490
|
+
WebsocketService.prototype.onDisconnect = function () {
|
|
7491
|
+
return this.disconnected$.asObservable();
|
|
7492
|
+
};
|
|
7493
|
+
/**
|
|
7494
|
+
* Event responsable to emit an event when the connection is reestablished.
|
|
7495
|
+
* Do not forget to unsubscribe the observable when you don't need it anymore.
|
|
7496
|
+
* @return `Observable<void>`
|
|
7497
|
+
*/
|
|
7498
|
+
WebsocketService.prototype.onReconnect = function () {
|
|
7499
|
+
return this.reconnected$.asObservable();
|
|
7500
|
+
};
|
|
7501
|
+
/**
|
|
7502
|
+
* Event responsable to emit an event when an error ocurred.
|
|
7503
|
+
* Do not forget to unsubscribe the observable when you don't need it anymore.
|
|
7504
|
+
* @return `Observable<FrameImpl>`
|
|
7273
7505
|
*/
|
|
7274
7506
|
WebsocketService.prototype.onError = function () {
|
|
7275
7507
|
return this.error$.asObservable();
|
|
7276
7508
|
};
|
|
7277
7509
|
/**
|
|
7278
|
-
*
|
|
7279
|
-
*
|
|
7280
|
-
* @
|
|
7281
|
-
* @param {
|
|
7282
|
-
* @
|
|
7283
|
-
* @return Um Observable<T> que emite notificações toda vez que o respectivo evento é publicado.
|
|
7510
|
+
* Event responsible to emit an event when a primitive is called.
|
|
7511
|
+
* Do not forget to unsubscribe the observable when you don't need it anymore.
|
|
7512
|
+
* @typeParam `<T>` Object type that will be used in the observable for the `data` property.
|
|
7513
|
+
* @param {OnEventOptions} options Configurations for the event.
|
|
7514
|
+
* @return `Observable<PrimitiveEvent<T>>` Observable that emits an event when the service calls the primitive.
|
|
7284
7515
|
*/
|
|
7285
7516
|
WebsocketService.prototype.onEvent = function (options) {
|
|
7286
7517
|
var _this = this;
|
|
7287
|
-
this.connect();
|
|
7288
7518
|
var domain = options.domain, service = options.service, primitive = options.primitive;
|
|
7289
|
-
var key = this.
|
|
7519
|
+
var key = this.buildPrimitiveManagerKey(domain, service, primitive);
|
|
7290
7520
|
if (this.primitiveManagers.has(key)) {
|
|
7291
|
-
return this.primitiveManagers.get(key).
|
|
7521
|
+
return this.primitiveManagers.get(key).getEventObservable();
|
|
7292
7522
|
}
|
|
7293
|
-
var primitiveManager =
|
|
7294
|
-
domain: domain,
|
|
7295
|
-
service: service,
|
|
7296
|
-
primitive: primitive,
|
|
7297
|
-
stompSubscriptions: [],
|
|
7298
|
-
event$: new Subject(),
|
|
7299
|
-
subscribed$: new BehaviorSubject(false)
|
|
7300
|
-
};
|
|
7523
|
+
var primitiveManager = new PrimitiveManager(domain, service, primitive);
|
|
7301
7524
|
this.primitiveManagers.set(key, primitiveManager);
|
|
7302
|
-
this.
|
|
7303
|
-
.
|
|
7304
|
-
|
|
7305
|
-
|
|
7525
|
+
this.connect().then(function () {
|
|
7526
|
+
_this.onConnect()
|
|
7527
|
+
.pipe(take(1))
|
|
7528
|
+
.subscribe(function () {
|
|
7529
|
+
_this.createStompSubscriptions(primitiveManager);
|
|
7530
|
+
});
|
|
7306
7531
|
});
|
|
7307
|
-
return primitiveManager
|
|
7308
|
-
.
|
|
7309
|
-
.pipe(finalize(function () { return _this.
|
|
7310
|
-
};
|
|
7311
|
-
/** @private */
|
|
7312
|
-
WebsocketService.prototype.createStompSubscriptions = function (primitiveManager) {
|
|
7313
|
-
var withTokenUrl = this.getSubscriptionUrlWithToken(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
7314
|
-
var stompSubscriptionWithToken = this.createStompSubscription(withTokenUrl, primitiveManager);
|
|
7315
|
-
var withoutTokenUrl = this.getSubscriptionUrlWithoutToken(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
7316
|
-
var stompSubscriptionWithoutToken = this.createStompSubscription(withoutTokenUrl, primitiveManager);
|
|
7317
|
-
primitiveManager.stompSubscriptions = [
|
|
7318
|
-
stompSubscriptionWithToken,
|
|
7319
|
-
stompSubscriptionWithoutToken
|
|
7320
|
-
];
|
|
7321
|
-
primitiveManager.subscribed$.next(true);
|
|
7322
|
-
this.subscribed$.next(primitiveManager);
|
|
7532
|
+
return primitiveManager
|
|
7533
|
+
.getEventObservable()
|
|
7534
|
+
.pipe(finalize(function () { return _this.unsubscribePrimitiveOnFinalize(primitiveManager); }));
|
|
7323
7535
|
};
|
|
7324
|
-
/**
|
|
7325
|
-
|
|
7536
|
+
/**
|
|
7537
|
+
* Event responsible to emit an event when a subscription is created for the primitive.
|
|
7538
|
+
* Do not forget to unsubscribe the observable when you don't need it anymore.
|
|
7539
|
+
* @param {OnEventOptions} options Configurations for the event.
|
|
7540
|
+
* Observable responsável por emitir uma notificação após o subscribe do evento pela primeira vez.
|
|
7541
|
+
* @return `Observable<boolean>` Observable that emits an event when the service calls the primitive.
|
|
7542
|
+
*/
|
|
7543
|
+
WebsocketService.prototype.onSubscribe = function (options) {
|
|
7326
7544
|
var _this = this;
|
|
7327
|
-
|
|
7328
|
-
|
|
7329
|
-
this.
|
|
7330
|
-
|
|
7331
|
-
|
|
7332
|
-
|
|
7333
|
-
|
|
7334
|
-
|
|
7335
|
-
_this.reconnectPrimitives();
|
|
7336
|
-
_this.connected$.next(true);
|
|
7337
|
-
_this.reconnect$.next();
|
|
7545
|
+
var domain = options.domain, service = options.service, primitive = options.primitive;
|
|
7546
|
+
var key = this.buildPrimitiveManagerKey(domain, service, primitive);
|
|
7547
|
+
return this.onConnect().pipe(take(1), switchMap(function () {
|
|
7548
|
+
if (_this.primitiveManagers.has(key)) {
|
|
7549
|
+
return _this.primitiveManagers
|
|
7550
|
+
.get(key)
|
|
7551
|
+
.getSubscriptionObservable()
|
|
7552
|
+
.pipe(take(1));
|
|
7338
7553
|
}
|
|
7339
|
-
|
|
7340
|
-
_this.
|
|
7341
|
-
|
|
7342
|
-
|
|
7343
|
-
}, function (error) {
|
|
7344
|
-
_this.isConnected = false;
|
|
7345
|
-
_this.connected$.next(false);
|
|
7346
|
-
_this.error$.next(error);
|
|
7347
|
-
race(_this.disconnect$.pipe(take(1), map(function () { return ({ wasDisconnected: true }); })), timer(WebsocketService_1.RECONNECT_INTERVAL).pipe(take(1), switchMap(function () {
|
|
7348
|
-
return iif(function () { return document.hidden; }, fromEvent(document, 'visibilitychange').pipe(first()), of(void 0));
|
|
7349
|
-
}), map(function () { return ({ wasDisconnected: false }); })))
|
|
7350
|
-
.pipe(take(1))
|
|
7351
|
-
.subscribe({
|
|
7352
|
-
next: function (_a) {
|
|
7353
|
-
var wasDisconnected = _a.wasDisconnected;
|
|
7354
|
-
if (!wasDisconnected &&
|
|
7355
|
-
!(_this.isConnected || _this.isConnecting)) {
|
|
7356
|
-
_this.connect();
|
|
7357
|
-
}
|
|
7358
|
-
}
|
|
7359
|
-
});
|
|
7360
|
-
});
|
|
7554
|
+
return _this.subscribed$.asObservable().pipe(filter(function (primitiveManager) {
|
|
7555
|
+
return _this.buildPrimitiveManagerKey(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive) === key;
|
|
7556
|
+
}), map(function () { return true; }), take(1));
|
|
7557
|
+
}));
|
|
7361
7558
|
};
|
|
7362
|
-
WebsocketService.prototype.
|
|
7363
|
-
var
|
|
7364
|
-
|
|
7559
|
+
WebsocketService.prototype.debug = function (message) {
|
|
7560
|
+
var optionalParams = [];
|
|
7561
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
7562
|
+
optionalParams[_i - 1] = arguments[_i];
|
|
7563
|
+
}
|
|
7564
|
+
if (!this.debugEnable) {
|
|
7365
7565
|
return;
|
|
7366
7566
|
}
|
|
7367
|
-
|
|
7368
|
-
|
|
7369
|
-
|
|
7370
|
-
|
|
7371
|
-
|
|
7372
|
-
|
|
7373
|
-
|
|
7374
|
-
|
|
7375
|
-
|
|
7376
|
-
|
|
7377
|
-
|
|
7378
|
-
try {
|
|
7379
|
-
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
7380
|
-
}
|
|
7381
|
-
finally { if (e_2) throw e_2.error; }
|
|
7382
|
-
}
|
|
7383
|
-
}
|
|
7567
|
+
console.log.apply(console, __spread(['WS debug: ' + message], optionalParams));
|
|
7568
|
+
};
|
|
7569
|
+
WebsocketService.prototype.info = function (message) {
|
|
7570
|
+
console.info('WS info: ' + message);
|
|
7571
|
+
};
|
|
7572
|
+
WebsocketService.prototype.handleOnConnected = function () {
|
|
7573
|
+
this.info('Webscoket connected');
|
|
7574
|
+
this.connected$.next(true);
|
|
7575
|
+
if (this.lostConnection) {
|
|
7576
|
+
this.info('Webscoket reconnected, recriating subscriptions');
|
|
7577
|
+
this.handleReconnection();
|
|
7384
7578
|
}
|
|
7385
|
-
|
|
7386
|
-
|
|
7387
|
-
|
|
7388
|
-
|
|
7389
|
-
|
|
7390
|
-
|
|
7579
|
+
};
|
|
7580
|
+
WebsocketService.prototype.handleOnDisconnect = function () {
|
|
7581
|
+
this.info('Webscoket disconnected');
|
|
7582
|
+
this.connected$.next(false);
|
|
7583
|
+
this.disconnected$.next();
|
|
7584
|
+
};
|
|
7585
|
+
WebsocketService.prototype.handleOnWebSocketClose = function (data) {
|
|
7586
|
+
if (data.wasClean) {
|
|
7587
|
+
return;
|
|
7391
7588
|
}
|
|
7392
|
-
|
|
7393
|
-
|
|
7394
|
-
|
|
7395
|
-
|
|
7396
|
-
|
|
7589
|
+
this.lostConnection = true;
|
|
7590
|
+
};
|
|
7591
|
+
WebsocketService.prototype.handleOnStompError = function (data) {
|
|
7592
|
+
this.handleError('StompError', data);
|
|
7593
|
+
if (this.isAuthenticationError(data)) {
|
|
7594
|
+
this.info('Authentication error, recriating subscriptions');
|
|
7595
|
+
this.handleReconnection();
|
|
7397
7596
|
}
|
|
7398
|
-
|
|
7399
|
-
|
|
7400
|
-
|
|
7401
|
-
|
|
7402
|
-
|
|
7403
|
-
|
|
7597
|
+
};
|
|
7598
|
+
WebsocketService.prototype.isAuthenticationError = function (data) {
|
|
7599
|
+
var _a;
|
|
7600
|
+
var errorMessage = (_a = data === null || data === void 0 ? void 0 : data.headers) === null || _a === void 0 ? void 0 : _a.message;
|
|
7601
|
+
if (!errorMessage) {
|
|
7602
|
+
return false;
|
|
7404
7603
|
}
|
|
7405
|
-
|
|
7406
|
-
this._stompClient.disconnect();
|
|
7407
|
-
this._stompClient.deactivate();
|
|
7408
|
-
this.isConnected = false;
|
|
7409
|
-
this.isConnecting = false;
|
|
7410
|
-
this.wasConnected = false;
|
|
7411
|
-
this.connected$.next(false);
|
|
7412
|
-
this.disconnect$.next();
|
|
7604
|
+
return errorMessage.toLowerCase().indexOf('forbiddenexception') !== -1;
|
|
7413
7605
|
};
|
|
7414
|
-
|
|
7415
|
-
|
|
7416
|
-
var tenant = WebsocketService_1.TOKEN
|
|
7417
|
-
? WebsocketService_1.TOKEN.username.split('@')[1]
|
|
7418
|
-
: null;
|
|
7419
|
-
var token = WebsocketService_1.TOKEN
|
|
7420
|
-
? WebsocketService_1.TOKEN.access_token
|
|
7421
|
-
: null;
|
|
7422
|
-
return "/topic/" + tenant + "/" + token + "/" + domain + "/" + service + "/" + primitive;
|
|
7606
|
+
WebsocketService.prototype.handleOnWebSocketError = function (data) {
|
|
7607
|
+
this.handleError('WebSocketError', data);
|
|
7423
7608
|
};
|
|
7424
|
-
|
|
7425
|
-
|
|
7426
|
-
|
|
7427
|
-
? WebsocketService_1.TOKEN.username.split('@')[1]
|
|
7428
|
-
: null;
|
|
7429
|
-
return "/topic/" + tenant + "/" + domain + "/" + service + "/" + primitive;
|
|
7609
|
+
WebsocketService.prototype.handleError = function (origin, data) {
|
|
7610
|
+
console.error(origin, data);
|
|
7611
|
+
this.error$.next(data);
|
|
7430
7612
|
};
|
|
7431
|
-
|
|
7432
|
-
|
|
7433
|
-
|
|
7434
|
-
|
|
7435
|
-
primitiveManager.event$.next(event);
|
|
7436
|
-
});
|
|
7613
|
+
WebsocketService.prototype.handleReconnection = function () {
|
|
7614
|
+
this.lostConnection = false;
|
|
7615
|
+
this.reconnectPrimitives();
|
|
7616
|
+
this.reconnected$.next();
|
|
7437
7617
|
};
|
|
7438
|
-
/** @private */
|
|
7439
|
-
WebsocketService.prototype.createStompClient = function () {
|
|
7440
|
-
var ws = new SockJS(WebsocketService_1.WEBSOCKET_URL + "subscription", null, { timeout: WebsocketService_1.CONNECTION_TIMEOUT });
|
|
7441
|
-
this._stompClient = Stomp.over(ws);
|
|
7442
|
-
this._stompClient.debug = function () { return null; };
|
|
7443
|
-
};
|
|
7444
|
-
/** @private */
|
|
7445
7618
|
WebsocketService.prototype.reconnectPrimitives = function () {
|
|
7446
|
-
var
|
|
7619
|
+
var e_2, _a;
|
|
7447
7620
|
try {
|
|
7448
7621
|
for (var _b = __values(this.primitiveManagers.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
7449
7622
|
var primitiveManager = _c.value;
|
|
7450
7623
|
this.createStompSubscriptions(primitiveManager);
|
|
7451
7624
|
}
|
|
7452
7625
|
}
|
|
7453
|
-
catch (
|
|
7626
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
7454
7627
|
finally {
|
|
7455
7628
|
try {
|
|
7456
7629
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
7457
7630
|
}
|
|
7458
|
-
finally { if (
|
|
7631
|
+
finally { if (e_2) throw e_2.error; }
|
|
7459
7632
|
}
|
|
7460
7633
|
};
|
|
7461
|
-
|
|
7634
|
+
WebsocketService.prototype.buildSubscriptionUrlWithToken = function (domain, service, primitive) {
|
|
7635
|
+
var authToken = this.userInformationService.getAuthToken();
|
|
7636
|
+
var tenant = this.userInformationService.getTenantDomain();
|
|
7637
|
+
return "/topic/" + tenant + "/" + authToken + "/" + domain + "/" + service + "/" + primitive;
|
|
7638
|
+
};
|
|
7639
|
+
WebsocketService.prototype.getSubscriptionUrlWithoutToken = function (domain, service, primitive) {
|
|
7640
|
+
var tenant = this.userInformationService.getTenantDomain();
|
|
7641
|
+
return "/topic/" + tenant + "/" + domain + "/" + service + "/" + primitive;
|
|
7642
|
+
};
|
|
7643
|
+
WebsocketService.prototype.buildPrimitiveManagerKey = function (domain, service, primitive) {
|
|
7644
|
+
return domain + "/" + service + "/" + primitive;
|
|
7645
|
+
};
|
|
7646
|
+
WebsocketService.prototype.unsubscribePrimitiveOnFinalize = function (primitiveManager) {
|
|
7647
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
7648
|
+
var key;
|
|
7649
|
+
return __generator(this, function (_a) {
|
|
7650
|
+
switch (_a.label) {
|
|
7651
|
+
case 0:
|
|
7652
|
+
if (primitiveManager.hasObservers()) {
|
|
7653
|
+
return [2 /*return*/];
|
|
7654
|
+
}
|
|
7655
|
+
primitiveManager.unsubscribe();
|
|
7656
|
+
key = this.buildPrimitiveManagerKey(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
7657
|
+
this.primitiveManagers.delete(key);
|
|
7658
|
+
return [4 /*yield*/, this.disconnectIfNoMoreObservables()];
|
|
7659
|
+
case 1:
|
|
7660
|
+
_a.sent();
|
|
7661
|
+
return [2 /*return*/];
|
|
7662
|
+
}
|
|
7663
|
+
});
|
|
7664
|
+
});
|
|
7665
|
+
};
|
|
7666
|
+
WebsocketService.prototype.disconnectIfNoMoreObservables = function () {
|
|
7667
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
7668
|
+
return __generator(this, function (_a) {
|
|
7669
|
+
switch (_a.label) {
|
|
7670
|
+
case 0:
|
|
7671
|
+
if (!(this.getObserversCount() === 0)) return [3 /*break*/, 2];
|
|
7672
|
+
this.debug('Manually disconnecting because there are no more observers');
|
|
7673
|
+
return [4 /*yield*/, this.disconnect()];
|
|
7674
|
+
case 1:
|
|
7675
|
+
_a.sent();
|
|
7676
|
+
_a.label = 2;
|
|
7677
|
+
case 2: return [2 /*return*/];
|
|
7678
|
+
}
|
|
7679
|
+
});
|
|
7680
|
+
});
|
|
7681
|
+
};
|
|
7462
7682
|
WebsocketService.prototype.getObserversCount = function () {
|
|
7463
|
-
var e_5, _a;
|
|
7464
7683
|
var observersCount = 0;
|
|
7465
|
-
|
|
7466
|
-
|
|
7467
|
-
|
|
7468
|
-
observersCount += primitiveManager.event$.observers.length;
|
|
7469
|
-
}
|
|
7470
|
-
}
|
|
7471
|
-
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
7472
|
-
finally {
|
|
7473
|
-
try {
|
|
7474
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
7475
|
-
}
|
|
7476
|
-
finally { if (e_5) throw e_5.error; }
|
|
7477
|
-
}
|
|
7684
|
+
this.primitiveManagers.forEach(function (primitiveManager) {
|
|
7685
|
+
observersCount += primitiveManager.getObserversCount();
|
|
7686
|
+
});
|
|
7478
7687
|
return observersCount;
|
|
7479
7688
|
};
|
|
7480
|
-
|
|
7481
|
-
|
|
7482
|
-
|
|
7483
|
-
|
|
7484
|
-
|
|
7485
|
-
if (hasObservers)
|
|
7486
|
-
return;
|
|
7487
|
-
primitiveManager.event$.complete();
|
|
7488
|
-
try {
|
|
7489
|
-
for (var _b = __values(primitiveManager.stompSubscriptions), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
7490
|
-
var stompSubscription = _c.value;
|
|
7491
|
-
stompSubscription.unsubscribe();
|
|
7492
|
-
}
|
|
7493
|
-
}
|
|
7494
|
-
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
7495
|
-
finally {
|
|
7496
|
-
try {
|
|
7497
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
7498
|
-
}
|
|
7499
|
-
finally { if (e_6) throw e_6.error; }
|
|
7500
|
-
}
|
|
7501
|
-
primitiveManager.subscribed$.complete();
|
|
7502
|
-
var key = this.getPrimitiveManagerKey(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
7503
|
-
this.primitiveManagers.delete(key);
|
|
7504
|
-
this.disconnect();
|
|
7689
|
+
WebsocketService.prototype.createStompSubscription = function (destination, primitiveManager) {
|
|
7690
|
+
return this.stompClient.subscribe(destination, function (message) {
|
|
7691
|
+
var event = JSON.parse(message.body || '{}');
|
|
7692
|
+
primitiveManager.fireEvent(event);
|
|
7693
|
+
});
|
|
7505
7694
|
};
|
|
7506
|
-
|
|
7507
|
-
|
|
7508
|
-
|
|
7695
|
+
WebsocketService.prototype.createStompSubscriptions = function (primitiveManager) {
|
|
7696
|
+
var subscriptionUrlWithToken = this.buildSubscriptionUrlWithToken(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
7697
|
+
var subscriptionUrlWithoutToken = this.getSubscriptionUrlWithoutToken(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
7698
|
+
var stompSubscriptionWithToken = this.createStompSubscription(subscriptionUrlWithToken, primitiveManager);
|
|
7699
|
+
var stompSubscriptionWithoutToken = this.createStompSubscription(subscriptionUrlWithoutToken, primitiveManager);
|
|
7700
|
+
primitiveManager.subscribe(stompSubscriptionWithToken, stompSubscriptionWithoutToken);
|
|
7701
|
+
this.subscribed$.next(primitiveManager);
|
|
7509
7702
|
};
|
|
7510
|
-
|
|
7511
|
-
|
|
7512
|
-
|
|
7513
|
-
|
|
7514
|
-
|
|
7515
|
-
|
|
7516
|
-
WebsocketService
|
|
7517
|
-
|
|
7518
|
-
WebsocketService.TOKEN = JSON.parse(get(WebsocketService_1.TOKEN_COOKIE) || '{}');
|
|
7519
|
-
/** @private */
|
|
7520
|
-
WebsocketService.WEBSOCKET_URL = get(WebsocketService_1.BASE_URL_COOKIE) + '/websocket/';
|
|
7521
|
-
WebsocketService.ɵprov = ɵɵdefineInjectable({ factory: function WebsocketService_Factory() { return new WebsocketService(); }, token: WebsocketService, providedIn: "root" });
|
|
7522
|
-
WebsocketService = WebsocketService_1 = __decorate([
|
|
7703
|
+
WebsocketService.prototype.getSubscriptionUrl = function () {
|
|
7704
|
+
return this.userInformationService.getWebSocketUrl() + "/subscription";
|
|
7705
|
+
};
|
|
7706
|
+
WebsocketService.ctorParameters = function () { return [
|
|
7707
|
+
{ type: UserInformationService }
|
|
7708
|
+
]; };
|
|
7709
|
+
WebsocketService.ɵprov = ɵɵdefineInjectable({ factory: function WebsocketService_Factory() { return new WebsocketService(ɵɵinject(UserInformationService)); }, token: WebsocketService, providedIn: "root" });
|
|
7710
|
+
WebsocketService = __decorate([
|
|
7523
7711
|
Injectable({
|
|
7524
7712
|
providedIn: 'root'
|
|
7525
7713
|
})
|
|
@@ -7595,6 +7783,73 @@ var VerifyModulePermission = /** @class */ (function () {
|
|
|
7595
7783
|
return VerifyModulePermission;
|
|
7596
7784
|
}());
|
|
7597
7785
|
|
|
7786
|
+
var VerifyModulePermissionsService = /** @class */ (function () {
|
|
7787
|
+
function VerifyModulePermissionsService(http) {
|
|
7788
|
+
this.http = http;
|
|
7789
|
+
}
|
|
7790
|
+
VerifyModulePermissionsService_1 = VerifyModulePermissionsService;
|
|
7791
|
+
VerifyModulePermissionsService.prototype.consultaModulos = function (request) {
|
|
7792
|
+
return this.http.post(VerifyModulePermissionsService_1.QUERY_MODULES_URL, request);
|
|
7793
|
+
};
|
|
7794
|
+
var VerifyModulePermissionsService_1;
|
|
7795
|
+
VerifyModulePermissionsService.QUERY_MODULES_URL = "erpx_fnd/empresa/queries/consultaModulos";
|
|
7796
|
+
VerifyModulePermissionsService.ctorParameters = function () { return [
|
|
7797
|
+
{ type: HttpClient }
|
|
7798
|
+
]; };
|
|
7799
|
+
VerifyModulePermissionsService.ɵprov = ɵɵdefineInjectable({ factory: function VerifyModulePermissionsService_Factory() { return new VerifyModulePermissionsService(ɵɵinject(HttpClient)); }, token: VerifyModulePermissionsService, providedIn: "any" });
|
|
7800
|
+
VerifyModulePermissionsService = VerifyModulePermissionsService_1 = __decorate([
|
|
7801
|
+
Injectable({
|
|
7802
|
+
providedIn: "any"
|
|
7803
|
+
})
|
|
7804
|
+
], VerifyModulePermissionsService);
|
|
7805
|
+
return VerifyModulePermissionsService;
|
|
7806
|
+
}());
|
|
7807
|
+
|
|
7808
|
+
var VerifyModulePermissions = /** @class */ (function () {
|
|
7809
|
+
function VerifyModulePermissions(verifyModulePermissionsService) {
|
|
7810
|
+
this.verifyModulePermissionsService = verifyModulePermissionsService;
|
|
7811
|
+
}
|
|
7812
|
+
VerifyModulePermissions_1 = VerifyModulePermissions;
|
|
7813
|
+
/**
|
|
7814
|
+
* Method to verify if user has permission on a specific module
|
|
7815
|
+
* @param modules Modules to verify the permission
|
|
7816
|
+
* @param requestPermission Indicative if must be call the primitive
|
|
7817
|
+
* @returns An boolean Observable
|
|
7818
|
+
*/
|
|
7819
|
+
VerifyModulePermissions.prototype.hasPermissions = function (modules, requestPermission) {
|
|
7820
|
+
var moduleSubject = VerifyModulePermissions_1.subjectsPerModuleMap.get(modules);
|
|
7821
|
+
if (!moduleSubject || requestPermission) {
|
|
7822
|
+
var newModuleSubject_1 = new ReplaySubject(1);
|
|
7823
|
+
VerifyModulePermissions_1.subjectsPerModuleMap.set(modules, newModuleSubject_1);
|
|
7824
|
+
this.verifyModulePermissionsService
|
|
7825
|
+
.consultaModulos({ modulo: modules, somenteAtivo: true })
|
|
7826
|
+
.pipe(take(1))
|
|
7827
|
+
.subscribe(function (response) {
|
|
7828
|
+
var hasPermissions = (response === null || response === void 0 ? void 0 : response.modulos) || [];
|
|
7829
|
+
newModuleSubject_1.next(hasPermissions);
|
|
7830
|
+
}, function (err) {
|
|
7831
|
+
VerifyModulePermissions_1.subjectsPerModuleMap.delete(modules);
|
|
7832
|
+
newModuleSubject_1.error(err);
|
|
7833
|
+
newModuleSubject_1.unsubscribe();
|
|
7834
|
+
});
|
|
7835
|
+
return newModuleSubject_1.asObservable();
|
|
7836
|
+
}
|
|
7837
|
+
return moduleSubject.asObservable();
|
|
7838
|
+
};
|
|
7839
|
+
var VerifyModulePermissions_1;
|
|
7840
|
+
VerifyModulePermissions.ctorParameters = function () { return [
|
|
7841
|
+
{ type: VerifyModulePermissionsService }
|
|
7842
|
+
]; };
|
|
7843
|
+
VerifyModulePermissions.subjectsPerModuleMap = new Map();
|
|
7844
|
+
VerifyModulePermissions.ɵprov = ɵɵdefineInjectable({ factory: function VerifyModulePermissions_Factory() { return new VerifyModulePermissions(ɵɵinject(VerifyModulePermissionsService)); }, token: VerifyModulePermissions, providedIn: "root" });
|
|
7845
|
+
VerifyModulePermissions = VerifyModulePermissions_1 = __decorate([
|
|
7846
|
+
Injectable({
|
|
7847
|
+
providedIn: "root"
|
|
7848
|
+
})
|
|
7849
|
+
], VerifyModulePermissions);
|
|
7850
|
+
return VerifyModulePermissions;
|
|
7851
|
+
}());
|
|
7852
|
+
|
|
7598
7853
|
var ModulesEnum;
|
|
7599
7854
|
(function (ModulesEnum) {
|
|
7600
7855
|
ModulesEnum["CONTROLADORIA"] = "CONTROLADORIA";
|
|
@@ -7613,5 +7868,5 @@ var ModulesEnum;
|
|
|
7613
7868
|
* Generated bundle index. Do not edit.
|
|
7614
7869
|
*/
|
|
7615
7870
|
|
|
7616
|
-
export { AgreementLookup, BankLookup, BeneficioFiscalLookup, BreadcrumbComponent, BreadcrumbModule, Breakpoints, ContaInternaFilialLookup, CountryLookup, CplTriNotaSaidaE001EndLookup, CplTriNotaSaidaE001PesLookup, CplTriNotaSaidaE001TnsLookup, CplTriNotaSaidaE007UfsLookup, CplTriNotaSaidaE008RaiLookup, CplTriNotaSaidaE015MedLookup, CplTriNotaSaidaE020SnfLookup, CplTriNotaSaidaE024MsgLookup, CplTriNotaSaidaE028CpgLookup, CplTriNotaSaidaE032EdcLookup, CplTriNotaSaidaE051DisLookup, CplTriNotaSaidaE066FpgLookup, CplTriNotaSaidaE070EmpLookup, CplTriNotaSaidaE070FilLookup, CplTriNotaSaidaE075DerLookup, CplTriNotaSaidaE080SerLookup, CplTriNotaSaidaNaturezaReceitaPisCofinsLookup, CplTriNotaSaidaNcmLookup, CplTriNotaSaidaNfEntradaLookup, CplTriNotaSaidaNfSaidaLookup, CurrencyLookup, DocumentoLookup, E001EndLookup, E001PesLookup, E001TnsLookup, E001TnsSupEstLookup, E002TptLookup, E007UfsLookup, E008CepLookup, E008RaiLookup, E012FamLookup, E015MedLookup, E020SnfLookup, E021MotLookup, E023CrpLookup, E024MsgLookup, E027EqiLookup, E027StrLookup, E028CpgLookup, E030AgeLookup, E030BanLookup, E031MoeLookup, E032EdcLookup, E035OcrLookup, E036InsLookup, E039PorLookup, E043MpcLookup, E043PcmLookup, E044CcuFinRatDepLookup, E044CcuLookup, E045PlaLookup, E046HpdLookup, E047NtgLookup, E048FctLookup, E048SfcLookup, E051DisLookup, E066FpgLookup, E067FinLookup, E069GreLookup, E070EmpLookup, E070EntLookup, E070FilLookup, E073PesLookup, E073VeiLookup, E075DerLookup, E080SerLookup, E081TabLookup, E082TprLookup, E085PesLookup, E089DocLookup, E090HrpComGerLookup, E090PesLookup, E091PlfFinRatLookup, E095PesLookup, E099UsuComGerLookup, E099UsuSupCprLookup, E140InsLookup, E140NfsLookup, E200LotLookup, E200SerLookup, E205DepLookup, E210DxpE075DerLookup, E210DxpLookup, E301TcrLookup, E403FprLookup, E420IcpLookup, E420IpcLookup, E420OcpLookup, E501TcpLookup, E600CcoLookup, E640LotLookup, EntityPersonProductLookup, EnumLogicalOperator, EquipmentLookup, ErpLookups, ErpLookupsModule, ErpPolling, ExportUtils, FiltersStorageService, FormUtilsService, HTTP_STATUS_CODE, LigacaoItemFornecedorLookup, LookupValidationUtils, ModulesEnum, NcmLookup, NotaFiscalEntradaLookup, NpsService, ParametersLookup, ProdutoServicoLookup, QuantidadeDisponivelDemandaLookup, RequisicaoLookup, SegmentoLookup, TypeTaxesLookup, UnidadeMedidaLookup, UtilsModule, VerifyModulePermission, WebsocketService, naturezaReceitaPisCofins, ɵ0, ErpLookupsService as ɵa, EnumAnaSin as ɵb, EnumNatCtb as ɵc, StorageService as ɵd,
|
|
7871
|
+
export { AgreementLookup, BankLookup, BeneficioFiscalLookup, BreadcrumbComponent, BreadcrumbModule, Breakpoints, ContaInternaFilialLookup, CountryLookup, CplTriNotaSaidaE001EndLookup, CplTriNotaSaidaE001PesLookup, CplTriNotaSaidaE001TnsLookup, CplTriNotaSaidaE007UfsLookup, CplTriNotaSaidaE008RaiLookup, CplTriNotaSaidaE015MedLookup, CplTriNotaSaidaE020SnfLookup, CplTriNotaSaidaE024MsgLookup, CplTriNotaSaidaE028CpgLookup, CplTriNotaSaidaE032EdcLookup, CplTriNotaSaidaE051DisLookup, CplTriNotaSaidaE066FpgLookup, CplTriNotaSaidaE070EmpLookup, CplTriNotaSaidaE070FilLookup, CplTriNotaSaidaE075DerLookup, CplTriNotaSaidaE080SerLookup, CplTriNotaSaidaNaturezaReceitaPisCofinsLookup, CplTriNotaSaidaNcmLookup, CplTriNotaSaidaNfEntradaLookup, CplTriNotaSaidaNfSaidaLookup, CurrencyLookup, DocumentoLookup, E001EndLookup, E001PesLookup, E001TnsLookup, E001TnsSupEstLookup, E002TptLookup, E007UfsLookup, E008CepLookup, E008RaiLookup, E012FamLookup, E015MedLookup, E020SnfLookup, E021MotLookup, E023CrpLookup, E024MsgLookup, E027EqiLookup, E027StrLookup, E028CpgLookup, E030AgeLookup, E030BanLookup, E031MoeLookup, E032EdcLookup, E035OcrLookup, E036InsLookup, E039PorLookup, E043MpcLookup, E043PcmLookup, E044CcuFinRatDepLookup, E044CcuLookup, E045PlaLookup, E046HpdLookup, E047NtgLookup, E048FctLookup, E048SfcLookup, E051DisLookup, E066FpgLookup, E067FinLookup, E069GreLookup, E070EmpLookup, E070EntLookup, E070FilLookup, E073PesLookup, E073VeiLookup, E075DerLookup, E080SerLookup, E081TabLookup, E082TprLookup, E085PesLookup, E089DocLookup, E090HrpComGerLookup, E090PesLookup, E091PlfFinRatLookup, E095PesLookup, E099UsuComGerLookup, E099UsuSupCprLookup, E140InsLookup, E140NfsLookup, E200LotLookup, E200SerLookup, E205DepLookup, E210DxpE075DerLookup, E210DxpLookup, E301TcrLookup, E403FprLookup, E420IcpLookup, E420IpcLookup, E420OcpLookup, E501TcpLookup, E600CcoLookup, E640LotLookup, EntityPersonProductLookup, EnumLogicalOperator, EquipmentLookup, ErpLookups, ErpLookupsModule, ErpPolling, ExportUtils, FiltersStorageService, FormUtilsService, HTTP_STATUS_CODE, LigacaoItemFornecedorLookup, LookupValidationUtils, ModulesEnum, NcmLookup, NotaFiscalEntradaLookup, NpsService, ParametersLookup, PrimitiveManager, ProdutoServicoLookup, QuantidadeDisponivelDemandaLookup, RequisicaoLookup, SegmentoLookup, TypeTaxesLookup, UnidadeMedidaLookup, UtilsModule, VerifyModulePermission, VerifyModulePermissions, WebsocketService, naturezaReceitaPisCofins, ɵ0, ErpLookupsService as ɵa, EnumAnaSin as ɵb, EnumNatCtb as ɵc, StorageService as ɵd, UserInformationService as ɵe, VerifyModulePermissionService as ɵf, VerifyModulePermissionsService as ɵg };
|
|
7617
7872
|
//# sourceMappingURL=senior-gestao-empresarial-angular-components.js.map
|