You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

95 lines
3.4 KiB

  1. import {NgModule} from '@angular/core';
  2. import {Routes, RouterModule} from '@angular/router';
  3. import {HomeComponent} from './home';
  4. import {AuthGuard} from './_helpers';
  5. import {PartnersComponent} from "@app/partners/partners.component";
  6. import {TwoColumnComponent} from "@app/layout/two-column/two-column.component";
  7. import {PartnersDetailComponent} from "@app/partners/partners-detail/partners-detail.component";
  8. import {ProductsComponent} from "@app/products/products.component";
  9. import {ProductsDetailComponent} from "@app/products/products-detail/products-detail.component";
  10. import {DocumentsComponent} from "@app/documents/documents.component";
  11. import {ContactsComponent} from "@app/contacts/contacts.component";
  12. import {ContactsDetailComponent} from "@app/contacts/contacts-detail/contacts-detail.component";
  13. import {TasksComponent} from "@app/tasks/tasks.component";
  14. const accountModule = () => import('./account/account.module').then(x => x.AccountModule);
  15. const usersModule = () => import('./users/users.module').then(x => x.UsersModule);
  16. const routes: Routes = [
  17. {path: '', component: HomeComponent, canActivate: [AuthGuard]},
  18. {path: 'users', loadChildren: usersModule, canActivate: [AuthGuard]},
  19. {path: 'account', loadChildren: accountModule},
  20. {
  21. path: 'customer',
  22. component: TwoColumnComponent,
  23. canActivate: [AuthGuard],
  24. children: [
  25. {path: '', component: PartnersComponent, data: {dataType: 'customer'}},
  26. {path: ':id', component: PartnersDetailComponent, data: {dataType: 'customer-detail'}},
  27. ]
  28. },
  29. {
  30. path: 'supplier',
  31. component: TwoColumnComponent,
  32. canActivate: [AuthGuard],
  33. children: [
  34. {path: '', component: PartnersComponent, data: {dataType: 'supplier'}},
  35. {path: ':id', component: PartnersDetailComponent, data: {dataType: 'supplier-detail'}},
  36. ]
  37. },
  38. {
  39. path: 'service',
  40. component: TwoColumnComponent,
  41. canActivate: [AuthGuard],
  42. children: [
  43. {path: '', component: PartnersComponent, data: {dataType: 'service'}},
  44. {path: ':id', component: PartnersDetailComponent, data: {dataType: 'service-detail'}},
  45. ]
  46. },
  47. {
  48. path: 'contacts',
  49. component: TwoColumnComponent,
  50. canActivate: [AuthGuard],
  51. children: [
  52. {path: '', component: ContactsComponent},
  53. {path: ':id', component: ContactsDetailComponent},
  54. ]
  55. },
  56. {
  57. path: 'products',
  58. component: TwoColumnComponent,
  59. canActivate: [AuthGuard],
  60. children: [
  61. {path: '', component: ProductsComponent, data: {dataType: 'product'}},
  62. {path: ':id', component: ProductsDetailComponent, data: {dataType: 'product-detail'}},
  63. ]
  64. },
  65. {
  66. path: 'tasks',
  67. component: TwoColumnComponent,
  68. canActivate: [AuthGuard],
  69. children: [
  70. {path: '', component: TasksComponent, data: {dataType: 'task'}},
  71. ]
  72. },
  73. {
  74. path: 'documents',
  75. component: TwoColumnComponent,
  76. canActivate: [AuthGuard],
  77. children: [
  78. {path: '', component: DocumentsComponent, data: {dataType: 'document'}},
  79. ]
  80. },
  81. // otherwise redirect to home
  82. {path: '**', redirectTo: ''}
  83. ];
  84. @NgModule({
  85. imports: [RouterModule.forRoot(routes)],
  86. exports: [RouterModule]
  87. })
  88. export class AppRoutingModule {
  89. }