2019-11-13 10:46:23 +00:00
|
|
|
import {
|
|
|
|
NgModule,
|
|
|
|
Inject,
|
|
|
|
APP_BOOTSTRAP_LISTENER,
|
|
|
|
InjectionToken, Type,
|
|
|
|
} from '@angular/core';
|
|
|
|
import { BrowserModule } from '@angular/platform-browser';
|
|
|
|
|
2022-02-03 11:00:09 +00:00
|
|
|
import { AppCommonModule,AppCommonServiceModule,AuthConfigFactory,FM_COMMON_STARTPAGE } from '@farmmaps/common';
|
2019-11-13 10:46:23 +00:00
|
|
|
|
|
|
|
import {AppRootComponent} from './app.component';
|
|
|
|
|
2020-04-17 11:26:50 +00:00
|
|
|
import {StoreModule, ActionReducer,MetaReducer} from '@ngrx/store';
|
2019-11-13 10:46:23 +00:00
|
|
|
import {EffectsModule, EffectSources} from '@ngrx/effects';
|
2021-07-27 14:26:57 +00:00
|
|
|
import { StoreRouterConnectingModule,routerReducer} from '@ngrx/router-store';
|
2019-11-13 10:46:23 +00:00
|
|
|
|
|
|
|
import {AppRoutingModule} from './app-routing.module';
|
|
|
|
import { LogoComponent } from './logo/logo.component';
|
|
|
|
import { MenuComponent } from './menu/menu.component';
|
2020-02-04 13:20:32 +00:00
|
|
|
import {RegisterDeviceComponent} from './registerdevice/registerdevice.component';
|
2020-01-22 10:33:33 +00:00
|
|
|
import { SecureOAuthStorage} from '@farmmaps/common';
|
|
|
|
import { OAuthStorage } from 'angular-oauth2-oidc';
|
2020-02-12 20:34:11 +00:00
|
|
|
import {Id4AuthconfigFactory} from './id4AuthconfigFactory';
|
2020-10-06 07:07:40 +00:00
|
|
|
import { TestComponent } from './test/test.component';
|
2020-11-02 11:24:15 +00:00
|
|
|
import { LandingpageComponent } from './landingpage/landingpage.component';
|
2019-11-13 10:46:23 +00:00
|
|
|
|
|
|
|
export const BOOTSTRAP_EFFECTS = new InjectionToken('Bootstrap Effects');
|
|
|
|
|
|
|
|
export function bootstrapEffects(effects: Type<any>[], sources: EffectSources) {
|
|
|
|
return () => {
|
|
|
|
effects.forEach(effect => sources.addEffects(effect));
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function createInstances(...instances: any[]) {
|
|
|
|
return instances;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function provideBootstrapEffects(effects: Type<any>[]) {
|
|
|
|
return [
|
|
|
|
effects,
|
|
|
|
{provide: BOOTSTRAP_EFFECTS, deps: effects, useFactory: createInstances},
|
|
|
|
{
|
|
|
|
provide: APP_BOOTSTRAP_LISTENER,
|
|
|
|
multi: true,
|
|
|
|
useFactory: bootstrapEffects,
|
|
|
|
deps: [[new Inject(BOOTSTRAP_EFFECTS)], EffectSources],
|
|
|
|
},
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2020-04-17 11:26:50 +00:00
|
|
|
// console.log all actions
|
|
|
|
export function debug(reducer: ActionReducer<any>): ActionReducer<any> {
|
|
|
|
return function(state, action) {
|
2023-04-11 09:33:11 +00:00
|
|
|
//console.debug('-- State', state);
|
|
|
|
//console.debug('-- Action', action);
|
2020-04-17 11:26:50 +00:00
|
|
|
|
|
|
|
return reducer(state, action);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export const metaReducers: MetaReducer<any>[] = [debug];
|
|
|
|
|
2019-11-13 10:46:23 +00:00
|
|
|
@NgModule({
|
|
|
|
declarations: [
|
|
|
|
AppRootComponent,
|
|
|
|
LogoComponent,
|
2020-02-04 13:20:32 +00:00
|
|
|
MenuComponent,
|
2020-10-06 07:07:40 +00:00
|
|
|
RegisterDeviceComponent,
|
2020-11-02 11:24:15 +00:00
|
|
|
TestComponent,
|
|
|
|
LandingpageComponent
|
2019-11-13 10:46:23 +00:00
|
|
|
],
|
|
|
|
imports: [
|
|
|
|
AppRoutingModule,
|
|
|
|
AppCommonModule,
|
|
|
|
AppCommonServiceModule.forRoot(),
|
|
|
|
BrowserModule,
|
2021-07-27 14:26:57 +00:00
|
|
|
StoreModule.forRoot({router:routerReducer},{metaReducers,runtimeChecks: { // TODO fix this should all be true
|
2020-04-01 14:11:44 +00:00
|
|
|
strictStateImmutability: false,
|
|
|
|
strictActionImmutability: false,
|
|
|
|
strictStateSerializability: false,
|
|
|
|
strictActionSerializability: false
|
2021-07-27 14:26:57 +00:00
|
|
|
}}),
|
|
|
|
StoreRouterConnectingModule.forRoot({stateKey:"router"}),
|
|
|
|
EffectsModule.forRoot([]),
|
2019-11-13 10:46:23 +00:00
|
|
|
],
|
2019-12-19 12:41:59 +00:00
|
|
|
providers: [
|
2020-09-25 17:27:53 +00:00
|
|
|
AuthConfigFactory,
|
2020-02-13 13:45:10 +00:00
|
|
|
{
|
|
|
|
provide:AuthConfigFactory,
|
|
|
|
useClass:Id4AuthconfigFactory
|
2022-02-03 11:00:09 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
provide: FM_COMMON_STARTPAGE,
|
|
|
|
useValue: '/map'
|
|
|
|
}
|
2019-12-19 12:41:59 +00:00
|
|
|
],
|
2019-11-13 10:46:23 +00:00
|
|
|
bootstrap: [AppRootComponent]
|
|
|
|
})
|
|
|
|
export class AppModule { }
|