monkey-front-core 0.0.149 → 0.0.152

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.
@@ -2129,6 +2129,7 @@ class MonkeyEcxCommonsService {
2129
2129
  this.__onSearchChanged$ = new BehaviorSubject(null);
2130
2130
  this.__onDataChanged$ = new BehaviorSubject(null);
2131
2131
  this.__onLoadingInProgress$ = new BehaviorSubject(false);
2132
+ this.__onUploadInProgress$ = new BehaviorSubject(false);
2132
2133
  this.__onDataDeleted$ = new BehaviorSubject(null);
2133
2134
  this.__onErrorChanged$ = new BehaviorSubject(null);
2134
2135
  this.__onGovernmentIdDataChanged$ = new BehaviorSubject(null);
@@ -2149,7 +2150,7 @@ class MonkeyEcxCommonsService {
2149
2150
  }
2150
2151
  if (this.otherArgs?.router) {
2151
2152
  const { clearOnChangeRoute } = this.otherArgs?.schedule?.options || {
2152
- clearOnChangeRoute: false,
2153
+ clearOnChangeRoute: false
2153
2154
  };
2154
2155
  this.otherArgs.router.events
2155
2156
  .pipe(filter((event) => {
@@ -2165,7 +2166,7 @@ class MonkeyEcxCommonsService {
2165
2166
  }
2166
2167
  navigateToPendencyPage(arg, router) {
2167
2168
  const { companyType } = this.__tokenCredentials || {
2168
- companyType: '',
2169
+ companyType: ''
2169
2170
  };
2170
2171
  let route = '/app';
2171
2172
  if (companyType) {
@@ -2181,9 +2182,9 @@ class MonkeyEcxCommonsService {
2181
2182
  else {
2182
2183
  router.navigate([`${route}/company-pendency`.toLowerCase()], {
2183
2184
  state: {
2184
- pendencyData: arg,
2185
+ pendencyData: arg
2185
2186
  },
2186
- skipLocationChange: true,
2187
+ skipLocationChange: true
2187
2188
  });
2188
2189
  }
2189
2190
  }
@@ -2199,7 +2200,7 @@ class MonkeyEcxCommonsService {
2199
2200
  allowedSecurityAccessByPendency(args) {
2200
2201
  if (!args) {
2201
2202
  return {
2202
- hasPendencies: false,
2203
+ hasPendencies: false
2203
2204
  };
2204
2205
  }
2205
2206
  const { service, type } = args;
@@ -2239,21 +2240,21 @@ class MonkeyEcxCommonsService {
2239
2240
  403: 'forbidden',
2240
2241
  404: 'not-found',
2241
2242
  500: 'service-problems',
2242
- 503: 'service-problems',
2243
+ 503: 'service-problems'
2243
2244
  };
2244
2245
  if (!router) {
2245
2246
  console.error('Router must be declared');
2246
2247
  }
2247
2248
  else {
2248
2249
  router?.navigate([`/app/pages/${routes[statusCode]}`.toLowerCase()], {
2249
- skipLocationChange: true,
2250
+ skipLocationChange: true
2250
2251
  });
2251
2252
  }
2252
2253
  }
2253
2254
  setPage(requestPaged) {
2254
2255
  this.__requestPaged = {
2255
2256
  ...this.__requestPaged,
2256
- ...requestPaged,
2257
+ ...requestPaged
2257
2258
  };
2258
2259
  return this;
2259
2260
  }
@@ -2270,8 +2271,8 @@ class MonkeyEcxCommonsService {
2270
2271
  ...this.__requestPaged,
2271
2272
  page: {
2272
2273
  ...page,
2273
- number: number + 1,
2274
- },
2274
+ number: number + 1
2275
+ }
2275
2276
  };
2276
2277
  return true;
2277
2278
  }
@@ -2328,8 +2329,8 @@ class MonkeyEcxCommonsService {
2328
2329
  this.setPage({
2329
2330
  page: {
2330
2331
  number: 0,
2331
- size: 10,
2332
- },
2332
+ size: 10
2333
+ }
2333
2334
  });
2334
2335
  }
2335
2336
  if (otherArgs?.translateOptions) {
@@ -2372,7 +2373,7 @@ class MonkeyEcxCommonsService {
2372
2373
  getHTTPHeaderApplicationPDF() {
2373
2374
  return {
2374
2375
  observe: 'response',
2375
- responseType: 'blob',
2376
+ responseType: 'blob'
2376
2377
  };
2377
2378
  }
2378
2379
  genericMethod(link, data, callback) {
@@ -2400,8 +2401,8 @@ class MonkeyEcxCommonsService {
2400
2401
  if (!this.__onLoadingInProgress$.value) {
2401
2402
  const hasMorePages = this.setPage({
2402
2403
  page: {
2403
- ...this.__page,
2404
- },
2404
+ ...this.__page
2405
+ }
2405
2406
  }).nextPage();
2406
2407
  if (hasMorePages && this.__callbackPagination) {
2407
2408
  this.__callbackPagination();
@@ -2416,24 +2417,24 @@ class MonkeyEcxCommonsService {
2416
2417
  router.navigate([url], {
2417
2418
  queryParams: {
2418
2419
  ...search,
2419
- r: MonkeyEcxUtils.getRandomString(30),
2420
+ r: MonkeyEcxUtils.getRandomString(30)
2420
2421
  },
2421
2422
  queryParamsHandling: 'merge',
2422
- ...extras,
2423
+ ...extras
2423
2424
  });
2424
2425
  }
2425
2426
  saveState(state) {
2426
2427
  this.__savedState = {
2427
2428
  page: this.__page,
2428
- ...state,
2429
+ ...state
2429
2430
  };
2430
2431
  }
2431
2432
  }
2432
2433
  __decorate([
2433
2434
  MonkeyEcxCoreService({
2434
2435
  requestInProgress: {
2435
- showProgress: true,
2436
- },
2436
+ showProgress: true
2437
+ }
2437
2438
  })
2438
2439
  ], MonkeyEcxCommonsService.prototype, "genericMethod", null);
2439
2440
 
@@ -3663,17 +3664,25 @@ class MonkeyEcxHttpErrorHandlingService extends MonkeyEcxCommonsService {
3663
3664
  }
3664
3665
  }
3665
3666
  handleError(error, mkc) {
3666
- const { router } = this;
3667
+ const { router, tokenStorage } = this;
3667
3668
  const { status } = error;
3669
+ const { companyType } = tokenStorage?.getToken() || { companyType: '' };
3668
3670
  const routes = {
3669
3671
  403: 'forbidden',
3670
3672
  500: 'service-problems',
3671
3673
  503: 'service-problems'
3672
3674
  };
3675
+ let route = '/app';
3676
+ if (companyType) {
3677
+ route = `${route}/${companyType}/pages`;
3678
+ }
3679
+ else {
3680
+ route = `${route}/pages`;
3681
+ }
3673
3682
  const found = routes[status];
3674
3683
  let timeout = 0;
3675
3684
  if (found && !this.isHttpCodeIgnoreRedirect(mkc, error?.status)) {
3676
- const route = `/app/pages/${found}`.toLowerCase();
3685
+ route = `${route}/${found}`.toLowerCase();
3677
3686
  timeout = 800;
3678
3687
  router.navigate([route]);
3679
3688
  }
@@ -4219,6 +4228,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
4219
4228
  class MonkeyEcxLoggedHandlingService {
4220
4229
  constructor() {
4221
4230
  this.schedules = [];
4231
+ this.genericSchedules = [];
4222
4232
  // not to do
4223
4233
  }
4224
4234
  destroySchedule() {
@@ -4227,11 +4237,21 @@ class MonkeyEcxLoggedHandlingService {
4227
4237
  });
4228
4238
  this.schedules = [];
4229
4239
  }
4240
+ destroyGenericSchedule() {
4241
+ this.genericSchedules.forEach((sch) => {
4242
+ clearInterval(sch.interval);
4243
+ });
4244
+ this.genericSchedules = [];
4245
+ }
4230
4246
  addSchedule(sch) {
4231
4247
  this.schedules = sch;
4232
4248
  }
4249
+ addGenericSchedule(sch) {
4250
+ this.genericSchedules = sch;
4251
+ }
4233
4252
  destroy() {
4234
4253
  this.destroySchedule();
4254
+ this.destroyGenericSchedule();
4235
4255
  }
4236
4256
  }
4237
4257
  MonkeyEcxLoggedHandlingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxLoggedHandlingService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
@@ -4438,15 +4458,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
4438
4458
  }], ctorParameters: function () { return [{ type: i1$3.Router }]; } });
4439
4459
 
4440
4460
  class MonkeyEcxRequestScheduleService {
4441
- constructor(monkeyecxService, monkeyecxLoggedHandlingService) {
4461
+ constructor(monkeyecxService, monkeyLoggedHandlingService) {
4442
4462
  this.monkeyecxService = monkeyecxService;
4443
- this.monkeyecxLoggedHandlingService = monkeyecxLoggedHandlingService;
4463
+ this.monkeyLoggedHandlingService = monkeyLoggedHandlingService;
4444
4464
  this.schedule = [];
4465
+ this.genericSchedule = [];
4445
4466
  // not to do
4446
4467
  }
4447
4468
  addToSchedule(q) {
4448
4469
  this.schedule.push(q);
4449
- this.monkeyecxLoggedHandlingService.addSchedule(this.schedule);
4470
+ this.monkeyLoggedHandlingService.addSchedule(this.schedule);
4471
+ }
4472
+ addToGenericSchedule(q) {
4473
+ this.genericSchedule.push(q);
4474
+ this.monkeyLoggedHandlingService.addGenericSchedule(this.genericSchedule);
4450
4475
  }
4451
4476
  removeFromSchedule(q) {
4452
4477
  clearInterval(q.interval);
@@ -4454,66 +4479,121 @@ class MonkeyEcxRequestScheduleService {
4454
4479
  this.schedule = [
4455
4480
  ...saved.map((sch) => {
4456
4481
  const savedLocal = {
4457
- ...sch,
4482
+ ...sch
4458
4483
  };
4459
4484
  if (sch.id === q.id) {
4460
4485
  return null;
4461
4486
  }
4462
4487
  return savedLocal;
4463
- }),
4488
+ })
4489
+ ].filter((_) => {
4490
+ return _;
4491
+ });
4492
+ this.monkeyLoggedHandlingService.addSchedule(this.schedule);
4493
+ }
4494
+ removeFromGenericSchedule(q) {
4495
+ clearInterval(q.interval);
4496
+ const saved = [...this.genericSchedule];
4497
+ this.genericSchedule = [
4498
+ ...saved.map((sch) => {
4499
+ const savedLocal = {
4500
+ ...sch
4501
+ };
4502
+ if (sch.id === q.id) {
4503
+ return null;
4504
+ }
4505
+ return savedLocal;
4506
+ })
4464
4507
  ].filter((_) => {
4465
4508
  return _;
4466
4509
  });
4467
- this.monkeyecxLoggedHandlingService.addSchedule(this.schedule);
4510
+ this.monkeyLoggedHandlingService.addGenericSchedule(this.genericSchedule);
4468
4511
  }
4469
4512
  removeFromScheduleById(id) {
4470
4513
  const q = this.getScheduleById(id);
4471
- clearInterval(q.interval);
4514
+ clearInterval(q?.interval);
4472
4515
  const saved = [...this.schedule];
4473
4516
  this.schedule = [
4474
4517
  ...saved.map((sch) => {
4475
4518
  const savedLocal = {
4476
- ...sch,
4519
+ ...sch
4477
4520
  };
4478
- if (sch.id === q.id) {
4521
+ if (sch.id === q?.id) {
4479
4522
  return null;
4480
4523
  }
4481
4524
  return savedLocal;
4482
- }),
4525
+ })
4483
4526
  ].filter((_) => {
4484
4527
  return _;
4485
4528
  });
4486
- this.monkeyecxLoggedHandlingService.addSchedule(this.schedule);
4529
+ this.monkeyLoggedHandlingService.addSchedule(this.schedule);
4487
4530
  }
4488
4531
  doCall(sch) {
4489
- const { url, method, params, data, action } = sch;
4532
+ const { url, method, params, data, action, errorAction } = sch;
4533
+ const errAction = errorAction || ((...args) => { });
4490
4534
  this.monkeyecxService[method.toLowerCase()](`${url}`, params).subscribe((resp) => {
4491
4535
  action({
4492
4536
  ...data,
4493
- ...resp,
4537
+ ...resp
4494
4538
  }, sch);
4495
- }, () => {
4539
+ }, (err) => {
4496
4540
  this.removeFromSchedule(sch);
4541
+ errAction({
4542
+ ...data
4543
+ }, sch, err);
4544
+ });
4545
+ }
4546
+ doGenericCall(sch) {
4547
+ const { url, method, params, data, action, errorAction } = sch;
4548
+ const errAction = errorAction || ((...args) => { });
4549
+ this.monkeyecxService[method.toLowerCase()](`${url}`, params).subscribe((resp) => {
4550
+ action({
4551
+ ...data,
4552
+ ...resp
4553
+ }, sch);
4554
+ }, (err) => {
4555
+ this.removeFromGenericSchedule(sch);
4556
+ errAction({
4557
+ ...data
4558
+ }, sch, err);
4497
4559
  });
4498
4560
  }
4499
4561
  setSchedule(q, delay = 3000) {
4500
4562
  const interval = setInterval(() => {
4501
4563
  this.doCall({
4502
4564
  ...q,
4503
- interval,
4565
+ interval
4504
4566
  });
4505
4567
  }, delay);
4506
4568
  const sch = {
4507
4569
  ...q,
4508
4570
  id: `${MonkeyEcxUtils.getRandomString(40)}`,
4509
- interval,
4571
+ interval
4510
4572
  };
4511
4573
  this.addToSchedule(sch);
4512
4574
  return sch;
4513
4575
  }
4576
+ setGenericSchedule(q, delay = 3000) {
4577
+ const interval = setInterval(() => {
4578
+ this.doGenericCall({
4579
+ ...q,
4580
+ interval
4581
+ });
4582
+ }, delay);
4583
+ const sch = {
4584
+ ...q,
4585
+ id: `${MonkeyEcxUtils.getRandomString(40)}`,
4586
+ interval
4587
+ };
4588
+ this.addToGenericSchedule(sch);
4589
+ return sch;
4590
+ }
4514
4591
  removeSchedule(q) {
4515
4592
  this.removeFromSchedule(q);
4516
4593
  }
4594
+ removeGenericSchedule(q) {
4595
+ this.removeFromGenericSchedule(q);
4596
+ }
4517
4597
  removeScheduleById(id) {
4518
4598
  this.removeFromScheduleById(id);
4519
4599
  }
@@ -4529,19 +4609,30 @@ MonkeyEcxRequestScheduleService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion
4529
4609
  __decorate([
4530
4610
  MonkeyEcxCoreService({
4531
4611
  httpResponse: {
4532
- httpCodeIgnore: [400, 403, 404, 500, 503],
4612
+ httpCodeIgnore: [400, 403, 404, 500, 503]
4533
4613
  },
4534
4614
  requestInProgress: {
4535
- showProgress: false,
4536
- },
4615
+ showProgress: false
4616
+ }
4537
4617
  })
4538
4618
  ], MonkeyEcxRequestScheduleService.prototype, "doCall", null);
4619
+ __decorate([
4620
+ MonkeyEcxCoreService({
4621
+ httpResponse: {
4622
+ httpCodeIgnore: [400, 401, 403, 404, 500, 503],
4623
+ httpCodeIgnoreRedirect: [503]
4624
+ },
4625
+ requestInProgress: {
4626
+ showProgress: false
4627
+ }
4628
+ })
4629
+ ], MonkeyEcxRequestScheduleService.prototype, "doGenericCall", null);
4539
4630
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxRequestScheduleService, decorators: [{
4540
4631
  type: Injectable,
4541
4632
  args: [{
4542
- providedIn: 'root',
4633
+ providedIn: 'root'
4543
4634
  }]
4544
- }], ctorParameters: function () { return [{ type: MonkeyEcxService }, { type: MonkeyEcxLoggedHandlingService }]; }, propDecorators: { doCall: [] } });
4635
+ }], ctorParameters: function () { return [{ type: MonkeyEcxService }, { type: MonkeyEcxLoggedHandlingService }]; }, propDecorators: { doCall: [], doGenericCall: [] } });
4545
4636
 
4546
4637
  /* eslint-disable no-unused-vars */
4547
4638
  var OpSearch;