Files
smartguide/webapp/src/app/app.config.ts
T
Roman 98ef93f642
LocationBasedServices/smartguide/pipeline/head This commit looks good
LocationBasedServices/smartguide/pipeline/pr-dev This commit looks good
Merge branch 'dev' of https://project.nes.uni-due.de/gitea/lbs/smartguide into company-connections
2026-06-18 18:48:28 +02:00

80 lines
2.6 KiB
TypeScript

import { ApplicationConfig, inject, LOCALE_ID } from '@angular/core';
import {
NavigationError,
provideRouter,
Router,
withComponentInputBinding,
withNavigationErrorHandler,
} from '@angular/router';
import { routes } from './app.routes';
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
import {
HttpErrorResponse,
provideHttpClient,
withInterceptors,
} from '@angular/common/http';
import locale from '@angular/common/locales/de';
import { registerLocaleData } from '@angular/common';
import { authenticationInterceptor } from './shared/interceptors/authentication.interceptor';
import { MAT_FORM_FIELD_DEFAULT_OPTIONS } from '@angular/material/form-field';
import { MatPaginatorIntl } from '@angular/material/paginator';
import { PaginatorIntl } from './shared/utils/paginatorIntl';
import { provideEchartsCore } from 'ngx-echarts';
import { ErrorService } from './shared/services/error.service';
registerLocaleData(locale);
export const appConfig: ApplicationConfig = {
providers: [
{ provide: LOCALE_ID, useValue: 'de' },
{
provide: MAT_FORM_FIELD_DEFAULT_OPTIONS,
useValue: { appearance: 'outline' },
},
{ provide: MatPaginatorIntl, useClass: PaginatorIntl },
provideRouter(
routes,
withComponentInputBinding(),
withNavigationErrorHandler((navigationError: NavigationError) => {
const router = inject(Router);
const errorService = inject(ErrorService);
if (
router.url.includes('/error') ||
router.currentNavigation()?.extractedUrl.toString().includes('/error')
) {
console.error(
'Kritischer Fehler beim Laden der Fehlerseite selbst:',
navigationError,
);
return;
}
console.error('Fehler beim Navigieren:', navigationError);
const error = navigationError.error;
let errorMessage: string = 'Unbekannter Fehler';
if (error instanceof HttpErrorResponse) {
errorMessage = error.error?.message || 'Unbekannter HTTP-Fehler';
}
errorService.setError({
statusCode: error.status || 500,
title: 'Daten-Fehler',
message: 'Die Daten für diese Ansicht konnten nicht geladen werden.',
errorDetails: errorMessage,
});
setTimeout(() => {
router.navigate(['/error'], { replaceUrl: true });
});
}),
),
provideHttpClient(withInterceptors([authenticationInterceptor])),
// provideApi('/inse-service'),
provideAnimationsAsync(),
provideEchartsCore({ echarts: () => import('echarts') }),
],
};