diff --git a/frontend/src/app/_components/modal-availability-schedule/modal-availability-schedule.component.ts b/frontend/src/app/_components/modal-availability-schedule/modal-availability-schedule.component.ts index 163d417..9d66d19 100644 --- a/frontend/src/app/_components/modal-availability-schedule/modal-availability-schedule.component.ts +++ b/frontend/src/app/_components/modal-availability-schedule/modal-availability-schedule.component.ts @@ -1,6 +1,7 @@ import { Component, OnInit, ViewEncapsulation, HostListener } from '@angular/core'; import { BsModalRef } from 'ngx-bootstrap/modal'; import { ApiClientService } from 'src/app/_services/api-client.service'; +import { ToastrService } from 'ngx-toastr'; @Component({ selector: 'modal-availability-schedule', @@ -51,7 +52,11 @@ export class ModalAvailabilityScheduleComponent implements OnInit { public isSelecting = false; - constructor(public bsModalRef: BsModalRef, private api: ApiClientService) { } + constructor( + private toastr: ToastrService, + public bsModalRef: BsModalRef, + private api: ApiClientService + ) { } loadSchedules(schedules: any) { console.log("Loaded schedules", schedules); @@ -68,6 +73,9 @@ export class ModalAvailabilityScheduleComponent implements OnInit { this.orientation = window.innerHeight > window.innerWidth ? "portrait" : "landscape"; this.api.get("schedules").then((response: any) => { this.loadSchedules(response); + }).catch((err) => { + if(err.status === 500) throw err; + this.toastr.error("Errore nel caricare la programmazione oraria. Riprova."); }); } @@ -75,6 +83,9 @@ export class ModalAvailabilityScheduleComponent implements OnInit { console.log("Selected cells", this.selectedCells); this.api.post("schedules", { schedules: this.selectedCells + }).catch((err) => { + if(err.status === 500) throw err; + this.toastr.error("Errore nel salvare la programmazione oraria. Riprova."); }); this.bsModalRef.hide(); } diff --git a/frontend/src/app/_routes/edit-service/edit-service.component.ts b/frontend/src/app/_routes/edit-service/edit-service.component.ts index 49f1bcb..42d958e 100644 --- a/frontend/src/app/_routes/edit-service/edit-service.component.ts +++ b/frontend/src/app/_routes/edit-service/edit-service.component.ts @@ -92,6 +92,8 @@ export class EditServiceComponent implements OnInit { patch.crew = patch.crew.map((e: any) => e.pivot.user_id+""); patch.type = patch.type_id; this.serviceForm.patchValue(patch); + }).catch((err) => { + this.toastr.error("Errore nel caricare l'intervento. Ricarica la pagina e riprova."); }); } console.log(this.serviceId); @@ -99,6 +101,8 @@ export class EditServiceComponent implements OnInit { this.api.get("list").then((users) => { this.users = users; console.log(this.users); + }).catch((err) => { + this.toastr.error("Errore nel caricare la lista degli utenti. Ricarica la pagina e riprova."); }); this.loadTypes(); } @@ -107,6 +111,8 @@ export class EditServiceComponent implements OnInit { this.api.get("service_types").then((types) => { console.log(types); this.types = types; + }).catch((err) => { + this.toastr.error("Errore nel caricare le tipologie di intervento. Ricarica la pagina e riprova."); }); } @@ -135,6 +141,8 @@ export class EditServiceComponent implements OnInit { }); this.loadTypes(); } + }).catch((err) => { + this.toastr.error("Errore nell'aggiungere tipologia di intervento. Riprova."); }); } diff --git a/frontend/src/app/_routes/place-details/place-details.component.ts b/frontend/src/app/_routes/place-details/place-details.component.ts index 5cd3fd6..d799991 100644 --- a/frontend/src/app/_routes/place-details/place-details.component.ts +++ b/frontend/src/app/_routes/place-details/place-details.component.ts @@ -1,6 +1,7 @@ import { Component, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { ApiClientService } from 'src/app/_services/api-client.service'; +import { ToastrService } from 'ngx-toastr'; import { marker, latLng, tileLayer } from 'leaflet'; @Component({ @@ -18,7 +19,11 @@ export class PlaceDetailsComponent implements OnInit { options = {}; layers: any[] = []; - constructor(private route: ActivatedRoute, private api: ApiClientService) { + constructor( + private route: ActivatedRoute, + private api: ApiClientService, + private toastr: ToastrService + ) { this.route.paramMap.subscribe(params => { this.id = parseInt(params.get('id') || ''); @@ -58,6 +63,8 @@ export class PlaceDetailsComponent implements OnInit { ]; this.place_loaded = true; + }).catch((err) => { + this.toastr.error("Errore nel caricare i dati del luogo. Ricarica la pagina e riprova."); }); }); }