Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 1 | import { ApplicationRef, NgModule } from '@angular/core'; |
| 2 | import { BrowserModule } from '@angular/platform-browser'; |
| 3 | import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http'; |
| 4 | import { FormsModule, ReactiveFormsModule } from '@angular/forms'; |
| 5 | import { AppComponent } from './app.component'; |
| 6 | import { HomeComponent } from './home/home.component'; |
| 7 | import { ApiService } from './shared'; |
| 8 | import { routing } from './app.routing'; |
| 9 | import { createNewHosts, removeNgStyles } from '@angularclass/hmr'; |
| 10 | import { BrowseSdcModule } from './browseSdc/browseSdc.module'; |
| 11 | import { VlanTaggingModule } from './vlanTagging/vlan-tagging.module' |
| 12 | import { BootstrapModalModule } from 'ng2-bootstrap-modal'; |
| 13 | import { HashLocationStrategy, LocationStrategy } from "@angular/common"; |
| 14 | import { InstantiationStatusModule } from './instantiationStatus/InstantiationStatus.module'; |
| 15 | import { SharedModule } from './shared/shared.module'; |
| 16 | import { AngularSvgIconModule } from 'angular-svg-icon'; |
| 17 | import { NgReduxModule } from '@angular-redux/store'; |
| 18 | import { StoreModule } from "./store/module"; |
| 19 | import { HttpInterceptorService } from './shared/utils/httpInterceptor/httpInterceptor.service'; |
| 20 | import { DrawingBoardModule } from './drawingBoard/drawingBoard.module'; |
| 21 | import { HealthStatusComponent } from './healthStatus/health-status.component'; |
| 22 | import { ScrollToModule } from '@nicky-lenaers/ngx-scroll-to'; |
| 23 | import { LogService } from './shared/utils/log/log.service'; |
| 24 | |
| 25 | @NgModule({ |
| 26 | imports: [ |
| 27 | BrowserModule, |
| 28 | HttpClientModule, |
| 29 | FormsModule, |
| 30 | routing, |
| 31 | SharedModule.forRoot(), |
| 32 | ScrollToModule.forRoot(), |
| 33 | DrawingBoardModule, |
| 34 | VlanTaggingModule, |
| 35 | InstantiationStatusModule, |
| 36 | BrowseSdcModule, |
| 37 | BootstrapModalModule, |
| 38 | BrowseSdcModule, |
| 39 | AngularSvgIconModule, |
| 40 | ReactiveFormsModule, |
| 41 | NgReduxModule, |
| 42 | StoreModule, |
| 43 | ], |
| 44 | declarations: [ |
| 45 | AppComponent, |
| 46 | HomeComponent, |
| 47 | HealthStatusComponent |
| 48 | ], |
| 49 | providers: [ |
| 50 | ApiService, |
| 51 | LogService, |
| 52 | { provide: LocationStrategy, useClass: HashLocationStrategy }, |
| 53 | { provide: HTTP_INTERCEPTORS, useClass: HttpInterceptorService, multi: true } |
| 54 | ], |
| 55 | bootstrap: [AppComponent] |
| 56 | }) |
| 57 | export class AppModule { |
| 58 | private static CustomLoader: any; |
| 59 | |
| 60 | constructor(public appRef: ApplicationRef) { |
| 61 | //for ng2-bootstrap-modal in angualar 5 |
| 62 | Object.defineProperty(appRef, '_rootComponents', { get: () => appRef['components'] }); |
| 63 | } |
| 64 | hmrOnInit(store) { |
| 65 | console.log('HMR store', store); |
| 66 | } |
| 67 | hmrOnDestroy(store) { |
| 68 | let cmpLocation = this.appRef.components.map(cmp => cmp.location.nativeElement); |
| 69 | // recreate elements |
| 70 | store.disposeOldHosts = createNewHosts(cmpLocation); |
| 71 | // remove styles |
| 72 | removeNgStyles(); |
| 73 | } |
| 74 | hmrAfterDestroy(store) { |
| 75 | // display new elements |
| 76 | store.disposeOldHosts(); |
| 77 | delete store.disposeOldHosts; |
| 78 | } |
| 79 | } |