This commit is contained in:
@@ -0,0 +1,298 @@
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
import httpx
|
||||
from fastapi import HTTPException
|
||||
from starlette.status import HTTP_502_BAD_GATEWAY, HTTP_503_SERVICE_UNAVAILABLE
|
||||
|
||||
from . import model
|
||||
from .search_client import CompanyConnectionsSearchClient, MissingApiKeyError
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
UDE_OPENALEX_ID = "https://openalex.org/I62318514"
|
||||
UDE_ROR = "https://ror.org/04mz5ra38"
|
||||
UDE_DISPLAY_NAME = "University of Duisburg-Essen"
|
||||
|
||||
MATCHING_METHOD = "exact_openalex_display_name_to_handelsregister_officer_name"
|
||||
|
||||
|
||||
async def get_company_connections_by_author_id(
|
||||
author_id: str,
|
||||
client: CompanyConnectionsSearchClient | None = None,
|
||||
) -> model.CompanyConnectionsResponse:
|
||||
search_client = client or CompanyConnectionsSearchClient()
|
||||
|
||||
try:
|
||||
author_hit = await search_client.get_openalex_author(author_id)
|
||||
except MissingApiKeyError as exc:
|
||||
raise HTTPException(
|
||||
status_code=HTTP_503_SERVICE_UNAVAILABLE,
|
||||
detail="Elasticsearch is not configured.",
|
||||
) from exc
|
||||
except httpx.HTTPError as exc:
|
||||
logger.exception("OpenAlex author lookup failed for %s.", author_id)
|
||||
raise HTTPException(
|
||||
status_code=HTTP_502_BAD_GATEWAY,
|
||||
detail="OpenAlex author lookup failed.",
|
||||
) from exc
|
||||
|
||||
if author_hit is None:
|
||||
raise HTTPException(status_code=404, detail=f"Author {author_id} not found.")
|
||||
|
||||
source = author_hit.get("_source", {})
|
||||
display_name = _clean(source.get("display_name"))
|
||||
institution_scope, matching_institutions = _get_ude_institution_scope(source)
|
||||
is_ude_author = institution_scope is not None
|
||||
|
||||
if not is_ude_author or not display_name:
|
||||
return model.CompanyConnectionsResponse(
|
||||
author_id=author_id,
|
||||
display_name=display_name or None,
|
||||
is_ude_author=is_ude_author,
|
||||
institution_scope=institution_scope,
|
||||
matching_institutions=matching_institutions,
|
||||
matching_method=None,
|
||||
company_count=0,
|
||||
has_more_results=False,
|
||||
common_name_warning=False,
|
||||
connections=[],
|
||||
)
|
||||
|
||||
try:
|
||||
hr_response = await search_client.search_handelsregister_by_officer_name(
|
||||
display_name
|
||||
)
|
||||
except MissingApiKeyError as exc:
|
||||
raise HTTPException(
|
||||
status_code=HTTP_503_SERVICE_UNAVAILABLE,
|
||||
detail="Elasticsearch is not configured.",
|
||||
) from exc
|
||||
except httpx.HTTPError as exc:
|
||||
logger.exception("Handelsregister lookup failed for %s.", display_name)
|
||||
raise HTTPException(
|
||||
status_code=HTTP_502_BAD_GATEWAY,
|
||||
detail="Handelsregister lookup failed.",
|
||||
) from exc
|
||||
|
||||
company_count, company_count_relation = _parse_total(hr_response)
|
||||
connections = _parse_company_connections(
|
||||
response=hr_response,
|
||||
matched_person_name=display_name,
|
||||
)
|
||||
|
||||
has_more_results = company_count_relation == "gte" or company_count > len(
|
||||
connections
|
||||
)
|
||||
common_name_warning = has_more_results or company_count > 3
|
||||
|
||||
return model.CompanyConnectionsResponse(
|
||||
author_id=author_id,
|
||||
display_name=display_name,
|
||||
is_ude_author=True,
|
||||
institution_scope=institution_scope,
|
||||
matching_institutions=matching_institutions,
|
||||
matching_method=MATCHING_METHOD,
|
||||
company_count=company_count,
|
||||
has_more_results=has_more_results,
|
||||
common_name_warning=common_name_warning,
|
||||
connections=connections,
|
||||
)
|
||||
|
||||
|
||||
def _get_ude_institution_scope(source: dict[str, Any]) -> tuple[str | None, list[str]]:
|
||||
institutions = source.get("last_known_institutions") or []
|
||||
|
||||
direct_matches: list[str] = []
|
||||
child_matches: list[str] = []
|
||||
|
||||
for institution in institutions:
|
||||
if not isinstance(institution, dict):
|
||||
continue
|
||||
|
||||
institution_id = _clean(institution.get("id"))
|
||||
ror = _clean(institution.get("ror"))
|
||||
name = _clean(institution.get("display_name"))
|
||||
lineage = institution.get("lineage") or []
|
||||
|
||||
label = name or institution_id or ror
|
||||
|
||||
is_direct = (
|
||||
institution_id == UDE_OPENALEX_ID
|
||||
or ror == UDE_ROR
|
||||
or name == UDE_DISPLAY_NAME
|
||||
)
|
||||
is_child = UDE_OPENALEX_ID in lineage and not is_direct
|
||||
|
||||
if is_direct:
|
||||
direct_matches.append(label)
|
||||
elif is_child:
|
||||
child_matches.append(label)
|
||||
|
||||
if direct_matches:
|
||||
return "direct_ude", sorted(set(direct_matches))
|
||||
|
||||
if child_matches:
|
||||
return "child_of_ude", sorted(set(child_matches))
|
||||
|
||||
return None, []
|
||||
|
||||
|
||||
def _parse_total(response: dict[str, Any]) -> tuple[int, str]:
|
||||
total = response.get("hits", {}).get("total", 0)
|
||||
|
||||
if isinstance(total, dict):
|
||||
return int(total.get("value") or 0), total.get("relation") or "eq"
|
||||
|
||||
return int(total or 0), "eq"
|
||||
|
||||
|
||||
def _parse_company_connections(
|
||||
response: dict[str, Any],
|
||||
matched_person_name: str,
|
||||
) -> list[model.CompanyConnection]:
|
||||
connections: list[model.CompanyConnection] = []
|
||||
|
||||
hits = response.get("hits", {}).get("hits", [])
|
||||
|
||||
for hit in hits:
|
||||
source = hit.get("_source", {})
|
||||
|
||||
matched_officers = _parse_inner_hit_officers(hit)
|
||||
officers = _parse_source_officers(
|
||||
source=source,
|
||||
matched_person_name=matched_person_name,
|
||||
)
|
||||
|
||||
connections.append(
|
||||
model.CompanyConnection(
|
||||
company_number=source.get("company_number"),
|
||||
company_name=source.get("name"),
|
||||
company_status=source.get("current_status"),
|
||||
register_art=source.get("register_art"),
|
||||
register_nummer=source.get("register_nummer"),
|
||||
native_company_number=source.get("native_company_number"),
|
||||
registrar=source.get("registrar"),
|
||||
registered_office=source.get("registered_office"),
|
||||
registered_address=source.get("registered_address"),
|
||||
retrieved_at=source.get("retrieved_at"),
|
||||
matched_officers=matched_officers,
|
||||
officers=officers,
|
||||
)
|
||||
)
|
||||
|
||||
return connections
|
||||
|
||||
|
||||
def _parse_inner_hit_officers(hit: dict[str, Any]) -> list[model.MatchedOfficer]:
|
||||
inner_hits = (
|
||||
hit.get("inner_hits", {}).get("officers", {}).get("hits", {}).get("hits", [])
|
||||
)
|
||||
|
||||
officers: list[model.MatchedOfficer] = []
|
||||
|
||||
for inner_hit in inner_hits:
|
||||
source = inner_hit.get("_source", {})
|
||||
officer_source = _normalize_officer_source(source)
|
||||
|
||||
officers.append(
|
||||
_to_officer(
|
||||
officer_source,
|
||||
is_matched_person=True,
|
||||
)
|
||||
)
|
||||
|
||||
return _deduplicate_officers(officers)
|
||||
|
||||
|
||||
def _parse_source_officers(
|
||||
source: dict[str, Any],
|
||||
matched_person_name: str,
|
||||
) -> list[model.MatchedOfficer]:
|
||||
raw_officers = source.get("officers") or []
|
||||
|
||||
if not isinstance(raw_officers, list):
|
||||
return []
|
||||
|
||||
officers: list[model.MatchedOfficer] = []
|
||||
|
||||
for raw_officer in raw_officers:
|
||||
if not isinstance(raw_officer, dict):
|
||||
continue
|
||||
|
||||
if _clean(raw_officer.get("type")) != "person":
|
||||
continue
|
||||
|
||||
officer_name = _clean(raw_officer.get("name"))
|
||||
is_matched_person = officer_name == matched_person_name
|
||||
|
||||
officers.append(
|
||||
_to_officer(
|
||||
raw_officer,
|
||||
is_matched_person=is_matched_person,
|
||||
)
|
||||
)
|
||||
|
||||
return _deduplicate_officers(officers)
|
||||
|
||||
|
||||
def _to_officer(
|
||||
source: dict[str, Any],
|
||||
is_matched_person: bool,
|
||||
) -> model.MatchedOfficer:
|
||||
return model.MatchedOfficer(
|
||||
name=_clean_or_none(source.get("name")),
|
||||
firstname=_clean_or_none(source.get("firstname")),
|
||||
lastname=_clean_or_none(source.get("lastname")),
|
||||
city=_clean_or_none(source.get("city")),
|
||||
position=_clean_or_none(source.get("position")),
|
||||
start_date=_clean_or_none(source.get("start_date")),
|
||||
type=_clean_or_none(source.get("type")),
|
||||
flag=_clean_or_none(source.get("flag")),
|
||||
is_matched_person=is_matched_person,
|
||||
)
|
||||
|
||||
|
||||
def _deduplicate_officers(
|
||||
officers: list[model.MatchedOfficer],
|
||||
) -> list[model.MatchedOfficer]:
|
||||
seen: set[tuple[str, str, str, str]] = set()
|
||||
deduplicated: list[model.MatchedOfficer] = []
|
||||
|
||||
for officer in officers:
|
||||
key = (
|
||||
officer.name or "",
|
||||
officer.position or "",
|
||||
officer.city or "",
|
||||
officer.start_date or "",
|
||||
)
|
||||
|
||||
if key in seen:
|
||||
continue
|
||||
|
||||
seen.add(key)
|
||||
deduplicated.append(officer)
|
||||
|
||||
return deduplicated
|
||||
|
||||
|
||||
def _normalize_officer_source(source: dict[str, Any]) -> dict[str, Any]:
|
||||
officers = source.get("officers")
|
||||
|
||||
if isinstance(officers, dict):
|
||||
return officers
|
||||
|
||||
return source
|
||||
|
||||
|
||||
def _clean_or_none(value: Any) -> str | None:
|
||||
cleaned = _clean(value)
|
||||
|
||||
return cleaned or None
|
||||
|
||||
|
||||
def _clean(value: Any) -> str:
|
||||
if value is None:
|
||||
return ""
|
||||
|
||||
return str(value).strip()
|
||||
@@ -0,0 +1,44 @@
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class MatchedOfficer(BaseModel):
|
||||
name: str | None = None
|
||||
firstname: str | None = None
|
||||
lastname: str | None = None
|
||||
city: str | None = None
|
||||
position: str | None = None
|
||||
start_date: str | None = None
|
||||
type: str | None = None
|
||||
flag: str | None = None
|
||||
is_matched_person: bool = False
|
||||
|
||||
|
||||
class CompanyConnection(BaseModel):
|
||||
company_number: str | None = None
|
||||
company_name: str | None = None
|
||||
company_status: str | None = None
|
||||
register_art: str | None = None
|
||||
register_nummer: str | None = None
|
||||
native_company_number: str | None = None
|
||||
registrar: str | None = None
|
||||
registered_office: str | None = None
|
||||
registered_address: str | None = None
|
||||
retrieved_at: str | None = None
|
||||
matched_officers: list[MatchedOfficer] = Field(default_factory=list)
|
||||
officers: list[MatchedOfficer] = Field(default_factory=list)
|
||||
|
||||
|
||||
class CompanyConnectionsResponse(BaseModel):
|
||||
author_id: str
|
||||
display_name: str | None = None
|
||||
is_ude_author: bool
|
||||
institution_scope: str | None = None
|
||||
matching_institutions: list[str] = Field(default_factory=list)
|
||||
|
||||
matching_method: str | None = None
|
||||
|
||||
company_count: int
|
||||
has_more_results: bool
|
||||
common_name_warning: bool
|
||||
|
||||
connections: list[CompanyConnection] = Field(default_factory=list)
|
||||
@@ -0,0 +1,141 @@
|
||||
from typing import Any
|
||||
|
||||
import httpx
|
||||
|
||||
from .. import config
|
||||
|
||||
|
||||
class MissingApiKeyError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class CompanyConnectionsSearchClient:
|
||||
def __init__(
|
||||
self,
|
||||
base_url: str | None = None,
|
||||
api_key: str | None = None,
|
||||
openalex_index: str = "openalex-authors",
|
||||
handelsregister_index: str = "handelsregister",
|
||||
timeout: float = 30.0,
|
||||
transport: httpx.AsyncBaseTransport | None = None,
|
||||
):
|
||||
self.base_url = (
|
||||
base_url
|
||||
or config.settings.elasticsearch_url
|
||||
or config.settings.openalex_works_search_base_url
|
||||
).rstrip("/")
|
||||
self.api_key = (
|
||||
api_key
|
||||
if api_key is not None
|
||||
else config.settings.elasticsearch_api_key
|
||||
or config.settings.openalex_works_api_key
|
||||
)
|
||||
self.openalex_index = openalex_index
|
||||
self.handelsregister_index = handelsregister_index
|
||||
self.timeout = timeout
|
||||
self.transport = transport
|
||||
|
||||
@staticmethod
|
||||
def openalex_doc_id(author_id: str) -> str:
|
||||
return author_id.strip().removeprefix("https://openalex.org/")
|
||||
|
||||
async def get_openalex_author(self, author_id: str) -> dict[str, Any] | None:
|
||||
if not self.api_key:
|
||||
raise MissingApiKeyError("Elasticsearch API key is not configured.")
|
||||
|
||||
doc_id = self.openalex_doc_id(author_id)
|
||||
|
||||
async with httpx.AsyncClient(
|
||||
base_url=self.base_url,
|
||||
timeout=self.timeout,
|
||||
transport=self.transport,
|
||||
) as client:
|
||||
response = await client.get(
|
||||
f"/{self.openalex_index}/_doc/{doc_id}",
|
||||
headers={"Authorization": f"ApiKey {self.api_key}"},
|
||||
)
|
||||
|
||||
if response.status_code == 404:
|
||||
return None
|
||||
|
||||
response.raise_for_status()
|
||||
return response.json()
|
||||
|
||||
async def search_handelsregister_by_officer_name(
|
||||
self,
|
||||
officer_name: str,
|
||||
size: int = 10000,
|
||||
track_total_hits: bool = True,
|
||||
) -> dict[str, Any]:
|
||||
if not self.api_key:
|
||||
raise MissingApiKeyError("Elasticsearch API key is not configured.")
|
||||
|
||||
payload = self.handelsregister_officer_name_query(
|
||||
officer_name=officer_name,
|
||||
size=size,
|
||||
track_total_hits=track_total_hits,
|
||||
)
|
||||
|
||||
async with httpx.AsyncClient(
|
||||
base_url=self.base_url,
|
||||
timeout=self.timeout,
|
||||
transport=self.transport,
|
||||
) as client:
|
||||
response = await client.post(
|
||||
f"/{self.handelsregister_index}/_search",
|
||||
headers={"Authorization": f"ApiKey {self.api_key}"},
|
||||
json=payload,
|
||||
)
|
||||
response.raise_for_status()
|
||||
return response.json()
|
||||
|
||||
@staticmethod
|
||||
def handelsregister_officer_name_query(
|
||||
officer_name: str,
|
||||
size: int,
|
||||
track_total_hits: bool,
|
||||
) -> dict[str, Any]:
|
||||
return {
|
||||
"track_total_hits": track_total_hits,
|
||||
"size": size,
|
||||
"_source": [
|
||||
"company_number",
|
||||
"name",
|
||||
"current_status",
|
||||
"registered_address",
|
||||
"registered_office",
|
||||
"registrar",
|
||||
"register_art",
|
||||
"register_nummer",
|
||||
"native_company_number",
|
||||
"retrieved_at",
|
||||
"officers",
|
||||
],
|
||||
"query": {
|
||||
"nested": {
|
||||
"path": "officers",
|
||||
"query": {
|
||||
"bool": {
|
||||
"filter": [
|
||||
{"term": {"officers.type": "person"}},
|
||||
{"term": {"officers.name.keyword": officer_name}},
|
||||
]
|
||||
}
|
||||
},
|
||||
"inner_hits": {
|
||||
"size": 10,
|
||||
"_source": [
|
||||
"officers.name",
|
||||
"officers.firstname",
|
||||
"officers.lastname",
|
||||
"officers.city",
|
||||
"officers.position",
|
||||
"officers.start_date",
|
||||
"officers.type",
|
||||
"officers.flag",
|
||||
],
|
||||
},
|
||||
}
|
||||
},
|
||||
"sort": [{"company_number": {"order": "asc"}}],
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
REST API for possible company connections of OpenAlex authors.
|
||||
"""
|
||||
|
||||
from fastapi import APIRouter
|
||||
|
||||
from . import logic, model
|
||||
|
||||
router = APIRouter(
|
||||
prefix="/api/inse-service/authors",
|
||||
tags=["Company Connections"],
|
||||
)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/{author_id}/company-connections",
|
||||
operation_id="getCompanyConnectionsByAuthor",
|
||||
response_model=model.CompanyConnectionsResponse,
|
||||
response_model_exclude_none=True,
|
||||
summary="Get possible company connections by OpenAlex author ID.",
|
||||
)
|
||||
async def get_company_connections_by_author(author_id: str):
|
||||
return await logic.get_company_connections_by_author_id(author_id)
|
||||
@@ -16,6 +16,7 @@ from inse.topics.service import router as topics_service_router
|
||||
from inse.works.service import router as works_service_router
|
||||
from inse.persons.service import router as persons_service_router
|
||||
from inse.funders.service import router as funders_service_router
|
||||
from inse.company_connections.service import router as company_connections_router
|
||||
|
||||
from . import config
|
||||
from .service import router as service_router
|
||||
@@ -40,6 +41,7 @@ app.include_router(topics_service_router)
|
||||
app.include_router(works_service_router)
|
||||
app.include_router(persons_service_router)
|
||||
app.include_router(funders_service_router)
|
||||
app.include_router(company_connections_router)
|
||||
app.include_router(service_router)
|
||||
app.include_router(account_router)
|
||||
|
||||
|
||||
@@ -25,6 +25,9 @@ export * from './topics.serviceInterface';
|
||||
export * from './works.service';
|
||||
import { WorksService } from './works.service';
|
||||
export * from './works.serviceInterface';
|
||||
export * from './company-connections.service';
|
||||
import { CompanyConnectionsService } from './company-connections.service';
|
||||
export * from './company-connections.serviceInterface';
|
||||
export const APIS = [
|
||||
FundingService,
|
||||
INSEAccountServiceService,
|
||||
@@ -35,4 +38,5 @@ export const APIS = [
|
||||
PersonsService,
|
||||
TopicsService,
|
||||
WorksService,
|
||||
CompanyConnectionsService,
|
||||
];
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
/* tslint:disable:no-unused-variable member-ordering */
|
||||
|
||||
import { Inject, Injectable, Optional } from '@angular/core';
|
||||
import {
|
||||
HttpClient,
|
||||
HttpHeaders,
|
||||
HttpParams,
|
||||
HttpResponse,
|
||||
HttpEvent,
|
||||
HttpParameterCodec,
|
||||
HttpContext,
|
||||
} from '@angular/common/http';
|
||||
import { CustomHttpParameterCodec } from '../encoder';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
// @ts-ignore
|
||||
import { CompanyConnectionsResponse } from '../model/company-connections-response';
|
||||
// @ts-ignore
|
||||
import { HTTPValidationError } from '../model/http-validation-error';
|
||||
|
||||
// @ts-ignore
|
||||
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
|
||||
import { Configuration } from '../configuration';
|
||||
import { BaseService } from '../api.base.service';
|
||||
import { CompanyConnectionsServiceInterface } from './company-connections.serviceInterface';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class CompanyConnectionsService
|
||||
extends BaseService
|
||||
implements CompanyConnectionsServiceInterface
|
||||
{
|
||||
constructor(
|
||||
protected httpClient: HttpClient,
|
||||
@Optional() @Inject(BASE_PATH) basePath: string | string[],
|
||||
@Optional() configuration?: Configuration,
|
||||
) {
|
||||
super(basePath, configuration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get possible company connections by OpenAlex author ID.
|
||||
* @endpoint get /api/inse-service/authors/{author_id}/company-connections
|
||||
* @param authorId
|
||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
public getCompanyConnectionsByAuthor(
|
||||
authorId: string,
|
||||
observe?: 'body',
|
||||
reportProgress?: boolean,
|
||||
options?: {
|
||||
httpHeaderAccept?: 'application/json';
|
||||
context?: HttpContext;
|
||||
transferCache?: boolean;
|
||||
},
|
||||
): Observable<CompanyConnectionsResponse>;
|
||||
public getCompanyConnectionsByAuthor(
|
||||
authorId: string,
|
||||
observe?: 'response',
|
||||
reportProgress?: boolean,
|
||||
options?: {
|
||||
httpHeaderAccept?: 'application/json';
|
||||
context?: HttpContext;
|
||||
transferCache?: boolean;
|
||||
},
|
||||
): Observable<HttpResponse<CompanyConnectionsResponse>>;
|
||||
public getCompanyConnectionsByAuthor(
|
||||
authorId: string,
|
||||
observe?: 'events',
|
||||
reportProgress?: boolean,
|
||||
options?: {
|
||||
httpHeaderAccept?: 'application/json';
|
||||
context?: HttpContext;
|
||||
transferCache?: boolean;
|
||||
},
|
||||
): Observable<HttpEvent<CompanyConnectionsResponse>>;
|
||||
public getCompanyConnectionsByAuthor(
|
||||
authorId: string,
|
||||
observe: any = 'body',
|
||||
reportProgress: boolean = false,
|
||||
options?: {
|
||||
httpHeaderAccept?: 'application/json';
|
||||
context?: HttpContext;
|
||||
transferCache?: boolean;
|
||||
},
|
||||
): Observable<any> {
|
||||
if (authorId === null || authorId === undefined) {
|
||||
throw new Error(
|
||||
'Required parameter authorId was null or undefined when calling getCompanyConnectionsByAuthor.',
|
||||
);
|
||||
}
|
||||
|
||||
let localVarHeaders = this.defaultHeaders;
|
||||
|
||||
const localVarHttpHeaderAcceptSelected: string | undefined =
|
||||
options?.httpHeaderAccept ??
|
||||
this.configuration.selectHeaderAccept(['application/json']);
|
||||
if (localVarHttpHeaderAcceptSelected !== undefined) {
|
||||
localVarHeaders = localVarHeaders.set(
|
||||
'Accept',
|
||||
localVarHttpHeaderAcceptSelected,
|
||||
);
|
||||
}
|
||||
|
||||
const localVarHttpContext: HttpContext =
|
||||
options?.context ?? new HttpContext();
|
||||
|
||||
const localVarTransferCache: boolean = options?.transferCache ?? true;
|
||||
|
||||
let responseType_: 'text' | 'json' | 'blob' = 'json';
|
||||
if (localVarHttpHeaderAcceptSelected) {
|
||||
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
|
||||
responseType_ = 'text';
|
||||
} else if (
|
||||
this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)
|
||||
) {
|
||||
responseType_ = 'json';
|
||||
} else {
|
||||
responseType_ = 'blob';
|
||||
}
|
||||
}
|
||||
|
||||
let localVarPath = `/api/inse-service/authors/${this.configuration.encodeParam({ name: 'authorId', value: authorId, in: 'path', style: 'simple', explode: false, dataType: 'string', dataFormat: undefined })}/company-connections`;
|
||||
const { basePath, withCredentials } = this.configuration;
|
||||
return this.httpClient.request<CompanyConnectionsResponse>(
|
||||
'get',
|
||||
`${basePath}${localVarPath}`,
|
||||
{
|
||||
context: localVarHttpContext,
|
||||
responseType: <any>responseType_,
|
||||
...(withCredentials ? { withCredentials } : {}),
|
||||
headers: localVarHeaders,
|
||||
observe: observe,
|
||||
...(localVarTransferCache !== undefined
|
||||
? { transferCache: localVarTransferCache }
|
||||
: {}),
|
||||
reportProgress: reportProgress,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
import { HttpHeaders } from '@angular/common/http';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { CompanyConnectionsResponse } from '../model/models';
|
||||
import { HTTPValidationError } from '../model/models';
|
||||
|
||||
import { Configuration } from '../configuration';
|
||||
|
||||
export interface CompanyConnectionsServiceInterface {
|
||||
defaultHeaders: HttpHeaders;
|
||||
configuration: Configuration;
|
||||
|
||||
/**
|
||||
* Get possible company connections by OpenAlex author ID.
|
||||
*
|
||||
* @endpoint get /api/inse-service/authors/{author_id}/company-connections
|
||||
* @param authorId
|
||||
*/
|
||||
getCompanyConnectionsByAuthor(
|
||||
authorId: string,
|
||||
extraHttpRequestParams?: any,
|
||||
): Observable<CompanyConnectionsResponse>;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
import { MatchedOfficer } from './matched-officer';
|
||||
|
||||
export interface CompanyConnection {
|
||||
company_number?: string | null;
|
||||
company_name?: string | null;
|
||||
company_status?: string | null;
|
||||
register_art?: string | null;
|
||||
register_nummer?: string | null;
|
||||
native_company_number?: string | null;
|
||||
registrar?: string | null;
|
||||
registered_office?: string | null;
|
||||
registered_address?: string | null;
|
||||
retrieved_at?: string | null;
|
||||
matched_officers?: Array<MatchedOfficer>;
|
||||
officers?: Array<MatchedOfficer>;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
import { CompanyConnection } from './company-connection';
|
||||
|
||||
export interface CompanyConnectionsResponse {
|
||||
author_id: string;
|
||||
display_name?: string | null;
|
||||
is_ude_author: boolean;
|
||||
institution_scope?: string | null;
|
||||
matching_institutions?: Array<string | null>;
|
||||
matching_method?: string | null;
|
||||
company_count: number;
|
||||
has_more_results: boolean;
|
||||
common_name_warning: boolean;
|
||||
connections?: Array<CompanyConnection>;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
export interface MatchedOfficer {
|
||||
name?: string | null;
|
||||
firstname?: string | null;
|
||||
lastname?: string | null;
|
||||
city?: string | null;
|
||||
position?: string | null;
|
||||
start_date?: string | null;
|
||||
type?: string | null;
|
||||
flag?: string | null;
|
||||
is_matched_person?: boolean;
|
||||
}
|
||||
@@ -84,3 +84,6 @@ export * from './work-topic-information';
|
||||
export * from './work-topic-subfield';
|
||||
export * from './works-filter-properties';
|
||||
export * from './works-list-response';
|
||||
export * from './company-connection';
|
||||
export * from './company-connections-response';
|
||||
export * from './matched-officer';
|
||||
|
||||
@@ -135,6 +135,13 @@ export const routes: Routes = [
|
||||
(mod) => mod.PersonFundingComponent,
|
||||
),
|
||||
},
|
||||
{
|
||||
path: 'company-connections',
|
||||
loadComponent: () =>
|
||||
import('./modules/person-company-connections/person-company-connections.component').then(
|
||||
(mod) => mod.PersonCompanyConnectionsComponent,
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
+260
@@ -0,0 +1,260 @@
|
||||
@if (loading) {
|
||||
<div class="state state-loading" aria-live="polite">
|
||||
<mat-spinner diameter="36"></mat-spinner>
|
||||
<span>Verbindungen zu Unternehmen werden geladen ...</span>
|
||||
</div>
|
||||
} @else if (error) {
|
||||
<div class="state state-error">
|
||||
Verbindungen zu Unternehmen konnten nicht geladen werden.
|
||||
</div>
|
||||
} @else if (data && !data.is_ude_author) {
|
||||
<section class="empty-state">
|
||||
<h2>Keine Unternehmenssuche verfügbar</h2>
|
||||
<p>Für diese Person wird aktuell keine Suche nach Unternehmen angezeigt.</p>
|
||||
</section>
|
||||
} @else if (data && connections.length === 0) {
|
||||
<section class="empty-state">
|
||||
<h2>Keine Treffer im Handelsregister</h2>
|
||||
<p>
|
||||
Für diese Person wurden keine passenden Treffer im Handelsregister
|
||||
gefunden.
|
||||
</p>
|
||||
</section>
|
||||
} @else if (data) {
|
||||
<section class="company-connections">
|
||||
<header class="page-header">
|
||||
<h2>Mögliche Verbindungen zu Unternehmen</h2>
|
||||
<p>
|
||||
{{ getResultCountLabel() }} für
|
||||
<strong>{{ data.display_name }}</strong>
|
||||
</p>
|
||||
</header>
|
||||
|
||||
@if (data.common_name_warning) {
|
||||
<div class="warning-box">
|
||||
Für diesen Namen gibt es mehrere Treffer im Handelsregister. Die
|
||||
Ergebnisse sollten besonders vorsichtig interpretiert werden.
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="main-layout">
|
||||
<section class="graph-column">
|
||||
@if (graphOptions) {
|
||||
<section class="graph-card">
|
||||
<div class="graph-toolbar">
|
||||
<button
|
||||
type="button"
|
||||
class="related-toggle"
|
||||
[class.active]="showRelatedPersons"
|
||||
[attr.aria-pressed]="showRelatedPersons"
|
||||
(click)="toggleRelatedPersons()">
|
||||
<span class="toggle-switch">
|
||||
<span class="toggle-knob"></span>
|
||||
</span>
|
||||
<span class="toggle-text">
|
||||
Weitere Registerpersonen anzeigen
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="graph-stage">
|
||||
<div
|
||||
class="graph"
|
||||
echarts
|
||||
[options]="graphOptions"
|
||||
[autoResize]="true"
|
||||
(wheel)="onGraphWheel($event)"
|
||||
(chartClick)="onGraphClick($event)"></div>
|
||||
</div>
|
||||
|
||||
@if (roleLegendItems.length > 0) {
|
||||
<div class="role-legend" aria-label="Legende der Rollen">
|
||||
@for (item of roleLegendItems; track item.role) {
|
||||
<span class="role-legend-item">
|
||||
<span
|
||||
class="role-legend-line"
|
||||
[style.background]="item.color"></span>
|
||||
<span class="role-legend-text">{{ item.role }}</span>
|
||||
</span>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (connections.length > 10) {
|
||||
<p class="graph-note">
|
||||
Der Graph zeigt die ersten 10 Unternehmen. Die vollständige
|
||||
Liste ist rechts sichtbar.
|
||||
</p>
|
||||
}
|
||||
</section>
|
||||
}
|
||||
|
||||
<p class="disclaimer">
|
||||
{{ disclaimer }}
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section class="list-column">
|
||||
<div class="connection-list">
|
||||
<div class="list-header">
|
||||
<span>Unternehmen</span>
|
||||
<span>Rolle</span>
|
||||
</div>
|
||||
|
||||
<div class="list-scroll">
|
||||
@for (connection of connections; track getCompanyKey(connection)) {
|
||||
@let officer = getPrimaryOfficer(connection);
|
||||
@let companyKey = getCompanyKey(connection);
|
||||
@let relatedOfficers = getRelatedOfficers(connection);
|
||||
|
||||
<div class="connection-item">
|
||||
<div
|
||||
class="connection-row"
|
||||
[attr.data-company-key]="companyKey"
|
||||
[class.selected]="companyKey === selectedCompanyKey"
|
||||
[class.removed]="connection.company_status === 'removed'"
|
||||
(click)="selectCompany(connection)">
|
||||
<span
|
||||
class="company-name"
|
||||
[title]="connection.company_name || ''">
|
||||
{{ connection.company_name || 'Unbekanntes Unternehmen' }}
|
||||
</span>
|
||||
|
||||
<span
|
||||
class="role-value"
|
||||
[style.border-color]="getRoleColor(officer?.position)"
|
||||
[title]="officer?.position || ''">
|
||||
{{ officer?.position || '—' }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@if (companyKey === selectedCompanyKey) {
|
||||
<div
|
||||
class="connection-detail"
|
||||
(click)="$event.stopPropagation()">
|
||||
<div class="detail-grid">
|
||||
<div class="detail-field">
|
||||
<span class="detail-label">Register</span>
|
||||
<span class="detail-value">
|
||||
{{ getCompanyRegisterLabel(connection) }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="detail-field">
|
||||
<span class="detail-label">Amtsgericht</span>
|
||||
<span class="detail-value">
|
||||
{{ getRegistrarLabel(connection) }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="detail-field detail-field--address">
|
||||
<span class="detail-label">Adresse</span>
|
||||
<span class="detail-value">
|
||||
{{ getCompanyAddressLabel(connection) }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="detail-field">
|
||||
<span class="detail-label">Unternehmensstatus</span>
|
||||
<span
|
||||
class="detail-value detail-status"
|
||||
[class.detail-status--active]="
|
||||
connection.company_status === 'currently registered'
|
||||
"
|
||||
[class.detail-status--removed]="
|
||||
connection.company_status === 'removed'
|
||||
">
|
||||
{{ getCompanyStatusLabel(connection.company_status) }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="detail-field detail-field--wide">
|
||||
<span class="detail-label">Gegenstand</span>
|
||||
<span class="detail-value">
|
||||
{{ getGegenstandLabel() }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (relatedOfficers.length > 0) {
|
||||
<button
|
||||
type="button"
|
||||
class="officers-toggle"
|
||||
(click)="toggleCompanyOfficers(connection, $event)">
|
||||
<span>
|
||||
Weitere Registerpersonen ({{
|
||||
relatedOfficers.length
|
||||
}})
|
||||
</span>
|
||||
<span>
|
||||
{{
|
||||
isCompanyOfficersExpanded(connection) ? '▲' : '▼'
|
||||
}}
|
||||
</span>
|
||||
</button>
|
||||
|
||||
@if (isCompanyOfficersExpanded(connection)) {
|
||||
<ul class="related-officers">
|
||||
@for (
|
||||
relatedOfficer of relatedOfficers;
|
||||
track relatedOfficer.name
|
||||
) {
|
||||
<li class="related-officer">
|
||||
<span
|
||||
class="officer-name"
|
||||
[title]="relatedOfficer.name || ''">
|
||||
{{ relatedOfficer.name }}
|
||||
</span>
|
||||
|
||||
<span
|
||||
class="officer-role"
|
||||
[style.border-color]="
|
||||
getRoleColor(relatedOfficer.position)
|
||||
"
|
||||
[title]="relatedOfficer.position || ''">
|
||||
{{ relatedOfficer.position || '—' }}
|
||||
</span>
|
||||
|
||||
@if (relatedOfficer.name) {
|
||||
<a
|
||||
mat-icon-button
|
||||
color="primary"
|
||||
class="officer-open-link"
|
||||
[routerLink]="['/persons']"
|
||||
[queryParams]="
|
||||
getPersonSearchQueryParams(
|
||||
relatedOfficer.name
|
||||
)
|
||||
"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
[attr.aria-label]="
|
||||
'Suche nach ' +
|
||||
relatedOfficer.name +
|
||||
' öffnen'
|
||||
"
|
||||
[title]="
|
||||
'Suche nach ' +
|
||||
relatedOfficer.name +
|
||||
' öffnen'
|
||||
">
|
||||
<mat-icon>open_in_new</mat-icon>
|
||||
</a>
|
||||
} @else {
|
||||
<span class="officer-open-placeholder"></span>
|
||||
}
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</section>
|
||||
}
|
||||
+572
@@ -0,0 +1,572 @@
|
||||
$author-color: #5470c6;
|
||||
$timeline-purple: #7255d9;
|
||||
$timeline-purple-bg: #f6f0ff;
|
||||
|
||||
$timeline-green-bg: #effaf3;
|
||||
$timeline-green-border: #bdebcf;
|
||||
|
||||
$timeline-orange-bg: #fff7e8;
|
||||
$timeline-orange-border: #ffd796;
|
||||
$timeline-orange-text: #c67500;
|
||||
|
||||
$card-border: #dbe5f6;
|
||||
$text-main: #07163d;
|
||||
$text-muted: #64718f;
|
||||
|
||||
:host {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.company-connections {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
padding: 20px 28px 32px;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
h2 {
|
||||
margin: 0 0 6px;
|
||||
color: $text-main;
|
||||
font-size: 20px;
|
||||
font-weight: 700;
|
||||
line-height: 1.25;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
color: $text-muted;
|
||||
font-size: 14px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
}
|
||||
|
||||
.state {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 14px;
|
||||
min-height: 220px;
|
||||
color: $text-muted;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.state-error {
|
||||
color: #b42318;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
margin: 14px 28px;
|
||||
padding: 18px 22px;
|
||||
border: 1px solid $card-border;
|
||||
border-radius: 16px;
|
||||
background: #ffffff;
|
||||
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
|
||||
|
||||
h2 {
|
||||
margin: 0 0 6px;
|
||||
color: $text-main;
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
color: $text-muted;
|
||||
font-size: 14px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
}
|
||||
|
||||
.warning-box {
|
||||
padding: 12px 14px;
|
||||
border: 1px solid $timeline-orange-border;
|
||||
border-radius: 12px;
|
||||
background: $timeline-orange-bg;
|
||||
color: $timeline-orange-text;
|
||||
font-size: 14px;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.main-layout {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
||||
gap: 18px;
|
||||
height: 680px;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.graph-column,
|
||||
.list-column {
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.graph-card,
|
||||
.connection-list {
|
||||
border: 1px solid $card-border;
|
||||
border-radius: 16px;
|
||||
background: #ffffff;
|
||||
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.graph-card {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.graph-toolbar {
|
||||
flex: 0 0 auto;
|
||||
padding: 12px 18px 8px;
|
||||
border-bottom: 1px solid #edf2fb;
|
||||
}
|
||||
|
||||
.related-toggle {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
max-width: 100%;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: $text-main;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.toggle-switch {
|
||||
position: relative;
|
||||
flex: 0 0 auto;
|
||||
width: 44px;
|
||||
height: 24px;
|
||||
border-radius: 999px;
|
||||
background: #dbe5f6;
|
||||
transition: background 160ms ease;
|
||||
}
|
||||
|
||||
.toggle-knob {
|
||||
position: absolute;
|
||||
top: 3px;
|
||||
left: 3px;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
border-radius: 999px;
|
||||
background: #ffffff;
|
||||
box-shadow: 0 1px 4px rgba(15, 23, 42, 0.24);
|
||||
transition: transform 160ms ease;
|
||||
}
|
||||
|
||||
.related-toggle.active .toggle-switch {
|
||||
background: #e95590;
|
||||
}
|
||||
|
||||
.related-toggle.active .toggle-knob {
|
||||
transform: translateX(20px);
|
||||
}
|
||||
|
||||
.toggle-text {
|
||||
min-width: 0;
|
||||
color: $text-main;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.graph-stage {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.graph {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
overscroll-behavior: contain;
|
||||
touch-action: none;
|
||||
user-select: none;
|
||||
cursor: grab;
|
||||
}
|
||||
|
||||
.graph:active {
|
||||
cursor: grabbing;
|
||||
}
|
||||
|
||||
.role-legend {
|
||||
flex: 0 0 auto;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 10px 18px;
|
||||
padding: 10px 18px 6px;
|
||||
}
|
||||
|
||||
.role-legend-item {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
color: $text-muted;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.role-legend-line {
|
||||
flex: 0 0 auto;
|
||||
display: inline-block;
|
||||
width: 24px;
|
||||
height: 3px;
|
||||
border-radius: 999px;
|
||||
}
|
||||
|
||||
.role-legend-text {
|
||||
min-width: 0;
|
||||
max-width: 260px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.graph-note {
|
||||
flex: 0 0 auto;
|
||||
margin: 0;
|
||||
padding: 4px 18px 16px;
|
||||
color: $text-muted;
|
||||
font-size: 13px;
|
||||
line-height: 1.35;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.disclaimer {
|
||||
flex: 0 0 auto;
|
||||
margin: 14px 0 0;
|
||||
padding: 12px 14px;
|
||||
border-left: 3px solid $timeline-purple;
|
||||
border-radius: 8px;
|
||||
background: $timeline-purple-bg;
|
||||
color: $text-muted;
|
||||
font-size: 13px;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.connection-list {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.list-header,
|
||||
.connection-row {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
|
||||
gap: clamp(10px, 1vw, 18px);
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.list-header {
|
||||
flex: 0 0 auto;
|
||||
padding: 12px 16px;
|
||||
border-bottom: 1px solid $card-border;
|
||||
background: #fbfdff;
|
||||
color: $text-muted;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.02em;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.list-header span,
|
||||
.connection-row span {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.list-header span {
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.list-header span,
|
||||
.connection-row span {
|
||||
justify-self: start;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.list-scroll {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.connection-item {
|
||||
border-bottom: 1px solid #edf2fb;
|
||||
}
|
||||
|
||||
.connection-row {
|
||||
padding: 14px 16px;
|
||||
color: $text-main;
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
background: #f8fbff;
|
||||
}
|
||||
|
||||
&.selected {
|
||||
background: #f0f6ff;
|
||||
box-shadow: inset 3px 0 0 $author-color;
|
||||
}
|
||||
|
||||
&.removed {
|
||||
color: $text-muted;
|
||||
}
|
||||
}
|
||||
|
||||
.company-name,
|
||||
.role-value,
|
||||
.detail-value,
|
||||
.officer-name,
|
||||
.officer-role {
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.company-name {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.company-name {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.detail-value.detail-status {
|
||||
display: block;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
border-radius: 0;
|
||||
background: transparent;
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.detail-value.detail-status--active {
|
||||
color: #218354;
|
||||
}
|
||||
|
||||
.detail-value.detail-status--removed {
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
.role-value {
|
||||
width: auto;
|
||||
padding-left: 8px;
|
||||
border-left: 3px solid;
|
||||
color: $text-main;
|
||||
}
|
||||
|
||||
.connection-detail {
|
||||
padding: 0 16px 16px;
|
||||
background: #f8fbff;
|
||||
}
|
||||
|
||||
.detail-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 10px 18px;
|
||||
padding: 14px 0 4px;
|
||||
border-top: 1px solid #e5edf8;
|
||||
}
|
||||
|
||||
.detail-field {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.detail-field--wide {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.detail-field--address .detail-value,
|
||||
.detail-field--wide .detail-value {
|
||||
overflow: visible;
|
||||
text-overflow: unset;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.detail-label {
|
||||
display: block;
|
||||
margin-bottom: 3px;
|
||||
color: $text-muted;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.detail-value {
|
||||
color: $text-main;
|
||||
font-size: 13px;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.officers-toggle {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
margin-top: 14px;
|
||||
padding: 12px 0 0;
|
||||
border: 0;
|
||||
border-top: 1px solid #e5edf8;
|
||||
background: transparent;
|
||||
color: $text-muted;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
text-align: left;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.02em;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.related-officers {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
margin: 8px 0 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.related-officer {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) minmax(0, 0.72fr) 28px;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
padding-right: 34px;
|
||||
color: $text-main;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.officer-name {
|
||||
color: $text-main;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.officer-role {
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
min-width: 0;
|
||||
padding-left: 10px;
|
||||
border-left: 4px solid #8a95b3;
|
||||
color: $text-main;
|
||||
font-weight: 600;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.officer-open-link {
|
||||
--mdc-icon-button-state-layer-size: 28px;
|
||||
--mat-icon-button-state-layer-size: 28px;
|
||||
|
||||
justify-self: center;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
padding: 0;
|
||||
border-radius: 6px;
|
||||
color: $author-color;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.officer-open-link:hover {
|
||||
background: rgba(47, 76, 190, 0.08);
|
||||
}
|
||||
|
||||
.officer-open-link .mat-icon {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
font-size: 20px;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
.officer-open-placeholder {
|
||||
display: block;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
}
|
||||
|
||||
@media (max-width: 1450px) {
|
||||
.main-layout {
|
||||
grid-template-columns: 1fr;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.graph-card {
|
||||
height: 520px;
|
||||
}
|
||||
|
||||
.connection-list {
|
||||
height: 520px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 760px) {
|
||||
.company-connections {
|
||||
padding: 18px 16px 28px;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
margin: 14px 16px;
|
||||
}
|
||||
|
||||
.graph-card {
|
||||
height: 420px;
|
||||
}
|
||||
|
||||
.list-header {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.connection-row {
|
||||
grid-template-columns: 1fr;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.detail-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.related-officer {
|
||||
grid-template-columns: minmax(0, 1fr) 28px;
|
||||
gap: 6px 10px;
|
||||
padding-right: 0;
|
||||
}
|
||||
|
||||
.officer-role {
|
||||
grid-column: 1 / 2;
|
||||
}
|
||||
|
||||
.officer-open-link,
|
||||
.officer-open-placeholder {
|
||||
grid-column: 2 / 3;
|
||||
grid-row: 1 / 3;
|
||||
align-self: center;
|
||||
justify-self: center;
|
||||
}
|
||||
}
|
||||
+654
@@ -0,0 +1,654 @@
|
||||
import { CommonModule, LocationStrategy } from '@angular/common';
|
||||
import { Component, ElementRef, OnInit, inject } from '@angular/core';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { ActivatedRoute, Router, RouterModule } from '@angular/router';
|
||||
import { EChartsOption } from 'echarts';
|
||||
import { NgxEchartsDirective } from 'ngx-echarts';
|
||||
|
||||
import {
|
||||
CompanyConnection,
|
||||
CompanyConnectionsResponse,
|
||||
CompanyConnectionsService,
|
||||
MatchedOfficer,
|
||||
} from '../../api';
|
||||
|
||||
interface RoleLegendItem {
|
||||
role: string;
|
||||
color: string;
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-person-company-connections',
|
||||
imports: [
|
||||
CommonModule,
|
||||
MatProgressSpinnerModule,
|
||||
NgxEchartsDirective,
|
||||
MatButtonModule,
|
||||
MatIconModule,
|
||||
RouterModule,
|
||||
],
|
||||
templateUrl: './person-company-connections.component.html',
|
||||
styleUrl: './person-company-connections.component.scss',
|
||||
})
|
||||
export class PersonCompanyConnectionsComponent implements OnInit {
|
||||
private readonly route = inject(ActivatedRoute);
|
||||
private readonly router = inject(Router);
|
||||
private readonly locationStrategy = inject(LocationStrategy);
|
||||
private readonly host = inject(ElementRef<HTMLElement>);
|
||||
private readonly companyConnectionsApi = inject(CompanyConnectionsService);
|
||||
|
||||
private readonly graphCompanyLimit = 10;
|
||||
private readonly searchInstitutionName = 'University of Duisburg-Essen';
|
||||
|
||||
private readonly personCategoryIndex = 0;
|
||||
private readonly activeCompanyCategoryIndex = 1;
|
||||
private readonly removedCompanyCategoryIndex = 2;
|
||||
private readonly registerPersonCategoryIndex = 3;
|
||||
|
||||
private readonly personCategoryName = 'Person';
|
||||
private readonly activeCompanyCategoryName = 'Aktives Unternehmen';
|
||||
private readonly removedCompanyCategoryName = 'Gelöschtes Unternehmen';
|
||||
private readonly registerPersonCategoryName = 'Registerperson';
|
||||
|
||||
private readonly authorColor = '#7255d9';
|
||||
private readonly companyActiveColor = '#39a96b';
|
||||
private readonly companyRemovedColor = '#8a95b3';
|
||||
private readonly relatedPersonColor = '#4f8df5';
|
||||
private readonly fallbackRoleColor = '#8a95b3';
|
||||
|
||||
private readonly roleColors: Record<string, string> = {
|
||||
Geschäftsführer: '#2678e8',
|
||||
Prokurist: '#39a96b',
|
||||
'Persönlich haftender Gesellschafter': '#7255d9',
|
||||
Liquidator: '#f59e0b',
|
||||
Inhaber: '#e0527c',
|
||||
Vorstand: '#0f766e',
|
||||
};
|
||||
|
||||
readonly disclaimer =
|
||||
'Die angezeigten Verbindungen basieren nur auf einem Namensabgleich und können gleichnamige Personen enthalten.';
|
||||
|
||||
loading = true;
|
||||
error = false;
|
||||
data: CompanyConnectionsResponse | null = null;
|
||||
|
||||
graphOptions: EChartsOption | null = null;
|
||||
roleLegendItems: RoleLegendItem[] = [];
|
||||
|
||||
selectedCompanyKey: string | null = null;
|
||||
expandedOfficersCompanyKey: string | null = null;
|
||||
showRelatedPersons = false;
|
||||
|
||||
get connections(): CompanyConnection[] {
|
||||
return this.data?.connections ?? [];
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.route.parent?.paramMap.subscribe((params) => {
|
||||
const authorId = params.get('id');
|
||||
|
||||
if (!authorId) {
|
||||
this.loading = false;
|
||||
this.error = true;
|
||||
return;
|
||||
}
|
||||
|
||||
this.loadCompanyConnections(authorId);
|
||||
});
|
||||
}
|
||||
|
||||
getPrimaryOfficer(connection: CompanyConnection): MatchedOfficer | null {
|
||||
return connection.matched_officers?.[0] ?? null;
|
||||
}
|
||||
|
||||
getRelatedOfficers(connection: CompanyConnection): MatchedOfficer[] {
|
||||
const displayName = this.data?.display_name?.trim();
|
||||
|
||||
return (connection.officers ?? []).filter((officer) => {
|
||||
const officerName = officer.name?.trim();
|
||||
|
||||
if (!officerName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (officer.is_matched_person) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return officerName !== displayName;
|
||||
});
|
||||
}
|
||||
|
||||
getCompanyStatusLabel(status?: string | null): string {
|
||||
if (status === 'currently registered') {
|
||||
return 'Aktiv';
|
||||
}
|
||||
|
||||
if (status === 'removed') {
|
||||
return 'Gelöscht';
|
||||
}
|
||||
|
||||
return status || 'Unbekannt';
|
||||
}
|
||||
|
||||
getCompanyKey(connection: CompanyConnection): string {
|
||||
return (
|
||||
connection.company_number ||
|
||||
`${connection.company_name}-${connection.register_art}-${connection.register_nummer}`
|
||||
);
|
||||
}
|
||||
|
||||
getCompanyRegisterLabel(connection: CompanyConnection): string {
|
||||
const parts = [connection.register_art, connection.register_nummer].filter(
|
||||
Boolean,
|
||||
);
|
||||
|
||||
return parts.length > 0 ? parts.join(' ') : '—';
|
||||
}
|
||||
|
||||
getRegistrarLabel(connection: CompanyConnection): string {
|
||||
return connection.registrar || '—';
|
||||
}
|
||||
|
||||
getCompanyAddressLabel(connection: CompanyConnection): string {
|
||||
return connection.registered_address || connection.registered_office || '—';
|
||||
}
|
||||
|
||||
getGegenstandLabel(): string {
|
||||
return 'Noch nicht verfügbar.';
|
||||
}
|
||||
|
||||
getResultCountLabel(): string {
|
||||
if (!this.data) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const companyCount = this.data.company_count ?? this.connections.length;
|
||||
|
||||
if (companyCount === 1) {
|
||||
return '1 Treffer';
|
||||
}
|
||||
|
||||
return `${companyCount} Treffer`;
|
||||
}
|
||||
|
||||
getRoleColor(role?: string | null): string {
|
||||
if (!role) {
|
||||
return this.fallbackRoleColor;
|
||||
}
|
||||
|
||||
return this.roleColors[role] ?? this.fallbackRoleColor;
|
||||
}
|
||||
|
||||
isCompanySelected(connection: CompanyConnection): boolean {
|
||||
return this.selectedCompanyKey === this.getCompanyKey(connection);
|
||||
}
|
||||
|
||||
isCompanyOfficersExpanded(connection: CompanyConnection): boolean {
|
||||
return this.expandedOfficersCompanyKey === this.getCompanyKey(connection);
|
||||
}
|
||||
|
||||
selectCompany(connection: CompanyConnection): void {
|
||||
const companyKey = this.getCompanyKey(connection);
|
||||
|
||||
if (this.selectedCompanyKey === companyKey) {
|
||||
this.selectedCompanyKey = null;
|
||||
this.expandedOfficersCompanyKey = null;
|
||||
return;
|
||||
}
|
||||
|
||||
this.selectedCompanyKey = companyKey;
|
||||
this.expandedOfficersCompanyKey = null;
|
||||
}
|
||||
|
||||
toggleCompanyOfficers(connection: CompanyConnection, event: Event): void {
|
||||
event.stopPropagation();
|
||||
|
||||
const companyKey = this.getCompanyKey(connection);
|
||||
|
||||
if (this.expandedOfficersCompanyKey === companyKey) {
|
||||
this.expandedOfficersCompanyKey = null;
|
||||
return;
|
||||
}
|
||||
|
||||
this.expandedOfficersCompanyKey = companyKey;
|
||||
}
|
||||
|
||||
toggleRelatedPersons(): void {
|
||||
this.showRelatedPersons = !this.showRelatedPersons;
|
||||
this.refreshGraph();
|
||||
}
|
||||
|
||||
onGraphClick(event: any): void {
|
||||
if (event.dataType !== 'node') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.data?.category === this.personCategoryIndex) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.isCompanyNodeCategory(event.data?.category)) {
|
||||
this.selectedCompanyKey = event.data.id;
|
||||
this.expandedOfficersCompanyKey = null;
|
||||
this.scrollSelectedCompanyIntoView();
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.data?.category === this.registerPersonCategoryIndex) {
|
||||
this.openPersonSearchInNewTab(event.data.searchName || event.data.name);
|
||||
}
|
||||
}
|
||||
|
||||
onGraphWheel(event: WheelEvent): void {
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
private isCompanyNodeCategory(category: unknown): boolean {
|
||||
return (
|
||||
category === this.activeCompanyCategoryIndex ||
|
||||
category === this.removedCompanyCategoryIndex
|
||||
);
|
||||
}
|
||||
|
||||
private loadCompanyConnections(authorId: string): void {
|
||||
this.loading = true;
|
||||
this.error = false;
|
||||
this.data = null;
|
||||
this.graphOptions = null;
|
||||
this.roleLegendItems = [];
|
||||
this.selectedCompanyKey = null;
|
||||
this.expandedOfficersCompanyKey = null;
|
||||
this.showRelatedPersons = false;
|
||||
|
||||
this.companyConnectionsApi
|
||||
.getCompanyConnectionsByAuthor(authorId)
|
||||
.subscribe({
|
||||
next: (response) => {
|
||||
this.data = response;
|
||||
this.graphOptions = this.createGraphOptions(response);
|
||||
this.loading = false;
|
||||
},
|
||||
error: (error) => {
|
||||
console.error('Failed to load company connections:', error);
|
||||
this.error = true;
|
||||
this.loading = false;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
private refreshGraph(): void {
|
||||
if (!this.data) {
|
||||
this.graphOptions = null;
|
||||
this.roleLegendItems = [];
|
||||
return;
|
||||
}
|
||||
|
||||
this.graphOptions = this.createGraphOptions(this.data);
|
||||
}
|
||||
|
||||
private createGraphOptions(
|
||||
response: CompanyConnectionsResponse,
|
||||
): EChartsOption | null {
|
||||
const connections = response.connections ?? [];
|
||||
|
||||
if (!response.is_ude_author || connections.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const graphConnections = connections.slice(0, this.graphCompanyLimit);
|
||||
|
||||
this.roleLegendItems = this.createRoleLegendItems(graphConnections);
|
||||
|
||||
const personNodeId = `author-${response.author_id}`;
|
||||
|
||||
const nodes: any[] = [
|
||||
{
|
||||
id: personNodeId,
|
||||
name: response.display_name || 'Person',
|
||||
category: this.personCategoryIndex,
|
||||
symbol: 'circle',
|
||||
symbolSize: 44,
|
||||
itemStyle: {
|
||||
color: this.authorColor,
|
||||
},
|
||||
label: {
|
||||
show: true,
|
||||
position: 'bottom',
|
||||
fontWeight: 700,
|
||||
color: '#07163d',
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const links: any[] = [];
|
||||
|
||||
for (const connection of graphConnections) {
|
||||
const companyKey = this.getCompanyKey(connection);
|
||||
const isRemoved = connection.company_status === 'removed';
|
||||
|
||||
nodes.push({
|
||||
id: companyKey,
|
||||
name: connection.company_name || 'Unbekanntes Unternehmen',
|
||||
category: isRemoved
|
||||
? this.removedCompanyCategoryIndex
|
||||
: this.activeCompanyCategoryIndex,
|
||||
symbol: 'roundRect',
|
||||
symbolSize: [48, 34],
|
||||
itemStyle: {
|
||||
color: isRemoved ? this.companyRemovedColor : this.companyActiveColor,
|
||||
},
|
||||
label: {
|
||||
show: true,
|
||||
position: 'bottom',
|
||||
color: '#07163d',
|
||||
width: 125,
|
||||
overflow: 'truncate',
|
||||
},
|
||||
});
|
||||
|
||||
const officer = this.getPrimaryOfficer(connection);
|
||||
const role = officer?.position || 'Unbekannte Rolle';
|
||||
const color = this.getRoleColor(officer?.position);
|
||||
|
||||
links.push({
|
||||
source: personNodeId,
|
||||
target: companyKey,
|
||||
value: role,
|
||||
lineStyle: {
|
||||
color,
|
||||
width: 2.4,
|
||||
opacity: 1,
|
||||
},
|
||||
});
|
||||
|
||||
if (this.showRelatedPersons) {
|
||||
const relatedOfficers = this.getRelatedOfficers(connection);
|
||||
|
||||
relatedOfficers.forEach((relatedOfficer, index) => {
|
||||
const relatedOfficerId = `officer-${companyKey}-${index}`;
|
||||
const relatedRole = relatedOfficer.position || 'Unbekannte Rolle';
|
||||
|
||||
nodes.push({
|
||||
id: relatedOfficerId,
|
||||
name: relatedOfficer.name || 'Registerperson',
|
||||
searchName: relatedOfficer.name,
|
||||
role: relatedRole,
|
||||
category: this.registerPersonCategoryIndex,
|
||||
symbol: 'circle',
|
||||
symbolSize: 28,
|
||||
itemStyle: {
|
||||
color: this.relatedPersonColor,
|
||||
},
|
||||
label: {
|
||||
show: true,
|
||||
position: 'bottom',
|
||||
color: '#07163d',
|
||||
width: 110,
|
||||
overflow: 'truncate',
|
||||
fontSize: 11,
|
||||
},
|
||||
});
|
||||
|
||||
links.push({
|
||||
source: companyKey,
|
||||
target: relatedOfficerId,
|
||||
value: relatedRole,
|
||||
lineStyle: {
|
||||
color: this.getRoleColor(relatedOfficer.position),
|
||||
width: 1.8,
|
||||
opacity: 1,
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const graphSeries: any = {
|
||||
type: 'graph',
|
||||
layout: 'force',
|
||||
roam: true,
|
||||
roamTrigger: 'global',
|
||||
animation: false,
|
||||
top: 24,
|
||||
left: 20,
|
||||
right: 20,
|
||||
bottom: 64,
|
||||
data: nodes,
|
||||
links,
|
||||
categories: this.createGraphCategories(),
|
||||
force: {
|
||||
repulsion: this.showRelatedPersons ? 760 : 620,
|
||||
edgeLength: this.showRelatedPersons ? 145 : 170,
|
||||
gravity: 0.08,
|
||||
},
|
||||
lineStyle: {
|
||||
curveness: 0.05,
|
||||
opacity: 1,
|
||||
},
|
||||
edgeSymbol: ['none', 'none'],
|
||||
emphasis: {
|
||||
focus: 'adjacency',
|
||||
lineStyle: {
|
||||
width: 3.5,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
return {
|
||||
legend: {
|
||||
data: this.createNodeLegendData(graphConnections),
|
||||
bottom: 8,
|
||||
left: 'center',
|
||||
orient: 'horizontal',
|
||||
itemGap: 18,
|
||||
itemWidth: 18,
|
||||
itemHeight: 14,
|
||||
selectedMode: false,
|
||||
textStyle: {
|
||||
color: '#3f4659',
|
||||
fontSize: 13,
|
||||
fontWeight: 500,
|
||||
},
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'item',
|
||||
formatter: (params: any) => {
|
||||
if (params.dataType === 'node') {
|
||||
if (params.data?.category === this.registerPersonCategoryIndex) {
|
||||
return params.data?.role
|
||||
? `${params.data.name}<br/>Rolle: ${params.data.role}`
|
||||
: params.data?.name;
|
||||
}
|
||||
|
||||
return params.data?.name ?? '';
|
||||
}
|
||||
|
||||
if (params.dataType === 'edge') {
|
||||
return params.data?.value
|
||||
? `Rolle: ${params.data.value}`
|
||||
: 'Verbindung';
|
||||
}
|
||||
|
||||
return '';
|
||||
},
|
||||
},
|
||||
series: [graphSeries],
|
||||
} as EChartsOption;
|
||||
}
|
||||
|
||||
private createGraphCategories(): any[] {
|
||||
return [
|
||||
{
|
||||
name: this.personCategoryName,
|
||||
symbol: 'circle',
|
||||
itemStyle: {
|
||||
color: this.authorColor,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: this.activeCompanyCategoryName,
|
||||
symbol: 'roundRect',
|
||||
itemStyle: {
|
||||
color: this.companyActiveColor,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: this.removedCompanyCategoryName,
|
||||
symbol: 'roundRect',
|
||||
itemStyle: {
|
||||
color: this.companyRemovedColor,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: this.registerPersonCategoryName,
|
||||
symbol: 'circle',
|
||||
itemStyle: {
|
||||
color: this.relatedPersonColor,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
private createNodeLegendData(connections: CompanyConnection[]): any[] {
|
||||
const hasActiveCompany = connections.some(
|
||||
(connection) => connection.company_status !== 'removed',
|
||||
);
|
||||
const hasRemovedCompany = connections.some(
|
||||
(connection) => connection.company_status === 'removed',
|
||||
);
|
||||
|
||||
const legendData = [
|
||||
{
|
||||
name: this.personCategoryName,
|
||||
icon: 'circle',
|
||||
itemStyle: {
|
||||
color: this.authorColor,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
if (hasActiveCompany) {
|
||||
legendData.push({
|
||||
name: this.activeCompanyCategoryName,
|
||||
icon: 'roundRect',
|
||||
itemStyle: {
|
||||
color: this.companyActiveColor,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (hasRemovedCompany) {
|
||||
legendData.push({
|
||||
name: this.removedCompanyCategoryName,
|
||||
icon: 'roundRect',
|
||||
itemStyle: {
|
||||
color: this.companyRemovedColor,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (this.showRelatedPersons) {
|
||||
legendData.push({
|
||||
name: this.registerPersonCategoryName,
|
||||
icon: 'circle',
|
||||
itemStyle: {
|
||||
color: this.relatedPersonColor,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return legendData;
|
||||
}
|
||||
|
||||
private createRoleLegendItems(
|
||||
connections: CompanyConnection[],
|
||||
): RoleLegendItem[] {
|
||||
const usedRoles = new Set<string>();
|
||||
|
||||
for (const connection of connections) {
|
||||
const role = this.getPrimaryOfficer(connection)?.position;
|
||||
|
||||
if (role) {
|
||||
usedRoles.add(role);
|
||||
}
|
||||
|
||||
if (this.showRelatedPersons) {
|
||||
for (const officer of this.getRelatedOfficers(connection)) {
|
||||
if (officer.position) {
|
||||
usedRoles.add(officer.position);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [...usedRoles]
|
||||
.sort((a, b) => a.localeCompare(b))
|
||||
.map((role) => ({
|
||||
role,
|
||||
color: this.getRoleColor(role),
|
||||
}));
|
||||
}
|
||||
|
||||
openPersonSearchInNewTab(name?: string | null): void {
|
||||
const url = this.createPersonSearchUrl(name);
|
||||
|
||||
if (!url) {
|
||||
return;
|
||||
}
|
||||
|
||||
window.open(url, '_blank', 'noopener,noreferrer');
|
||||
}
|
||||
|
||||
private createPersonSearchUrl(name?: string | null): string | null {
|
||||
const query = name?.trim();
|
||||
|
||||
if (!query) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const urlTree = this.router.createUrlTree(['/persons'], {
|
||||
queryParams: this.getPersonSearchQueryParams(query),
|
||||
});
|
||||
|
||||
const internalUrl = this.router.serializeUrl(urlTree);
|
||||
|
||||
return this.locationStrategy.prepareExternalUrl(internalUrl);
|
||||
}
|
||||
|
||||
getPersonSearchQueryParams(name?: string | null): {
|
||||
institutionName: string;
|
||||
query: string;
|
||||
page: number;
|
||||
} {
|
||||
return {
|
||||
institutionName: this.searchInstitutionName,
|
||||
query: name?.trim() ?? '',
|
||||
page: 1,
|
||||
};
|
||||
}
|
||||
|
||||
private scrollSelectedCompanyIntoView(): void {
|
||||
window.setTimeout(() => {
|
||||
if (!this.selectedCompanyKey) {
|
||||
return;
|
||||
}
|
||||
|
||||
const rows = Array.from(
|
||||
this.host.nativeElement.querySelectorAll('.connection-row'),
|
||||
) as HTMLElement[];
|
||||
|
||||
for (const row of rows) {
|
||||
if (row.dataset['companyKey'] === this.selectedCompanyKey) {
|
||||
row.scrollIntoView({
|
||||
block: 'nearest',
|
||||
behavior: 'smooth',
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -139,7 +139,9 @@ export class PersonComponent {
|
||||
);
|
||||
readonly worksCount = computed(() => this.person()?.works_count ?? null);
|
||||
readonly citedByCount = computed(() => this.person()?.cited_by_count ?? null);
|
||||
readonly h_index = computed(() => this.person()?.summary_stats?.h_index ?? null);
|
||||
readonly h_index = computed(
|
||||
() => this.person()?.summary_stats?.h_index ?? null,
|
||||
);
|
||||
readonly orcid = computed(() => {
|
||||
const rawOrcid = this.getId('orcid');
|
||||
if (!rawOrcid) {
|
||||
@@ -171,7 +173,7 @@ export class PersonComponent {
|
||||
{ label: 'Projekte', path: 'projects', disabled: true },
|
||||
{ label: 'Publikationen', path: 'publications', disabled: false },
|
||||
{ label: 'Netzwerk', path: 'network', disabled: false },
|
||||
{ label: 'Gründungen', path: 'foundings', disabled: true },
|
||||
{ label: 'Unternehmen', path: 'company-connections', disabled: false },
|
||||
{ label: 'Förderungen', path: 'funding', disabled: false },
|
||||
];
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
"compileOnSave": false,
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist/out-tsc",
|
||||
"rootDir": "./src",
|
||||
"strict": true,
|
||||
"noImplicitOverride": true,
|
||||
"noPropertyAccessFromIndexSignature": true,
|
||||
|
||||
Reference in New Issue
Block a user