Add error handling and snackbar notifications
Introduces error state management in LoadingService, displays error bar and snackbar notifications in the UI, and updates ScheduleComponent to use the new error handling. Also adds custom theming for error snackbar and progress bar.
This commit is contained in:
@@ -4,6 +4,7 @@ import { Vorstellung } from '@infinimotion/model-frontend';
|
||||
import { Performance } from '../model/performance.model';
|
||||
import { MovieGroup } from '../model/movie-group.model';
|
||||
import { LoadingService } from '../loading.service';
|
||||
import { catchError, map, of, tap } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'app-schedule',
|
||||
@@ -47,14 +48,19 @@ export class ScheduleComponent implements OnInit {
|
||||
|
||||
loadPerformances() {
|
||||
this.loading.show();
|
||||
this.http.getPerformaces().subscribe({
|
||||
next: (data) => {
|
||||
this.performaces = Array.isArray(data) ? data : [data];
|
||||
this.http.getPerformaces().pipe(
|
||||
map(data => Array.isArray(data) ? data : [data]),
|
||||
tap(performaces => {
|
||||
this.performaces = performaces;
|
||||
this.assignPerformancesToDates();
|
||||
},
|
||||
error: (err) => console.error('Fehler beim Laden der Performances', err),
|
||||
complete: () => this.loading.hide()
|
||||
});
|
||||
this.loading.hide();
|
||||
}),
|
||||
catchError(err => {
|
||||
this.loading.showError(err);
|
||||
console.error('Fehler beim Laden der Vorstellung', err);
|
||||
return of([]);
|
||||
})
|
||||
).subscribe();
|
||||
}
|
||||
|
||||
assignPerformancesToDates() {
|
||||
|
||||
Reference in New Issue
Block a user