import { NgModule } from '@angular/core';
import {Routes, RouterModule, ExtraOptions} from '@angular/router';
import {HomeComponent} from './home/home.component';
import {LoginService} from './services/login.service';
import {SampleComponent} from './sample/sample.component';
import {SamplesComponent} from './samples/samples.component';
import {DocumentationComponent} from './documentation/documentation.component';
import {TemplatesComponent} from './templates/templates.component';
import {SettingsComponent} from './settings/settings.component';
import {UsersComponent} from './users/users.component';
import {ChangelogComponent} from './changelog/changelog.component';
import {DocumentationDatabaseComponent} from './documentation/documentation-database/documentation-database.component';
import {PredictionComponent} from './prediction/prediction.component';
import {ModelTemplatesComponent} from './model-templates/model-templates.component';
import {DocumentationArchitectureComponent} from
    './documentation/documentation-architecture/documentation-architecture.component';
import {MaterialsComponent} from './materials/materials.component';
import {MaterialComponent} from './material/material.component';
import {DocumentationModelsComponent} from './documentation/documentation-models/documentation-models.component';


const routes: Routes = [
  {path: '', component: HomeComponent},
  {path: 'home', component: HomeComponent},
  {path: 'prediction', component: PredictionComponent},
  {path: 'models', component: ModelTemplatesComponent},
  {path: 'samples', component: SamplesComponent, canActivate: [LoginService]},
  {path: 'samples/new', component: SampleComponent, canActivate: [LoginService]},
  {path: 'samples/edit/:id', component: SampleComponent, canActivate: [LoginService]},
  {path: 'materials', component: MaterialsComponent, canActivate: [LoginService]},
  {path: 'materials/edit/:id', component: MaterialComponent, canActivate: [LoginService]},
  {path: 'templates', component: TemplatesComponent, canActivate: [LoginService]},
  {path: 'changelog', component: ChangelogComponent, canActivate: [LoginService]},
  {path: 'users', component: UsersComponent, canActivate: [LoginService]},
  {path: 'settings', component: SettingsComponent, canActivate: [LoginService]},
  {path: 'documentation', component: DocumentationComponent},
  {path: 'documentation/architecture', component: DocumentationArchitectureComponent},
  {path: 'documentation/database', component: DocumentationDatabaseComponent},
  {path: 'documentation/models', component: DocumentationModelsComponent},

  // if not authenticated
  { path: '**', redirectTo: '' }
];

const routerOptions: ExtraOptions = {
  scrollPositionRestoration: 'enabled',
  anchorScrolling: 'enabled',
  scrollOffset: [0, 64],
};

@NgModule({
  imports: [RouterModule.forRoot(routes, routerOptions)],
  exports: [RouterModule]
})
export class AppRoutingModule { }
