moved row with filters up above all visuals. Implemented treemap for fuzzy search. adapted resolver
LocationBasedServices/smartguide/pipeline/head This commit looks good
LocationBasedServices/smartguide/pipeline/head This commit looks good
This commit is contained in:
+120
-82
@@ -92,6 +92,87 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Combined Child Component Selectors Row (all filter logic at top before diagrams) -->
|
||||
<div class="comparison-selectors-row">
|
||||
<!-- Countries / Regions Selector -->
|
||||
@if (activeConfig().showLocationSelector) {
|
||||
<app-location-selector
|
||||
class="selector-item"
|
||||
[comparisonCountries]="comparisonCountries()"
|
||||
[comparisonRegions]="comparisonRegions()"
|
||||
[locationQuery]="locationQuery()"
|
||||
[locationSearchResults]="locationSearchResults()"
|
||||
[getEntityColor]="boundGetEntityColor"
|
||||
[isVisible]="boundIsVisible"
|
||||
[selectedPieEntityId]="selectedPieEntity()?.id ?? null"
|
||||
(addLocation)="addLocation($event)"
|
||||
(removeLocation)="removeLocation($event.id, $event.type)"
|
||||
(searchChange)="onLocationSearchChange($event)"
|
||||
(toggleVisibility)="toggleVisibility($event)"
|
||||
(selectPie)="onSelectPieEntity($event)">
|
||||
</app-location-selector>
|
||||
}
|
||||
|
||||
<!-- Top-Autoren einer Einrichtung hinzufügen -->
|
||||
@if (activeConfig().showAuthorSelector) {
|
||||
<app-author-institution-selector
|
||||
class="selector-item"
|
||||
[searchQuery]="authorInstSearchQuery()"
|
||||
[searchResults]="authorInstSearchResults()"
|
||||
(addInstitutionAuthors)="
|
||||
addInstitutionAuthors($event.id, $event.name)
|
||||
"
|
||||
(searchChange)="onAuthorInstSearchChange($event)">
|
||||
</app-author-institution-selector>
|
||||
}
|
||||
|
||||
<!-- Unified Institution Search, Compare, & Recommendations -->
|
||||
@if (activeConfig().showInstitutionSelector) {
|
||||
<app-institution-selector
|
||||
class="selector-item selector-item--main"
|
||||
[activeTab]="selectedSearchType()"
|
||||
[comparisonInstitutions]="comparisonInstitutions()"
|
||||
[primaryInstitution]="primaryInstitution()"
|
||||
[primaryInstitutionName]="primaryInstitutionName()"
|
||||
[topSuggestions]="topSuggestions()"
|
||||
[isSuggestionsLoading]="isSuggestionsLoading()"
|
||||
[activeChartTopic]="activeChartTopic()"
|
||||
[searchQuery]="searchQuery()"
|
||||
[searchResults]="searchResults()"
|
||||
[getEntityColor]="boundGetEntityColor"
|
||||
[isVisible]="boundIsVisible"
|
||||
[selectedPieEntityId]="selectedPieEntity()?.id ?? null"
|
||||
(addInstitution)="addInstitution($event.id, $event.name)"
|
||||
(removeInstitution)="removeInstitution($event)"
|
||||
(searchChange)="onSearchChange($event)"
|
||||
(toggleVisibility)="toggleVisibility($event)"
|
||||
(selectPie)="onSelectPieEntity($event)">
|
||||
</app-institution-selector>
|
||||
}
|
||||
|
||||
<!-- Reusable Author Selection UI -->
|
||||
@if (activeConfig().showAuthorSelector) {
|
||||
<app-author-selector
|
||||
class="selector-item selector-item--main"
|
||||
[activeTab]="selectedSearchType()"
|
||||
[comparisonAuthors]="comparisonAuthors()"
|
||||
[topSuggestions]="recommendedAuthors()"
|
||||
[isSuggestionsLoading]="isSuggestionsLoading()"
|
||||
[activeChartTopic]="activeChartTopic()"
|
||||
[searchQuery]="authorSearchQuery()"
|
||||
[searchResults]="authorSearchResults()"
|
||||
[getEntityColor]="boundGetEntityColor"
|
||||
[isVisible]="boundIsVisible"
|
||||
[selectedPieEntityId]="selectedPieEntity()?.id ?? null"
|
||||
(addAuthor)="addAuthor($event.id, $event.name)"
|
||||
(removeAuthor)="removeAuthor($event)"
|
||||
(searchChange)="onAuthorSearchChange($event)"
|
||||
(toggleVisibility)="toggleVisibility($event)"
|
||||
(selectPie)="onSelectPieEntity($event)">
|
||||
</app-author-selector>
|
||||
}
|
||||
</div>
|
||||
|
||||
<!-- Main Full-Width Content Area -->
|
||||
<main class="trend-main-fullwidth">
|
||||
@if (isPageResolving() || (isTrendLoading() && !rawTrendResponse())) {
|
||||
@@ -109,11 +190,11 @@
|
||||
@if (selectedSearchType() === 'news') {
|
||||
<app-topic-chip
|
||||
[label]="topic"
|
||||
[active]="true"
|
||||
[active]="isVisible('news_topic_' + topic)"
|
||||
[color]="getTopicColor(topic)"
|
||||
[disabled]="false"
|
||||
[matTooltip]="topic"
|
||||
style="pointer-events: none; cursor: default">
|
||||
(chipClick)="toggleVisibility('news_topic_' + topic)">
|
||||
</app-topic-chip>
|
||||
} @else if (selectedTrendTopics().length > 1) {
|
||||
<app-topic-chip
|
||||
@@ -183,86 +264,43 @@
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- Combined Child Component Selectors Row (fits into a single line on desktop) -->
|
||||
<div class="comparison-selectors-row">
|
||||
<!-- Countries / Regions Selector -->
|
||||
@if (activeConfig().showLocationSelector) {
|
||||
<app-location-selector
|
||||
class="selector-item"
|
||||
[comparisonCountries]="comparisonCountries()"
|
||||
[comparisonRegions]="comparisonRegions()"
|
||||
[locationQuery]="locationQuery()"
|
||||
[locationSearchResults]="locationSearchResults()"
|
||||
[getEntityColor]="boundGetEntityColor"
|
||||
[isVisible]="boundIsVisible"
|
||||
[selectedPieEntityId]="selectedPieEntity()?.id ?? null"
|
||||
(addLocation)="addLocation($event)"
|
||||
(removeLocation)="removeLocation($event.id, $event.type)"
|
||||
(searchChange)="onLocationSearchChange($event)"
|
||||
(toggleVisibility)="toggleVisibility($event)"
|
||||
(selectPie)="onSelectPieEntity($event)">
|
||||
</app-location-selector>
|
||||
}
|
||||
|
||||
<!-- Top-Autoren einer Einrichtung hinzufügen -->
|
||||
@if (activeConfig().showAuthorSelector) {
|
||||
<app-author-institution-selector
|
||||
class="selector-item"
|
||||
[searchQuery]="authorInstSearchQuery()"
|
||||
[searchResults]="authorInstSearchResults()"
|
||||
(addInstitutionAuthors)="
|
||||
addInstitutionAuthors($event.id, $event.name)
|
||||
"
|
||||
(searchChange)="onAuthorInstSearchChange($event)">
|
||||
</app-author-institution-selector>
|
||||
}
|
||||
|
||||
<!-- Unified Institution Search, Compare, & Recommendations -->
|
||||
@if (activeConfig().showInstitutionSelector) {
|
||||
<app-institution-selector
|
||||
class="selector-item selector-item--main"
|
||||
[activeTab]="selectedSearchType()"
|
||||
[comparisonInstitutions]="comparisonInstitutions()"
|
||||
[primaryInstitution]="primaryInstitution()"
|
||||
[primaryInstitutionName]="primaryInstitutionName()"
|
||||
[topSuggestions]="topSuggestions()"
|
||||
[isSuggestionsLoading]="isSuggestionsLoading()"
|
||||
[activeChartTopic]="activeChartTopic()"
|
||||
[searchQuery]="searchQuery()"
|
||||
[searchResults]="searchResults()"
|
||||
[getEntityColor]="boundGetEntityColor"
|
||||
[isVisible]="boundIsVisible"
|
||||
[selectedPieEntityId]="selectedPieEntity()?.id ?? null"
|
||||
(addInstitution)="addInstitution($event.id, $event.name)"
|
||||
(removeInstitution)="removeInstitution($event)"
|
||||
(searchChange)="onSearchChange($event)"
|
||||
(toggleVisibility)="toggleVisibility($event)"
|
||||
(selectPie)="onSelectPieEntity($event)">
|
||||
</app-institution-selector>
|
||||
}
|
||||
|
||||
<!-- Reusable Author Selection UI -->
|
||||
@if (activeConfig().showAuthorSelector) {
|
||||
<app-author-selector
|
||||
class="selector-item selector-item--main"
|
||||
[activeTab]="selectedSearchType()"
|
||||
[comparisonAuthors]="comparisonAuthors()"
|
||||
[topSuggestions]="recommendedAuthors()"
|
||||
[isSuggestionsLoading]="isSuggestionsLoading()"
|
||||
[activeChartTopic]="activeChartTopic()"
|
||||
[searchQuery]="authorSearchQuery()"
|
||||
[searchResults]="authorSearchResults()"
|
||||
[getEntityColor]="boundGetEntityColor"
|
||||
[isVisible]="boundIsVisible"
|
||||
[selectedPieEntityId]="selectedPieEntity()?.id ?? null"
|
||||
(addAuthor)="addAuthor($event.id, $event.name)"
|
||||
(removeAuthor)="removeAuthor($event)"
|
||||
(searchChange)="onAuthorSearchChange($event)"
|
||||
(toggleVisibility)="toggleVisibility($event)"
|
||||
(selectPie)="onSelectPieEntity($event)">
|
||||
</app-author-selector>
|
||||
}
|
||||
</div>
|
||||
<!-- Topic Treemap (Hierarchie-Tree) for Fuzzy Search -->
|
||||
@if (isFuzzy() && activeTreemapData()) {
|
||||
<section class="treemap-section" style="margin-top: 24px">
|
||||
<div class="chart-holder-card">
|
||||
<h3
|
||||
style="
|
||||
margin-bottom: 16px;
|
||||
font-weight: 700;
|
||||
font-size: 1.1rem;
|
||||
color: #101a3d;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
">
|
||||
<mat-icon style="color: #6366f1">account_tree</mat-icon>
|
||||
Themen-Hierarchie & Verteilung (Treemap)
|
||||
@if (selectedPieEntity()?.name || primaryInstitutionName()) {
|
||||
<span
|
||||
style="
|
||||
font-weight: 500;
|
||||
font-size: 0.95rem;
|
||||
color: #64708f;
|
||||
">
|
||||
·
|
||||
{{ selectedPieEntity()?.name || primaryInstitutionName() }}
|
||||
</span>
|
||||
}
|
||||
</h3>
|
||||
<app-topic-treemap
|
||||
[data]="activeTreemapData()!"
|
||||
[selectedNodeId]="selectedTopicTreemapNode()"
|
||||
(selectedNodeIdChange)="onTopicTreemapNodeChange($event)"
|
||||
(topicSelect)="onTopicTreemapTopicSelect($event)">
|
||||
</app-topic-treemap>
|
||||
</div>
|
||||
</section>
|
||||
}
|
||||
} @else {
|
||||
<div class="no-data-fallback">
|
||||
<mat-icon>trending_up</mat-icon>
|
||||
|
||||
+298
-36
@@ -56,6 +56,16 @@ import { AuthorSelectorComponent } from '../../../shared/ui/author-selector/auth
|
||||
import { AuthorInstitutionSelectorComponent } from '../../../shared/ui/author-institution-selector/author-institution-selector.component';
|
||||
import { SearchResultsStateService } from '../../keywords-search/search-results/search-results-state.service';
|
||||
import { LoadingComponent } from '../../../shared/ui/loading/loading.component';
|
||||
import { TopicTreemapComponent } from '../../../shared/ui/topic-treemap/topic-treemap.component';
|
||||
import {
|
||||
TopicTreemapData,
|
||||
TopicTreemapField,
|
||||
TopicTreemapSubfield,
|
||||
TopicTreemapTopic,
|
||||
TopicTreemapValue,
|
||||
TopicTreemapTopicSelect,
|
||||
} from '../../../shared/ui/topic-treemap/topic-treemap.models';
|
||||
import { TopicsService } from '../../../api/api/topics.service';
|
||||
|
||||
export interface CompareItem {
|
||||
id: string;
|
||||
@@ -136,6 +146,7 @@ export const TREND_CONFIGS: Record<string, TrendStrategyConfig> = {
|
||||
AuthorSelectorComponent,
|
||||
AuthorInstitutionSelectorComponent,
|
||||
LoadingComponent,
|
||||
TopicTreemapComponent,
|
||||
],
|
||||
templateUrl: './uni-trend-parent.component.html',
|
||||
styleUrl: './uni-trend-parent.component.scss',
|
||||
@@ -143,6 +154,7 @@ export const TREND_CONFIGS: Record<string, TrendStrategyConfig> = {
|
||||
})
|
||||
export class UniTrendParentComponent implements OnInit {
|
||||
private readonly apiService = inject(UniversityRankingsService);
|
||||
private readonly topicsService = inject(TopicsService);
|
||||
private readonly institutionsApiService = inject(InstitutionsService);
|
||||
private readonly personsApiService = inject(PersonsService);
|
||||
private readonly organizationService = inject(OrganizationService, {
|
||||
@@ -230,6 +242,12 @@ export class UniTrendParentComponent implements OnInit {
|
||||
readonly isTopTopicsLoading = signal<boolean>(false);
|
||||
readonly topTopicsError = signal<boolean>(false);
|
||||
|
||||
// Topic Treemap signals
|
||||
readonly isFuzzy = computed(() => this.state?.fuzzySearch() ?? true);
|
||||
readonly topicTreemap = signal<TopicTreemapData | null>(null);
|
||||
readonly isTreemapLoading = signal<boolean>(false);
|
||||
readonly selectedTopicTreemapNode = signal<string | undefined>(undefined);
|
||||
|
||||
getMappedTopic(topicOrKeyword: string): string {
|
||||
const kws = this.keywords();
|
||||
const topics = this.state?.topicsList() ?? kws;
|
||||
@@ -299,6 +317,197 @@ export class UniTrendParentComponent implements OnInit {
|
||||
});
|
||||
});
|
||||
|
||||
cleanEntityId(id: string | null | undefined): string {
|
||||
if (!id) return '';
|
||||
const lower = id.toLowerCase().trim();
|
||||
return lower.includes('/') ? lower.split('/').pop()! : lower;
|
||||
}
|
||||
|
||||
// Dynamic Treemap Data for Selected Entity (Institution or Author or Region/Country)
|
||||
readonly activeTreemapData = computed<TopicTreemapData | null>(() => {
|
||||
const data = this.trendResponse();
|
||||
const searchType = this.selectedSearchType();
|
||||
const isFuzzy = this.isFuzzy();
|
||||
if (!data || !data.series || !isFuzzy) return null;
|
||||
|
||||
const startYr = this.startYear();
|
||||
const endYr = this.endYear();
|
||||
|
||||
const activePie = this.selectedPieEntity();
|
||||
let targetEntityId: string | undefined = activePie?.id || undefined;
|
||||
let targetEntityName = activePie?.name || 'Ausgewählte Entität';
|
||||
|
||||
if (!targetEntityId) {
|
||||
if (searchType === 'authors') {
|
||||
const firstAuthor = this.comparisonAuthors()[0];
|
||||
targetEntityId = firstAuthor?.id || undefined;
|
||||
targetEntityName = firstAuthor?.name || 'Autor';
|
||||
} else {
|
||||
targetEntityId = this.primaryInstitution() || undefined;
|
||||
targetEntityName = this.primaryInstitutionName();
|
||||
}
|
||||
}
|
||||
|
||||
const cleanTargetId = targetEntityId
|
||||
? this.cleanEntityId(targetEntityId)
|
||||
: '';
|
||||
|
||||
let matchingSeries: TrendSeries[] = [];
|
||||
if (searchType === 'news') {
|
||||
matchingSeries = data.series;
|
||||
} else {
|
||||
matchingSeries = data.series.filter(
|
||||
(s) => this.cleanEntityId(s.entity_id) === cleanTargetId,
|
||||
);
|
||||
if (matchingSeries.length === 0 && data.series.length > 0) {
|
||||
matchingSeries = data.series;
|
||||
}
|
||||
}
|
||||
|
||||
if (matchingSeries.length === 0) return null;
|
||||
|
||||
const keywordEntries = this.state?.selectedKeywordEntries() ?? [];
|
||||
const fieldsMap = new Map<
|
||||
string,
|
||||
{
|
||||
id: string;
|
||||
name: string;
|
||||
subfieldsMap: Map<
|
||||
string,
|
||||
{
|
||||
id: string;
|
||||
name: string;
|
||||
topicsMap: Map<
|
||||
string,
|
||||
{
|
||||
id: string;
|
||||
name: string;
|
||||
total: number;
|
||||
values: TopicTreemapValue[];
|
||||
}
|
||||
>;
|
||||
}
|
||||
>;
|
||||
}
|
||||
>();
|
||||
|
||||
matchingSeries.forEach((s) => {
|
||||
Object.entries(s.topic_data || {}).forEach(
|
||||
([topicName, yearlyDataList]) => {
|
||||
const totalCount = yearlyDataList
|
||||
.filter((y) => y.year >= startYr && y.year <= endYr)
|
||||
.reduce((sum, item) => sum + (item.raw || 0), 0);
|
||||
|
||||
if (totalCount <= 0) return;
|
||||
|
||||
const mappedName = this.getMappedTopic(topicName);
|
||||
const targetLower = topicName.toLowerCase().trim();
|
||||
const mappedLower = mappedName.toLowerCase().trim();
|
||||
|
||||
const match = keywordEntries.find(
|
||||
(e) =>
|
||||
e.topic_mapping?.topic?.display_name?.toLowerCase().trim() ===
|
||||
mappedLower ||
|
||||
e.topic_mapping?.topic?.display_name?.toLowerCase().trim() ===
|
||||
targetLower ||
|
||||
e.llm_keyword?.keyword?.toLowerCase().trim() === targetLower,
|
||||
);
|
||||
|
||||
const fieldName =
|
||||
match?.topic_mapping?.topic?.field?.display_name ||
|
||||
'Information & Communication Technology';
|
||||
const fieldId = match?.topic_mapping?.topic?.field?.id
|
||||
? String(match.topic_mapping.topic.field.id)
|
||||
: 'field_ict';
|
||||
|
||||
const subfieldName =
|
||||
match?.topic_mapping?.topic?.subfield?.display_name || fieldName;
|
||||
const subfieldId = match?.topic_mapping?.topic?.subfield?.id
|
||||
? String(match.topic_mapping.topic.subfield.id)
|
||||
: `subfield_${fieldId}`;
|
||||
|
||||
const topicId = match?.topic_mapping?.topic?.id
|
||||
? String(match.topic_mapping.topic.id)
|
||||
: topicName;
|
||||
|
||||
if (!fieldsMap.has(fieldId)) {
|
||||
fieldsMap.set(fieldId, {
|
||||
id: fieldId,
|
||||
name: fieldName,
|
||||
subfieldsMap: new Map(),
|
||||
});
|
||||
}
|
||||
const fieldEntry = fieldsMap.get(fieldId)!;
|
||||
|
||||
if (!fieldEntry.subfieldsMap.has(subfieldId)) {
|
||||
fieldEntry.subfieldsMap.set(subfieldId, {
|
||||
id: subfieldId,
|
||||
name: subfieldName,
|
||||
topicsMap: new Map(),
|
||||
});
|
||||
}
|
||||
const subfieldEntry = fieldEntry.subfieldsMap.get(subfieldId)!;
|
||||
|
||||
if (!subfieldEntry.topicsMap.has(topicId)) {
|
||||
const yearlyValues: TopicTreemapValue[] = yearlyDataList
|
||||
.filter((y) => y.year >= startYr && y.year <= endYr)
|
||||
.map((y) => ({
|
||||
year: y.year,
|
||||
count: y.raw || 0,
|
||||
share: y.normalized || 0,
|
||||
}));
|
||||
|
||||
subfieldEntry.topicsMap.set(topicId, {
|
||||
id: topicId,
|
||||
name: topicName,
|
||||
total: totalCount,
|
||||
values: yearlyValues,
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
const years = Array.from(
|
||||
{ length: endYr - startYr + 1 },
|
||||
(_, i) => startYr + i,
|
||||
);
|
||||
const fields: TopicTreemapField[] = Array.from(fieldsMap.values()).map(
|
||||
(f) => {
|
||||
const subfields: TopicTreemapSubfield[] = Array.from(
|
||||
f.subfieldsMap.values(),
|
||||
).map((sf) => {
|
||||
const topics: TopicTreemapTopic[] = Array.from(sf.topicsMap.values());
|
||||
const sfTotal = topics.reduce((sum, t) => sum + t.total, 0);
|
||||
return {
|
||||
id: sf.id,
|
||||
name: sf.name,
|
||||
total: sfTotal,
|
||||
values: [],
|
||||
topics,
|
||||
};
|
||||
});
|
||||
const fTotal = subfields.reduce((sum, sf) => sum + sf.total, 0);
|
||||
return {
|
||||
id: f.id,
|
||||
name: f.name,
|
||||
total: fTotal,
|
||||
values: [],
|
||||
subfields,
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
if (fields.length === 0) return null;
|
||||
|
||||
return {
|
||||
institution_id: cleanTargetId,
|
||||
organization_name: targetEntityName,
|
||||
years,
|
||||
fields,
|
||||
};
|
||||
});
|
||||
|
||||
// Autocomplete UI state
|
||||
readonly searchQuery = signal<string>('');
|
||||
readonly searchResults = signal<AutocompleteResponseResultsInner[]>([]);
|
||||
@@ -316,6 +525,26 @@ export class UniTrendParentComponent implements OnInit {
|
||||
|
||||
readonly entityVisibilityMap = signal<Map<string, boolean>>(new Map());
|
||||
|
||||
isTopicEmpty(topic: string): boolean {
|
||||
const res = this.rawTrendResponse();
|
||||
if (!res || !res.series || res.series.length === 0) return false;
|
||||
const startYr = this.startYear();
|
||||
const endYr = this.endYear();
|
||||
const mapped = this.getMappedTopic(topic).toLowerCase().trim();
|
||||
|
||||
return !res.series.some((s) => {
|
||||
const yearlyList =
|
||||
s.topic_data?.[topic] ||
|
||||
s.topic_data?.[mapped] ||
|
||||
Object.values(s.topic_data || {})[0];
|
||||
if (!yearlyList) return false;
|
||||
const total = yearlyList
|
||||
.filter((y) => y.year >= startYr && y.year <= endYr)
|
||||
.reduce((sum, item) => sum + (item.raw || 0), 0);
|
||||
return total > 0;
|
||||
});
|
||||
}
|
||||
|
||||
isVisible(id: string): boolean {
|
||||
return this.entityVisibilityMap().get(id) !== false;
|
||||
}
|
||||
@@ -621,20 +850,50 @@ export class UniTrendParentComponent implements OnInit {
|
||||
if (resolved.topics && resolved.topics.length > 0) {
|
||||
this.selectedTrendTopics.set(resolved.topics);
|
||||
this.fetchedTopics.set([...resolved.topics]);
|
||||
if (
|
||||
!this.activeChartTopic() ||
|
||||
!resolved.topics.includes(this.activeChartTopic())
|
||||
) {
|
||||
this.activeChartTopic.set(resolved.topics[0]);
|
||||
}
|
||||
const firstNonEmpty = resolved.topics.find(
|
||||
(t: string) => !this.isTopicEmpty(t),
|
||||
);
|
||||
const targetTopic = firstNonEmpty || resolved.topics[0];
|
||||
this.activeChartTopic.set(targetTopic);
|
||||
} else {
|
||||
this.fetchedTopics.set([...this.selectedTrendTopics()]);
|
||||
}
|
||||
|
||||
this.fetchedInstitutions.set([...this.comparisonInstitutions()]);
|
||||
this.fetchedCountries.set([...this.comparisonCountries()]);
|
||||
this.fetchedRegions.set([...this.comparisonRegions()]);
|
||||
this.fetchedAuthors.set([...this.comparisonAuthors()]);
|
||||
if (resolved.institutions && resolved.institutions.length > 0) {
|
||||
this.comparisonInstitutions.set(resolved.institutions);
|
||||
this.fetchedInstitutions.set([...resolved.institutions]);
|
||||
} else {
|
||||
this.fetchedInstitutions.set([...this.comparisonInstitutions()]);
|
||||
}
|
||||
|
||||
if (resolved.countries && resolved.countries.length > 0) {
|
||||
this.comparisonCountries.set(resolved.countries);
|
||||
this.fetchedCountries.set([...resolved.countries]);
|
||||
} else {
|
||||
this.fetchedCountries.set([...this.comparisonCountries()]);
|
||||
}
|
||||
|
||||
if (resolved.regions && resolved.regions.length > 0) {
|
||||
this.comparisonRegions.set(resolved.regions);
|
||||
this.fetchedRegions.set([...resolved.regions]);
|
||||
} else {
|
||||
this.fetchedRegions.set([...this.comparisonRegions()]);
|
||||
}
|
||||
|
||||
if (resolved.authors && resolved.authors.length > 0) {
|
||||
this.comparisonAuthors.set(resolved.authors);
|
||||
this.fetchedAuthors.set([...resolved.authors]);
|
||||
} else {
|
||||
this.fetchedAuthors.set([...this.comparisonAuthors()]);
|
||||
}
|
||||
|
||||
if (resolved.treemapData) {
|
||||
this.topicTreemap.set(resolved.treemapData);
|
||||
}
|
||||
|
||||
if (resolved.treemapNode !== undefined) {
|
||||
this.selectedTopicTreemapNode.set(resolved.treemapNode || undefined);
|
||||
}
|
||||
|
||||
this.isTrendLoading.set(false);
|
||||
}
|
||||
@@ -1335,6 +1594,7 @@ export class UniTrendParentComponent implements OnInit {
|
||||
end_year: this.endYear(),
|
||||
chart_mode: this.chartMode(),
|
||||
active_chart_topic: this.activeChartTopic(),
|
||||
treemapNode: this.selectedTopicTreemapNode() ?? null,
|
||||
};
|
||||
|
||||
this.router.navigate([], {
|
||||
@@ -1344,6 +1604,34 @@ export class UniTrendParentComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
fetchTreemapData() {
|
||||
const fuzzy = this.state?.fuzzySearch() ?? true;
|
||||
const topics = this.selectedTrendTopics();
|
||||
if (!fuzzy || topics.length === 0) {
|
||||
this.topicTreemap.set(null);
|
||||
return;
|
||||
}
|
||||
this.isTreemapLoading.set(true);
|
||||
this.topicsService.countTopicHierarchy(topics).subscribe({
|
||||
next: (res: any) => {
|
||||
this.topicTreemap.set(res);
|
||||
this.isTreemapLoading.set(false);
|
||||
},
|
||||
error: () => {
|
||||
this.isTreemapLoading.set(false);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
onTopicTreemapNodeChange(nodeId: string | undefined): void {
|
||||
this.selectedTopicTreemapNode.set(nodeId);
|
||||
this.updateUrlParams();
|
||||
}
|
||||
|
||||
onTopicTreemapTopicSelect(topic: TopicTreemapTopicSelect): void {
|
||||
// Topic selected inside treemap component
|
||||
}
|
||||
|
||||
// Checkbox topic toggling
|
||||
onTrendTopicToggle(topic: string, event: Event) {
|
||||
const isChecked = (event.target as HTMLInputElement).checked;
|
||||
@@ -1541,32 +1829,6 @@ export class UniTrendParentComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
isTopicEmpty(topic: string): boolean {
|
||||
const data = this.trendResponse();
|
||||
if (!data || !data.series || data.series.length === 0) {
|
||||
return false;
|
||||
}
|
||||
const mapped = this.getMappedTopic(topic);
|
||||
const startYr = this.startYear();
|
||||
const endYr = this.endYear();
|
||||
|
||||
let totalRaw = 0;
|
||||
data.series.forEach((s) => {
|
||||
if (s.visible !== false && s.topic_data) {
|
||||
const items = s.topic_data[topic] || s.topic_data[mapped];
|
||||
if (items) {
|
||||
items.forEach((y) => {
|
||||
if (y.year >= startYr && y.year <= endYr) {
|
||||
totalRaw += y.raw || 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return totalRaw === 0;
|
||||
}
|
||||
|
||||
// Topic tab toggle (data reuses instantly)
|
||||
updateActiveChartTopic(topic: string) {
|
||||
if (this.isTopicEmpty(topic)) {
|
||||
|
||||
@@ -4,12 +4,22 @@ import { catchError, of, Observable, map } from 'rxjs';
|
||||
import { TrendResponse, UniversityRankingsService } from '../api';
|
||||
import { SearchResultsStateService } from '../modules/keywords-search/search-results/search-results-state.service';
|
||||
|
||||
export interface CompareItem {
|
||||
id: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface UniTrendResolvedData {
|
||||
trendResponse: TrendResponse | null;
|
||||
searchType: string;
|
||||
topics: string[];
|
||||
keywords: string[];
|
||||
fuzzy: boolean;
|
||||
institutions: CompareItem[];
|
||||
countries: CompareItem[];
|
||||
regions: CompareItem[];
|
||||
authors: CompareItem[];
|
||||
treemapNode?: string | null;
|
||||
}
|
||||
|
||||
export const uniTrendResolver: ResolveFn<UniTrendResolvedData> = (
|
||||
@@ -21,6 +31,7 @@ export const uniTrendResolver: ResolveFn<UniTrendResolvedData> = (
|
||||
|
||||
const searchType = params.get('search_type') || 'publications';
|
||||
const fuzzy = params.get('fuzzy') !== 'false';
|
||||
const treemapNode = params.get('treemapNode');
|
||||
|
||||
// Extract keywords & topics
|
||||
let keywords = params.getAll('keyword');
|
||||
@@ -61,32 +72,42 @@ export const uniTrendResolver: ResolveFn<UniTrendResolvedData> = (
|
||||
keywords = topics;
|
||||
}
|
||||
|
||||
// Parse institutions
|
||||
// Parse comparison items
|
||||
const instParams = params.getAll('institutions');
|
||||
let institutions = instParams.map((i) => {
|
||||
const parsedInstitutions: CompareItem[] = instParams.map((i) => {
|
||||
const parts = i.split('|');
|
||||
const cleanId = parts[0].includes('/')
|
||||
? parts[0].split('/').pop() || parts[0]
|
||||
: parts[0];
|
||||
return cleanId;
|
||||
return { id: cleanId, name: parts[1] || cleanId };
|
||||
});
|
||||
if (institutions.length === 0) {
|
||||
institutions = ['I62318514'];
|
||||
}
|
||||
|
||||
// Parse countries
|
||||
const countryParams = params.getAll('countries');
|
||||
let countries = countryParams.map((c) => c.split('|')[0]);
|
||||
if (countries.length === 0) {
|
||||
countries = ['DE'];
|
||||
}
|
||||
const parsedCountries: CompareItem[] = countryParams.map((c) => {
|
||||
const parts = c.split('|');
|
||||
return { id: parts[0], name: parts[1] || parts[0] };
|
||||
});
|
||||
|
||||
// Parse regions & authors
|
||||
const regionParams = params.getAll('regions');
|
||||
const regions = regionParams.map((r) => r.split('|')[0]);
|
||||
const parsedRegions: CompareItem[] = regionParams.map((r) => {
|
||||
const parts = r.split('|');
|
||||
return { id: parts[0], name: parts[1] || parts[0] };
|
||||
});
|
||||
|
||||
const authorParams = params.getAll('authors');
|
||||
const authors = authorParams.map((a) => a.split('|')[0]);
|
||||
const parsedAuthors: CompareItem[] = authorParams.map((a) => {
|
||||
const parts = a.split('|');
|
||||
return { id: parts[0], name: parts[1] || parts[0] };
|
||||
});
|
||||
|
||||
const instIds =
|
||||
parsedInstitutions.length > 0
|
||||
? parsedInstitutions.map((i) => i.id)
|
||||
: ['I62318514'];
|
||||
const countryIds =
|
||||
parsedCountries.length > 0 ? parsedCountries.map((c) => c.id) : ['DE'];
|
||||
const regionIds = parsedRegions.map((r) => r.id);
|
||||
const authorIds = parsedAuthors.map((a) => a.id);
|
||||
|
||||
const apiService = inject(UniversityRankingsService);
|
||||
|
||||
@@ -95,29 +116,25 @@ export const uniTrendResolver: ResolveFn<UniTrendResolvedData> = (
|
||||
topics,
|
||||
keywords,
|
||||
fuzzy,
|
||||
institutions,
|
||||
countries,
|
||||
regions,
|
||||
authors,
|
||||
instIds,
|
||||
countryIds,
|
||||
regionIds,
|
||||
authorIds,
|
||||
searchType as any,
|
||||
)
|
||||
.pipe(
|
||||
catchError(() => of(null)),
|
||||
map((trendResponse) => ({
|
||||
trendResponse,
|
||||
searchType,
|
||||
topics,
|
||||
keywords,
|
||||
fuzzy,
|
||||
institutions: parsedInstitutions,
|
||||
countries: parsedCountries,
|
||||
regions: parsedRegions,
|
||||
authors: parsedAuthors,
|
||||
treemapNode,
|
||||
})),
|
||||
catchError((err) => {
|
||||
console.error('uniTrendResolver failed to load trend data:', err);
|
||||
return of({
|
||||
trendResponse: null,
|
||||
searchType,
|
||||
topics,
|
||||
keywords,
|
||||
fuzzy,
|
||||
});
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user