From af00bc46357230fa96985d092c96922696dd57f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mats=20Paul=20Ton=C4=8Dik?= Date: Sun, 26 Jul 2026 14:49:23 +0200 Subject: [PATCH] feat(publication-search): added publication card search and respective card --- service/src/main/inse/authors/v2/service.py | 2 +- service/src/main/inse/topics/v2/service.py | 3 +- service/src/main/inse/works/v2/router.py | 62 ++++++++++ service/src/main/inse/works/v2/service.py | 87 +++++++++----- webapp/src/app/api/api/worksV2.service.ts | 111 ++++++++++++++++++ webapp/src/app/app.routes.ts | 29 +++++ .../directives/component-tooltip.directive.ts | 22 ++++ .../publications/publications.component.html | 30 +++++ .../publications/publications.component.scss | 10 ++ .../publications/publications.component.ts | 51 ++++++++ .../src/app/resolvers/work-page.resolver.ts | 20 ++++ .../shared/ui/app-menu/app-menu.component.ts | 16 ++- .../app-publication-card.component.html | 53 +++++++++ .../app-publication-card.component.scss | 50 ++++++++ .../app-publication-card.component.ts | 58 +++++++++ .../app-topic-chip.component.html | 1 + .../app-topic-chip.component.scss | 7 +- 17 files changed, 578 insertions(+), 34 deletions(-) create mode 100644 webapp/src/app/modules/publications/publications.component.html create mode 100644 webapp/src/app/modules/publications/publications.component.scss create mode 100644 webapp/src/app/modules/publications/publications.component.ts create mode 100644 webapp/src/app/shared/ui/app-publication-card/app-publication-card.component.html create mode 100644 webapp/src/app/shared/ui/app-publication-card/app-publication-card.component.scss create mode 100644 webapp/src/app/shared/ui/app-publication-card/app-publication-card.component.ts diff --git a/service/src/main/inse/authors/v2/service.py b/service/src/main/inse/authors/v2/service.py index f2abbaba..0c82f1bc 100644 --- a/service/src/main/inse/authors/v2/service.py +++ b/service/src/main/inse/authors/v2/service.py @@ -388,7 +388,7 @@ async def _build_collaboration_graph( f"Searching works for collaboration graph of author {raw_oa_author_id} with query: {query}" ) - work_page: WorkPageV2 = await works_service.search_works( + work_page: WorkPageV2 = await works_service._search_works( query=query, source=COLLABORATION_GRAPH_SOURCE_FIELDS, page=0, diff --git a/service/src/main/inse/topics/v2/service.py b/service/src/main/inse/topics/v2/service.py index d8f3f604..2538b860 100644 --- a/service/src/main/inse/topics/v2/service.py +++ b/service/src/main/inse/topics/v2/service.py @@ -38,11 +38,12 @@ async def _search_topics( hits_block = response.get("hits", {}) hits = hits_block.get("hits", []) + total_hits = hits_block.get("total", {}).get("value", 0) topics: list[Topic] = [] for hit in hits: _source = hit.get("_source", {}) topics.append(Topic.from_dict(_source)) # type: ignore - return TopicPageV2(elements=topics, total=len(topics), page=page, size=size) + return TopicPageV2(elements=topics, total=total_hits, page=page, size=size) async def search_topics( diff --git a/service/src/main/inse/works/v2/router.py b/service/src/main/inse/works/v2/router.py index 02907ba9..b0d413f0 100644 --- a/service/src/main/inse/works/v2/router.py +++ b/service/src/main/inse/works/v2/router.py @@ -22,6 +22,68 @@ logger = logging.getLogger(__name__) router = APIRouter(prefix=RouterPrefixes.WORKS_V2, tags=[Tags.WORKS_V2]) +@router.get( + "/search", + operation_id="searchWorks", + summary="Search works with filters.", +) +async def search_works( + page: Annotated[ + int, Query(description="The page number to retrieve. (0-based)", ge=0) + ] = 0, + size: Annotated[ + int, + Query(description="The number of works to retrieve per page.", ge=1, le=100), + ] = 10, + title: Annotated[ + str, Query(description="A title to filter by (partial matches allowed).") + ] = "", + publication_years: Annotated[ + list[int] | None, + Query(description="A list of publication years to filter by."), + ] = None, + publication_types: Annotated[ + list[str] | None, + Query(description="A list of publication types to filter by."), + ] = None, + author_ids: Annotated[ + list[str] | None, + Query(description="A list of author IDs to filter by."), + ] = None, + institution_ids: Annotated[ + list[str] | None, + Query(description="A list of institution IDs to filter by."), + ] = None, + topic_ids: Annotated[ + list[str] | None, + Query(description="A list of topic IDs to filter by."), + ] = None, + language_codes: Annotated[ + list[str] | None, + Query(description="A list of language codes to filter by."), + ] = None, + sort_by: Annotated[ + WorkSortBy, Query(description="The field to sort by.") + ] = WorkSortBy.PUBLICATION_YEAR, + sort_order: Annotated[ + SortDirection, Query(description="The order to sort by.") + ] = SortDirection.DESCENDING, +) -> WorkPageV2: + return await works_service.search_works( + page=page, + size=size, + title=title, + publication_years=publication_years or [], + publication_types=publication_types or [], + author_ids=author_ids or [], + institution_ids=institution_ids or [], + topic_ids=topic_ids or [], + language_codes=language_codes or [], + sort_by=sort_by, + sort_order=sort_order, + ) + + @router.get( "/author/{raw_oa_author_id}", operation_id="getAuthorWorkPage", diff --git a/service/src/main/inse/works/v2/service.py b/service/src/main/inse/works/v2/service.py index 10f580d2..65f6a358 100644 --- a/service/src/main/inse/works/v2/service.py +++ b/service/src/main/inse/works/v2/service.py @@ -156,7 +156,7 @@ async def _execute_works_search( Returns: WorkPageV2: The page of works matching the search criteria. """ - return await search_works( + return await _search_works( source=[ "id", "title", @@ -180,9 +180,6 @@ async def _execute_works_search( async def get_works( page: int, size: int, - raw_oa_author_id: str | None = None, - raw_oa_institution_id: str | None = None, - raw_oa_topic_id: str | None = None, title: str | None = None, author_ids: list[str] | None = None, institution_ids: list[str] | None = None, @@ -198,9 +195,6 @@ async def get_works( Args: page (int): The page number for pagination. size (int): The number of results per page. - raw_oa_author_id (Optional[str], optional): The ID of the author to filter by. Defaults to None. - raw_oa_institution_id (Optional[str], optional): The ID of the institution to filter by. Defaults to None. - raw_oa_topic_id (Optional[str], optional): The ID of the topic to filter by. Defaults to None. title (Optional[str], optional): The title of the works to filter by. Defaults to None. author_ids (Optional[List[str]], optional): A list of author IDs to filter by. Defaults to None. institution_ids (Optional[List[str]], optional): A list of institution IDs to filter by. Defaults to None. @@ -211,32 +205,18 @@ async def get_works( sort_by (WorkSortBy, optional): The field to sort by. Defaults to WorkSortBy.PUBLICATION_YEAR. sort_order (SortDirection, optional): The direction to sort in. Defaults to SortDirection.DESCENDING. - Raises: - ValueError: If neither raw_oa_author_id nor raw_oa_institution_id nor raw_oa_topic_id is provided. - Returns: WorkPageV2: The page of works matching the criteria. """ - if not raw_oa_author_id and not raw_oa_institution_id and not raw_oa_topic_id: - raise ValueError( - "get_works requires at least one of raw_oa_author_id or raw_oa_institution_id or raw_oa_topic_id" - ) - must: list = [] - if raw_oa_author_id: - must.append(_authors_nested_query(author_ids=[raw_oa_author_id])) - elif author_ids: + if author_ids: must.append(_authors_nested_query(author_ids=author_ids)) - if raw_oa_institution_id: - must.append(_institutions_nested_query(institution_ids=[raw_oa_institution_id])) - elif institution_ids: + if institution_ids: must.append(_institutions_nested_query(institution_ids=institution_ids)) - if raw_oa_topic_id: - must.append(_topics_nested_query(topic_ids=[raw_oa_topic_id])) - elif topic_ids: + if topic_ids: must.append(_topics_nested_query(topic_ids=topic_ids)) _apply_common_filters( @@ -448,7 +428,7 @@ async def get_author_works( return await get_works( page=page, size=size, - raw_oa_author_id=raw_oa_author_id, + author_ids=[raw_oa_author_id], title=title, institution_ids=institution_ids, publication_years=publication_years, @@ -495,7 +475,7 @@ async def get_institution_works( return await get_works( page=page, size=size, - raw_oa_institution_id=raw_oa_institution_id, + institution_ids=[raw_oa_institution_id], author_ids=author_ids, title=title, publication_years=publication_years, @@ -542,7 +522,7 @@ async def get_topic_works( return await get_works( page=page, size=size, - raw_oa_topic_id=raw_oa_topic_id, + topic_ids=[raw_oa_topic_id], title=title, institution_ids=institution_ids, author_ids=author_ids, @@ -554,6 +534,53 @@ async def get_topic_works( ) +async def search_works( + page: int, + size: int, + title: str | None = None, + author_ids: list[str] | None = None, + institution_ids: list[str] | None = None, + publication_years: list[int] | None = None, + publication_types: list[str] | None = None, + topic_ids: list[str] | None = None, + language_codes: list[str] | None = None, + sort_by: WorkSortBy = WorkSortBy.PUBLICATION_YEAR, + sort_order: SortDirection = SortDirection.DESCENDING, +) -> WorkPageV2: + """Searches for works based on the provided criteria. + + Args: + page (int): The page number of the results to retrieve. + size (int): The number of results per page. + title (str | None, optional): The title of the works to filter by. Defaults to None. + author_ids (list[str] | None, optional): A list of author IDs to filter by. Defaults to None. + institution_ids (list[str] | None, optional): A list of institution IDs to filter by. Defaults to None. + publication_years (list[int] | None, optional): A list of publication years to filter by. Defaults to None. + publication_types (list[str] | None, optional): A list of publication types to filter by. Defaults to None. + topic_ids (list[str] | None, optional): A list of topic IDs to filter by. Defaults to None. + language_codes (list[str] | None, optional): A list of language codes to filter by. Defaults to None. + sort_by (WorkSortBy, optional): The field by which to sort the results. Defaults to WorkSortBy.PUBLICATION_YEAR. + sort_order (SortDirection, optional): The direction to sort in. Defaults to SortDirection.DESCENDING. + + Returns: + WorkPageV2: The page of works matching the criteria. + """ + + return await get_works( + page=page, + size=size, + title=title, + author_ids=author_ids, + institution_ids=institution_ids, + publication_years=publication_years, + publication_types=publication_types, + topic_ids=topic_ids, + language_codes=language_codes, + sort_by=sort_by, + sort_order=sort_order, + ) + + async def get_work(raw_oa_work_id: str, source: list[str] | None = None) -> Work | None: """Retrieves a work based on its OpenAlex ID. @@ -566,7 +593,7 @@ async def get_work(raw_oa_work_id: str, source: list[str] | None = None) -> Work """ # search instead of get, because multiple indices are used for works - work_page = await search_works( + work_page = await _search_works( query={"term": {"id": _prefix_id(raw_oa_work_id)}}, source=source, page=0, @@ -578,7 +605,7 @@ async def get_work(raw_oa_work_id: str, source: list[str] | None = None) -> Work return None -async def search_works( +async def _search_works( query: dict | None = None, source: list[str] | None = None, page: int = 0, @@ -636,7 +663,7 @@ async def _get_works_by_work_ids_and_institution_id( prefixed_work_ids = [_prefix_id(wid) for wid in work_ids] prefixed_institution_id = _prefix_id(raw_oa_institution_id) - return await search_works( + return await _search_works( query={ "bool": { "must": [ diff --git a/webapp/src/app/api/api/worksV2.service.ts b/webapp/src/app/api/api/worksV2.service.ts index 993978a0..5f629ee0 100644 --- a/webapp/src/app/api/api/worksV2.service.ts +++ b/webapp/src/app/api/api/worksV2.service.ts @@ -778,4 +778,115 @@ export class WorksV2Service extends BaseService { ); } + /** + * Search works with filters. + * @endpoint get /api/works/v2/search + * @param page The page number to retrieve. (0-based) + * @param size The number of works to retrieve per page. + * @param title A title to filter by (partial matches allowed). + * @param publicationYears A list of publication years to filter by. + * @param publicationTypes A list of publication types to filter by. + * @param authorIds A list of author IDs to filter by. + * @param institutionIds A list of institution IDs to filter by. + * @param topicIds A list of topic IDs to filter by. + * @param languageCodes A list of language codes to filter by. + * @param sortBy The field to sort by. + * @param sortOrder The order to sort by. + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public searchWorks(page?: number, size?: number, title?: string, publicationYears?: Array, publicationTypes?: Array, authorIds?: Array, institutionIds?: Array, topicIds?: Array, languageCodes?: Array, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public searchWorks(page?: number, size?: number, title?: string, publicationYears?: Array, publicationTypes?: Array, authorIds?: Array, institutionIds?: Array, topicIds?: Array, languageCodes?: Array, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public searchWorks(page?: number, size?: number, title?: string, publicationYears?: Array, publicationTypes?: Array, authorIds?: Array, institutionIds?: Array, topicIds?: Array, languageCodes?: Array, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public searchWorks(page?: number, size?: number, title?: string, publicationYears?: Array, publicationTypes?: Array, authorIds?: Array, institutionIds?: Array, topicIds?: Array, languageCodes?: Array, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + + let localVarQueryParameters = new HttpParams({encoder: this.encoder}); + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + page, 'page'); + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + size, 'size'); + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + title, 'title'); + if (publicationYears) { + publicationYears.forEach((element) => { + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + element, 'publication_years'); + }) + } + if (publicationTypes) { + publicationTypes.forEach((element) => { + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + element, 'publication_types'); + }) + } + if (authorIds) { + authorIds.forEach((element) => { + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + element, 'author_ids'); + }) + } + if (institutionIds) { + institutionIds.forEach((element) => { + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + element, 'institution_ids'); + }) + } + if (topicIds) { + topicIds.forEach((element) => { + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + element, 'topic_ids'); + }) + } + if (languageCodes) { + languageCodes.forEach((element) => { + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + element, 'language_codes'); + }) + } + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + sortBy, 'sort_by'); + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + sortOrder, 'sort_order'); + + let localVarHeaders = this.defaultHeaders; + + const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([ + 'application/json' + ]); + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + const localVarHttpContext: HttpContext = options?.context ?? new HttpContext(); + + const localVarTransferCache: boolean = options?.transferCache ?? true; + + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/api/works/v2/search`; + const { basePath, withCredentials } = this.configuration; + return this.httpClient.request('get', `${basePath}${localVarPath}`, + { + context: localVarHttpContext, + params: localVarQueryParameters, + responseType: responseType_, + ...(withCredentials ? { withCredentials } : {}), + headers: localVarHeaders, + observe: observe, + ...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}), + reportProgress: reportProgress + } + ); + } + } diff --git a/webapp/src/app/app.routes.ts b/webapp/src/app/app.routes.ts index 179ee7c9..27ab1022 100644 --- a/webapp/src/app/app.routes.ts +++ b/webapp/src/app/app.routes.ts @@ -710,6 +710,35 @@ export const routes: Routes = [ }, ], }, + { + path: 'publications', + canActivate: [ + roleGuard([ + UserRole.User, + UserRole.Manager, + UserRole.Admin, + UserRole.SuperAdmin, + ]), + ], + loadComponent: () => + import('./modules/publications/publications.component').then( + (mod) => mod.PublicationsComponent, + ), + resolve: { + workPage: workPageResolver, + selectedAuthorsPage: selectedAuthorsResolver, + selectedInstitutionsPage: selectedInstitutionsResolver, + selectedTopicsPage: selectedTopicsResolver, + }, + data: { + resolvingFor: RESOLVING_WORK_PAGE_FOR.PUBLICATION_SEARCH, + }, + runGuardsAndResolvers: (from, to) => { + return Object.values(workQueryParamKeys).some( + (key) => from.queryParamMap.get(key) !== to.queryParamMap.get(key), + ); + }, + }, { path: 'topics', canActivate: [ diff --git a/webapp/src/app/directives/component-tooltip.directive.ts b/webapp/src/app/directives/component-tooltip.directive.ts index eefd8b15..9a945510 100644 --- a/webapp/src/app/directives/component-tooltip.directive.ts +++ b/webapp/src/app/directives/component-tooltip.directive.ts @@ -34,6 +34,7 @@ export class ComponentTooltipDirective implements OnDestroy { readonly tooltipShowDelay = input(150); readonly tooltipHideDelay = input(100); readonly tooltipDisabled = input(false); + readonly tooltipMaxWidth = input(null); private readonly elementRef = inject(ElementRef); private readonly overlay = inject(Overlay); @@ -57,6 +58,13 @@ export class ComponentTooltipDirective implements OnDestroy { } } }); + + effect(() => { + const maxWidth = this.tooltipMaxWidth(); + if (this.overlayRef?.hasAttached()) { + this.applyMaxWidth(this.overlayRef.overlayElement, maxWidth); + } + }); } @HostListener('mouseenter') @@ -141,10 +149,24 @@ export class ComponentTooltipDirective implements OnDestroy { } const overlayElement = this.overlayRef.overlayElement; + this.applyMaxWidth(overlayElement, this.tooltipMaxWidth()); + overlayElement.addEventListener('mouseenter', this.onOverlayEnter); overlayElement.addEventListener('mouseleave', this.onOverlayLeave); } + private applyMaxWidth( + element: HTMLElement, + maxWidth: string | number | null, + ): void { + if (maxWidth === null) { + element.style.maxWidth = ''; + return; + } + element.style.maxWidth = + typeof maxWidth === 'number' ? `${maxWidth}px` : maxWidth; + } + private readonly onOverlayEnter = (): void => { this.isOverOverlay = true; clearTimeout(this.hideTimeout); diff --git a/webapp/src/app/modules/publications/publications.component.html b/webapp/src/app/modules/publications/publications.component.html new file mode 100644 index 00000000..11992125 --- /dev/null +++ b/webapp/src/app/modules/publications/publications.component.html @@ -0,0 +1,30 @@ +
+

Passende Publikationen finden

+ + + + +
+ + + + + + +
+ +
+
diff --git a/webapp/src/app/modules/publications/publications.component.scss b/webapp/src/app/modules/publications/publications.component.scss new file mode 100644 index 00000000..1b215c59 --- /dev/null +++ b/webapp/src/app/modules/publications/publications.component.scss @@ -0,0 +1,10 @@ +.content { + display: flex; + flex-direction: column; + gap: 1rem; + padding: 1rem; +} + +.additional-filters { + margin: 0rem 1rem; +} diff --git a/webapp/src/app/modules/publications/publications.component.ts b/webapp/src/app/modules/publications/publications.component.ts new file mode 100644 index 00000000..50259642 --- /dev/null +++ b/webapp/src/app/modules/publications/publications.component.ts @@ -0,0 +1,51 @@ +import { Component, computed, input } from '@angular/core'; +import { + AuthorPage, + InstitutionPageV2, + SortDirection, + TopicPageV2, + WorkPageV2, + WorkSortBy, +} from '../../api'; +import { + Page, + CardSearchComponent, +} from '../../shared/ui/card-search/card-search.component'; +import { MatDivider } from '@angular/material/divider'; +import { AppPublicationCardComponent } from '../../shared/ui/app-publication-card/app-publication-card.component'; +import { PublicationFilterComponent } from '../../shared/ui/publication-filters/publication-filters.component'; +import { SelectorOption } from '../../shared/ui/query-param-selector/query-param-selector.component'; + +@Component({ + selector: 'app-publications', + imports: [ + MatDivider, + CardSearchComponent, + AppPublicationCardComponent, + PublicationFilterComponent, + ], + templateUrl: './publications.component.html', + styleUrl: './publications.component.scss', +}) +export class PublicationsComponent { + workPage = input.required(); + selectedAuthorsPage = input.required(); + selectedInstitutionsPage = input.required(); + selectedTopicsPage = input.required(); + + page = computed(() => ({ + page: this.workPage().page || 0, + size: this.workPage().size || 10, + total: this.workPage().total || 0, + elements: this.workPage().elements || [], + })); + + sortingOptions: SelectorOption[] = [ + { value: WorkSortBy.Title, display_name: 'Titel' }, + { value: WorkSortBy.CitedByCount, display_name: 'Anzahl Zitationen' }, + ]; + sortingDirectionOptions: SelectorOption[] = [ + { value: SortDirection.Asc, display_name: 'Aufsteigend' }, + { value: SortDirection.Desc, display_name: 'Absteigend' }, + ]; +} diff --git a/webapp/src/app/resolvers/work-page.resolver.ts b/webapp/src/app/resolvers/work-page.resolver.ts index be963c87..4e7b6b04 100644 --- a/webapp/src/app/resolvers/work-page.resolver.ts +++ b/webapp/src/app/resolvers/work-page.resolver.ts @@ -11,6 +11,7 @@ export const RESOLVING_WORK_PAGE_FOR = { PERSON: 'PERSON', INSTITUTION: 'INSTITUTION', TOPIC: 'TOPIC', + PUBLICATION_SEARCH: 'PUBLICATION_SEARCH', KEYWORDS_SEARCH: 'KEYWORDS_SEARCH', } as const; @@ -175,6 +176,25 @@ export const workPageResolver: ResolveFn = ( sortBy, sortDirection, ); + } else if (resolvingFor === RESOLVING_WORK_PAGE_FOR.PUBLICATION_SEARCH) { + const authorIds = route.queryParamMap.getAll(workQueryParamKeys.authorId); + const institutionIds = route.queryParamMap.getAll( + workQueryParamKeys.institutionId, + ); + const topicIds = route.queryParamMap.getAll(workQueryParamKeys.topicId); + return inject(WorksV2Service).searchWorks( + page, + size, + title, + publicationYears, + publicationTypes, + authorIds, + institutionIds, + topicIds, + languages, + WorkSortBy.CitedByCount, + sortDirection, + ); } else { throw new Error(`Unknown resolvingFor value: ${resolvingFor}`); } diff --git a/webapp/src/app/shared/ui/app-menu/app-menu.component.ts b/webapp/src/app/shared/ui/app-menu/app-menu.component.ts index df9ee95e..2db3a978 100644 --- a/webapp/src/app/shared/ui/app-menu/app-menu.component.ts +++ b/webapp/src/app/shared/ui/app-menu/app-menu.component.ts @@ -13,7 +13,8 @@ import { MatCardContent, MatCardModule } from '@angular/material/card'; import { MatProgressSpinner } from '@angular/material/progress-spinner'; import { activeInstitutionPersonListQueryParams } from '../../person-list-query-params'; import { topicQueryParamKeys } from '../../../resolvers/topic-page.resolver'; -import { SortDirection, TopicSortBy } from '../../../api'; +import { SortDirection, TopicSortBy, WorkSortBy } from '../../../api'; +import { workQueryParamKeys } from '../../../resolvers/work-page.resolver'; type NavItem = { label: string; @@ -106,6 +107,19 @@ export class AppMenuComponent { sorting_order: SortDirection.Desc, }, }, + { + label: 'Publikationen', + icon: 'menu_book', + route: '/publications', + disabled: false, + queryParams: { + [workQueryParamKeys.title]: '', + [workQueryParamKeys.page]: 0, + [workQueryParamKeys.size]: 10, + [workQueryParamKeys.sortBy]: WorkSortBy.CitedByCount, + [workQueryParamKeys.sortDirection]: SortDirection.Desc, + }, + }, { label: 'Themen', icon: 'topic', diff --git a/webapp/src/app/shared/ui/app-publication-card/app-publication-card.component.html b/webapp/src/app/shared/ui/app-publication-card/app-publication-card.component.html new file mode 100644 index 00000000..14444dae --- /dev/null +++ b/webapp/src/app/shared/ui/app-publication-card/app-publication-card.component.html @@ -0,0 +1,53 @@ +@let work = this.work(); + + + + {{ work.title }} + + {{ work.publication_year }} - {{ work.type | workType }} - + {{ work.language | languageCode }} + + + + + +
+ @for (topic of topics(); track topic.id) { + + } + @for (author of authors(); track author.id) { + + } +
+ + + +
+
+ format_quote + {{ work.cited_by_count | number: undefined : 'de' }} Zitationen +
+
+
+ + + + + + + open_in_new + Öffnen + + + +
diff --git a/webapp/src/app/shared/ui/app-publication-card/app-publication-card.component.scss b/webapp/src/app/shared/ui/app-publication-card/app-publication-card.component.scss new file mode 100644 index 00000000..ce2961eb --- /dev/null +++ b/webapp/src/app/shared/ui/app-publication-card/app-publication-card.component.scss @@ -0,0 +1,50 @@ +.card-content { + display: flex; + flex-direction: column; + gap: 1rem; + height: 100%; +} + +.subtitle { + display: flex; + align-items: center; + gap: 0.5rem; + color: var(--sg-text-muted); +} + +.metrics { + display: flex; + flex-direction: column; + gap: 0.5rem; + font-size: 0.875rem; +} + +.metric-item { + display: flex; + align-items: center; + gap: 0.25rem; + color: var(--sg-text-muted); +} + +.card-actions { + display: flex; + gap: 0.5rem; +} + +.card-action { + width: 100%; +} + +.chips { + display: flex; + flex-wrap: wrap; + gap: 0.5rem; + height: 100%; +} + +.mat-card-content { + display: flex; + flex-direction: column; + gap: 1rem; + height: 100%; +} diff --git a/webapp/src/app/shared/ui/app-publication-card/app-publication-card.component.ts b/webapp/src/app/shared/ui/app-publication-card/app-publication-card.component.ts new file mode 100644 index 00000000..41c8a29a --- /dev/null +++ b/webapp/src/app/shared/ui/app-publication-card/app-publication-card.component.ts @@ -0,0 +1,58 @@ +import { Component, computed, input } from '@angular/core'; +import { DehydratedAuthor, Work } from '../../../api'; +import { MatCardModule } from '@angular/material/card'; +import { MatIconModule } from '@angular/material/icon'; +import { MatButtonModule } from '@angular/material/button'; +import { RouterModule } from '@angular/router'; +import { MatDividerModule } from '@angular/material/divider'; +import { DecimalPipe } from '@angular/common'; +import { WorkTypePipe } from '../../pipes/work-type.pipe'; +import { LanguageCodePipe } from '../../pipes/language-code.pipe'; +import { AppTopicChipComponent } from '../app-topic-chip/app-topic-chip.component'; +import { AppAuthorChipComponent } from '../app-author-chip/app-author-chip.component'; + +@Component({ + selector: 'app-publication-card', + imports: [ + MatCardModule, + MatIconModule, + MatButtonModule, + RouterModule, + MatDividerModule, + DecimalPipe, + WorkTypePipe, + LanguageCodePipe, + AppTopicChipComponent, + AppAuthorChipComponent, + ], + templateUrl: './app-publication-card.component.html', + styleUrl: './app-publication-card.component.scss', +}) +export class AppPublicationCardComponent { + work = input.required(); + + stripOpenAlexId(id: string | null | undefined): string | undefined { + if (!id) { + return undefined; + } + return id.replace('https://openalex.org/', ''); + } + + topics = computed(() => { + const work = this.work(); + if (!work?.topics) { + return []; + } + return work.topics; + }); + + authors = computed(() => { + const work = this.work(); + if (!work?.authorships) { + return []; + } + return work.authorships + .map((authorship) => authorship.author) + .filter((author): author is DehydratedAuthor => !!author); + }); +} diff --git a/webapp/src/app/shared/ui/app-topic-chip/app-topic-chip.component.html b/webapp/src/app/shared/ui/app-topic-chip/app-topic-chip.component.html index 11bbb37d..7dea292f 100644 --- a/webapp/src/app/shared/ui/app-topic-chip/app-topic-chip.component.html +++ b/webapp/src/app/shared/ui/app-topic-chip/app-topic-chip.component.html @@ -2,6 +2,7 @@ class="topic-chip" [appComponentTooltip]="AppTopicTooltipComponent" [tooltipInputs]="{ topicId: rawOaTopicId() }" + [tooltipMaxWidth]="'500px'" (keydown)="_onChipClick($event)" (click)="_onChipClick($event)"> diff --git a/webapp/src/app/shared/ui/app-topic-chip/app-topic-chip.component.scss b/webapp/src/app/shared/ui/app-topic-chip/app-topic-chip.component.scss index f6e768ce..9ce202bf 100644 --- a/webapp/src/app/shared/ui/app-topic-chip/app-topic-chip.component.scss +++ b/webapp/src/app/shared/ui/app-topic-chip/app-topic-chip.component.scss @@ -3,7 +3,6 @@ --topic-border: color-mix(in srgb, hsl(var(--topic-color)) 72%, #ffffff); font-weight: 500; - background-color: var(--topic-background); border: 1px solid var(--topic-border); border-radius: var(--sg-radius-sm); display: flex; @@ -11,6 +10,12 @@ gap: 0.5rem; } +:host ::ng-deep .topic-chip .mat-mdc-chip-action, +:host ::ng-deep .topic-chip .mdc-evolution-chip__action { + background-color: var(--topic-background); + border-radius: var(--sg-radius-sm); +} + :host.is-clickable { ::ng-deep .mdc-evolution-chip__action { cursor: pointer;