OpenSlides/client/src/app/app.module.ts
GabrielMeyer 376f4e2a31 Implements a mechanism for a fallback theme
- If the previously selected theme is not available the default OpenSlides theme will be displayed.
- Before the current selected theme was loaded, no theme is displayed.
2019-05-07 17:32:28 +02:00

55 lines
2.1 KiB
TypeScript

// angular modules
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { NgModule, APP_INITIALIZER } from '@angular/core';
import { HttpClientModule, HttpClientXsrfModule } from '@angular/common/http';
import { PapaParseModule } from 'ngx-papaparse';
// Elementary App Components
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { CoreModule } from './core/core.module';
import { LoginModule } from './site/login/login.module';
import { AppLoadService } from './core/core-services/app-load.service';
import { SlidesModule } from './slides/slides.module';
import { OpenSlidesTranslateModule } from './core/translate/openslides-translate-module';
// PWA
import { ServiceWorkerModule } from '@angular/service-worker';
import { environment } from '../environments/environment';
import { GlobalSpinnerComponent } from './site/global-spinner/global-spinner.component';
/**
* Returns a function that returns a promis that will be resolved, if all apps are loaded.
* @param appLoadService The service that loads the apps.
*/
export function AppLoaderFactory(appLoadService: AppLoadService): () => Promise<void> {
return () => appLoadService.loadApps();
}
/**
* Global App Module. Keep it as clean as possible.
*/
@NgModule({
declarations: [AppComponent, GlobalSpinnerComponent],
imports: [
BrowserModule,
HttpClientModule,
HttpClientXsrfModule.withOptions({
cookieName: 'OpenSlidesCsrfToken',
headerName: 'X-CSRFToken'
}),
BrowserAnimationsModule,
OpenSlidesTranslateModule.forRoot(),
AppRoutingModule,
CoreModule,
LoginModule,
PapaParseModule,
ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production }),
SlidesModule.forRoot()
],
providers: [{ provide: APP_INITIALIZER, useFactory: AppLoaderFactory, deps: [AppLoadService], multi: true }],
bootstrap: [AppComponent]
})
export class AppModule {}