2018-06-25 17:03:52 +02:00
|
|
|
// angular modules
|
2018-07-23 16:42:17 +02:00
|
|
|
import { BrowserModule } from '@angular/platform-browser';
|
2018-06-25 17:03:52 +02:00
|
|
|
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
2018-09-20 13:03:51 +02:00
|
|
|
import { NgModule, APP_INITIALIZER } from '@angular/core';
|
2018-07-23 16:42:17 +02:00
|
|
|
import { HttpClientModule, HttpClient, HttpClientXsrfModule } from '@angular/common/http';
|
2018-06-25 17:03:52 +02:00
|
|
|
|
2018-07-23 16:42:17 +02:00
|
|
|
// Elementary App Components
|
2018-06-16 18:05:46 +02:00
|
|
|
import { AppRoutingModule } from './app-routing.module';
|
2018-07-23 16:42:17 +02:00
|
|
|
import { AppComponent } from './app.component';
|
|
|
|
import { CoreModule } from './core/core.module';
|
2018-07-12 14:11:31 +02:00
|
|
|
|
|
|
|
// translation module.
|
2018-06-29 17:24:44 +02:00
|
|
|
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
|
|
|
|
import { PruningTranslationLoader } from './core/pruning-loader';
|
2018-07-23 16:42:17 +02:00
|
|
|
import { LoginModule } from './site/login/login.module';
|
2018-09-20 13:03:51 +02:00
|
|
|
import { AppLoadService } from './core/services/app-load.service';
|
2018-06-29 17:24:44 +02:00
|
|
|
|
2018-07-12 14:11:31 +02:00
|
|
|
/**
|
|
|
|
* For the translation module. Loads a Custom 'translation loader' and provides it as loader.
|
|
|
|
* @param http Just the HttpClient to load stuff
|
|
|
|
*/
|
2018-09-07 13:12:59 +02:00
|
|
|
export function HttpLoaderFactory(http: HttpClient): PruningTranslationLoader {
|
2018-06-29 17:24:44 +02:00
|
|
|
return new PruningTranslationLoader(http);
|
|
|
|
}
|
2018-09-20 13:03:51 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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();
|
|
|
|
}
|
|
|
|
|
2018-07-23 16:42:17 +02:00
|
|
|
/**
|
|
|
|
* Global App Module. Keep it as clean as possible.
|
|
|
|
*/
|
2018-06-13 18:34:10 +02:00
|
|
|
@NgModule({
|
2018-07-23 16:42:17 +02:00
|
|
|
declarations: [AppComponent],
|
2018-06-19 16:55:50 +02:00
|
|
|
imports: [
|
|
|
|
BrowserModule,
|
|
|
|
HttpClientModule,
|
|
|
|
HttpClientXsrfModule.withOptions({
|
|
|
|
cookieName: 'OpenSlidesCsrfToken',
|
|
|
|
headerName: 'X-CSRFToken'
|
|
|
|
}),
|
2018-07-31 15:46:55 +02:00
|
|
|
BrowserAnimationsModule,
|
2018-06-29 17:24:44 +02:00
|
|
|
TranslateModule.forRoot({
|
|
|
|
loader: {
|
|
|
|
provide: TranslateLoader,
|
|
|
|
useFactory: HttpLoaderFactory,
|
|
|
|
deps: [HttpClient]
|
|
|
|
}
|
|
|
|
}),
|
2018-07-23 16:42:17 +02:00
|
|
|
AppRoutingModule,
|
|
|
|
CoreModule,
|
|
|
|
LoginModule
|
2018-07-12 14:11:31 +02:00
|
|
|
],
|
2018-09-20 13:03:51 +02:00
|
|
|
providers: [{ provide: APP_INITIALIZER, useFactory: AppLoaderFactory, deps: [AppLoadService], multi: true }],
|
2018-06-19 16:55:50 +02:00
|
|
|
bootstrap: [AppComponent]
|
2018-06-13 18:34:10 +02:00
|
|
|
})
|
2018-06-19 16:55:50 +02:00
|
|
|
export class AppModule {}
|