2017-06-16 08:32:15 -04:00
|
|
|
import { NgModule } from '@angular/core'
|
2021-04-28 16:17:02 -04:00
|
|
|
import { RouteReuseStrategy, RouterModule, Routes, UrlMatchResult, UrlSegment } from '@angular/router'
|
2019-03-21 11:49:46 -04:00
|
|
|
import { CustomReuseStrategy } from '@app/core/routing/custom-reuse-strategy'
|
2020-03-07 07:50:26 -05:00
|
|
|
import { MenuGuards } from '@app/core/routing/menu-guard.service'
|
2021-01-14 08:13:23 -05:00
|
|
|
import { POSSIBLE_LOCALES } from '@shared/core-utils/i18n'
|
2021-05-14 10:12:45 -04:00
|
|
|
import { MetaGuard, PreloadSelectedModulesList } from './core'
|
2020-06-23 08:49:20 -04:00
|
|
|
import { EmptyComponent } from './empty.component'
|
2021-04-28 16:17:02 -04:00
|
|
|
import { RootComponent } from './root.component'
|
2016-11-20 11:18:15 -05:00
|
|
|
|
|
|
|
const routes: Routes = [
|
2018-05-17 09:25:50 -04:00
|
|
|
{
|
|
|
|
path: 'admin',
|
2020-03-07 07:50:26 -05:00
|
|
|
canActivate: [ MenuGuards.close() ],
|
|
|
|
canDeactivate: [ MenuGuards.open() ],
|
2021-05-14 10:12:45 -04:00
|
|
|
loadChildren: () => import('./+admin/admin.module').then(m => m.AdminModule),
|
|
|
|
canActivateChild: [ MetaGuard ]
|
2018-05-17 09:25:50 -04:00
|
|
|
},
|
2021-05-27 09:59:55 -04:00
|
|
|
{
|
|
|
|
path: 'home',
|
|
|
|
loadChildren: () => import('./+home/home.module').then(m => m.HomeModule)
|
2018-05-17 09:25:50 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: 'my-account',
|
2021-05-14 10:12:45 -04:00
|
|
|
loadChildren: () => import('./+my-account/my-account.module').then(m => m.MyAccountModule),
|
|
|
|
canActivateChild: [ MetaGuard ]
|
2018-05-17 09:25:50 -04:00
|
|
|
},
|
2020-11-12 09:28:54 -05:00
|
|
|
{
|
|
|
|
path: 'my-library',
|
2021-05-14 10:12:45 -04:00
|
|
|
loadChildren: () => import('./+my-library/my-library.module').then(m => m.MyLibraryModule),
|
|
|
|
canActivateChild: [ MetaGuard ]
|
2020-11-12 09:28:54 -05:00
|
|
|
},
|
2018-08-31 03:18:19 -04:00
|
|
|
{
|
|
|
|
path: 'verify-account',
|
2021-05-14 10:12:45 -04:00
|
|
|
loadChildren: () => import('./+signup/+verify-account/verify-account.module').then(m => m.VerifyAccountModule),
|
|
|
|
canActivateChild: [ MetaGuard ]
|
2018-08-31 03:18:19 -04:00
|
|
|
},
|
2018-05-17 09:25:50 -04:00
|
|
|
{
|
2021-04-28 17:45:23 -04:00
|
|
|
path: 'a',
|
2021-05-14 10:12:45 -04:00
|
|
|
loadChildren: () => import('./+accounts/accounts.module').then(m => m.AccountsModule),
|
|
|
|
canActivateChild: [ MetaGuard ]
|
2018-05-17 09:25:50 -04:00
|
|
|
},
|
|
|
|
{
|
2021-04-28 17:45:23 -04:00
|
|
|
path: 'c',
|
2021-05-14 10:12:45 -04:00
|
|
|
loadChildren: () => import('./+video-channels/video-channels.module').then(m => m.VideoChannelsModule),
|
|
|
|
canActivateChild: [ MetaGuard ]
|
2018-05-31 05:35:01 -04:00
|
|
|
},
|
2018-06-27 08:21:03 -04:00
|
|
|
{
|
|
|
|
path: 'about',
|
2021-05-14 10:12:45 -04:00
|
|
|
loadChildren: () => import('./+about/about.module').then(m => m.AboutModule),
|
|
|
|
canActivateChild: [ MetaGuard ]
|
2018-06-27 08:21:03 -04:00
|
|
|
},
|
2019-05-29 08:39:49 -04:00
|
|
|
{
|
|
|
|
path: 'signup',
|
2021-05-14 10:12:45 -04:00
|
|
|
loadChildren: () => import('./+signup/+register/register.module').then(m => m.RegisterModule),
|
|
|
|
canActivateChild: [ MetaGuard ]
|
2019-05-29 08:39:49 -04:00
|
|
|
},
|
2020-06-23 08:49:20 -04:00
|
|
|
{
|
|
|
|
path: 'reset-password',
|
2021-05-14 10:12:45 -04:00
|
|
|
loadChildren: () => import('./+reset-password/reset-password.module').then(m => m.ResetPasswordModule),
|
|
|
|
canActivateChild: [ MetaGuard ]
|
2020-06-23 08:49:20 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: 'login',
|
2021-05-14 10:12:45 -04:00
|
|
|
loadChildren: () => import('./+login/login.module').then(m => m.LoginModule),
|
|
|
|
canActivateChild: [ MetaGuard ]
|
2020-06-23 08:49:20 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: 'search',
|
2021-05-14 10:12:45 -04:00
|
|
|
loadChildren: () => import('./+search/search.module').then(m => m.SearchModule),
|
|
|
|
canActivateChild: [ MetaGuard ]
|
2020-06-23 08:49:20 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: 'videos',
|
2021-05-14 10:12:45 -04:00
|
|
|
loadChildren: () => import('./+videos/videos.module').then(m => m.VideosModule),
|
|
|
|
canActivateChild: [ MetaGuard ]
|
2020-06-23 08:49:20 -04:00
|
|
|
},
|
2021-01-14 08:13:23 -05:00
|
|
|
{
|
|
|
|
path: 'remote-interaction',
|
2021-05-14 10:12:45 -04:00
|
|
|
loadChildren: () => import('./+remote-interaction/remote-interaction.module').then(m => m.RemoteInteractionModule),
|
|
|
|
canActivateChild: [ MetaGuard ]
|
2021-01-14 08:13:23 -05:00
|
|
|
},
|
2021-03-04 03:04:10 -05:00
|
|
|
{
|
|
|
|
path: 'video-playlists/watch',
|
|
|
|
redirectTo: 'videos/watch/playlist'
|
|
|
|
},
|
2021-04-23 19:51:11 -04:00
|
|
|
{
|
2021-04-28 17:45:23 -04:00
|
|
|
path: 'accounts',
|
|
|
|
redirectTo: 'a'
|
2021-04-23 19:51:11 -04:00
|
|
|
},
|
|
|
|
{
|
2021-04-28 17:45:23 -04:00
|
|
|
path: 'video-channels',
|
|
|
|
redirectTo: 'c'
|
2021-04-23 19:51:11 -04:00
|
|
|
},
|
|
|
|
{
|
2021-04-28 16:17:02 -04:00
|
|
|
matcher: (url): UrlMatchResult => {
|
|
|
|
// Matches /@:actorName
|
|
|
|
if (url.length === 1 && url[0].path.match(/^@[\w]+$/gm)) {
|
|
|
|
return {
|
|
|
|
consumed: url,
|
|
|
|
posParams: {
|
|
|
|
actorName: new UrlSegment(url[0].path.substr(1), {})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null
|
|
|
|
},
|
|
|
|
component: RootComponent
|
2021-04-23 19:51:11 -04:00
|
|
|
},
|
2018-06-28 11:16:22 -04:00
|
|
|
{
|
|
|
|
path: '',
|
2020-06-23 08:49:20 -04:00
|
|
|
component: EmptyComponent // Avoid 404, app component will redirect dynamically
|
2018-05-17 09:25:50 -04:00
|
|
|
}
|
2017-06-16 08:32:15 -04:00
|
|
|
]
|
2016-11-20 11:18:15 -05:00
|
|
|
|
2020-08-26 02:54:19 -04:00
|
|
|
// Avoid 404 when changing language
|
|
|
|
for (const locale of POSSIBLE_LOCALES) {
|
|
|
|
routes.push({
|
|
|
|
path: locale,
|
|
|
|
component: EmptyComponent
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
routes.push({
|
|
|
|
path: '**',
|
|
|
|
loadChildren: () => import('./+page-not-found/page-not-found.module').then(m => m.PageNotFoundModule)
|
|
|
|
})
|
|
|
|
|
2016-11-20 11:18:15 -05:00
|
|
|
@NgModule({
|
2017-09-06 15:48:15 -04:00
|
|
|
imports: [
|
|
|
|
RouterModule.forRoot(routes, {
|
|
|
|
useHash: Boolean(history.pushState) === false,
|
2019-03-21 11:49:46 -04:00
|
|
|
scrollPositionRestoration: 'disabled',
|
2019-01-08 09:06:58 -05:00
|
|
|
preloadingStrategy: PreloadSelectedModulesList,
|
2019-03-21 11:49:46 -04:00
|
|
|
anchorScrolling: 'disabled'
|
2017-09-06 15:48:15 -04:00
|
|
|
})
|
|
|
|
],
|
2018-03-01 07:57:29 -05:00
|
|
|
providers: [
|
2020-03-07 07:50:26 -05:00
|
|
|
MenuGuards.guards,
|
2019-03-21 11:49:46 -04:00
|
|
|
PreloadSelectedModulesList,
|
|
|
|
{ provide: RouteReuseStrategy, useClass: CustomReuseStrategy }
|
2018-03-01 07:57:29 -05:00
|
|
|
],
|
2016-11-20 11:18:15 -05:00
|
|
|
exports: [ RouterModule ]
|
|
|
|
})
|
|
|
|
export class AppRoutingModule {}
|