-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.module.ts
executable file
·88 lines (86 loc) · 3.88 KB
/
app.module.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import {LOCALE_ID, NgModule} from '@angular/core';
import {registerLocaleData} from '@angular/common';
import {HttpClient, HttpClientModule} from '@angular/common/http';
import locale from '@angular/common/locales/en';
import {BrowserModule, Title} from '@angular/platform-browser';
import {ServiceWorkerModule} from '@angular/service-worker';
import {FaIconLibrary} from '@fortawesome/angular-fontawesome';
import {MissingTranslationHandler, TranslateLoader, TranslateModule, TranslateService} from '@ngx-translate/core';
import {NgxWebstorageModule, SessionStorageService} from 'ngx-webstorage';
import * as dayjs from 'dayjs';
import {NgbDateAdapter, NgbDatepickerConfig} from '@ng-bootstrap/ng-bootstrap';
import {SERVER_API_URL} from './app.constants';
import {ApplicationConfigService} from 'app/core/config/application-config.service';
import './config/dayjs';
import {SharedModule} from 'app/shared/shared.module';
import {AppRoutingModule} from './app-routing.module';
import {HomeModule} from './home/home.module';
import {DashboardModule} from './dashboard/dashboard.module';
import {DatawarehouseModule} from './datawarehouse/datawarehouse.module';
import {EntityRoutingModule} from './entities/entity-routing.module';
import {ChartsModule} from 'ng2-charts';
// jhipster-needle-angular-add-module-import JHipster will add new module here
import {NgbDateDayjsAdapter} from './config/datepicker-adapter';
import {fontAwesomeIcons} from './config/font-awesome-icons';
import {httpInterceptorProviders} from 'app/core/interceptor/index';
import {missingTranslationHandler, translatePartialLoader} from './config/translation.config';
import {MainComponent} from './layouts/main/main.component';
import {NavbarComponent} from './layouts/navbar/navbar.component';
import {FooterComponent} from './layouts/footer/footer.component';
import {PageRibbonComponent} from './layouts/profiles/page-ribbon.component';
import {ActiveMenuDirective} from './layouts/navbar/active-menu.directive';
import {ErrorComponent} from './layouts/error/error.component';
@NgModule({
imports: [
BrowserModule,
SharedModule,
ChartsModule,
HomeModule,
DashboardModule,
DatawarehouseModule,
// jhipster-needle-angular-add-module JHipster will add new module here
EntityRoutingModule,
AppRoutingModule,
// Set this to true to enable service worker (PWA)
ServiceWorkerModule.register('ngsw-worker.js', {enabled: false}),
HttpClientModule,
NgxWebstorageModule.forRoot({prefix: 'jhi', separator: '-', caseSensitive: true}),
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: translatePartialLoader,
deps: [HttpClient],
},
missingTranslationHandler: {
provide: MissingTranslationHandler,
useFactory: missingTranslationHandler,
},
}),
],
providers: [
Title,
{provide: LOCALE_ID, useValue: 'en'},
{provide: NgbDateAdapter, useClass: NgbDateDayjsAdapter},
httpInterceptorProviders,
],
declarations: [MainComponent, NavbarComponent, ErrorComponent, PageRibbonComponent, ActiveMenuDirective, FooterComponent],
bootstrap: [MainComponent],
})
export class AppModule {
constructor(
applicationConfigService: ApplicationConfigService,
iconLibrary: FaIconLibrary,
dpConfig: NgbDatepickerConfig,
translateService: TranslateService,
sessionStorageService: SessionStorageService
) {
applicationConfigService.setEndpointPrefix(SERVER_API_URL);
registerLocaleData(locale);
iconLibrary.addIcons(...fontAwesomeIcons);
dpConfig.minDate = {year: dayjs().subtract(100, 'year').year(), month: 1, day: 1};
translateService.setDefaultLang('en');
// if user have changed language and navigates away from the application and back to the application then use previously choosed language
const langKey = sessionStorageService.retrieve('locale') ?? 'en';
translateService.use(langKey);
}
}