From 8f1462cecc9c0bb9beb8ec3bc7db6065c08518dc Mon Sep 17 00:00:00 2001 From: genja Date: Tue, 14 Jul 2026 13:24:12 +0200 Subject: [PATCH] added stub publications by keywords component --- webapp/src/app/api/api/worksV2.service.ts | 792 ++++++++---------- webapp/src/app/app.routes.ts | 2 + .../works-results.component.html | 58 +- .../works-results.component.scss | 2 +- .../works-results/works-results.component.ts | 235 ++++-- 5 files changed, 564 insertions(+), 525 deletions(-) diff --git a/webapp/src/app/api/api/worksV2.service.ts b/webapp/src/app/api/api/worksV2.service.ts index 077b468c..01f2a30a 100644 --- a/webapp/src/app/api/api/worksV2.service.ts +++ b/webapp/src/app/api/api/worksV2.service.ts @@ -1,7 +1,7 @@ /** * Innovation Search Engine API * - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -9,18 +9,12 @@ */ /* tslint:disable:no-unused-variable member-ordering */ -import { Inject, Injectable, Optional } from '@angular/core'; -import { - HttpClient, - HttpHeaders, - HttpParams, - HttpResponse, - HttpEvent, - HttpParameterCodec, - HttpContext, -} from '@angular/common/http'; -import { CustomHttpParameterCodec } from '../encoder'; -import { Observable } from 'rxjs'; +import { Inject, Injectable, Optional } from '@angular/core'; +import { HttpClient, HttpHeaders, HttpParams, + HttpResponse, HttpEvent, HttpParameterCodec, HttpContext + } from '@angular/common/http'; +import { CustomHttpParameterCodec } from '../encoder'; +import { Observable } from 'rxjs'; // @ts-ignore import { AuthorWorkPage } from '../model/authorWorkPage'; @@ -36,450 +30,364 @@ import { WorkSortBy } from '../model/workSortBy'; import { WorkTopic } from '../model/workTopic'; // @ts-ignore -import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; -import { Configuration } from '../configuration'; +import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; +import { Configuration } from '../configuration'; import { BaseService } from '../api.base.service'; + + @Injectable({ - providedIn: 'root', + providedIn: 'root' }) export class WorksV2Service extends BaseService { - constructor( - protected httpClient: HttpClient, - @Optional() @Inject(BASE_PATH) basePath: string | string[], - @Optional() configuration?: Configuration, - ) { - super(basePath, configuration); - } - /** - * Returns a paginated list of works for a given author based on their ID. - * @endpoint get /api/v2/works/{raw_oa_author_id} - * @param rawOaAuthorId The raw OpenAlex author id. - * @param page The page number to retrieve. (0-based) - * @param size The number of works to retrieve per page. - * @param publicationYears A list of publication years to filter by. - * @param publicationTypes A list of publication types 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 getAuthorWorkPage( - rawOaAuthorId: string, - page?: number, - size?: number, - publicationYears?: Array, - publicationTypes?: 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 getAuthorWorkPage( - rawOaAuthorId: string, - page?: number, - size?: number, - publicationYears?: Array, - publicationTypes?: 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 getAuthorWorkPage( - rawOaAuthorId: string, - page?: number, - size?: number, - publicationYears?: Array, - publicationTypes?: 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 getAuthorWorkPage( - rawOaAuthorId: string, - page?: number, - size?: number, - publicationYears?: Array, - publicationTypes?: 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 { - if (rawOaAuthorId === null || rawOaAuthorId === undefined) { - throw new Error( - 'Required parameter rawOaAuthorId was null or undefined when calling getAuthorWorkPage.', - ); + constructor(protected httpClient: HttpClient, @Optional() @Inject(BASE_PATH) basePath: string|string[], @Optional() configuration?: Configuration) { + super(basePath, configuration); } - let localVarQueryParameters = new HttpParams({ encoder: this.encoder }); - localVarQueryParameters = this.addToHttpParams( - localVarQueryParameters, - page, - 'page', - ); - localVarQueryParameters = this.addToHttpParams( - localVarQueryParameters, - size, - 'size', - ); - if (publicationYears) { - publicationYears.forEach((element) => { - localVarQueryParameters = this.addToHttpParams( - localVarQueryParameters, - element, - 'publication_years', + /** + * Returns a paginated list of works for a given author based on their ID. + * @endpoint get /api/v2/works/{raw_oa_author_id} + * @param rawOaAuthorId The raw OpenAlex author id. + * @param page The page number to retrieve. (0-based) + * @param size The number of works to retrieve per page. + * @param publicationYears A list of publication years to filter by. + * @param publicationTypes A list of publication types 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 getAuthorWorkPage(rawOaAuthorId: string, page?: number, size?: number, publicationYears?: Array, publicationTypes?: 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 getAuthorWorkPage(rawOaAuthorId: string, page?: number, size?: number, publicationYears?: Array, publicationTypes?: 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 getAuthorWorkPage(rawOaAuthorId: string, page?: number, size?: number, publicationYears?: Array, publicationTypes?: 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 getAuthorWorkPage(rawOaAuthorId: string, page?: number, size?: number, publicationYears?: Array, publicationTypes?: 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 { + if (rawOaAuthorId === null || rawOaAuthorId === undefined) { + throw new Error('Required parameter rawOaAuthorId was null or undefined when calling getAuthorWorkPage.'); + } + + let localVarQueryParameters = new HttpParams({encoder: this.encoder}); + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + page, 'page'); + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + size, 'size'); + 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 (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/v2/works/${this.configuration.encodeParam({name: "rawOaAuthorId", value: rawOaAuthorId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`; + 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 + } ); - }); } - if (publicationTypes) { - publicationTypes.forEach((element) => { - localVarQueryParameters = this.addToHttpParams( - localVarQueryParameters, - element, - 'publication_types', + + /** + * Returns a list of institutions based on their IDs. + * @endpoint get /api/v2/works/institutions/search + * @param institutionIds A list of institution IDs to retrieve. + * @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 getInstitutionsByIds(institutionIds?: Array, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getInstitutionsByIds(institutionIds?: Array, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; + public getInstitutionsByIds(institutionIds?: Array, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; + public getInstitutionsByIds(institutionIds?: Array, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + + let localVarQueryParameters = new HttpParams({encoder: this.encoder}); + if (institutionIds) { + institutionIds.forEach((element) => { + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + element, 'institution_ids'); + }) + } + + 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/v2/works/institutions/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 + } ); - }); } - if (institutionIds) { - institutionIds.forEach((element) => { - localVarQueryParameters = this.addToHttpParams( - localVarQueryParameters, - element, - 'institution_ids', + + /** + * Returns a list of work topics based on their IDs. + * @endpoint get /api/v2/works/topics/search + * @param topicIds A list of topic IDs to retrieve. + * @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 getWorkTopicsByIds(topicIds?: Array, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getWorkTopicsByIds(topicIds?: Array, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; + public getWorkTopicsByIds(topicIds?: Array, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; + public getWorkTopicsByIds(topicIds?: Array, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + + let localVarQueryParameters = new HttpParams({encoder: this.encoder}); + if (topicIds) { + topicIds.forEach((element) => { + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + element, 'topic_ids'); + }) + } + + 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/v2/works/topics/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 + } ); - }); } - if (topicIds) { - topicIds.forEach((element) => { - localVarQueryParameters = this.addToHttpParams( - localVarQueryParameters, - element, - 'topic_ids', + + /** + * Search works by topics or raw keywords with filters. + * @endpoint get /api/v2/works/keyword/search + * @param topics List of topics to match. + * @param topicIds List of topic IDs to match. + * @param keywords Raw keywords to search in title/abstract. + * @param fuzzy Use topic resolution if True, otherwise use raw keywords. + * @param publicationYear A list of publication years to filter by. + * @param publicationType A list of publication types to filter by. + * @param institutionIds A list of institution IDs to filter by. + * @param language A list of language codes to filter by. + * @param page The page number to retrieve. (0-based) + * @param size The number of works to retrieve per page. + * @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 getWorksByKeywords(topics?: Array, topicIds?: Array, keywords?: Array, fuzzy?: boolean, publicationYear?: Array, publicationType?: Array, institutionIds?: Array, language?: Array, page?: number, size?: number, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public getWorksByKeywords(topics?: Array, topicIds?: Array, keywords?: Array, fuzzy?: boolean, publicationYear?: Array, publicationType?: Array, institutionIds?: Array, language?: Array, page?: number, size?: number, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getWorksByKeywords(topics?: Array, topicIds?: Array, keywords?: Array, fuzzy?: boolean, publicationYear?: Array, publicationType?: Array, institutionIds?: Array, language?: Array, page?: number, size?: number, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getWorksByKeywords(topics?: Array, topicIds?: Array, keywords?: Array, fuzzy?: boolean, publicationYear?: Array, publicationType?: Array, institutionIds?: Array, language?: Array, page?: number, size?: number, 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}); + if (topics) { + topics.forEach((element) => { + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + element, 'topics'); + }) + } + if (topicIds) { + topicIds.forEach((element) => { + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + element, 'topic_ids'); + }) + } + if (keywords) { + keywords.forEach((element) => { + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + element, 'keywords'); + }) + } + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + fuzzy, 'fuzzy'); + if (publicationYear) { + publicationYear.forEach((element) => { + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + element, 'publication_year'); + }) + } + if (publicationType) { + publicationType.forEach((element) => { + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + element, 'publication_type'); + }) + } + if (institutionIds) { + institutionIds.forEach((element) => { + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + element, 'institution_ids'); + }) + } + if (language) { + language.forEach((element) => { + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + element, 'language'); + }) + } + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + page, 'page'); + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + size, 'size'); + 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/v2/works/keyword/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 + } ); - }); - } - 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/v2/works/${this.configuration.encodeParam({ name: 'rawOaAuthorId', value: rawOaAuthorId, in: 'path', style: 'simple', explode: false, dataType: 'string', dataFormat: undefined })}`; - 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, - }, - ); - } - - /** - * Returns a list of institutions based on their IDs. - * @endpoint get /api/v2/works/institutions/search - * @param institutionIds A list of institution IDs to retrieve. - * @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 getInstitutionsByIds( - institutionIds?: Array, - observe?: 'body', - reportProgress?: boolean, - options?: { - httpHeaderAccept?: 'application/json'; - context?: HttpContext; - transferCache?: boolean; - }, - ): Observable>; - public getInstitutionsByIds( - institutionIds?: Array, - observe?: 'response', - reportProgress?: boolean, - options?: { - httpHeaderAccept?: 'application/json'; - context?: HttpContext; - transferCache?: boolean; - }, - ): Observable>>; - public getInstitutionsByIds( - institutionIds?: Array, - observe?: 'events', - reportProgress?: boolean, - options?: { - httpHeaderAccept?: 'application/json'; - context?: HttpContext; - transferCache?: boolean; - }, - ): Observable>>; - public getInstitutionsByIds( - institutionIds?: Array, - observe: any = 'body', - reportProgress: boolean = false, - options?: { - httpHeaderAccept?: 'application/json'; - context?: HttpContext; - transferCache?: boolean; - }, - ): Observable { - let localVarQueryParameters = new HttpParams({ encoder: this.encoder }); - if (institutionIds) { - institutionIds.forEach((element) => { - localVarQueryParameters = this.addToHttpParams( - localVarQueryParameters, - element, - 'institution_ids', - ); - }); - } - - 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/v2/works/institutions/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, - }, - ); - } - - /** - * Returns a list of work topics based on their IDs. - * @endpoint get /api/v2/works/topics/search - * @param topicIds A list of topic IDs to retrieve. - * @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 getWorkTopicsByIds( - topicIds?: Array, - observe?: 'body', - reportProgress?: boolean, - options?: { - httpHeaderAccept?: 'application/json'; - context?: HttpContext; - transferCache?: boolean; - }, - ): Observable>; - public getWorkTopicsByIds( - topicIds?: Array, - observe?: 'response', - reportProgress?: boolean, - options?: { - httpHeaderAccept?: 'application/json'; - context?: HttpContext; - transferCache?: boolean; - }, - ): Observable>>; - public getWorkTopicsByIds( - topicIds?: Array, - observe?: 'events', - reportProgress?: boolean, - options?: { - httpHeaderAccept?: 'application/json'; - context?: HttpContext; - transferCache?: boolean; - }, - ): Observable>>; - public getWorkTopicsByIds( - topicIds?: Array, - observe: any = 'body', - reportProgress: boolean = false, - options?: { - httpHeaderAccept?: 'application/json'; - context?: HttpContext; - transferCache?: boolean; - }, - ): Observable { - let localVarQueryParameters = new HttpParams({ encoder: this.encoder }); - if (topicIds) { - topicIds.forEach((element) => { - localVarQueryParameters = this.addToHttpParams( - localVarQueryParameters, - element, - 'topic_ids', - ); - }); - } - - 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/v2/works/topics/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 34caa730..55afe7f2 100644 --- a/webapp/src/app/app.routes.ts +++ b/webapp/src/app/app.routes.ts @@ -35,6 +35,7 @@ import { authorWorkPurposesResolver } from './resolvers/author-work-purposes.res import { workPageResolver } from './resolvers/work-page.resolver'; import { selectedTopicsResolver } from './resolvers/selected-topics.resolver'; import { selectedInstitutionsResolver } from './resolvers/selected-institutions.resolver'; +import { SearchResultsStateService } from './modules/keywords-search/search-results/search-results-state.service'; export const routes: Routes = [ { path: '', @@ -127,6 +128,7 @@ export const routes: Routes = [ import('./modules/keywords-search/search-results/search-results.component').then( (mod) => mod.KeywordsSearchResultsComponent, ), + providers: [SearchResultsStateService], children: [ { path: '', pathMatch: 'full', redirectTo: 'persons' }, { path: 'persons', component: KeywordsToPersonsResultsComponent }, 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 0bae9c40..625ad209 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 @@ -1,31 +1,31 @@
- - - groups -

Publikationsliste

-

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

-
-
- - - - - - + @if (works() === null) { + + } @else if (works()?.elements?.length === 0) { + + + groups + Keine Publikationen gefunden. + + + } @else { + + + + + + + }
diff --git a/webapp/src/app/modules/keywords-search/search-results/works-results/works-results.component.scss b/webapp/src/app/modules/keywords-search/search-results/works-results/works-results.component.scss index ffeea20d..409150fd 100644 --- a/webapp/src/app/modules/keywords-search/search-results/works-results/works-results.component.scss +++ b/webapp/src/app/modules/keywords-search/search-results/works-results/works-results.component.scss @@ -3,7 +3,7 @@ ============================================================ */ .result-layout { display: grid; - grid-template-columns: minmax(300px, 420px) 1fr; + grid-template-columns: 1fr; grid-template-areas: 'summary results'; gap: 0.75rem; align-items: start; diff --git a/webapp/src/app/modules/keywords-search/search-results/works-results/works-results.component.ts b/webapp/src/app/modules/keywords-search/search-results/works-results/works-results.component.ts index 44a918fb..3bcf4822 100644 --- a/webapp/src/app/modules/keywords-search/search-results/works-results/works-results.component.ts +++ b/webapp/src/app/modules/keywords-search/search-results/works-results/works-results.component.ts @@ -1,31 +1,61 @@ -import { Component, inject, signal } from '@angular/core'; - +import { + Component, + DestroyRef, + OnInit, + inject, + signal, + computed, +} from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; +import { WeightsSlidersComponent } from '../../../../shared/ui/weights-sliders/weights-sliders.component'; import { MatCardModule } from '@angular/material/card'; import { MatIconModule } from '@angular/material/icon'; - +import { DataTableComponent } from '../../../../shared/ui/data-table/data-table.component'; +import { LoadingComponent } from '../../../../shared/ui/loading/loading.component'; +import { GenericColumn } from '../../../../shared/ui/data-table/data-table.component'; +import { AuthorWork } from '../../../../api/model/authorWork'; +import { PaginationService } from '../../../../shared/services/pagination.service'; +import { QueryParamPaginatorComponent } from '../../../../shared/ui/query-param-paginator/query-param-paginator.component'; import { - WeightMap, WeightSliderOption, - WeightsSlidersComponent, WeightsSlidersValue, + WeightMap, } from '../../../../shared/ui/weights-sliders/weights-sliders.component'; +import { viewChild, TemplateRef } from '@angular/core'; +import { + AuthorWorkPage, + SortDirection, + WorkSortBy, + WorksV2Service, +} from '../../../../api'; + import { SearchResultsStateService } from '../search-results-state.service'; @Component({ selector: 'app-works-results', - imports: [MatCardModule, MatIconModule, WeightsSlidersComponent], + imports: [ + MatCardModule, + MatIconModule, + //WeightsSlidersComponent, + DataTableComponent, + LoadingComponent, + QueryParamPaginatorComponent, + ], templateUrl: './works-results.component.html', styleUrl: './works-results.component.scss', }) -export class KeywordsToWorksResultsComponent { - // injects the state set by the parent route — no duplicate parsing here +export class KeywordsToWorksResultsComponent implements OnInit { private readonly state = inject(SearchResultsStateService); - + private readonly route = inject(ActivatedRoute); + private readonly worksService = inject(WorksV2Service); + private readonly destroyRef = inject(DestroyRef); + public readonly paginationService = inject(PaginationService); + readonly works = signal(null); readonly defaultWeights: WeightMap = { param1: 0.33, param2: 0.33, param3: 0.34, }; - readonly weightOptions: WeightSliderOption[] = [ { key: 'param1', @@ -52,60 +82,159 @@ export class KeywordsToWorksResultsComponent { queryParamName: 'wParam3', }, ]; - readonly currentWeights = signal({ raw: this.defaultWeights, - normalized: { - param1: 0.33, - param2: 0.33, - param3: 0.34, - }, + normalized: { param1: 0.33, param2: 0.33, param3: 0.34 }, rawSum: 2.5, normalizedSum: 1, valid: true, }); + fuzzySearch = signal(false); + totalElements = computed(() => this.works()?.total ?? 0); + elements = computed(() => this.works()?.elements ?? []); - readonly works = signal([]); // placeholder until the results service lands + workColumns: GenericColumn[] = []; + titleTmp = viewChild.required>('titleTmp'); + typeTmp = viewChild.required>('typeTmp'); + yearTmp = viewChild.required>('yearTmp'); + languageTmp = viewChild.required>('languageTmp'); + institutionsTmp = viewChild.required>('institutionsTmp'); + topicsTmp = viewChild.required>('topicsTmp'); + citationsTmp = viewChild.required>('citationsTmp'); + actionsTmp = viewChild.required>('actionsTmp'); + constructor() { + this.route.queryParamMap + .pipe(takeUntilDestroyed(this.destroyRef)) + .subscribe(() => { + const fuzzy = this.route.snapshot.queryParamMap.get('fuzzy') === 'true'; + this.fuzzySearch.set(fuzzy); + console.log('Query params changed, reloading works with fuzzy=', fuzzy); + this.loadWorks(); + }); + } + ngOnInit(): void { + this.loadWorks(); + } + ngAfterViewInit(): void { + this.workColumns = [ + { + id: 'title', + header: 'Titel', + type: 'accessor', + accessorKey: 'title', + }, + { + id: 'type', + header: 'Typ', + type: 'accessor', + accessorKey: 'type', + }, + { + id: 'publication_year', + header: 'Jahr', + type: 'accessor', + accessorKey: 'publication_year', + }, + { + id: 'language', + header: 'Sprache', + type: 'display', + }, + { + id: 'institutions', + header: 'Institutionen', + type: 'display', + }, + { + id: 'topics', + header: 'Themen', + type: 'display', + }, + { + id: 'cited_by_count', + header: 'Zitiert von', + type: 'accessor', + accessorKey: 'cited_by_count', + }, + { + id: 'actions', + header: 'Aktionen', + type: 'display', + }, + ]; + } - private hasLoadedInitial = false; + private loadWorks(): void { + const payload = this.state.payload(); + console.log('GOT PAYLOAD', payload); + + const topicIds = this.state + .selectedKeywordEntries() + .map((entry) => entry.topic_mapping?.topic?.id) + .filter((id): id is string => !!id); + + console.log('GOT TOPIC IDS', topicIds); + + if (topicIds.length === 0) { + console.warn('No topic IDs available'); + return; + } + + const keywords = payload?.keywords ?? []; + + const page = Number(this.route.snapshot.queryParamMap.get('page')) || 1; + + const size = Number(this.route.snapshot.queryParamMap.get('size')) || 10; + + const publicationYears = this.route.snapshot.queryParamMap + .getAll('publicationYear') + .map(Number) + .filter((year) => !Number.isNaN(year)); + + const publicationTypes = + this.route.snapshot.queryParamMap.getAll('publicationType'); + + const institutionIds = this.route.snapshot.queryParamMap.getAll( + 'publicationInstitutionId', + ); + + const sortBy = (this.route.snapshot.queryParamMap.get('sort_by') ?? + 'publication_year') as WorkSortBy; + + const sortDirection = (this.route.snapshot.queryParamMap.get( + 'sort_direction', + ) ?? 'desc') as SortDirection; + + this.worksService + .getWorksByKeywords( + [], + topicIds, + keywords, + this.fuzzySearch(), + publicationYears, + publicationTypes, + institutionIds, + [], + page, + size, + sortBy, + sortDirection, + ) + .pipe(takeUntilDestroyed(this.destroyRef)) + .subscribe({ + next: (page) => { + console.log('GOT WORKS PAGE', page); + this.works.set(page); + }, + error: (err) => console.error(err), + }); + } 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.loadworks(); - } - } - + } // fires once with the query-param-aware initial state — use it to load onApplyWeights(value: WeightsSlidersValue): void { this.currentWeights.set(value); - this.loadworks(); - } - - private loadworks(): 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.worksService.searchworks(requestPayload).subscribe({ - * next: results => this.works.set(results), - * error: error => console.error(error), - * }); - */ - } + this.loadWorks(); + } // reload works with the new weights applied }