]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/app-routing.module.ts
Fix video channels quick filter overflow
[github/Chocobozzz/PeerTube.git] / client / src / app / app-routing.module.ts
CommitLineData
df98563e 1import { NgModule } from '@angular/core'
69e076dd 2import { RouteReuseStrategy, RouterModule, Routes, UrlMatchResult, UrlSegment } 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'
fc21ef5c 6import { HomepageRedirectComponent, MetaGuard, PreloadSelectedModulesList } from './core'
1942f11d 7import { EmptyComponent } from './empty.component'
012580d9
C
8import { USER_USERNAME_REGEX_CHARACTERS } from './shared/form-validators/user-validators'
9import { ActorRedirectGuard } from './shared/shared-main'
693b1aba
C
10
11const routes: Routes = [
4b4f22fc
C
12 {
13 path: 'admin',
3b20bdd6
RK
14 canActivate: [ MenuGuards.close() ],
15 canDeactivate: [ MenuGuards.open() ],
0f01a8ba
C
16 loadChildren: () => import('./+admin/admin.module').then(m => m.AdminModule),
17 canActivateChild: [ MetaGuard ]
4b4f22fc 18 },
2539932e
C
19 {
20 path: 'home',
012580d9
C
21 loadChildren: () => import('./+home/home.module').then(m => m.HomeModule),
22 canActivateChild: [ MetaGuard ]
4b4f22fc
C
23 },
24 {
25 path: 'my-account',
0f01a8ba
C
26 loadChildren: () => import('./+my-account/my-account.module').then(m => m.MyAccountModule),
27 canActivateChild: [ MetaGuard ]
4b4f22fc 28 },
17119e4a
C
29 {
30 path: 'my-library',
0f01a8ba
C
31 loadChildren: () => import('./+my-library/my-library.module').then(m => m.MyLibraryModule),
32 canActivateChild: [ MetaGuard ]
17119e4a 33 },
d9eaee39
JM
34 {
35 path: 'verify-account',
0f01a8ba
C
36 loadChildren: () => import('./+signup/+verify-account/verify-account.module').then(m => m.VerifyAccountModule),
37 canActivateChild: [ MetaGuard ]
d9eaee39 38 },
a1eda903
C
39
40 {
41 path: 'accounts',
42 redirectTo: 'a'
43 },
4b4f22fc 44 {
71887396 45 path: 'a',
0f01a8ba
C
46 loadChildren: () => import('./+accounts/accounts.module').then(m => m.AccountsModule),
47 canActivateChild: [ MetaGuard ]
4b4f22fc 48 },
a1eda903
C
49
50 {
51 path: 'video-channels',
52 redirectTo: 'c'
53 },
4b4f22fc 54 {
71887396 55 path: 'c',
0f01a8ba
C
56 loadChildren: () => import('./+video-channels/video-channels.module').then(m => m.VideoChannelsModule),
57 canActivateChild: [ MetaGuard ]
a51bad1a 58 },
a37e9e74 59 {
60 path: 'manage',
61 loadChildren: () => import('./+manage/manage.module').then(m => m.ManageModule),
62 canActivateChild: [ MetaGuard ]
63 },
d63e6d46
C
64 {
65 path: 'p',
66 loadChildren: () => import('./+plugin-pages/plugin-pages.module').then(m => m.PluginPagesModule),
67 canActivateChild: [ MetaGuard ]
68 },
69
78f912ed
C
70 {
71 path: 'about',
0f01a8ba
C
72 loadChildren: () => import('./+about/about.module').then(m => m.AboutModule),
73 canActivateChild: [ MetaGuard ]
78f912ed 74 },
b247a132
C
75 {
76 path: 'signup',
0f01a8ba
C
77 loadChildren: () => import('./+signup/+register/register.module').then(m => m.RegisterModule),
78 canActivateChild: [ MetaGuard ]
b247a132 79 },
1942f11d
C
80 {
81 path: 'reset-password',
0f01a8ba
C
82 loadChildren: () => import('./+reset-password/reset-password.module').then(m => m.ResetPasswordModule),
83 canActivateChild: [ MetaGuard ]
1942f11d
C
84 },
85 {
86 path: 'login',
0f01a8ba
C
87 loadChildren: () => import('./+login/login.module').then(m => m.LoginModule),
88 canActivateChild: [ MetaGuard ]
1942f11d
C
89 },
90 {
91 path: 'search',
0f01a8ba
C
92 loadChildren: () => import('./+search/search.module').then(m => m.SearchModule),
93 canActivateChild: [ MetaGuard ]
1942f11d 94 },
a1eda903 95
1942f11d 96 {
a1eda903
C
97 path: 'videos/upload',
98 loadChildren: () => import('@app/+videos/+video-edit/video-add.module').then(m => m.VideoAddModule),
72dd3a7c 99 canActivateChild: [ MetaGuard ],
a1eda903
C
100 data: {
101 meta: {
102 title: $localize`Upload a video`
103 }
104 }
1942f11d 105 },
d43c6b1f 106 {
a1eda903
C
107 path: 'videos/update/:uuid',
108 loadChildren: () => import('@app/+videos/+video-edit/video-update.module').then(m => m.VideoUpdateModule),
72dd3a7c 109 canActivateChild: [ MetaGuard ],
a1eda903
C
110 data: {
111 meta: {
112 title: $localize`Edit a video`
113 }
114 }
115 },
116
117 {
118 path: 'videos/watch/playlist',
119 redirectTo: 'w/p'
120 },
121 {
122 path: 'videos/watch',
123 redirectTo: 'w'
124 },
125 {
126 path: 'w',
127 loadChildren: () => import('@app/+videos/+video-watch/video-watch.module').then(m => m.VideoWatchModule),
128 data: {
8e08d415 129 preload: 5000
a1eda903
C
130 }
131 },
132 {
133 path: 'videos',
134 loadChildren: () => import('./+videos/videos.module').then(m => m.VideosModule),
0f01a8ba 135 canActivateChild: [ MetaGuard ]
d43c6b1f 136 },
0bd6d35f
C
137 {
138 path: 'video-playlists/watch',
139 redirectTo: 'videos/watch/playlist'
140 },
a1eda903 141
ff8c5ccf 142 {
a1eda903
C
143 path: 'remote-interaction',
144 loadChildren: () => import('./+remote-interaction/remote-interaction.module').then(m => m.RemoteInteractionModule),
145 canActivateChild: [ MetaGuard ]
ff8c5ccf 146 },
a1eda903 147
c729caf6 148 {
92e66e04
C
149 path: 'studio',
150 loadChildren: () => import('./+video-studio/video-studio.module').then(m => m.VideoStudioModule),
c729caf6
C
151 canActivateChild: [ MetaGuard ]
152 },
153
384ba8b7
C
154 {
155 path: 'stats',
156 loadChildren: () => import('./+stats/stats.module').then(m => m.StatsModule),
157 canActivateChild: [ MetaGuard ]
158 },
159
a1eda903 160 // Matches /@:actorName
ff8c5ccf 161 {
69e076dd 162 matcher: (url): UrlMatchResult => {
012580d9
C
163 const regex = new RegExp(`^@(${USER_USERNAME_REGEX_CHARACTERS}+)$`)
164 if (url.length !== 1) return null
165
166 const matchResult = url[0].path.match(regex)
167 if (!matchResult) return null
168
169 return {
170 consumed: url,
171 posParams: {
172 actorName: new UrlSegment(matchResult[1], {})
69e076dd
K
173 }
174 }
69e076dd 175 },
012580d9
C
176 pathMatch: 'full',
177 canActivate: [ ActorRedirectGuard ],
178 component: EmptyComponent
ff8c5ccf 179 },
a1eda903 180
b889cdb2
C
181 {
182 path: '',
fc21ef5c 183 component: HomepageRedirectComponent
4b4f22fc 184 }
df98563e 185]
693b1aba 186
ca00baa7
C
187// Avoid 404 when changing language
188for (const locale of POSSIBLE_LOCALES) {
189 routes.push({
190 path: locale,
fc21ef5c 191 component: HomepageRedirectComponent
ca00baa7
C
192 })
193}
194
195routes.push({
196 path: '**',
c0e3d9ff 197 loadChildren: () => import('./+error-page/error-page.module').then(m => m.ErrorPageModule)
ca00baa7
C
198})
199
693b1aba 200@NgModule({
04de542a
C
201 imports: [
202 RouterModule.forRoot(routes, {
203 useHash: Boolean(history.pushState) === false,
dd24f1bb 204 // Redefined in app component
489290b8 205 scrollPositionRestoration: 'disabled',
07a98236 206 preloadingStrategy: PreloadSelectedModulesList,
489290b8 207 anchorScrolling: 'disabled'
04de542a
C
208 })
209 ],
901637bb 210 providers: [
3b20bdd6 211 MenuGuards.guards,
489290b8
C
212 PreloadSelectedModulesList,
213 { provide: RouteReuseStrategy, useClass: CustomReuseStrategy }
901637bb 214 ],
693b1aba
C
215 exports: [ RouterModule ]
216})
217export class AppRoutingModule {}