Integrate primary topics into research timeline
This commit is contained in:
+19
-9
@@ -57,14 +57,22 @@
|
||||
</span>
|
||||
|
||||
<div class="topic-list">
|
||||
<span
|
||||
*ngFor="let topic of getTopTopics(item); trackBy: trackByTopic"
|
||||
class="topic-chip"
|
||||
[ngClass]="getColorClass(index)"
|
||||
>
|
||||
<span class="topic-name">{{ topic.name }}</span>
|
||||
<span class="topic-count">{{ topic.count }}</span>
|
||||
</span>
|
||||
<ng-container *ngIf="getDisplayedTopics(item).length > 0; else noTopicsForYear">
|
||||
<span
|
||||
*ngFor="let topic of getDisplayedTopics(item); trackBy: trackByTopic"
|
||||
class="topic-chip"
|
||||
[ngClass]="getColorClass(index)"
|
||||
>
|
||||
<span class="topic-name">{{ topic.name }}</span>
|
||||
<span class="topic-count">{{ topic.count }}</span>
|
||||
</span>
|
||||
</ng-container>
|
||||
|
||||
<ng-template #noTopicsForYear>
|
||||
<span class="no-topics">
|
||||
Keine weiteren Topics
|
||||
</span>
|
||||
</ng-template>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
@@ -73,7 +81,9 @@
|
||||
|
||||
<div class="timeline-note">
|
||||
<span class="note-dot"></span>
|
||||
<span>Die drei häufigsten Topics je Jahr, gezählt über Publikationen.</span>
|
||||
<span>
|
||||
Hauptforschungsschwerpunkte im jeweiligen Zeitraum
|
||||
</span>
|
||||
</div>
|
||||
</ng-container>
|
||||
</ng-container>
|
||||
|
||||
+5
@@ -210,6 +210,11 @@
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.no-topics {
|
||||
color: #9aa5bc;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.purple {
|
||||
.dot {
|
||||
background: #7255d9;
|
||||
|
||||
+29
-3
@@ -10,6 +10,7 @@ export interface TopicTimelineElement {
|
||||
year: number;
|
||||
publication_count: number;
|
||||
topics: TopicTimelineTopic[];
|
||||
primary_topics?: TopicTimelineTopic[];
|
||||
}
|
||||
|
||||
@Component({
|
||||
@@ -26,6 +27,7 @@ export class ResearchTimelineComponent {
|
||||
|
||||
private readonly colors = ['purple', 'blue', 'green', 'orange', 'pink'];
|
||||
private readonly columnWidth = 240;
|
||||
private readonly displayedTopicLimit = 3;
|
||||
|
||||
get timelineItems(): TopicTimelineElement[] {
|
||||
return this.elements ?? [];
|
||||
@@ -41,12 +43,20 @@ export class ResearchTimelineComponent {
|
||||
return Math.max(count * this.columnWidth, 1000);
|
||||
}
|
||||
|
||||
getTopTopics(item: TopicTimelineElement): TopicTimelineTopic[] {
|
||||
return (item.topics ?? []).slice(0, 3);
|
||||
getPrimaryTopic(item: TopicTimelineElement): TopicTimelineTopic | undefined {
|
||||
return (item.primary_topics ?? [])[0];
|
||||
}
|
||||
|
||||
getMainTopic(item: TopicTimelineElement): string {
|
||||
return this.getTopTopics(item)[0]?.name ?? 'Keine Topics';
|
||||
return this.getPrimaryTopic(item)?.name ?? this.getFirstTopic(item)?.name ?? 'Keine Topics';
|
||||
}
|
||||
|
||||
getDisplayedTopics(item: TopicTimelineElement): TopicTimelineTopic[] {
|
||||
const primaryTopicName = this.getPrimaryTopic(item)?.name;
|
||||
|
||||
return (item.topics ?? [])
|
||||
.filter((topic) => !this.isSameTopic(topic.name, primaryTopicName))
|
||||
.slice(0, this.displayedTopicLimit);
|
||||
}
|
||||
|
||||
getColorClass(index: number): string {
|
||||
@@ -60,4 +70,20 @@ export class ResearchTimelineComponent {
|
||||
trackByTopic(_: number, topic: TopicTimelineTopic): string {
|
||||
return topic.name;
|
||||
}
|
||||
|
||||
private getFirstTopic(item: TopicTimelineElement): TopicTimelineTopic | undefined {
|
||||
return (item.topics ?? [])[0];
|
||||
}
|
||||
|
||||
private isSameTopic(topicName: string, primaryTopicName: string | undefined): boolean {
|
||||
if (!primaryTopicName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.normalizeTopicName(topicName) === this.normalizeTopicName(primaryTopicName);
|
||||
}
|
||||
|
||||
private normalizeTopicName(topicName: string): string {
|
||||
return topicName.trim().toLowerCase();
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,8 @@ export class PersonOverviewComponent implements OnInit {
|
||||
this.loadingTimeline = true;
|
||||
this.timelineLoadFailed = false;
|
||||
|
||||
const url = `/inse-service/authors/${encodeURIComponent(authorId)}/topics-by-time`;
|
||||
const topicCountLimit = 4;
|
||||
const url = `/inse-service/authors/${encodeURIComponent(authorId)}/topics-by-time?max_topics_per_year=${topicCountLimit}`;
|
||||
|
||||
this.http
|
||||
.get<TopicTimelineResponse>(url)
|
||||
|
||||
Reference in New Issue
Block a user