import {NgModule} from '@angular/core';
import {PreloadAllModules, RouterModule, Routes} from '@angular/router';
import {HomePage} from './home/home.page';
import {EastPage} from './east/east.page';
import {LoginPage} from './login/login.page';
import {Auth} from './service/auth';
import {AlarmPage} from './alarm/alarm.page';
import {RowPage} from './row/row.page';
import {IndexPage} from './index/index.page';
import {OtherPage} from './other/other.page';
import {MinePage} from './mine/mine.page';
import {EnvFanPage} from './envCtrl/env-fan/env-fan.page';
import {EnvDetailPage} from './envCtrl/env-detail/env-detail.page';
import {EnvShowerPage} from './envCtrl/env-shower/env-shower.page';
import {EnvLightPageModule} from './envCtrl/env-light/env-light.module';
import {EnvLightPage} from './envCtrl/env-light/env-light.page';
import {EnvWaterchannelPage} from './envCtrl/env-waterchannel/env-waterchannel.page';
import {EnvAnalPage} from './envCtrl/env-anal/env-anal.page';
import {EnvAlarmPage} from './envCtrl/env-alarm/env-alarm.page';
import {EnvAlarmDetailPage} from './envCtrl/env-alarm-detail/env-alarm-detail.page';
import {EnvCfgPageModule} from './envCtrl/env-cfg/env-cfg.module';
import {EnvCfgPage} from './envCtrl/env-cfg/env-cfg.page';
import {EnvHomePage} from './envCtrl/env-home/env-home.page';
import {EnvHistoryPage} from './envCtrl/env-history/env-history.page';
import {EnvAddModelPage} from './envCtrl/env-add-model/env-add-model.page';
import {EnvChangeModelPage} from './envCtrl/env-change-model/env-change-model.page';
import {EnvAnalDetailPage} from './envCtrl/env-anal-detail/env-anal-detail.page';

const routes: Routes = [
    {
        path: '',
        // canActivateChild: [Auth],
        children: [
            {path: '', redirectTo: 'index', pathMatch: 'full'},
            {path: 'home', component: HomePage},
            {path: 'east', component: EastPage},
            {path: 'other', component: OtherPage},
            {path: 'alarm', component: AlarmPage},
            {path: 'row', component: RowPage},
            {path: 'index', component: IndexPage},
            {path: 'mine', component: MinePage}
        ]
    },
    {path: 'login', component: LoginPage},
    // {path: 'env-detail',
    //     component: EnvDetailPage,
    //     children: [
    //         {path: 'fan', component: EnvFanPage},
    //         {path: 'shower/:fieldRegionNo', component: EnvShowerPage},
    //         {path: 'light/:fieldRegionNo', component: EnvLightPage},
    //         {path: 'waterchannel/:fieldRegionNo', component: EnvWaterchannelPage},
    //         {path: '', redirectTo: 'fan', pathMatch : 'prefix'},
    //     ]
    // },

    {path: 'env-detail',
        component: EnvDetailPage,
        children: [
            {path: 'fan', component: EnvFanPage},
            {path: 'shower/:fieldRegionNo/:operationModel', component: EnvShowerPage},
            {path: 'light/:fieldRegionNo/:operationModel', component: EnvLightPage},
            {path: 'waterchannel/:fieldRegionNo/:operationModel', component: EnvWaterchannelPage},
            {path: '', redirectTo: 'fan', pathMatch : 'prefix'},
        ]

        // children: [
        //     {path: 'fan', component: EnvFanPage},
        //     {path: 'shower', component: EnvShowerPage},
        //     {path: 'light', component: EnvLightPage},
        //     {path: 'waterchannel', component: EnvWaterchannelPage},
        //     {path: '', redirectTo: 'fan', pathMatch : 'prefix'},
        // ]

        // children: [
        //     {path: 'fan', loadChildren: './envCtrl/env-fan/env-fan.module#EnvFanPageModule'},
        //     {path: 'shower', loadChildren: './envCtrl/env-shower/env-shower.module#EnvShowerPageModule'},
        //     {path: 'light', loadChildren: './envCtrl/env-light/env-light.module#EnvLightPageModule'},
        //     {path: 'waterchannel', loadChildren: './envCtrl/env-waterchannel/env-waterchannel.module#EnvWaterchannelPageModule'},
        //     {path: '', redirectTo: 'fan', pathMatch : 'prefix'},
        // ]
    },

    // { path: 'env-detail', loadChildren: './envCtrl/env-detail/env-detail.module#EnvDetailPageModule' },
    // {path: 'env-history', component: EnvHistoryPage},
    { path: 'env-history', loadChildren: './envCtrl/env-history/env-history.module#EnvHistoryPageModule' },
    {path: 'env-alarmDetail', component: EnvAlarmDetailPage},
    { path: 'env-alarm-detail', loadChildren: './envCtrl/env-alarm-detail/env-alarm-detail.module#EnvAlarmDetailPageModule' },
    {path: 'tabs', loadChildren: './envCtrl/tabs/tabs.module#TabsPageModule'},
    {path: 'env-add-model', component: EnvAddModelPage},
    {path: 'env-change-model', component: EnvChangeModelPage},
    {path: 'env-anal-detail', component: EnvAnalDetailPage},
];

@NgModule({
    imports: [
        RouterModule.forRoot(routes, {preloadingStrategy: PreloadAllModules, enableTracing: false})
    ],
    exports: [RouterModule]
})
export class AppRoutingModule {
}
