import { BrowserModule } from '@angular/platform-browser'; import { NgModule, APP_INITIALIZER } from '@angular/core'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; import {ComponentsModule, KeycloakService, kcFactory, AzureAuthUtils} from '@esp/esp-common'; import { SidebarModule } from 'ng-sidebar'; import { GraphQLModule } from 'projects/esp-common-ui/src/app/graphql.module'; import { BsDatepickerModule } from 'ngx-bootstrap/datepicker'; import { LicenseManager } from 'ag-grid-enterprise'; import {environment} from "../environments/environment"; import {HTTP_INTERCEPTORS, HttpClientModule} from "@angular/common/http"; import { MsalGuard, MsalInterceptor, MsalBroadcastService, MsalModule, MsalService, MSAL_GUARD_CONFIG, MSAL_INSTANCE, MSAL_INTERCEPTOR_CONFIG, MsalRedirectComponent } from '@azure/msal-angular'; import {TabsModule} from 'ngx-bootstrap/tabs'; declare var CONFIG: any; if (!environment.production) { window['CONFIG'] = environment; } LicenseManager.setLicenseKey(CONFIG.AGGRID_LICENSE_KEY); const keycloakProviders = [ KeycloakService, { provide: APP_INITIALIZER, useFactory: kcFactory, deps: [KeycloakService], multi: true } ]; const msalProviders = [ { provide: HTTP_INTERCEPTORS, useClass: MsalInterceptor, multi: true }, { provide: MSAL_INSTANCE, useFactory: AzureAuthUtils.MSALInstanceFactory }, { provide: MSAL_GUARD_CONFIG, useFactory: AzureAuthUtils.MSALGuardConfigFactory }, { provide: MSAL_INTERCEPTOR_CONFIG, useFactory: AzureAuthUtils.MSALInterceptorConfigFactory }, MsalService, MsalGuard, MsalBroadcastService ]; const bootstrapComponents = environment.AZURE_AUTHENTICATION ? [AppComponent, MsalRedirectComponent] : [AppComponent]; @NgModule({ declarations: [AppComponent], imports: [ BrowserModule, ComponentsModule, BrowserAnimationsModule, AppRoutingModule, SidebarModule.forRoot(), GraphQLModule, BsDatepickerModule.forRoot(), HttpClientModule, MsalModule, TabsModule.forRoot(), ], providers: environment.AZURE_AUTHENTICATION ? msalProviders : keycloakProviders, bootstrap: bootstrapComponents, exports: [], }) export class AppModule {}