diff --git a/packages/geo/src/lib/offline/geoDB/configFileToGeoDB.service.ts b/packages/geo/src/lib/offline/geoDB/configFileToGeoDB.service.ts index 5a0ab71dae..91dccf45be 100644 --- a/packages/geo/src/lib/offline/geoDB/configFileToGeoDB.service.ts +++ b/packages/geo/src/lib/offline/geoDB/configFileToGeoDB.service.ts @@ -1,9 +1,10 @@ -import { HttpClient } from '@angular/common/http'; +import { HttpClient, HttpErrorResponse } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { MessageService } from '@igo2/core'; import { default as JSZip } from 'jszip'; +import { ActiveToast } from 'ngx-toastr'; import { of, zip } from 'rxjs'; import { catchError, concatMap } from 'rxjs/operators'; @@ -22,12 +23,12 @@ export class ConfigFileToGeoDBService { ) {} load(url: string) { - let downloadMessage; + let downloadMessage: ActiveToast; this.http .get(url) .pipe( - catchError((error: any): any => { - console.log(`GeoData file ${url} could not be read`); + catchError((error: HttpErrorResponse) => { + this.messageService.error(`GeoData file ${url} could not be read`); error.error.caught = true; throw error; }), @@ -69,6 +70,19 @@ export class ConfigFileToGeoDBService { responseType = 'arraybuffer'; } return this.http.get(url, { responseType }).pipe( + catchError((error: HttpErrorResponse) => { + this.messageService.remove( + downloadMessage.toastId + ); + this.messageService.success( + 'igo.geo.indexedDb.data-download-failed', + undefined, + { timeOut: 40000 } + ); + + error.error.caught = true; + throw error; + }), concatMap((r) => { if (isZip) { const observables$ = [ @@ -145,7 +159,7 @@ export class ConfigFileToGeoDBService { .subscribe(() => { if (downloadMessage) { setTimeout(() => { - this.messageService.remove((downloadMessage as any).toastId); + this.messageService.remove(downloadMessage.toastId); this.messageService.success( 'igo.geo.indexedDb.data-download-completed', undefined, diff --git a/packages/geo/src/locale/en.geo.json b/packages/geo/src/locale/en.geo.json index a046db4164..250b4a6e24 100644 --- a/packages/geo/src/locale/en.geo.json +++ b/packages/geo/src/locale/en.geo.json @@ -807,7 +807,8 @@ }, "indexedDb": { "data-download-start": "Downloading data. Please don't leave the current app.", - "data-download-completed": "Data download completed" + "data-download-completed": "Data download completed", + "data-download-failed": "Data download failed. Please contact your application manager." } } } diff --git a/packages/geo/src/locale/fr.geo.json b/packages/geo/src/locale/fr.geo.json index 7d912c8e0b..326d1858ac 100644 --- a/packages/geo/src/locale/fr.geo.json +++ b/packages/geo/src/locale/fr.geo.json @@ -808,7 +808,8 @@ }, "indexedDb": { "data-download-start": "Téléchargement des données. Veuillez ne pas quitter.", - "data-download-completed": "Téléchargement des données terminées." + "data-download-completed": "Téléchargement des données terminées.", + "data-download-failed": "Échec du téléchargement des données pour utilisation hors ligne. Contacter le support de l'application" } } }