feat(work-classifications): optimized aggregation retrieval, moved chart to own component, and added chart for institution publications
LocationBasedServices/smartguide/pipeline/head This commit looks good

This commit is contained in:
Mats Paul Tončik
2026-07-20 21:11:17 +02:00
parent 9da17840ad
commit a5664e01fe
29 changed files with 980 additions and 667 deletions
+2 -2
View File
@@ -188,6 +188,8 @@ model/patentsByKeywordsRequest.ts
model/patentsByKeywordsResponse.ts
model/personBio.ts
model/personBookmarkResponse.ts
model/primaryCategoryYearAggregation.ts
model/primaryCategoryYearAggregationPage.ts
model/projectType.ts
model/projectsFilteringProperties.ts
model/projectsSortBy.ts
@@ -238,8 +240,6 @@ model/workClassification.ts
model/workClassificationAuthor.ts
model/workClassificationDetails.ts
model/workClassificationInstitution.ts
model/workClassificationMerge.ts
model/workClassificationMergePage.ts
model/workClassificationMeta.ts
model/workClassificationPage.ts
model/workClassificationTopic.ts
+138 -61
View File
@@ -19,12 +19,12 @@ import { Observable } from 'rxjs';
// @ts-ignore
import { HTTPValidationError } from '../model/hTTPValidationError';
// @ts-ignore
import { PrimaryCategoryYearAggregationPage } from '../model/primaryCategoryYearAggregationPage';
// @ts-ignore
import { SortDirection } from '../model/sortDirection';
// @ts-ignore
import { WorkClassification } from '../model/workClassification';
// @ts-ignore
import { WorkClassificationMergePage } from '../model/workClassificationMergePage';
// @ts-ignore
import { WorkClassificationPage } from '../model/workClassificationPage';
// @ts-ignore
import { WorkPageV2 } from '../model/workPageV2';
@@ -263,6 +263,142 @@ export class WorksV2Service extends BaseService {
);
}
/**
* Returns the primary category aggregations of works for a given author based on their ID
* @endpoint get /api/v2/works/author/{raw_oa_author_id}/primary-category-aggregations
* @param rawOaAuthorId The raw OpenAlex author id.
* @param yearSize The number of years to retrieve aggregations for.
* @param categorySize The number of categories to retrieve aggregations for.
* @param secureFgpAcc
* @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 getPrimaryCategoryAggregationsByAuthorId(rawOaAuthorId: string, yearSize?: number, categorySize?: number, secureFgpAcc?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<PrimaryCategoryYearAggregationPage>;
public getPrimaryCategoryAggregationsByAuthorId(rawOaAuthorId: string, yearSize?: number, categorySize?: number, secureFgpAcc?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<PrimaryCategoryYearAggregationPage>>;
public getPrimaryCategoryAggregationsByAuthorId(rawOaAuthorId: string, yearSize?: number, categorySize?: number, secureFgpAcc?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<PrimaryCategoryYearAggregationPage>>;
public getPrimaryCategoryAggregationsByAuthorId(rawOaAuthorId: string, yearSize?: number, categorySize?: number, secureFgpAcc?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
if (rawOaAuthorId === null || rawOaAuthorId === undefined) {
throw new Error('Required parameter rawOaAuthorId was null or undefined when calling getPrimaryCategoryAggregationsByAuthorId.');
}
let localVarQueryParameters = new HttpParams({encoder: this.encoder});
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>yearSize, 'year_size');
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>categorySize, 'category_size');
let localVarHeaders = this.defaultHeaders;
// authentication (HTTPBearer) required
localVarHeaders = this.configuration.addCredentialToHeaders('HTTPBearer', '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/v2/works/author/${this.configuration.encodeParam({name: "rawOaAuthorId", value: rawOaAuthorId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/primary-category-aggregations`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<PrimaryCategoryYearAggregationPage>('get', `${basePath}${localVarPath}`,
{
context: localVarHttpContext,
params: localVarQueryParameters,
responseType: <any>responseType_,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
observe: observe,
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
reportProgress: reportProgress
}
);
}
/**
* Returns the primary category aggregations of works for a given institution based on their ID.
* @endpoint get /api/v2/works/institution/{raw_oa_institution_id}/primary-category-aggregations
* @param rawOaInstitutionId The raw OpenAlex institution id.
* @param yearSize The number of years to retrieve aggregations for.
* @param categorySize The number of categories to retrieve aggregations for.
* @param secureFgpAcc
* @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 getPrimaryCategoryAggregationsByInstitutionId(rawOaInstitutionId: string, yearSize?: number, categorySize?: number, secureFgpAcc?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<PrimaryCategoryYearAggregationPage>;
public getPrimaryCategoryAggregationsByInstitutionId(rawOaInstitutionId: string, yearSize?: number, categorySize?: number, secureFgpAcc?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<PrimaryCategoryYearAggregationPage>>;
public getPrimaryCategoryAggregationsByInstitutionId(rawOaInstitutionId: string, yearSize?: number, categorySize?: number, secureFgpAcc?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<PrimaryCategoryYearAggregationPage>>;
public getPrimaryCategoryAggregationsByInstitutionId(rawOaInstitutionId: string, yearSize?: number, categorySize?: number, secureFgpAcc?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
if (rawOaInstitutionId === null || rawOaInstitutionId === undefined) {
throw new Error('Required parameter rawOaInstitutionId was null or undefined when calling getPrimaryCategoryAggregationsByInstitutionId.');
}
let localVarQueryParameters = new HttpParams({encoder: this.encoder});
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>yearSize, 'year_size');
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>categorySize, 'category_size');
let localVarHeaders = this.defaultHeaders;
// authentication (HTTPBearer) required
localVarHeaders = this.configuration.addCredentialToHeaders('HTTPBearer', '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/v2/works/institution/${this.configuration.encodeParam({name: "rawOaInstitutionId", value: rawOaInstitutionId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/primary-category-aggregations`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<PrimaryCategoryYearAggregationPage>('get', `${basePath}${localVarPath}`,
{
context: localVarHttpContext,
params: localVarQueryParameters,
responseType: <any>responseType_,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
observe: observe,
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
reportProgress: reportProgress
}
);
}
/**
* Returns the classifications of a work based on its ID.
* @endpoint get /api/v2/works/classification/work/{raw_oa_work_id}
@@ -322,65 +458,6 @@ export class WorksV2Service extends BaseService {
);
}
/**
* Returns the classifications of an author\&#39;s works based on their ID.
* @endpoint get /api/v2/works/classification/author/{raw_oa_author_id}
* @param rawOaAuthorId The raw OpenAlex author id.
* @param secureFgpAcc
* @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 getWorkClassificationsByAuthorId(rawOaAuthorId: string, secureFgpAcc?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<WorkClassificationMergePage>;
public getWorkClassificationsByAuthorId(rawOaAuthorId: string, secureFgpAcc?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<WorkClassificationMergePage>>;
public getWorkClassificationsByAuthorId(rawOaAuthorId: string, secureFgpAcc?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<WorkClassificationMergePage>>;
public getWorkClassificationsByAuthorId(rawOaAuthorId: string, secureFgpAcc?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
if (rawOaAuthorId === null || rawOaAuthorId === undefined) {
throw new Error('Required parameter rawOaAuthorId was null or undefined when calling getWorkClassificationsByAuthorId.');
}
let localVarHeaders = this.defaultHeaders;
// authentication (HTTPBearer) required
localVarHeaders = this.configuration.addCredentialToHeaders('HTTPBearer', '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/v2/works/classification/author/${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<WorkClassificationMergePage>('get', `${basePath}${localVarPath}`,
{
context: localVarHttpContext,
responseType: <any>responseType_,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
observe: observe,
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
reportProgress: reportProgress
}
);
}
/**
* Returns the classifications of works based on their IDs.
* @endpoint get /api/v2/works/classification/works/search
+3
View File
@@ -10,6 +10,9 @@
import { Author } from './author';
/**
* A paginated response containing a list of authors.
*/
export interface AuthorPage {
/**
* The elements of the page.
@@ -1,23 +1,25 @@
/**
* 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.
*/
/**
* A summary of a DFG institution.
*/
export interface DfgInstitutionSummary {
id: number;
institute_name_de?: string | null;
institute_name_en?: string | null;
root_id?: number | null;
root_name_de?: string | null;
root_name_en?: string | null;
address_country_de?: string | null;
address_country_en?: string | null;
export interface DfgInstitutionSummary {
id: number;
institute_name_de?: string | null;
institute_name_en?: string | null;
root_id?: number | null;
root_name_de?: string | null;
root_name_en?: string | null;
address_country_de?: string | null;
address_country_en?: string | null;
}
+11 -9
View File
@@ -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,12 +9,14 @@
*/
import { DfgInstitutionSummary } from './dfgInstitutionSummary';
export interface DfgPersonSummary {
person_id: number;
orcid_id?: string | null;
project_ref_id?: number | null;
full_name?: string | null;
role_label_en?: string | null;
role_label_de?: string | null;
institution?: DfgInstitutionSummary | null;
export interface DfgPersonSummary {
person_id: number;
orcid_id?: string | null;
project_ref_id?: number | null;
full_name?: string | null;
role_label_en?: string | null;
role_label_de?: string | null;
institution?: DfgInstitutionSummary | null;
}
+26 -24
View File
@@ -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
@@ -11,27 +11,29 @@ import { DfgInstitutionSummary } from './dfgInstitutionSummary';
import { DFGProjectFachgebieteInner } from './dFGProjectFachgebieteInner';
import { DfgPersonSummary } from './dfgPersonSummary';
export interface DfgProjectSummary {
/**
* The unique identifier of the DFG project.
*/
id: string;
link?: string | null;
title?: string | null;
professional_classification?: string | null;
funding_start?: string | null;
funding_end?: string | null;
/**
* Institutions associated with the project.
*/
institutions?: Array<DfgInstitutionSummary>;
/**
* The names of the persons involved in the DFG project.
*/
names?: Array<string>;
/**
* The persons involved in the DFG project.
*/
persons?: Array<DfgPersonSummary>;
subject_classifications?: Array<DFGProjectFachgebieteInner> | null;
export interface DfgProjectSummary {
/**
* The unique identifier of the DFG project.
*/
id: string;
link?: string | null;
title?: string | null;
professional_classification?: string | null;
funding_start?: string | null;
funding_end?: string | null;
/**
* Institutions associated with the project.
*/
institutions?: Array<DfgInstitutionSummary>;
/**
* The names of the persons involved in the DFG project.
*/
names?: Array<string>;
/**
* The persons involved in the DFG project.
*/
persons?: Array<DfgPersonSummary>;
subject_classifications?: Array<DFGProjectFachgebieteInner> | null;
}
@@ -10,6 +10,9 @@
import { Institution } from './institution';
/**
* A paginated response containing a list of institutions.
*/
export interface InstitutionPageV2 {
/**
* The elements of the page.
+2 -2
View File
@@ -154,6 +154,8 @@ export * from './patentsByKeywordsRequest';
export * from './patentsByKeywordsResponse';
export * from './personBio';
export * from './personBookmarkResponse';
export * from './primaryCategoryYearAggregation';
export * from './primaryCategoryYearAggregationPage';
export * from './projectType';
export * from './projectsFilteringProperties';
export * from './projectsSortBy';
@@ -204,8 +206,6 @@ export * from './workClassification';
export * from './workClassificationAuthor';
export * from './workClassificationDetails';
export * from './workClassificationInstitution';
export * from './workClassificationMerge';
export * from './workClassificationMergePage';
export * from './workClassificationMeta';
export * from './workClassificationPage';
export * from './workClassificationTopic';
@@ -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 PrimaryCategoryYearAggregation {
/**
* The publication year.
*/
publication_year: number;
/**
* A mapping of primary categories to their counts for the given year.
*/
categories?: { [key: string]: number; };
}
@@ -7,14 +7,14 @@
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { WorkClassificationMerge } from './workClassificationMerge';
import { PrimaryCategoryYearAggregation } from './primaryCategoryYearAggregation';
export interface WorkClassificationMergePage {
export interface PrimaryCategoryYearAggregationPage {
/**
* The elements of the page.
*/
elements?: Array<WorkClassificationMerge>;
elements?: Array<PrimaryCategoryYearAggregation>;
/**
* The page number. (0-based)
*/
@@ -1,21 +0,0 @@
/**
* 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 { WorkClassification } from './workClassification';
import { Work } from './work';
export interface WorkClassificationMerge {
/**
* The OpenAlex work object.
*/
work: Work;
classification?: WorkClassification | null;
}
+5 -3
View File
@@ -39,10 +39,10 @@ import { roleGuard } from './shared/guards/role.guard';
import { UserRole } from './api';
import { personCordisEuProjectPageResolver } from './resolvers/person-cordis-eu-project-page.resolver';
import { selectedAuthorsResolver } from './resolvers/selected-authors.resolver';
import { authorWorkClassificationPageResolver } from './resolvers/author-work-classification-page.resolver';
import { workClassificationResolver } from './resolvers/work-classification.resolver';
import { selectedDfgAuthorsResolver } from './resolvers/selected-dfg-authors.resolver';
import { selectedDfgInstitutionsResolver } from './resolvers/selected-dfg-institutions.resolver';
import { primaryCategoryYearAggregationPageResolver } from './resolvers/primary-category-year-aggregation-page.resolver';
export const routes: Routes = [
{
path: '',
@@ -400,8 +400,8 @@ export const routes: Routes = [
selectedTopicsPage: selectedTopicsResolver,
selectedInstitutionsPage: selectedInstitutionsResolver,
authorWorkPage: workPageResolver,
authorWorkClassificationMergePage:
authorWorkClassificationPageResolver,
primaryCategoryYearAggregationPage:
primaryCategoryYearAggregationPageResolver,
},
data: {
resolvingFor: RESOLVING_WORK_PAGE_FOR.PERSON,
@@ -527,6 +527,8 @@ export const routes: Routes = [
selectedAuthorsPage: selectedAuthorsResolver,
selectedTopicsPage: selectedTopicsResolver,
institutionWorkPage: workPageResolver,
primaryCategoryYearAggregationPage:
primaryCategoryYearAggregationPageResolver,
},
data: {
resolvingFor: RESOLVING_WORK_PAGE_FOR.INSTITUTION,
@@ -1,4 +1,35 @@
<div class="content">
<div>
<h6>Publikationen</h6>
<p>Übersicht der wissenschaftlichen Veröffentlichungen.</p>
</div>
@if (canViewClassificationChart()) {
<mat-accordion multi>
<mat-expansion-panel class="mat-elevation-z1">
<mat-expansion-panel-header>
<mat-panel-title>Forschungszwecke</mat-panel-title>
</mat-expansion-panel-header>
<app-primary-category-year-aggregation-chart
[page]="primaryCategoryYearAggregationPage()" />
</mat-expansion-panel>
<mat-expansion-panel class="mat-elevation-z1" [expanded]="true">
<mat-expansion-panel-header>
<mat-panel-title>Publikationsliste</mat-panel-title>
<mat-panel-description
>{{ total() >= 10000 ? 'mehr als' : '' }}
{{ total() }} Publikationen</mat-panel-description
>
</mat-expansion-panel-header>
<ng-container *ngTemplateOutlet="filterTableAndPaginator" />
</mat-expansion-panel>
</mat-accordion>
} @else {
<ng-container *ngTemplateOutlet="filterTableAndPaginator" />
}
</div>
<ng-template #filterTableAndPaginator>
<app-publication-filter
[selectedAuthorsPage]="selectedAuthorsPage()"
[selectedTopicsPage]="selectedTopicsPage()"
@@ -12,4 +43,4 @@
[total]="total()"
queryParamPageKey="page"
queryParamSizeKey="size" />
</div>
</ng-template>
@@ -4,3 +4,25 @@
gap: 1rem;
padding: 2rem;
}
mat-expansion-panel {
border: 1px solid var(--sg-border);
border-radius: var(--sg-radius-sm);
background: var(--sg-none);
box-shadow: none;
}
mat-expansion-panel-header {
padding: 0 16px;
min-height: 48px;
}
mat-panel-title {
font-size: 16px;
font-weight: 700;
}
mat-panel-description {
font-size: 14px;
color: var(--sg-text-muted);
}
@@ -1,8 +1,16 @@
import { Component, computed, input } from '@angular/core';
import { PublicationTableComponent } from '../../shared/ui/publication-table/publication-table.component';
import { Author, AuthorPage, TopicPageV2, WorkPageV2, WorkTopic } from '../../api';
import {
AuthorPage,
PrimaryCategoryYearAggregationPage,
TopicPageV2,
WorkPageV2,
} from '../../api';
import { QueryParamPaginatorComponent } from '../../shared/ui/query-param-paginator/query-param-paginator.component';
import { PublicationFilterComponent } from '../../shared/ui/publication-filters/publication-filters.component';
import { PrimaryCategoryYearAggregationChartComponent } from '../../shared/ui/primary-category-year-aggregation-chart/primary-category-year-aggregation-chart.component';
import { MatExpansionModule } from '@angular/material/expansion';
import { CommonModule } from '@angular/common';
@Component({
selector: 'app-institution-publications',
@@ -10,6 +18,9 @@ import { PublicationFilterComponent } from '../../shared/ui/publication-filters/
PublicationTableComponent,
QueryParamPaginatorComponent,
PublicationFilterComponent,
PrimaryCategoryYearAggregationChartComponent,
MatExpansionModule,
CommonModule,
],
templateUrl: './institution-publications.component.html',
styleUrl: './institution-publications.component.scss',
@@ -18,6 +29,13 @@ export class InstitutionPublicationsComponent {
institutionWorkPage = input.required<WorkPageV2>();
selectedAuthorsPage = input.required<AuthorPage>();
selectedTopicsPage = input.required<TopicPageV2>();
primaryCategoryYearAggregationPage =
input.required<PrimaryCategoryYearAggregationPage>();
total = computed(() => this.institutionWorkPage().total ?? 0);
canViewClassificationChart = computed(() => {
const page = this.primaryCategoryYearAggregationPage();
return (page?.elements?.length ?? 0) > 0;
});
}
@@ -3,75 +3,45 @@
<h6>Publikationen</h6>
<p>Übersicht der wissenschaftlichen Veröffentlichungen.</p>
</div>
<mat-accordion [multi]="true" app>
<mat-expansion-panel class="mat-elevation-z1">
<mat-expansion-panel-header>
<mat-panel-title>Forschungszwecke</mat-panel-title>
</mat-expansion-panel-header>
@if (this.authorWorkClassificationsMerges().length === 0) {
<div class="no-results">Keine Publikationen gefunden.</div>
} @else {
<div
echarts
[options]="chartOption"
style="height: 300px; width: 100%"></div>
}
<div class="purpose-info-cards">
<app-info-card
[value]="this.basicResearchAmount() + ''"
[description]="this.basicResearchLabel" />
<app-info-card
[value]="this.appliedResearchAmount() + ''"
[description]="this.appliedResearchLabel" />
<app-info-card
[value]="this.nonResearchAmount() + ''"
[description]="this.nonResearchLabel" />
<app-info-card
[value]="this.experimentalDevelopmentAmount() + ''"
[description]="this.experimentalDevelopmentLabel" />
<app-info-card
[value]="this.notClassifiedAmount() + ''"
[description]="this.notClassifiedLabel" />
<div>
<div class="classification-disclaimer">
<button
mat-icon-button
matTooltip="Du siehst ausschließlich klassifizierte Publikationen, welche deiner Institution zugeordnet sind. Publikationen von anderen Institutionen werden nicht angezeigt.">
<mat-icon>info_outline</mat-icon>
</button>
<span
>Im Diagramm sind ausschließlich klassifizierte Publikationen
deiner Institution enthalten.</span
>
</div>
</div>
</div>
</mat-expansion-panel>
@if (canViewClassificationChart()) {
<mat-accordion multi>
<mat-expansion-panel class="mat-elevation-z1">
<mat-expansion-panel-header>
<mat-panel-title>Forschungszwecke</mat-panel-title>
</mat-expansion-panel-header>
<app-primary-category-year-aggregation-chart
[page]="primaryCategoryYearAggregationPage()" />
</mat-expansion-panel>
<mat-expansion-panel class="mat-elevation-z1" [expanded]="true">
<mat-expansion-panel-header>
<mat-panel-title>Publikationsliste</mat-panel-title>
<mat-panel-description
>{{ total() }} Publikationen</mat-panel-description
>
</mat-expansion-panel-header>
<div class="publication-list">
<app-publication-filter
[selectedTopicsPage]="selectedTopicsPage()"
[selectedInstitutionsPage]="selectedInstitutionsPage()"
[showAuthorFilter]="false" />
<app-publication-table
[page]="authorWorkPage()"
[institutionFilterEnabled]="true" />
<app-query-param-paginator
[total]="total()"
queryParamPageKey="page"
queryParamSizeKey="size"
[pageSizeOptions]="[10, 25, 50]" />
</div>
</mat-expansion-panel>
</mat-accordion>
<mat-expansion-panel class="mat-elevation-z1" [expanded]="true">
<mat-expansion-panel-header>
<mat-panel-title>Publikationsliste</mat-panel-title>
<mat-panel-description
>{{ total() >= 10000 ? 'mehr als' : '' }}
{{ total() }} Publikationen</mat-panel-description
>
</mat-expansion-panel-header>
<ng-container *ngTemplateOutlet="filterTableAndPaginator" />
</mat-expansion-panel>
</mat-accordion>
} @else {
<ng-container *ngTemplateOutlet="filterTableAndPaginator" />
}
</div>
<ng-template #filterTableAndPaginator>
<app-publication-filter
[selectedTopicsPage]="selectedTopicsPage()"
[selectedInstitutionsPage]="selectedInstitutionsPage()"
[showAuthorFilter]="false" />
<app-publication-table
[page]="authorWorkPage()"
[institutionFilterEnabled]="true" />
<app-query-param-paginator
[total]="total()"
queryParamPageKey="page"
queryParamSizeKey="size"
[pageSizeOptions]="[10, 25, 50]" />
</ng-template>
@@ -1,62 +1,27 @@
import { Component, computed, effect, input } from '@angular/core';
import { Component, computed, input } from '@angular/core';
import {
WorkPageV2,
Author,
WorkTopic,
WorkPrimaryCategory,
WorkClassificationMerge,
WorkClassificationMergePage,
InstitutionPageV2,
TopicPageV2,
PrimaryCategoryYearAggregationPage,
} from '../../api';
import { NgxEchartsDirective } from 'ngx-echarts';
import * as echarts from 'echarts/core';
import {
GridComponent,
LegendComponent,
TitleComponent,
} from 'echarts/components';
import { CanvasRenderer } from 'echarts/renderers';
import { GraphChart } from 'echarts/charts';
import { MatExpansionModule } from '@angular/material/expansion';
import { QueryParamPaginatorComponent } from '../../shared/ui/query-param-paginator/query-param-paginator.component';
import { AppInfoCardComponent } from '../../shared/ui/app-info-card/app-info-card.component';
import { PublicationTableComponent } from '../../shared/ui/publication-table/publication-table.component';
import { PublicationFilterComponent } from '../../shared/ui/publication-filters/publication-filters.component';
import { transformWorkPrimaryCategory } from '../../shared/pipes/work-primary-category.pipe';
import { MatIconModule } from '@angular/material/icon';
import { MatButtonModule } from '@angular/material/button';
import { MatTooltipModule } from '@angular/material/tooltip';
echarts.use([
GridComponent,
CanvasRenderer,
GraphChart,
TitleComponent,
LegendComponent,
]);
interface YearlyPurposeCounts {
year: number;
basicResearch: number;
appliedResearch: number;
nonResearch: number;
experimentalDevelopment: number;
notClassified: number;
}
import { PrimaryCategoryYearAggregationChartComponent } from '../../shared/ui/primary-category-year-aggregation-chart/primary-category-year-aggregation-chart.component';
import { CommonModule } from '@angular/common';
@Component({
selector: 'app-person-publications',
imports: [
MatIconModule,
MatButtonModule,
MatExpansionModule,
MatTooltipModule,
NgxEchartsDirective,
AppInfoCardComponent,
PublicationTableComponent,
PublicationFilterComponent,
QueryParamPaginatorComponent,
PrimaryCategoryYearAggregationChartComponent,
CommonModule,
],
templateUrl: './person-publications.component.html',
styleUrl: './person-publications.component.scss',
@@ -69,218 +34,11 @@ export class PersonPublicationsComponent {
selectedInstitutionsPage = input.required<InstitutionPageV2>();
selectedTopicsPage = input.required<TopicPageV2>();
authorWorkClassificationMergePage =
input.required<WorkClassificationMergePage>();
authorWorkClassificationsMerges = computed(
() => this.authorWorkClassificationMergePage().elements ?? [],
);
primaryCategoryYearAggregationPage =
input.required<PrimaryCategoryYearAggregationPage>();
specificWorkPurposesByYear = computed(() => {
const authorWorkClassificationMerges =
this.authorWorkClassificationsMerges();
return this.getAuthorWorkClassificationByYear(
authorWorkClassificationMerges,
);
canViewClassificationChart = computed(() => {
const page = this.primaryCategoryYearAggregationPage();
return (page?.elements?.length ?? 0) > 0;
});
basicResearchAmount = computed(() => {
return this.countPurpose(
this.authorWorkClassificationsMerges(),
WorkPrimaryCategory.BasicResearch,
);
});
basicResearchLabel = transformWorkPrimaryCategory(
WorkPrimaryCategory.BasicResearch,
);
appliedResearchAmount = computed(() => {
return this.countPurpose(
this.authorWorkClassificationsMerges(),
WorkPrimaryCategory.AppliedResearch,
);
});
appliedResearchLabel = transformWorkPrimaryCategory(
WorkPrimaryCategory.AppliedResearch,
);
nonResearchAmount = computed(() => {
return this.countPurpose(
this.authorWorkClassificationsMerges(),
WorkPrimaryCategory.NonResearch,
);
});
nonResearchLabel = transformWorkPrimaryCategory(
WorkPrimaryCategory.NonResearch,
);
experimentalDevelopmentAmount = computed(() => {
return this.countPurpose(
this.authorWorkClassificationsMerges(),
WorkPrimaryCategory.ExperimentalDevelopment,
);
});
experimentalDevelopmentLabel = transformWorkPrimaryCategory(
WorkPrimaryCategory.ExperimentalDevelopment,
);
notClassifiedAmount = computed(() => {
return this.authorWorkClassificationsMerges().filter(
(workClassification) =>
!workClassification.classification?.classification?.primary_category,
).length;
});
notClassifiedLabel = transformWorkPrimaryCategory(
WorkPrimaryCategory.NotClassified,
);
countPurpose = (
workClassifications: WorkClassificationMerge[],
primaryCategory: WorkPrimaryCategory,
) => {
let count = 0;
for (const workClassification of workClassifications) {
if (
workClassification.classification?.classification?.primary_category ==
primaryCategory
) {
count++;
}
}
return count;
};
chartOption!: echarts.EChartsCoreOption;
constructor() {
effect(() => {
const yearlyCounts = this.buildYearlyCounts(
this.specificWorkPurposesByYear(),
);
this.chartOption = this.buildChartOption(yearlyCounts);
});
}
getAuthorWorkClassificationByYear(
authorWorkClassificationMerges: WorkClassificationMerge[],
): Record<number, Array<WorkClassificationMerge>> {
const workClassificationsByYear: Record<
number,
Array<WorkClassificationMerge>
> = {};
for (const classificationMerge of authorWorkClassificationMerges) {
const year = classificationMerge.work.publication_year;
if (!year) continue;
if (!workClassificationsByYear[year]) {
workClassificationsByYear[year] = [];
}
workClassificationsByYear[year].push(classificationMerge);
}
return workClassificationsByYear;
}
buildYearlyCounts(
workClassificationsByYear: Record<number, Array<WorkClassificationMerge>>,
): YearlyPurposeCounts[] {
return Object.entries(workClassificationsByYear)
.map(([year, classificiationMerges]) => {
const counts: YearlyPurposeCounts = {
year: Number(year),
basicResearch: 0,
appliedResearch: 0,
nonResearch: 0,
experimentalDevelopment: 0,
notClassified: 0,
};
for (const classificationMerge of classificiationMerges) {
const primaryCategory =
classificationMerge.classification?.classification
?.primary_category;
if (!primaryCategory) {
counts.notClassified++;
continue;
}
if (primaryCategory == WorkPrimaryCategory.BasicResearch) {
counts.basicResearch++;
} else if (primaryCategory == WorkPrimaryCategory.AppliedResearch) {
counts.appliedResearch++;
} else if (primaryCategory == WorkPrimaryCategory.NonResearch) {
counts.nonResearch++;
} else if (
primaryCategory == WorkPrimaryCategory.ExperimentalDevelopment
) {
counts.experimentalDevelopment++;
}
}
return counts;
})
.sort((a, b) => a.year - b.year);
}
buildChartOption(data: YearlyPurposeCounts[]): echarts.EChartsCoreOption {
return {
tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' } },
legend: {
data: [
this.basicResearchLabel,
this.appliedResearchLabel,
this.nonResearchLabel,
this.experimentalDevelopmentLabel,
this.notClassifiedLabel,
],
bottom: 0,
itemGap: 40,
},
grid: {
left: '3%',
right: '4%',
bottom: '10%',
top: '3%',
containLabel: true,
},
xAxis: {
type: 'category',
data: data.map((d) => d.year.toString()),
},
yAxis: { type: 'value' },
series: [
{
name: this.basicResearchLabel,
type: 'bar',
stack: 'total',
emphasis: { focus: 'series' },
data: data.map((d) => d.basicResearch),
},
{
name: this.appliedResearchLabel,
type: 'bar',
stack: 'total',
emphasis: { focus: 'series' },
data: data.map((d) => d.appliedResearch),
},
{
name: this.nonResearchLabel,
type: 'bar',
stack: 'total',
emphasis: { focus: 'series' },
data: data.map((d) => d.nonResearch),
},
{
name: this.experimentalDevelopmentLabel,
type: 'bar',
stack: 'total',
emphasis: { focus: 'series' },
data: data.map((d) => d.experimentalDevelopment),
},
{
name: this.notClassifiedLabel,
type: 'bar',
stack: 'total',
emphasis: { focus: 'series' },
data: data.map((d) => d.notClassified),
},
],
};
}
}
@@ -1,16 +0,0 @@
import { ResolveFn } from '@angular/router';
import { WorkClassificationMergePage, WorksV2Service } from '../api';
import { inject } from '@angular/core';
export const authorWorkClassificationPageResolver: ResolveFn<
WorkClassificationMergePage
> = (route, state) => {
const id = route.parent?.paramMap.get('id') || route.paramMap.get('id');
if (!id) {
throw new Error(
'Author ID is required to resolve author work classification page.',
);
}
return inject(WorksV2Service).getWorkClassificationsByAuthorId(id);
};
@@ -0,0 +1,26 @@
import { inject } from '@angular/core';
import { ResolveFn } from '@angular/router';
import { PrimaryCategoryYearAggregationPage, WorksV2Service } from '../api';
export const primaryCategoryYearAggregationPageResolver: ResolveFn<
PrimaryCategoryYearAggregationPage
> = (route, state) => {
const institutionId = route.parent?.paramMap.get('institutionId');
const authorId = route.parent?.paramMap.get('id');
console.log(route.parent?.paramMap);
if (!institutionId && !authorId) {
throw new Error('Institution ID or Author ID is required');
}
if (institutionId) {
return inject(WorksV2Service).getPrimaryCategoryAggregationsByInstitutionId(
institutionId,
);
} else if (authorId) {
return inject(WorksV2Service).getPrimaryCategoryAggregationsByAuthorId(
authorId,
);
} else {
throw new Error('Institution ID or Author ID is required');
}
};
@@ -103,6 +103,9 @@ export class CredentialService {
public readonly effectiveAccountId = computed(
() => this.accessToken()?.effective_account_id ?? '',
);
public readonly effectiveInstitutionId = computed(
() => this.accessToken()?.effective_institution_id ?? '',
);
public readonly isImpersonating = computed(
() => this.realAccountId() !== this.effectiveAccountId(),
);
@@ -0,0 +1,18 @@
<div>
<div
echarts
[options]="chartOption()"
style="height: 300px; width: 100%"></div>
<div class="info-cards">
@for (cardInput of this.cardInputs(); track $index) {
<app-info-card
[value]="cardInput.value"
[description]="cardInput.description"
[icon]="cardInput.icon" />
}
<app-info-card
[value]="this.totalCount() + ''"
description="Gesamtanzahl klassifizierter Publikationen"
icon="article" />
</div>
</div>
@@ -0,0 +1,7 @@
.info-cards {
width: 100%;
display: flex;
gap: 1rem;
flex-wrap: wrap;
margin-top: 1rem;
}
@@ -0,0 +1,184 @@
import { Component, computed, input } from '@angular/core';
import {
PrimaryCategoryYearAggregation,
PrimaryCategoryYearAggregationPage,
WorkPrimaryCategory,
} from '../../../api';
import { transformWorkPrimaryCategory } from '../../pipes/work-primary-category.pipe';
import { AppInfoCardComponent } from '../app-info-card/app-info-card.component';
import { EChartsCoreOption } from 'echarts';
import { NgxEchartsDirective } from 'ngx-echarts';
type CardInput = {
value: string;
description: string;
icon: string;
};
@Component({
selector: 'app-primary-category-year-aggregation-chart',
imports: [AppInfoCardComponent, NgxEchartsDirective],
templateUrl: './primary-category-year-aggregation-chart.component.html',
styleUrl: './primary-category-year-aggregation-chart.component.scss',
})
export class PrimaryCategoryYearAggregationChartComponent {
page = input.required<PrimaryCategoryYearAggregationPage>();
countPrimaryCategoryForAllYears(
page: PrimaryCategoryYearAggregationPage,
primaryCategory: WorkPrimaryCategory,
): number {
if (!page?.elements) {
return 0;
}
return page.elements.reduce((acc, element) => {
const count = element.categories?.[primaryCategory] || 0;
return acc + count;
}, 0);
}
basicResearchCount = computed(() => {
return this.countPrimaryCategoryForAllYears(
this.page(),
WorkPrimaryCategory.BasicResearch,
);
});
basicResearchLabel = transformWorkPrimaryCategory(
WorkPrimaryCategory.BasicResearch,
);
appliedResearchCount = computed(() => {
return this.countPrimaryCategoryForAllYears(
this.page(),
WorkPrimaryCategory.AppliedResearch,
);
});
appliedResearchLabel = transformWorkPrimaryCategory(
WorkPrimaryCategory.AppliedResearch,
);
nonResearchCount = computed(() => {
return this.countPrimaryCategoryForAllYears(
this.page(),
WorkPrimaryCategory.NonResearch,
);
});
nonResearchLabel = transformWorkPrimaryCategory(
WorkPrimaryCategory.NonResearch,
);
experimentalDevelopmentCount = computed(() => {
return this.countPrimaryCategoryForAllYears(
this.page(),
WorkPrimaryCategory.ExperimentalDevelopment,
);
});
experimentalDevelopmentLabel = transformWorkPrimaryCategory(
WorkPrimaryCategory.ExperimentalDevelopment,
);
totalCount = computed(() => {
return (
this.basicResearchCount() +
this.appliedResearchCount() +
this.nonResearchCount() +
this.experimentalDevelopmentCount()
);
});
cardInputs = computed<CardInput[]>(() => {
return [
{
value: this.basicResearchCount().toString(),
description: this.basicResearchLabel,
icon: 'science',
},
{
value: this.appliedResearchCount().toString(),
description: this.appliedResearchLabel,
icon: 'biotech',
},
{
value: this.nonResearchCount().toString(),
description: this.nonResearchLabel,
icon: 'work_outline',
},
{
value: this.experimentalDevelopmentCount().toString(),
description: this.experimentalDevelopmentLabel,
icon: 'build',
},
];
});
chartOption = computed(() => {
return this.buildChartOptions(this.page().elements ?? []);
});
buildChartOptions(data: PrimaryCategoryYearAggregation[]): EChartsCoreOption {
return {
tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' } },
legend: {
data: [
this.basicResearchLabel,
this.appliedResearchLabel,
this.nonResearchLabel,
this.experimentalDevelopmentLabel,
],
bottom: 0,
itemGap: 40,
},
grid: {
left: '3%',
right: '4%',
bottom: '10%',
top: '3%',
containLabel: true,
},
xAxis: {
type: 'category',
data: data.map((d) => d.publication_year.toString()),
},
yAxis: { type: 'value' },
series: [
{
name: this.basicResearchLabel,
type: 'bar',
stack: 'total',
emphasis: { focus: 'series' },
data: data.map(
(d) => d.categories?.[WorkPrimaryCategory.BasicResearch] || 0,
),
},
{
name: this.appliedResearchLabel,
type: 'bar',
stack: 'total',
emphasis: { focus: 'series' },
data: data.map(
(d) => d.categories?.[WorkPrimaryCategory.AppliedResearch] || 0,
),
},
{
name: this.nonResearchLabel,
type: 'bar',
stack: 'total',
emphasis: { focus: 'series' },
data: data.map(
(d) => d.categories?.[WorkPrimaryCategory.NonResearch] || 0,
),
},
{
name: this.experimentalDevelopmentLabel,
type: 'bar',
stack: 'total',
emphasis: { focus: 'series' },
data: data.map(
(d) =>
d.categories?.[WorkPrimaryCategory.ExperimentalDevelopment] || 0,
),
},
],
};
}
}