diff --git a/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.html b/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.html index 7fd2abbb..629a11c9 100644 --- a/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.html +++ b/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.html @@ -1,100 +1,172 @@ -
- - +
+ + + + +
+
+ Visualisierungsskala: +
+ + + +
-
-
- @if (isTrendLoading()) { -
-
-

Trenddaten werden aus dem Publikationsverzeichnis abgerufen...

-
- } - @if (selectedTrendTopics().length > 1) { -
- @for (topic of selectedTrendTopics(); track topic) { - - - } -
- } - -
+
+ @if (isTrendLoading()) { +
+
+

Trenddaten werden abgerufen...

+
+ } + @if ( + selectedTrendTopics().length > 1 && selectedSearchType() !== 'news' + ) { +
+ @for (topic of selectedTrendTopics(); track topic) { + + + } +
+ } + +
- - - - + + @if (activeConfig().showInstitutionSelector) { + + + } + + + @if (activeConfig().showAuthorSelector) { + + + } + +
diff --git a/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.scss b/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.scss index 0e630880..6146c6cc 100644 --- a/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.scss +++ b/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.scss @@ -179,3 +179,47 @@ transform: rotate(360deg); } } + +.strategy-toggles-bar { + display: flex; + flex-wrap: wrap; + gap: 8px; + background: #f8fafc; + border-radius: 12px; + padding: 6px; + border: 1px solid #e2e8f0; + margin-bottom: 0.5rem; + + button { + padding: 0.5rem 1rem; + border: none; + background: none; + font-size: 0.75rem; + font-weight: 600; + color: #64748b; + border-radius: 8px; + cursor: pointer; + display: inline-flex; + align-items: center; + gap: 6px; + transition: all 0.2s ease; + + mat-icon { + font-size: 16px; + width: 16px; + height: 16px; + } + + &:hover:not(.active) { + color: #0f172a; + background: #f1f5f9; + } + &.active { + background: white; + color: #3b82f6; + box-shadow: + 0 4px 6px -1px rgba(0, 0, 0, 0.05), + 0 2px 4px -1px rgba(0, 0, 0, 0.03); + } + } +} diff --git a/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.ts b/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.ts index 879b30ce..e145ecd6 100644 --- a/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.ts +++ b/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.ts @@ -32,20 +32,78 @@ import { AutocompleteResponseResultsInner, UniversityRankingsService, InstitutionsService, + PersonsService, } from '../../../api'; import { TopicChipComponent } from '../../../shared/ui/topic-chip/topic-chip.component'; import { topicHierarchyColor } from '../../../resolvers/utils/topic-colors'; import { YearRangeSliderComponent } from '../../../shared/ui/year-range-slider/year-range-slider.component'; import { LocationSelectorComponent } from '../../../shared/ui/location-selector/location-selector.component'; import { InstitutionSelectorComponent } from '../../../shared/ui/institution-selector/institution-selector.component'; +import { AuthorSelectorComponent } from '../../../shared/ui/author-selector/author-selector.component'; +import { AuthorInstitutionSelectorComponent } from '../../../shared/ui/author-institution-selector/author-institution-selector.component'; +import { SearchResultsStateService } from '../../keywords-search/search-results/search-results-state.service'; export interface CompareItem { id: string; name: string; } +export interface TrendStrategyConfig { + showInstitutionSelector: boolean; + showLocationSelector: boolean; + showAuthorSelector: boolean; + yAxisLabel: string; + chartTitle: string; +} + +export const TREND_CONFIGS: Record = { + publications: { + showInstitutionSelector: true, + showLocationSelector: true, + showAuthorSelector: false, + yAxisLabel: 'Publikationen', + chartTitle: 'Publikationstrends', + }, + authors: { + showInstitutionSelector: false, + showLocationSelector: false, + showAuthorSelector: true, + yAxisLabel: 'Publikationen von Autoren', + chartTitle: 'Autorentrends', + }, + patents: { + showInstitutionSelector: true, + showLocationSelector: false, + showAuthorSelector: false, + yAxisLabel: 'Patentanmeldungen', + chartTitle: 'Patentrecherche-Trends', + }, + projects: { + showInstitutionSelector: true, + showLocationSelector: false, + showAuthorSelector: false, + yAxisLabel: 'Projektförderung (Anz)', + chartTitle: 'Drittmittelförderung-Trends', + }, + news: { + showInstitutionSelector: false, + showLocationSelector: false, + showAuthorSelector: false, + yAxisLabel: 'Pressemitteilungen', + chartTitle: 'Nachrichtentrends', + }, + all: { + showInstitutionSelector: false, + showLocationSelector: false, + showAuthorSelector: false, + yAxisLabel: 'Aktivitäts-Index', + chartTitle: 'Cross-Domain-Themenlebenszyklus (UDE)', + }, +}; + @Component({ selector: 'app-uni-trend-parent', + standalone: true, imports: [ CommonModule, FormsModule, @@ -58,6 +116,8 @@ export interface CompareItem { YearRangeSliderComponent, LocationSelectorComponent, InstitutionSelectorComponent, + AuthorSelectorComponent, + AuthorInstitutionSelectorComponent, ], templateUrl: './uni-trend-parent.component.html', styleUrl: './uni-trend-parent.component.scss', @@ -66,13 +126,22 @@ export interface CompareItem { export class UniTrendParentComponent implements OnInit { private readonly apiService = inject(UniversityRankingsService); private readonly institutionsApiService = inject(InstitutionsService); + private readonly personsApiService = inject(PersonsService); private readonly route = inject(ActivatedRoute); private readonly router = inject(Router); + // Inject SearchResultsStateService optionally if loaded in keywords search + private readonly state = inject(SearchResultsStateService, { + optional: true, + }); + // Input containing extracted/selected keywords from parent readonly keywords = input([]); // Trend settings signals + readonly selectedSearchType = signal< + 'publications' | 'authors' | 'patents' | 'projects' | 'news' | 'all' + >('publications'); readonly selectedTrendTopics = signal([]); readonly primaryInstitution = signal(null); readonly primaryInstitutionName = signal( @@ -83,6 +152,7 @@ export class UniTrendParentComponent implements OnInit { { id: 'DE', name: 'Deutschland' }, ]); readonly comparisonRegions = signal([]); + readonly comparisonAuthors = signal([]); readonly startYear = signal(2010); readonly endYear = signal(2025); readonly chartMode = signal<'normalized' | 'total' | 'cumulative'>( @@ -90,16 +160,24 @@ export class UniTrendParentComponent implements OnInit { ); readonly activeChartTopic = signal(''); + // Config mapper for active strategy UI representation + readonly activeConfig = computed( + () => TREND_CONFIGS[this.selectedSearchType()], + ); + // Cached parameters of the last active search request to track "isDirty" + readonly fetchedSearchType = signal(null); readonly fetchedTopics = signal([]); readonly fetchedInstitutions = signal([]); readonly fetchedCountries = signal([]); readonly fetchedRegions = signal([]); + readonly fetchedAuthors = signal([]); // Results & Loading signals readonly rawTrendResponse = signal(null); readonly isTrendLoading = signal(false); readonly topSuggestions = signal([]); + readonly recommendedAuthors = signal([]); readonly isSuggestionsLoading = signal(false); getTopicColor(topic: string): string { @@ -111,6 +189,12 @@ export class UniTrendParentComponent implements OnInit { readonly searchResults = signal([]); readonly locationQuery = signal(''); readonly locationSearchResults = signal([]); + readonly authorSearchQuery = signal(''); + readonly authorSearchResults = signal([]); + readonly authorInstSearchQuery = signal(''); + readonly authorInstSearchResults = signal( + [], + ); // Years array for selects readonly availableYears: number[] = []; @@ -136,8 +220,15 @@ export class UniTrendParentComponent implements OnInit { const insts = this.comparisonInstitutions().map((i) => i.id); const countries = this.comparisonCountries().map((c) => c.id); const regions = this.comparisonRegions().map((r) => r.id); + const authors = this.comparisonAuthors().map((a) => a.id); - const orderedIds = [primaryId, ...insts, ...countries, ...regions]; + const orderedIds = [ + primaryId, + ...insts, + ...countries, + ...regions, + ...authors, + ]; const idx = orderedIds.indexOf(entityId); if (idx === -1) return '#9ca3af'; @@ -172,6 +263,34 @@ export class UniTrendParentComponent implements OnInit { const raw = this.rawTrendResponse(); if (!raw) return null; + const type = this.selectedSearchType(); + if (type === 'news' || type === 'all') { + return { + ...raw, + series: raw.series.map((s) => ({ + ...s, + visible: this.isVisible(s.entity_id), + })), + }; + } + + if (type === 'authors') { + const currentAuthorIds = new Set( + this.comparisonAuthors().map((a) => a.id.toLowerCase()), + ); + const filtered = raw.series + .filter((s) => currentAuthorIds.has(s.entity_id.toLowerCase())) + .map((s) => ({ + ...s, + visible: this.isVisible(s.entity_id), + })); + return { + ...raw, + series: filtered, + }; + } + + // Default: publications, patents, projects const currentInstIds = new Set( this.comparisonInstitutions().map((i: CompareItem) => i.id.toLowerCase()), ); @@ -235,6 +354,7 @@ export class UniTrendParentComponent implements OnInit { const kws = this.keywords(); const currentSelections = untracked(() => this.selectedTrendTopics()); const currentActive = untracked(() => this.activeChartTopic()); + const searchType = this.selectedSearchType(); if (kws.length > 0) { // Find existing selections that are still in keywords, or default to all @@ -254,10 +374,17 @@ export class UniTrendParentComponent implements OnInit { this.activeChartTopic.set(updatedSelections[0] || ''); } - // If comparison list is empty, initialize default institutions dynamically - const currentInsts = untracked(() => this.comparisonInstitutions()); - if (currentInsts.length === 0) { - untracked(() => this.initializeDefaultInstitutions()); + // If comparison list is empty, initialize default institutions/authors dynamically + if (searchType === 'authors') { + const currentAuthors = untracked(() => this.comparisonAuthors()); + if (currentAuthors.length === 0) { + untracked(() => this.initializeDefaultAuthors()); + } + } else { + const currentInsts = untracked(() => this.comparisonInstitutions()); + if (currentInsts.length === 0) { + untracked(() => this.initializeDefaultInstitutions()); + } } } else { this.selectedTrendTopics.set([]); @@ -275,46 +402,62 @@ export class UniTrendParentComponent implements OnInit { }); }); - // Effect: automatically refetch trend data whenever topics or comparisons change (fully reactive) + // Effect: automatically refetch trend data whenever topics or comparisons change (fully reactive with subset check) effect(() => { const topics = this.selectedTrendTopics(); const insts = this.comparisonInstitutions(); const countries = this.comparisonCountries(); const regions = this.comparisonRegions(); + const authors = this.comparisonAuthors(); + const searchType = this.selectedSearchType(); if (topics.length === 0) return; - // Check if all requested topics and entities are subsets of what was already fetched const fetchedT = new Set(untracked(() => this.fetchedTopics())); - const fetchedI = new Set( - untracked(() => this.fetchedInstitutions()).map((i) => - i.id.toLowerCase(), - ), - ); - const fetchedC = new Set( - untracked(() => this.fetchedCountries()).map((c) => c.id.toLowerCase()), - ); - const fetchedR = new Set( - untracked(() => this.fetchedRegions()).map((r) => r.id.toLowerCase()), - ); + const fetchedType = untracked(() => this.fetchedSearchType()); const allTopicsFetched = topics.every((t) => fetchedT.has(t)); - const allInstsFetched = insts.every((i) => - fetchedI.has(i.id.toLowerCase()), - ); - const allCountriesFetched = countries.every((c) => - fetchedC.has(c.id.toLowerCase()), - ); - const allRegionsFetched = regions.every((r) => - fetchedR.has(r.id.toLowerCase()), - ); + const sameType = searchType === fetchedType; - if ( - allTopicsFetched && - allInstsFetched && - allCountriesFetched && - allRegionsFetched - ) { + let allEntitiesFetched = false; + if (sameType) { + if (searchType === 'authors') { + const fetchedA = new Set( + untracked(() => this.fetchedAuthors()).map((a) => + a.id.toLowerCase(), + ), + ); + allEntitiesFetched = authors.every((a) => + fetchedA.has(a.id.toLowerCase()), + ); + } else if (searchType === 'news' || searchType === 'all') { + allEntitiesFetched = true; + } else { + // publications, patents, projects + const fetchedI = new Set( + untracked(() => this.fetchedInstitutions()).map((i) => + i.id.toLowerCase(), + ), + ); + const fetchedC = new Set( + untracked(() => this.fetchedCountries()).map((c) => + c.id.toLowerCase(), + ), + ); + const fetchedR = new Set( + untracked(() => this.fetchedRegions()).map((r) => + r.id.toLowerCase(), + ), + ); + allEntitiesFetched = + insts.every((i) => fetchedI.has(i.id.toLowerCase())) && + countries.every((c) => fetchedC.has(c.id.toLowerCase())) && + regions.every((r) => fetchedR.has(r.id.toLowerCase())); + } + } + + const hasResponse = !!untracked(() => this.rawTrendResponse()); + if (allTopicsFetched && sameType && allEntitiesFetched && hasResponse) { // All requested data is already present in rawTrendResponse, so skip backend call! return; } @@ -324,6 +467,10 @@ export class UniTrendParentComponent implements OnInit { // Handle initialization and synchronization of URL state this.route.queryParams.subscribe((params) => { + if (params['search_type']) { + this.selectedSearchType.set(params['search_type'] as any); + } + // Parse institutions serialized as id|name if (params['institutions']) { const insts = Array.isArray(params['institutions']) @@ -405,6 +552,33 @@ export class UniTrendParentComponent implements OnInit { } } + // Parse authors + if (params['authors']) { + const auths = Array.isArray(params['authors']) + ? params['authors'] + : [params['authors']]; + const parsed = auths.map((a: string) => { + const parts = a.split('|'); + return { id: parts[0], name: parts[1] || parts[0] }; + }); + + const currentIds = this.comparisonAuthors() + .map((a) => a.id) + .sort() + .join(','); + const parsedIds = parsed + .map((a) => a.id) + .sort() + .join(','); + if (currentIds !== parsedIds) { + this.comparisonAuthors.set(parsed); + } + } else { + if (this.comparisonAuthors().length > 0) { + this.comparisonAuthors.set([]); + } + } + if (params['start_year']) { this.startYear.set(Number(params['start_year'])); } @@ -429,7 +603,9 @@ export class UniTrendParentComponent implements OnInit { const kws = this.keywords(); if (kws.length === 0) return; - const topic = kws[0]; + // Use mapped topic names if softSearch is false + const topics = this.state?.topicsList() ?? kws; + const topic = topics[0] || kws[0] || 'Artificial Intelligence'; this.isSuggestionsLoading.set(true); forkJoin({ @@ -457,13 +633,11 @@ export class UniTrendParentComponent implements OnInit { }) => { const uniqueInsts = new Map(); - // Add DE ones deInsts.forEach((inst: TopInstitutionItem) => { if (inst.id) uniqueInsts.set(inst.id, inst.display_name || 'Unbekannt'); }); - // Add overall ones overallInsts.forEach((inst: TopInstitutionItem) => { if (inst.id) uniqueInsts.set(inst.id, inst.display_name || 'Unbekannt'); @@ -476,7 +650,6 @@ export class UniTrendParentComponent implements OnInit { this.comparisonInstitutions.set(list); this.isSuggestionsLoading.set(false); - // Auto-fetch trend data on first load if we don't have it yet if (!this.rawTrendResponse()) { this.fetchTrendData(); } @@ -488,15 +661,62 @@ export class UniTrendParentComponent implements OnInit { }); } - // Fetch recommended institutions for comparison based on current topics - loadTrendSuggestions() { + // Dynamically load top authors for UDE to initialize comparison list + initializeDefaultAuthors() { + const kws = this.keywords(); + if (kws.length === 0) return; + + const topics = this.state?.topicsList() ?? kws; + const topic = topics[0] || kws[0] || 'Artificial Intelligence'; this.isSuggestionsLoading.set(true); + + this.personsApiService + .searchPersonsList( + undefined, // query + 'University of Duisburg-Essen', // primary institution + undefined, // sortBy + undefined, // sortOrder + [topic], // topic + 1, // page + 3, // pageSize + undefined, // include (fetch all fields!) + ) + .subscribe({ + next: (res) => { + const list = (res.results || []).map((author: any) => ({ + id: author.id, + name: author.display_name || 'Unbekannt', + })); + this.comparisonAuthors.set(list); + this.isSuggestionsLoading.set(false); + + if (!this.rawTrendResponse()) { + this.fetchTrendData(); + } + }, + error: (err) => { + console.error('Failed to load default authors:', err); + this.isSuggestionsLoading.set(false); + }, + }); + } + + // Fetch recommended institutions or authors for comparison based on current topics + loadTrendSuggestions() { + if (this.selectedSearchType() === 'authors') { + this.loadRecommendedAuthors(); + return; + } + + this.isSuggestionsLoading.set(true); + const kws = this.keywords(); + const topics = this.state?.topicsList() ?? kws; const topic = this.activeChartTopic() || (this.selectedTrendTopics().length > 0 ? this.selectedTrendTopics()[0] - : this.keywords().length > 0 - ? this.keywords()[0] + : topics.length > 0 + ? topics[0] : 'Artificial Intelligence'); const countryFilter = @@ -526,18 +746,57 @@ export class UniTrendParentComponent implements OnInit { }); } - // Trigger search trend data (only when "Search" is clicked) + // Load UDE recommended authors for selected topic + loadRecommendedAuthors() { + this.isSuggestionsLoading.set(true); + const kws = this.keywords(); + const topics = this.state?.topicsList() ?? kws; + const topic = + this.activeChartTopic() || + (this.selectedTrendTopics().length > 0 + ? this.selectedTrendTopics()[0] + : topics.length > 0 + ? topics[0] + : 'Artificial Intelligence'); + + this.personsApiService + .searchPersonsList( + undefined, // query + 'University of Duisburg-Essen', // UDE + undefined, // sortBy + undefined, // sortOrder + [topic], // topic + 1, // page + 6, // pageSize + undefined, // include (fetch all fields!) + ) + .subscribe({ + next: (res) => { + this.recommendedAuthors.set(res.results || []); + this.isSuggestionsLoading.set(false); + }, + error: () => { + this.isSuggestionsLoading.set(false); + }, + }); + } + + // Trigger search trend data fetchTrendData() { const topics = this.selectedTrendTopics(); if (topics.length === 0) return; this.isTrendLoading.set(true); - // Save parameters of this request to check dirty state later + this.fetchedSearchType.set(this.selectedSearchType()); this.fetchedTopics.set([...topics]); this.fetchedInstitutions.set([...this.comparisonInstitutions()]); this.fetchedCountries.set([...this.comparisonCountries()]); this.fetchedRegions.set([...this.comparisonRegions()]); + this.fetchedAuthors.set([...this.comparisonAuthors()]); + + const kws = this.state?.keywordsList() ?? []; + const softSearch = this.state?.softSearch() ?? true; this.apiService .getTrendApiInseServiceUniversityRankingsTrendGet( @@ -545,6 +804,10 @@ export class UniTrendParentComponent implements OnInit { this.comparisonInstitutions().map((i: CompareItem) => i.id), this.comparisonCountries().map((c: CompareItem) => c.id), this.comparisonRegions().map((r: CompareItem) => r.id), + kws, + softSearch, + this.selectedSearchType(), + this.comparisonAuthors().map((a: CompareItem) => a.id), ) .subscribe({ next: (response: TrendResponse) => { @@ -561,6 +824,7 @@ export class UniTrendParentComponent implements OnInit { // Update query params to synchronize state updateUrlParams() { const queryParams: any = { + search_type: this.selectedSearchType(), trend_topics: this.selectedTrendTopics(), institutions: this.comparisonInstitutions().length > 0 @@ -580,6 +844,12 @@ export class UniTrendParentComponent implements OnInit { (r: CompareItem) => `${r.id}|${r.name}`, ) : null, + authors: + this.comparisonAuthors().length > 0 + ? this.comparisonAuthors().map( + (a: CompareItem) => `${a.id}|${a.name}`, + ) + : null, start_year: this.startYear(), end_year: this.endYear(), chart_mode: this.chartMode(), @@ -613,13 +883,36 @@ export class UniTrendParentComponent implements OnInit { this.selectedTrendTopics.set(updated); - // Auto-update active tab selection if previous was removed const active = this.activeChartTopic(); if (!updated.includes(active)) { this.activeChartTopic.set(updated[0] || ''); } } + // Strategy SearchType changes + setSearchType( + type: 'publications' | 'authors' | 'patents' | 'projects' | 'news' | 'all', + ) { + this.selectedSearchType.set(type); + + // Auto-initialize default lists if empty for the target type + const kws = this.keywords(); + if (kws.length > 0) { + if (type === 'authors' && this.comparisonAuthors().length === 0) { + this.initializeDefaultAuthors(); + } else if ( + type !== 'authors' && + type !== 'news' && + type !== 'all' && + this.comparisonInstitutions().length === 0 + ) { + this.initializeDefaultInstitutions(); + } + } + + this.updateUrlParams(); + } + // Add comparison institution addInstitution(id: string, name: string) { const current = this.comparisonInstitutions(); @@ -633,7 +926,6 @@ export class UniTrendParentComponent implements OnInit { this.searchResults.set([]); } - // Remove comparison institution (data reuses instantly via computed) removeInstitution(id: string) { const current = this.comparisonInstitutions(); this.comparisonInstitutions.set( @@ -665,7 +957,6 @@ export class UniTrendParentComponent implements OnInit { this.loadTrendSuggestions(); } - // Remove country or region removeLocation(id: string, type: 'country' | 'continent') { if (type === 'country') { const current = this.comparisonCountries(); @@ -681,6 +972,63 @@ export class UniTrendParentComponent implements OnInit { this.loadTrendSuggestions(); } + // Add Top 3 Authors for a selected institution from institutions autocomplete + addInstitutionAuthors(id: string, name: string) { + const kws = this.keywords(); + const topics = this.state?.topicsList() ?? kws; + const topic = + this.activeChartTopic() || topics[0] || 'Artificial Intelligence'; + + this.isSuggestionsLoading.set(true); + + this.personsApiService + .searchPersonsList( + undefined, // query + name, // institutionName + undefined, // sortBy + undefined, // sortOrder + [topic], // topic + 1, // page + 3, // pageSize + undefined, // include + ) + .subscribe({ + next: (res) => { + const current = this.comparisonAuthors(); + const updated = [...current]; + (res.results || []).forEach((author: any) => { + if (author.id && !updated.some((a) => a.id === author.id)) { + updated.push({ + id: author.id, + name: author.display_name || 'Unbekannt', + }); + } + }); + this.comparisonAuthors.set(updated); + this.isSuggestionsLoading.set(false); + }, + error: (err) => { + console.error('Failed to load top authors for institution:', err); + this.isSuggestionsLoading.set(false); + }, + }); + + this.authorInstSearchQuery.set(''); + this.authorInstSearchResults.set([]); + } + + addAuthor(id: string, name: string) { + const current = this.comparisonAuthors(); + if (!current.some((a) => a.id === id)) { + this.comparisonAuthors.set([...current, { id, name }]); + } + } + + removeAuthor(id: string) { + const current = this.comparisonAuthors(); + this.comparisonAuthors.set(current.filter((a: CompareItem) => a.id !== id)); + } + // Scaling mode toggle (data reuses instantly) setChartMode(mode: 'normalized' | 'total' | 'cumulative') { this.chartMode.set(mode); @@ -732,4 +1080,45 @@ export class UniTrendParentComponent implements OnInit { this.locationSearchResults.set([]); } } + + // Autocomplete query changes for authors in the authors tab (direct search) + onAuthorSearchChange(query: string) { + this.authorSearchQuery.set(query); + if (query.trim().length >= 3) { + this.personsApiService + .searchPersonsAutocomplete( + query, + 'display_name,last_known_institutions', + ) + .subscribe({ + next: (res: any) => { + this.authorSearchResults.set(res.results || []); + }, + error: () => { + this.authorSearchResults.set([]); + }, + }); + } else { + this.authorSearchResults.set([]); + } + } + + // Autocomplete query changes for institutions inside the top-authors selector + onAuthorInstSearchChange(query: string) { + this.authorInstSearchQuery.set(query); + if (query.trim().length >= 3) { + this.institutionsApiService + .autocompleteInstitutions(query, undefined, 'education', 10) + .subscribe({ + next: (res: AutocompleteResponse) => { + this.authorInstSearchResults.set(res.results || []); + }, + error: () => { + this.authorInstSearchResults.set([]); + }, + }); + } else { + this.authorInstSearchResults.set([]); + } + } } diff --git a/webapp/src/app/shared/ui/author-institution-selector/author-institution-selector.component.html b/webapp/src/app/shared/ui/author-institution-selector/author-institution-selector.component.html new file mode 100644 index 00000000..5cad7734 --- /dev/null +++ b/webapp/src/app/shared/ui/author-institution-selector/author-institution-selector.component.html @@ -0,0 +1,32 @@ +
+
+
+

Top-Autoren einer Einrichtung hinzufügen

+
+ + + +
+
diff --git a/webapp/src/app/shared/ui/author-institution-selector/author-institution-selector.component.scss b/webapp/src/app/shared/ui/author-institution-selector/author-institution-selector.component.scss new file mode 100644 index 00000000..99442ae2 --- /dev/null +++ b/webapp/src/app/shared/ui/author-institution-selector/author-institution-selector.component.scss @@ -0,0 +1,117 @@ +.author-institution-selector-container { + display: flex; + flex-direction: column; + background: white; + border: 1px solid #d7e4ff; + border-radius: 16px; + padding: 24px; + box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04); + box-sizing: border-box; + margin-top: 20px; + width: 100%; +} + +.search-compare-section { + display: flex; + flex-direction: column; + box-sizing: border-box; + + h3 { + font-size: 0.9rem; + font-weight: 700; + color: #07163d; + margin: 0 0 1rem 0; + line-height: 1.2; + } +} + +.section-header { + display: flex; + align-items: center; + justify-content: space-between; + gap: 12px; + flex-wrap: wrap; + margin-bottom: 0.5rem; + + h3 { + margin: 0; + } +} + +/* Autocomplete Search input */ +.autocomplete-search { + position: relative; + width: 100%; + + .search-icon { + position: absolute; + left: 10px; + top: 50%; + transform: translateY(-50%); + font-size: 18px; + width: 18px; + height: 18px; + color: #9ca3af; + pointer-events: none; + } + + input { + width: 100%; + padding: 0.6rem 0.6rem 0.6rem 2.2rem; + border-radius: 8px; + border: 1px solid #d1d5db; + font-size: 0.8125rem; + outline: none; + box-sizing: border-box; + transition: all 0.2s ease; + + &:focus { + border-color: #3b82f6; + box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1); + } + } +} + +.autocomplete-results { + position: absolute; + top: 100%; + left: 0; + right: 0; + z-index: 50; + background: white; + border: 1px solid #e5e7eb; + border-radius: 8px; + box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1); + margin-top: 4px; + padding: 4px 0; + list-style: none; + max-height: 200px; + overflow-y: auto; + + li button { + width: 100%; + text-align: left; + background: none; + border: none; + padding: 0.6rem 1rem; + cursor: pointer; + display: flex; + flex-direction: column; + transition: background 0.15s ease; + + &:hover { + background: #f3f4f6; + } + + .name { + font-size: 0.75rem; + font-weight: 600; + color: #1f2937; + } + .hint { + font-size: 0.65rem; + color: #6b7280; + margin-top: 2px; + } + } +} diff --git a/webapp/src/app/shared/ui/author-institution-selector/author-institution-selector.component.ts b/webapp/src/app/shared/ui/author-institution-selector/author-institution-selector.component.ts new file mode 100644 index 00000000..d4600f5a --- /dev/null +++ b/webapp/src/app/shared/ui/author-institution-selector/author-institution-selector.component.ts @@ -0,0 +1,30 @@ +import { Component, input, output } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { MatIconModule } from '@angular/material/icon'; + +@Component({ + selector: 'app-author-institution-selector', + standalone: true, + imports: [CommonModule, MatIconModule], + templateUrl: './author-institution-selector.component.html', + styleUrl: './author-institution-selector.component.scss', +}) +export class AuthorInstitutionSelectorComponent { + readonly searchQuery = input(''); + readonly searchResults = input([]); + + readonly addInstitutionAuthors = output<{ id: string; name: string }>(); + readonly searchChange = output(); + + onSearchInput(event: Event): void { + const val = (event.target as HTMLInputElement).value; + this.searchChange.emit(val); + } + + onSelectResult(result: any): void { + this.addInstitutionAuthors.emit({ + id: result.id || '', + name: result.display_name || '', + }); + } +} diff --git a/webapp/src/app/shared/ui/author-selector/author-selector.component.html b/webapp/src/app/shared/ui/author-selector/author-selector.component.html new file mode 100644 index 00000000..349f3c91 --- /dev/null +++ b/webapp/src/app/shared/ui/author-selector/author-selector.component.html @@ -0,0 +1,128 @@ +
+ +
+
+

Autoren vergleichen

+
+ + + + + +
+ @if (comparisonAuthors().length > 0) { +
+ @for (auth of comparisonAuthors(); track auth.id) { +
+ + person {{ auth.name }} + +
+ + +
+
+ } +
+ } @else { +
+ Keine Autoren ausgewählt. Suchen Sie nach Autoren, um sie zu + vergleichen. +
+ } +
+
+ + +
+

+ Empfohlene Top-Autoren (UDE) für das Thema: {{ activeChartTopic() }} +

+ +
+ @if (isSuggestionsLoading()) { +
+
+ Empfehlungen werden geladen... +
+ } @else { + @if (topSuggestions().length === 0) { +

+ Keine Autorenempfehlungen für dieses Thema gefunden. +

+ } @else { +
+ @for (item of topSuggestions(); track item.id || '') { + + } +
+ } + } +
+
+
diff --git a/webapp/src/app/shared/ui/author-selector/author-selector.component.scss b/webapp/src/app/shared/ui/author-selector/author-selector.component.scss new file mode 100644 index 00000000..83d3db84 --- /dev/null +++ b/webapp/src/app/shared/ui/author-selector/author-selector.component.scss @@ -0,0 +1,320 @@ +.author-selector-container { + display: grid; + grid-template-columns: 1fr 1.5fr; + gap: 24px; + background: white; + border: 1px solid #d7e4ff; + border-radius: 16px; + padding: 24px; + box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04); + box-sizing: border-box; + margin-top: 20px; + + @media (max-width: 1024px) { + grid-template-columns: 1fr; + gap: 20px; + padding: 16px; + } +} + +.search-compare-section, +.recommendations-section { + display: flex; + flex-direction: column; + box-sizing: border-box; + + h3 { + font-size: 0.9rem; + font-weight: 700; + color: #07163d; + margin: 0 0 1rem 0; + line-height: 1.2; + } +} + +.section-header { + display: flex; + align-items: center; + justify-content: space-between; + gap: 12px; + flex-wrap: wrap; + margin-bottom: 0.5rem; + + h3 { + margin: 0; + } +} + +/* Autocomplete Search input */ +.autocomplete-search { + position: relative; + width: 100%; + margin-bottom: 1rem; + + .search-icon { + position: absolute; + left: 10px; + top: 50%; + transform: translateY(-50%); + font-size: 18px; + width: 18px; + height: 18px; + color: #9ca3af; + pointer-events: none; + } + + input { + width: 100%; + padding: 0.6rem 0.6rem 0.6rem 2.2rem; + border-radius: 8px; + border: 1px solid #d1d5db; + font-size: 0.8125rem; + outline: none; + box-sizing: border-box; + transition: all 0.2s ease; + + &:focus { + border-color: #3b82f6; + box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1); + } + } +} + +.autocomplete-results { + position: absolute; + top: 100%; + left: 0; + right: 0; + z-index: 50; + background: white; + border: 1px solid #e5e7eb; + border-radius: 8px; + box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1); + margin-top: 4px; + padding: 4px 0; + list-style: none; + max-height: 200px; + overflow-y: auto; + + li button { + width: 100%; + text-align: left; + background: none; + border: none; + padding: 0.6rem 1rem; + cursor: pointer; + display: flex; + flex-direction: column; + transition: background 0.15s ease; + + &:hover { + background: #f3f4f6; + } + + .name { + font-size: 0.75rem; + font-weight: 600; + color: #1f2937; + } + .hint { + font-size: 0.65rem; + color: #6b7280; + margin-top: 2px; + } + } +} + +/* Comparison list & chips */ +.comparison-list { + flex: 1; + min-height: 80px; + + .empty-list-info { + font-size: 0.75rem; + color: #9ca3af; + text-align: center; + padding: 16px; + border: 1px dashed #e5e7eb; + border-radius: 8px; + } +} + +.chips-flex { + display: flex; + flex-wrap: wrap; + gap: 0.5rem; + max-height: 180px; + overflow-y: auto; + padding-right: 4px; +} + +.comparison-item { + display: inline-flex; + justify-content: space-between; + align-items: center; + border: 1px solid #e5e7eb; + border-radius: 6px; + padding: 0.35rem 0.6rem; + gap: 8px; + transition: all 0.2s ease; + max-width: 100%; + + .item-name { + display: inline-flex; + align-items: center; + gap: 6px; + font-size: 0.75rem; + font-weight: 600; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + max-width: 180px; + + mat-icon { + font-size: 14px; + width: 14px; + height: 14px; + } + } + + .item-actions { + display: flex; + align-items: center; + gap: 4px; + } + + .action-btn { + background: none; + border: none; + cursor: pointer; + padding: 2px; + border-radius: 4px; + display: inline-flex; + align-items: center; + justify-content: center; + transition: all 0.15s ease; + + mat-icon { + font-size: 14px; + width: 14px; + height: 14px; + } + + &:hover { + background: rgba(0, 0, 0, 0.05); + } + + &.remove-btn:hover { + color: #ef4444 !important; + background: #fee2e2; + } + } +} + +/* Recommendations suggestions section */ +.suggestions-grid { + flex: 1; + display: flex; + flex-direction: column; +} + +.suggestions-flex { + display: grid; + grid-template-columns: repeat(2, 1fr); + gap: 10px; + max-height: 250px; + overflow-y: auto; + padding-right: 4px; + + @media (max-width: 600px) { + grid-template-columns: 1fr; + } +} + +.suggestion-item-horizontal { + display: flex; + align-items: center; + gap: 8px; + padding: 10px 12px; + border: 1px solid #e5e7eb; + border-radius: 8px; + background: #f9fafb; + text-align: left; + cursor: pointer; + transition: all 0.2s ease; + box-sizing: border-box; + + &:hover:not(:disabled) { + background: #f3f4f6; + border-color: #3b82f6; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02); + } + + &:disabled { + opacity: 0.5; + cursor: not-allowed; + background: #f3f4f6; + } + + .add-icon { + color: #3b82f6; + font-size: 18px; + width: 18px; + height: 18px; + flex-shrink: 0; + } + + .info { + display: flex; + flex-direction: column; + min-width: 0; + + .name { + font-size: 0.75rem; + font-weight: 600; + color: #1f2937; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + } + + .meta { + font-size: 0.65rem; + color: #6b7280; + margin-top: 2px; + } + } +} + +.no-suggestions-msg { + font-size: 0.75rem; + color: #6b7280; + margin: 12px 0 0 0; +} + +.suggestions-loader { + display: flex; + align-items: center; + gap: 8px; + font-size: 0.75rem; + color: #6b7280; + margin-top: 12px; +} + +.spinner-small { + width: 16px; + height: 16px; + border: 2px solid #e5e7eb; + border-top: 2px solid #3b82f6; + border-radius: 50%; + animation: spin 0.8s linear infinite; +} + +@keyframes spin { + 0% { + transform: rotate(0deg); + } + 100% { + transform: rotate(360deg); + } +} diff --git a/webapp/src/app/shared/ui/author-selector/author-selector.component.ts b/webapp/src/app/shared/ui/author-selector/author-selector.component.ts new file mode 100644 index 00000000..9e2f74f5 --- /dev/null +++ b/webapp/src/app/shared/ui/author-selector/author-selector.component.ts @@ -0,0 +1,63 @@ +import { Component, input, output } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { MatIconModule } from '@angular/material/icon'; + +export interface CompareItem { + id: string; + name: string; +} + +@Component({ + selector: 'app-author-selector', + standalone: true, + imports: [CommonModule, MatIconModule], + templateUrl: './author-selector.component.html', + styleUrl: './author-selector.component.scss', +}) +export class AuthorSelectorComponent { + readonly comparisonAuthors = input([]); + readonly topSuggestions = input([]); + readonly isSuggestionsLoading = input(false); + readonly searchQuery = input(''); + readonly searchResults = input([]); + readonly activeChartTopic = input(''); + readonly getEntityColor = input<(id: string) => string>(() => '#9ca3af'); + readonly isVisible = input<(id: string) => boolean>(() => true); + + readonly addAuthor = output<{ id: string; name: string }>(); + readonly removeAuthor = output(); + readonly searchChange = output(); + readonly toggleVisibility = output(); + + onSearchInput(event: Event): void { + const val = (event.target as HTMLInputElement).value; + this.searchChange.emit(val); + } + + onSelectResult(result: any): void { + this.addAuthor.emit({ + id: result.id || '', + name: result.display_name || '', + }); + } + + onSelectSuggestion(item: any): void { + this.addAuthor.emit({ + id: item.id || '', + name: item.display_name || 'Unbekannt', + }); + } + + onRemove(id: string): void { + this.removeAuthor.emit(id); + } + + onToggleVisibility(id: string): void { + this.toggleVisibility.emit(id); + } + + isAlreadyAdded(id: string | undefined): boolean { + if (!id) return false; + return this.comparisonAuthors().some((i) => i.id === id); + } +}