diff --git a/webapp/src/app/api/.openapi-generator/FILES b/webapp/src/app/api/.openapi-generator/FILES index 0fa5c409..0da98db0 100644 --- a/webapp/src/app/api/.openapi-generator/FILES +++ b/webapp/src/app/api/.openapi-generator/FILES @@ -53,6 +53,9 @@ model/models.ts model/openAccess.ts model/personBio.ts model/score.ts +model/topicCount.ts +model/topicsByTime.ts +model/topicsByYear.ts model/validationError.ts model/validationErrorLocInner.ts model/value.ts diff --git a/webapp/src/app/api/api/works.service.ts b/webapp/src/app/api/api/works.service.ts index 56e33449..6b6dd9fa 100644 --- a/webapp/src/app/api/api/works.service.ts +++ b/webapp/src/app/api/api/works.service.ts @@ -19,6 +19,8 @@ import { Observable } from 'rxjs'; // @ts-ignore import { HTTPValidationError } from '../model/hTTPValidationError'; // @ts-ignore +import { TopicsByTime } from '../model/topicsByTime'; +// @ts-ignore import { WorkPage } from '../model/workPage'; // @ts-ignore import { WorksListResponse } from '../model/worksListResponse'; @@ -185,4 +187,68 @@ export class WorksService extends BaseService { ); } + /** + * Returns topics grouped by publication year for an author. + * @endpoint get /api/works/{author_id}/topics-by-time + * @param authorId The author id, for example A5023888391. + * @param maxTopicsPerYear The maximum number of topics per year. + * @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 getTopicsByTimeByAuthor(authorId: string, maxTopicsPerYear?: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public getTopicsByTimeByAuthor(authorId: string, maxTopicsPerYear?: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getTopicsByTimeByAuthor(authorId: string, maxTopicsPerYear?: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getTopicsByTimeByAuthor(authorId: string, maxTopicsPerYear?: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + if (authorId === null || authorId === undefined) { + throw new Error('Required parameter authorId was null or undefined when calling getTopicsByTimeByAuthor.'); + } + + let localVarQueryParameters = new HttpParams({encoder: this.encoder}); + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + maxTopicsPerYear, 'max_topics_per_year'); + + let localVarHeaders = this.defaultHeaders; + + // authentication (bearer) required + localVarHeaders = this.configuration.addCredentialToHeaders('bearer', 'Authorization', localVarHeaders, 'Bearer '); + + 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/${this.configuration.encodeParam({name: "authorId", value: authorId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/topics-by-time`; + 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/api/model/models.ts b/webapp/src/app/api/model/models.ts index 7a7099b5..859f206d 100644 --- a/webapp/src/app/api/model/models.ts +++ b/webapp/src/app/api/model/models.ts @@ -35,6 +35,9 @@ export * from './model2YrMeanCitedness'; export * from './openAccess'; export * from './personBio'; export * from './score'; +export * from './topicCount'; +export * from './topicsByTime'; +export * from './topicsByYear'; export * from './validationError'; export * from './validationErrorLocInner'; export * from './value'; diff --git a/webapp/src/app/api/model/topicCount.ts b/webapp/src/app/api/model/topicCount.ts new file mode 100644 index 00000000..d6c3c481 --- /dev/null +++ b/webapp/src/app/api/model/topicCount.ts @@ -0,0 +1,22 @@ +/** + * Innovation Search Engine API + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export interface TopicCount { + /** + * The topic display name. + */ + name: string; + /** + * The number of occurrences. + */ + count?: number; +} + diff --git a/webapp/src/app/api/model/topicsByTime.ts b/webapp/src/app/api/model/topicsByTime.ts new file mode 100644 index 00000000..0dac04a7 --- /dev/null +++ b/webapp/src/app/api/model/topicsByTime.ts @@ -0,0 +1,23 @@ +/** + * Innovation Search Engine API + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +import { TopicsByYear } from './topicsByYear'; + + +export interface TopicsByTime { + /** + * Topics grouped by year. + */ + elements?: Array; + /** + * The number of years. + */ + total?: number; +} + diff --git a/webapp/src/app/api/model/topicsByYear.ts b/webapp/src/app/api/model/topicsByYear.ts new file mode 100644 index 00000000..fded8da0 --- /dev/null +++ b/webapp/src/app/api/model/topicsByYear.ts @@ -0,0 +1,31 @@ +/** + * Innovation Search Engine API + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +import { TopicCount } from './topicCount'; + + +export interface TopicsByYear { + /** + * The publication year. + */ + year: number; + /** + * The number of works in this year. + */ + publication_count?: number; + /** + * The topics in this year. + */ + topics?: Array; + /** + * The primary topics in this year. + */ + primary_topics?: Array; +} + diff --git a/webapp/src/app/modules/person-overview/person-overview.component.ts b/webapp/src/app/modules/person-overview/person-overview.component.ts index 5edfefd6..ef984db6 100644 --- a/webapp/src/app/modules/person-overview/person-overview.component.ts +++ b/webapp/src/app/modules/person-overview/person-overview.component.ts @@ -1,20 +1,16 @@ import { CommonModule } from '@angular/common'; -import { HttpClient } from '@angular/common/http'; import { Component, DestroyRef, OnInit, inject } from '@angular/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { ActivatedRoute, ParamMap } from '@angular/router'; import { combineLatest, distinctUntilChanged, map } from 'rxjs'; +import { TopicCount, TopicsByYear, WorksService } from '../../api'; import { ResearchTimelineComponent, TopicTimelineElement, + TopicTimelineTopic, } from './components/research-timeline/research-timeline.component'; -interface TopicTimelineResponse { - elements: TopicTimelineElement[]; - total: number; -} - @Component({ selector: 'app-person-overview', standalone: true, @@ -24,7 +20,7 @@ interface TopicTimelineResponse { }) export class PersonOverviewComponent implements OnInit { private readonly route = inject(ActivatedRoute); - private readonly http = inject(HttpClient); + private readonly worksService = inject(WorksService); private readonly destroyRef = inject(DestroyRef); topicTimelineElements: TopicTimelineElement[] = []; @@ -63,14 +59,13 @@ export class PersonOverviewComponent implements OnInit { this.timelineLoadFailed = false; const topicCountLimit = 4; - const url = `/inse-service/authors/${encodeURIComponent(authorId)}/topics-by-time?max_topics_per_year=${topicCountLimit}`; - this.http - .get(url) + this.worksService + .getTopicsByTimeByAuthor(authorId, topicCountLimit) .pipe(takeUntilDestroyed(this.destroyRef)) .subscribe({ next: (response) => { - this.topicTimelineElements = response.elements ?? []; + this.topicTimelineElements = this.mapTimelineElements(response.elements); this.loadingTimeline = false; this.timelineLoadFailed = false; }, @@ -82,4 +77,22 @@ export class PersonOverviewComponent implements OnInit { }, }); } -} \ No newline at end of file + + private mapTimelineElements( + elements: TopicsByYear[] | undefined, + ): TopicTimelineElement[] { + return (elements ?? []).map((element) => ({ + year: element.year, + publication_count: element.publication_count ?? 0, + topics: this.mapTopicCounts(element.topics), + primary_topics: this.mapTopicCounts(element.primary_topics), + })); + } + + private mapTopicCounts(topics: TopicCount[] | undefined): TopicTimelineTopic[] { + return (topics ?? []).map((topic) => ({ + name: topic.name, + count: topic.count ?? 0, + })); + } +} diff --git a/webapp/src/proxy.conf.json b/webapp/src/proxy.conf.json index 1e0c9ebd..b6617689 100644 --- a/webapp/src/proxy.conf.json +++ b/webapp/src/proxy.conf.json @@ -4,6 +4,11 @@ "secure": false, "changeOrigin": true }, + "/api/": { + "target": "http://127.0.0.1:8000", + "secure": false, + "changeOrigin": true + }, "/inse-account/": { "target": "http://127.0.0.1:8000", "secure": false,