From f76d63a76c35bdef8d3336c809a4f7ce05ec1634 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mats=20Paul=20Ton=C4=8Dik?= Date: Fri, 5 Jun 2026 14:23:55 +0200 Subject: [PATCH] Added network table for institutions --- .../person-network-collaborators.component.ts | 4 + .../person-network-graph.component.ts | 3 +- ...person-network-institutions.component.html | 45 +++++++ ...person-network-institutions.component.scss | 29 ++++ .../person-network-institutions.component.ts | 126 ++++++++++++++++++ ...person-network-publications.component.html | 12 -- .../person-network-publications.component.ts | 6 +- .../person-network.component.html | 19 ++- .../person-network.component.ts | 26 +++- 9 files changed, 246 insertions(+), 24 deletions(-) create mode 100644 webapp/src/app/modules/person-network-institutions/person-network-institutions.component.html create mode 100644 webapp/src/app/modules/person-network-institutions/person-network-institutions.component.scss create mode 100644 webapp/src/app/modules/person-network-institutions/person-network-institutions.component.ts diff --git a/webapp/src/app/modules/person-network-collaborators/person-network-collaborators.component.ts b/webapp/src/app/modules/person-network-collaborators/person-network-collaborators.component.ts index 6138705f..0860dec1 100644 --- a/webapp/src/app/modules/person-network-collaborators/person-network-collaborators.component.ts +++ b/webapp/src/app/modules/person-network-collaborators/person-network-collaborators.component.ts @@ -142,6 +142,10 @@ export class PersonNetworkCollaboratorsComponent implements AfterViewInit { } }); + Object.values(allAuthors).forEach((author) => { + author.works.sort((a, b) => a.title.localeCompare(b.title)); + }); + return new MatTableDataSource( Object.values(allAuthors).filter( (author) => 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 7362cb6a..8c6235de 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 @@ -13,7 +13,6 @@ import { import { CanvasRenderer } from 'echarts/renderers'; import { GraphChart } from 'echarts/charts'; import { MatIconModule } from '@angular/material/icon'; -import { ActivatedRoute, Router } from '@angular/router'; echarts.use([ GridComponent, CanvasRenderer, @@ -22,7 +21,7 @@ echarts.use([ LegendComponent, ]); -export type NodeCategory = 'author' | 'collaborator' | 'work'; +export type NodeCategory = 'author' | 'collaborator' | 'work' | 'institution'; export interface NodeClickEvent { id: string; diff --git a/webapp/src/app/modules/person-network-institutions/person-network-institutions.component.html b/webapp/src/app/modules/person-network-institutions/person-network-institutions.component.html new file mode 100644 index 00000000..052d4d06 --- /dev/null +++ b/webapp/src/app/modules/person-network-institutions/person-network-institutions.component.html @@ -0,0 +1,45 @@ +
+ + + + + + + + + + + + + + + + +
ID{{ element.id }}Titel + {{ element.name }} + Mitwirkende + {{ element.collaborators.length }} +
+
+ + + + + + + + diff --git a/webapp/src/app/modules/person-network-institutions/person-network-institutions.component.scss b/webapp/src/app/modules/person-network-institutions/person-network-institutions.component.scss new file mode 100644 index 00000000..57d2cbf4 --- /dev/null +++ b/webapp/src/app/modules/person-network-institutions/person-network-institutions.component.scss @@ -0,0 +1,29 @@ +.table { + overflow: auto; + width: 100%; + max-height: 100%; +} + +.mat-mdc-table { + background-color: var(--sg-background); +} + +.element-row { + position: relative; +} + +.element-row:not(.expanded) { + cursor: pointer; +} + +.element-row:not(.expanded):hover { + background: #f5f5f5; +} + +.element-row.expanded { + border-bottom-color: transparent; +} + +.detail-row { + width: 100%; +} diff --git a/webapp/src/app/modules/person-network-institutions/person-network-institutions.component.ts b/webapp/src/app/modules/person-network-institutions/person-network-institutions.component.ts new file mode 100644 index 00000000..38df3cbe --- /dev/null +++ b/webapp/src/app/modules/person-network-institutions/person-network-institutions.component.ts @@ -0,0 +1,126 @@ +import { + AfterViewInit, + Component, + effect, + input, + ViewChild, +} from '@angular/core'; +import { CollaborationNetwork } from '../../api'; +import { MatTableDataSource, MatTableModule } from '@angular/material/table'; +import { MatSort, MatSortModule } from '@angular/material/sort'; +import { MatIconModule } from '@angular/material/icon'; +import { RouterModule } from '@angular/router'; +import { CdkDetailRowDirective } from '../../directives/cdk-detail-row.directive'; +import { MatButtonModule } from '@angular/material/button'; + +type Collaborator = { + id: string; + name: string; +}; + +type Institution = { + id: string; + name: string; + collaborators: Collaborator[]; +}; + +@Component({ + selector: 'app-person-network-institutions', + imports: [ + MatTableModule, + MatIconModule, + MatSortModule, + RouterModule, + CdkDetailRowDirective, + MatButtonModule, + ], + templateUrl: './person-network-institutions.component.html', + styleUrl: './person-network-institutions.component.scss', +}) +export class PersonNetworkInstitutionsComponent implements AfterViewInit { + collaborationNetwork = input.required(); + searchTerm = input.required(); + + displayedColumns: string[] = ['id', 'name', 'collaborators']; + + dataSource = new MatTableDataSource(); + + trackBy = (index: number, item: Institution) => item.id; + + @ViewChild(MatSort) sort!: MatSort; + + constructor() { + effect(() => { + const collaborationNetwork = this.collaborationNetwork(); + if (!collaborationNetwork) { + return; + } + + this.dataSource = this.buildInstitutionsDataSource(collaborationNetwork); + this.dataSource.sortingDataAccessor = (item, property) => { + if (property === 'collaborators') { + return item.collaborators.length; + } + return (item as any)[property]; + }; + if (this.sort) { + this.dataSource.sort = this.sort; + this.setDefaultSort(); + } + }); + + effect(() => { + const searchTerm = this.searchTerm().toLowerCase(); + this.dataSource.filter = searchTerm; + }); + } + + ngAfterViewInit() { + if (this.sort) { + this.dataSource.sort = this.sort; + } + } + + private setDefaultSort(): void { + this.sort.active = 'name'; + this.sort.direction = 'asc'; + this.sort.sortChange.emit({ active: 'name', direction: 'asc' }); + } + + buildInstitutionsDataSource( + collaborationNetwork: CollaborationNetwork, + ): MatTableDataSource { + const institutionsMap: Record = {}; + + for (const node of collaborationNetwork.nodes) { + if (node.category === 'institution') { + institutionsMap[node.raw_id] = { + id: node.raw_id, + name: node.display_name, + collaborators: [], + }; + } + } + + for (const edge of collaborationNetwork.edges) { + if (edge.raw_target_id in institutionsMap) { + const institution = institutionsMap[edge.raw_target_id]; + institution.collaborators.push({ + id: edge.raw_source_id, + name: + collaborationNetwork.nodes.find( + (node) => node.raw_id === edge.raw_source_id, + )?.display_name || 'Unbekannt', + }); + } + } + + for (const institution of Object.values(institutionsMap)) { + institution.collaborators.sort((a, b) => + a.name.localeCompare(b.name, 'de', { sensitivity: 'base' }), + ); + } + + return new MatTableDataSource(Object.values(institutionsMap)); + } +} diff --git a/webapp/src/app/modules/person-network-publications/person-network-publications.component.html b/webapp/src/app/modules/person-network-publications/person-network-publications.component.html index c9227bb8..9206482a 100644 --- a/webapp/src/app/modules/person-network-publications/person-network-publications.component.html +++ b/webapp/src/app/modules/person-network-publications/person-network-publications.component.html @@ -16,18 +16,6 @@ {{ element.collaborators.length }} - - - - - - (); searchTerm = input.required(); - displayedColumns: string[] = ['id', 'title', 'contributors', 'actions']; + displayedColumns: string[] = ['id', 'title', 'contributors']; dataSource = new MatTableDataSource(); @@ -134,6 +134,10 @@ export class PersonNetworkPublicationsComponent implements AfterViewInit { } }); + Object.values(allWorks).forEach((work) => { + work.collaborators.sort((a, b) => a.name.localeCompare(b.name)); + }); + return new MatTableDataSource( Object.values(allWorks).filter((work) => work.collaborators.length > 0), ); 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 6ed2bd00..6883dce7 100644 --- a/webapp/src/app/modules/person-network/person-network.component.html +++ b/webapp/src/app/modules/person-network/person-network.component.html @@ -27,6 +27,9 @@ Publikationen + + Institutionen + - {{ - this.displayedTable() === "collaborators" - ? "Suche Kollaborierende nach Name oder ID" - : "Suche Publikationen nach Titel oder ID" - }} + {{ this.searchTermLabel() }} - search + search + @@ -61,6 +63,11 @@ [collaborationNetwork]="collaborationNetwork" [searchTerm]="searchTerm()" /> + } @else if (this.displayedTable() === "institutions") { + } 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 5dc7902b..e91df9fb 100644 --- a/webapp/src/app/modules/person-network/person-network.component.ts +++ b/webapp/src/app/modules/person-network/person-network.component.ts @@ -36,6 +36,7 @@ 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'; import { PersonNetworkInfoCardComponent } from '../person-network-info-card/person-network-info-card.component'; +import { PersonNetworkInstitutionsComponent } from '../person-network-institutions/person-network-institutions.component'; @Component({ selector: 'app-person-network', @@ -62,6 +63,7 @@ import { PersonNetworkInfoCardComponent } from '../person-network-info-card/pers MatExpansionModule, MatDialogModule, PersonNetworkInfoCardComponent, + PersonNetworkInstitutionsComponent, ], templateUrl: './person-network.component.html', styleUrl: './person-network.component.scss', @@ -88,18 +90,32 @@ export class PersonNetworkComponent implements OnInit { publications = signal(0); connections = signal(0); + searchTermLabel = computed(() => { + const displayedTable = this.displayedTable(); + switch (displayedTable) { + case 'collaborators': + return 'Suche Kollaborierende nach Name oder ID'; + case 'publications': + return 'Suche Publikationen nach Titel oder ID'; + case 'institutions': + return 'Suche Institutionen nach Name oder ID'; + default: + return 'Suchbegriff'; + } + }); + private readonly categoryTableMap: Record = { author: 'collaborators', collaborator: 'collaborators', work: 'publications', + institution: 'institutions', }; latestNodeId = signal(null); handleNodeClick = ({ id, name, category }: NodeClickEvent): void => { if (this.latestNodeId() === id) { - this.latestNodeId.set(null); - this.filterForm.patchValue({ searchTerm: '' }); + this.clearSearch(); return; } @@ -111,6 +127,11 @@ export class PersonNetworkComponent implements OnInit { }); }; + clearSearch() { + this.latestNodeId.set(null); + this.filterForm.patchValue({ searchTerm: '' }); + } + readonly summaryCards = computed(() => [ { icon: 'person', @@ -175,7 +196,6 @@ export class PersonNetworkComponent implements OnInit { }); dialogRef.afterClosed().subscribe((result) => { - console.log('Dialog result:', result); if (result) { this.filterForm.setValue({ searchTerm: this.filterForm.get('searchTerm')?.value || '',