427 lines
13 KiB
TypeScript
427 lines
13 KiB
TypeScript
import { Routes } from '@angular/router';
|
|
import { userGuard } from './shared/guards/user.guard';
|
|
import { adminGuard } from './shared/guards/admin.guard';
|
|
import { superAdminGuard } from './shared/guards/super-admin.guard';
|
|
import { collaborationNetworkResolver } from './resolvers/collaboration-network.resolver';
|
|
import { personListResolver } from './resolvers/person-list.resolver';
|
|
import { personBioResolver } from './resolvers/person-bio.resolver';
|
|
import { personResolver } from './resolvers/person.resolver';
|
|
import { institutionResolver } from './resolvers/institution.resolver';
|
|
import { bundProjectPageResolver } from './resolvers/bund-project-page.resolver';
|
|
import { dfgProjectsResolver } from './resolvers/dfg-projects.resolver';
|
|
import { personNewsResolver } from './resolvers/person-news.resolver';
|
|
import { institutionsResolver } from './resolvers/institutions.resolver';
|
|
import { bundProjectsFundingResolver } from './resolvers/bund-projects-funding.resolver';
|
|
import { dfgSingleProjectResolver } from './resolvers/dfg-single-project-resolver';
|
|
import { bundSingleProjectResolver } from './resolvers/bund-single-project-resolver';
|
|
import { cordisEuProjectPageResolver } from './resolvers/cordis-eu-project-page.resolver';
|
|
import { cordisEuProjectsFundingResolver } from './resolvers/cordis-eu-projects-funding.resolver';
|
|
import { fundingProjectPageResolver } from './resolvers/funding-project-page.resolver';
|
|
import { personCordisEuProjectPageResolver } from './resolvers/person-cordis-eu-project-page.resolver';
|
|
|
|
export const routes: Routes = [
|
|
{
|
|
path: '',
|
|
pathMatch: 'full',
|
|
redirectTo: 'dashboard',
|
|
},
|
|
{
|
|
path: 'login',
|
|
loadComponent: () =>
|
|
import('./modules/app-login/app-login.component').then(
|
|
(mod) => mod.AppLoginComponent,
|
|
),
|
|
},
|
|
{
|
|
path: 'register',
|
|
loadComponent: () =>
|
|
import('./modules/app-register/app-register.component').then(
|
|
(mod) => mod.AppRegisterComponent,
|
|
),
|
|
},
|
|
{
|
|
path: 'dashboard',
|
|
canActivate: [userGuard],
|
|
loadComponent: () =>
|
|
import('./modules/dashboard/dashboard.component').then(
|
|
(mod) => mod.DashboardComponent,
|
|
),
|
|
},
|
|
{
|
|
path: 'persons',
|
|
canActivate: [userGuard],
|
|
loadComponent: () =>
|
|
import('./modules/person-list/person-list.component').then(
|
|
(mod) => mod.PersonListComponent,
|
|
),
|
|
resolve: {
|
|
persons: personListResolver,
|
|
},
|
|
runGuardsAndResolvers: (to, from) => {
|
|
const keys = [
|
|
'query',
|
|
'page',
|
|
'pageSize',
|
|
'institutionName',
|
|
'sortBy',
|
|
'sortOrder',
|
|
'yearFilterEnabled',
|
|
'filterMode',
|
|
'filterYear',
|
|
];
|
|
|
|
// scalar params
|
|
const scalarChanged = keys.some(
|
|
(key) => to.queryParamMap.get(key) !== from.queryParamMap.get(key),
|
|
);
|
|
|
|
// multi-value param: topics
|
|
const toTopics = to.queryParamMap.getAll('topic');
|
|
const fromTopics = from.queryParamMap.getAll('topic');
|
|
|
|
const topicsChanged =
|
|
toTopics.length !== fromTopics.length ||
|
|
toTopics.some((t, i) => t !== fromTopics[i]);
|
|
|
|
return scalarChanged || topicsChanged;
|
|
},
|
|
},
|
|
{
|
|
path: 'news',
|
|
canActivate: [userGuard],
|
|
loadComponent: () =>
|
|
import('./modules/news/news.component').then((mod) => mod.NewsComponent),
|
|
},
|
|
{
|
|
path: 'accounts',
|
|
canActivate: [adminGuard],
|
|
loadComponent: () =>
|
|
import('./modules/accounts/accounts.component').then(
|
|
(mod) => mod.AccountsComponent,
|
|
),
|
|
},
|
|
{
|
|
path: 'organizations',
|
|
canActivate: [superAdminGuard],
|
|
loadComponent: () =>
|
|
import('./modules/organizations/organizations.component').then(
|
|
(mod) => mod.OrganizationsComponent,
|
|
),
|
|
},
|
|
{
|
|
path: 'news/:id',
|
|
canActivate: [userGuard],
|
|
loadComponent: () =>
|
|
import('./modules/news-detail/news-detail.component').then(
|
|
(mod) => mod.NewsDetailComponent,
|
|
),
|
|
},
|
|
{
|
|
path: 'publication/:publicationId',
|
|
canActivate: [userGuard],
|
|
loadComponent: () =>
|
|
import('./modules/publication-detail/publication-detail.component').then(
|
|
(mod) => mod.PublicationDetailComponent,
|
|
),
|
|
},
|
|
{
|
|
path: 'projects/dfg/:id',
|
|
canActivate: [userGuard],
|
|
pathMatch: 'full',
|
|
loadComponent: () =>
|
|
import('./modules/person-projects/dfg-details/dfg-details.component').then(
|
|
(mod) => mod.DfgDetailsComponent,
|
|
),
|
|
resolve: {
|
|
dfgSingleProject: dfgSingleProjectResolver,
|
|
},
|
|
},
|
|
{
|
|
path: 'projects/bund/:id',
|
|
canActivate: [userGuard],
|
|
pathMatch: 'full',
|
|
loadComponent: () =>
|
|
import('./modules/person-projects/bund-details/bund-details.component').then(
|
|
(mod) => mod.BundDetailsComponent,
|
|
),
|
|
resolve: {
|
|
bundSingleProject: bundSingleProjectResolver,
|
|
},
|
|
},
|
|
{
|
|
path: 'person/:id',
|
|
canActivate: [userGuard],
|
|
loadComponent: () =>
|
|
import('./modules/person/person.component').then(
|
|
(mod) => mod.PersonComponent,
|
|
),
|
|
resolve: {
|
|
personData: personResolver,
|
|
personBio: personBioResolver,
|
|
},
|
|
runGuardsAndResolvers: (from, to) => from.params['id'] !== to.params['id'],
|
|
children: [
|
|
{
|
|
path: '',
|
|
pathMatch: 'full',
|
|
redirectTo: 'overview',
|
|
},
|
|
{
|
|
path: 'overview',
|
|
loadComponent: () =>
|
|
import('./modules/person-overview/person-overview.component').then(
|
|
(mod) => mod.PersonOverviewComponent,
|
|
),
|
|
},
|
|
{
|
|
path: 'projects',
|
|
loadComponent: () =>
|
|
import('./modules/person-projects/person-projects.component').then(
|
|
(mod) => mod.PersonProjectsComponent,
|
|
),
|
|
resolve: {
|
|
dfgProjectPage: dfgProjectsResolver,
|
|
personCordisEuProjectPage: personCordisEuProjectPageResolver,
|
|
},
|
|
runGuardsAndResolvers: (from, to) => {
|
|
const keys = ['page', 'size', 'sort_by', 'sort_direction', 'search'];
|
|
|
|
return keys.some(
|
|
(key) => from.queryParamMap.get(key) !== to.queryParamMap.get(key),
|
|
);
|
|
},
|
|
},
|
|
{
|
|
path: 'publications',
|
|
loadComponent: () =>
|
|
import('./modules/person-publications/person-publications.component').then(
|
|
(mod) => mod.PersonPublicationsComponent,
|
|
),
|
|
},
|
|
{
|
|
path: 'network',
|
|
loadComponent: () =>
|
|
import('./modules/person-network/person-network.component').then(
|
|
(mod) => mod.PersonNetworkComponent,
|
|
),
|
|
resolve: {
|
|
collaborationNetwork: collaborationNetworkResolver,
|
|
},
|
|
runGuardsAndResolvers: (from, to) => {
|
|
const network = from.data['collaborationNetwork'] as
|
|
| {
|
|
filter_information?: {
|
|
min_possible_year?: number;
|
|
max_possible_year?: number;
|
|
};
|
|
}
|
|
| undefined;
|
|
|
|
const filterInformation = network?.filter_information;
|
|
|
|
const defaultQueryParams: Record<string, string> = {
|
|
filter_by: 'works',
|
|
start_year: filterInformation?.min_possible_year
|
|
? String(filterInformation.min_possible_year)
|
|
: '',
|
|
end_year: filterInformation?.max_possible_year
|
|
? String(filterInformation.max_possible_year)
|
|
: '',
|
|
min_contributors: '2',
|
|
max_contributors: '10',
|
|
min_collaborations: '1',
|
|
max_collaborations: '100',
|
|
institutions: '',
|
|
topics: '',
|
|
};
|
|
|
|
const keys = [
|
|
'filter_by',
|
|
'start_year',
|
|
'end_year',
|
|
'min_contributors',
|
|
'max_contributors',
|
|
'min_collaborations',
|
|
'max_collaborations',
|
|
'institutions',
|
|
'topics',
|
|
];
|
|
|
|
return keys.some((key) => {
|
|
const fromRawValue = from.queryParamMap.get(key);
|
|
const toRawValue = to.queryParamMap.get(key);
|
|
|
|
const fromValue =
|
|
fromRawValue === null || fromRawValue === ''
|
|
? defaultQueryParams[key]
|
|
: fromRawValue;
|
|
|
|
const toValue =
|
|
toRawValue === null || toRawValue === ''
|
|
? defaultQueryParams[key]
|
|
: toRawValue;
|
|
|
|
return fromValue !== toValue;
|
|
});
|
|
},
|
|
},
|
|
|
|
{
|
|
path: 'funding',
|
|
loadComponent: () =>
|
|
import('./modules/person-funding/person-funding.component').then(
|
|
(mod) => mod.PersonFundingComponent,
|
|
),
|
|
},
|
|
{
|
|
path: 'news',
|
|
loadComponent: () =>
|
|
import('./modules/person-news/person-news.component').then(
|
|
(mod) => mod.PersonNewsComponent,
|
|
),
|
|
resolve: {
|
|
newsPage: personNewsResolver,
|
|
},
|
|
runGuardsAndResolvers: (from, to) => {
|
|
const keys = ['page', 'pageSize', 'sortOrder', 'query'];
|
|
|
|
return keys.some(
|
|
(key) => from.queryParamMap.get(key) !== to.queryParamMap.get(key),
|
|
);
|
|
},
|
|
},
|
|
{
|
|
path: 'patents',
|
|
loadComponent: () =>
|
|
import('./modules/person-patents/person-patents.component').then(
|
|
(mod) => mod.PersonPatentsComponent,
|
|
),
|
|
},
|
|
{
|
|
path: 'company-connections',
|
|
loadComponent: () =>
|
|
import('./modules/person-company-connections/person-company-connections.component').then(
|
|
(mod) => mod.PersonCompanyConnectionsComponent,
|
|
),
|
|
},
|
|
],
|
|
},
|
|
{
|
|
path: 'institutions',
|
|
canActivate: [userGuard],
|
|
loadComponent: () =>
|
|
import('./modules/institutions/institutions.component').then(
|
|
(mod) => mod.InstitutionsComponent,
|
|
),
|
|
resolve: {
|
|
institutionPage: institutionsResolver,
|
|
},
|
|
runGuardsAndResolvers: (from, to) => {
|
|
const keys = ['search', 'page', 'size', 'sort_by', 'sorting_order'];
|
|
|
|
return keys.some(
|
|
(key) => from.queryParamMap.get(key) !== to.queryParamMap.get(key),
|
|
);
|
|
},
|
|
},
|
|
{
|
|
path: 'institution/:institutionId',
|
|
canActivate: [userGuard],
|
|
loadComponent: () =>
|
|
import('./modules/institution/institution.component').then(
|
|
(mod) => mod.InstitutionComponent,
|
|
),
|
|
resolve: {
|
|
institution: institutionResolver,
|
|
},
|
|
children: [
|
|
{
|
|
path: '',
|
|
pathMatch: 'full',
|
|
redirectTo: 'overview',
|
|
},
|
|
{
|
|
path: 'overview',
|
|
loadComponent: () =>
|
|
import('./modules/institution-overview/institution-overview.component').then(
|
|
(mod) => mod.InstitutionOverviewComponent,
|
|
),
|
|
},
|
|
{
|
|
path: 'publications',
|
|
loadComponent: () =>
|
|
import('./modules/institution-publications/institution-publications.component').then(
|
|
(mod) => mod.InstitutionPublicationsComponent,
|
|
),
|
|
},
|
|
{
|
|
path: 'projects',
|
|
loadComponent: () => {
|
|
return import('./modules/institution-projects/institution-projects.component').then(
|
|
(mod) => mod.InstitutionProjectsComponent,
|
|
);
|
|
},
|
|
resolve: {
|
|
bundProjectPage: bundProjectPageResolver,
|
|
bundProjectsFunding: bundProjectsFundingResolver,
|
|
cordisEuProjectPage: cordisEuProjectPageResolver,
|
|
cordisEuProjectsFunding: cordisEuProjectsFundingResolver,
|
|
},
|
|
runGuardsAndResolvers: (from, to) => {
|
|
const keys = ['page', 'size', 'sort_by', 'sort_direction', 'search'];
|
|
|
|
return keys.some(
|
|
(key) => from.queryParamMap.get(key) !== to.queryParamMap.get(key),
|
|
);
|
|
},
|
|
},
|
|
],
|
|
},
|
|
{
|
|
path: 'projects',
|
|
canActivate: [userGuard],
|
|
loadComponent: () =>
|
|
import('./modules/projects/projects.component').then(
|
|
(mod) => mod.ProjectsComponent,
|
|
),
|
|
resolve: {
|
|
fundingProjectPage: fundingProjectPageResolver,
|
|
},
|
|
runGuardsAndResolvers: (from, to) => {
|
|
const keys = [
|
|
'search',
|
|
'page',
|
|
'size',
|
|
'selected_project_types',
|
|
'sort_by',
|
|
'sorting_order',
|
|
];
|
|
|
|
return keys.some(
|
|
(key) => from.queryParamMap.get(key) !== to.queryParamMap.get(key),
|
|
);
|
|
},
|
|
},
|
|
{
|
|
path: 'error',
|
|
loadComponent: () =>
|
|
import('./modules/error-page/error-page.component').then(
|
|
(mod) => mod.ErrorPageComponent,
|
|
),
|
|
},
|
|
{
|
|
path: '**',
|
|
loadComponent: () =>
|
|
import('./modules/error-page/error-page.component').then(
|
|
(mod) => mod.ErrorPageComponent,
|
|
),
|
|
data: {
|
|
routeStatusCode: 404,
|
|
routeTitle: 'Seite nicht gefunden',
|
|
routeMessage:
|
|
'Die gesuchte Seite existiert leider nicht oder wurde verschoben.',
|
|
},
|
|
canActivate: [userGuard],
|
|
},
|
|
];
|