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