OpenSlides/client/src/app/app.module.ts

51 lines
1.9 KiB
TypeScript
Raw Normal View History

import { HttpClientModule, HttpClientXsrfModule } from '@angular/common/http';
import { APP_INITIALIZER, NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
2018-06-25 17:03:52 +02:00
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { ServiceWorkerModule } from '@angular/service-worker';
import { StorageModule } from '@ngx-pwa/local-storage';
import { AppLoadService } from './core/core-services/app-load.service';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { CoreModule } from './core/core.module';
import { environment } from '../environments/environment';
import { LoginModule } from './site/login/login.module';
import { OpenSlidesTranslateModule } from './core/translate/openslides-translate-module';
import { SlidesModule } from './slides/slides.module';
/**
* 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],
imports: [
BrowserModule,
HttpClientModule,
HttpClientXsrfModule.withOptions({
cookieName: 'OpenSlidesCsrfToken',
headerName: 'X-CSRFToken'
}),
BrowserAnimationsModule,
OpenSlidesTranslateModule.forRoot(),
AppRoutingModule,
CoreModule,
2018-12-04 19:31:24 +01:00
LoginModule,
ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production }),
SlidesModule.forRoot(),
StorageModule.forRoot({ IDBNoWrap: false })
],
providers: [{ provide: APP_INITIALIZER, useFactory: AppLoaderFactory, deps: [AppLoadService], multi: true }],
bootstrap: [AppComponent]
})
export class AppModule {}