import { registerLocaleData } from '@angular/common';
import { HttpClientModule } from '@angular/common/http';
import zh from '@angular/common/locales/zh';
import { APP_INITIALIZER, Injector, NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { NgCortexModule } from '@ng-cortex/core';
import { NzConfig, NZ_CONFIG } from 'ng-zorro-antd/core/config';
import { NZ_I18N, zh_CN } from 'ng-zorro-antd/i18n';
import { NzNotificationModule } from 'ng-zorro-antd/notification';

import { NcBootComponent } from './nc-boot.component';
import { NcBootFactory } from './nc-boot.factory';
import { NcBootRoutingModule } from './nc-boot-routing.module';

/** NgZorroAntd配置 */
const ngZorroConfig: NzConfig = {
  card: { nzBorderless: true },
  descriptions: {
    nzBordered: true,
    nzColon: false,
    nzColumn: { xxl: 4, xl: 4, lg: 2, md: 2, sm: 1, xs: 1 },
    nzSize: 'small'
  },
  modal: { nzMaskClosable: false },
  notification: { nzPlacement: 'bottomRight' },
  pageHeader: { nzGhost: false },
  pagination: {
    nzSize: 'small',
    nzShowSizeChanger: true
  },
  table: {
    nzBordered: true,
    nzSize: 'small',
    nzShowSizeChanger: true
  }
};

/** 注册语言环境数据 */
registerLocaleData(zh);

/** NgCortex引导模块 */
@NgModule({
  bootstrap: [NcBootComponent],
  declarations: [NcBootComponent],
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    HttpClientModule,
    NzNotificationModule,
    NgCortexModule,
    NcBootRoutingModule
  ],
  providers: [
    { provide: APP_INITIALIZER, useFactory: NcBootFactory, deps: [Injector], multi: true },
    { provide: NZ_I18N, useValue: zh_CN },
    { provide: NZ_CONFIG, useValue: ngZorroConfig }
  ]
})
export class NcBootModule { }
