blob: a87ffb5b7423c690c26737d105247694a650b4db [file] [log] [blame]
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +03001import { ApplicationRef, NgModule } from '@angular/core';
2import { BrowserModule } from '@angular/platform-browser';
3import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
4import { FormsModule, ReactiveFormsModule } from '@angular/forms';
5import { AppComponent } from './app.component';
6import { HomeComponent } from './home/home.component';
7import { ApiService } from './shared';
8import { routing } from './app.routing';
9import { createNewHosts, removeNgStyles } from '@angularclass/hmr';
10import { BrowseSdcModule } from './browseSdc/browseSdc.module';
11import { VlanTaggingModule } from './vlanTagging/vlan-tagging.module'
12import { BootstrapModalModule } from 'ng2-bootstrap-modal';
13import { HashLocationStrategy, LocationStrategy } from "@angular/common";
14import { InstantiationStatusModule } from './instantiationStatus/InstantiationStatus.module';
15import { SharedModule } from './shared/shared.module';
16import { AngularSvgIconModule } from 'angular-svg-icon';
17import { NgReduxModule } from '@angular-redux/store';
18import { StoreModule } from "./store/module";
19import { HttpInterceptorService } from './shared/utils/httpInterceptor/httpInterceptor.service';
20import { DrawingBoardModule } from './drawingBoard/drawingBoard.module';
21import { HealthStatusComponent } from './healthStatus/health-status.component';
22import { ScrollToModule } from '@nicky-lenaers/ngx-scroll-to';
23import { 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})
57export 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}