import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; // this is needed!
import {Injector, LOCALE_ID, NgModule} from '@angular/core';
import { HttpClientModule, HttpClient } from '@angular/common/http';
import { HttpModule  } from '@angular/http';
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';

import { AppComponent } from './app.component';

import { CoreModule } from './core/core.module';
import { LayoutModule } from './layout/layout.module';
import { SharedModule } from './shared/shared.module';
import { RoutesModule } from './routes/routes.module';
import { FrameRequest } from './shared/frame/frame-request';
import { FrameVariable } from './shared/frame/frame-variable';
import {ANIMATION_TYPES, LoadingModule} from 'ngx-loading';
import { log } from 'util';

//预加载
import { HmSoftModule } from './routes/hm-soft/hmsoft.module';

// https://github.com/ocombe/ng2-translate/issues/218
export function createTranslateLoader(http: HttpClient) {
    return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}
// 用于获取静态注入的类
export let InjectorInstance: Injector;

@NgModule({
  declarations: [AppComponent],
    imports: [
        HttpClientModule,
        HttpModule,
        BrowserAnimationsModule, // required for ng2-tag-input
        CoreModule,
        LayoutModule,
        SharedModule.forRoot(),
        HmSoftModule,
        RoutesModule,
        // 等待提示框
        LoadingModule.forRoot({
          animationType: ANIMATION_TYPES.circleSwish,
          fullScreenBackdrop: true,
          backdropBackgroundColour: 'rgba(0,0,0,0.3)',
          backdropBorderRadius: '4px',
          primaryColour: '#1E90FF',
          secondaryColour: '#ffffff',
          tertiaryColour: '#ffffff'
        }),
        TranslateModule.forRoot({
            loader: {
                provide: TranslateLoader,
                useFactory: (createTranslateLoader),
                deps: [HttpClient]
            }
        })
    ],
    providers: [
    ],
    bootstrap: [AppComponent]
})
export class AppModule {

  constructor(private injector: Injector) {
	InjectorInstance = this.injector;
	localStorage.clear();
    FrameRequest.request('frame/optr/initGx.htm', { }, (data) => {
        FrameVariable.InitFrameVariable(data.map);
    });
  }
}
