@senior-gestao-empresarial/angular-components 4.22.2 → 4.23.2

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.
@@ -4,7 +4,7 @@ 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
6
  import { Subject, throwError, interval, of, ReplaySubject } from 'rxjs';
7
- import { takeUntil, filter, catchError, map, takeWhile, switchMap, first, take } from 'rxjs/operators';
7
+ import { takeUntil, filter, catchError, map, takeWhile, switchMap, first, finalize, take } 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';
@@ -15,7 +15,6 @@ import { user } from '@seniorsistemas/senior-platform-data';
15
15
  import { FormControl, FormGroup } from '@angular/forms';
16
16
  import { get } from 'js-cookie';
17
17
  import { Stomp } from '@stomp/stompjs';
18
- import { CookieService } from 'ngx-cookie-service';
19
18
  import * as SockJS from 'sockjs-client';
20
19
 
21
20
  let BreadcrumbComponent = class BreadcrumbComponent {
@@ -5322,6 +5321,72 @@ ParametersLookup = __decorate([
5322
5321
  Injectable()
5323
5322
  ], ParametersLookup);
5324
5323
 
5324
+ let BeneficioFiscalLookup = class BeneficioFiscalLookup extends ErpLookups {
5325
+ constructor(lookupService, translate) {
5326
+ super(lookupService, translate, "beneficioFiscal", [
5327
+ {
5328
+ name: "codigo",
5329
+ type: FieldType.String
5330
+ },
5331
+ {
5332
+ name: "descricao",
5333
+ type: FieldType.String
5334
+ },
5335
+ ], [
5336
+ {
5337
+ name: "codigo",
5338
+ type: FieldType.String
5339
+ },
5340
+ {
5341
+ name: "descricao",
5342
+ type: FieldType.String
5343
+ },
5344
+ {
5345
+ name: "abreviatura",
5346
+ type: FieldType.String
5347
+ },
5348
+ {
5349
+ name: "vigenciaInicial",
5350
+ type: FieldType.Date
5351
+ },
5352
+ {
5353
+ name: "vigenciaFinal",
5354
+ type: FieldType.Date
5355
+ },
5356
+ ], [
5357
+ {
5358
+ name: "codigo",
5359
+ type: FieldType.String
5360
+ },
5361
+ {
5362
+ name: "descricao",
5363
+ type: FieldType.String
5364
+ },
5365
+ {
5366
+ name: "abreviatura",
5367
+ type: FieldType.String
5368
+ },
5369
+ {
5370
+ name: "vigenciaInicial",
5371
+ type: FieldType.Date
5372
+ },
5373
+ {
5374
+ name: "vigenciaFinal",
5375
+ type: FieldType.Date
5376
+ },
5377
+ ], "erpx_cpl_imp", "impostos");
5378
+ this.lookupService = lookupService;
5379
+ this.translate = translate;
5380
+ }
5381
+ };
5382
+ BeneficioFiscalLookup.ctorParameters = () => [
5383
+ { type: ErpLookupsService },
5384
+ { type: TranslateService }
5385
+ ];
5386
+ BeneficioFiscalLookup = __decorate([
5387
+ Injectable()
5388
+ ], BeneficioFiscalLookup);
5389
+
5325
5390
  let ErpLookupsModule = class ErpLookupsModule {
5326
5391
  };
5327
5392
  ErpLookupsModule = __decorate([
@@ -5425,7 +5490,8 @@ ErpLookupsModule = __decorate([
5425
5490
  CountryLookup,
5426
5491
  BankLookup,
5427
5492
  TypeTaxesLookup,
5428
- ParametersLookup
5493
+ ParametersLookup,
5494
+ BeneficioFiscalLookup
5429
5495
  ],
5430
5496
  declarations: [],
5431
5497
  exports: [],
@@ -6014,17 +6080,16 @@ NpsService = __decorate([
6014
6080
 
6015
6081
  var WebsocketService_1;
6016
6082
  let WebsocketService = WebsocketService_1 = class WebsocketService {
6017
- constructor(cookieService) {
6018
- this.cookieService = cookieService;
6019
- this.baseUrl = null;
6020
- this.username = null;
6083
+ constructor() {
6021
6084
  this.focused = true;
6085
+ this.wasConnected = false;
6022
6086
  this.connected = false;
6023
6087
  this.isConnecting = false;
6024
- this.stompSubscriptions = new Map();
6025
6088
  this.primitiveManagers = new Map();
6026
- this.disconnectSubject = new Subject();
6027
6089
  this.connect$ = new Subject();
6090
+ this.disconnect$ = new Subject();
6091
+ this.reconnect$ = new Subject();
6092
+ this.error$ = new Subject();
6028
6093
  window.onfocus = this.onFocus;
6029
6094
  window.onblur = this.onBlur;
6030
6095
  this.connect();
@@ -6036,22 +6101,36 @@ let WebsocketService = WebsocketService_1 = class WebsocketService {
6036
6101
  onConnect() {
6037
6102
  setTimeout(() => {
6038
6103
  if (this.isConnected()) {
6039
- this.publishOnConnect();
6104
+ this.connect$.next();
6040
6105
  }
6041
6106
  }, 0);
6042
- return this.connect$.asObservable();
6107
+ return this.connect$.pipe(first());
6043
6108
  }
6044
6109
  /**
6045
- * Observable responsável por emitir uma notificação quando a conexão é finalizada.
6046
- * @return Um `Observable<void>` que emite uma notificação quando a conexão é finalizada.
6110
+ * Observable responsável por emitir uma notificação quando a conexão é desconectada.
6111
+ * @return Um `Observable<void>` que emite uma notificação quando a conexão é desconectada.
6047
6112
  */
6048
6113
  onDisconnect() {
6049
- return this.disconnectSubject.asObservable();
6114
+ return this.disconnect$.asObservable();
6115
+ }
6116
+ /**
6117
+ * Observable responsável por emitir uma notificação quando a conexão é reconectada.
6118
+ * @return Um `Observable<void>` que emite uma notificação quando a conexão é reconectada.
6119
+ */
6120
+ onReconnect() {
6121
+ return this.reconnect$.asObservable();
6122
+ }
6123
+ /**
6124
+ * Observable responsável por emitir uma notificação quando ocorre algum erro.
6125
+ * @return Um `Observable<FrameImpl>` que emite uma notificação quando ocorre algum erro.
6126
+ */
6127
+ onError() {
6128
+ return this.error$.asObservable();
6050
6129
  }
6051
6130
  /**
6052
6131
  * Observable responsável por emitir uma notificação quando um evento é publicado.
6053
6132
  * @typeParam `<T>` Tipo do objeto que o retorno do `observable` vai devolver.
6054
- * @param domain Dominio da primitva.
6133
+ * @param domain Dominio da primitiva.
6055
6134
  * @param service Service da primitiva.
6056
6135
  * @param primitive Primitiva que será "observada" pelo client.
6057
6136
  * @param identifierPath Caminho até a propriedade considerada o identificador do registro.
@@ -6062,25 +6141,27 @@ let WebsocketService = WebsocketService_1 = class WebsocketService {
6062
6141
  return this.primitiveManagers.get(primitive).subject.asObservable();
6063
6142
  }
6064
6143
  const primitiveManager = {
6144
+ domain: domain,
6145
+ service: service,
6146
+ primitive: primitive,
6147
+ stompSubscriptions: [],
6065
6148
  subject: new Subject(),
6066
6149
  identifierPath: identifierPath,
6067
6150
  publishedEvents: [],
6068
6151
  };
6069
6152
  this.primitiveManagers.set(primitive, primitiveManager);
6070
6153
  if (this.isConnected()) {
6071
- this.createStompSubscriptions(domain, service, primitive, primitiveManager);
6072
- return primitiveManager.subject.asObservable();
6154
+ this.createStompSubscriptions(primitiveManager);
6155
+ return primitiveManager.subject.pipe(finalize(() => this.disconnectPrimitiveOnFinalize(primitive)));
6073
6156
  }
6074
6157
  else {
6075
6158
  if (!this.isConnecting) {
6076
6159
  this.connect();
6077
6160
  }
6078
- this.onConnect()
6079
- .pipe(first())
6080
- .subscribe(() => {
6081
- this.createStompSubscriptions(domain, service, primitive, primitiveManager);
6161
+ this.connect$.pipe(first()).subscribe(() => {
6162
+ this.createStompSubscriptions(primitiveManager);
6082
6163
  });
6083
- return primitiveManager.subject.asObservable();
6164
+ return primitiveManager.subject.pipe(finalize(() => this.disconnectPrimitiveOnFinalize(primitive)));
6084
6165
  }
6085
6166
  }
6086
6167
  /**
@@ -6111,12 +6192,12 @@ let WebsocketService = WebsocketService_1 = class WebsocketService {
6111
6192
  primitiveManager.publishedEvents.push(event);
6112
6193
  }
6113
6194
  }
6114
- createStompSubscriptions(domain, service, primitive, primitiveManager) {
6115
- const withTokenUrl = this.getSubscriptionUrlWithToken(domain, service, primitive);
6195
+ createStompSubscriptions(primitiveManager) {
6196
+ const withTokenUrl = this.getSubscriptionUrlWithToken(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
6116
6197
  const stompSubscriptionWithToken = this.createStompSubscription(withTokenUrl, primitiveManager);
6117
- const withoutTokenUrl = this.getSubscriptionUrlWithoutToken(domain, service, primitive);
6198
+ const withoutTokenUrl = this.getSubscriptionUrlWithoutToken(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
6118
6199
  const stompSubscriptionWithoutToken = this.createStompSubscription(withoutTokenUrl, primitiveManager);
6119
- this.stompSubscriptions.set(primitive, [stompSubscriptionWithToken, stompSubscriptionWithoutToken]);
6200
+ primitiveManager.stompSubscriptions = [stompSubscriptionWithToken, stompSubscriptionWithoutToken];
6120
6201
  }
6121
6202
  getIdentifierFromEvent(identifierPath, event) {
6122
6203
  const properties = identifierPath.split(".");
@@ -6129,19 +6210,24 @@ let WebsocketService = WebsocketService_1 = class WebsocketService {
6129
6210
  connect() {
6130
6211
  this.createStompClient();
6131
6212
  this.isConnecting = true;
6213
+ this._stompClient.activate();
6132
6214
  this._stompClient.connect({}, () => {
6133
- this.setConnected(true);
6134
6215
  this.isConnecting = false;
6135
- this.publishOnConnect();
6136
- }, () => {
6216
+ this.setConnected(true);
6217
+ if (this.wasConnected) {
6218
+ this.reconnectPrimitives();
6219
+ this.reconnect$.next();
6220
+ }
6221
+ else {
6222
+ this.wasConnected = true;
6223
+ this.connect$.next();
6224
+ }
6225
+ }, (error) => {
6137
6226
  this.setConnected(false);
6138
- // this.reconnectWebSocket();
6227
+ this.error$.next(error);
6228
+ this.reconnect();
6139
6229
  });
6140
6230
  }
6141
- publishOnConnect() {
6142
- this.connect$.next();
6143
- this.connect$.observers = [];
6144
- }
6145
6231
  onFocus() {
6146
6232
  this.focused = true;
6147
6233
  }
@@ -6149,27 +6235,24 @@ let WebsocketService = WebsocketService_1 = class WebsocketService {
6149
6235
  this.focused = false;
6150
6236
  }
6151
6237
  disconnect() {
6152
- let observersCount = 0;
6238
+ const observersCount = this.getObserversCount();
6239
+ if (observersCount > 0)
6240
+ return;
6153
6241
  for (const primitiveManager of this.primitiveManagers.values()) {
6154
- observersCount += primitiveManager.subject.observers.length;
6155
- }
6156
- if (observersCount === 0) {
6157
- this.stompSubscriptions.forEach(stompSubscriptions => {
6158
- for (const stompSubscription of stompSubscriptions) {
6159
- stompSubscription.unsubscribe();
6160
- }
6161
- });
6162
- for (const primitiveManager of this.primitiveManagers.values()) {
6163
- primitiveManager.subject.complete();
6242
+ for (const stompSubscription of primitiveManager.stompSubscriptions) {
6243
+ stompSubscription.unsubscribe();
6164
6244
  }
6165
- this.stompSubscriptions.clear();
6166
- this.primitiveManagers.clear();
6167
- this._stompClient.disconnect();
6168
- this._stompClient.deactivate();
6169
- this.setConnected(false);
6170
- this.isConnecting = false;
6171
- this.disconnectSubject.next();
6172
6245
  }
6246
+ for (const primitiveManager of this.primitiveManagers.values()) {
6247
+ primitiveManager.subject.complete();
6248
+ }
6249
+ this.primitiveManagers.clear();
6250
+ this._stompClient.disconnect();
6251
+ this._stompClient.deactivate();
6252
+ this.setConnected(false);
6253
+ this.isConnecting = false;
6254
+ this.wasConnected = false;
6255
+ this.disconnect$.next();
6173
6256
  }
6174
6257
  isConnected() {
6175
6258
  return this.connected;
@@ -6196,45 +6279,60 @@ let WebsocketService = WebsocketService_1 = class WebsocketService {
6196
6279
  createStompClient() {
6197
6280
  const ws = new SockJS(`${WebsocketService_1.WEBSOCKET_URL}subscription`, null, { timeout: WebsocketService_1.CONNECTION_TIMEOUT });
6198
6281
  this._stompClient = Stomp.over(ws);
6282
+ // this._stompClient.debug = (str) => console.log(new Date().toISOString(), str);
6199
6283
  this._stompClient.debug = () => { }; // Para remover os logs.
6200
6284
  }
6201
- getBaseUrl() {
6202
- return this.cookieService.get("com.senior.base.url");
6203
- }
6204
- getUserName() {
6205
- const token = this.cookieService.get("com.senior.token");
6206
- return token && JSON.parse(token).username;
6207
- }
6208
- reconnectWebSocket() {
6209
- this._stompClient.disconnect();
6210
- const baseUrl = this.getBaseUrl();
6211
- if (this.baseUrl !== null && baseUrl != this.baseUrl) {
6212
- return;
6213
- }
6214
- const username = this.getUserName();
6215
- if (this.username !== null && username != this.username) {
6216
- return;
6217
- }
6285
+ reconnect() {
6286
+ if (this.connected)
6287
+ this._stompClient.disconnect();
6218
6288
  setTimeout(() => {
6289
+ if (this.getObserversCount() === 0)
6290
+ return;
6219
6291
  if (this.focused) {
6220
6292
  this.connect();
6221
6293
  }
6222
6294
  else {
6223
- this.reconnectWebSocket();
6295
+ this.reconnect();
6224
6296
  }
6225
6297
  }, WebsocketService_1.RECONNECT_TIMER);
6226
6298
  }
6299
+ reconnectPrimitives() {
6300
+ for (const primitiveManager of this.primitiveManagers.values()) {
6301
+ for (const stompSubscription of primitiveManager.stompSubscriptions) {
6302
+ stompSubscription.unsubscribe();
6303
+ }
6304
+ this.createStompSubscriptions(primitiveManager);
6305
+ }
6306
+ }
6307
+ getObserversCount() {
6308
+ let observersCount = 0;
6309
+ for (const primitiveManager of this.primitiveManagers.values()) {
6310
+ observersCount += primitiveManager.subject.observers.length;
6311
+ }
6312
+ return observersCount;
6313
+ }
6314
+ disconnectPrimitiveOnFinalize(primitive) {
6315
+ const primitiveManager = this.primitiveManagers.get(primitive);
6316
+ if (!primitiveManager)
6317
+ return;
6318
+ // @IMPORTANT: Replace .observers.length with .observed in rxjs 7.0+
6319
+ const hasObservers = !(primitiveManager.subject.observers.length === 1);
6320
+ if (hasObservers)
6321
+ return;
6322
+ for (const stompSubscription of primitiveManager.stompSubscriptions) {
6323
+ stompSubscription.unsubscribe();
6324
+ }
6325
+ this.primitiveManagers.delete(primitive);
6326
+ this.disconnect();
6327
+ }
6227
6328
  };
6228
6329
  WebsocketService.RECONNECT_TIMER = 3000;
6229
- WebsocketService.CONNECTION_TIMEOUT = 30000;
6330
+ WebsocketService.CONNECTION_TIMEOUT = 15000;
6230
6331
  WebsocketService.BASE_URL_COOKIE = "com.senior.base.url";
6231
6332
  WebsocketService.TOKEN_COOKIE = "com.senior.token";
6232
6333
  WebsocketService.TOKEN = JSON.parse(get(WebsocketService_1.TOKEN_COOKIE) || "{}");
6233
6334
  WebsocketService.WEBSOCKET_URL = get(WebsocketService_1.BASE_URL_COOKIE) + "/websocket/";
6234
- WebsocketService.ctorParameters = () => [
6235
- { type: CookieService }
6236
- ];
6237
- WebsocketService.ɵprov = ɵɵdefineInjectable({ factory: function WebsocketService_Factory() { return new WebsocketService(ɵɵinject(CookieService)); }, token: WebsocketService, providedIn: "root" });
6335
+ WebsocketService.ɵprov = ɵɵdefineInjectable({ factory: function WebsocketService_Factory() { return new WebsocketService(); }, token: WebsocketService, providedIn: "root" });
6238
6336
  WebsocketService = WebsocketService_1 = __decorate([
6239
6337
  Injectable({
6240
6338
  providedIn: "root",
@@ -6315,5 +6413,5 @@ var ModulesEnum;
6315
6413
  * Generated bundle index. Do not edit.
6316
6414
  */
6317
6415
 
6318
- export { BankLookup, BreadcrumbComponent, BreadcrumbModule, Breakpoints, CountryLookup, CplTriNotaSaidaE001EndLookup, CplTriNotaSaidaE001PesLookup, CplTriNotaSaidaE001TnsLookup, CplTriNotaSaidaE007UfsLookup, CplTriNotaSaidaE008RaiLookup, CplTriNotaSaidaE015MedLookup, CplTriNotaSaidaE020SnfLookup, CplTriNotaSaidaE024MsgLookup, CplTriNotaSaidaE028CpgLookup, CplTriNotaSaidaE032EdcLookup, CplTriNotaSaidaE051DisLookup, CplTriNotaSaidaE066FpgLookup, CplTriNotaSaidaE070EmpLookup, CplTriNotaSaidaE070FilLookup, CplTriNotaSaidaE075DerLookup, CplTriNotaSaidaE080SerLookup, CplTriNotaSaidaNaturezaReceitaPisCofinsLookup, CplTriNotaSaidaNcmLookup, CplTriNotaSaidaNfEntradaLookup, CplTriNotaSaidaNfSaidaLookup, CurrencyLookup, E001EndLookup, E001PesLookup, E001TnsLookup, E001TnsSupEstLookup, E002TptLookup, E007UfsLookup, E008CepLookup, E008RaiLookup, E012FamLookup, E015MedLookup, E020SnfLookup, E021MotLookup, E023CrpLookup, E024MsgLookup, E027EqiLookup, E027StrLookup, E028CpgLookup, E030AgeLookup, E030BanLookup, E031MoeLookup, E032EdcLookup, E035OcrLookup, E036InsLookup, E039PorLookup, E044CcuFinRatDepLookup, E044CcuLookup, E045PlaLookup, E046HpdLookup, E047NtgLookup, E048FctLookup, E048SfcLookup, E051DisLookup, E066FpgLookup, E067FinLookup, E070EmpLookup, E070EntLookup, E070FilLookup, E073PesLookup, E073VeiLookup, E075DerLookup, E080SerLookup, E082TprLookup, E085PesLookup, E090PesLookup, E091PlfFinRatLookup, E095PesLookup, E099UsuComGerLookup, E140InsLookup, E140NfsLookup, E200LotLookup, E200SerLookup, E205DepLookup, E210DxpE075DerLookup, E210DxpLookup, E301TcrLookup, E403FprLookup, E420IcpLookup, E420IpcLookup, E420OcpLookup, E600CcoLookup, E640LotLookup, EnumLogicalOperator, EquipmentLookup, ErpLookups, ErpLookupsModule, ErpPolling, ExportUtils, FiltersStorageService, FormUtilsService, LigacaoItemFornecedorLookup, LookupValidationUtils, ModulesEnum, NcmLookup, NpsService, ParametersLookup, ProdutoServicoLookup, QuantidadeDisponivelDemandaLookup, RequisicaoLookup, TypeTaxesLookup, UnidadeMedidaLookup, UtilsModule, VerifyModulePermission, WebsocketService, naturezaReceitaPisCofins, ErpLookupsService as ɵa, StorageService as ɵb, VerifyModulePermissionService as ɵc };
6416
+ export { BankLookup, BeneficioFiscalLookup, BreadcrumbComponent, BreadcrumbModule, Breakpoints, CountryLookup, CplTriNotaSaidaE001EndLookup, CplTriNotaSaidaE001PesLookup, CplTriNotaSaidaE001TnsLookup, CplTriNotaSaidaE007UfsLookup, CplTriNotaSaidaE008RaiLookup, CplTriNotaSaidaE015MedLookup, CplTriNotaSaidaE020SnfLookup, CplTriNotaSaidaE024MsgLookup, CplTriNotaSaidaE028CpgLookup, CplTriNotaSaidaE032EdcLookup, CplTriNotaSaidaE051DisLookup, CplTriNotaSaidaE066FpgLookup, CplTriNotaSaidaE070EmpLookup, CplTriNotaSaidaE070FilLookup, CplTriNotaSaidaE075DerLookup, CplTriNotaSaidaE080SerLookup, CplTriNotaSaidaNaturezaReceitaPisCofinsLookup, CplTriNotaSaidaNcmLookup, CplTriNotaSaidaNfEntradaLookup, CplTriNotaSaidaNfSaidaLookup, CurrencyLookup, E001EndLookup, E001PesLookup, E001TnsLookup, E001TnsSupEstLookup, E002TptLookup, E007UfsLookup, E008CepLookup, E008RaiLookup, E012FamLookup, E015MedLookup, E020SnfLookup, E021MotLookup, E023CrpLookup, E024MsgLookup, E027EqiLookup, E027StrLookup, E028CpgLookup, E030AgeLookup, E030BanLookup, E031MoeLookup, E032EdcLookup, E035OcrLookup, E036InsLookup, E039PorLookup, E044CcuFinRatDepLookup, E044CcuLookup, E045PlaLookup, E046HpdLookup, E047NtgLookup, E048FctLookup, E048SfcLookup, E051DisLookup, E066FpgLookup, E067FinLookup, E070EmpLookup, E070EntLookup, E070FilLookup, E073PesLookup, E073VeiLookup, E075DerLookup, E080SerLookup, E082TprLookup, E085PesLookup, E090PesLookup, E091PlfFinRatLookup, E095PesLookup, E099UsuComGerLookup, E140InsLookup, E140NfsLookup, E200LotLookup, E200SerLookup, E205DepLookup, E210DxpE075DerLookup, E210DxpLookup, E301TcrLookup, E403FprLookup, E420IcpLookup, E420IpcLookup, E420OcpLookup, E600CcoLookup, E640LotLookup, EnumLogicalOperator, EquipmentLookup, ErpLookups, ErpLookupsModule, ErpPolling, ExportUtils, FiltersStorageService, FormUtilsService, LigacaoItemFornecedorLookup, LookupValidationUtils, ModulesEnum, NcmLookup, NpsService, ParametersLookup, ProdutoServicoLookup, QuantidadeDisponivelDemandaLookup, RequisicaoLookup, TypeTaxesLookup, UnidadeMedidaLookup, UtilsModule, VerifyModulePermission, WebsocketService, naturezaReceitaPisCofins, ErpLookupsService as ɵa, StorageService as ɵb, VerifyModulePermissionService as ɵc };
6319
6417
  //# sourceMappingURL=senior-gestao-empresarial-angular-components.js.map