From 736277d6ffcdd98115681bf35f3ebee4a95bf2c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mats=20Paul=20Ton=C4=8Dik?= Date: Thu, 4 Jun 2026 21:44:16 +0200 Subject: [PATCH] Moved network filter to dialog component --- .../person-network-graph.component.html | 26 +- .../person-network-graph.component.scss | 10 + .../person-network-graph.component.ts | 39 ++- .../person-network.component.html | 228 +++++------------- .../person-network.component.scss | 58 +++-- .../person-network.component.ts | 45 +++- ...erson-network-filter-dialog.component.html | 107 ++++++++ ...erson-network-filter-dialog.component.scss | 31 +++ .../person-network-filter-dialog.component.ts | 71 ++++++ 9 files changed, 404 insertions(+), 211 deletions(-) create mode 100644 webapp/src/app/person-network-filter-dialog/person-network-filter-dialog.component.html create mode 100644 webapp/src/app/person-network-filter-dialog/person-network-filter-dialog.component.scss create mode 100644 webapp/src/app/person-network-filter-dialog/person-network-filter-dialog.component.ts diff --git a/webapp/src/app/modules/person-network-graph/person-network-graph.component.html b/webapp/src/app/modules/person-network-graph/person-network-graph.component.html index 8a37053e..a80560d8 100644 --- a/webapp/src/app/modules/person-network-graph/person-network-graph.component.html +++ b/webapp/src/app/modules/person-network-graph/person-network-graph.component.html @@ -1,16 +1,18 @@ - - Kollaborations Netzwerk von {{ authorDisplayName }} - -
+ @if (!isValidGraph()) { +
+ warning +

Das Netzwerk ist zu groß für eine detaillierte Darstellung.

+
+ } @else { +
+ }
diff --git a/webapp/src/app/modules/person-network-graph/person-network-graph.component.scss b/webapp/src/app/modules/person-network-graph/person-network-graph.component.scss index ebdd5e69..93a43f1b 100644 --- a/webapp/src/app/modules/person-network-graph/person-network-graph.component.scss +++ b/webapp/src/app/modules/person-network-graph/person-network-graph.component.scss @@ -13,6 +13,7 @@ mat-card { mat-card-content { flex: 1 1 auto; min-height: 0; + align-items: center; } .graph { @@ -24,3 +25,12 @@ mat-card-content { user-select: none; cursor: grab; } + +.warning-container { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + gap: 16px; + padding: 24px; +} diff --git a/webapp/src/app/modules/person-network-graph/person-network-graph.component.ts b/webapp/src/app/modules/person-network-graph/person-network-graph.component.ts index f3e16580..018ee2be 100644 --- a/webapp/src/app/modules/person-network-graph/person-network-graph.component.ts +++ b/webapp/src/app/modules/person-network-graph/person-network-graph.component.ts @@ -1,4 +1,4 @@ -import { Component, effect, input } from '@angular/core'; +import { Component, computed, effect, input } from '@angular/core'; import { MatCardModule } from '@angular/material/card'; import { CollaborationNetwork } from '../../api'; import { NgxEchartsDirective } from 'ngx-echarts'; @@ -8,11 +8,12 @@ import * as echarts from 'echarts/core'; import { GridComponent, TitleComponent } from 'echarts/components'; import { CanvasRenderer } from 'echarts/renderers'; import { GraphChart } from 'echarts/charts'; +import { MatIconModule } from '@angular/material/icon'; echarts.use([GridComponent, CanvasRenderer, GraphChart, TitleComponent]); @Component({ selector: 'app-person-network-graph', - imports: [MatCardModule, NgxEchartsDirective], + imports: [MatCardModule, MatIconModule, NgxEchartsDirective], templateUrl: './person-network-graph.component.html', styleUrl: './person-network-graph.component.scss', }) @@ -23,6 +24,16 @@ export class PersonNetworkGraphComponent { options!: EChartsCoreOption; + readonly isValidGraph = computed(() => { + const network = this.collaborationNetwork(); + return ( + network !== undefined && + network.nodes.length > 0 && + network.nodes.length < 1000 && + network.edges.length > 0 + ); + }); + constructor() { effect(() => { const network = this.collaborationNetwork(); @@ -42,6 +53,12 @@ export class PersonNetworkGraphComponent { return; } + const frequencies = + this.calculateOccurenceFrequencies(collaborationNetwork); + + const minFrequency = Math.min(...Object.values(frequencies)); + const maxFrequency = Math.max(...Object.values(frequencies)); + const datas = [ { nodes: collaborationNetwork.nodes.map((node) => { @@ -73,6 +90,11 @@ export class PersonNetworkGraphComponent { label: { show: true, }, + symbolSize: + 25 + + (((frequencies[node.raw_id] || 0) - minFrequency) / + (maxFrequency - minFrequency)) * + 30, }; }), links: collaborationNetwork.edges.map((edge) => { @@ -134,4 +156,17 @@ export class PersonNetworkGraphComponent { }), }; } + + calculateOccurenceFrequencies( + netork: CollaborationNetwork, + ): Record { + const frequencies: Record = {}; + netork.edges.forEach((edge) => { + frequencies[edge.raw_source_id] = + (frequencies[edge.raw_source_id] || 0) + 1; + frequencies[edge.raw_target_id] = + (frequencies[edge.raw_target_id] || 0) + 1; + }); + return frequencies; + } } diff --git a/webapp/src/app/modules/person-network/person-network.component.html b/webapp/src/app/modules/person-network/person-network.component.html index 9bb58c92..d68d7eee 100644 --- a/webapp/src/app/modules/person-network/person-network.component.html +++ b/webapp/src/app/modules/person-network/person-network.component.html @@ -1,172 +1,72 @@
- @if (collaborationNetwork.nodes.length < 1000) { - - } +
+
+
Netzwerk
+

Zusammenarbeit und Verbindungen im wissenschaftlichen Netzwerk.

+
+ +
-
-
- - - Filter - -
- - Startjahr (inklusive) - - - - Endjahr (inklusive) - - -
-
- - Minimale Anzahl von Kollaborierenden (inklusiv) - - - - Maximale Anzahl von Kollaborierenden (exklusiv) - - -
-
- - Minimale Anzahl von Kollaborationen (inklusiv) - - - - Maximale Anzahl von Kollaborationen (inklusiv) - - -
+
+ -
- - Institutionen - - @for ( - institution of collaborationNetwork.filter_information - .institutions; - track institution.raw_id - ) { - - {{ institution.display_name }} - - } - - - - Themen - - @for ( - topic of collaborationNetwork.filter_information.topics; - track topic.raw_topic_id - ) { - - {{ topic.display_name }} - - } - - -
- - - - - Kollaborierende - - Publikationen + + - - - {{ - this.displayedTable() === "collaborators" - ? "Suche Kollaborierende nach Name oder ID" - : "Suche Publikationen nach Titel oder ID" - }} - - search - - + + Kollaborierende + + Publikationen + + + {{ + this.displayedTable() === "collaborators" + ? "Suche Kollaborierende nach Name oder ID" + : "Suche Publikationen nach Titel oder ID" + }} + + search + + -
- - -
- @if (this.displayedTable() === "collaborators") { - - } @else if (this.displayedTable() === "publications") { - - } -
-
-
+
+ + +
+ @if (this.displayedTable() === "collaborators") { + + } @else if (this.displayedTable() === "publications") { + + } +
+
+
+
diff --git a/webapp/src/app/modules/person-network/person-network.component.scss b/webapp/src/app/modules/person-network/person-network.component.scss index 234fc412..b51ee5be 100644 --- a/webapp/src/app/modules/person-network/person-network.component.scss +++ b/webapp/src/app/modules/person-network/person-network.component.scss @@ -1,47 +1,36 @@ .content { display: flex; - flex-direction: row; + flex-direction: column; padding: 40px; gap: 20px; align-items: stretch; } +.top-row { + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: end; + gap: 20px; +} + +.description-container { + display: flex; + flex-direction: column; +} + +.cards { + display: flex; + flex-direction: row; + gap: 20px; +} + .content > app-person-network-graph, .right-card { flex: 1 1 0; min-width: 0; } -.table { - overflow: auto; - width: 100%; - max-height: 70vh; - height: 100%; -} - -.table table { - width: 100%; -} - -.table-area { - width: 100%; - height: 100%; - display: flex; - flex-direction: column; -} - -.scroll-viewport-container { - width: 100%; - height: 100%; -} - -.form-controls { - display: flex; - flex-direction: row; - align-items: flex-start; - gap: 10px; -} - .form-field-full { width: 100%; } @@ -67,3 +56,10 @@ .pair-field > mat-form-field { width: 100%; } + +.top-row button { + height: 42px; + border-color: var(--sg-border); + border-radius: var(--sg-radius-sm); + color: var(--sg-text); +} \ No newline at end of file diff --git a/webapp/src/app/modules/person-network/person-network.component.ts b/webapp/src/app/modules/person-network/person-network.component.ts index 66c9c25d..0c192706 100644 --- a/webapp/src/app/modules/person-network/person-network.component.ts +++ b/webapp/src/app/modules/person-network/person-network.component.ts @@ -29,6 +29,8 @@ import { debounceTime } from 'rxjs'; import { PersonNetworkGraphComponent } from '../person-network-graph/person-network-graph.component'; import { MatSelectModule } from '@angular/material/select'; import { MatExpansionModule } from '@angular/material/expansion'; +import { MatDialog, MatDialogModule } from '@angular/material/dialog'; +import { PersonNetworkFilterDialogComponent } from '../../person-network-filter-dialog/person-network-filter-dialog.component'; @Component({ selector: 'app-person-network', @@ -53,6 +55,7 @@ import { MatExpansionModule } from '@angular/material/expansion'; PersonNetworkGraphComponent, MatSelectModule, MatExpansionModule, + MatDialogModule, ], templateUrl: './person-network.component.html', styleUrl: './person-network.component.scss', @@ -89,13 +92,51 @@ export class PersonNetworkComponent implements OnInit { readonly activatedRouteData = toSignal(this.activatedRoute.data); - formatYearLabel = (value: number) => `${value}`; - constructor( private readonly activatedRoute: ActivatedRoute, private readonly router: Router, + private readonly dialog: MatDialog, ) {} + openFilterDialog() { + const dialogRef = this.dialog.open(PersonNetworkFilterDialogComponent, { + data: { + collaborationNetwork: this.collaborationNetwork, + startYear: this.filterForm.get('startYear')?.value, + endYear: this.filterForm.get('endYear')?.value, + minimumCollaborators: this.filterForm.get('minimumCollaborators') + ?.value, + maximumCollaborators: this.filterForm.get('maximumCollaborators') + ?.value, + minimumCollaborations: this.filterForm.get('minimumCollaborations') + ?.value, + maximumCollaborations: this.filterForm.get('maximumCollaborations') + ?.value, + institutions: this.filterForm.get('institutions')?.value, + topics: this.filterForm.get('topics')?.value, + }, + }); + + dialogRef.afterClosed().subscribe((result) => { + console.log('Dialog result:', result); + if (result) { + this.filterForm.setValue({ + searchTerm: this.filterForm.get('searchTerm')?.value || '', + startYear: result.startYear, + endYear: result.endYear, + minimumCollaborators: result.minimumCollaborators, + maximumCollaborators: result.maximumCollaborators, + minimumCollaborations: result.minimumCollaborations, + maximumCollaborations: result.maximumCollaborations, + institutions: result.institutions, + topics: result.topics, + displayedTable: + this.filterForm.get('displayedTable')?.value || 'collaborators', + }); + } + }); + } + ngOnInit(): void { this.activatedRoute.data.subscribe(({ collaborationNetwork }) => { this.collaborationNetwork = collaborationNetwork; diff --git a/webapp/src/app/person-network-filter-dialog/person-network-filter-dialog.component.html b/webapp/src/app/person-network-filter-dialog/person-network-filter-dialog.component.html new file mode 100644 index 00000000..c9bef5f4 --- /dev/null +++ b/webapp/src/app/person-network-filter-dialog/person-network-filter-dialog.component.html @@ -0,0 +1,107 @@ +

Netzwerkfilter

+ + +
+
+ + Startjahr (inklusive) + + + + Endjahr (inklusive) + + +
+ + + Minimale Anzahl von Kollaborierenden (inklusiv) + + + + Maximale Anzahl von Kollaborierenden (exklusiv) + + + + + Minimale Anzahl von Kollaborationen (inklusiv) + + + + Maximale Anzahl von Kollaborationen (inklusiv) + + + + + Institutionen + + @for ( + institution of collaborationNetwork.filter_information.institutions; + track institution.raw_id + ) { + + {{ institution.display_name }} + + } + + + + Themen + + @for ( + topic of collaborationNetwork.filter_information.topics; + track topic.raw_topic_id + ) { + + {{ topic.display_name }} + + } + + +
+
+ + + + diff --git a/webapp/src/app/person-network-filter-dialog/person-network-filter-dialog.component.scss b/webapp/src/app/person-network-filter-dialog/person-network-filter-dialog.component.scss new file mode 100644 index 00000000..8a9b4eb9 --- /dev/null +++ b/webapp/src/app/person-network-filter-dialog/person-network-filter-dialog.component.scss @@ -0,0 +1,31 @@ +form { + padding: 20px; + display: flex; + flex-direction: column; + gap: 20px; +} + + + +.form-field-full { + width: 100%; +} + + +.toggle-group { + margin-bottom: 20px; +} + +.toggle-group .mat-button-toggle { + text-transform: none; + width: 100%; +} + +.pair-field { + display: flex; + gap: 20px; +} + +.pair-field > mat-form-field { + width: 100%; +} diff --git a/webapp/src/app/person-network-filter-dialog/person-network-filter-dialog.component.ts b/webapp/src/app/person-network-filter-dialog/person-network-filter-dialog.component.ts new file mode 100644 index 00000000..f452c4df --- /dev/null +++ b/webapp/src/app/person-network-filter-dialog/person-network-filter-dialog.component.ts @@ -0,0 +1,71 @@ +import { Component, inject } from '@angular/core'; +import { + FormControl, + FormGroup, + FormsModule, + ReactiveFormsModule, +} from '@angular/forms'; +import { + MAT_DIALOG_DATA, + MatDialogModule, + MatDialogRef, +} from '@angular/material/dialog'; +import { MatFormFieldModule } from '@angular/material/form-field'; +import { CollaborationNetwork } from '../api'; +import { MatSelectModule } from '@angular/material/select'; +import { MatInputModule } from '@angular/material/input'; +import { MatButtonModule } from '@angular/material/button'; + +export interface PersonNetworkFilterDialogData { + collaborationNetwork: CollaborationNetwork; + startYear: number; + endYear: number; + minimumCollaborators: number; + maximumCollaborators: number; + minimumCollaborations: number; + maximumCollaborations: number; + institutions: string[]; + topics: string[]; +} + +@Component({ + selector: 'app-person-network-filter-dialog', + imports: [ + FormsModule, + ReactiveFormsModule, + MatFormFieldModule, + MatSelectModule, + MatDialogModule, + MatInputModule, + MatButtonModule + ], + templateUrl: './person-network-filter-dialog.component.html', + styleUrl: './person-network-filter-dialog.component.scss', +}) +export class PersonNetworkFilterDialogComponent { + readonly dialogRef = inject(MatDialogRef); + readonly data = inject(MAT_DIALOG_DATA); + + readonly collaborationNetwork = this.data.collaborationNetwork; + + filterForm = new FormGroup({ + startYear: new FormControl(2000), + endYear: new FormControl(2025), + minimumCollaborators: new FormControl(2), + maximumCollaborators: new FormControl(10), + minimumCollaborations: new FormControl(1), + maximumCollaborations: new FormControl(100), + institutions: new FormControl([]), + topics: new FormControl([]), + }); + + onCancel() { + this.dialogRef.close(); + } + + onApply() { + if (this.filterForm.valid) { + this.dialogRef.close(this.filterForm.value); + } + } +}