diff --git a/webapp/src/app/app.routes.ts b/webapp/src/app/app.routes.ts index 5368cc05..d8ecdca9 100644 --- a/webapp/src/app/app.routes.ts +++ b/webapp/src/app/app.routes.ts @@ -8,7 +8,10 @@ import { personResolver } from './resolvers/person.resolver'; import { personNewsResolver } from './resolvers/person-news.resolver'; import { institutionResolver } from './resolvers/institution.resolver'; import { bundProjectPageResolver } from './resolvers/bund-project-page.resolver'; -import { dfgProjectsResolver } from './resolvers/dfg-projects.resolver'; +import { + dfgProjectsResolver, + RESOLVING_PROJECT_PAGE_FOR, +} from './resolvers/dfg-projects.resolver'; import { institutionsResolver } from './resolvers/institutions.resolver'; import { bundProjectsFundingResolver } from './resolvers/bund-projects-funding.resolver'; import { dfgSingleProjectResolver } from './resolvers/dfg-single-project-resolver'; @@ -167,7 +170,23 @@ export const routes: Routes = [ children: [ { path: '', pathMatch: 'full', redirectTo: 'persons' }, { path: 'persons', component: KeywordsToPersonsResultsComponent }, - { path: 'projects', component: KeywordsToProjectsResultsComponent }, + { + path: 'projects', + component: KeywordsToProjectsResultsComponent, + runGuardsAndResolvers: 'always', + resolve: { + dfgProjectPage: dfgProjectsResolver, + personCordisEuProjectPage: personCordisEuProjectPageResolver, + selectedDfgInstitutionsPage: selectedDfgInstitutionsResolver, + selectedDfgAuthorsPage: selectedDfgAuthorsResolver, + selectedTopicsPage: selectedTopicsResolver, + selectedEuInstitutionsPage: selectedInstitutionsResolver, + selectedEuAuthorsPage: selectedAuthorsResolver, + }, + data: { + resolvingFor: RESOLVING_PROJECT_PAGE_FOR.KEYWORDS_SEARCH, + }, + }, { path: 'patents', component: KeywordsToPatentsResultsComponent }, { path: 'works', @@ -177,6 +196,10 @@ export const routes: Routes = [ selectedTopicsPage: selectedTopicsResolver, selectedAuthorsPage: selectedAuthorsResolver, selectedInstitutionsPage: selectedInstitutionsResolver, + workPage: workPageResolver, + }, + data: { + resolvingFor: RESOLVING_WORK_PAGE_FOR.KEYWORDS_SEARCH, }, }, { path: 'news', component: KeywordsToNewsResultsComponent }, @@ -384,10 +407,14 @@ export const routes: Routes = [ personCordisEuProjectPage: personCordisEuProjectPageResolver, selectedDfgInstitutionsPage: selectedDfgInstitutionsResolver, selectedDfgAuthorsPage: selectedDfgAuthorsResolver, + selectedTopicsPage: selectedTopicsResolver, selectedEuInstitutionsPage: selectedInstitutionsResolver, selectedEuAuthorsPage: selectedAuthorsResolver, }, runGuardsAndResolvers: 'always', + data: { + resolvingFor: RESOLVING_PROJECT_PAGE_FOR.PERSON, + }, }, { path: 'publications', diff --git a/webapp/src/app/modules/keywords-search/search-results/projects-results/projects-results.component.html b/webapp/src/app/modules/keywords-search/search-results/projects-results/projects-results.component.html index 80f6a51b..dd9481b3 100644 --- a/webapp/src/app/modules/keywords-search/search-results/projects-results/projects-results.component.html +++ b/webapp/src/app/modules/keywords-search/search-results/projects-results/projects-results.component.html @@ -1,31 +1,36 @@ -
- - - groups -

Projectsliste

-

- Die aktuelle Gewichtung ist unter normalized verfügbar. -

-
-
- - +
+
+
Projekte
+

Übersicht der durchgeführten Projekte.

+
+ - + + + + + + + + + +
diff --git a/webapp/src/app/modules/keywords-search/search-results/projects-results/projects-results.component.scss b/webapp/src/app/modules/keywords-search/search-results/projects-results/projects-results.component.scss index ffeea20d..9bd15288 100644 --- a/webapp/src/app/modules/keywords-search/search-results/projects-results/projects-results.component.scss +++ b/webapp/src/app/modules/keywords-search/search-results/projects-results/projects-results.component.scss @@ -1,29 +1,13 @@ -/* ============================================================ - RESULT LAYOUT - ============================================================ */ -.result-layout { - display: grid; - grid-template-columns: minmax(300px, 420px) 1fr; - grid-template-areas: 'summary results'; - gap: 0.75rem; - align-items: start; +.person-projects { + padding: 2rem; } -.search-summary-card { - grid-area: summary; +.description-container { + display: flex; + flex-direction: column; } -.results-card { - grid-area: results; -} - -.search-summary-card, -.results-card { - background: var(--sg-surface, #ffffff); - border: 1px solid var(--sg-divider, rgba(0, 0, 0, 0.12)); - box-shadow: none; - - .mat-mdc-card-content { - padding: 0.75rem; - } +mat-card, +mat-paginator { + background-color: var(--sg-background); } diff --git a/webapp/src/app/modules/keywords-search/search-results/projects-results/projects-results.component.ts b/webapp/src/app/modules/keywords-search/search-results/projects-results/projects-results.component.ts index 61c4e797..aec16222 100644 --- a/webapp/src/app/modules/keywords-search/search-results/projects-results/projects-results.component.ts +++ b/webapp/src/app/modules/keywords-search/search-results/projects-results/projects-results.component.ts @@ -1,111 +1,73 @@ -import { Component, inject, signal } from '@angular/core'; - -import { MatCardModule } from '@angular/material/card'; -import { MatIconModule } from '@angular/material/icon'; - +import { Component, computed, input, signal } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; +import { toSignal } from '@angular/core/rxjs-interop'; +import { DfgInstitutionSummaryPage } from '../../../../api/model/dfgInstitutionSummaryPage'; import { - WeightMap, - WeightSliderOption, - WeightsSlidersComponent, - WeightsSlidersValue, -} from '../../../../shared/ui/weights-sliders/weights-sliders.component'; + CordisEuProjectPage, + DfgProjectPage, + AuthorPage, + InstitutionPageV2, + DfgPersonSummaryPage, + TopicPageV2, +} from '../../../../api'; +import { MatCardModule } from '@angular/material/card'; +import { MatTabsModule } from '@angular/material/tabs'; +import { ProjectFilterComponent } from '../../../../shared/ui/project-filters/project-filters.component'; +import { DfgProjectTableComponent } from '../../../../shared/ui/dfg-project-table/dfg-project-table.component'; +import { EuProjectTableComponent } from '../../../../shared/ui/eu-project-table/eu-project-table.component'; +import { projectQueryParamKeys } from '../../../../resolvers/dfg-projects.resolver'; +import { euProjectQueryParamKeys } from '../../../../resolvers/person-cordis-eu-project-page.resolver'; + +const PROJECT_TAB_QUERY_PARAM_KEY = 'project_type'; + import { SearchResultsStateService } from '../search-results-state.service'; @Component({ selector: 'app-projects-results', - imports: [MatCardModule, MatIconModule, WeightsSlidersComponent], + imports: [ + MatCardModule, + MatTabsModule, + ProjectFilterComponent, + DfgProjectTableComponent, + EuProjectTableComponent, + ], templateUrl: './projects-results.component.html', styleUrl: './projects-results.component.scss', }) export class KeywordsToProjectsResultsComponent { - // injects the state set by the parent route — no duplicate parsing here - private readonly state = inject(SearchResultsStateService); + dfgProjectPage = input.required(); + personCordisEuProjectPage = input.required(); - readonly defaultWeights: WeightMap = { - param1: 0.33, - param2: 0.33, - param3: 0.34, - }; + selectedDfgInstitutionsPage = input.required(); + selectedDfgAuthorsPage = input.required(); + selectedTopicsPage = input.required(); - readonly weightOptions: WeightSliderOption[] = [ - { - key: 'param1', - label: 'Parameter 1', - icon: 'workspace_premium', - description: 'Gewichtet Parameter 1.', - defaultValue: 0.5, - queryParamName: 'wParam1', - }, - { - key: 'param2', - label: 'Parameter 2', - icon: 'workspace_premium', - description: 'Gewichtet Parameter 2.', - defaultValue: 0.5, - queryParamName: 'wParam2', - }, - { - key: 'param3', - label: 'Parameter 3', - icon: 'workspace_premium', - description: 'Gewichtet Parameter 3.', - defaultValue: 0.5, - queryParamName: 'wParam3', - }, - ]; + selectedEuInstitutionsPage = input.required(); + selectedEuAuthorsPage = input.required(); - readonly currentWeights = signal({ - raw: this.defaultWeights, - normalized: { - param1: 0.33, - param2: 0.33, - param3: 0.34, - }, - rawSum: 2.5, - normalizedSum: 1, - valid: true, + readonly dfgQueryParamKeys = projectQueryParamKeys; + readonly euQueryParamKeys = euProjectQueryParamKeys; + + constructor( + private readonly router: Router, + private readonly activatedRoute: ActivatedRoute, + ) {} + loading = signal(false); + queryParamMap = toSignal(this.activatedRoute.queryParamMap, { + initialValue: this.activatedRoute.snapshot.queryParamMap, + }); + readonly fuzzySearch = computed( + () => this.queryParamMap().get('fuzzy') === 'true', + ); + selectedTabIndex = computed(() => { + const type = this.queryParamMap().get(PROJECT_TAB_QUERY_PARAM_KEY); + return type === 'eu' ? 1 : 0; }); - readonly projects = signal([]); // placeholder until the results service lands - - private hasLoadedInitial = false; - - onWeightsChange(value: WeightsSlidersValue): void { - this.currentWeights.set(value); - - // fires once with the query-param-aware initial state — use it to load - if (!this.hasLoadedInitial) { - this.hasLoadedInitial = true; - this.loadprojects(); - } - } - - onApplyWeights(value: WeightsSlidersValue): void { - this.currentWeights.set(value); - this.loadprojects(); - } - - private loadprojects(): void { - const weights = this.currentWeights(); - - const requestPayload = { - manualKeywords: this.state.manualKeywords(), - extractedKeywords: this.state.extractedKeywords(), - keywords: this.state.keywords(), - fuzzy: this.state.fuzzySearch(), - weights: { - raw: weights.raw, - normalized: weights.normalized, - }, - }; - - console.log(requestPayload); - - /** - * TODO: - * this.projectsService.searchprojects(requestPayload).subscribe({ - * next: results => this.projects.set(results), - * error: error => console.error(error), - * }); - */ + onTabChange(index: number): void { + const type = index === 1 ? 'eu' : 'dfg'; + this.router.navigate([], { + queryParams: { [PROJECT_TAB_QUERY_PARAM_KEY]: type }, + queryParamsHandling: 'merge', + }); } } diff --git a/webapp/src/app/modules/keywords-search/search-results/works-results/works-results.component.html b/webapp/src/app/modules/keywords-search/search-results/works-results/works-results.component.html index 0edb91db..7f6d987c 100644 --- a/webapp/src/app/modules/keywords-search/search-results/works-results/works-results.component.html +++ b/webapp/src/app/modules/keywords-search/search-results/works-results/works-results.component.html @@ -5,15 +5,11 @@ [selectedAuthorsPage]="selectedAuthorsPage()" [showTopicFilter]="fuzzySearch()" /> - @if (loading()) { - - } @else { - - } + (false); - - private readonly yearParamKey = workQueryParamKeys.years; - private readonly typeParamKey = workQueryParamKeys.types; - private readonly languageParamKey = workQueryParamKeys.language; private readonly institutionParamKey = workQueryParamKeys.institutionId; private readonly authorParamKey = workQueryParamKeys.authorId; private readonly topicParamKey = workQueryParamKeys.topicId; - private readonly pageParamKey = workQueryParamKeys.page; queryParamMap = toSignal(this.route.queryParamMap, { initialValue: this.route.snapshot.queryParamMap, @@ -87,122 +52,20 @@ export class KeywordsToWorksResultsComponent implements OnInit { this.queryParamMap().getAll(this.topicParamKey), ); - total = computed(() => this.works()?.total ?? 0); - totalElements = computed(() => this.works()?.total ?? 0); - elements = computed(() => this.works()?.elements ?? []); - fuzzySearch = computed(() => this.queryParamMap().get('fuzzy') === 'true'); - - readonly works = toSignal( - this.route.queryParamMap.pipe( - switchMap((params) => this.fetchWorks(params)), - takeUntilDestroyed(this.destroyRef), - ), - { initialValue: EMPTY_WORK_PAGE }, - ); - - private readonly institutionsFromWorks = computed(() => { - const map = new Map(); - for (const work of this.works().elements ?? []) { - for (const authorship of work.authorships ?? []) { - for (const institution of authorship.institutions ?? []) { - if (institution.id) map.set(institution.id, institution); - } - } - } - return map; - }); - private readonly authorsFromWorks = computed(() => { - const map = new Map(); - for (const work of this.works().elements ?? []) { - for (const authorship of work.authorships ?? []) { - const author = authorship.author; - if (author?.id) map.set(author.id, author); - } - } - return map; - }); - - private readonly topicsFromWorks = computed(() => { - const map = new Map(); - for (const work of this.works().elements ?? []) { - for (const topic of work.topics ?? []) { - if (topic.id) map.set(topic.id, topic); - } - } - return map; - }); - selectedAuthors = computed(() => { - const byId = this.authorsFromWorks(); - return this.selectedAuthorIdsQueryParams() - .map((id) => byId.get(id)) - .filter((author): author is Author => !!author); - }); + workPage = input.required(); selectedInstitutionsPage = input.required(); selectedTopicsPage = input.required(); selectedAuthorsPage = input.required(); + total = computed(() => this.workPage().total ?? 0); + totalElements = computed(() => this.workPage().total ?? 0); + elements = computed(() => this.workPage().elements ?? []); + + fuzzySearch = computed(() => this.queryParamMap().get('fuzzy') === 'true'); + ngOnInit(): void {} - private fetchWorks(params: ParamMap) { - this.loading.set(true); - // Base search topics — derived from the keyword→topic mapping. - // This remains the actual search criterion. - const baseTopicIds = this.state - .selectedKeywordEntries() - .map((entry) => entry.topic_mapping?.topic?.id) - .filter((id): id is string => !!id); - - const keywords = this.state.keywords(); - - if (baseTopicIds.length === 0 && keywords.length === 0) { - this.loading.set(false); - return of(EMPTY_WORK_PAGE); - } - const title = params.get('title') ?? undefined; - const filterTopicIds = params.getAll(this.topicParamKey); - const page = Number(params.get(this.pageParamKey)) || 0; - const size = Number(params.get('size')) || 10; - const publicationYears = params - .getAll(this.yearParamKey) - .map(Number) - .filter((year) => !Number.isNaN(year)); - const publicationTypes = params.getAll(this.typeParamKey); - const publicationLanguages = params.getAll(this.languageParamKey); - const institutionIds = params.getAll(this.institutionParamKey); - const authorIds = params.getAll(this.authorParamKey); - const fuzzy = params.get('fuzzy') === 'true'; - const sortBy = (params.get('sort_by') ?? 'publication_year') as WorkSortBy; - const sortDirection = (params.get('sort_direction') ?? - 'desc') as SortDirection; - - return this.worksService - .getWorksByKeywords( - [], - baseTopicIds, - filterTopicIds, - keywords, - fuzzy, - publicationYears, - publicationTypes, - institutionIds, - authorIds, - publicationLanguages, - title, - page, - size, - sortBy, - sortDirection, - ) - .pipe( - catchError((err) => { - console.error(err); - return of(EMPTY_WORK_PAGE); - }), - finalize(() => this.loading.set(false)), - ); - } - clearFilters(): void { this.router.navigate([], { queryParams: { diff --git a/webapp/src/app/resolvers/dfg-projects.resolver.ts b/webapp/src/app/resolvers/dfg-projects.resolver.ts index 7d19daba..ab88d9c7 100644 --- a/webapp/src/app/resolvers/dfg-projects.resolver.ts +++ b/webapp/src/app/resolvers/dfg-projects.resolver.ts @@ -7,17 +7,33 @@ export const projectQueryParamKeys = { size: 'size', title: 'title', institutionId: 'institutionId', - years: 'years', + funding_start: 'funding_start', + funding_end: 'funding_end', authorId: 'authorId', topicId: 'topicId', sortBy: 'sort_by', sortDirection: 'sort_direction', } as const; - +const RESOLVING_PROJECT_PAGE_FOR_KEY = 'resolvingFor'; +export const RESOLVING_PROJECT_PAGE_FOR = { + PERSON: 'PERSON', + KEYWORDS_SEARCH: 'KEYWORDS_SEARCH', +} as const; export const dfgProjectsResolver: ResolveFn = ( route, state, ) => { + const resolvingFor: (typeof RESOLVING_PROJECT_PAGE_FOR)[keyof typeof RESOLVING_PROJECT_PAGE_FOR] = + route.data[RESOLVING_PROJECT_PAGE_FOR_KEY] || + RESOLVING_PROJECT_PAGE_FOR.PERSON; + + console.log( + 'Resolving project page for', + resolvingFor, + 'with route data:', + route.data, + ); + const rawAuthorId = route.parent?.params['id']; const page = Number(route.queryParamMap.get(projectQueryParamKeys.page)) || 0; @@ -30,11 +46,15 @@ export const dfgProjectsResolver: ResolveFn = ( const sortDirection = route.queryParamMap.get(projectQueryParamKeys.sortDirection) || 'asc'; - // TODO: verify ProjectsService.getDfgProjects accepts institution/author - // filters. Wire these in once the service signature supports them. - const topics = route.queryParamMap.getAll(projectQueryParamKeys.topicId); - - const years = route.queryParamMap.getAll(projectQueryParamKeys.years); + const fundingStart = route.queryParamMap.getAll( + projectQueryParamKeys.funding_start, + ); + const fundingEnd = route.queryParamMap.getAll( + projectQueryParamKeys.funding_end, + ); + const filteredTopicIds = route.queryParamMap.getAll( + projectQueryParamKeys.topicId, + ); const institutionIds = route.queryParamMap .getAll(projectQueryParamKeys.institutionId) .map((id) => Number(id)) @@ -43,24 +63,44 @@ export const dfgProjectsResolver: ResolveFn = ( .getAll(projectQueryParamKeys.authorId) .map((id) => Number(id)) .filter((id) => !isNaN(id)); - console.log( - 'RESOLVING', - authorIds, - institutionIds, - topics, - years, - searchTerm, - ); - return inject(ProjectsService).getDfgProjects( - rawAuthorId, - authorIds, - institutionIds, - searchTerm, - topics, - years, - page, - size, - sortBy, - sortDirection, - ); + if (resolvingFor === RESOLVING_PROJECT_PAGE_FOR.PERSON) { + return inject(ProjectsService).getDfgProjects( + rawAuthorId, + authorIds, + institutionIds, + searchTerm, + [], + [], + filteredTopicIds, + fundingStart, + fundingEnd, + page, + size, + sortBy, + sortDirection, + false, + ); + } else if (resolvingFor === RESOLVING_PROJECT_PAGE_FOR.KEYWORDS_SEARCH) { + const keywords = route.queryParamMap.get('keywords')?.split(',') ?? []; + const selectedTopicIds = route.queryParamMap.getAll('topics'); + const fuzzySearch = route.queryParamMap.get('fuzzy') === 'true'; + return inject(ProjectsService).getDfgProjects( + undefined, + authorIds, + institutionIds, + searchTerm, + keywords, + selectedTopicIds, + filteredTopicIds, + fundingStart, + fundingEnd, + page, + size, + sortBy, + sortDirection, + fuzzySearch, + ); + } else { + throw new Error(`Unknown resolvingFor value: ${resolvingFor}`); + } }; diff --git a/webapp/src/app/resolvers/person-cordis-eu-project-page.resolver.ts b/webapp/src/app/resolvers/person-cordis-eu-project-page.resolver.ts index 1bec6001..9632940c 100644 --- a/webapp/src/app/resolvers/person-cordis-eu-project-page.resolver.ts +++ b/webapp/src/app/resolvers/person-cordis-eu-project-page.resolver.ts @@ -15,10 +15,10 @@ export const euProjectQueryParamKeys = { export const personCordisEuProjectPageResolver: ResolveFn< CordisEuProjectPage > = (route, state) => { - const rawAuthorId = route.parent?.paramMap.get('id') ?? null; - if (!rawAuthorId) { - throw new Error('Author ID is required to resolve EU projects.'); - } + const rawAuthorId = route.parent?.params['id']; + // if (!rawAuthorId) { + // throw new Error('Author ID is required to resolve EU projects.'); + // } const page = Number(route.queryParamMap.get(euProjectQueryParamKeys.page)) || 0; @@ -38,7 +38,7 @@ export const personCordisEuProjectPageResolver: ResolveFn< euProjectQueryParamKeys.authorId, ); return inject(ProjectsService).getEuProjectsForAuthor( - rawAuthorId, + rawAuthorId || '1', // searchTerm, // page, // size, diff --git a/webapp/src/app/resolvers/work-page.resolver.ts b/webapp/src/app/resolvers/work-page.resolver.ts index 1d186e9e..f42a153d 100644 --- a/webapp/src/app/resolvers/work-page.resolver.ts +++ b/webapp/src/app/resolvers/work-page.resolver.ts @@ -8,6 +8,7 @@ import { SortDirection, WorkSortBy, WorksV2Service, + WorksService, } from '../api'; import { inject } from '@angular/core'; @@ -15,6 +16,7 @@ const RESOLVING_WORK_PAGE_FOR_KEY = 'resolvingFor'; export const RESOLVING_WORK_PAGE_FOR = { PERSON: 'PERSON', INSTITUTION: 'INSTITUTION', + KEYWORDS_SEARCH: 'KEYWORDS_SEARCH', } as const; export const workQueryParamKeys = { @@ -106,6 +108,55 @@ export const workPageResolver: ResolveFn = ( sortBy, sortDirection, ); + } else if (resolvingFor === RESOLVING_WORK_PAGE_FOR.KEYWORDS_SEARCH) { + const baseTopicIds = route.queryParamMap.get('topics')?.split(',') ?? []; + const keywords = route.queryParamMap.get('keywords')?.split(',') ?? []; + + const title = + route.queryParamMap.get(workQueryParamKeys.title) ?? undefined; + const filterTopicIds = route.queryParamMap.getAll( + workQueryParamKeys.topicId, + ); + const page = Number(route.queryParamMap.get(workQueryParamKeys.page)) || 0; + const size = Number(route.queryParamMap.get(workQueryParamKeys.size)) || 10; + const publicationYears = route.queryParamMap + .getAll(workQueryParamKeys.years) + .map(Number) + .filter((year) => !Number.isNaN(year)); + const publicationTypes = route.queryParamMap.getAll( + workQueryParamKeys.types, + ); + const publicationLanguages = route.queryParamMap.getAll( + workQueryParamKeys.language, + ); + const institutionIds = route.queryParamMap.getAll( + workQueryParamKeys.institutionId, + ); + const authorIds = route.queryParamMap.getAll(workQueryParamKeys.authorId); + const fuzzy = route.queryParamMap.get('fuzzy') === 'true'; + const sortBy = (route.queryParamMap.get(workQueryParamKeys.sortBy) ?? + 'publication_year') as WorkSortBy; + const sortDirection = (route.queryParamMap.get( + workQueryParamKeys.sortDirection, + ) ?? 'desc') as SortDirection; + + return inject(WorksV2Service).getWorksByKeywords( + [], + baseTopicIds, + filterTopicIds, + keywords, + fuzzy, + publicationYears, + publicationTypes, + institutionIds, + authorIds, + publicationLanguages, + title, + page, + size, + sortBy, + sortDirection, + ); } else { throw new Error(`Unknown resolvingFor value: ${resolvingFor}`); }