@arsedizioni/ars-utils 22.0.11 → 22.0.13

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,8 +4,7 @@ import { HttpClient, HttpHeaders, HttpRequest, HttpErrorResponse } from '@angula
4
4
  import { BroadcastService, SystemUtils } from '@arsedizioni/ars-utils/core';
5
5
  import { EMPTY, throwError, of, catchError as catchError$1 } from 'rxjs';
6
6
  import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
7
- import { DialogService } from '@arsedizioni/ars-utils/ui';
8
- import { catchError, finalize, map } from 'rxjs/operators';
7
+ import { catchError, map, finalize } from 'rxjs/operators';
9
8
 
10
9
  const ClipperMessages = {
11
10
  /**
@@ -13,13 +12,16 @@ const ClipperMessages = {
13
12
  */
14
13
  // Error
15
14
  ERROR: '§clipper-error',
15
+ SUCCESS: '§clipper-success',
16
+ SUCCESS_TOAST: '§clipper-success-toast',
16
17
  // Login
17
18
  LOGIN_CHANGED: '§clipper-login-changed',
18
19
  LOGIN_COMPLETED: '§clipper-login-completed',
19
- LOGOUT_COMPLETED: '§clipper-logout-completed',
20
20
  LOGIN_PENDING: '§clipper-login-pending',
21
21
  LOGIN_FAILED: '§clipper-login-failed',
22
22
  LOGOUT: '§clipper-logout',
23
+ LOGOUT_COMPLETED: '§clipper-logout-completed',
24
+ LOGOUT_FAILED: '§clipper-logout-failed',
23
25
  // Document
24
26
  DOCUMENT_READ: '$clipper-document-read',
25
27
  DOCUMENT_NAVIGATE: '$clipper-document-navigate',
@@ -2194,7 +2196,6 @@ class ClipperService {
2194
2196
  this.httpClient = inject(HttpClient);
2195
2197
  this.destroyRef = inject(DestroyRef);
2196
2198
  this.broadcastService = inject(BroadcastService);
2197
- this.dialogService = inject(DialogService);
2198
2199
  this.broadcastInitialized = false;
2199
2200
  this._serviceUri = '';
2200
2201
  this._flags = ClipperServiceFlags.None;
@@ -2280,13 +2281,13 @@ class ClipperService {
2280
2281
  next: r => {
2281
2282
  if (!r.success) {
2282
2283
  if ((this.flags & ClipperServiceFlags.DisplayConnectionStateMessages) > 0) {
2283
- this.dialogService.error("Le credenziali di accesso sono cambiate o non sono più valide. Esegui un nuovo accesso.", undefined, "Errore di Clipper");
2284
+ this.broadcastService.sendMessage(ClipperMessages.ERROR, { message: "Le credenziali di accesso sono cambiate o non sono più valide. Esegui un nuovo accesso." });
2284
2285
  }
2285
2286
  this.broadcastService.sendMessage(ClipperMessages.LOGIN_FAILED);
2286
2287
  }
2287
2288
  else {
2288
2289
  if ((this.flags & ClipperServiceFlags.DisplayConnectionStateMessages) > 0) {
2289
- this.dialogService.toast('Connesso a Clipper', 1500, 'power');
2290
+ this.broadcastService.sendMessage(ClipperMessages.SUCCESS_TOAST, { message: "Connesso a Clipper", icon: 'power', duration: 1500 });
2290
2291
  }
2291
2292
  // Load bag
2292
2293
  this.loadBag();
@@ -2300,12 +2301,12 @@ class ClipperService {
2300
2301
  this.logout().subscribe(r => {
2301
2302
  if (!r.success) {
2302
2303
  if (r.message) {
2303
- this.dialogService.error("<p>" + r.message + "</p><br><br><hr><p class='small'><i>Per eliminare la configurazione di Clipper accedere a:<br><b>menu > personalizza > collegamenti</b></i></p>", undefined, "Errore di Clipper");
2304
+ this.broadcastService.sendMessage(ClipperMessages.ERROR, { message: "<p>" + r.message + "</p><br><br><hr><p class='small'><i>Per eliminare la configurazione di Clipper accedere a:<br><b>menu > personalizza > collegamenti</b></i></p>" });
2304
2305
  }
2305
2306
  }
2306
2307
  else {
2307
2308
  if ((this.flags & ClipperServiceFlags.DisplayConnectionStateMessages) > 0) {
2308
- this.dialogService.toast('Disconnesso da Clipper', 1500, 'power_off');
2309
+ this.broadcastService.sendMessage(ClipperMessages.SUCCESS_TOAST, { message: "Disconnesso da Clipper", icon: 'power_off', duration: 1500 });
2309
2310
  }
2310
2311
  // Empty bag
2311
2312
  this.bag.set([]);
@@ -2360,22 +2361,21 @@ class ClipperService {
2360
2361
  */
2361
2362
  autoLogin(onSuccess) {
2362
2363
  this.login(undefined, undefined, true)
2363
- .pipe(finalize(() => this.dialogService.clearBusy()))
2364
2364
  .subscribe({
2365
2365
  next: r => {
2366
2366
  if (!r.success) {
2367
- this.dialogService.error(r.message, undefined, "Errore in Clipper");
2367
+ this.broadcastService.sendMessage(ClipperMessages.ERROR, { message: r.message });
2368
2368
  }
2369
2369
  else {
2370
2370
  if (!r.value.requiresMfa) {
2371
- this.dialogService.toast('Connesso a Clipper', 1500, 'power');
2371
+ this.broadcastService.sendMessage(ClipperMessages.SUCCESS_TOAST, { message: "Connesso a Clipper", icon: 'power', duration: 1500 });
2372
2372
  }
2373
2373
  if (onSuccess) {
2374
2374
  onSuccess(r.value);
2375
2375
  }
2376
2376
  }
2377
2377
  },
2378
- error: () => { this.dialogService.error("Clipper non disponibile."); }
2378
+ error: () => { this.broadcastService.sendMessage(ClipperMessages.ERROR, { message: "Clipper non disponibile." }); }
2379
2379
  });
2380
2380
  }
2381
2381
  /**
@@ -2388,17 +2388,16 @@ class ClipperService {
2388
2388
  next: r => {
2389
2389
  if (!r.success) {
2390
2390
  if (r.message) {
2391
- this.dialogService.error(r.message, undefined, "Errore in Clipper");
2391
+ this.broadcastService.sendMessage(ClipperMessages.ERROR, { message: r.message });
2392
2392
  }
2393
2393
  this.broadcastService.sendMessage(ClipperMessages.LOGIN_CHANGED);
2394
2394
  }
2395
2395
  else {
2396
- this.dialogService.toast('Disconnesso da Clipper', 1500, 'power_off');
2396
+ this.broadcastService.sendMessage(ClipperMessages.SUCCESS_TOAST, { message: "Disconnesso da Clipper", icon: 'power_off', duration: 1500 });
2397
2397
  }
2398
2398
  },
2399
2399
  error: () => { },
2400
2400
  complete: () => {
2401
- this.dialogService.clearBusy();
2402
2401
  if (onSuccess) {
2403
2402
  onSuccess();
2404
2403
  }
@@ -2799,7 +2798,7 @@ class ClipperService {
2799
2798
  .get(this.serviceUri + '/documents/working')
2800
2799
  .subscribe(r => {
2801
2800
  if (!r.success) {
2802
- this.dialogService.error(r.message);
2801
+ this.broadcastService.sendMessage(ClipperMessages.ERROR, { message: r.message });
2803
2802
  }
2804
2803
  else {
2805
2804
  if (r.value) {
@@ -2832,7 +2831,7 @@ class ClipperService {
2832
2831
  .post(this.serviceUri + '/documents/working/add', { documentIds: documentIds })
2833
2832
  .subscribe((r) => {
2834
2833
  if (!r.success) {
2835
- this.dialogService.error(r.message);
2834
+ this.broadcastService.sendMessage(ClipperMessages.LOGIN_CHANGED);
2836
2835
  }
2837
2836
  else {
2838
2837
  if (r.value) {
@@ -2852,7 +2851,7 @@ class ClipperService {
2852
2851
  if (newItems.length > 0) {
2853
2852
  this.bag.update((values) => [...values, ...newItems]);
2854
2853
  }
2855
- this.dialogService.toast('Operazione completata con successo.');
2854
+ this.broadcastService.sendMessage(ClipperMessages.SUCCESS_TOAST, { message: "Operazione completata con successo.", icon: 'check', duration: 1500 });
2856
2855
  }
2857
2856
  }
2858
2857
  });
@@ -2866,7 +2865,7 @@ class ClipperService {
2866
2865
  .post(this.serviceUri + '/documents/working/delete', { documentIds: [documentId] })
2867
2866
  .subscribe((r) => {
2868
2867
  if (!r.success) {
2869
- this.dialogService.error(r.message);
2868
+ this.broadcastService.sendMessage(ClipperMessages.ERROR, { message: r.message });
2870
2869
  }
2871
2870
  else {
2872
2871
  const p = this.bag().findIndex((n) => n.documentId === documentId);
@@ -2875,7 +2874,7 @@ class ClipperService {
2875
2874
  values.splice(p, 1);
2876
2875
  return [...values];
2877
2876
  });
2878
- this.dialogService.toast('Operazione completata con successo.');
2877
+ this.broadcastService.sendMessage(ClipperMessages.SUCCESS_TOAST, { message: "Operazione completata con successo.", icon: 'check', duration: 1500 });
2879
2878
  }
2880
2879
  }
2881
2880
  });
@@ -2888,11 +2887,11 @@ class ClipperService {
2888
2887
  .post(this.serviceUri + '/documents/working/delete', { deleteAll: true })
2889
2888
  .subscribe((r) => {
2890
2889
  if (!r.success) {
2891
- this.dialogService.error(r.message);
2890
+ this.broadcastService.sendMessage(ClipperMessages.ERROR, { message: r.message });
2892
2891
  }
2893
2892
  else {
2894
2893
  this.bag.set([]);
2895
- this.dialogService.toast('Operazione completata con successo.');
2894
+ this.broadcastService.sendMessage(ClipperMessages.SUCCESS_TOAST, { message: "Operazione completata con successo.", icon: 'check', duration: 1500 });
2896
2895
  }
2897
2896
  });
2898
2897
  }