import {NgModule} from '@angular/core';
import {PreloadAllModules, RouterModule, Routes} from '@angular/router';

import {EnvironmentSpecificResolver} from './openaireLibrary/utils/properties/environmentSpecificResolver';
import {EnvironmentSpecificService} from './openaireLibrary/utils/properties/environment-specific.service';

import {OpenaireErrorPageComponent} from './error/errorPage.component';

const routes: Routes = [
  {
    path: 'reload',
    loadChildren: './reload/libReload.module#LibReloadModule',
    resolve: {envSpecific: EnvironmentSpecificResolver},
    data: {hasSidebar: false}
  },
  {
    path: 'user-info',
    loadChildren: './login/libUser.module#LibUserModule',
    resolve: {envSpecific: EnvironmentSpecificResolver},
    data: {hasSidebar: false}
  },
  {
    path: 'error',
    component: OpenaireErrorPageComponent,
    resolve: {envSpecific: EnvironmentSpecificResolver},
    data: {hasSidebar: false}
  },
  {
    path: 'admin',
    loadChildren: './manageStakeholders/manageStakeholders.module#ManageStakeholdersModule',
    resolve: {envSpecific: EnvironmentSpecificResolver},
    data: {hasAdminMenu: true}
  },
  {

    path: 'admin/:stakeholder/general',
    loadChildren: './manageStakeholder/manageStakeholder.module#ManageStakeholderModule',
    resolve: {envSpecific: EnvironmentSpecificResolver},
    data: {hasAdminMenu: true}
  },
  {
    path: 'admin/:stakeholder/users',
    loadChildren: './users/users.module#UsersModule',
    resolve: {envSpecific: EnvironmentSpecificResolver},
    data: {hasAdminMenu: true}
  },
  {
     path: 'admin/:stakeholder',
    loadChildren: './stakeholder/stakeholder.module#StakeholderModule',
    resolve: {envSpecific: EnvironmentSpecificResolver},
  },
  {
    path: 'admin/:stakeholder/indicators/:topic',
    loadChildren: './topic/topic.module#TopicModule',
    resolve: {envSpecific: EnvironmentSpecificResolver},
  },
  {  path: 'admin/:stakeholder/indicators',
    loadChildren: './topic/topic.module#TopicModule',
    resolve: {envSpecific: EnvironmentSpecificResolver},
  },

  /* Library paths*/
  {
    path: 'portals',
    loadChildren: './portals/portals.module#PortalsModule',
    resolve: { envSpecific: EnvironmentSpecificResolver  },
    data: {hasAdminMenu: true}
  },
  {
    path: 'entities',
    loadChildren: './entities/entities.module#MonitorEntitiesModule',
    resolve: { envSpecific: EnvironmentSpecificResolver  },
    data: {hasAdminMenu: true}
  },
  {
    path: 'classes',
    loadChildren: './classes/classes.module#ClassesModule',
    resolve: { envSpecific: EnvironmentSpecificResolver  },
    data: {hasAdminMenu: true}
  },
  {
    path: 'classContents',
    loadChildren: './classHelpTexts/div-help-contents.module#MonitorDivHelpContentsModule',
    resolve: { envSpecific: EnvironmentSpecificResolver  },
    data: {hasAdminMenu: true}
  },
  {
    path: 'classContents/new',
    loadChildren: './classHelpTexts/new-div-help-content.module#MonitorNewDivHelpContentModule',
    resolve: { envSpecific: EnvironmentSpecificResolver  },
    data: {hasAdminMenu: true}
  },
  {
    path: 'classContents/edit',
    loadChildren: './classHelpTexts/edit-div-help-content.module#MonitorEditDivHelpContentModule',
    resolve: { envSpecific: EnvironmentSpecificResolver  },
    data: {hasAdminMenu: true}
  },
  {
    path: 'helptexts',
    loadChildren: './helpTexts/page-help-contents.module#MonitorPageHelpContentsModule',
    resolve: { envSpecific: EnvironmentSpecificResolver  },
    data: {hasAdminMenu: true}
  },
  {
    path: 'helptexts/new',
    loadChildren: './helpTexts/new-page-help-content.module#MonitorNewPageHelpContentModule',
    resolve: { envSpecific: EnvironmentSpecificResolver  },
    data: {hasAdminMenu: true}
  },
  {
    path: 'helptexts/edit',
    loadChildren: './helpTexts/edit-page-help-content.module#MonitorEditPageHelpContentModule',
    resolve: { envSpecific: EnvironmentSpecificResolver  },
    data: {hasAdminMenu: true}
  },
  {
    path: 'pages',
    loadChildren: './pages/pages.module#MonitorPagesModule',
    resolve: { envSpecific: EnvironmentSpecificResolver  },
    data: {hasAdminMenu: true}
  },
  {
    path: 'pageContents',
    loadChildren: './helpTexts/page-help-contents.module#MonitorPageHelpContentsModule',
    resolve: { envSpecific: EnvironmentSpecificResolver  },
    data: {hasAdminMenu: true}
  },
  {
    path: 'pageContents/new',
    loadChildren: './helpTexts/new-page-help-content.module#MonitorNewPageHelpContentModule',
    resolve: { envSpecific: EnvironmentSpecificResolver  },
    data: {hasAdminMenu: true}
  },
  {
    path: 'pageContents/edit',
    loadChildren: './helpTexts/edit-page-help-content.module#MonitorEditPageHelpContentModule',
    resolve: { envSpecific: EnvironmentSpecificResolver  },
    data: {hasAdminMenu: true}
  },
  //
  // {
  //   path: 'htmlPageContent/edit',
  //   loadChildren: './pages/htmlpagecontent/edit-html-page-content.module#EditHtmlPageContentModule',
  //   resolve: { envSpecific: EnvironmentSpecificResolver  },
  //   data: {hasAdminMenu: true}
  // },
  { path: 'theme', loadChildren: './openaireLibrary/utils/theme/theme.module#ThemeModule'},
  {
    path: '',
    loadChildren: './monitor/monitor.module#MonitorModule',
    resolve: {envSpecific: EnvironmentSpecificResolver},
    data: {hasMiniMenu: true, isFrontPage: true}
  },
  {
    path: '**',
    pathMatch: 'full',
    component: OpenaireErrorPageComponent,
    resolve: {envSpecific: EnvironmentSpecificResolver},
    data: {hasSidebar: false, hasAdminMenu: false}
  }
];

@NgModule({
  imports: [RouterModule.forRoot(routes, {
    preloadingStrategy: PreloadAllModules,
    scrollPositionRestoration: "top",
    onSameUrlNavigation: "reload"
  })],
  exports: [RouterModule],
  providers: [EnvironmentSpecificResolver, EnvironmentSpecificService]
})
export class AppRoutingModule {
}
