@senior-gestao-empresarial/angular-components 5.1.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/senior-gestao-empresarial-angular-components.umd.js +118 -148
- 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/lookups/erp-lookups.d.ts +1 -0
- package/components/nps/index.d.ts +1 -0
- package/components/nps/nps.service.d.ts +4 -35
- package/components/nps/protocols/index.d.ts +3 -0
- package/components/nps/protocols/tenant-full-dto.d.ts +3 -0
- package/components/nps/protocols/token-senior-x.d.ts +14 -0
- package/components/nps/protocols/tracksale-request.d.ts +18 -0
- package/components/websocket/websocket.service.d.ts +42 -17
- package/esm2015/components/lookups/erp-lookups.js +14 -19
- package/esm2015/components/nps/index.js +1 -1
- package/esm2015/components/nps/nps.service.js +12 -9
- package/esm2015/components/nps/protocols/index.js +1 -0
- package/esm2015/components/nps/protocols/tenant-full-dto.js +1 -0
- package/esm2015/components/nps/protocols/token-senior-x.js +1 -0
- package/esm2015/components/nps/protocols/tracksale-request.js +1 -0
- package/esm2015/components/websocket/websocket.service.js +51 -58
- package/esm5/components/lookups/erp-lookups.js +15 -19
- package/esm5/components/nps/index.js +1 -1
- package/esm5/components/nps/nps.service.js +32 -23
- package/esm5/components/nps/protocols/index.js +1 -0
- package/esm5/components/nps/protocols/tenant-full-dto.js +1 -0
- package/esm5/components/nps/protocols/token-senior-x.js +1 -0
- package/esm5/components/nps/protocols/tracksale-request.js +1 -0
- package/esm5/components/websocket/websocket.service.js +72 -107
- package/fesm2015/senior-gestao-empresarial-angular-components.js +74 -83
- package/fesm2015/senior-gestao-empresarial-angular-components.js.map +1 -1
- package/fesm5/senior-gestao-empresarial-angular-components.js +115 -145
- package/fesm5/senior-gestao-empresarial-angular-components.js.map +1 -1
- package/package.json +1 -1
- package/senior-gestao-empresarial-angular-components.metadata.json +1 -1
|
@@ -13,8 +13,8 @@ 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 { get } from 'js-cookie';
|
|
17
16
|
import { Stomp } from '@stomp/stompjs';
|
|
17
|
+
import { get } from 'js-cookie';
|
|
18
18
|
import * as SockJS from 'sockjs-client';
|
|
19
19
|
|
|
20
20
|
var BreadcrumbComponent = /** @class */ (function () {
|
|
@@ -423,15 +423,7 @@ var ErpLookups = /** @class */ (function () {
|
|
|
423
423
|
}, this.entity, options.domain || this.domain, options.service || this.service)
|
|
424
424
|
.pipe(takeUntil(this.ngUnsubscribe))
|
|
425
425
|
.pipe(map(function (list) {
|
|
426
|
-
return list.contents.map(function (item) { return (__assign(__assign({}, item), { label: lookupDisplayFields
|
|
427
|
-
.map(function (field) {
|
|
428
|
-
if (field.indexOf(".") > 0)
|
|
429
|
-
return _this.getProp(item, field, prefix);
|
|
430
|
-
return item[field] !== undefined && item[field] !== null
|
|
431
|
-
? item[field]
|
|
432
|
-
: _this.translate.instant(prefix + ".empty_label");
|
|
433
|
-
})
|
|
434
|
-
.join(" - ") })); });
|
|
426
|
+
return list.contents.map(function (item) { return (__assign(__assign({}, item), { label: _this.getItemLabel(item, prefix, lookupDisplayFields) })); });
|
|
435
427
|
}))
|
|
436
428
|
.subscribe(function (data) {
|
|
437
429
|
_this.lookupSuggestionsObservable.next(data);
|
|
@@ -500,21 +492,25 @@ var ErpLookups = /** @class */ (function () {
|
|
|
500
492
|
.list({ page: page, sort: sort, filterQuery: filterQuery, displayFields: displayFields }, this.entity, options.domain || this.domain, options.service || this.service)
|
|
501
493
|
.pipe(takeUntil(this.ngUnsubscribe))
|
|
502
494
|
.pipe(map(function (list) { return ({
|
|
503
|
-
gridData: list.contents.map(function (item) { return (__assign(__assign({}, item), { label: lookupDisplayFields
|
|
504
|
-
.map(function (field) {
|
|
505
|
-
if (field.indexOf(".") > 0)
|
|
506
|
-
return _this.getProp(item, field, prefix);
|
|
507
|
-
return item[field] !== undefined && item[field] !== null
|
|
508
|
-
? item[field]
|
|
509
|
-
: _this.translate.instant(prefix + ".empty_label");
|
|
510
|
-
})
|
|
511
|
-
.join(" - ") })); }),
|
|
495
|
+
gridData: list.contents.map(function (item) { return (__assign(__assign({}, item), { label: _this.getItemLabel(item, prefix, lookupDisplayFields) })); }),
|
|
512
496
|
totalRecords: list.totalElements
|
|
513
497
|
}); }))
|
|
514
498
|
.subscribe(function (data) {
|
|
515
499
|
_this.lookupSearchObservable.next(data);
|
|
516
500
|
});
|
|
517
501
|
};
|
|
502
|
+
ErpLookups.prototype.getItemLabel = function (item, prefix, lookupDisplayFields) {
|
|
503
|
+
var _this = this;
|
|
504
|
+
return lookupDisplayFields
|
|
505
|
+
.map(function (field) {
|
|
506
|
+
if (field.indexOf(".") > 0)
|
|
507
|
+
return _this.getProp(item, field, prefix);
|
|
508
|
+
return item[field] !== undefined && item[field] !== null
|
|
509
|
+
? item[field]
|
|
510
|
+
: _this.translate.instant(prefix + ".empty_label");
|
|
511
|
+
})
|
|
512
|
+
.join(" - ");
|
|
513
|
+
};
|
|
518
514
|
ErpLookups.ctorParameters = function () { return [
|
|
519
515
|
{ type: ErpLookupsService },
|
|
520
516
|
{ type: TranslateService },
|
|
@@ -6470,38 +6466,47 @@ var UtilsModule = /** @class */ (function () {
|
|
|
6470
6466
|
return UtilsModule;
|
|
6471
6467
|
}());
|
|
6472
6468
|
|
|
6469
|
+
// https://widget.tracksale.co/
|
|
6473
6470
|
var NpsService = /** @class */ (function () {
|
|
6474
6471
|
function NpsService() {
|
|
6475
6472
|
}
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
return
|
|
6479
|
-
|
|
6480
|
-
|
|
6481
|
-
|
|
6482
|
-
|
|
6473
|
+
NpsService.prototype.getUserInformation = function () {
|
|
6474
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
6475
|
+
return __generator(this, function (_a) {
|
|
6476
|
+
switch (_a.label) {
|
|
6477
|
+
case 0: return [4 /*yield*/, user.getToken()];
|
|
6478
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
6479
|
+
}
|
|
6480
|
+
});
|
|
6481
|
+
});
|
|
6482
|
+
};
|
|
6483
6483
|
/**
|
|
6484
6484
|
* Executa o serviço de NPS utilizando os dados do usuário atual, no caso sobreescrevendos os campos name, email, identification,
|
|
6485
6485
|
* tags.tenant e tags.email fornecidos no request original. Esses serão sobreescritos com os valores retornados pelo cookie
|
|
6486
|
-
* com.senior.pau.userdata.
|
|
6486
|
+
* com.senior.pau.userdata.
|
|
6487
|
+
*
|
|
6487
6488
|
* @param tracksaleRequest request que será enviado ao serviço de nps
|
|
6488
6489
|
*/
|
|
6489
6490
|
NpsService.prototype.currentUserInitNPS = function (tracksaleRequest) {
|
|
6490
6491
|
return __awaiter(this, void 0, void 0, function () {
|
|
6491
|
-
var _a, tenantName, email,
|
|
6492
|
+
var _a, tenantName, email, fullName, copyTracksaleRequest;
|
|
6492
6493
|
return __generator(this, function (_b) {
|
|
6493
|
-
|
|
6494
|
-
|
|
6495
|
-
|
|
6496
|
-
|
|
6497
|
-
{};
|
|
6498
|
-
|
|
6499
|
-
|
|
6500
|
-
|
|
6501
|
-
|
|
6502
|
-
|
|
6503
|
-
|
|
6504
|
-
|
|
6494
|
+
switch (_b.label) {
|
|
6495
|
+
case 0: return [4 /*yield*/, this.getUserInformation()];
|
|
6496
|
+
case 1:
|
|
6497
|
+
_a = _b.sent(), tenantName = _a.tenantName, email = _a.email, fullName = _a.fullName;
|
|
6498
|
+
copyTracksaleRequest = __assign({}, tracksaleRequest);
|
|
6499
|
+
copyTracksaleRequest.tags =
|
|
6500
|
+
(tracksaleRequest.tags && __assign({}, tracksaleRequest.tags)) ||
|
|
6501
|
+
{};
|
|
6502
|
+
copyTracksaleRequest.name = fullName;
|
|
6503
|
+
copyTracksaleRequest.email = email;
|
|
6504
|
+
copyTracksaleRequest.identification = email;
|
|
6505
|
+
copyTracksaleRequest.tags.tenant = tenantName;
|
|
6506
|
+
copyTracksaleRequest.tags.email = email;
|
|
6507
|
+
this.initNPS(copyTracksaleRequest);
|
|
6508
|
+
return [2 /*return*/];
|
|
6509
|
+
}
|
|
6505
6510
|
});
|
|
6506
6511
|
});
|
|
6507
6512
|
};
|
|
@@ -6547,14 +6552,23 @@ var NpsService = /** @class */ (function () {
|
|
|
6547
6552
|
|
|
6548
6553
|
var WebsocketService = /** @class */ (function () {
|
|
6549
6554
|
function WebsocketService() {
|
|
6555
|
+
/** @private */
|
|
6550
6556
|
this.focused = true;
|
|
6557
|
+
/** @private */
|
|
6551
6558
|
this.wasConnected = false;
|
|
6559
|
+
/** @private */
|
|
6552
6560
|
this.connected = false;
|
|
6561
|
+
/** @private */
|
|
6553
6562
|
this.isConnecting = false;
|
|
6563
|
+
/** @private */
|
|
6554
6564
|
this.primitiveManagers = new Map();
|
|
6565
|
+
/** @private */
|
|
6555
6566
|
this.connect$ = new Subject();
|
|
6567
|
+
/** @private */
|
|
6556
6568
|
this.disconnect$ = new Subject();
|
|
6569
|
+
/** @private */
|
|
6557
6570
|
this.reconnect$ = new Subject();
|
|
6571
|
+
/** @private */
|
|
6558
6572
|
this.error$ = new Subject();
|
|
6559
6573
|
window.onfocus = this.onFocus;
|
|
6560
6574
|
window.onblur = this.onBlur;
|
|
@@ -6596,18 +6610,19 @@ var WebsocketService = /** @class */ (function () {
|
|
|
6596
6610
|
return this.error$.asObservable();
|
|
6597
6611
|
};
|
|
6598
6612
|
/**
|
|
6599
|
-
* Observable responsável por emitir uma notificação quando um evento é publicado.
|
|
6600
6613
|
* @typeParam `<T>` Tipo do objeto que o retorno do `observable` vai devolver.
|
|
6601
|
-
* @param
|
|
6602
|
-
* @param
|
|
6603
|
-
* @param
|
|
6604
|
-
* @param
|
|
6605
|
-
* @return Um
|
|
6614
|
+
* @param {Object} options Objeto de configuração do evento.
|
|
6615
|
+
* @param {string} options.domain Domínio da primitiva.
|
|
6616
|
+
* @param {string} options.service Serviço da primitiva.
|
|
6617
|
+
* @param {string} options.primitive Primitiva que será "observada".
|
|
6618
|
+
* @return Um Observable<T> que emite notificações toda vez que o respectivo evento é publicado.
|
|
6606
6619
|
*/
|
|
6607
|
-
WebsocketService.prototype.onEvent = function (
|
|
6620
|
+
WebsocketService.prototype.onEvent = function (options) {
|
|
6608
6621
|
var _this = this;
|
|
6609
|
-
|
|
6610
|
-
|
|
6622
|
+
var domain = options.domain, service = options.service, primitive = options.primitive;
|
|
6623
|
+
var key = this.getPrimitiveManagerKey(domain, service, primitive);
|
|
6624
|
+
if (this.primitiveManagers.has(key)) {
|
|
6625
|
+
return this.primitiveManagers.get(key).subject.asObservable();
|
|
6611
6626
|
}
|
|
6612
6627
|
var primitiveManager = {
|
|
6613
6628
|
domain: domain,
|
|
@@ -6615,13 +6630,11 @@ var WebsocketService = /** @class */ (function () {
|
|
|
6615
6630
|
primitive: primitive,
|
|
6616
6631
|
stompSubscriptions: [],
|
|
6617
6632
|
subject: new Subject(),
|
|
6618
|
-
identifierPath: identifierPath,
|
|
6619
|
-
publishedEvents: [],
|
|
6620
6633
|
};
|
|
6621
|
-
this.primitiveManagers.set(
|
|
6634
|
+
this.primitiveManagers.set(key, primitiveManager);
|
|
6622
6635
|
if (this.isConnected()) {
|
|
6623
6636
|
this.createStompSubscriptions(primitiveManager);
|
|
6624
|
-
return primitiveManager.subject.pipe(finalize(function () { return _this.disconnectPrimitiveOnFinalize(
|
|
6637
|
+
return primitiveManager.subject.pipe(finalize(function () { return _this.disconnectPrimitiveOnFinalize(primitiveManager); }));
|
|
6625
6638
|
}
|
|
6626
6639
|
else {
|
|
6627
6640
|
if (!this.isConnecting) {
|
|
@@ -6630,53 +6643,10 @@ var WebsocketService = /** @class */ (function () {
|
|
|
6630
6643
|
this.connect$.pipe(first()).subscribe(function () {
|
|
6631
6644
|
_this.createStompSubscriptions(primitiveManager);
|
|
6632
6645
|
});
|
|
6633
|
-
return primitiveManager.subject.pipe(finalize(function () { return _this.disconnectPrimitiveOnFinalize(
|
|
6634
|
-
}
|
|
6635
|
-
};
|
|
6636
|
-
/**
|
|
6637
|
-
* Retorna todos os eventos ouvidos pela primitiva com os respectivos identificadores.
|
|
6638
|
-
* @typeParam `<T>` Tipo do evento retornado pela primitiva.
|
|
6639
|
-
* @param primitive Primitiva que será "observada" pelo client.
|
|
6640
|
-
* @param identifiers Array com os identificadores interessados.
|
|
6641
|
-
* @return Array contendo o último evento recebido de cada identificador fornecido.
|
|
6642
|
-
*/
|
|
6643
|
-
WebsocketService.prototype.getPublishedEvents = function (primitive, identifiers) {
|
|
6644
|
-
var e_1, _a;
|
|
6645
|
-
var _this = this;
|
|
6646
|
-
var publishedEvents = [];
|
|
6647
|
-
var primitiveManager = this.primitiveManagers.get(primitive);
|
|
6648
|
-
var _loop_1 = function (identifier) {
|
|
6649
|
-
var event_1 = primitiveManager.publishedEvents.find(function (x) { return _this.getIdentifierFromEvent(primitiveManager.identifierPath, x) === identifier; });
|
|
6650
|
-
if (event_1) {
|
|
6651
|
-
publishedEvents.push(event_1);
|
|
6652
|
-
}
|
|
6653
|
-
};
|
|
6654
|
-
try {
|
|
6655
|
-
for (var identifiers_1 = __values(identifiers), identifiers_1_1 = identifiers_1.next(); !identifiers_1_1.done; identifiers_1_1 = identifiers_1.next()) {
|
|
6656
|
-
var identifier = identifiers_1_1.value;
|
|
6657
|
-
_loop_1(identifier);
|
|
6658
|
-
}
|
|
6659
|
-
}
|
|
6660
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
6661
|
-
finally {
|
|
6662
|
-
try {
|
|
6663
|
-
if (identifiers_1_1 && !identifiers_1_1.done && (_a = identifiers_1.return)) _a.call(identifiers_1);
|
|
6664
|
-
}
|
|
6665
|
-
finally { if (e_1) throw e_1.error; }
|
|
6666
|
-
}
|
|
6667
|
-
return publishedEvents;
|
|
6668
|
-
};
|
|
6669
|
-
WebsocketService.prototype.addPublishedEvent = function (primitiveManager, event) {
|
|
6670
|
-
var _this = this;
|
|
6671
|
-
var identifier = this.getIdentifierFromEvent(primitiveManager.identifierPath, event);
|
|
6672
|
-
var eventIndex = primitiveManager.publishedEvents.findIndex(function (x) { return _this.getIdentifierFromEvent(primitiveManager.identifierPath, x) === identifier; });
|
|
6673
|
-
if (eventIndex !== -1) {
|
|
6674
|
-
primitiveManager.publishedEvents[eventIndex] = __assign(__assign({}, primitiveManager.publishedEvents[eventIndex]), event);
|
|
6675
|
-
}
|
|
6676
|
-
else {
|
|
6677
|
-
primitiveManager.publishedEvents.push(event);
|
|
6646
|
+
return primitiveManager.subject.pipe(finalize(function () { return _this.disconnectPrimitiveOnFinalize(primitiveManager); }));
|
|
6678
6647
|
}
|
|
6679
6648
|
};
|
|
6649
|
+
/** @private */
|
|
6680
6650
|
WebsocketService.prototype.createStompSubscriptions = function (primitiveManager) {
|
|
6681
6651
|
var withTokenUrl = this.getSubscriptionUrlWithToken(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
6682
6652
|
var stompSubscriptionWithToken = this.createStompSubscription(withTokenUrl, primitiveManager);
|
|
@@ -6684,25 +6654,7 @@ var WebsocketService = /** @class */ (function () {
|
|
|
6684
6654
|
var stompSubscriptionWithoutToken = this.createStompSubscription(withoutTokenUrl, primitiveManager);
|
|
6685
6655
|
primitiveManager.stompSubscriptions = [stompSubscriptionWithToken, stompSubscriptionWithoutToken];
|
|
6686
6656
|
};
|
|
6687
|
-
|
|
6688
|
-
var e_2, _a;
|
|
6689
|
-
var properties = identifierPath.split(".");
|
|
6690
|
-
var identifier = event;
|
|
6691
|
-
try {
|
|
6692
|
-
for (var properties_1 = __values(properties), properties_1_1 = properties_1.next(); !properties_1_1.done; properties_1_1 = properties_1.next()) {
|
|
6693
|
-
var property = properties_1_1.value;
|
|
6694
|
-
identifier = identifier[property];
|
|
6695
|
-
}
|
|
6696
|
-
}
|
|
6697
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
6698
|
-
finally {
|
|
6699
|
-
try {
|
|
6700
|
-
if (properties_1_1 && !properties_1_1.done && (_a = properties_1.return)) _a.call(properties_1);
|
|
6701
|
-
}
|
|
6702
|
-
finally { if (e_2) throw e_2.error; }
|
|
6703
|
-
}
|
|
6704
|
-
return identifier;
|
|
6705
|
-
};
|
|
6657
|
+
/** @private */
|
|
6706
6658
|
WebsocketService.prototype.connect = function () {
|
|
6707
6659
|
var _this = this;
|
|
6708
6660
|
this.createStompClient();
|
|
@@ -6725,14 +6677,16 @@ var WebsocketService = /** @class */ (function () {
|
|
|
6725
6677
|
_this.reconnect();
|
|
6726
6678
|
});
|
|
6727
6679
|
};
|
|
6680
|
+
/** @private */
|
|
6728
6681
|
WebsocketService.prototype.onFocus = function () {
|
|
6729
6682
|
this.focused = true;
|
|
6730
6683
|
};
|
|
6684
|
+
/** @private */
|
|
6731
6685
|
WebsocketService.prototype.onBlur = function () {
|
|
6732
6686
|
this.focused = false;
|
|
6733
6687
|
};
|
|
6734
6688
|
WebsocketService.prototype.disconnect = function () {
|
|
6735
|
-
var
|
|
6689
|
+
var e_1, _a, e_2, _b, e_3, _c;
|
|
6736
6690
|
var observersCount = this.getObserversCount();
|
|
6737
6691
|
if (observersCount > 0)
|
|
6738
6692
|
return;
|
|
@@ -6740,26 +6694,26 @@ var WebsocketService = /** @class */ (function () {
|
|
|
6740
6694
|
for (var _d = __values(this.primitiveManagers.values()), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
6741
6695
|
var primitiveManager = _e.value;
|
|
6742
6696
|
try {
|
|
6743
|
-
for (var _f = (
|
|
6697
|
+
for (var _f = (e_2 = void 0, __values(primitiveManager.stompSubscriptions)), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
6744
6698
|
var stompSubscription = _g.value;
|
|
6745
6699
|
stompSubscription.unsubscribe();
|
|
6746
6700
|
}
|
|
6747
6701
|
}
|
|
6748
|
-
catch (
|
|
6702
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
6749
6703
|
finally {
|
|
6750
6704
|
try {
|
|
6751
6705
|
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
6752
6706
|
}
|
|
6753
|
-
finally { if (
|
|
6707
|
+
finally { if (e_2) throw e_2.error; }
|
|
6754
6708
|
}
|
|
6755
6709
|
}
|
|
6756
6710
|
}
|
|
6757
|
-
catch (
|
|
6711
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
6758
6712
|
finally {
|
|
6759
6713
|
try {
|
|
6760
6714
|
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
6761
6715
|
}
|
|
6762
|
-
finally { if (
|
|
6716
|
+
finally { if (e_1) throw e_1.error; }
|
|
6763
6717
|
}
|
|
6764
6718
|
try {
|
|
6765
6719
|
for (var _h = __values(this.primitiveManagers.values()), _j = _h.next(); !_j.done; _j = _h.next()) {
|
|
@@ -6767,12 +6721,12 @@ var WebsocketService = /** @class */ (function () {
|
|
|
6767
6721
|
primitiveManager.subject.complete();
|
|
6768
6722
|
}
|
|
6769
6723
|
}
|
|
6770
|
-
catch (
|
|
6724
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
6771
6725
|
finally {
|
|
6772
6726
|
try {
|
|
6773
6727
|
if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
|
|
6774
6728
|
}
|
|
6775
|
-
finally { if (
|
|
6729
|
+
finally { if (e_3) throw e_3.error; }
|
|
6776
6730
|
}
|
|
6777
6731
|
this.primitiveManagers.clear();
|
|
6778
6732
|
this._stompClient.disconnect();
|
|
@@ -6782,35 +6736,40 @@ var WebsocketService = /** @class */ (function () {
|
|
|
6782
6736
|
this.wasConnected = false;
|
|
6783
6737
|
this.disconnect$.next();
|
|
6784
6738
|
};
|
|
6739
|
+
/** @private */
|
|
6785
6740
|
WebsocketService.prototype.isConnected = function () {
|
|
6786
6741
|
return this.connected;
|
|
6787
6742
|
};
|
|
6743
|
+
/** @private */
|
|
6788
6744
|
WebsocketService.prototype.setConnected = function (connected) {
|
|
6789
6745
|
this.connected = connected;
|
|
6790
6746
|
};
|
|
6747
|
+
/** @private */
|
|
6791
6748
|
WebsocketService.prototype.getSubscriptionUrlWithToken = function (domain, service, primitive) {
|
|
6792
6749
|
var tenant = WebsocketService_1.TOKEN ? WebsocketService_1.TOKEN.username.split("@")[1] : null;
|
|
6793
6750
|
var token = WebsocketService_1.TOKEN ? WebsocketService_1.TOKEN.access_token : null;
|
|
6794
6751
|
return "/topic/" + tenant + "/" + token + "/" + domain + "/" + service + "/" + primitive;
|
|
6795
6752
|
};
|
|
6753
|
+
/** @private */
|
|
6796
6754
|
WebsocketService.prototype.getSubscriptionUrlWithoutToken = function (domain, service, primitive) {
|
|
6797
6755
|
var tenant = WebsocketService_1.TOKEN ? WebsocketService_1.TOKEN.username.split("@")[1] : null;
|
|
6798
6756
|
return "/topic/" + tenant + "/" + domain + "/" + service + "/" + primitive;
|
|
6799
6757
|
};
|
|
6758
|
+
/** @private */
|
|
6800
6759
|
WebsocketService.prototype.createStompSubscription = function (destination, primitiveManager) {
|
|
6801
|
-
var _this = this;
|
|
6802
6760
|
return this._stompClient.subscribe(destination, function (message) {
|
|
6803
6761
|
var event = JSON.parse(message.body || "{}");
|
|
6804
|
-
_this.addPublishedEvent(primitiveManager, event);
|
|
6805
6762
|
primitiveManager.subject.next(event);
|
|
6806
6763
|
});
|
|
6807
6764
|
};
|
|
6765
|
+
/** @private */
|
|
6808
6766
|
WebsocketService.prototype.createStompClient = function () {
|
|
6809
6767
|
var ws = new SockJS(WebsocketService_1.WEBSOCKET_URL + "subscription", null, { timeout: WebsocketService_1.CONNECTION_TIMEOUT });
|
|
6810
6768
|
this._stompClient = Stomp.over(ws);
|
|
6811
6769
|
// this._stompClient.debug = (str) => console.log(new Date().toISOString(), str);
|
|
6812
6770
|
this._stompClient.debug = function () { }; // Para remover os logs.
|
|
6813
6771
|
};
|
|
6772
|
+
/** @private */
|
|
6814
6773
|
WebsocketService.prototype.reconnect = function () {
|
|
6815
6774
|
var _this = this;
|
|
6816
6775
|
if (this.connected)
|
|
@@ -6826,37 +6785,39 @@ var WebsocketService = /** @class */ (function () {
|
|
|
6826
6785
|
}
|
|
6827
6786
|
}, WebsocketService_1.RECONNECT_TIMER);
|
|
6828
6787
|
};
|
|
6788
|
+
/** @private */
|
|
6829
6789
|
WebsocketService.prototype.reconnectPrimitives = function () {
|
|
6830
|
-
var
|
|
6790
|
+
var e_4, _a, e_5, _b;
|
|
6831
6791
|
try {
|
|
6832
6792
|
for (var _c = __values(this.primitiveManagers.values()), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
6833
6793
|
var primitiveManager = _d.value;
|
|
6834
6794
|
try {
|
|
6835
|
-
for (var _e = (
|
|
6795
|
+
for (var _e = (e_5 = void 0, __values(primitiveManager.stompSubscriptions)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
6836
6796
|
var stompSubscription = _f.value;
|
|
6837
6797
|
stompSubscription.unsubscribe();
|
|
6838
6798
|
}
|
|
6839
6799
|
}
|
|
6840
|
-
catch (
|
|
6800
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
6841
6801
|
finally {
|
|
6842
6802
|
try {
|
|
6843
6803
|
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
6844
6804
|
}
|
|
6845
|
-
finally { if (
|
|
6805
|
+
finally { if (e_5) throw e_5.error; }
|
|
6846
6806
|
}
|
|
6847
6807
|
this.createStompSubscriptions(primitiveManager);
|
|
6848
6808
|
}
|
|
6849
6809
|
}
|
|
6850
|
-
catch (
|
|
6810
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
6851
6811
|
finally {
|
|
6852
6812
|
try {
|
|
6853
6813
|
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
6854
6814
|
}
|
|
6855
|
-
finally { if (
|
|
6815
|
+
finally { if (e_4) throw e_4.error; }
|
|
6856
6816
|
}
|
|
6857
6817
|
};
|
|
6818
|
+
/** @private */
|
|
6858
6819
|
WebsocketService.prototype.getObserversCount = function () {
|
|
6859
|
-
var
|
|
6820
|
+
var e_6, _a;
|
|
6860
6821
|
var observersCount = 0;
|
|
6861
6822
|
try {
|
|
6862
6823
|
for (var _b = __values(this.primitiveManagers.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -6864,21 +6825,19 @@ var WebsocketService = /** @class */ (function () {
|
|
|
6864
6825
|
observersCount += primitiveManager.subject.observers.length;
|
|
6865
6826
|
}
|
|
6866
6827
|
}
|
|
6867
|
-
catch (
|
|
6828
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
6868
6829
|
finally {
|
|
6869
6830
|
try {
|
|
6870
6831
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
6871
6832
|
}
|
|
6872
|
-
finally { if (
|
|
6833
|
+
finally { if (e_6) throw e_6.error; }
|
|
6873
6834
|
}
|
|
6874
6835
|
return observersCount;
|
|
6875
6836
|
};
|
|
6876
|
-
|
|
6877
|
-
|
|
6878
|
-
var
|
|
6879
|
-
|
|
6880
|
-
return;
|
|
6881
|
-
// @IMPORTANT: Replace .observers.length with .observed in rxjs 7.0+
|
|
6837
|
+
/** @private */
|
|
6838
|
+
WebsocketService.prototype.disconnectPrimitiveOnFinalize = function (primitiveManager) {
|
|
6839
|
+
var e_7, _a;
|
|
6840
|
+
// @IMPORTANT: Replace .observers.length === 1 with .observed in rxjs 7.0+
|
|
6882
6841
|
var hasObservers = !(primitiveManager.subject.observers.length === 1);
|
|
6883
6842
|
if (hasObservers)
|
|
6884
6843
|
return;
|
|
@@ -6888,22 +6847,33 @@ var WebsocketService = /** @class */ (function () {
|
|
|
6888
6847
|
stompSubscription.unsubscribe();
|
|
6889
6848
|
}
|
|
6890
6849
|
}
|
|
6891
|
-
catch (
|
|
6850
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
6892
6851
|
finally {
|
|
6893
6852
|
try {
|
|
6894
6853
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
6895
6854
|
}
|
|
6896
|
-
finally { if (
|
|
6855
|
+
finally { if (e_7) throw e_7.error; }
|
|
6897
6856
|
}
|
|
6898
|
-
this.
|
|
6857
|
+
var key = this.getPrimitiveManagerKey(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
6858
|
+
this.primitiveManagers.delete(key);
|
|
6899
6859
|
this.disconnect();
|
|
6900
6860
|
};
|
|
6861
|
+
/** @private */
|
|
6862
|
+
WebsocketService.prototype.getPrimitiveManagerKey = function (domain, service, primitive) {
|
|
6863
|
+
return domain + "/" + service + "/" + primitive;
|
|
6864
|
+
};
|
|
6901
6865
|
var WebsocketService_1;
|
|
6866
|
+
/** @private */
|
|
6902
6867
|
WebsocketService.RECONNECT_TIMER = 3000;
|
|
6868
|
+
/** @private */
|
|
6903
6869
|
WebsocketService.CONNECTION_TIMEOUT = 15000;
|
|
6870
|
+
/** @private */
|
|
6904
6871
|
WebsocketService.BASE_URL_COOKIE = "com.senior.base.url";
|
|
6872
|
+
/** @private */
|
|
6905
6873
|
WebsocketService.TOKEN_COOKIE = "com.senior.token";
|
|
6874
|
+
/** @private */
|
|
6906
6875
|
WebsocketService.TOKEN = JSON.parse(get(WebsocketService_1.TOKEN_COOKIE) || "{}");
|
|
6876
|
+
/** @private */
|
|
6907
6877
|
WebsocketService.WEBSOCKET_URL = get(WebsocketService_1.BASE_URL_COOKIE) + "/websocket/";
|
|
6908
6878
|
WebsocketService.ɵprov = ɵɵdefineInjectable({ factory: function WebsocketService_Factory() { return new WebsocketService(); }, token: WebsocketService, providedIn: "root" });
|
|
6909
6879
|
WebsocketService = WebsocketService_1 = __decorate([
|