2019-03-25 16:12:42 +01:00
|
|
|
import { NgModule, Optional, SkipSelf, Type, PLATFORM_ID } from '@angular/core';
|
2018-07-23 16:42:17 +02:00
|
|
|
import { CommonModule } from '@angular/common';
|
|
|
|
import { Title } from '@angular/platform-browser';
|
|
|
|
|
2019-03-25 16:12:42 +01:00
|
|
|
import { LocalDatabase, LOCAL_STORAGE_PREFIX } from '@ngx-pwa/local-storage';
|
|
|
|
|
2019-01-31 13:40:27 +01:00
|
|
|
// Shared Components
|
2018-10-01 15:36:16 +02:00
|
|
|
import { PromptDialogComponent } from '../shared/components/prompt-dialog/prompt-dialog.component';
|
2018-11-27 22:44:37 +01:00
|
|
|
import { ChoiceDialogComponent } from '../shared/components/choice-dialog/choice-dialog.component';
|
2019-01-10 15:06:10 +01:00
|
|
|
import { ProjectionDialogComponent } from 'app/shared/components/projection-dialog/projection-dialog.component';
|
2019-03-25 16:12:42 +01:00
|
|
|
|
2019-02-01 13:56:08 +01:00
|
|
|
import { OperatorService } from './core-services/operator.service';
|
|
|
|
import { OnAfterAppsLoaded } from './onAfterAppsLoaded';
|
2019-03-25 16:12:42 +01:00
|
|
|
import { StoragelockService } from './local-storage/storagelock.service';
|
|
|
|
import { customLocalDatabaseFactory } from './local-storage/custom-indexeddb-database';
|
2019-02-01 13:56:08 +01:00
|
|
|
|
|
|
|
export const ServicesToLoadOnAppsLoaded: Type<OnAfterAppsLoaded>[] = [OperatorService];
|
2018-07-23 16:42:17 +02:00
|
|
|
|
2019-01-31 13:40:27 +01:00
|
|
|
/**
|
|
|
|
* Global Core Module.
|
2018-07-23 16:42:17 +02:00
|
|
|
*/
|
|
|
|
@NgModule({
|
|
|
|
imports: [CommonModule],
|
2019-03-25 16:12:42 +01:00
|
|
|
providers: [
|
|
|
|
Title,
|
|
|
|
// Use our own localStorage wrapper.
|
|
|
|
{
|
|
|
|
provide: LocalDatabase,
|
|
|
|
useFactory: customLocalDatabaseFactory,
|
|
|
|
deps: [PLATFORM_ID, StoragelockService, [new Optional(), LOCAL_STORAGE_PREFIX]]
|
|
|
|
}
|
|
|
|
],
|
2019-01-10 15:06:10 +01:00
|
|
|
entryComponents: [PromptDialogComponent, ChoiceDialogComponent, ProjectionDialogComponent]
|
2018-07-23 16:42:17 +02:00
|
|
|
})
|
|
|
|
export class CoreModule {
|
|
|
|
/** make sure CoreModule is imported only by one NgModule, the AppModule */
|
2018-08-29 13:21:25 +02:00
|
|
|
public constructor(
|
2018-07-23 16:42:17 +02:00
|
|
|
@Optional()
|
|
|
|
@SkipSelf()
|
|
|
|
parentModule: CoreModule
|
|
|
|
) {
|
|
|
|
if (parentModule) {
|
|
|
|
throw new Error('CoreModule is already loaded. Import only in AppModule');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|