feat(publication-search): added publication card search and respective card
LocationBasedServices/smartguide/pipeline/head This commit looks good
LocationBasedServices/smartguide/pipeline/head This commit looks good
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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": [
|
||||
|
||||
@@ -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<number>, publicationTypes?: Array<string>, authorIds?: Array<string>, institutionIds?: Array<string>, topicIds?: Array<string>, languageCodes?: Array<string>, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<WorkPageV2>;
|
||||
public searchWorks(page?: number, size?: number, title?: string, publicationYears?: Array<number>, publicationTypes?: Array<string>, authorIds?: Array<string>, institutionIds?: Array<string>, topicIds?: Array<string>, languageCodes?: Array<string>, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<WorkPageV2>>;
|
||||
public searchWorks(page?: number, size?: number, title?: string, publicationYears?: Array<number>, publicationTypes?: Array<string>, authorIds?: Array<string>, institutionIds?: Array<string>, topicIds?: Array<string>, languageCodes?: Array<string>, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<WorkPageV2>>;
|
||||
public searchWorks(page?: number, size?: number, title?: string, publicationYears?: Array<number>, publicationTypes?: Array<string>, authorIds?: Array<string>, institutionIds?: Array<string>, topicIds?: Array<string>, languageCodes?: Array<string>, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
|
||||
|
||||
let localVarQueryParameters = new HttpParams({encoder: this.encoder});
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>page, 'page');
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>size, 'size');
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>title, 'title');
|
||||
if (publicationYears) {
|
||||
publicationYears.forEach((element) => {
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>element, 'publication_years');
|
||||
})
|
||||
}
|
||||
if (publicationTypes) {
|
||||
publicationTypes.forEach((element) => {
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>element, 'publication_types');
|
||||
})
|
||||
}
|
||||
if (authorIds) {
|
||||
authorIds.forEach((element) => {
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>element, 'author_ids');
|
||||
})
|
||||
}
|
||||
if (institutionIds) {
|
||||
institutionIds.forEach((element) => {
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>element, 'institution_ids');
|
||||
})
|
||||
}
|
||||
if (topicIds) {
|
||||
topicIds.forEach((element) => {
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>element, 'topic_ids');
|
||||
})
|
||||
}
|
||||
if (languageCodes) {
|
||||
languageCodes.forEach((element) => {
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>element, 'language_codes');
|
||||
})
|
||||
}
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>sortBy, 'sort_by');
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>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<WorkPageV2>('get', `${basePath}${localVarPath}`,
|
||||
{
|
||||
context: localVarHttpContext,
|
||||
params: localVarQueryParameters,
|
||||
responseType: <any>responseType_,
|
||||
...(withCredentials ? { withCredentials } : {}),
|
||||
headers: localVarHeaders,
|
||||
observe: observe,
|
||||
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
|
||||
reportProgress: reportProgress
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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: [
|
||||
|
||||
@@ -34,6 +34,7 @@ export class ComponentTooltipDirective<T extends object> implements OnDestroy {
|
||||
readonly tooltipShowDelay = input(150);
|
||||
readonly tooltipHideDelay = input(100);
|
||||
readonly tooltipDisabled = input(false);
|
||||
readonly tooltipMaxWidth = input<string | number | null>(null);
|
||||
|
||||
private readonly elementRef = inject(ElementRef);
|
||||
private readonly overlay = inject(Overlay);
|
||||
@@ -57,6 +58,13 @@ export class ComponentTooltipDirective<T extends object> 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<T extends object> 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);
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<div class="content">
|
||||
<h1>Passende Publikationen finden</h1>
|
||||
|
||||
<mat-divider />
|
||||
|
||||
<app-card-search
|
||||
[page]="page()"
|
||||
[cardMinWidth]="500"
|
||||
[cardTmp]="cardTmp"
|
||||
[additionalFiltersTmp]="additionalFiltersTmp"
|
||||
searchLabel="Suche nach Titel"
|
||||
[sortingOptions]="sortingOptions"
|
||||
searchQueryParamKey="title"
|
||||
[sortingDirectionOptions]="sortingDirectionOptions"
|
||||
sortingDirectionQueryParamKey="sort_direction" />
|
||||
</div>
|
||||
|
||||
<ng-template #cardTmp let-work>
|
||||
<app-publication-card [work]="work" />
|
||||
</ng-template>
|
||||
|
||||
<ng-template #additionalFiltersTmp>
|
||||
<div class="additional-filters">
|
||||
<app-publication-filter
|
||||
[selectedAuthorsPage]="selectedAuthorsPage()"
|
||||
[selectedTopicsPage]="selectedTopicsPage()"
|
||||
[selectedInstitutionsPage]="selectedInstitutionsPage()"
|
||||
[showTitleFilter]="false" />
|
||||
</div>
|
||||
</ng-template>
|
||||
@@ -0,0 +1,10 @@
|
||||
.content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.additional-filters {
|
||||
margin: 0rem 1rem;
|
||||
}
|
||||
@@ -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<WorkPageV2>();
|
||||
selectedAuthorsPage = input.required<AuthorPage>();
|
||||
selectedInstitutionsPage = input.required<InstitutionPageV2>();
|
||||
selectedTopicsPage = input.required<TopicPageV2>();
|
||||
|
||||
page = computed<Page>(() => ({
|
||||
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' },
|
||||
];
|
||||
}
|
||||
@@ -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<WorkPageV2> = (
|
||||
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}`);
|
||||
}
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
@let work = this.work();
|
||||
|
||||
<mat-card
|
||||
class="card-content"
|
||||
appearance="outlined"
|
||||
[routerLink]="work.id ? ['/topic', stripOpenAlexId(work.id)] : null">
|
||||
<mat-card-header>
|
||||
<mat-card-title>{{ work.title }}</mat-card-title>
|
||||
<mat-card-subtitle class="subtitle">
|
||||
{{ work.publication_year }} - {{ work.type | workType }} -
|
||||
{{ work.language | languageCode }}</mat-card-subtitle
|
||||
>
|
||||
</mat-card-header>
|
||||
|
||||
<mat-divider />
|
||||
|
||||
<mat-card-content class="mat-card-content">
|
||||
<div class="chips">
|
||||
@for (topic of topics(); track topic.id) {
|
||||
<app-topic-chip-2 [topic]="topic" />
|
||||
}
|
||||
@for (author of authors(); track author.id) {
|
||||
<app-author-chip [author]="author" />
|
||||
}
|
||||
</div>
|
||||
|
||||
<mat-divider />
|
||||
|
||||
<div class="metrics">
|
||||
<div class="metric-item">
|
||||
<mat-icon>format_quote</mat-icon>
|
||||
<span
|
||||
>{{ work.cited_by_count | number: undefined : 'de' }} Zitationen</span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card-content>
|
||||
|
||||
<mat-divider />
|
||||
|
||||
<mat-card-footer>
|
||||
<mat-card-actions class="card-actions">
|
||||
<a
|
||||
class="card-action"
|
||||
[routerLink]="['/publication', stripOpenAlexId(work.id)]"
|
||||
matButton="outlined"
|
||||
(click)="$event.stopPropagation()">
|
||||
<mat-icon>open_in_new</mat-icon>
|
||||
Öffnen
|
||||
</a>
|
||||
</mat-card-actions>
|
||||
</mat-card-footer>
|
||||
</mat-card>
|
||||
@@ -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%;
|
||||
}
|
||||
@@ -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<Work>();
|
||||
|
||||
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<DehydratedAuthor[]>(() => {
|
||||
const work = this.work();
|
||||
if (!work?.authorships) {
|
||||
return [];
|
||||
}
|
||||
return work.authorships
|
||||
.map((authorship) => authorship.author)
|
||||
.filter((author): author is DehydratedAuthor => !!author);
|
||||
});
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
class="topic-chip"
|
||||
[appComponentTooltip]="AppTopicTooltipComponent"
|
||||
[tooltipInputs]="{ topicId: rawOaTopicId() }"
|
||||
[tooltipMaxWidth]="'500px'"
|
||||
(keydown)="_onChipClick($event)"
|
||||
(click)="_onChipClick($event)">
|
||||
<span class="chip-content">
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user