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