231 lines
9.3 KiB
TypeScript
231 lines
9.3 KiB
TypeScript
import { AuthErrorComponent } from '@components/auth-error/auth-error.component';
|
|
import {
|
|
CompositeRouteGuard,
|
|
CustomRouteReuseStrategy,
|
|
DEFAULT_REDIRECT_KEY,
|
|
IqserAuthGuard,
|
|
IqserPermissionsGuard,
|
|
IqserRoutes,
|
|
} from '@iqser/common-ui';
|
|
import { RedRoleGuard } from '@users/red-role.guard';
|
|
import { BaseScreenComponent } from '@components/base-screen/base-screen.component';
|
|
import { RouteReuseStrategy, RouterModule } from '@angular/router';
|
|
import { NgModule } from '@angular/core';
|
|
import { DownloadsListScreenComponent } from '@components/downloads-list-screen/downloads-list-screen.component';
|
|
import { DossiersGuard } from '@guards/dossiers.guard';
|
|
import { ACTIVE_DOSSIERS_SERVICE, ARCHIVED_DOSSIERS_SERVICE } from './tokens';
|
|
import { FeaturesGuard } from '@guards/features-guard.service';
|
|
import { DossierTemplatesGuard } from '@guards/dossier-templates.guard';
|
|
import { DossierTemplateExistsGuard } from '@guards/dossier-template-exists.guard';
|
|
import { DashboardGuard } from '@guards/dashboard-guard.service';
|
|
import { TrashGuard } from '@guards/trash.guard';
|
|
import { ARCHIVE_ROUTE, BreadcrumbTypes, DOSSIER_ID, DOSSIER_TEMPLATE_ID, DOSSIERS_ARCHIVE, DOSSIERS_ROUTE, FILE_ID } from '@red/domain';
|
|
import { DossierFilesGuard } from '@guards/dossier-files-guard';
|
|
import { WebViewerLoadedGuard } from './modules/pdf-viewer/services/webviewer-loaded.guard';
|
|
import { ROLES } from '@users/roles';
|
|
|
|
const dossierTemplateIdRoutes: IqserRoutes = [
|
|
{
|
|
path: `${DOSSIERS_ROUTE}`,
|
|
canActivate: [CompositeRouteGuard, IqserPermissionsGuard],
|
|
data: {
|
|
routeGuards: [DossiersGuard],
|
|
dossiersService: ACTIVE_DOSSIERS_SERVICE,
|
|
permissions: {
|
|
allow: [ROLES.files.readStatus],
|
|
redirectTo: '/auth-error',
|
|
},
|
|
},
|
|
children: [
|
|
{
|
|
path: `:${DOSSIER_ID}`,
|
|
canActivate: [CompositeRouteGuard, IqserPermissionsGuard],
|
|
data: {
|
|
routeGuards: [DossierFilesGuard],
|
|
breadcrumbs: [BreadcrumbTypes.dossierTemplate, BreadcrumbTypes.dossier],
|
|
dossiersService: ACTIVE_DOSSIERS_SERVICE,
|
|
permissions: {
|
|
allow: [ROLES.dossierAttributes.read, ROLES.dossierAttributes.readConfig],
|
|
redirectTo: '/auth-error',
|
|
},
|
|
skeleton: 'dossier',
|
|
},
|
|
loadChildren: () => import('./modules/dossier-overview/dossier-overview.module').then(m => m.DossierOverviewModule),
|
|
},
|
|
{
|
|
path: `:${DOSSIER_ID}/file/:${FILE_ID}`,
|
|
canActivate: [CompositeRouteGuard, IqserPermissionsGuard],
|
|
data: {
|
|
routeGuards: [DossierFilesGuard, WebViewerLoadedGuard],
|
|
breadcrumbs: [BreadcrumbTypes.dossierTemplate, BreadcrumbTypes.dossier, BreadcrumbTypes.file],
|
|
dossiersService: ACTIVE_DOSSIERS_SERVICE,
|
|
permissions: {
|
|
allow: [ROLES.readRedactionLog, ROLES.files.downloadOriginal, ROLES.highlights.read],
|
|
redirectTo: '/auth-error',
|
|
},
|
|
},
|
|
loadChildren: () => import('./modules/file-preview/file-preview.module').then(m => m.FilePreviewModule),
|
|
},
|
|
{
|
|
path: '',
|
|
pathMatch: 'full',
|
|
loadChildren: () => import('./modules/dossiers-listing/dossiers-listing.module').then(m => m.DossiersListingModule),
|
|
data: {
|
|
breadcrumbs: [BreadcrumbTypes.dossierTemplate],
|
|
},
|
|
},
|
|
],
|
|
},
|
|
{
|
|
path: `${ARCHIVE_ROUTE}`,
|
|
loadChildren: () => import('./modules/archive/archive.module').then(m => m.ArchiveModule),
|
|
canActivate: [CompositeRouteGuard, WebViewerLoadedGuard],
|
|
data: {
|
|
routeGuards: [FeaturesGuard, DossiersGuard],
|
|
dossiersService: ARCHIVED_DOSSIERS_SERVICE,
|
|
features: [DOSSIERS_ARCHIVE],
|
|
},
|
|
},
|
|
{
|
|
path: '**',
|
|
redirectTo: `${DOSSIERS_ROUTE}`,
|
|
pathMatch: 'full',
|
|
},
|
|
];
|
|
|
|
const routes: IqserRoutes = [
|
|
{
|
|
path: '',
|
|
redirectTo: 'main',
|
|
pathMatch: 'full',
|
|
},
|
|
{
|
|
path: 'main',
|
|
component: BaseScreenComponent,
|
|
children: [
|
|
{
|
|
path: '',
|
|
redirectTo: 'dashboard',
|
|
pathMatch: 'full',
|
|
},
|
|
{
|
|
path: 'account',
|
|
loadChildren: () => import('./modules/account/account.module').then(m => m.AccountModule),
|
|
},
|
|
{
|
|
path: 'admin',
|
|
loadChildren: () => import('./modules/admin/admin.module').then(m => m.AdminModule),
|
|
canActivate: [RedRoleGuard],
|
|
},
|
|
{
|
|
path: 'dashboard',
|
|
loadChildren: () => import('./modules/dashboard/dashboard.module').then(m => m.DashboardModule),
|
|
canActivate: [CompositeRouteGuard],
|
|
data: {
|
|
routeGuards: [IqserAuthGuard, RedRoleGuard, IqserPermissionsGuard, DossierTemplatesGuard, DashboardGuard],
|
|
permissions: {
|
|
allow: [
|
|
ROLES.any,
|
|
ROLES.templates.read,
|
|
ROLES.fileAttributes.readConfig,
|
|
ROLES.watermarks.read,
|
|
ROLES.dictionaryTypes.read,
|
|
ROLES.colors.read,
|
|
ROLES.states.read,
|
|
ROLES.notifications.read,
|
|
'RED_USER',
|
|
],
|
|
redirectTo: {
|
|
RED_USER: '/main/admin',
|
|
[ROLES.templates.read]: '/main/admin',
|
|
[DEFAULT_REDIRECT_KEY]: '/auth-error',
|
|
},
|
|
},
|
|
skeleton: 'dashboard',
|
|
},
|
|
},
|
|
{
|
|
path: 'downloads',
|
|
component: DownloadsListScreenComponent,
|
|
canActivate: [CompositeRouteGuard, IqserPermissionsGuard],
|
|
data: {
|
|
routeGuards: [IqserAuthGuard, RedRoleGuard],
|
|
permissions: {
|
|
allow: ROLES.readDownloadStatus,
|
|
redirectTo: '/auth-error',
|
|
},
|
|
},
|
|
},
|
|
{
|
|
path: 'search',
|
|
loadChildren: () => import('./modules/search/search.module').then(m => m.SearchModule),
|
|
canActivate: [CompositeRouteGuard, IqserPermissionsGuard],
|
|
data: {
|
|
routeGuards: [IqserAuthGuard, RedRoleGuard],
|
|
permissions: {
|
|
allow: [ROLES.search],
|
|
redirectTo: '/auth-error',
|
|
},
|
|
},
|
|
},
|
|
{
|
|
path: 'trash',
|
|
loadChildren: () => import('./modules/trash/trash.module').then(m => m.TrashModule),
|
|
canActivate: [CompositeRouteGuard, IqserPermissionsGuard],
|
|
data: {
|
|
routeGuards: [IqserAuthGuard, RedRoleGuard, DossiersGuard, TrashGuard],
|
|
dossiersService: ACTIVE_DOSSIERS_SERVICE,
|
|
permissions: {
|
|
allow: [ROLES.dossiers.read, ROLES.files.readStatus],
|
|
redirectTo: '/auth-error',
|
|
},
|
|
},
|
|
},
|
|
{
|
|
path: `:${DOSSIER_TEMPLATE_ID}`,
|
|
children: dossierTemplateIdRoutes,
|
|
canActivate: [CompositeRouteGuard, IqserPermissionsGuard],
|
|
data: {
|
|
routeGuards: [IqserAuthGuard, RedRoleGuard, DossierTemplatesGuard, DashboardGuard, DossierTemplateExistsGuard],
|
|
permissions: {
|
|
allow: [
|
|
ROLES.any,
|
|
ROLES.templates.read,
|
|
ROLES.fileAttributes.readConfig,
|
|
ROLES.watermarks.read,
|
|
ROLES.dictionaryTypes.read,
|
|
ROLES.colors.read,
|
|
ROLES.states.read,
|
|
ROLES.notifications.read,
|
|
ROLES.dossiers.read,
|
|
'RED_USER',
|
|
],
|
|
redirectTo: {
|
|
[ROLES.any]: '/auth-error',
|
|
RED_USER: '/main/admin',
|
|
[DEFAULT_REDIRECT_KEY]: '/',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
],
|
|
},
|
|
{
|
|
path: 'auth-error',
|
|
component: AuthErrorComponent,
|
|
canActivate: [IqserAuthGuard],
|
|
},
|
|
{
|
|
path: '**',
|
|
redirectTo: 'main',
|
|
pathMatch: 'full',
|
|
},
|
|
];
|
|
|
|
@NgModule({
|
|
imports: [RouterModule.forRoot(routes, { scrollPositionRestoration: 'enabled' })],
|
|
providers: [{ provide: RouteReuseStrategy, useClass: CustomRouteReuseStrategy }],
|
|
exports: [RouterModule],
|
|
})
|
|
export class AppRoutingModule {}
|