PeerTube/client/src/app/app-routing.module.ts

100 lines
3.0 KiB
TypeScript
Raw Normal View History

import { NgModule } from '@angular/core'
2019-03-21 16:49:46 +01:00
import { RouteReuseStrategy, RouterModule, Routes } from '@angular/router'
import { CustomReuseStrategy } from '@app/core/routing/custom-reuse-strategy'
import { MenuGuards } from '@app/core/routing/menu-guard.service'
2021-01-14 14:13:23 +01:00
import { POSSIBLE_LOCALES } from '@shared/core-utils/i18n'
2020-06-23 14:10:17 +02:00
import { PreloadSelectedModulesList } from './core'
2020-06-23 14:49:20 +02:00
import { EmptyComponent } from './empty.component'
2016-11-20 17:18:15 +01:00
const routes: Routes = [
2018-05-17 15:25:50 +02:00
{
path: 'admin',
canActivate: [ MenuGuards.close() ],
canDeactivate: [ MenuGuards.open() ],
2019-07-24 16:05:59 +02:00
loadChildren: () => import('./+admin/admin.module').then(m => m.AdminModule)
2018-05-17 15:25:50 +02:00
},
{
path: 'my-account',
2019-07-24 16:05:59 +02:00
loadChildren: () => import('./+my-account/my-account.module').then(m => m.MyAccountModule)
2018-05-17 15:25:50 +02:00
},
{
path: 'my-library',
loadChildren: () => import('./+my-library/my-library.module').then(m => m.MyLibraryModule)
},
{
path: 'verify-account',
2019-07-24 16:05:59 +02:00
loadChildren: () => import('./+signup/+verify-account/verify-account.module').then(m => m.VerifyAccountModule)
},
2018-05-17 15:25:50 +02:00
{
path: 'accounts',
2019-07-24 16:05:59 +02:00
loadChildren: () => import('./+accounts/accounts.module').then(m => m.AccountsModule)
2018-05-17 15:25:50 +02:00
},
{
path: 'video-channels',
2019-07-24 16:05:59 +02:00
loadChildren: () => import('./+video-channels/video-channels.module').then(m => m.VideoChannelsModule)
2018-05-31 11:35:01 +02:00
},
2018-06-27 14:21:03 +02:00
{
path: 'about',
2019-07-24 16:05:59 +02:00
loadChildren: () => import('./+about/about.module').then(m => m.AboutModule)
2018-06-27 14:21:03 +02:00
},
2019-05-29 14:39:49 +02:00
{
path: 'signup',
2019-07-24 16:05:59 +02:00
loadChildren: () => import('./+signup/+register/register.module').then(m => m.RegisterModule)
2019-05-29 14:39:49 +02:00
},
2020-06-23 14:49:20 +02:00
{
path: 'reset-password',
loadChildren: () => import('./+reset-password/reset-password.module').then(m => m.ResetPasswordModule)
},
{
path: 'login',
loadChildren: () => import('./+login/login.module').then(m => m.LoginModule)
},
{
path: 'search',
loadChildren: () => import('./+search/search.module').then(m => m.SearchModule)
},
{
path: 'videos',
loadChildren: () => import('./+videos/videos.module').then(m => m.VideosModule)
},
2021-01-14 14:13:23 +01:00
{
path: 'remote-interaction',
loadChildren: () => import('./+remote-interaction/remote-interaction.module').then(m => m.RemoteInteractionModule)
},
2018-06-28 17:16:22 +02:00
{
path: '',
2020-06-23 14:49:20 +02:00
component: EmptyComponent // Avoid 404, app component will redirect dynamically
2018-05-17 15:25:50 +02:00
}
]
2016-11-20 17:18:15 +01:00
2020-08-26 08:54:19 +02:00
// Avoid 404 when changing language
for (const locale of POSSIBLE_LOCALES) {
routes.push({
path: locale,
component: EmptyComponent
})
}
routes.push({
path: '**',
loadChildren: () => import('./+page-not-found/page-not-found.module').then(m => m.PageNotFoundModule)
})
2016-11-20 17:18:15 +01:00
@NgModule({
2017-09-06 21:48:15 +02:00
imports: [
RouterModule.forRoot(routes, {
useHash: Boolean(history.pushState) === false,
2019-03-21 16:49:46 +01:00
scrollPositionRestoration: 'disabled',
preloadingStrategy: PreloadSelectedModulesList,
2019-03-21 16:49:46 +01:00
anchorScrolling: 'disabled'
2017-09-06 21:48:15 +02:00
})
],
2018-03-01 13:57:29 +01:00
providers: [
MenuGuards.guards,
2019-03-21 16:49:46 +01:00
PreloadSelectedModulesList,
{ provide: RouteReuseStrategy, useClass: CustomReuseStrategy }
2018-03-01 13:57:29 +01:00
],
2016-11-20 17:18:15 +01:00
exports: [ RouterModule ]
})
export class AppRoutingModule {}