/** Angular Imports */ import { NgModule , Optional , SkipSelf } from '@angular/core' ; import { HTTP_INTERCEPTORS , HttpClient , HttpClientModule } from '@angular/common/http' ; import { RouteReuseStrategy , RouterModule } from '@angular/router' ; /** Translation Imports */ import { TranslateModule , TranslateLoader } from '@ngx-translate/core' ; import { TranslateHttpLoader } from '@ngx-translate/http-loader' ; /** Custom Services */ import { AuthenticationService } from './authentication/authentication.service' ; import { HttpService } from './http/http.service' ; import { HttpCacheService } from './http/http-cache.service' ; import { ProgressBarService } from './progress-bar/progress-bar.service' ; import { I18nService } from './i18n/i18n.service' ; /** Custom Guards */ import { AuthenticationGuard } from './authentication/authentication.guard' ; /** Custom Interceptors */ import { ProgressInterceptor } from './progress-bar/progress.interceptor' ; import { ApiPrefixInterceptor } from './http/api-prefix.interceptor' ; import { ErrorHandlerInterceptor } from './http/error-handler.interceptor' ; import { CacheInterceptor } from './http/cache.interceptor' ; import { AuthenticationInterceptor } from './authentication/authentication.interceptor' ; /** Custom Strategies */ import { RouteReusableStrategy } from './route/route-reusable-strategy' ; /** Custom Modules */ import { SharedModule } from '../shared/shared.module' ; import { NotificationsModule } from '../notifications/notifications.module' ; import { SearchModule } from 'app/search/search.module' ; /** Custom Components */ import { ShellComponent } from './shell/shell.component' ; import { SidenavComponent } from './shell/sidenav/sidenav.component' ; import { ToolbarComponent } from './shell/toolbar/toolbar.component' ; import { BreadcrumbComponent } from './shell/breadcrumb/breadcrumb.component' ; import { ContentComponent } from './shell/content/content.component' ; /**
 * Core Module
 *
 * Main app shell components and singleton services should be here.
 */ @ NgModule ( { imports : [ SharedModule , HttpClientModule , TranslateModule . forRoot ( { loader : { provide : TranslateLoader , useFactory : ( http ) => { return new TranslateHttpLoader ( http , `${ window . location . protocol }//${ window . location . host }/assets/translations/` , '.json' ) ; } , deps : [ HttpClient ] } } ) , RouterModule ] , declarations : [ ShellComponent , SidenavComponent , ToolbarComponent , BreadcrumbComponent , ContentComponent ] , exports : [ SharedModule ] , providers : [ AuthenticationService , AuthenticationGuard , AuthenticationInterceptor , { provide : HTTP_INTERCEPTORS , useClass : AuthenticationInterceptor , multi : true } , I18nService , HttpCacheService , ApiPrefixInterceptor , ErrorHandlerInterceptor , CacheInterceptor , { provide : HttpClient , useClass : HttpService } , ProgressBarService , { provide : HTTP_INTERCEPTORS , useClass : ProgressInterceptor , multi : true } , { provide : RouteReuseStrategy , useClass : RouteReusableStrategy } ] } ) export class CoreModule { constructor ( @ Optional ( ) @ SkipSelf ( ) parentModule ) { if ( parentModule ) { throw new Error ( `${ parentModule } has already been loaded. Import Core module in the AppModule only.` ) ; } } }