]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/app-routing.module.ts
Add video edition finished notification
[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),
99 data: {
100 meta: {
101 title: $localize`Upload a video`
102 }
103 }
1942f11d 104 },
d43c6b1f 105 {
a1eda903
C
106 path: 'videos/update/:uuid',
107 loadChildren: () => import('@app/+videos/+video-edit/video-update.module').then(m => m.VideoUpdateModule),
108 data: {
109 meta: {
110 title: $localize`Edit a video`
111 }
112 }
113 },
114
115 {
116 path: 'videos/watch/playlist',
117 redirectTo: 'w/p'
118 },
119 {
120 path: 'videos/watch',
121 redirectTo: 'w'
122 },
123 {
124 path: 'w',
125 loadChildren: () => import('@app/+videos/+video-watch/video-watch.module').then(m => m.VideoWatchModule),
126 data: {
8e08d415 127 preload: 5000
a1eda903
C
128 }
129 },
130 {
131 path: 'videos',
132 loadChildren: () => import('./+videos/videos.module').then(m => m.VideosModule),
0f01a8ba 133 canActivateChild: [ MetaGuard ]
d43c6b1f 134 },
0bd6d35f
C
135 {
136 path: 'video-playlists/watch',
137 redirectTo: 'videos/watch/playlist'
138 },
a1eda903 139
ff8c5ccf 140 {
a1eda903
C
141 path: 'remote-interaction',
142 loadChildren: () => import('./+remote-interaction/remote-interaction.module').then(m => m.RemoteInteractionModule),
143 canActivateChild: [ MetaGuard ]
ff8c5ccf 144 },
a1eda903 145
c729caf6
C
146 {
147 path: 'video-editor',
148 loadChildren: () => import('./+video-editor/video-editor.module').then(m => m.VideoEditorModule),
149 canActivateChild: [ MetaGuard ]
150 },
151
a1eda903 152 // Matches /@:actorName
ff8c5ccf 153 {
69e076dd 154 matcher: (url): UrlMatchResult => {
012580d9
C
155 const regex = new RegExp(`^@(${USER_USERNAME_REGEX_CHARACTERS}+)$`)
156 if (url.length !== 1) return null
157
158 const matchResult = url[0].path.match(regex)
159 if (!matchResult) return null
160
161 return {
162 consumed: url,
163 posParams: {
164 actorName: new UrlSegment(matchResult[1], {})
69e076dd
K
165 }
166 }
69e076dd 167 },
012580d9
C
168 pathMatch: 'full',
169 canActivate: [ ActorRedirectGuard ],
170 component: EmptyComponent
ff8c5ccf 171 },
a1eda903 172
b889cdb2
C
173 {
174 path: '',
fc21ef5c 175 component: HomepageRedirectComponent
4b4f22fc 176 }
df98563e 177]
693b1aba 178
ca00baa7
C
179// Avoid 404 when changing language
180for (const locale of POSSIBLE_LOCALES) {
181 routes.push({
182 path: locale,
fc21ef5c 183 component: HomepageRedirectComponent
ca00baa7
C
184 })
185}
186
187routes.push({
188 path: '**',
189 loadChildren: () => import('./+page-not-found/page-not-found.module').then(m => m.PageNotFoundModule)
190})
191
693b1aba 192@NgModule({
04de542a
C
193 imports: [
194 RouterModule.forRoot(routes, {
195 useHash: Boolean(history.pushState) === false,
dd24f1bb 196 // Redefined in app component
489290b8 197 scrollPositionRestoration: 'disabled',
07a98236 198 preloadingStrategy: PreloadSelectedModulesList,
489290b8 199 anchorScrolling: 'disabled'
04de542a
C
200 })
201 ],
901637bb 202 providers: [
3b20bdd6 203 MenuGuards.guards,
489290b8
C
204 PreloadSelectedModulesList,
205 { provide: RouteReuseStrategy, useClass: CustomReuseStrategy }
901637bb 206 ],
693b1aba
C
207 exports: [ RouterModule ]
208})
209export class AppRoutingModule {}