147 lines
5.2 KiB
TypeScript
147 lines
5.2 KiB
TypeScript
import { APP_INITIALIZER, ApplicationConfig, ErrorHandler } from '@angular/core';
|
|
import { provideRouter, withEnabledBlockingInitialNavigation, withInMemoryScrolling } from '@angular/router';
|
|
|
|
import { HTTP_INTERCEPTORS, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
|
|
import { provideAnimations } from '@angular/platform-browser/animations';
|
|
import { KeycloakBearerInterceptor, KeycloakService } from 'keycloak-angular';
|
|
import { GALLERY_CONFIG, GalleryConfig } from 'ng-gallery';
|
|
import { provideQuillConfig } from 'ngx-quill';
|
|
import { provideShareButtonsOptions, SharerMethods, withConfig } from 'ngx-sharebuttons';
|
|
import { shareIcons } from 'ngx-sharebuttons/icons';
|
|
import { provideNgxStripe } from 'ngx-stripe';
|
|
import { routes } from './app.routes';
|
|
import { LoadingInterceptor } from './interceptors/loading.interceptor';
|
|
import { TimeoutInterceptor } from './interceptors/timeout.interceptor';
|
|
import { GlobalErrorHandler } from './services/globalErrorHandler';
|
|
import { KeycloakInitializerService } from './services/keycloak-initializer.service';
|
|
import { SelectOptionsService } from './services/select-options.service';
|
|
import { createLogger } from './utils/utils';
|
|
// provideClientHydration()
|
|
const logger = createLogger('ApplicationConfig');
|
|
export const appConfig: ApplicationConfig = {
|
|
providers: [
|
|
provideHttpClient(withInterceptorsFromDi()),
|
|
{ provide: KeycloakService },
|
|
{
|
|
provide: APP_INITIALIZER,
|
|
// useFactory: initializeKeycloak1,
|
|
//useFactory: initializeKeycloak2,
|
|
useFactory: initializeKeycloak,
|
|
multi: true,
|
|
//deps: [KeycloakService],
|
|
deps: [KeycloakInitializerService],
|
|
},
|
|
{
|
|
provide: APP_INITIALIZER,
|
|
useFactory: initServices,
|
|
multi: true,
|
|
deps: [SelectOptionsService],
|
|
},
|
|
{
|
|
provide: HTTP_INTERCEPTORS,
|
|
useClass: LoadingInterceptor,
|
|
multi: true,
|
|
},
|
|
{
|
|
provide: HTTP_INTERCEPTORS,
|
|
useClass: KeycloakBearerInterceptor,
|
|
multi: true,
|
|
},
|
|
{
|
|
provide: HTTP_INTERCEPTORS,
|
|
useClass: TimeoutInterceptor,
|
|
multi: true,
|
|
},
|
|
{
|
|
provide: 'TIMEOUT_DURATION',
|
|
useValue: 5000, // Standard-Timeout von 5 Sekunden
|
|
},
|
|
{
|
|
provide: GALLERY_CONFIG,
|
|
useValue: {
|
|
autoHeight: true,
|
|
imageSize: 'cover',
|
|
} as GalleryConfig,
|
|
},
|
|
{ provide: ErrorHandler, useClass: GlobalErrorHandler }, // Registriere den globalen ErrorHandler
|
|
provideShareButtonsOptions(
|
|
shareIcons(),
|
|
withConfig({
|
|
debug: true,
|
|
sharerMethod: SharerMethods.Anchor,
|
|
}),
|
|
),
|
|
provideRouter(
|
|
routes,
|
|
withEnabledBlockingInitialNavigation(),
|
|
withInMemoryScrolling({
|
|
scrollPositionRestoration: 'enabled',
|
|
anchorScrolling: 'enabled',
|
|
}),
|
|
),
|
|
provideAnimations(),
|
|
provideNgxStripe('pk_test_IlpbVQhxAXZypLgnCHOCqlj8'),
|
|
provideQuillConfig({
|
|
modules: {
|
|
syntax: true,
|
|
toolbar: [
|
|
['bold', 'italic', 'underline'], // Einige Standardoptionen
|
|
[{ header: [1, 2, 3, false] }], // Benutzerdefinierte Header
|
|
[{ list: 'ordered' }, { list: 'bullet' }],
|
|
[{ color: [] }], // Dropdown mit Standardfarben
|
|
['clean'], // Entfernt Formatierungen
|
|
],
|
|
},
|
|
}),
|
|
],
|
|
};
|
|
function initServices(selectOptions: SelectOptionsService) {
|
|
return async () => {
|
|
await selectOptions.init();
|
|
};
|
|
}
|
|
export function initializeKeycloak(keycloak: KeycloakInitializerService) {
|
|
return () => keycloak.initialize();
|
|
}
|
|
|
|
// export function initializeKeycloak1(keycloak: KeycloakService): () => Promise<void> {
|
|
// return async () => {
|
|
// const { url, realm, clientId } = environment.keycloak;
|
|
// const adapter = customKeycloakAdapter(() => keycloak.getKeycloakInstance(), {});
|
|
// if (window.location.search.length > 0) {
|
|
// sessionStorage.setItem('SEARCH', window.location.search);
|
|
// }
|
|
// const { host, hostname, href, origin, pathname, port, protocol, search } = window.location;
|
|
// await keycloak.init({
|
|
// config: { url, realm, clientId },
|
|
// initOptions: {
|
|
// onLoad: 'check-sso',
|
|
// silentCheckSsoRedirectUri: window.location.hostname === 'localhost' ? `${window.location.origin}/assets/silent-check-sso.html` : `${window.location.origin}/dealerweb/assets/silent-check-sso.html`,
|
|
// adapter,
|
|
// redirectUri: `${origin}${pathname}`,
|
|
// },
|
|
// });
|
|
// };
|
|
// }
|
|
// function initializeKeycloak2(keycloak: KeycloakService) {
|
|
// return async () => {
|
|
// logger.info(`###>calling keycloakService init ...`);
|
|
// const authenticated = await keycloak.init({
|
|
// config: {
|
|
// url: environment.keycloak.url,
|
|
// realm: environment.keycloak.realm,
|
|
// clientId: environment.keycloak.clientId,
|
|
// },
|
|
// initOptions: {
|
|
// onLoad: 'check-sso',
|
|
// silentCheckSsoRedirectUri: (<any>window).location.origin + '/assets/silent-check-sso.html',
|
|
// },
|
|
// bearerExcludedUrls: ['/assets'],
|
|
// shouldUpdateToken(request) {
|
|
// return !request.headers.get('token-update') === false;
|
|
// },
|
|
// });
|
|
// logger.info(`+++>${authenticated}`);
|
|
// };
|
|
// }
|