]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/app-routing.module.ts
c0a2d29e4bddeec80f9ffb8086bfd2050f2ec98b
[github/Chocobozzz/PeerTube.git] / client / src / app / app-routing.module.ts
1 import { NgModule } from '@angular/core'
2 import { RouteReuseStrategy, RouterModule, Routes } from '@angular/router'
3 import { CustomReuseStrategy } from '@app/core/routing/custom-reuse-strategy'
4 import { MenuGuards } from '@app/core/routing/menu-guard.service'
5 import { POSSIBLE_LOCALES } from '@shared/core-utils/i18n'
6 import { PreloadSelectedModulesList } from './core'
7 import { EmptyComponent } from './empty.component'
8 import { ActorsComponent } from './+actors/actors.component'
9
10 const routes: Routes = [
11 {
12 path: 'admin',
13 canActivate: [ MenuGuards.close() ],
14 canDeactivate: [ MenuGuards.open() ],
15 loadChildren: () => import('./+admin/admin.module').then(m => m.AdminModule)
16 },
17 {
18 path: 'my-account',
19 loadChildren: () => import('./+my-account/my-account.module').then(m => m.MyAccountModule)
20 },
21 {
22 path: 'my-library',
23 loadChildren: () => import('./+my-library/my-library.module').then(m => m.MyLibraryModule)
24 },
25 {
26 path: 'verify-account',
27 loadChildren: () => import('./+signup/+verify-account/verify-account.module').then(m => m.VerifyAccountModule)
28 },
29 {
30 path: 'accounts',
31 loadChildren: () => import('./+accounts/accounts.module').then(m => m.AccountsModule)
32 },
33 {
34 path: 'video-channels',
35 loadChildren: () => import('./+video-channels/video-channels.module').then(m => m.VideoChannelsModule)
36 },
37 {
38 path: 'about',
39 loadChildren: () => import('./+about/about.module').then(m => m.AboutModule)
40 },
41 {
42 path: 'signup',
43 loadChildren: () => import('./+signup/+register/register.module').then(m => m.RegisterModule)
44 },
45 {
46 path: 'reset-password',
47 loadChildren: () => import('./+reset-password/reset-password.module').then(m => m.ResetPasswordModule)
48 },
49 {
50 path: 'login',
51 loadChildren: () => import('./+login/login.module').then(m => m.LoginModule)
52 },
53 {
54 path: 'search',
55 loadChildren: () => import('./+search/search.module').then(m => m.SearchModule)
56 },
57 {
58 path: 'videos',
59 loadChildren: () => import('./+videos/videos.module').then(m => m.VideosModule)
60 },
61 {
62 path: 'remote-interaction',
63 loadChildren: () => import('./+remote-interaction/remote-interaction.module').then(m => m.RemoteInteractionModule)
64 },
65 {
66 path: 'video-playlists/watch',
67 redirectTo: 'videos/watch/playlist'
68 },
69 {
70 path: 'a',
71 redirectTo: 'accounts'
72 },
73 {
74 path: 'c',
75 redirectTo: 'video-channels'
76 },
77 {
78 path: ':actorName',
79 component: ActorsComponent
80 },
81 {
82 path: '',
83 component: EmptyComponent // Avoid 404, app component will redirect dynamically
84 }
85 ]
86
87 // Avoid 404 when changing language
88 for (const locale of POSSIBLE_LOCALES) {
89 routes.push({
90 path: locale,
91 component: EmptyComponent
92 })
93 }
94
95 routes.push({
96 path: '**',
97 loadChildren: () => import('./+page-not-found/page-not-found.module').then(m => m.PageNotFoundModule)
98 })
99
100 @NgModule({
101 imports: [
102 RouterModule.forRoot(routes, {
103 useHash: Boolean(history.pushState) === false,
104 scrollPositionRestoration: 'disabled',
105 preloadingStrategy: PreloadSelectedModulesList,
106 anchorScrolling: 'disabled'
107 })
108 ],
109 providers: [
110 MenuGuards.guards,
111 PreloadSelectedModulesList,
112 { provide: RouteReuseStrategy, useClass: CustomReuseStrategy }
113 ],
114 exports: [ RouterModule ]
115 })
116 export class AppRoutingModule {}