import {NgModule, ModuleWithProviders} from '@angular/core';
import {CommonModule} from '@angular/common';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {RouterModule} from '@angular/router';
import {ToasterModule, ToasterService} from 'angular2-toaster/angular2-toaster';

import {AccordionModule} from 'ngx-bootstrap/accordion';
import {AlertModule} from 'ngx-bootstrap/alert';
import {ButtonsModule} from 'ngx-bootstrap/buttons';
import {CarouselModule} from 'ngx-bootstrap/carousel';
import {CollapseModule} from 'ngx-bootstrap/collapse';
import {BsDropdownModule} from 'ngx-bootstrap/dropdown';
import {BsModalService, ModalModule} from 'ngx-bootstrap/modal';
import {PaginationModule} from 'ngx-bootstrap/pagination';
import {ProgressbarModule} from 'ngx-bootstrap/progressbar';
import {RatingModule} from 'ngx-bootstrap/rating';
import {TabsModule} from 'ngx-bootstrap/tabs';
import {TimepickerModule} from 'ngx-bootstrap/timepicker';
import {TooltipModule} from 'ngx-bootstrap/tooltip';
import {PopoverModule} from 'ngx-bootstrap/popover';
import {TypeaheadModule} from 'ngx-bootstrap/typeahead';
import {DatepickerModule} from 'ngx-bootstrap/datepicker';
import {BsDatepickerModule} from 'ngx-bootstrap/datepicker';

import {ColorsService} from './colors/colors.service';
import {CheckallDirective} from './directives/checkall/checkall.directive';
import {NowDirective} from './directives/now/now.directive';
import {ScrollableDirective} from './directives/scrollable/scrollable.directive';
import {ngxLoadingAnimationTypes, NgxLoadingModule} from 'ngx-loading';
import {CookieService} from 'ngx-cookie-service';
import {PagerComponent} from '../core/pager/pager.component';
import {FrameDictDirective} from './directives/framedict/frame-dict.directive';
import {FrameDictPipe} from './pipe/frame-dict.pipe';
import {FrameStatusPipe} from './pipe/frame-status.pipe';
import {TreeModule} from 'angular-tree-component';
import {UploaderComponent} from '../core/uploader/uploader.component';
import {FileUploadModule} from 'ng2-file-upload';
import {TrustUrlPipe} from './pipe/trust-url.pipe';
import {FrameStatusCustomPipe} from './pipe/frame-status-custom.pipe';
import {FormMsgComponent} from '../core/msg/form-msg/form-msg.component';
import {NumberArrayPipe} from './pipe/number-array.pipe';
import {NgxSelectModule} from 'ngx-select-ex';
import {AjaxComponent} from '../core/ajax/ajax.component';
import {TrustHtmlPipe} from './pipe/trust-html.pipe';
import {FrameStylePipe} from './pipe/frame-style.pipe';
import {FrameSumPipe} from './pipe/frame-sum.pipe';
import {ArrayFilterPipe} from './pipe/array-filter.pipe';
import {AttrFilterPipe} from './pipe/attr-filter.pipe';
import {FrameRoleDirective} from './directives/framerole/frame-role.directive';
import {NgxViewerModule} from 'ngx-viewer';
import {OrderModule, OrderPipe} from 'ngx-order-pipe';
import {ColorPickerModule} from 'ngx-color-picker';
import {NgxEchartsModule} from 'ngx-echarts';

@NgModule({
  imports: [
    CommonModule,
    FormsModule,
    ReactiveFormsModule,
    AccordionModule.forRoot(),
    AlertModule.forRoot(),
    ButtonsModule.forRoot(),
    CarouselModule.forRoot(),
    CollapseModule.forRoot(),
    DatepickerModule.forRoot(),
    BsDatepickerModule.forRoot(),
    BsDropdownModule.forRoot(),
    ModalModule.forRoot(),
    PaginationModule.forRoot(),
    ProgressbarModule.forRoot(),
    RatingModule.forRoot(),
    TabsModule.forRoot(),
    TimepickerModule.forRoot(),
    TooltipModule.forRoot(),
    PopoverModule.forRoot(),
    TypeaheadModule.forRoot(),
    ToasterModule.forRoot(),
    TreeModule.forRoot(),
    OrderModule,
    NgxSelectModule,
    NgxEchartsModule,
    NgxViewerModule,
    FileUploadModule,
    ColorPickerModule,


    NgxLoadingModule.forRoot({
      animationType: ngxLoadingAnimationTypes.circleSwish,
      fullScreenBackdrop: true,
      backdropBackgroundColour: 'rgba(0,0,0,0.3)',
      backdropBorderRadius: '4px',
      primaryColour: '#1E90FF',
      secondaryColour: '#ffffff',
      tertiaryColour: '#ffffff'
    })
  ],
  providers: [
    ColorsService,
    ToasterService,
    CookieService,
    BsModalService
  ],
  declarations: [
    CheckallDirective,
    NowDirective,
    ScrollableDirective,
    FrameDictDirective,
    FrameRoleDirective,

    FrameDictPipe,
    FrameStatusPipe,
    TrustUrlPipe,
    TrustHtmlPipe,
    FrameStylePipe,
    FrameStatusCustomPipe,
    NumberArrayPipe,
    ArrayFilterPipe,
    AttrFilterPipe,
    FrameSumPipe,

    AjaxComponent,
    PagerComponent,
    UploaderComponent,
    FormMsgComponent
  ],
  exports: [
    CommonModule,
    FormsModule,
    ReactiveFormsModule,
    RouterModule,
    AccordionModule,
    AlertModule,
    ButtonsModule,
    CarouselModule,
    CollapseModule,
    DatepickerModule,
    BsDatepickerModule,
    BsDropdownModule,
    ModalModule,
    PaginationModule,
    ProgressbarModule,
    RatingModule,
    TabsModule,
    TimepickerModule,
    TooltipModule,
    PopoverModule,
    NgxLoadingModule,
    NgxViewerModule,
    TypeaheadModule,
    ToasterModule,
    TreeModule,
    FileUploadModule,
    NgxSelectModule,
    NgxEchartsModule,
    OrderModule,
    ColorPickerModule,

    CheckallDirective,
    NowDirective,
    ScrollableDirective,
    FrameDictDirective,
    FrameRoleDirective,
    FrameDictPipe,
    FrameStatusPipe,
    TrustUrlPipe,
    TrustHtmlPipe,
    FrameStylePipe,
    FrameStatusCustomPipe,
    NumberArrayPipe,
    ArrayFilterPipe,
    AttrFilterPipe,
    FrameSumPipe,

    AjaxComponent,
    PagerComponent,
    UploaderComponent,
    FormMsgComponent
  ]
})

export class SharedModule {
  static forRoot(): ModuleWithProviders {
    return {
      ngModule: SharedModule
    };
  }
}
