]>
Commit | Line | Data |
---|---|---|
df98563e | 1 | import { NgModule } from '@angular/core' |
69e076dd | 2 | import { RouteReuseStrategy, RouterModule, Routes, UrlMatchResult, UrlSegment } from '@angular/router' |
489290b8 | 3 | import { CustomReuseStrategy } from '@app/core/routing/custom-reuse-strategy' |
3b20bdd6 | 4 | import { MenuGuards } from '@app/core/routing/menu-guard.service' |
d43c6b1f | 5 | import { POSSIBLE_LOCALES } from '@shared/core-utils/i18n' |
67ed6552 | 6 | import { PreloadSelectedModulesList } from './core' |
1942f11d | 7 | import { EmptyComponent } from './empty.component' |
69e076dd | 8 | import { RootComponent } from './root.component' |
693b1aba C |
9 | |
10 | const routes: Routes = [ | |
4b4f22fc C |
11 | { |
12 | path: 'admin', | |
3b20bdd6 RK |
13 | canActivate: [ MenuGuards.close() ], |
14 | canDeactivate: [ MenuGuards.open() ], | |
f36da21e | 15 | loadChildren: () => import('./+admin/admin.module').then(m => m.AdminModule) |
4b4f22fc C |
16 | }, |
17 | { | |
18 | path: 'my-account', | |
f36da21e | 19 | loadChildren: () => import('./+my-account/my-account.module').then(m => m.MyAccountModule) |
4b4f22fc | 20 | }, |
17119e4a C |
21 | { |
22 | path: 'my-library', | |
23 | loadChildren: () => import('./+my-library/my-library.module').then(m => m.MyLibraryModule) | |
24 | }, | |
d9eaee39 JM |
25 | { |
26 | path: 'verify-account', | |
f36da21e | 27 | loadChildren: () => import('./+signup/+verify-account/verify-account.module').then(m => m.VerifyAccountModule) |
d9eaee39 | 28 | }, |
4b4f22fc C |
29 | { |
30 | path: 'accounts', | |
f36da21e | 31 | loadChildren: () => import('./+accounts/accounts.module').then(m => m.AccountsModule) |
4b4f22fc C |
32 | }, |
33 | { | |
34 | path: 'video-channels', | |
f36da21e | 35 | loadChildren: () => import('./+video-channels/video-channels.module').then(m => m.VideoChannelsModule) |
a51bad1a | 36 | }, |
78f912ed C |
37 | { |
38 | path: 'about', | |
f36da21e | 39 | loadChildren: () => import('./+about/about.module').then(m => m.AboutModule) |
78f912ed | 40 | }, |
b247a132 C |
41 | { |
42 | path: 'signup', | |
f36da21e | 43 | loadChildren: () => import('./+signup/+register/register.module').then(m => m.RegisterModule) |
b247a132 | 44 | }, |
1942f11d C |
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 | }, | |
d43c6b1f C |
61 | { |
62 | path: 'remote-interaction', | |
63 | loadChildren: () => import('./+remote-interaction/remote-interaction.module').then(m => m.RemoteInteractionModule) | |
64 | }, | |
0bd6d35f C |
65 | { |
66 | path: 'video-playlists/watch', | |
67 | redirectTo: 'videos/watch/playlist' | |
68 | }, | |
ff8c5ccf K |
69 | { |
70 | path: 'a', | |
71 | redirectTo: 'accounts' | |
72 | }, | |
73 | { | |
74 | path: 'c', | |
75 | redirectTo: 'video-channels' | |
76 | }, | |
77 | { | |
69e076dd K |
78 | matcher: (url): UrlMatchResult => { |
79 | // Matches /@:actorName | |
80 | if (url.length === 1 && url[0].path.match(/^@[\w]+$/gm)) { | |
81 | return { | |
82 | consumed: url, | |
83 | posParams: { | |
84 | actorName: new UrlSegment(url[0].path.substr(1), {}) | |
85 | } | |
86 | } | |
87 | } | |
88 | ||
89 | return null | |
90 | }, | |
91 | component: RootComponent | |
ff8c5ccf | 92 | }, |
b889cdb2 C |
93 | { |
94 | path: '', | |
1942f11d | 95 | component: EmptyComponent // Avoid 404, app component will redirect dynamically |
4b4f22fc | 96 | } |
df98563e | 97 | ] |
693b1aba | 98 | |
ca00baa7 C |
99 | // Avoid 404 when changing language |
100 | for (const locale of POSSIBLE_LOCALES) { | |
101 | routes.push({ | |
102 | path: locale, | |
103 | component: EmptyComponent | |
104 | }) | |
105 | } | |
106 | ||
107 | routes.push({ | |
108 | path: '**', | |
109 | loadChildren: () => import('./+page-not-found/page-not-found.module').then(m => m.PageNotFoundModule) | |
110 | }) | |
111 | ||
693b1aba | 112 | @NgModule({ |
04de542a C |
113 | imports: [ |
114 | RouterModule.forRoot(routes, { | |
115 | useHash: Boolean(history.pushState) === false, | |
489290b8 | 116 | scrollPositionRestoration: 'disabled', |
07a98236 | 117 | preloadingStrategy: PreloadSelectedModulesList, |
489290b8 | 118 | anchorScrolling: 'disabled' |
04de542a C |
119 | }) |
120 | ], | |
901637bb | 121 | providers: [ |
3b20bdd6 | 122 | MenuGuards.guards, |
489290b8 C |
123 | PreloadSelectedModulesList, |
124 | { provide: RouteReuseStrategy, useClass: CustomReuseStrategy } | |
901637bb | 125 | ], |
693b1aba C |
126 | exports: [ RouterModule ] |
127 | }) | |
128 | export class AppRoutingModule {} |