Skip to content

Commit

Permalink
feat(geo): add a error message on fail during data download (#1464)
Browse files Browse the repository at this point in the history
* feat(geo): add a error message on fail during data download

* feat(geo): add a error message on fail during data download
  • Loading branch information
pelord authored Oct 27, 2023
1 parent 13cb3e7 commit 6673979
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
24 changes: 19 additions & 5 deletions packages/geo/src/lib/offline/geoDB/configFileToGeoDB.service.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -22,12 +23,12 @@ export class ConfigFileToGeoDBService {
) {}

load(url: string) {
let downloadMessage;
let downloadMessage: ActiveToast<any>;
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;
}),
Expand Down Expand Up @@ -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$ = [
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion packages/geo/src/locale/en.geo.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion packages/geo/src/locale/fr.geo.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
Expand Down

0 comments on commit 6673979

Please sign in to comment.