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
LocationBasedServices/smartguide/pipeline/head This commit looks good
This commit is contained in:
+32
-1
@@ -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>
|
||||
|
||||
+22
@@ -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);
|
||||
}
|
||||
|
||||
+19
-1
@@ -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),
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user