Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
470b9095c4 |
@@ -2,7 +2,7 @@ import logging
|
|||||||
import uuid
|
import uuid
|
||||||
from typing import Annotated
|
from typing import Annotated
|
||||||
|
|
||||||
from fastapi import APIRouter, Body, Depends, Query, Response, status
|
from fastapi import APIRouter, Body, Depends, Response, status
|
||||||
from sqlmodel import Session
|
from sqlmodel import Session
|
||||||
|
|
||||||
import inse.auth.service as auth_service
|
import inse.auth.service as auth_service
|
||||||
@@ -204,30 +204,3 @@ async def change_password(
|
|||||||
current_password=current_password,
|
current_password=current_password,
|
||||||
new_password=new_password,
|
new_password=new_password,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@router.get(
|
|
||||||
"/can-fetch-gdpr-relevant-data",
|
|
||||||
summary="Check if user can fetch GDPR-relevant data",
|
|
||||||
description="Check if the authenticated user can fetch GDPR-relevant data for a given author and institution.",
|
|
||||||
operation_id="canFetchGdprRelevantData",
|
|
||||||
)
|
|
||||||
async def can_fetch_gdpr_relevant_data(
|
|
||||||
access_token: Annotated[
|
|
||||||
AccessTokenMetadata,
|
|
||||||
auth_service.CurrentUserAccessTokenPayloadDep,
|
|
||||||
],
|
|
||||||
raw_oa_author_id: Annotated[
|
|
||||||
str | None,
|
|
||||||
Query(description="OpenAlex author ID to check access for"),
|
|
||||||
] = None,
|
|
||||||
raw_oa_institution_id: Annotated[
|
|
||||||
str | None,
|
|
||||||
Query(description="OpenAlex institution ID to check access for"),
|
|
||||||
] = None,
|
|
||||||
) -> bool:
|
|
||||||
return await auth_service.can_fetch_gdpr_relevant_data(
|
|
||||||
access_token=access_token,
|
|
||||||
raw_oa_author_id=raw_oa_author_id,
|
|
||||||
raw_oa_institution_id=raw_oa_institution_id,
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ from inse.auth.model import (
|
|||||||
effective_role_for_roles,
|
effective_role_for_roles,
|
||||||
normalize_roles,
|
normalize_roles,
|
||||||
)
|
)
|
||||||
from inse.authors.v2 import service as authors_service
|
|
||||||
from inse.config import get_settings
|
from inse.config import get_settings
|
||||||
from inse.database import get_session
|
from inse.database import get_session
|
||||||
|
|
||||||
@@ -1452,69 +1451,3 @@ def change_password(
|
|||||||
logger.info("Password changed successfully for account %s", account.id)
|
logger.info("Password changed successfully for account %s", account.id)
|
||||||
|
|
||||||
return {"status": "ok"}
|
return {"status": "ok"}
|
||||||
|
|
||||||
|
|
||||||
async def can_fetch_gdpr_relevant_data(
|
|
||||||
access_token: AccessTokenMetadata,
|
|
||||||
raw_oa_author_id: str | None = None,
|
|
||||||
raw_oa_institution_id: str | None = None,
|
|
||||||
) -> bool:
|
|
||||||
"""Returns True if the user associated with the provided access token is allowed to fetch GDPR-relevant data for the specified OpenAlex author ID and institution ID, based on their effective institution ID.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
access_token (AccessTokenMetadata): The access token for the user.
|
|
||||||
raw_oa_author_id (str | None, optional): The OpenAlex author ID for which to check access. Defaults to None.
|
|
||||||
raw_oa_institution_id (str | None, optional): The OpenAlex institution ID for which to check access. Defaults to None.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
bool: True if the user is allowed to fetch GDPR-relevant data for the specified IDs, False otherwise.
|
|
||||||
"""
|
|
||||||
|
|
||||||
logger.debug(
|
|
||||||
"Checking if user with effective institution ID %s can fetch GDPR-relevant data for author ID %s and institution ID %s",
|
|
||||||
access_token.effective_institution_id,
|
|
||||||
raw_oa_author_id,
|
|
||||||
raw_oa_institution_id,
|
|
||||||
)
|
|
||||||
|
|
||||||
if not raw_oa_author_id and not raw_oa_institution_id:
|
|
||||||
logger.debug("No OpenAlex author ID or institution ID provided")
|
|
||||||
return False
|
|
||||||
|
|
||||||
effective_institution_id = access_token.effective_institution_id
|
|
||||||
# Current user does not belong to any institution
|
|
||||||
if not effective_institution_id:
|
|
||||||
logger.debug(
|
|
||||||
"Current user does not belong to any institution, cannot fetch GDPR-relevant data"
|
|
||||||
)
|
|
||||||
return False
|
|
||||||
|
|
||||||
# Current user belongs to an institution, but the request is for a different institution
|
|
||||||
if (
|
|
||||||
raw_oa_institution_id
|
|
||||||
and effective_institution_id
|
|
||||||
and raw_oa_institution_id != effective_institution_id
|
|
||||||
):
|
|
||||||
logger.debug(
|
|
||||||
"Current user belongs to institution %s, but request is for institution %s, cannot fetch GDPR-relevant data",
|
|
||||||
effective_institution_id,
|
|
||||||
raw_oa_institution_id,
|
|
||||||
)
|
|
||||||
return False
|
|
||||||
|
|
||||||
# Current user belongs to an institution, but request is for author not belonging to that institution
|
|
||||||
if raw_oa_author_id:
|
|
||||||
author_belongs_to_institution = (
|
|
||||||
await authors_service.author_currently_belongs_to_institution(
|
|
||||||
raw_oa_author_id or "", effective_institution_id
|
|
||||||
)
|
|
||||||
)
|
|
||||||
logger.debug(
|
|
||||||
"Author %s belongs to institution %s: %s",
|
|
||||||
raw_oa_author_id,
|
|
||||||
effective_institution_id,
|
|
||||||
author_belongs_to_institution,
|
|
||||||
)
|
|
||||||
return author_belongs_to_institution
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|||||||
@@ -11,13 +11,13 @@ from sqlmodel import Session
|
|||||||
|
|
||||||
from inse import config
|
from inse import config
|
||||||
from inse.auth.model import AccessToken, Organization
|
from inse.auth.model import AccessToken, Organization
|
||||||
|
from inse.authors.institution_membership_query import (
|
||||||
|
build_institution_membership_query,
|
||||||
|
)
|
||||||
from inse.institutions.institutions_search_client import InstitutionsSearchClient
|
from inse.institutions.institutions_search_client import InstitutionsSearchClient
|
||||||
from inse.institutions.v2 import service as institutions_v2_service
|
|
||||||
from inse.integrations import elasticsearch
|
from inse.integrations import elasticsearch
|
||||||
from inse.model import ESCluster, ESIndex
|
from inse.model import ESCluster, ESIndex
|
||||||
from inse.patents.org.elastic_search_client import OrgPatentsSearchClient
|
from inse.patents.org.elastic_search_client import OrgPatentsSearchClient
|
||||||
from inse.persons import service as persons_service
|
|
||||||
from inse.projects import service as projects_service
|
|
||||||
from inse.projects.dfg_institutions.service import (
|
from inse.projects.dfg_institutions.service import (
|
||||||
autocomplete_institutions_for_selector,
|
autocomplete_institutions_for_selector,
|
||||||
)
|
)
|
||||||
@@ -30,7 +30,6 @@ from inse.projects.model import (
|
|||||||
ProjectsFilteringProperties,
|
ProjectsFilteringProperties,
|
||||||
ProjectType,
|
ProjectType,
|
||||||
)
|
)
|
||||||
from inse.works.v2 import service as works_v2_service
|
|
||||||
|
|
||||||
from .institute_helper import get_openalex_institution
|
from .institute_helper import get_openalex_institution
|
||||||
from .model import (
|
from .model import (
|
||||||
@@ -242,32 +241,20 @@ async def get_dashboard_publications(
|
|||||||
) -> DashboardStatisticValue:
|
) -> DashboardStatisticValue:
|
||||||
normalized_id = _normalize_institution_id(institution_id)
|
normalized_id = _normalize_institution_id(institution_id)
|
||||||
period = _dashboard_period(from_year, to_year)
|
period = _dashboard_period(from_year, to_year)
|
||||||
must = [
|
filters = []
|
||||||
works_v2_service._institutions_nested_query([normalized_id]),
|
if year_filter := _publication_year_filter(period):
|
||||||
]
|
filters.append(year_filter)
|
||||||
if publication_years := _dashboard_publication_years(period):
|
query = _institution_works_query(normalized_id)
|
||||||
must.append({"terms": {"publication_year": publication_years}})
|
if filters:
|
||||||
|
query = {"bool": {"must": [query], "filter": filters}}
|
||||||
response = await elasticsearch.search(
|
response = await elasticsearch.search(
|
||||||
index=ESIndex.OPENALEX_WORKS_WILDCARD,
|
index=config.settings.openalex_works_search_index,
|
||||||
body={
|
query=query,
|
||||||
"size": 0,
|
size=0,
|
||||||
"track_total_hits": True,
|
track_total_hits=True,
|
||||||
"query": {"bool": {"must": must}},
|
|
||||||
},
|
|
||||||
cluster=ESCluster.NES,
|
cluster=ESCluster.NES,
|
||||||
)
|
)
|
||||||
return DashboardStatisticValue(
|
return _dashboard_statistic_value(normalized_id, organization_name, response)
|
||||||
institution_id=normalized_id,
|
|
||||||
organization_name=organization_name,
|
|
||||||
value=_total(response),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def _dashboard_publication_years(period: DashboardPeriod) -> list[int] | None:
|
|
||||||
from_year, to_year = period
|
|
||||||
if from_year is None and to_year is None:
|
|
||||||
return None
|
|
||||||
return list(range(from_year or 1900, (to_year or 2100) + 1))
|
|
||||||
|
|
||||||
|
|
||||||
async def get_dashboard_persons(
|
async def get_dashboard_persons(
|
||||||
@@ -283,25 +270,20 @@ async def get_dashboard_persons(
|
|||||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||||
detail="from_year and to_year must either both be provided or both omitted.",
|
detail="from_year and to_year must either both be provided or both omitted.",
|
||||||
)
|
)
|
||||||
persons = await persons_service.search_persons_list(
|
membership_query = build_institution_membership_query(
|
||||||
query=None,
|
|
||||||
institution_id=normalized_id,
|
institution_id=normalized_id,
|
||||||
sort_by=None,
|
year_mode="between" if period[0] is not None else "all",
|
||||||
sort_order=None,
|
year=period[0],
|
||||||
topic=None,
|
year_to=period[1],
|
||||||
page=1,
|
|
||||||
page_size=1,
|
|
||||||
include="",
|
|
||||||
year_filter_enabled=period[0] is not None,
|
|
||||||
filter_mode="between" if period[0] is not None else None,
|
|
||||||
filter_year=period[0],
|
|
||||||
filter_year_to=period[1],
|
|
||||||
)
|
)
|
||||||
return DashboardStatisticValue(
|
response = await elasticsearch.search(
|
||||||
institution_id=normalized_id,
|
index=ESIndex.OPENALEX_AUTHORS,
|
||||||
organization_name=organization_name,
|
query=membership_query,
|
||||||
value=int(persons.meta.count or 0) if persons.meta else 0,
|
size=0,
|
||||||
|
track_total_hits=True,
|
||||||
|
cluster=ESCluster.NES,
|
||||||
)
|
)
|
||||||
|
return _dashboard_statistic_value(normalized_id, organization_name, response)
|
||||||
|
|
||||||
|
|
||||||
async def get_dashboard_patents(
|
async def get_dashboard_patents(
|
||||||
@@ -333,43 +315,45 @@ async def get_dashboard_eu_projects(
|
|||||||
to_year: int | None = None,
|
to_year: int | None = None,
|
||||||
) -> DashboardStatisticValue:
|
) -> DashboardStatisticValue:
|
||||||
normalized_id = _normalize_institution_id(institution_id)
|
normalized_id = _normalize_institution_id(institution_id)
|
||||||
|
aliases = await _institution_aliases(normalized_id, organization_name)
|
||||||
period = _dashboard_period(from_year, to_year)
|
period = _dashboard_period(from_year, to_year)
|
||||||
projects = await projects_service.search_eu_cordis_projects(
|
period_filter = _project_overlap_filter(
|
||||||
institutions_search_client=InstitutionsSearchClient(),
|
"startDate",
|
||||||
raw_oa_institution_id=_raw_institution_id(normalized_id),
|
"endDate",
|
||||||
author_id=None,
|
_date_period(period, "iso"),
|
||||||
author_ids=None,
|
)
|
||||||
organization_ids=None,
|
if period_filter:
|
||||||
organization_names=None,
|
project_ids = await _eu_project_ids_for_aliases(aliases)
|
||||||
project_types=list(EuCordisProjectType),
|
value = await _count_eu_projects_in_period(project_ids, period_filter)
|
||||||
keywords=None,
|
return DashboardStatisticValue(
|
||||||
topic_ids=None,
|
institution_id=normalized_id,
|
||||||
filter_topic_ids=None,
|
organization_name=organization_name,
|
||||||
title=None,
|
value=value,
|
||||||
funding_start_years=(
|
)
|
||||||
[str(year) for year in range(1900, period[1] + 1)]
|
|
||||||
if period[1] is not None
|
response = await elasticsearch.search(
|
||||||
else None
|
index=ESIndex.CORDIS_EU_ORGANIZATIONS_WILDCARD,
|
||||||
),
|
body={
|
||||||
funding_end_years=(
|
"size": 0,
|
||||||
[str(year) for year in range(period[0], 2101)]
|
"query": _eu_organization_query(aliases),
|
||||||
if period[0] is not None
|
"aggs": {
|
||||||
else None
|
"projects": {
|
||||||
),
|
"cardinality": {
|
||||||
countries=None,
|
"field": "projectID",
|
||||||
framework_programmes=None,
|
}
|
||||||
funding_schemes=None,
|
}
|
||||||
statuses=None,
|
},
|
||||||
page=0,
|
},
|
||||||
size=1,
|
cluster=ESCluster.INSE,
|
||||||
sort_by="id",
|
|
||||||
sort_direction="asc",
|
|
||||||
fuzzy=False,
|
|
||||||
)
|
)
|
||||||
return DashboardStatisticValue(
|
return DashboardStatisticValue(
|
||||||
institution_id=normalized_id,
|
institution_id=normalized_id,
|
||||||
organization_name=organization_name,
|
organization_name=organization_name,
|
||||||
value=projects.total,
|
value=int(
|
||||||
|
response.get("aggregations", {})
|
||||||
|
.get("projects", {})
|
||||||
|
.get("value", 0)
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -384,18 +368,10 @@ async def get_dashboard_eu_project_statuses(
|
|||||||
project_ids = await _eu_project_ids_for_aliases(aliases)
|
project_ids = await _eu_project_ids_for_aliases(aliases)
|
||||||
|
|
||||||
if not project_ids:
|
if not project_ids:
|
||||||
total = (
|
|
||||||
await get_dashboard_eu_projects(
|
|
||||||
normalized_id,
|
|
||||||
organization_name,
|
|
||||||
from_year=from_year,
|
|
||||||
to_year=to_year,
|
|
||||||
)
|
|
||||||
).value
|
|
||||||
return EuProjectStatusStatistics(
|
return EuProjectStatusStatistics(
|
||||||
institution_id=normalized_id,
|
institution_id=normalized_id,
|
||||||
organization_name=organization_name,
|
organization_name=organization_name,
|
||||||
ongoing=total,
|
ongoing=0,
|
||||||
upcoming=0,
|
upcoming=0,
|
||||||
completed=0,
|
completed=0,
|
||||||
)
|
)
|
||||||
@@ -450,26 +426,12 @@ async def get_dashboard_eu_project_statuses(
|
|||||||
cluster=ESCluster.INSE,
|
cluster=ESCluster.INSE,
|
||||||
)
|
)
|
||||||
aggregations = response.get("aggregations", {})
|
aggregations = response.get("aggregations", {})
|
||||||
total = (
|
|
||||||
await get_dashboard_eu_projects(
|
|
||||||
normalized_id,
|
|
||||||
organization_name,
|
|
||||||
from_year=from_year,
|
|
||||||
to_year=to_year,
|
|
||||||
)
|
|
||||||
).value
|
|
||||||
ongoing, upcoming, completed = _reconcile_project_status_counts(
|
|
||||||
total,
|
|
||||||
_project_status_count(aggregations, "ongoing"),
|
|
||||||
_project_status_count(aggregations, "upcoming"),
|
|
||||||
_project_status_count(aggregations, "completed"),
|
|
||||||
)
|
|
||||||
return EuProjectStatusStatistics(
|
return EuProjectStatusStatistics(
|
||||||
institution_id=normalized_id,
|
institution_id=normalized_id,
|
||||||
organization_name=organization_name,
|
organization_name=organization_name,
|
||||||
ongoing=ongoing,
|
ongoing=_project_status_count(aggregations, "ongoing"),
|
||||||
upcoming=upcoming,
|
upcoming=_project_status_count(aggregations, "upcoming"),
|
||||||
completed=completed,
|
completed=_project_status_count(aggregations, "completed"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -479,32 +441,6 @@ def _project_status_count(aggregations: dict[str, Any], status_name: str) -> int
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _reconcile_project_status_counts(
|
|
||||||
total: int,
|
|
||||||
ongoing: int,
|
|
||||||
upcoming: int,
|
|
||||||
completed: int,
|
|
||||||
) -> tuple[int, int, int]:
|
|
||||||
"""Makes status buckets add up to the authoritative project-service total."""
|
|
||||||
counts = [max(0, ongoing), max(0, upcoming), max(0, completed)]
|
|
||||||
difference = total - sum(counts)
|
|
||||||
if difference >= 0:
|
|
||||||
counts[0] += difference
|
|
||||||
return counts[0], counts[1], counts[2]
|
|
||||||
|
|
||||||
# Defensive fallback for stale/duplicated status documents: reduce buckets
|
|
||||||
# without ever returning negative values, preferring the inferred ongoing
|
|
||||||
# bucket before changing explicit upcoming/completed classifications.
|
|
||||||
excess = -difference
|
|
||||||
for index in (0, 1, 2):
|
|
||||||
reduction = min(counts[index], excess)
|
|
||||||
counts[index] -= reduction
|
|
||||||
excess -= reduction
|
|
||||||
if excess == 0:
|
|
||||||
break
|
|
||||||
return counts[0], counts[1], counts[2]
|
|
||||||
|
|
||||||
|
|
||||||
async def get_dashboard_bmbf_projects(
|
async def get_dashboard_bmbf_projects(
|
||||||
institution_id: str,
|
institution_id: str,
|
||||||
organization_name: str,
|
organization_name: str,
|
||||||
@@ -512,38 +448,23 @@ async def get_dashboard_bmbf_projects(
|
|||||||
to_year: int | None = None,
|
to_year: int | None = None,
|
||||||
) -> DashboardStatisticValue:
|
) -> DashboardStatisticValue:
|
||||||
normalized_id = _normalize_institution_id(institution_id)
|
normalized_id = _normalize_institution_id(institution_id)
|
||||||
|
aliases = await _institution_aliases(normalized_id, organization_name)
|
||||||
period = _dashboard_period(from_year, to_year)
|
period = _dashboard_period(from_year, to_year)
|
||||||
projects = await projects_service.search_bund_projects_with_filters(
|
filters = [_alias_match_query("Zuwendungsempfänger", aliases)]
|
||||||
institutions_search_client=InstitutionsSearchClient(),
|
if period_filter := _project_overlap_filter(
|
||||||
executing_agency=None,
|
"funding_start",
|
||||||
raw_oa_institution_id=_raw_institution_id(normalized_id),
|
"funding_end",
|
||||||
title=None,
|
_date_period(period, "de"),
|
||||||
keywords=None,
|
):
|
||||||
funding_arts=None,
|
filters.append(period_filter)
|
||||||
topic_ids=None,
|
response = await elasticsearch.search(
|
||||||
filter_topic_ids=None,
|
index=ESIndex.PROJECTS_BUND_V1,
|
||||||
funding_start_years=(
|
query=filters[0] if len(filters) == 1 else {"bool": {"filter": filters}},
|
||||||
[str(year) for year in range(1900, period[1] + 1)]
|
size=0,
|
||||||
if period[1] is not None
|
track_total_hits=True,
|
||||||
else None
|
cluster=ESCluster.INSE,
|
||||||
),
|
|
||||||
funding_end_years=(
|
|
||||||
[str(year) for year in range(period[0], 2101)]
|
|
||||||
if period[0] is not None
|
|
||||||
else None
|
|
||||||
),
|
|
||||||
countries=None,
|
|
||||||
page=0,
|
|
||||||
size=1,
|
|
||||||
sort_by="id",
|
|
||||||
sort_direction="asc",
|
|
||||||
fuzzy=False,
|
|
||||||
)
|
|
||||||
return DashboardStatisticValue(
|
|
||||||
institution_id=normalized_id,
|
|
||||||
organization_name=organization_name,
|
|
||||||
value=projects.total,
|
|
||||||
)
|
)
|
||||||
|
return _dashboard_statistic_value(normalized_id, organization_name, response)
|
||||||
|
|
||||||
|
|
||||||
async def get_dashboard_bmbf_project_statuses(
|
async def get_dashboard_bmbf_project_statuses(
|
||||||
@@ -577,26 +498,12 @@ async def get_dashboard_bmbf_project_statuses(
|
|||||||
cluster=ESCluster.INSE,
|
cluster=ESCluster.INSE,
|
||||||
)
|
)
|
||||||
aggregations = response.get("aggregations", {})
|
aggregations = response.get("aggregations", {})
|
||||||
total = (
|
|
||||||
await get_dashboard_bmbf_projects(
|
|
||||||
normalized_id,
|
|
||||||
organization_name,
|
|
||||||
from_year=from_year,
|
|
||||||
to_year=to_year,
|
|
||||||
)
|
|
||||||
).value
|
|
||||||
ongoing, upcoming, completed = _reconcile_project_status_counts(
|
|
||||||
total,
|
|
||||||
int(aggregations.get("ongoing", {}).get("doc_count", 0)),
|
|
||||||
int(aggregations.get("upcoming", {}).get("doc_count", 0)),
|
|
||||||
int(aggregations.get("completed", {}).get("doc_count", 0)),
|
|
||||||
)
|
|
||||||
return BmbfProjectStatusStatistics(
|
return BmbfProjectStatusStatistics(
|
||||||
institution_id=normalized_id,
|
institution_id=normalized_id,
|
||||||
organization_name=organization_name,
|
organization_name=organization_name,
|
||||||
ongoing=ongoing,
|
ongoing=int(aggregations.get("ongoing", {}).get("doc_count", 0)),
|
||||||
upcoming=upcoming,
|
upcoming=int(aggregations.get("upcoming", {}).get("doc_count", 0)),
|
||||||
completed=completed,
|
completed=int(aggregations.get("completed", {}).get("doc_count", 0)),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -628,37 +535,15 @@ async def get_dashboard_dfg_projects(
|
|||||||
to_year: int | None = None,
|
to_year: int | None = None,
|
||||||
) -> DashboardStatisticValue:
|
) -> DashboardStatisticValue:
|
||||||
normalized_id = _normalize_institution_id(institution_id)
|
normalized_id = _normalize_institution_id(institution_id)
|
||||||
period = _dashboard_period(from_year, to_year)
|
project_ids = await _get_dfg_project_ids_for_institution(
|
||||||
projects = await projects_service.get_dfg_projects_by_author_id(
|
normalized_id,
|
||||||
institutions_search_client=InstitutionsSearchClient(),
|
from_year=from_year,
|
||||||
raw_oa_institution_id=_raw_institution_id(normalized_id),
|
to_year=to_year,
|
||||||
author_id=None,
|
|
||||||
author_filter_ids=None,
|
|
||||||
institution_ids=None,
|
|
||||||
keywords=None,
|
|
||||||
topic_ids=None,
|
|
||||||
filter_topic_ids=None,
|
|
||||||
title=None,
|
|
||||||
funding_start_years=(
|
|
||||||
[str(year) for year in range(1900, period[1] + 1)]
|
|
||||||
if period[1] is not None
|
|
||||||
else None
|
|
||||||
),
|
|
||||||
funding_end_years=(
|
|
||||||
[str(year) for year in range(period[0], 2101)]
|
|
||||||
if period[0] is not None
|
|
||||||
else None
|
|
||||||
),
|
|
||||||
page=0,
|
|
||||||
size=1,
|
|
||||||
sort_by="id",
|
|
||||||
sort_direction="asc",
|
|
||||||
fuzzy=False,
|
|
||||||
)
|
)
|
||||||
return DashboardStatisticValue(
|
return DashboardStatisticValue(
|
||||||
institution_id=normalized_id,
|
institution_id=normalized_id,
|
||||||
organization_name=organization_name,
|
organization_name=organization_name,
|
||||||
value=projects.total,
|
value=len(project_ids),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -674,18 +559,10 @@ async def get_dashboard_dfg_project_statuses(
|
|||||||
normalized_id,
|
normalized_id,
|
||||||
)
|
)
|
||||||
if not project_ids:
|
if not project_ids:
|
||||||
total = (
|
|
||||||
await get_dashboard_dfg_projects(
|
|
||||||
normalized_id,
|
|
||||||
organization_name,
|
|
||||||
from_year=from_year,
|
|
||||||
to_year=to_year,
|
|
||||||
)
|
|
||||||
).value
|
|
||||||
return DfgProjectStatusStatistics(
|
return DfgProjectStatusStatistics(
|
||||||
institution_id=normalized_id,
|
institution_id=normalized_id,
|
||||||
organization_name=organization_name,
|
organization_name=organization_name,
|
||||||
ongoing=total,
|
ongoing=0,
|
||||||
upcoming=0,
|
upcoming=0,
|
||||||
completed=0,
|
completed=0,
|
||||||
)
|
)
|
||||||
@@ -763,26 +640,12 @@ async def get_dashboard_dfg_project_statuses(
|
|||||||
.get("projects_nested", {})
|
.get("projects_nested", {})
|
||||||
.get("selected_projects", {})
|
.get("selected_projects", {})
|
||||||
)
|
)
|
||||||
total = (
|
|
||||||
await get_dashboard_dfg_projects(
|
|
||||||
normalized_id,
|
|
||||||
organization_name,
|
|
||||||
from_year=from_year,
|
|
||||||
to_year=to_year,
|
|
||||||
)
|
|
||||||
).value
|
|
||||||
ongoing, upcoming, completed = _reconcile_project_status_counts(
|
|
||||||
total,
|
|
||||||
_project_status_count(aggregations, "ongoing"),
|
|
||||||
0,
|
|
||||||
_project_status_count(aggregations, "completed"),
|
|
||||||
)
|
|
||||||
return DfgProjectStatusStatistics(
|
return DfgProjectStatusStatistics(
|
||||||
institution_id=normalized_id,
|
institution_id=normalized_id,
|
||||||
organization_name=organization_name,
|
organization_name=organization_name,
|
||||||
ongoing=ongoing,
|
ongoing=_project_status_count(aggregations, "ongoing"),
|
||||||
upcoming=upcoming,
|
upcoming=0,
|
||||||
completed=completed,
|
completed=_project_status_count(aggregations, "completed"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -793,11 +656,17 @@ async def get_dashboard_dfg_topics(
|
|||||||
to_year: int | None = None,
|
to_year: int | None = None,
|
||||||
) -> DfgProjectTopics:
|
) -> DfgProjectTopics:
|
||||||
normalized_id = _normalize_institution_id(institution_id)
|
normalized_id = _normalize_institution_id(institution_id)
|
||||||
project_ids = await _get_dfg_project_ids_from_projects_service(
|
project_ids = await _get_dfg_project_ids_for_institution(
|
||||||
normalized_id,
|
normalized_id,
|
||||||
from_year=from_year,
|
from_year=from_year,
|
||||||
to_year=to_year,
|
to_year=to_year,
|
||||||
)
|
)
|
||||||
|
print(
|
||||||
|
"Dashboard DFG project topics "
|
||||||
|
f"for institution {normalized_id}: "
|
||||||
|
f"{len(project_ids)} project IDs={project_ids}",
|
||||||
|
flush=True,
|
||||||
|
)
|
||||||
topics: dict[str, dict[str, Any]] = {}
|
topics: dict[str, dict[str, Any]] = {}
|
||||||
matched_project_ids: set[str] = set()
|
matched_project_ids: set[str] = set()
|
||||||
|
|
||||||
@@ -866,53 +735,6 @@ async def get_dashboard_dfg_topics(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def _get_dfg_project_ids_from_projects_service(
|
|
||||||
institution_id: str,
|
|
||||||
from_year: int | None = None,
|
|
||||||
to_year: int | None = None,
|
|
||||||
) -> list[str]:
|
|
||||||
"""Returns every matching DFG project ID through the canonical project service."""
|
|
||||||
period = _dashboard_period(from_year, to_year)
|
|
||||||
page_size = 1000
|
|
||||||
page_number = 0
|
|
||||||
project_ids: set[str] = set()
|
|
||||||
|
|
||||||
while True:
|
|
||||||
projects = await projects_service.get_dfg_projects_by_author_id(
|
|
||||||
institutions_search_client=InstitutionsSearchClient(),
|
|
||||||
raw_oa_institution_id=_raw_institution_id(institution_id),
|
|
||||||
author_id=None,
|
|
||||||
author_filter_ids=None,
|
|
||||||
institution_ids=None,
|
|
||||||
keywords=None,
|
|
||||||
topic_ids=None,
|
|
||||||
filter_topic_ids=None,
|
|
||||||
title=None,
|
|
||||||
funding_start_years=(
|
|
||||||
[str(year) for year in range(1900, period[1] + 1)]
|
|
||||||
if period[1] is not None
|
|
||||||
else None
|
|
||||||
),
|
|
||||||
funding_end_years=(
|
|
||||||
[str(year) for year in range(period[0], 2101)]
|
|
||||||
if period[0] is not None
|
|
||||||
else None
|
|
||||||
),
|
|
||||||
page=page_number,
|
|
||||||
size=page_size,
|
|
||||||
sort_by="id",
|
|
||||||
sort_direction="asc",
|
|
||||||
fuzzy=False,
|
|
||||||
skip_enrichment=True,
|
|
||||||
)
|
|
||||||
project_ids.update(project.id for project in projects.elements if project.id)
|
|
||||||
if len(project_ids) >= projects.total or not projects.elements:
|
|
||||||
break
|
|
||||||
page_number += 1
|
|
||||||
|
|
||||||
return sorted(project_ids)
|
|
||||||
|
|
||||||
|
|
||||||
async def _get_dfg_project_ids_for_institution(
|
async def _get_dfg_project_ids_for_institution(
|
||||||
institution_id: str,
|
institution_id: str,
|
||||||
from_year: int | None = None,
|
from_year: int | None = None,
|
||||||
@@ -1189,11 +1011,9 @@ async def get_top_authors(
|
|||||||
from_year = datetime.now().year - 4
|
from_year = datetime.now().year - 4
|
||||||
to_year = datetime.now().year
|
to_year = datetime.now().year
|
||||||
period = _dashboard_period(from_year, to_year)
|
period = _dashboard_period(from_year, to_year)
|
||||||
|
aliases = await _institution_aliases(normalized_id, organization_name)
|
||||||
authors = await _safe_institution_authors(normalized_id)
|
authors = await _safe_institution_authors(normalized_id)
|
||||||
works = await _safe_top_authors(
|
works = _top_work_authors(authors, period)
|
||||||
"works",
|
|
||||||
_top_work_authors(normalized_id, period, authors),
|
|
||||||
)
|
|
||||||
projects = await _safe_top_authors(
|
projects = await _safe_top_authors(
|
||||||
"projects",
|
"projects",
|
||||||
_top_project_authors(
|
_top_project_authors(
|
||||||
@@ -1205,12 +1025,7 @@ async def get_top_authors(
|
|||||||
)
|
)
|
||||||
eu_projects = await _safe_top_authors(
|
eu_projects = await _safe_top_authors(
|
||||||
"eu_projects",
|
"eu_projects",
|
||||||
_top_eu_project_publication_authors(
|
_top_eu_project_publication_authors(normalized_id, aliases, authors),
|
||||||
normalized_id,
|
|
||||||
authors,
|
|
||||||
from_year=period[0],
|
|
||||||
to_year=period[1],
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
patents = await _safe_top_authors(
|
patents = await _safe_top_authors(
|
||||||
@@ -1605,81 +1420,51 @@ def _short_author_id(value: str) -> str:
|
|||||||
return value.replace("https://openalex.org/", "").strip().upper()
|
return value.replace("https://openalex.org/", "").strip().upper()
|
||||||
|
|
||||||
|
|
||||||
async def _top_work_authors(
|
def _top_work_authors(
|
||||||
institution_id: str,
|
authors: list[dict[str, Any]],
|
||||||
period: DashboardPeriod,
|
period: DashboardPeriod,
|
||||||
institution_authors: list[dict[str, Any]],
|
|
||||||
) -> list[TopAuthor]:
|
) -> list[TopAuthor]:
|
||||||
institution_author_ids = {
|
if period != (None, None):
|
||||||
_short_author_id(str(author["id"]))
|
ranked_authors = sorted(
|
||||||
for author in institution_authors
|
(
|
||||||
if author.get("id")
|
{
|
||||||
}
|
**author,
|
||||||
if not institution_author_ids:
|
"selected_works_count": _works_count_in_period(author, period),
|
||||||
return []
|
}
|
||||||
|
for author in authors
|
||||||
|
),
|
||||||
|
key=lambda author: author["selected_works_count"],
|
||||||
|
reverse=True,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
ranked_authors = [
|
||||||
|
{**author, "selected_works_count": author["works_count"]}
|
||||||
|
for author in authors
|
||||||
|
]
|
||||||
|
|
||||||
must = [works_v2_service._institutions_nested_query([institution_id])]
|
|
||||||
if publication_years := _dashboard_publication_years(period):
|
|
||||||
must.append({"terms": {"publication_year": publication_years}})
|
|
||||||
|
|
||||||
author_counts: dict[str, int] = defaultdict(int)
|
|
||||||
author_names: dict[str, str] = {}
|
|
||||||
async for hit in elasticsearch.scan(
|
|
||||||
index=str(ESIndex.OPENALEX_WORKS_WILDCARD),
|
|
||||||
query={"bool": {"must": must}},
|
|
||||||
source=[
|
|
||||||
"id",
|
|
||||||
"authorships.author.id",
|
|
||||||
"authorships.author.display_name",
|
|
||||||
"authorships.institutions.id",
|
|
||||||
],
|
|
||||||
page_size=1000,
|
|
||||||
cluster=ESCluster.NES,
|
|
||||||
):
|
|
||||||
hit_author_ids: set[str] = set()
|
|
||||||
for authorship in hit.get("_source", {}).get("authorships", []):
|
|
||||||
if not any(
|
|
||||||
_normalize_institution_id(institution.get("id")) == institution_id
|
|
||||||
for institution in authorship.get("institutions") or []
|
|
||||||
if institution.get("id")
|
|
||||||
):
|
|
||||||
continue
|
|
||||||
author = authorship.get("author") or {}
|
|
||||||
author_id = author.get("id")
|
|
||||||
if not author_id:
|
|
||||||
continue
|
|
||||||
author_id = str(author_id)
|
|
||||||
if _short_author_id(author_id) not in institution_author_ids:
|
|
||||||
continue
|
|
||||||
hit_author_ids.add(author_id)
|
|
||||||
if author.get("display_name"):
|
|
||||||
author_names.setdefault(author_id, str(author["display_name"]))
|
|
||||||
for author_id in hit_author_ids:
|
|
||||||
author_counts[author_id] += 1
|
|
||||||
|
|
||||||
ranked_authors = sorted(
|
|
||||||
(
|
|
||||||
{
|
|
||||||
"id": author_id,
|
|
||||||
"name": author_names.get(author_id, author_id),
|
|
||||||
"count": count,
|
|
||||||
}
|
|
||||||
for author_id, count in author_counts.items()
|
|
||||||
),
|
|
||||||
key=lambda author: author["count"],
|
|
||||||
reverse=True,
|
|
||||||
)
|
|
||||||
return [
|
return [
|
||||||
TopAuthor(
|
TopAuthor(
|
||||||
id=_short_author_id(author["id"]),
|
id=_short_author_id(author["id"]),
|
||||||
name=author["name"],
|
name=author["name"],
|
||||||
count=author["count"],
|
count=author["selected_works_count"],
|
||||||
)
|
)
|
||||||
for author in ranked_authors[:TOP_AUTHOR_LIMIT]
|
for author in ranked_authors[:TOP_AUTHOR_LIMIT]
|
||||||
if author["count"] > 0
|
if author["selected_works_count"] > 0
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def _works_count_in_period(author: dict[str, Any], period: DashboardPeriod) -> int:
|
||||||
|
from_year, to_year = period
|
||||||
|
return sum(
|
||||||
|
int(item.get("works_count", 0) or 0)
|
||||||
|
for item in author.get("counts_by_year", [])
|
||||||
|
if (
|
||||||
|
(from_year is None or int(item.get("year", 0) or 0) >= from_year)
|
||||||
|
and (to_year is None or int(item.get("year", 0) or 0) <= to_year)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def _safe_institution_authors(institution_id: str) -> list[dict[str, Any]]:
|
async def _safe_institution_authors(institution_id: str) -> list[dict[str, Any]]:
|
||||||
try:
|
try:
|
||||||
return await _institution_authors(institution_id)
|
return await _institution_authors(institution_id)
|
||||||
@@ -2213,9 +1998,8 @@ async def _top_patent_authors(
|
|||||||
|
|
||||||
async def _top_eu_project_publication_authors(
|
async def _top_eu_project_publication_authors(
|
||||||
institution_id: str,
|
institution_id: str,
|
||||||
|
organization_names: list[str],
|
||||||
institution_authors: list[dict[str, Any]],
|
institution_authors: list[dict[str, Any]],
|
||||||
from_year: int | None = None,
|
|
||||||
to_year: int | None = None,
|
|
||||||
) -> list[TopAuthor]:
|
) -> list[TopAuthor]:
|
||||||
institution_author_ids = {
|
institution_author_ids = {
|
||||||
author_id
|
author_id
|
||||||
@@ -2225,12 +2009,17 @@ async def _top_eu_project_publication_authors(
|
|||||||
if not institution_author_ids:
|
if not institution_author_ids:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
project_ids = await _get_eu_project_ids_from_projects_service(
|
project_page = await get_eu_organization_project_contributions(
|
||||||
institution_id,
|
organization_names=organization_names,
|
||||||
from_year=from_year,
|
projects_filtering_properties=ProjectsFilteringProperties(
|
||||||
to_year=to_year,
|
project_type=ProjectType.EU,
|
||||||
|
page=0,
|
||||||
|
size=10000,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
project_ids = [project.project_id for project in project_page.elements]
|
||||||
|
|
||||||
if not project_ids:
|
if not project_ids:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
@@ -2239,7 +2028,11 @@ async def _top_eu_project_publication_authors(
|
|||||||
body={
|
body={
|
||||||
"size": 10000,
|
"size": 10000,
|
||||||
"_source": ["projectID", "qaProcessedDoi"],
|
"_source": ["projectID", "qaProcessedDoi"],
|
||||||
"query": {"terms": {"projectID": project_ids}},
|
"query": {
|
||||||
|
"terms": {
|
||||||
|
"projectID": project_ids,
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
cluster=ESCluster.INSE,
|
cluster=ESCluster.INSE,
|
||||||
)
|
)
|
||||||
@@ -2273,83 +2066,12 @@ async def _top_eu_project_publication_authors(
|
|||||||
cluster=ESCluster.NES,
|
cluster=ESCluster.NES,
|
||||||
)
|
)
|
||||||
|
|
||||||
candidates = _openalex_work_authors_by_eu_projects(
|
return _openalex_work_authors_by_eu_projects(
|
||||||
works_response,
|
works_response,
|
||||||
doi_project_ids,
|
doi_project_ids,
|
||||||
institution_id,
|
institution_id,
|
||||||
institution_author_ids,
|
institution_author_ids,
|
||||||
limit=None,
|
|
||||||
)
|
)
|
||||||
counts = await asyncio.gather(
|
|
||||||
*(
|
|
||||||
_person_eu_project_count(
|
|
||||||
candidate.id,
|
|
||||||
from_year=from_year,
|
|
||||||
to_year=to_year,
|
|
||||||
)
|
|
||||||
for candidate in candidates
|
|
||||||
if candidate.id
|
|
||||||
)
|
|
||||||
)
|
|
||||||
ranked = [
|
|
||||||
TopAuthor(id=candidate.id, name=candidate.name, count=count)
|
|
||||||
for candidate, count in zip(candidates, counts, strict=True)
|
|
||||||
]
|
|
||||||
ranked.sort(key=lambda author: (-author.count, author.name, author.id or ""))
|
|
||||||
return ranked[:TOP_AUTHOR_LIMIT]
|
|
||||||
|
|
||||||
|
|
||||||
async def _get_eu_project_ids_from_projects_service(
|
|
||||||
institution_id: str,
|
|
||||||
from_year: int | None = None,
|
|
||||||
to_year: int | None = None,
|
|
||||||
) -> list[str]:
|
|
||||||
"""Loads all organization EU project IDs from the canonical project service."""
|
|
||||||
period = _dashboard_period(from_year, to_year)
|
|
||||||
page_size = 1000
|
|
||||||
page_number = 0
|
|
||||||
project_ids: set[str] = set()
|
|
||||||
|
|
||||||
while True:
|
|
||||||
projects = await projects_service.search_eu_cordis_projects(
|
|
||||||
institutions_search_client=InstitutionsSearchClient(),
|
|
||||||
raw_oa_institution_id=_raw_institution_id(institution_id),
|
|
||||||
author_id=None,
|
|
||||||
author_ids=None,
|
|
||||||
organization_ids=None,
|
|
||||||
organization_names=None,
|
|
||||||
project_types=list(EuCordisProjectType),
|
|
||||||
keywords=None,
|
|
||||||
topic_ids=None,
|
|
||||||
filter_topic_ids=None,
|
|
||||||
title=None,
|
|
||||||
funding_start_years=(
|
|
||||||
[str(year) for year in range(1900, period[1] + 1)]
|
|
||||||
if period[1] is not None
|
|
||||||
else None
|
|
||||||
),
|
|
||||||
funding_end_years=(
|
|
||||||
[str(year) for year in range(period[0], 2101)]
|
|
||||||
if period[0] is not None
|
|
||||||
else None
|
|
||||||
),
|
|
||||||
countries=None,
|
|
||||||
framework_programmes=None,
|
|
||||||
funding_schemes=None,
|
|
||||||
statuses=None,
|
|
||||||
page=page_number,
|
|
||||||
size=page_size,
|
|
||||||
sort_by="id",
|
|
||||||
sort_direction="asc",
|
|
||||||
fuzzy=False,
|
|
||||||
skip_enrichment=True,
|
|
||||||
)
|
|
||||||
project_ids.update(project.id for project in projects.elements if project.id)
|
|
||||||
if len(project_ids) >= projects.total or not projects.elements:
|
|
||||||
break
|
|
||||||
page_number += 1
|
|
||||||
|
|
||||||
return sorted(project_ids)
|
|
||||||
|
|
||||||
|
|
||||||
def _cordis_publication_doi_project_ids(
|
def _cordis_publication_doi_project_ids(
|
||||||
@@ -2386,7 +2108,6 @@ def _openalex_work_authors_by_eu_projects(
|
|||||||
doi_project_ids: dict[str, set[str]],
|
doi_project_ids: dict[str, set[str]],
|
||||||
institution_id: str,
|
institution_id: str,
|
||||||
institution_author_ids: set[str],
|
institution_author_ids: set[str],
|
||||||
limit: int | None = TOP_AUTHOR_LIMIT,
|
|
||||||
) -> list[TopAuthor]:
|
) -> list[TopAuthor]:
|
||||||
# Count unique CORDIS projects per author, not publications. Multiple works
|
# Count unique CORDIS projects per author, not publications. Multiple works
|
||||||
# (and therefore multiple DOIs) can belong to the same project ID.
|
# (and therefore multiple DOIs) can belong to the same project ID.
|
||||||
@@ -2422,58 +2143,14 @@ def _openalex_work_authors_by_eu_projects(
|
|||||||
key=lambda item: (-len(item[1]), author_names.get(item[0], ""), item[0]),
|
key=lambda item: (-len(item[1]), author_names.get(item[0], ""), item[0]),
|
||||||
)
|
)
|
||||||
|
|
||||||
authors = [
|
return [
|
||||||
TopAuthor(
|
TopAuthor(
|
||||||
id=_short_author_id(author_id),
|
id=_short_author_id(author_id),
|
||||||
name=author_names[author_id],
|
name=author_names[author_id],
|
||||||
count=len(project_ids),
|
count=len(project_ids),
|
||||||
)
|
)
|
||||||
for author_id, project_ids in ranked_authors
|
for author_id, project_ids in ranked_authors[:TOP_AUTHOR_LIMIT]
|
||||||
]
|
]
|
||||||
return authors[:limit] if limit is not None else authors
|
|
||||||
|
|
||||||
|
|
||||||
async def _person_eu_project_count(
|
|
||||||
author_id: str,
|
|
||||||
from_year: int | None = None,
|
|
||||||
to_year: int | None = None,
|
|
||||||
) -> int:
|
|
||||||
"""Uses the same author-only EU project search as the person detail page."""
|
|
||||||
period = _dashboard_period(from_year, to_year)
|
|
||||||
projects = await projects_service.search_eu_cordis_projects(
|
|
||||||
page=0,
|
|
||||||
size=1,
|
|
||||||
project_types=None,
|
|
||||||
raw_oa_institution_id=None,
|
|
||||||
institutions_search_client=None,
|
|
||||||
author_id=_short_author_id(author_id),
|
|
||||||
author_ids=None,
|
|
||||||
organization_ids=None,
|
|
||||||
organization_names=None,
|
|
||||||
keywords=None,
|
|
||||||
topic_ids=None,
|
|
||||||
filter_topic_ids=None,
|
|
||||||
title=None,
|
|
||||||
funding_start_years=(
|
|
||||||
[str(year) for year in range(1900, period[1] + 1)]
|
|
||||||
if period[1] is not None
|
|
||||||
else None
|
|
||||||
),
|
|
||||||
funding_end_years=(
|
|
||||||
[str(year) for year in range(period[0], 2101)]
|
|
||||||
if period[0] is not None
|
|
||||||
else None
|
|
||||||
),
|
|
||||||
countries=None,
|
|
||||||
framework_programmes=None,
|
|
||||||
funding_schemes=None,
|
|
||||||
statuses=None,
|
|
||||||
sort_by="title",
|
|
||||||
sort_direction="asc",
|
|
||||||
fuzzy=False,
|
|
||||||
skip_enrichment=True,
|
|
||||||
)
|
|
||||||
return projects.total
|
|
||||||
|
|
||||||
|
|
||||||
def _normalize_author_id(value: Any) -> str | None:
|
def _normalize_author_id(value: Any) -> str | None:
|
||||||
|
|||||||
@@ -10,14 +10,7 @@ from inse import config
|
|||||||
from inse.auth.model import AccessToken, Organization, UserRole
|
from inse.auth.model import AccessToken, Organization, UserRole
|
||||||
from inse.dashboard.service import (
|
from inse.dashboard.service import (
|
||||||
_openalex_work_authors_by_eu_projects,
|
_openalex_work_authors_by_eu_projects,
|
||||||
_get_dfg_project_ids_from_projects_service,
|
|
||||||
_reconcile_project_status_counts,
|
|
||||||
get_dashboard_bmbf_projects,
|
|
||||||
get_dashboard_dfg_projects,
|
|
||||||
get_dashboard_eu_projects,
|
|
||||||
get_dashboard_organization,
|
get_dashboard_organization,
|
||||||
get_dashboard_persons,
|
|
||||||
get_dashboard_publications,
|
|
||||||
get_dashboard_statistics,
|
get_dashboard_statistics,
|
||||||
get_top_authors,
|
get_top_authors,
|
||||||
get_topic_heatmap,
|
get_topic_heatmap,
|
||||||
@@ -25,16 +18,6 @@ from inse.dashboard.service import (
|
|||||||
)
|
)
|
||||||
from inse.model import ESCluster, ESIndex
|
from inse.model import ESCluster, ESIndex
|
||||||
from inse.models.openalex.institution import Institution
|
from inse.models.openalex.institution import Institution
|
||||||
from inse.models.openalex.meta import Meta
|
|
||||||
from inse.persons.model import CustomAuthorsListResponse
|
|
||||||
from inse.projects.model import (
|
|
||||||
BundProjectPage,
|
|
||||||
DfgProjectPage,
|
|
||||||
DfgProjectSummary,
|
|
||||||
EuCordisProjectSearchPage,
|
|
||||||
EuCordisProjectSummary,
|
|
||||||
EuCordisProjectType,
|
|
||||||
)
|
|
||||||
|
|
||||||
ORG_INSTITUTION_ID = "https://openalex.org/I123"
|
ORG_INSTITUTION_ID = "https://openalex.org/I123"
|
||||||
|
|
||||||
@@ -44,47 +27,6 @@ def anyio_backend():
|
|||||||
return "asyncio"
|
return "asyncio"
|
||||||
|
|
||||||
|
|
||||||
def test_project_status_counts_match_authoritative_total():
|
|
||||||
assert _reconcile_project_status_counts(12, 4, 1, 5) == (6, 1, 5)
|
|
||||||
assert _reconcile_project_status_counts(7, 4, 2, 3) == (2, 2, 3)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.anyio
|
|
||||||
async def test_dfg_topic_project_ids_use_paginated_projects_service():
|
|
||||||
pages = [
|
|
||||||
DfgProjectPage(
|
|
||||||
elements=[DfgProjectSummary(id="101"), DfgProjectSummary(id="102")],
|
|
||||||
total=3,
|
|
||||||
page=0,
|
|
||||||
size=1000,
|
|
||||||
),
|
|
||||||
DfgProjectPage(
|
|
||||||
elements=[DfgProjectSummary(id="103")],
|
|
||||||
total=3,
|
|
||||||
page=1,
|
|
||||||
size=1000,
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
||||||
with patch(
|
|
||||||
"inse.dashboard.service.projects_service.get_dfg_projects_by_author_id",
|
|
||||||
new=AsyncMock(side_effect=pages),
|
|
||||||
) as mocked_get_projects:
|
|
||||||
project_ids = await _get_dfg_project_ids_from_projects_service(
|
|
||||||
ORG_INSTITUTION_ID,
|
|
||||||
from_year=2020,
|
|
||||||
to_year=2022,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert project_ids == ["101", "102", "103"]
|
|
||||||
assert mocked_get_projects.await_count == 2
|
|
||||||
first_call = mocked_get_projects.await_args_list[0]
|
|
||||||
assert first_call.kwargs["raw_oa_institution_id"] == "I123"
|
|
||||||
assert first_call.kwargs["skip_enrichment"] is True
|
|
||||||
assert first_call.kwargs["funding_start_years"][-1] == "2022"
|
|
||||||
assert first_call.kwargs["funding_end_years"][0] == "2020"
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.anyio
|
@pytest.mark.anyio
|
||||||
async def test_dashboard_statistics_counts_organization_data_and_all_projects():
|
async def test_dashboard_statistics_counts_organization_data_and_all_projects():
|
||||||
async def search(**kwargs):
|
async def search(**kwargs):
|
||||||
@@ -142,33 +84,6 @@ async def test_dashboard_statistics_counts_organization_data_and_all_projects():
|
|||||||
display_name_alternatives=["Example Universität"],
|
display_name_alternatives=["Example Universität"],
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
), patch(
|
|
||||||
"inse.dashboard.service.projects_service.get_dfg_projects_by_author_id",
|
|
||||||
new=AsyncMock(
|
|
||||||
return_value=DfgProjectPage(elements=[], total=3, page=0, size=1)
|
|
||||||
),
|
|
||||||
), patch(
|
|
||||||
"inse.dashboard.service.projects_service.search_eu_cordis_projects",
|
|
||||||
new=AsyncMock(
|
|
||||||
return_value=EuCordisProjectSearchPage(
|
|
||||||
elements=[], total=10, page=0, size=1
|
|
||||||
)
|
|
||||||
),
|
|
||||||
), patch(
|
|
||||||
"inse.dashboard.service.projects_service.search_bund_projects_with_filters",
|
|
||||||
new=AsyncMock(
|
|
||||||
return_value=BundProjectPage(elements=[], total=5, page=0, size=1)
|
|
||||||
),
|
|
||||||
), patch(
|
|
||||||
"inse.dashboard.service.persons_service.search_persons_list",
|
|
||||||
new=AsyncMock(
|
|
||||||
return_value=CustomAuthorsListResponse(
|
|
||||||
results=[], meta=Meta(count=35, page=1, per_page=1)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
), patch(
|
|
||||||
"inse.dashboard.service.institutions_v2_service.get_institution_by_id_or_raise",
|
|
||||||
new=AsyncMock(return_value=Institution(id=ORG_INSTITUTION_ID, works_count=120)),
|
|
||||||
):
|
):
|
||||||
result = await get_dashboard_statistics(
|
result = await get_dashboard_statistics(
|
||||||
ORG_INSTITUTION_ID,
|
ORG_INSTITUTION_ID,
|
||||||
@@ -186,162 +101,64 @@ async def test_dashboard_statistics_counts_organization_data_and_all_projects():
|
|||||||
"bmbf_projects": 5,
|
"bmbf_projects": 5,
|
||||||
}
|
}
|
||||||
|
|
||||||
@pytest.mark.anyio
|
publication_call = next(
|
||||||
async def test_dashboard_publications_counts_matching_openalex_works():
|
call
|
||||||
with patch(
|
for call in mocked_search.await_args_list
|
||||||
"inse.dashboard.service.elasticsearch.search",
|
if call.kwargs["index"] == config.settings.openalex_works_search_index
|
||||||
new=AsyncMock(
|
)
|
||||||
side_effect=[
|
assert publication_call.kwargs["query"]["nested"]["query"]["term"] == {
|
||||||
{"hits": {"total": {"value": 250}}},
|
"authorships.institutions.id": ORG_INSTITUTION_ID
|
||||||
{"hits": {"total": {"value": 22}}},
|
}
|
||||||
|
|
||||||
|
person_call = next(
|
||||||
|
call
|
||||||
|
for call in mocked_search.await_args_list
|
||||||
|
if call.kwargs["index"] == ESIndex.OPENALEX_AUTHORS
|
||||||
|
)
|
||||||
|
person_query = person_call.kwargs["query"]
|
||||||
|
affiliation = person_query["bool"]["should"][0]["bool"]["filter"][1]
|
||||||
|
|
||||||
|
assert affiliation["nested"]["path"] == "affiliations"
|
||||||
|
assert affiliation["nested"]["query"]["bool"]["filter"][0] == {
|
||||||
|
"term": {"affiliations.institution.id": ORG_INSTITUTION_ID}
|
||||||
|
}
|
||||||
|
eu_call = next(
|
||||||
|
call
|
||||||
|
for call in mocked_search.await_args_list
|
||||||
|
if call.kwargs["index"] == ESIndex.CORDIS_EU_ORGANIZATIONS_WILDCARD
|
||||||
|
)
|
||||||
|
assert eu_call.kwargs["cluster"] == ESCluster.INSE
|
||||||
|
assert eu_call.kwargs["body"]["query"] == {
|
||||||
|
"terms": {
|
||||||
|
"name.keyword": [
|
||||||
|
"EXAMPLE ORG",
|
||||||
|
"EXAMPLE UNI",
|
||||||
|
"EXAMPLE UNIVERSITY",
|
||||||
]
|
]
|
||||||
),
|
|
||||||
) as mocked_search:
|
|
||||||
all_time = await get_dashboard_publications(
|
|
||||||
ORG_INSTITUTION_ID,
|
|
||||||
"Example Org",
|
|
||||||
)
|
|
||||||
selected_period = await get_dashboard_publications(
|
|
||||||
ORG_INSTITUTION_ID,
|
|
||||||
"Example Org",
|
|
||||||
from_year=2021,
|
|
||||||
to_year=2022,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert all_time.value == 250
|
|
||||||
assert selected_period.value == 22
|
|
||||||
all_time_body = mocked_search.await_args_list[0].kwargs["body"]
|
|
||||||
selected_period_body = mocked_search.await_args_list[1].kwargs["body"]
|
|
||||||
assert mocked_search.await_args_list[0].kwargs["index"] == (
|
|
||||||
ESIndex.OPENALEX_WORKS_WILDCARD
|
|
||||||
)
|
|
||||||
assert all_time_body["track_total_hits"] is True
|
|
||||||
assert all_time_body["query"]["bool"]["must"] == [
|
|
||||||
{
|
|
||||||
"nested": {
|
|
||||||
"path": "authorships",
|
|
||||||
"query": {
|
|
||||||
"nested": {
|
|
||||||
"path": "authorships.institutions",
|
|
||||||
"query": {
|
|
||||||
"terms": {
|
|
||||||
"authorships.institutions.id": [ORG_INSTITUTION_ID]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
}
|
||||||
assert selected_period_body["query"]["bool"]["must"] == [
|
|
||||||
all_time_body["query"]["bool"]["must"][0],
|
|
||||||
{"terms": {"publication_year": [2021, 2022]}},
|
|
||||||
]
|
|
||||||
|
|
||||||
|
bund_call = next(
|
||||||
@pytest.mark.anyio
|
call
|
||||||
async def test_dashboard_persons_uses_persons_service_for_organization():
|
for call in mocked_search.await_args_list
|
||||||
response = CustomAuthorsListResponse(
|
if call.kwargs["index"] == ESIndex.PROJECTS_BUND_V1
|
||||||
results=[], meta=Meta(count=64, page=1, per_page=1)
|
|
||||||
)
|
)
|
||||||
|
assert bund_call.kwargs["cluster"] == ESCluster.INSE
|
||||||
|
assert bund_call.kwargs["query"]["bool"]["minimum_should_match"] == 1
|
||||||
|
assert bund_call.kwargs["query"]["bool"]["should"][0]["match"] == {
|
||||||
|
"Zuwendungsempfänger": {
|
||||||
|
"query": "Example Org",
|
||||||
|
"operator": "and",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
with patch(
|
dfg_calls = [
|
||||||
"inse.dashboard.service.persons_service.search_persons_list",
|
call
|
||||||
new=AsyncMock(return_value=response),
|
for call in mocked_search.await_args_list
|
||||||
) as mocked_search_persons:
|
if call.kwargs["index"] == ESIndex.DFG_INSTITUTES_V2
|
||||||
result = await get_dashboard_persons(
|
]
|
||||||
ORG_INSTITUTION_ID,
|
assert len(dfg_calls) == 2
|
||||||
"Example Org",
|
assert all(call.kwargs["cluster"] == ESCluster.INSE for call in dfg_calls)
|
||||||
from_year=2020,
|
|
||||||
to_year=2023,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result.value == 64
|
|
||||||
call = mocked_search_persons.await_args
|
|
||||||
assert call.kwargs["institution_id"] == ORG_INSTITUTION_ID
|
|
||||||
assert call.kwargs["filter_mode"] == "between"
|
|
||||||
assert call.kwargs["filter_year"] == 2020
|
|
||||||
assert call.kwargs["filter_year_to"] == 2023
|
|
||||||
assert call.kwargs["page"] == 1
|
|
||||||
assert call.kwargs["page_size"] == 1
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.anyio
|
|
||||||
async def test_dashboard_dfg_projects_uses_projects_service_total():
|
|
||||||
project_page = DfgProjectPage(elements=[], total=42, page=0, size=1)
|
|
||||||
|
|
||||||
with patch(
|
|
||||||
"inse.dashboard.service.projects_service.get_dfg_projects_by_author_id",
|
|
||||||
new=AsyncMock(return_value=project_page),
|
|
||||||
) as mocked_get_projects:
|
|
||||||
result = await get_dashboard_dfg_projects(
|
|
||||||
ORG_INSTITUTION_ID,
|
|
||||||
"Example Org",
|
|
||||||
from_year=2020,
|
|
||||||
to_year=2022,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result.value == 42
|
|
||||||
mocked_get_projects.assert_awaited_once()
|
|
||||||
call = mocked_get_projects.await_args
|
|
||||||
assert call.kwargs["raw_oa_institution_id"] == "I123"
|
|
||||||
assert call.kwargs["funding_start_years"][-1] == "2022"
|
|
||||||
assert call.kwargs["funding_end_years"][0] == "2020"
|
|
||||||
assert call.kwargs["page"] == 0
|
|
||||||
assert call.kwargs["size"] == 1
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.anyio
|
|
||||||
async def test_dashboard_bmbf_projects_uses_projects_service_total():
|
|
||||||
project_page = BundProjectPage(elements=[], total=29, page=0, size=1)
|
|
||||||
|
|
||||||
with patch(
|
|
||||||
"inse.dashboard.service.projects_service.search_bund_projects_with_filters",
|
|
||||||
new=AsyncMock(return_value=project_page),
|
|
||||||
) as mocked_get_projects:
|
|
||||||
result = await get_dashboard_bmbf_projects(
|
|
||||||
ORG_INSTITUTION_ID,
|
|
||||||
"Example Org",
|
|
||||||
from_year=2018,
|
|
||||||
to_year=2020,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result.value == 29
|
|
||||||
mocked_get_projects.assert_awaited_once()
|
|
||||||
call = mocked_get_projects.await_args
|
|
||||||
assert call.kwargs["raw_oa_institution_id"] == "I123"
|
|
||||||
assert call.kwargs["funding_start_years"][-1] == "2020"
|
|
||||||
assert call.kwargs["funding_end_years"][0] == "2018"
|
|
||||||
assert call.kwargs["page"] == 0
|
|
||||||
assert call.kwargs["size"] == 1
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.anyio
|
|
||||||
async def test_dashboard_eu_projects_uses_projects_service_total():
|
|
||||||
project_page = EuCordisProjectSearchPage(
|
|
||||||
elements=[], total=37, page=0, size=1
|
|
||||||
)
|
|
||||||
|
|
||||||
with patch(
|
|
||||||
"inse.dashboard.service.projects_service.search_eu_cordis_projects",
|
|
||||||
new=AsyncMock(return_value=project_page),
|
|
||||||
) as mocked_get_projects:
|
|
||||||
result = await get_dashboard_eu_projects(
|
|
||||||
ORG_INSTITUTION_ID,
|
|
||||||
"Example Org",
|
|
||||||
from_year=2019,
|
|
||||||
to_year=2021,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result.value == 37
|
|
||||||
mocked_get_projects.assert_awaited_once()
|
|
||||||
call = mocked_get_projects.await_args
|
|
||||||
assert call.kwargs["raw_oa_institution_id"] == "I123"
|
|
||||||
assert call.kwargs["funding_start_years"][-1] == "2021"
|
|
||||||
assert call.kwargs["funding_end_years"][0] == "2019"
|
|
||||||
assert call.kwargs["project_types"] == list(EuCordisProjectType)
|
|
||||||
assert call.kwargs["page"] == 0
|
|
||||||
assert call.kwargs["size"] == 1
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.anyio
|
@pytest.mark.anyio
|
||||||
@@ -455,79 +272,23 @@ async def test_top_authors_maps_works_patents_news_and_eu_projects():
|
|||||||
|
|
||||||
return {"aggregations": {"people": {"buckets": []}}}
|
return {"aggregations": {"people": {"buckets": []}}}
|
||||||
|
|
||||||
scan_calls = []
|
|
||||||
|
|
||||||
async def scan(**kwargs):
|
|
||||||
scan_calls.append(kwargs)
|
|
||||||
yield {
|
|
||||||
"_id": "W1",
|
|
||||||
"_source": {
|
|
||||||
"id": "https://openalex.org/W1",
|
|
||||||
"authorships": [
|
|
||||||
{
|
|
||||||
"author": {
|
|
||||||
"id": "https://openalex.org/A1",
|
|
||||||
"display_name": "Ada Example",
|
|
||||||
},
|
|
||||||
"institutions": [{"id": ORG_INSTITUTION_ID}],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"author": {
|
|
||||||
"id": "https://openalex.org/A2",
|
|
||||||
"display_name": "Grace Example",
|
|
||||||
},
|
|
||||||
"institutions": [{"id": "https://openalex.org/I999"}],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
yield {
|
|
||||||
"_id": "W2",
|
|
||||||
"_source": {
|
|
||||||
"id": "https://openalex.org/W2",
|
|
||||||
"authorships": [
|
|
||||||
{
|
|
||||||
"author": {
|
|
||||||
"id": "https://openalex.org/A1",
|
|
||||||
"display_name": "Ada Example",
|
|
||||||
},
|
|
||||||
"institutions": [{"id": ORG_INSTITUTION_ID}],
|
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
async def eu_projects(**kwargs):
|
|
||||||
if kwargs.get("raw_oa_institution_id"):
|
|
||||||
return EuCordisProjectSearchPage(
|
|
||||||
elements=[
|
|
||||||
EuCordisProjectSummary(id="P1", project_type=EuCordisProjectType.FP7),
|
|
||||||
EuCordisProjectSummary(id="P2", project_type=EuCordisProjectType.H2020),
|
|
||||||
EuCordisProjectSummary(id="P3", project_type=EuCordisProjectType.HEU),
|
|
||||||
],
|
|
||||||
total=3,
|
|
||||||
page=0,
|
|
||||||
size=1000,
|
|
||||||
)
|
|
||||||
return EuCordisProjectSearchPage(
|
|
||||||
elements=[],
|
|
||||||
total={"A1": 3, "A2": 4}[kwargs["author_id"]],
|
|
||||||
page=0,
|
|
||||||
size=1,
|
|
||||||
)
|
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"inse.dashboard.service.elasticsearch.search",
|
"inse.dashboard.service.elasticsearch.search",
|
||||||
new=AsyncMock(side_effect=search),
|
new=AsyncMock(side_effect=search),
|
||||||
) as mocked_search, patch(
|
) as mocked_search, patch(
|
||||||
"inse.dashboard.service.elasticsearch.scan",
|
|
||||||
new=scan,
|
|
||||||
), patch(
|
|
||||||
"inse.dashboard.service.InstitutionsSearchClient.get_institution_aliases_by_oa_institution_id",
|
"inse.dashboard.service.InstitutionsSearchClient.get_institution_aliases_by_oa_institution_id",
|
||||||
new=AsyncMock(return_value=["Example University"]),
|
new=AsyncMock(return_value=["Example University"]),
|
||||||
), patch(
|
), patch(
|
||||||
"inse.dashboard.service.projects_service.search_eu_cordis_projects",
|
"inse.dashboard.service.get_eu_organization_project_contributions",
|
||||||
new=AsyncMock(side_effect=eu_projects),
|
new=AsyncMock(
|
||||||
|
return_value=SimpleNamespace(
|
||||||
|
elements=[
|
||||||
|
SimpleNamespace(project_id="P1"),
|
||||||
|
SimpleNamespace(project_id="P2"),
|
||||||
|
SimpleNamespace(project_id="P3"),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
),
|
||||||
), patch(
|
), patch(
|
||||||
"inse.dashboard.service.OrgPatentsSearchClient.top_authors_by_institution",
|
"inse.dashboard.service.OrgPatentsSearchClient.top_authors_by_institution",
|
||||||
new=AsyncMock(
|
new=AsyncMock(
|
||||||
@@ -544,17 +305,16 @@ async def test_top_authors_maps_works_patents_news_and_eu_projects():
|
|||||||
assert result.works[0].model_dump() == {
|
assert result.works[0].model_dump() == {
|
||||||
"id": "A1",
|
"id": "A1",
|
||||||
"name": "Ada Example",
|
"name": "Ada Example",
|
||||||
"count": 2,
|
"count": 42,
|
||||||
}
|
}
|
||||||
assert len(result.works) == 1
|
|
||||||
assert result.patents[0].model_dump() == {
|
assert result.patents[0].model_dump() == {
|
||||||
"id": "A1",
|
"id": "A1",
|
||||||
"name": "Ada Example",
|
"name": "Ada Example",
|
||||||
"count": 4,
|
"count": 4,
|
||||||
}
|
}
|
||||||
assert [author.model_dump() for author in result.eu_projects] == [
|
assert [author.model_dump() for author in result.eu_projects] == [
|
||||||
{"id": "A2", "name": "Grace Example", "count": 4},
|
{"id": "A2", "name": "Grace Example", "count": 2},
|
||||||
{"id": "A1", "name": "Ada Example", "count": 3},
|
{"id": "A1", "name": "Ada Example", "count": 1},
|
||||||
]
|
]
|
||||||
assert result.news[0].model_dump() == {
|
assert result.news[0].model_dump() == {
|
||||||
"id": "A1",
|
"id": "A1",
|
||||||
@@ -586,44 +346,18 @@ async def test_top_authors_maps_works_patents_news_and_eu_projects():
|
|||||||
assert eu_body["_source"] == ["projectID", "qaProcessedDoi"]
|
assert eu_body["_source"] == ["projectID", "qaProcessedDoi"]
|
||||||
assert "aggs" not in eu_body
|
assert "aggs" not in eu_body
|
||||||
|
|
||||||
assert len(scan_calls) == 1
|
works_calls = [
|
||||||
assert scan_calls[0]["index"] == str(ESIndex.OPENALEX_WORKS_WILDCARD)
|
|
||||||
assert scan_calls[0]["query"]["bool"]["must"] == [
|
|
||||||
{
|
|
||||||
"nested": {
|
|
||||||
"path": "authorships",
|
|
||||||
"query": {
|
|
||||||
"nested": {
|
|
||||||
"path": "authorships.institutions",
|
|
||||||
"query": {
|
|
||||||
"terms": {
|
|
||||||
"authorships.institutions.id": [ORG_INSTITUTION_ID]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
assert scan_calls[0]["source"] == [
|
|
||||||
"id",
|
|
||||||
"authorships.author.id",
|
|
||||||
"authorships.author.display_name",
|
|
||||||
"authorships.institutions.id",
|
|
||||||
]
|
|
||||||
|
|
||||||
eu_work_calls = [
|
|
||||||
call
|
call
|
||||||
for call in mocked_search.await_args_list
|
for call in mocked_search.await_args_list
|
||||||
if call.kwargs["index"] == "openalex-works"
|
if call.kwargs["index"] == "openalex-works"
|
||||||
]
|
]
|
||||||
assert len(eu_work_calls) == 1
|
assert len(works_calls) == 1
|
||||||
eu_works_body = eu_work_calls[0].kwargs["body"]
|
works_body = works_calls[0].kwargs["body"]
|
||||||
assert eu_works_body["query"]["bool"]["filter"][0]["terms"]["doi"] == [
|
assert works_body["query"]["bool"]["filter"][0]["terms"]["doi"] == [
|
||||||
"https://doi.org/10.1234/p1",
|
"https://doi.org/10.1234/p1",
|
||||||
"https://doi.org/10.1234/p2",
|
"https://doi.org/10.1234/p2",
|
||||||
]
|
]
|
||||||
assert eu_works_body["_source"] == [
|
assert works_body["_source"] == [
|
||||||
"doi",
|
"doi",
|
||||||
"authorships.author.id",
|
"authorships.author.id",
|
||||||
"authorships.author.display_name",
|
"authorships.author.display_name",
|
||||||
@@ -839,24 +573,6 @@ async def test_top_eu_project_authors_count_filtered_projects_by_stable_author_i
|
|||||||
}
|
}
|
||||||
return {"aggregations": {"authors": {"buckets": []}}}
|
return {"aggregations": {"authors": {"buckets": []}}}
|
||||||
|
|
||||||
async def eu_projects(**kwargs):
|
|
||||||
if kwargs.get("raw_oa_institution_id"):
|
|
||||||
return EuCordisProjectSearchPage(
|
|
||||||
elements=[
|
|
||||||
EuCordisProjectSummary(id="P1", project_type=EuCordisProjectType.FP7),
|
|
||||||
EuCordisProjectSummary(id="P2", project_type=EuCordisProjectType.H2020),
|
|
||||||
],
|
|
||||||
total=2,
|
|
||||||
page=0,
|
|
||||||
size=1000,
|
|
||||||
)
|
|
||||||
return EuCordisProjectSearchPage(
|
|
||||||
elements=[],
|
|
||||||
total={"A1": 4, "A2": 1}[kwargs["author_id"]],
|
|
||||||
page=0,
|
|
||||||
size=1,
|
|
||||||
)
|
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"inse.dashboard.service.elasticsearch.search",
|
"inse.dashboard.service.elasticsearch.search",
|
||||||
new=AsyncMock(side_effect=search),
|
new=AsyncMock(side_effect=search),
|
||||||
@@ -864,8 +580,15 @@ async def test_top_eu_project_authors_count_filtered_projects_by_stable_author_i
|
|||||||
"inse.dashboard.service.InstitutionsSearchClient.get_institution_aliases_by_oa_institution_id",
|
"inse.dashboard.service.InstitutionsSearchClient.get_institution_aliases_by_oa_institution_id",
|
||||||
new=AsyncMock(return_value=["Example University"]),
|
new=AsyncMock(return_value=["Example University"]),
|
||||||
), patch(
|
), patch(
|
||||||
"inse.dashboard.service.projects_service.search_eu_cordis_projects",
|
"inse.dashboard.service.get_eu_organization_project_contributions",
|
||||||
new=AsyncMock(side_effect=eu_projects),
|
new=AsyncMock(
|
||||||
|
return_value=SimpleNamespace(
|
||||||
|
elements=[
|
||||||
|
SimpleNamespace(project_id="P1"),
|
||||||
|
SimpleNamespace(project_id="P2"),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
),
|
||||||
), patch(
|
), patch(
|
||||||
"inse.dashboard.service.OrgPatentsSearchClient.top_authors_by_institution",
|
"inse.dashboard.service.OrgPatentsSearchClient.top_authors_by_institution",
|
||||||
new=AsyncMock(return_value=[]),
|
new=AsyncMock(return_value=[]),
|
||||||
@@ -876,7 +599,7 @@ async def test_top_eu_project_authors_count_filtered_projects_by_stable_author_i
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert [author.model_dump() for author in result.eu_projects] == [
|
assert [author.model_dump() for author in result.eu_projects] == [
|
||||||
{"id": "A1", "name": "Ada Example", "count": 4},
|
{"id": "A1", "name": "Ada Example", "count": 2},
|
||||||
{"id": "A2", "name": "Grace Example", "count": 1},
|
{"id": "A2", "name": "Grace Example", "count": 1},
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -902,29 +625,9 @@ async def test_top_authors_returns_partial_response_when_one_source_fails():
|
|||||||
|
|
||||||
raise RuntimeError("projects unavailable")
|
raise RuntimeError("projects unavailable")
|
||||||
|
|
||||||
async def scan(**kwargs):
|
|
||||||
yield {
|
|
||||||
"_id": "W1",
|
|
||||||
"_source": {
|
|
||||||
"id": "https://openalex.org/W1",
|
|
||||||
"authorships": [
|
|
||||||
{
|
|
||||||
"author": {
|
|
||||||
"id": "https://openalex.org/A1",
|
|
||||||
"display_name": "Ada Example",
|
|
||||||
},
|
|
||||||
"institutions": [{"id": ORG_INSTITUTION_ID}],
|
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"inse.dashboard.service.elasticsearch.search",
|
"inse.dashboard.service.elasticsearch.search",
|
||||||
new=AsyncMock(side_effect=search),
|
new=AsyncMock(side_effect=search),
|
||||||
), patch(
|
|
||||||
"inse.dashboard.service.elasticsearch.scan",
|
|
||||||
new=scan,
|
|
||||||
), patch(
|
), patch(
|
||||||
"inse.dashboard.service.InstitutionsSearchClient.get_institution_aliases_by_oa_institution_id",
|
"inse.dashboard.service.InstitutionsSearchClient.get_institution_aliases_by_oa_institution_id",
|
||||||
new=AsyncMock(return_value=["Example University"]),
|
new=AsyncMock(return_value=["Example University"]),
|
||||||
@@ -988,47 +691,9 @@ async def test_top_authors_can_rank_works_by_last_five_years():
|
|||||||
}
|
}
|
||||||
return {"aggregations": {"people": {"buckets": []}}}
|
return {"aggregations": {"people": {"buckets": []}}}
|
||||||
|
|
||||||
scan_calls = []
|
|
||||||
|
|
||||||
async def scan(**kwargs):
|
|
||||||
scan_calls.append(kwargs)
|
|
||||||
for index in range(16):
|
|
||||||
yield {
|
|
||||||
"_id": f"W-grace-{index}",
|
|
||||||
"_source": {
|
|
||||||
"authorships": [
|
|
||||||
{
|
|
||||||
"author": {
|
|
||||||
"id": "https://openalex.org/A2",
|
|
||||||
"display_name": "Grace Example",
|
|
||||||
},
|
|
||||||
"institutions": [{"id": ORG_INSTITUTION_ID}],
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for index in range(2):
|
|
||||||
yield {
|
|
||||||
"_id": f"W-ada-{index}",
|
|
||||||
"_source": {
|
|
||||||
"authorships": [
|
|
||||||
{
|
|
||||||
"author": {
|
|
||||||
"id": "https://openalex.org/A1",
|
|
||||||
"display_name": "Ada Example",
|
|
||||||
},
|
|
||||||
"institutions": [{"id": ORG_INSTITUTION_ID}],
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"inse.dashboard.service.elasticsearch.search",
|
"inse.dashboard.service.elasticsearch.search",
|
||||||
new=AsyncMock(side_effect=search),
|
new=AsyncMock(side_effect=search),
|
||||||
) as mocked_search, patch(
|
|
||||||
"inse.dashboard.service.elasticsearch.scan",
|
|
||||||
new=scan,
|
|
||||||
), patch(
|
), patch(
|
||||||
"inse.dashboard.service.InstitutionsSearchClient.get_institution_aliases_by_oa_institution_id",
|
"inse.dashboard.service.InstitutionsSearchClient.get_institution_aliases_by_oa_institution_id",
|
||||||
new=AsyncMock(return_value=["Example University"]),
|
new=AsyncMock(return_value=["Example University"]),
|
||||||
@@ -1056,11 +721,6 @@ async def test_top_authors_can_rank_works_by_last_five_years():
|
|||||||
"count": 2,
|
"count": 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
assert len(scan_calls) == 1
|
|
||||||
assert scan_calls[0]["query"]["bool"]["must"][1] == {
|
|
||||||
"terms": {"publication_year": list(range(current_year - 4, current_year + 1))}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.anyio
|
@pytest.mark.anyio
|
||||||
async def test_topic_heatmap_maps_field_year_counts_and_shares():
|
async def test_topic_heatmap_maps_field_year_counts_and_shares():
|
||||||
|
|||||||
@@ -361,7 +361,6 @@ class InstitutionsSearchClient:
|
|||||||
"government",
|
"government",
|
||||||
"facility",
|
"facility",
|
||||||
"other",
|
"other",
|
||||||
"funder",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cleaned_source = {}
|
cleaned_source = {}
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ _VALID_INSTITUTION_TYPES = {
|
|||||||
"government",
|
"government",
|
||||||
"facility",
|
"facility",
|
||||||
"other",
|
"other",
|
||||||
"funder",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -174,34 +174,3 @@ async def test_list_institutions_accepts_practical_openalex_type_variants():
|
|||||||
assert result.results[0].counts_by_year[0].cited_by_count is None
|
assert result.results[0].counts_by_year[0].cited_by_count is None
|
||||||
assert result.group_by[0].key == "true"
|
assert result.group_by[0].key == "true"
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.anyio
|
|
||||||
async def test_list_institutions_accepts_funder_institution_type():
|
|
||||||
def handler(_: httpx.Request) -> httpx.Response:
|
|
||||||
return httpx.Response(
|
|
||||||
200,
|
|
||||||
json={
|
|
||||||
"meta": {"count": 1, "page": 1, "per_page": 25},
|
|
||||||
"results": [
|
|
||||||
{
|
|
||||||
"id": "https://openalex.org/I4210119759",
|
|
||||||
"display_name": "Essen University Hospital",
|
|
||||||
"country_code": "DE",
|
|
||||||
"type": "funder",
|
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
client = OpenAlexInstitutionsClient(
|
|
||||||
api_key="test-key",
|
|
||||||
transport=httpx.MockTransport(handler),
|
|
||||||
)
|
|
||||||
|
|
||||||
result = await logic.list_institutions(client=client)
|
|
||||||
|
|
||||||
assert result.results[0].id == "https://openalex.org/I4210119759"
|
|
||||||
assert result.results[0].display_name == "Essen University Hospital"
|
|
||||||
assert result.results[0].type == "funder"
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -142,55 +142,20 @@ async def autocomplete_institutions(
|
|||||||
if not query:
|
if not query:
|
||||||
return InstitutionPageV2(elements=[], total=0, page=0, size=0)
|
return InstitutionPageV2(elements=[], total=0, page=0, size=0)
|
||||||
|
|
||||||
stripped = query.strip()
|
|
||||||
fields = [("display_name", 1.0), ("display_name_alternatives", 0.8)]
|
|
||||||
should_clauses = []
|
|
||||||
for field, weight in fields:
|
|
||||||
should_clauses.extend([
|
|
||||||
{
|
|
||||||
"prefix": {
|
|
||||||
f"{field}.keyword": {
|
|
||||||
"value": stripped,
|
|
||||||
"case_insensitive": True,
|
|
||||||
"boost": 10.0 * weight,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{"match_phrase_prefix": {field: {"query": stripped, "boost": 5.0 * weight, "slop": 3}}},
|
|
||||||
{"match_bool_prefix": {field: {"query": stripped, "boost": 2.0 * weight}}},
|
|
||||||
{
|
|
||||||
"constant_score": {
|
|
||||||
"filter": {
|
|
||||||
"wildcard": {
|
|
||||||
f"{field}.keyword": {
|
|
||||||
"value": f"*{stripped}*",
|
|
||||||
"case_insensitive": True,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"boost": 1.0 * weight,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
])
|
|
||||||
|
|
||||||
return await search_institutions(
|
return await search_institutions(
|
||||||
page=page,
|
page=page,
|
||||||
size=size,
|
size=size,
|
||||||
query={
|
query={
|
||||||
"function_score": {
|
"bool": {
|
||||||
"query": {"bool": {"should": should_clauses, "minimum_should_match": 1}},
|
"should": [
|
||||||
"field_value_factor": {
|
{"match_phrase_prefix": {"display_name": query}},
|
||||||
"field": "works_count",
|
{"match_phrase_prefix": {"display_name_alternatives": query}},
|
||||||
"modifier": "log1p",
|
]
|
||||||
"factor": 0.05,
|
|
||||||
"missing": 1.0,
|
|
||||||
},
|
|
||||||
"boost_mode": "multiply",
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
source=source,
|
source=source,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def autocomplete_institutions_for_selector(
|
async def autocomplete_institutions_for_selector(
|
||||||
query: str, page: int = 0, size: int = 10
|
query: str, page: int = 0, size: int = 10
|
||||||
|
|||||||
@@ -170,6 +170,25 @@ class DfgProjectPublicationSummary(BaseModel):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class DfgProjectSubjectArea(BaseModel):
|
||||||
|
"""A single subject-area classification entry (DFG 'Fachsystematik')."""
|
||||||
|
|
||||||
|
model_config = ConfigDict(populate_by_name=True)
|
||||||
|
|
||||||
|
fach: str | None = None
|
||||||
|
fachgebiet: str | None = None
|
||||||
|
fachkollegium: str | None = None
|
||||||
|
wissenschaftsbereich: str | None = None
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_inner(cls, f: DFGProjectFachgebieteInner) -> "DfgProjectSubjectArea":
|
||||||
|
return cls(
|
||||||
|
fach=f.fach,
|
||||||
|
fachgebiet=f.fachgebiet,
|
||||||
|
fachkollegium=f.fachkollegium,
|
||||||
|
wissenschaftsbereich=f.wissenschaftsbereich,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class DfgProjectDetails(BaseModel):
|
class DfgProjectDetails(BaseModel):
|
||||||
"""
|
"""
|
||||||
@@ -234,7 +253,7 @@ class DfgProjectDetails(BaseModel):
|
|||||||
|
|
||||||
subject_area_de: str | None = Field(default=None, description="Subject area, summary text (German)")
|
subject_area_de: str | None = Field(default=None, description="Subject area, summary text (German)")
|
||||||
subject_area_en: str | None = Field(default=None, description="Subject area, summary text (English)")
|
subject_area_en: str | None = Field(default=None, description="Subject area, summary text (English)")
|
||||||
subject_classifications: list[DFGProjectFachgebieteInner] = Field(
|
subject_classifications: list[DfgProjectSubjectArea] = Field(
|
||||||
default_factory=list,
|
default_factory=list,
|
||||||
description="Detailed DFG subject-area classification entries (Fachsystematik)",
|
description="Detailed DFG subject-area classification entries (Fachsystematik)",
|
||||||
)
|
)
|
||||||
@@ -300,7 +319,7 @@ class DfgProjectDetails(BaseModel):
|
|||||||
DfgProjectPublicationSummary.from_inner(p) for p in (project.publications or [])
|
DfgProjectPublicationSummary.from_inner(p) for p in (project.publications or [])
|
||||||
]
|
]
|
||||||
subject_classifications = [
|
subject_classifications = [
|
||||||
DFGProjectFachgebieteInner.from_dict(f) for f in (project.subject_classifications or [])
|
DfgProjectSubjectArea.from_inner(f) for f in (project.fachgebiete or [])
|
||||||
]
|
]
|
||||||
|
|
||||||
# De-duplicated flat views, order-preserving
|
# De-duplicated flat views, order-preserving
|
||||||
@@ -364,6 +383,8 @@ class DfgProjectDetails(BaseModel):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_dict(cls, obj: dict) -> "DfgProjectDetails":
|
def from_dict(cls, obj: dict) -> "DfgProjectDetails":
|
||||||
|
"""Convenience constructor from a raw dict (e.g. a JSON API response body)."""
|
||||||
|
obj = cls._sanitize_raw_project_dict(obj)
|
||||||
return cls.from_dfg_project(DFGProject.from_dict(obj))
|
return cls.from_dfg_project(DFGProject.from_dict(obj))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class Institution(BaseModel):
|
|||||||
ror: StrictStr | None = Field(default=None, description="The ROR ID for this institution. This is the Canonical External ID for institutions.")
|
ror: StrictStr | None = Field(default=None, description="The ROR ID for this institution. This is the Canonical External ID for institutions.")
|
||||||
display_name: StrictStr | None = Field(default=None, description="The primary name of the institution.")
|
display_name: StrictStr | None = Field(default=None, description="The primary name of the institution.")
|
||||||
country_code: StrictStr | None = Field(default=None, description="ISO two-letter country code where this institution is located.")
|
country_code: StrictStr | None = Field(default=None, description="ISO two-letter country code where this institution is located.")
|
||||||
type: StrictStr | None = Field(default=None, description="The institution's primary type (ROR vocabulary): `Education`, `Healthcare`, `Company`, `Archive`, `Nonprofit`, `Government`, `Facility`, `Other`, `Funder`.")
|
type: StrictStr | None = Field(default=None, description="The institution's primary type (ROR vocabulary): `Education`, `Healthcare`, `Company`, `Archive`, `Nonprofit`, `Government`, `Facility`, `Other`.")
|
||||||
homepage_url: StrictStr | None = Field(default=None, description="URL for the institution's primary homepage.")
|
homepage_url: StrictStr | None = Field(default=None, description="URL for the institution's primary homepage.")
|
||||||
image_url: StrictStr | None = Field(default=None, description="URL for an image representing this institution (usually from Wikimedia).")
|
image_url: StrictStr | None = Field(default=None, description="URL for an image representing this institution (usually from Wikimedia).")
|
||||||
image_thumbnail_url: StrictStr | None = Field(default=None, description="Smaller version of `image_url`.")
|
image_thumbnail_url: StrictStr | None = Field(default=None, description="Smaller version of `image_url`.")
|
||||||
@@ -61,9 +61,8 @@ class Institution(BaseModel):
|
|||||||
if value is None:
|
if value is None:
|
||||||
return value
|
return value
|
||||||
|
|
||||||
valid_types = {'education', 'healthcare', 'company', 'archive', 'nonprofit', 'government', 'facility', 'other', 'funder'}
|
if value not in set(['education', 'healthcare', 'company', 'archive', 'nonprofit', 'government', 'facility', 'other']):
|
||||||
if value not in valid_types:
|
raise ValueError("must be one of enum values ('education', 'healthcare', 'company', 'archive', 'nonprofit', 'government', 'facility', 'other')")
|
||||||
return 'other'
|
|
||||||
return value
|
return value
|
||||||
|
|
||||||
model_config = ConfigDict(
|
model_config = ConfigDict(
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ class DFGProject(BaseModel):
|
|||||||
equipment_group: StrictStr | None = None
|
equipment_group: StrictStr | None = None
|
||||||
equipment_name: StrictStr | None = None
|
equipment_name: StrictStr | None = None
|
||||||
external_link: StrictStr | None = None
|
external_link: StrictStr | None = None
|
||||||
|
fachgebiete: list[DFGProjectFachgebieteInner] | None = None
|
||||||
fetched_at: datetime | None = None
|
fetched_at: datetime | None = None
|
||||||
final_report_abstract_de: StrictStr | None = None
|
final_report_abstract_de: StrictStr | None = None
|
||||||
final_report_abstract_en: StrictStr | None = None
|
final_report_abstract_en: StrictStr | None = None
|
||||||
@@ -80,7 +81,7 @@ class DFGProject(BaseModel):
|
|||||||
publications: list[DFGProjectPublicationsInner] | None = None
|
publications: list[DFGProjectPublicationsInner] | None = None
|
||||||
subject_area_de: StrictStr | None = None
|
subject_area_de: StrictStr | None = None
|
||||||
subject_area_en: StrictStr | None = None
|
subject_area_en: StrictStr | None = None
|
||||||
subject_classifications: list[DFGProjectFachgebieteInner] | None = None
|
subject_classifications: DFGProjectFachgebieteInner | None = None
|
||||||
subproject_order: list[StrictStr] | None = None
|
subproject_order: list[StrictStr] | None = None
|
||||||
subprojects: list[DFGProjectSubprojectsInner] | None = None
|
subprojects: list[DFGProjectSubprojectsInner] | None = None
|
||||||
template_type: StrictStr | None = None
|
template_type: StrictStr | None = None
|
||||||
@@ -89,7 +90,7 @@ class DFGProject(BaseModel):
|
|||||||
website_html_de: StrictStr | None = None
|
website_html_de: StrictStr | None = None
|
||||||
website_html_en: StrictStr | None = None
|
website_html_en: StrictStr | None = None
|
||||||
topics: list[Topic] | None = None
|
topics: list[Topic] | None = None
|
||||||
__properties: ClassVar[list[str]] = ["abstract_de", "abstract_en", "equipment_group", "equipment_name", "external_link","fetched_at", "final_report_abstract_de", "final_report_abstract_en", "funding_end", "funding_period_de", "funding_period_en", "funding_start", "funding_type_de", "funding_type_en", "funding_type_key", "funding_type_sort", "id", "institution_roles_order", "institutions", "international_relation_de", "international_relation_en", "is_transfer_project", "link", "page_url", "parent_project_id", "parent_title_de", "parent_title_en", "person_roles_order", "persons", "project", "project_id", "project_identifier_de", "project_identifier_en", "publications", "subject_area_de", "subject_area_en", "subject_classifications", "subproject_order", "subprojects", "template_type", "title_de", "title_en", "website_html_de", "website_html_en"]
|
__properties: ClassVar[list[str]] = ["abstract_de", "abstract_en", "equipment_group", "equipment_name", "external_link", "fachgebiete", "fetched_at", "final_report_abstract_de", "final_report_abstract_en", "funding_end", "funding_period_de", "funding_period_en", "funding_start", "funding_type_de", "funding_type_en", "funding_type_key", "funding_type_sort", "id", "institution_roles_order", "institutions", "international_relation_de", "international_relation_en", "is_transfer_project", "link", "page_url", "parent_project_id", "parent_title_de", "parent_title_en", "person_roles_order", "persons", "project", "project_id", "project_identifier_de", "project_identifier_en", "publications", "subject_area_de", "subject_area_en", "subject_classifications", "subproject_order", "subprojects", "template_type", "title_de", "title_en", "website_html_de", "website_html_en"]
|
||||||
|
|
||||||
model_config = ConfigDict(
|
model_config = ConfigDict(
|
||||||
validate_by_name=True,
|
validate_by_name=True,
|
||||||
@@ -130,6 +131,13 @@ class DFGProject(BaseModel):
|
|||||||
exclude=excluded_fields,
|
exclude=excluded_fields,
|
||||||
exclude_none=True,
|
exclude_none=True,
|
||||||
)
|
)
|
||||||
|
# override the default output from pydantic by calling `to_dict()` of each item in fachgebiete (list)
|
||||||
|
_items = []
|
||||||
|
if self.fachgebiete:
|
||||||
|
for _item_fachgebiete in self.fachgebiete:
|
||||||
|
if _item_fachgebiete:
|
||||||
|
_items.append(_item_fachgebiete.to_dict())
|
||||||
|
_dict['fachgebiete'] = _items
|
||||||
# override the default output from pydantic by calling `to_dict()` of each item in institutions (list)
|
# override the default output from pydantic by calling `to_dict()` of each item in institutions (list)
|
||||||
_items = []
|
_items = []
|
||||||
if self.institutions:
|
if self.institutions:
|
||||||
@@ -156,7 +164,7 @@ class DFGProject(BaseModel):
|
|||||||
_dict['publications'] = _items
|
_dict['publications'] = _items
|
||||||
# override the default output from pydantic by calling `to_dict()` of subject_classifications
|
# override the default output from pydantic by calling `to_dict()` of subject_classifications
|
||||||
if self.subject_classifications:
|
if self.subject_classifications:
|
||||||
_dict['subject_classifications'] = [f.to_dict() for f in self.subject_classifications]
|
_dict['subject_classifications'] = self.subject_classifications.to_dict()
|
||||||
# override the default output from pydantic by calling `to_dict()` of each item in subprojects (list)
|
# override the default output from pydantic by calling `to_dict()` of each item in subprojects (list)
|
||||||
_items = []
|
_items = []
|
||||||
if self.subprojects:
|
if self.subprojects:
|
||||||
@@ -183,12 +191,14 @@ class DFGProject(BaseModel):
|
|||||||
key=lambda t: t.get("rank") if t.get("rank") is not None else float("inf"),
|
key=lambda t: t.get("rank") if t.get("rank") is not None else float("inf"),
|
||||||
)
|
)
|
||||||
topics = [cls._topic_from_match(t) for t in sorted_topics_raw]
|
topics = [cls._topic_from_match(t) for t in sorted_topics_raw]
|
||||||
|
|
||||||
_obj = cls.model_validate({
|
_obj = cls.model_validate({
|
||||||
"abstract_de": obj.get("abstract_de"),
|
"abstract_de": obj.get("abstract_de"),
|
||||||
"abstract_en": obj.get("abstract_en"),
|
"abstract_en": obj.get("abstract_en"),
|
||||||
"equipment_group": obj.get("equipment_group"),
|
"equipment_group": obj.get("equipment_group"),
|
||||||
"equipment_name": obj.get("equipment_name"),
|
"equipment_name": obj.get("equipment_name"),
|
||||||
"external_link": obj.get("external_link"),
|
"external_link": obj.get("external_link"),
|
||||||
|
"fachgebiete": [DFGProjectFachgebieteInner.from_dict(_item) for _item in obj["fachgebiete"]] if obj.get("fachgebiete") is not None else None,
|
||||||
"fetched_at": obj.get("fetched_at"),
|
"fetched_at": obj.get("fetched_at"),
|
||||||
"final_report_abstract_de": obj.get("final_report_abstract_de"),
|
"final_report_abstract_de": obj.get("final_report_abstract_de"),
|
||||||
"final_report_abstract_en": obj.get("final_report_abstract_en"),
|
"final_report_abstract_en": obj.get("final_report_abstract_en"),
|
||||||
@@ -220,7 +230,7 @@ class DFGProject(BaseModel):
|
|||||||
"publications": [DFGProjectPublicationsInner.from_dict(_item) for _item in obj["publications"]] if obj.get("publications") is not None else None,
|
"publications": [DFGProjectPublicationsInner.from_dict(_item) for _item in obj["publications"]] if obj.get("publications") is not None else None,
|
||||||
"subject_area_de": obj.get("subject_area_de"),
|
"subject_area_de": obj.get("subject_area_de"),
|
||||||
"subject_area_en": obj.get("subject_area_en"),
|
"subject_area_en": obj.get("subject_area_en"),
|
||||||
"subject_classifications": [DFGProjectFachgebieteInner.from_dict(f) for f in (obj.get("subject_classifications") or [])],
|
"subject_classifications": DFGProjectFachgebieteInner.from_dict(obj["subject_classifications"]) if obj.get("subject_classifications") is not None else None,
|
||||||
"subproject_order": obj.get("subproject_order"),
|
"subproject_order": obj.get("subproject_order"),
|
||||||
"subprojects": [DFGProjectSubprojectsInner.from_dict(_item) for _item in obj["subprojects"]] if obj.get("subprojects") is not None else None,
|
"subprojects": [DFGProjectSubprojectsInner.from_dict(_item) for _item in obj["subprojects"]] if obj.get("subprojects") is not None else None,
|
||||||
"template_type": obj.get("template_type"),
|
"template_type": obj.get("template_type"),
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
"""Find patents for extracted OpenAlex keywords via IPC/CPC reverse lookup."""
|
"""Find patents for extracted OpenAlex keywords via patents_openalex_keywords index."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
@@ -31,6 +31,7 @@ from inse.patents.ipc_lookup import (
|
|||||||
)
|
)
|
||||||
from inse.patents.ipc_search_client import IpcSearchClient
|
from inse.patents.ipc_search_client import IpcSearchClient
|
||||||
from inse.patents.keywords.model import (
|
from inse.patents.keywords.model import (
|
||||||
|
KeywordEvidence,
|
||||||
KeywordPatentMappingStatus,
|
KeywordPatentMappingStatus,
|
||||||
KeywordPatentMatch,
|
KeywordPatentMatch,
|
||||||
KeywordPatentSearchDiagnostics,
|
KeywordPatentSearchDiagnostics,
|
||||||
@@ -75,7 +76,13 @@ _MIN_LEADER_RELATIVE_MASS = 0.20
|
|||||||
_MIN_LEADER_MASS_RATIO = 1.5
|
_MIN_LEADER_MASS_RATIO = 1.5
|
||||||
_TARGET_CUMULATIVE_CLUSTER_MASS = 0.75
|
_TARGET_CUMULATIVE_CLUSTER_MASS = 0.75
|
||||||
_MIN_PATENT_MATCH_SCORE = 0.50
|
_MIN_PATENT_MATCH_SCORE = 0.50
|
||||||
|
_MIN_TEXT_PATENT_MATCH_SCORE = 0.30
|
||||||
_DEFAULT_SCORE_WEIGHTS = {"ipc": 0.60, "topic": 0.25, "text": 0.15}
|
_DEFAULT_SCORE_WEIGHTS = {"ipc": 0.60, "topic": 0.25, "text": 0.15}
|
||||||
|
# When IPC mapping is abstained, score only topic + text evidence.
|
||||||
|
_TEXT_SCORE_WEIGHTS = {"ipc": 0.0, "topic": 0.45, "text": 0.55}
|
||||||
|
# Also try title/abstract search when IPC mapping produced terms but scoring
|
||||||
|
# returned no patents (empty retrieval or over-filtering).
|
||||||
|
_TEXT_SEARCH_AFTER_EMPTY_IPC = True
|
||||||
_TOPIC_SCORE_TOPIC_ID = 1.0
|
_TOPIC_SCORE_TOPIC_ID = 1.0
|
||||||
_TOPIC_SCORE_SUBFIELD = 0.7
|
_TOPIC_SCORE_SUBFIELD = 0.7
|
||||||
_TOPIC_SCORE_COMPATIBLE_FIELD = 0.3
|
_TOPIC_SCORE_COMPATIBLE_FIELD = 0.3
|
||||||
@@ -611,6 +618,12 @@ class TopicEvidence:
|
|||||||
score: float
|
score: float
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass(frozen=True)
|
||||||
|
class TextGateDecision:
|
||||||
|
accepted: bool
|
||||||
|
reason: str
|
||||||
|
|
||||||
|
|
||||||
def _compute_topic_evidence(
|
def _compute_topic_evidence(
|
||||||
patent_topics: list[MappedOpenAlexTopic],
|
patent_topics: list[MappedOpenAlexTopic],
|
||||||
keyword_topic_ids: frozenset[str],
|
keyword_topic_ids: frozenset[str],
|
||||||
@@ -689,6 +702,16 @@ def _tokenize_words(text: str) -> list[str]:
|
|||||||
return re.findall(r"[a-z0-9äöüß]+", (text or "").casefold())
|
return re.findall(r"[a-z0-9äöüß]+", (text or "").casefold())
|
||||||
|
|
||||||
|
|
||||||
|
def _contains_token_sequence(haystack: list[str], needle: list[str]) -> bool:
|
||||||
|
if not needle or len(needle) > len(haystack):
|
||||||
|
return False
|
||||||
|
width = len(needle)
|
||||||
|
for index in range(len(haystack) - width + 1):
|
||||||
|
if haystack[index : index + width] == needle:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def _token_set(tokens: list[str]) -> set[str]:
|
def _token_set(tokens: list[str]) -> set[str]:
|
||||||
return set(tokens)
|
return set(tokens)
|
||||||
|
|
||||||
@@ -712,6 +735,23 @@ def _text_search_terms(items: list[KeywordPatentSearchItem]) -> list[str]:
|
|||||||
return terms
|
return terms
|
||||||
|
|
||||||
|
|
||||||
|
def _text_search_phrases(items: list[KeywordPatentSearchItem]) -> list[str]:
|
||||||
|
"""Full phrases for ES title/abstract retrieval (text path)."""
|
||||||
|
phrases: list[str] = []
|
||||||
|
seen: set[str] = set()
|
||||||
|
for item in items:
|
||||||
|
for value in (item.keyword, item.topic_display_name):
|
||||||
|
cleaned = " ".join((value or "").strip().split())
|
||||||
|
if len(cleaned) < 3:
|
||||||
|
continue
|
||||||
|
key = cleaned.casefold()
|
||||||
|
if key in seen:
|
||||||
|
continue
|
||||||
|
seen.add(key)
|
||||||
|
phrases.append(cleaned)
|
||||||
|
return phrases
|
||||||
|
|
||||||
|
|
||||||
def _text_overlap_score(
|
def _text_overlap_score(
|
||||||
patent: model.PatentEntry,
|
patent: model.PatentEntry,
|
||||||
search_terms: list[str],
|
search_terms: list[str],
|
||||||
@@ -732,6 +772,173 @@ def _text_overlap_score(
|
|||||||
return min(hits / 3, 1.0)
|
return min(hits / 3, 1.0)
|
||||||
|
|
||||||
|
|
||||||
|
def _text_match_kind(
|
||||||
|
*,
|
||||||
|
phrase_in_title: bool,
|
||||||
|
phrase_in_abstract: bool,
|
||||||
|
full_token_match: bool,
|
||||||
|
partial_token_match: bool,
|
||||||
|
) -> str:
|
||||||
|
if phrase_in_title:
|
||||||
|
return "phrase_title"
|
||||||
|
if phrase_in_abstract:
|
||||||
|
return "phrase_abstract"
|
||||||
|
if full_token_match:
|
||||||
|
return "full_token"
|
||||||
|
if partial_token_match:
|
||||||
|
return "partial_token"
|
||||||
|
return "none"
|
||||||
|
|
||||||
|
|
||||||
|
def _collect_keyword_text_evidence(
|
||||||
|
patent: model.PatentEntry,
|
||||||
|
phrases: list[str],
|
||||||
|
search_terms: list[str],
|
||||||
|
) -> KeywordEvidence:
|
||||||
|
"""Record phrase / full-token / partial-token evidence separately."""
|
||||||
|
title_tokens = _tokenize_words(patent.title or "")
|
||||||
|
abstract_tokens = _tokenize_words(patent.abstract or "")
|
||||||
|
combined_tokens = _token_set(title_tokens + abstract_tokens)
|
||||||
|
|
||||||
|
phrase_in_title = False
|
||||||
|
phrase_in_abstract = False
|
||||||
|
full_token_match = False
|
||||||
|
partial_token_match = False
|
||||||
|
matched_phrases: list[str] = []
|
||||||
|
|
||||||
|
for phrase in phrases:
|
||||||
|
phrase_tokens = _tokenize_words(phrase)
|
||||||
|
if not phrase_tokens:
|
||||||
|
continue
|
||||||
|
if _contains_token_sequence(title_tokens, phrase_tokens):
|
||||||
|
phrase_in_title = True
|
||||||
|
matched_phrases.append(phrase)
|
||||||
|
elif _contains_token_sequence(abstract_tokens, phrase_tokens):
|
||||||
|
phrase_in_abstract = True
|
||||||
|
matched_phrases.append(phrase)
|
||||||
|
|
||||||
|
present = [token for token in phrase_tokens if token in combined_tokens]
|
||||||
|
if present and len(present) == len(phrase_tokens):
|
||||||
|
full_token_match = True
|
||||||
|
elif present:
|
||||||
|
partial_token_match = True
|
||||||
|
|
||||||
|
matched_words = [term for term in search_terms if term in combined_tokens]
|
||||||
|
if matched_words and not full_token_match and not partial_token_match:
|
||||||
|
# Lone search-term hits without a covering phrase count as partial.
|
||||||
|
partial_token_match = True
|
||||||
|
|
||||||
|
word_match_score = (
|
||||||
|
min(len(matched_words) / 3, 1.0) if search_terms and matched_words else 0.0
|
||||||
|
)
|
||||||
|
kind = _text_match_kind(
|
||||||
|
phrase_in_title=phrase_in_title,
|
||||||
|
phrase_in_abstract=phrase_in_abstract,
|
||||||
|
full_token_match=full_token_match,
|
||||||
|
partial_token_match=partial_token_match,
|
||||||
|
)
|
||||||
|
|
||||||
|
return KeywordEvidence(
|
||||||
|
phrase_in_title=phrase_in_title,
|
||||||
|
phrase_in_abstract=phrase_in_abstract,
|
||||||
|
full_token_match=full_token_match,
|
||||||
|
partial_token_match=partial_token_match,
|
||||||
|
word_match_score=round(word_match_score, 4),
|
||||||
|
matched_phrases=list(dict.fromkeys(matched_phrases)),
|
||||||
|
matched_words=matched_words,
|
||||||
|
text_match_kind=kind,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _keyword_text_score(evidence: KeywordEvidence) -> float:
|
||||||
|
if evidence.phrase_in_title:
|
||||||
|
return 1.0
|
||||||
|
if evidence.phrase_in_abstract:
|
||||||
|
return 0.85
|
||||||
|
if evidence.full_token_match:
|
||||||
|
return 0.55
|
||||||
|
if evidence.partial_token_match:
|
||||||
|
return 0.25
|
||||||
|
return 0.0
|
||||||
|
|
||||||
|
|
||||||
|
def _exact_topic_or_subfield_match(
|
||||||
|
patent_topics: list[MappedOpenAlexTopic],
|
||||||
|
keyword_topic_ids: frozenset[str],
|
||||||
|
keyword_subfield_names: frozenset[str],
|
||||||
|
) -> bool:
|
||||||
|
evidence = _compute_topic_evidence(
|
||||||
|
patent_topics,
|
||||||
|
keyword_topic_ids,
|
||||||
|
keyword_subfield_names,
|
||||||
|
frozenset(),
|
||||||
|
)
|
||||||
|
return evidence.match_kind in {"topic_id", "subfield"}
|
||||||
|
|
||||||
|
|
||||||
|
def _keyword_text_passes_relevance_gate(
|
||||||
|
evidence: KeywordEvidence,
|
||||||
|
*,
|
||||||
|
topic_evidence: TopicEvidence,
|
||||||
|
) -> TextGateDecision:
|
||||||
|
"""Keyword text acceptance policy (no domain hardcoding).
|
||||||
|
|
||||||
|
Accept:
|
||||||
|
- phrase in title (strong)
|
||||||
|
- phrase in abstract (medium)
|
||||||
|
- exact topic/subfield together with full token text evidence
|
||||||
|
Reject:
|
||||||
|
- partial/general words alone
|
||||||
|
- compatible field alone
|
||||||
|
- exact topic/subfield without text evidence
|
||||||
|
"""
|
||||||
|
exact = topic_evidence.match_kind in {"topic_id", "subfield"}
|
||||||
|
|
||||||
|
if evidence.phrase_in_title:
|
||||||
|
return TextGateDecision(True, "phrase_in_title")
|
||||||
|
if evidence.phrase_in_abstract:
|
||||||
|
return TextGateDecision(True, "phrase_in_abstract")
|
||||||
|
if exact and evidence.full_token_match:
|
||||||
|
return TextGateDecision(
|
||||||
|
True,
|
||||||
|
f"{topic_evidence.match_kind}_with_full_token_match",
|
||||||
|
)
|
||||||
|
if exact and evidence.partial_token_match:
|
||||||
|
return TextGateDecision(False, "exact_topic_with_partial_tokens_only")
|
||||||
|
if exact:
|
||||||
|
return TextGateDecision(False, "exact_topic_without_text")
|
||||||
|
if topic_evidence.match_kind == "compatible_field":
|
||||||
|
return TextGateDecision(False, "compatible_field_only")
|
||||||
|
if evidence.partial_token_match or evidence.matched_words:
|
||||||
|
return TextGateDecision(False, "partial_or_loose_words_only")
|
||||||
|
return TextGateDecision(False, "insufficient_evidence")
|
||||||
|
|
||||||
|
|
||||||
|
def _matched_keyword_labels_from_evidence(
|
||||||
|
items: list[KeywordPatentSearchItem],
|
||||||
|
evidence: KeywordEvidence,
|
||||||
|
) -> list[str]:
|
||||||
|
matched: list[str] = []
|
||||||
|
seen: set[str] = set()
|
||||||
|
phrase_keys = {phrase.casefold() for phrase in evidence.matched_phrases}
|
||||||
|
word_keys = set(evidence.matched_words)
|
||||||
|
|
||||||
|
for item in items:
|
||||||
|
for value in (item.keyword, item.topic_display_name):
|
||||||
|
label = (value or "").strip()
|
||||||
|
if not label:
|
||||||
|
continue
|
||||||
|
key = label.casefold()
|
||||||
|
if key in seen:
|
||||||
|
continue
|
||||||
|
label_tokens = _tokenize_words(label)
|
||||||
|
if key in phrase_keys or any(token in word_keys for token in label_tokens):
|
||||||
|
seen.add(key)
|
||||||
|
matched.append(label)
|
||||||
|
break
|
||||||
|
return matched
|
||||||
|
|
||||||
|
|
||||||
def _patent_passes_relevance_gate(
|
def _patent_passes_relevance_gate(
|
||||||
patent_topics: list[MappedOpenAlexTopic],
|
patent_topics: list[MappedOpenAlexTopic],
|
||||||
*,
|
*,
|
||||||
@@ -1054,6 +1261,210 @@ async def _score_patents_with_ipc(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async def _score_patents_text_search(
|
||||||
|
*,
|
||||||
|
raw_patents: list[model.PatentEntry],
|
||||||
|
search_keywords: list[KeywordPatentSearchItem],
|
||||||
|
phrases: list[str],
|
||||||
|
text_search_terms: list[str],
|
||||||
|
keyword_topic_ids: frozenset[str],
|
||||||
|
keyword_subfield_names: frozenset[str],
|
||||||
|
keyword_soft_field_names: frozenset[str],
|
||||||
|
resolver: PatentOpenAlexMappingResolver,
|
||||||
|
) -> tuple[list[KeywordPatentMatch], dict[str, int]]:
|
||||||
|
"""Score patents without IPC using graded topic + structured text evidence."""
|
||||||
|
patent_topics_by_key = await resolver.resolve_topics_for_patents(raw_patents)
|
||||||
|
scored: list[KeywordPatentMatch] = []
|
||||||
|
filtered_by_relevance_gate = 0
|
||||||
|
filtered_by_min_score = 0
|
||||||
|
passed_relevance_gate = 0
|
||||||
|
|
||||||
|
for patent in raw_patents:
|
||||||
|
patent_topics = patent_topics_by_key.get(patent_map_key(patent), [])
|
||||||
|
evidence = _collect_keyword_text_evidence(patent, phrases, text_search_terms)
|
||||||
|
topic_evidence = _compute_topic_evidence(
|
||||||
|
patent_topics,
|
||||||
|
keyword_topic_ids,
|
||||||
|
keyword_subfield_names,
|
||||||
|
keyword_soft_field_names,
|
||||||
|
)
|
||||||
|
decision = _keyword_text_passes_relevance_gate(
|
||||||
|
evidence,
|
||||||
|
topic_evidence=topic_evidence,
|
||||||
|
)
|
||||||
|
if not decision.accepted:
|
||||||
|
filtered_by_relevance_gate += 1
|
||||||
|
logger.info(
|
||||||
|
"Text reject: id=%s title=%s topic_kind=%s topic_score=%.2f "
|
||||||
|
"text_kind=%s phrase_title=%s phrase_abstract=%s "
|
||||||
|
"full_token=%s partial_token=%s reason=%s",
|
||||||
|
patent.patent_id,
|
||||||
|
patent.title,
|
||||||
|
topic_evidence.match_kind,
|
||||||
|
topic_evidence.score,
|
||||||
|
evidence.text_match_kind,
|
||||||
|
evidence.phrase_in_title,
|
||||||
|
evidence.phrase_in_abstract,
|
||||||
|
evidence.full_token_match,
|
||||||
|
evidence.partial_token_match,
|
||||||
|
decision.reason,
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
|
||||||
|
passed_relevance_gate += 1
|
||||||
|
text_score = _keyword_text_score(evidence)
|
||||||
|
# Field-only remains a weak ranking signal when already accepted via phrase.
|
||||||
|
score = _compute_final_score(
|
||||||
|
0.0,
|
||||||
|
topic_evidence.score,
|
||||||
|
text_score,
|
||||||
|
weights=_TEXT_SCORE_WEIGHTS,
|
||||||
|
)
|
||||||
|
if score < _MIN_TEXT_PATENT_MATCH_SCORE:
|
||||||
|
filtered_by_min_score += 1
|
||||||
|
logger.info(
|
||||||
|
"Text reject: id=%s reason=below_min_score score=%.4f",
|
||||||
|
patent.patent_id,
|
||||||
|
score,
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
|
||||||
|
logger.info(
|
||||||
|
"Text accept: id=%s title=%s topic_kind=%s topic_score=%.2f "
|
||||||
|
"text_kind=%s text_score=%.2f final_score=%.4f reason=%s",
|
||||||
|
patent.patent_id,
|
||||||
|
patent.title,
|
||||||
|
topic_evidence.match_kind,
|
||||||
|
topic_evidence.score,
|
||||||
|
evidence.text_match_kind,
|
||||||
|
text_score,
|
||||||
|
score,
|
||||||
|
decision.reason,
|
||||||
|
)
|
||||||
|
scored.append(
|
||||||
|
KeywordPatentMatch(
|
||||||
|
patent=patent,
|
||||||
|
match_score=score,
|
||||||
|
ipc_score=0.0,
|
||||||
|
topic_score=topic_evidence.score,
|
||||||
|
text_score=text_score,
|
||||||
|
matched_keywords=_matched_keyword_labels_from_evidence(
|
||||||
|
search_keywords,
|
||||||
|
evidence,
|
||||||
|
),
|
||||||
|
matched_ipc_symbols=[],
|
||||||
|
text_retrieval=True,
|
||||||
|
keyword_evidence=evidence,
|
||||||
|
topic_match_kind=topic_evidence.match_kind,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
logger.info(
|
||||||
|
"Keyword patent text search: filtered_by_relevance_gate=%d "
|
||||||
|
"filtered_by_min_score=%d passed_relevance_gate=%d scored=%d",
|
||||||
|
filtered_by_relevance_gate,
|
||||||
|
filtered_by_min_score,
|
||||||
|
passed_relevance_gate,
|
||||||
|
len(scored),
|
||||||
|
)
|
||||||
|
return scored, {
|
||||||
|
"filtered_by_relevance_gate": filtered_by_relevance_gate,
|
||||||
|
"filtered_by_min_score": filtered_by_min_score,
|
||||||
|
"passed_relevance_gate": passed_relevance_gate,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async def _search_patents_text_search(
|
||||||
|
*,
|
||||||
|
client: BasePatentSearchClient,
|
||||||
|
queries: IpcPatentSearchQueries,
|
||||||
|
ipc_search: IpcSearchClient,
|
||||||
|
resolver: PatentOpenAlexMappingResolver,
|
||||||
|
search_keywords: list[KeywordPatentSearchItem],
|
||||||
|
keyword_topic_ids: frozenset[str],
|
||||||
|
keyword_subfield_names: frozenset[str],
|
||||||
|
keyword_soft_field_names: frozenset[str],
|
||||||
|
mapping_status: KeywordPatentMappingStatus,
|
||||||
|
ipc_cluster_selections: list[dict] | None = None,
|
||||||
|
) -> PatentsByKeywordsResponse:
|
||||||
|
cluster_dicts = list(ipc_cluster_selections or [])
|
||||||
|
phrases = _text_search_phrases(search_keywords)
|
||||||
|
text_search_terms = _text_search_terms(search_keywords)
|
||||||
|
if not phrases:
|
||||||
|
logger.info(
|
||||||
|
"Keyword patent text search: no phrases for keywords %s",
|
||||||
|
[item.keyword for item in search_keywords],
|
||||||
|
)
|
||||||
|
return PatentsByKeywordsResponse(
|
||||||
|
patent_count=0,
|
||||||
|
patents=[],
|
||||||
|
mapping_status="no_patents_found",
|
||||||
|
diagnostics=_empty_diagnostics(
|
||||||
|
search_path="text",
|
||||||
|
ipc_cluster_selections=cluster_dicts,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
logger.info(
|
||||||
|
"Keyword patent text search: mapping_status=%s phrases=%s",
|
||||||
|
mapping_status,
|
||||||
|
phrases,
|
||||||
|
)
|
||||||
|
raw_patents = await _fetch_patents_for_queries(
|
||||||
|
client,
|
||||||
|
queries.epo_query_by_text_phrases(phrases, size=_MAX_PATENTS),
|
||||||
|
queries.uspto_query_by_text_phrases(phrases, size=_MAX_PATENTS),
|
||||||
|
)
|
||||||
|
if raw_patents is None:
|
||||||
|
return PatentsByKeywordsResponse(
|
||||||
|
patent_count=0,
|
||||||
|
patents=[],
|
||||||
|
mapping_status="search_error",
|
||||||
|
diagnostics=_empty_diagnostics(
|
||||||
|
search_path="text",
|
||||||
|
ipc_cluster_selections=cluster_dicts,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
logger.info("Keyword patent text search: raw_patents=%d", len(raw_patents))
|
||||||
|
scored, filter_counts = await _score_patents_text_search(
|
||||||
|
raw_patents=raw_patents,
|
||||||
|
search_keywords=search_keywords,
|
||||||
|
phrases=phrases,
|
||||||
|
text_search_terms=text_search_terms,
|
||||||
|
keyword_topic_ids=keyword_topic_ids,
|
||||||
|
keyword_subfield_names=keyword_subfield_names,
|
||||||
|
keyword_soft_field_names=keyword_soft_field_names,
|
||||||
|
resolver=resolver,
|
||||||
|
)
|
||||||
|
scored, diagnostics = _finalize_scored_patents(
|
||||||
|
scored,
|
||||||
|
raw_count=len(raw_patents),
|
||||||
|
filtered_by_ipc=0,
|
||||||
|
filtered_by_relevance_gate=filter_counts["filtered_by_relevance_gate"],
|
||||||
|
filtered_by_min_score=filter_counts["filtered_by_min_score"],
|
||||||
|
passed_relevance_gate=filter_counts["passed_relevance_gate"],
|
||||||
|
search_path="text",
|
||||||
|
ipc_cluster_selections=cluster_dicts,
|
||||||
|
)
|
||||||
|
await enrich_patents_classifications([item.patent for item in scored], ipc_search)
|
||||||
|
|
||||||
|
if not scored:
|
||||||
|
return PatentsByKeywordsResponse(
|
||||||
|
patent_count=0,
|
||||||
|
patents=[],
|
||||||
|
mapping_status="no_patents_found",
|
||||||
|
diagnostics=diagnostics,
|
||||||
|
)
|
||||||
|
|
||||||
|
return PatentsByKeywordsResponse(
|
||||||
|
patent_count=len(scored),
|
||||||
|
patents=scored,
|
||||||
|
mapping_status=mapping_status,
|
||||||
|
diagnostics=diagnostics,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def get_patents_by_keywords(
|
async def get_patents_by_keywords(
|
||||||
request: PatentsByKeywordsRequest,
|
request: PatentsByKeywordsRequest,
|
||||||
*,
|
*,
|
||||||
@@ -1117,18 +1528,21 @@ async def get_patents_by_keywords(
|
|||||||
)
|
)
|
||||||
logger.info(
|
logger.info(
|
||||||
"Keyword patent search: no IPC search terms for keywords %s "
|
"Keyword patent search: no IPC search terms for keywords %s "
|
||||||
"(mapping_status=%s)",
|
"(mapping_status=%s) — trying keyword text search",
|
||||||
[item.keyword for item in search_keywords],
|
[item.keyword for item in search_keywords],
|
||||||
mapping_status,
|
mapping_status,
|
||||||
)
|
)
|
||||||
return PatentsByKeywordsResponse(
|
return await _search_patents_text_search(
|
||||||
patent_count=0,
|
client=client,
|
||||||
patents=[],
|
queries=queries,
|
||||||
|
ipc_search=ipc_search,
|
||||||
|
resolver=resolver,
|
||||||
|
search_keywords=search_keywords,
|
||||||
|
keyword_topic_ids=keyword_topic_ids,
|
||||||
|
keyword_subfield_names=keyword_subfield_names,
|
||||||
|
keyword_soft_field_names=keyword_soft_field_names,
|
||||||
mapping_status=mapping_status,
|
mapping_status=mapping_status,
|
||||||
diagnostics=_empty_diagnostics(
|
ipc_cluster_selections=cluster_dicts,
|
||||||
search_path="none",
|
|
||||||
ipc_cluster_selections=cluster_dicts,
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
text_search_terms = _text_search_terms(search_keywords)
|
text_search_terms = _text_search_terms(search_keywords)
|
||||||
@@ -1180,11 +1594,31 @@ async def get_patents_by_keywords(
|
|||||||
diagnostics=diagnostics,
|
diagnostics=diagnostics,
|
||||||
)
|
)
|
||||||
|
|
||||||
return PatentsByKeywordsResponse(
|
if not _TEXT_SEARCH_AFTER_EMPTY_IPC:
|
||||||
patent_count=0,
|
return PatentsByKeywordsResponse(
|
||||||
patents=[],
|
patent_count=0,
|
||||||
mapping_status="no_patents_found",
|
patents=[],
|
||||||
diagnostics=diagnostics,
|
mapping_status="no_patents_found",
|
||||||
|
diagnostics=diagnostics,
|
||||||
|
)
|
||||||
|
|
||||||
|
logger.info(
|
||||||
|
"Keyword patent search: IPC path yielded no scored patents — "
|
||||||
|
"trying keyword text search (policy=_TEXT_SEARCH_AFTER_EMPTY_IPC)"
|
||||||
|
)
|
||||||
|
return await _search_patents_text_search(
|
||||||
|
client=client,
|
||||||
|
queries=queries,
|
||||||
|
ipc_search=ipc_search,
|
||||||
|
resolver=resolver,
|
||||||
|
search_keywords=search_keywords,
|
||||||
|
keyword_topic_ids=keyword_topic_ids,
|
||||||
|
keyword_subfield_names=keyword_subfield_names,
|
||||||
|
keyword_soft_field_names=keyword_soft_field_names,
|
||||||
|
# IPC was selected but produced no usable hits; UI treats this like
|
||||||
|
# uncertain IPC evidence and labels patents via text_retrieval.
|
||||||
|
mapping_status="uncertain",
|
||||||
|
ipc_cluster_selections=cluster_dicts,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -46,12 +46,19 @@ _USPTO_SOURCE_FIELDS = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
_MIN_MATCH_TERM_LEN = 4
|
_MIN_MATCH_TERM_LEN = 4
|
||||||
|
_MIN_TEXT_PHRASE_LEN = 3
|
||||||
|
|
||||||
# Prefer concrete group/subgroup hits over broad subclass prefixes.
|
# Prefer concrete group/subgroup hits over broad subclass prefixes.
|
||||||
_BOOST_SUBGROUP = 4.0
|
_BOOST_SUBGROUP = 4.0
|
||||||
_BOOST_MAIN_GROUP = 2.5
|
_BOOST_MAIN_GROUP = 2.5
|
||||||
_BOOST_SUBCLASS = 1.0
|
_BOOST_SUBCLASS = 1.0
|
||||||
|
|
||||||
|
# Text search: prefer exact phrases in title over abstract / loose match.
|
||||||
|
_BOOST_TEXT_PHRASE_TITLE = 5.0
|
||||||
|
_BOOST_TEXT_PHRASE_ABSTRACT = 3.0
|
||||||
|
_BOOST_TEXT_MATCH_TITLE = 1.5
|
||||||
|
_BOOST_TEXT_MATCH_ABSTRACT = 1.0
|
||||||
|
|
||||||
|
|
||||||
def _add_term_boost(weights: dict[str, float], term: str, boost: float) -> None:
|
def _add_term_boost(weights: dict[str, float], term: str, boost: float) -> None:
|
||||||
cleaned = term.strip()
|
cleaned = term.strip()
|
||||||
@@ -150,6 +157,76 @@ def _ipc_match_clauses(field: str, term_boosts: dict[str, float]) -> list[dict[s
|
|||||||
return clauses
|
return clauses
|
||||||
|
|
||||||
|
|
||||||
|
def _normalize_text_phrases(phrases: list[str]) -> list[str]:
|
||||||
|
cleaned: list[str] = []
|
||||||
|
seen: set[str] = set()
|
||||||
|
for phrase in phrases:
|
||||||
|
value = " ".join((phrase or "").strip().split())
|
||||||
|
if len(value) < _MIN_TEXT_PHRASE_LEN:
|
||||||
|
continue
|
||||||
|
key = value.casefold()
|
||||||
|
if key in seen:
|
||||||
|
continue
|
||||||
|
seen.add(key)
|
||||||
|
cleaned.append(value)
|
||||||
|
return cleaned
|
||||||
|
|
||||||
|
|
||||||
|
def _text_match_clauses(
|
||||||
|
phrases: list[str],
|
||||||
|
*,
|
||||||
|
title_fields: tuple[str, ...],
|
||||||
|
abstract_field: str,
|
||||||
|
) -> list[dict[str, Any]]:
|
||||||
|
"""Build title/abstract should-clauses with phrase boosts over loose match."""
|
||||||
|
clauses: list[dict[str, Any]] = []
|
||||||
|
for phrase in _normalize_text_phrases(phrases):
|
||||||
|
for field in title_fields:
|
||||||
|
clauses.append(
|
||||||
|
{
|
||||||
|
"match_phrase": {
|
||||||
|
field: {
|
||||||
|
"query": phrase,
|
||||||
|
"boost": _BOOST_TEXT_PHRASE_TITLE,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
clauses.append(
|
||||||
|
{
|
||||||
|
"match": {
|
||||||
|
field: {
|
||||||
|
"query": phrase,
|
||||||
|
"operator": "and",
|
||||||
|
"boost": _BOOST_TEXT_MATCH_TITLE,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
clauses.append(
|
||||||
|
{
|
||||||
|
"match_phrase": {
|
||||||
|
abstract_field: {
|
||||||
|
"query": phrase,
|
||||||
|
"boost": _BOOST_TEXT_PHRASE_ABSTRACT,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
clauses.append(
|
||||||
|
{
|
||||||
|
"match": {
|
||||||
|
abstract_field: {
|
||||||
|
"query": phrase,
|
||||||
|
"operator": "and",
|
||||||
|
"boost": _BOOST_TEXT_MATCH_ABSTRACT,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
return clauses
|
||||||
|
|
||||||
|
|
||||||
class IpcPatentSearchQueries:
|
class IpcPatentSearchQueries:
|
||||||
def epo_query_by_ipc_terms(
|
def epo_query_by_ipc_terms(
|
||||||
self,
|
self,
|
||||||
@@ -222,3 +299,55 @@ class IpcPatentSearchQueries:
|
|||||||
size: int = DEFAULT_SEARCH_SIZE,
|
size: int = DEFAULT_SEARCH_SIZE,
|
||||||
) -> dict[str, Any]:
|
) -> dict[str, Any]:
|
||||||
return self.uspto_query_by_ipc_terms(_merge_term_boosts(symbols), size=size)
|
return self.uspto_query_by_ipc_terms(_merge_term_boosts(symbols), size=size)
|
||||||
|
|
||||||
|
def epo_query_by_text_phrases(
|
||||||
|
self,
|
||||||
|
phrases: list[str],
|
||||||
|
size: int = DEFAULT_SEARCH_SIZE,
|
||||||
|
) -> dict[str, Any]:
|
||||||
|
should = _text_match_clauses(
|
||||||
|
phrases,
|
||||||
|
title_fields=("title_en", "title_de"),
|
||||||
|
abstract_field="abstract",
|
||||||
|
)
|
||||||
|
query: dict[str, Any] = (
|
||||||
|
{"match_none": {}}
|
||||||
|
if not should
|
||||||
|
else {"bool": {"should": should, "minimum_should_match": 1}}
|
||||||
|
)
|
||||||
|
return {
|
||||||
|
"size": size,
|
||||||
|
"track_total_hits": True,
|
||||||
|
"sort": [
|
||||||
|
{"_score": {"order": "desc"}},
|
||||||
|
{"date_publication": {"order": "desc", "missing": "_last"}},
|
||||||
|
],
|
||||||
|
"_source": _PATENT_SOURCE_FIELDS,
|
||||||
|
"query": query,
|
||||||
|
}
|
||||||
|
|
||||||
|
def uspto_query_by_text_phrases(
|
||||||
|
self,
|
||||||
|
phrases: list[str],
|
||||||
|
size: int = DEFAULT_SEARCH_SIZE,
|
||||||
|
) -> dict[str, Any]:
|
||||||
|
should = _text_match_clauses(
|
||||||
|
phrases,
|
||||||
|
title_fields=("title",),
|
||||||
|
abstract_field="abstract",
|
||||||
|
)
|
||||||
|
query: dict[str, Any] = (
|
||||||
|
{"match_none": {}}
|
||||||
|
if not should
|
||||||
|
else {"bool": {"should": should, "minimum_should_match": 1}}
|
||||||
|
)
|
||||||
|
return {
|
||||||
|
"size": size,
|
||||||
|
"track_total_hits": True,
|
||||||
|
"sort": [
|
||||||
|
{"_score": {"order": "desc"}},
|
||||||
|
{"publication_date": {"order": "desc", "missing": "_last"}},
|
||||||
|
],
|
||||||
|
"_source": _USPTO_SOURCE_FIELDS,
|
||||||
|
"query": query,
|
||||||
|
}
|
||||||
|
|||||||
@@ -10,17 +10,21 @@ from inse.patents.authors.ipc_openalex_mapping import MappedOpenAlexTopic
|
|||||||
from inse.patents.common import model
|
from inse.patents.common import model
|
||||||
from inse.patents.keywords.logic import (
|
from inse.patents.keywords.logic import (
|
||||||
TopicEvidence,
|
TopicEvidence,
|
||||||
|
_aggregate_subclass_clusters,
|
||||||
|
_collect_keyword_text_evidence,
|
||||||
_compute_final_score,
|
_compute_final_score,
|
||||||
_compute_topic_evidence,
|
_compute_topic_evidence,
|
||||||
|
_exact_topic_or_subfield_match,
|
||||||
_filter_keywords_for_patent_search,
|
_filter_keywords_for_patent_search,
|
||||||
_ipc_hierarchy_quality,
|
_ipc_hierarchy_quality,
|
||||||
_keyword_is_patent_searchable,
|
_keyword_is_patent_searchable,
|
||||||
|
_keyword_text_passes_relevance_gate,
|
||||||
|
_keyword_text_score,
|
||||||
_patent_passes_relevance_gate,
|
_patent_passes_relevance_gate,
|
||||||
_patent_search_terms,
|
_patent_search_terms,
|
||||||
_score_ipc_match,
|
_score_ipc_match,
|
||||||
_score_patent,
|
_score_patent,
|
||||||
_select_dominant_clusters,
|
_select_dominant_clusters,
|
||||||
_aggregate_subclass_clusters,
|
|
||||||
_term_from_ipc_match,
|
_term_from_ipc_match,
|
||||||
_text_overlap_score,
|
_text_overlap_score,
|
||||||
_text_search_terms,
|
_text_search_terms,
|
||||||
@@ -30,6 +34,10 @@ from inse.patents.keywords.logic import (
|
|||||||
get_patents_by_keywords,
|
get_patents_by_keywords,
|
||||||
select_ipc_matches_by_cluster_mass,
|
select_ipc_matches_by_cluster_mass,
|
||||||
)
|
)
|
||||||
|
from inse.patents.keywords.model import (
|
||||||
|
KeywordPatentSearchItem,
|
||||||
|
PatentsByKeywordsRequest,
|
||||||
|
)
|
||||||
from inse.patents.keywords.reverse_lookup import (
|
from inse.patents.keywords.reverse_lookup import (
|
||||||
IpcCodeMatch,
|
IpcCodeMatch,
|
||||||
_dedupe_ipc_matches,
|
_dedupe_ipc_matches,
|
||||||
@@ -37,7 +45,6 @@ from inse.patents.keywords.reverse_lookup import (
|
|||||||
_weighted_score,
|
_weighted_score,
|
||||||
clear_reverse_lookup_caches,
|
clear_reverse_lookup_caches,
|
||||||
)
|
)
|
||||||
from inse.patents.keywords.model import KeywordPatentSearchItem, PatentsByKeywordsRequest
|
|
||||||
from inse.patents.keywords.search_queries import (
|
from inse.patents.keywords.search_queries import (
|
||||||
IpcPatentSearchQueries,
|
IpcPatentSearchQueries,
|
||||||
_search_terms_for_symbol,
|
_search_terms_for_symbol,
|
||||||
@@ -639,6 +646,132 @@ def test_text_overlap_score_uses_word_boundaries_not_substrings() -> None:
|
|||||||
assert _text_overlap_score(patent, ["chemistry", "organic"]) == 0.0
|
assert _text_overlap_score(patent, ["chemistry", "organic"]) == 0.0
|
||||||
|
|
||||||
|
|
||||||
|
def test_fallback_rejects_mechanical_patent_for_organic_chemistry() -> None:
|
||||||
|
"""Soft field / loose words must not accept a mechanical separator patent."""
|
||||||
|
patent = model.PatentEntry(
|
||||||
|
patent_id="EP-MECH",
|
||||||
|
source="EPO",
|
||||||
|
title=(
|
||||||
|
"Rotating machine for separating materials in different "
|
||||||
|
"states of aggregation"
|
||||||
|
),
|
||||||
|
abstract="Apparatus for mechanical separation of materials.",
|
||||||
|
ipc=["B01D45/12"],
|
||||||
|
)
|
||||||
|
phrases = ["Organic Chemistry", "organische Chemie"]
|
||||||
|
terms = ["organic", "chemistry", "organische", "chemie"]
|
||||||
|
evidence = _collect_keyword_text_evidence(patent, phrases, terms)
|
||||||
|
|
||||||
|
assert evidence.phrase_in_title is False
|
||||||
|
assert evidence.phrase_in_abstract is False
|
||||||
|
assert evidence.full_token_match is False
|
||||||
|
assert evidence.matched_phrases == []
|
||||||
|
assert evidence.matched_words == []
|
||||||
|
|
||||||
|
field_only = TopicEvidence(match_kind="compatible_field", score=0.3)
|
||||||
|
assert not _keyword_text_passes_relevance_gate(
|
||||||
|
evidence,
|
||||||
|
topic_evidence=field_only,
|
||||||
|
).accepted
|
||||||
|
exact = TopicEvidence(match_kind="topic_id", score=1.0)
|
||||||
|
assert not _keyword_text_passes_relevance_gate(
|
||||||
|
evidence,
|
||||||
|
topic_evidence=exact,
|
||||||
|
).accepted
|
||||||
|
|
||||||
|
|
||||||
|
def test_fallback_accepts_strong_phrase_or_exact_topic_with_full_tokens() -> None:
|
||||||
|
phrase_patent = model.PatentEntry(
|
||||||
|
patent_id="EP-PHRASE",
|
||||||
|
source="EPO",
|
||||||
|
title="Process for organic chemistry synthesis",
|
||||||
|
abstract="Catalytic reactions.",
|
||||||
|
)
|
||||||
|
phrases = ["organic chemistry"]
|
||||||
|
terms = ["organic", "chemistry"]
|
||||||
|
evidence = _collect_keyword_text_evidence(phrase_patent, phrases, terms)
|
||||||
|
assert evidence.phrase_in_title is True
|
||||||
|
assert evidence.text_match_kind == "phrase_title"
|
||||||
|
assert _keyword_text_score(evidence) == 1.0
|
||||||
|
assert _keyword_text_passes_relevance_gate(
|
||||||
|
evidence,
|
||||||
|
topic_evidence=TopicEvidence(match_kind="none", score=0.0),
|
||||||
|
).accepted
|
||||||
|
|
||||||
|
full_token_patent = model.PatentEntry(
|
||||||
|
patent_id="EP-WORDS",
|
||||||
|
source="EPO",
|
||||||
|
title="Catalytic organic synthesis method",
|
||||||
|
abstract="Uses chemistry laboratory techniques.",
|
||||||
|
)
|
||||||
|
full_evidence = _collect_keyword_text_evidence(
|
||||||
|
full_token_patent,
|
||||||
|
phrases,
|
||||||
|
terms,
|
||||||
|
)
|
||||||
|
assert full_evidence.phrase_in_title is False
|
||||||
|
assert full_evidence.phrase_in_abstract is False
|
||||||
|
assert full_evidence.full_token_match is True
|
||||||
|
assert not _keyword_text_passes_relevance_gate(
|
||||||
|
full_evidence,
|
||||||
|
topic_evidence=TopicEvidence(match_kind="none", score=0.0),
|
||||||
|
).accepted
|
||||||
|
assert _keyword_text_passes_relevance_gate(
|
||||||
|
full_evidence,
|
||||||
|
topic_evidence=TopicEvidence(match_kind="topic_id", score=1.0),
|
||||||
|
).accepted
|
||||||
|
|
||||||
|
partial_patent = model.PatentEntry(
|
||||||
|
patent_id="EP-PARTIAL",
|
||||||
|
source="EPO",
|
||||||
|
title="Organic polymer blend",
|
||||||
|
abstract="Industrial materials processing.",
|
||||||
|
)
|
||||||
|
partial_evidence = _collect_keyword_text_evidence(
|
||||||
|
partial_patent,
|
||||||
|
phrases,
|
||||||
|
terms,
|
||||||
|
)
|
||||||
|
assert partial_evidence.partial_token_match is True
|
||||||
|
assert partial_evidence.full_token_match is False
|
||||||
|
decision = _keyword_text_passes_relevance_gate(
|
||||||
|
partial_evidence,
|
||||||
|
topic_evidence=TopicEvidence(match_kind="topic_id", score=1.0),
|
||||||
|
)
|
||||||
|
assert not decision.accepted
|
||||||
|
assert decision.reason == "exact_topic_with_partial_tokens_only"
|
||||||
|
|
||||||
|
assert _exact_topic_or_subfield_match(
|
||||||
|
[
|
||||||
|
MappedOpenAlexTopic(
|
||||||
|
topic_id="https://openalex.org/TORG",
|
||||||
|
topic_display_name="Organic Chemistry",
|
||||||
|
subfield_name="Organic Chemistry",
|
||||||
|
field_name="Chemistry",
|
||||||
|
)
|
||||||
|
],
|
||||||
|
frozenset({"TORG"}),
|
||||||
|
frozenset({"organic chemistry"}),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_token_match_rejects_machine_inside_micromachined() -> None:
|
||||||
|
patent = model.PatentEntry(
|
||||||
|
patent_id="EP-MICRO",
|
||||||
|
source="EPO",
|
||||||
|
title="Micromachined sensor device",
|
||||||
|
abstract="Fabrication of micromachined structures.",
|
||||||
|
)
|
||||||
|
assert _text_overlap_score(patent, ["machine", "learning"]) == 0.0
|
||||||
|
evidence = _collect_keyword_text_evidence(
|
||||||
|
patent,
|
||||||
|
["Machine Learning"],
|
||||||
|
["machine", "learning"],
|
||||||
|
)
|
||||||
|
assert evidence.matched_words == []
|
||||||
|
assert evidence.full_token_match is False
|
||||||
|
|
||||||
|
|
||||||
def test_patent_passes_relevance_gate_with_text_but_no_topics() -> None:
|
def test_patent_passes_relevance_gate_with_text_but_no_topics() -> None:
|
||||||
patent = model.PatentEntry(
|
patent = model.PatentEntry(
|
||||||
patent_id="EP1",
|
patent_id="EP1",
|
||||||
@@ -781,7 +914,8 @@ def test_get_patents_by_keywords_uses_symbol_queries() -> None:
|
|||||||
uspto_symbols.assert_called_once()
|
uspto_symbols.assert_called_once()
|
||||||
assert epo_symbols.call_args.args[0][0] == "C07C243/08"
|
assert epo_symbols.call_args.args[0][0] == "C07C243/08"
|
||||||
assert "C07C" in epo_symbols.call_args.args[0]
|
assert "C07C" in epo_symbols.call_args.args[0]
|
||||||
assert captured == ["epo", "uspto"]
|
# IPC search returns empty → text fallback also queries EPO/USPTO.
|
||||||
|
assert captured == ["epo", "uspto", "epo", "uspto"]
|
||||||
|
|
||||||
|
|
||||||
def test_text_search_terms_include_topic_metadata() -> None:
|
def test_text_search_terms_include_topic_metadata() -> None:
|
||||||
@@ -859,84 +993,64 @@ def test_epo_and_uspto_queries_boost_specific_symbols_over_subclass() -> None:
|
|||||||
assert uspto["sort"][0] == {"_score": {"order": "desc"}}
|
assert uspto["sort"][0] == {"_score": {"order": "desc"}}
|
||||||
|
|
||||||
|
|
||||||
def test_technical_search_failure_returns_search_error_not_no_patents_found() -> None:
|
def test_text_queries_prefer_phrase_match_in_title() -> None:
|
||||||
request = PatentsByKeywordsRequest(
|
queries = IpcPatentSearchQueries()
|
||||||
keywords=[
|
epo = queries.epo_query_by_text_phrases(["organic chemistry"])
|
||||||
KeywordPatentSearchItem(
|
uspto = queries.uspto_query_by_text_phrases(["organic chemistry"])
|
||||||
keyword="organische Chemie",
|
|
||||||
keyword_level="coarse",
|
epo_should = epo["query"]["bool"]["should"]
|
||||||
topic_id="https://openalex.org/TORG",
|
uspto_should = uspto["query"]["bool"]["should"]
|
||||||
topic_display_name="Organic Chemistry",
|
|
||||||
field_name="Chemistry",
|
def clause_boost(clauses: list[dict], kind: str, field: str) -> float | None:
|
||||||
relevance_score=1.0,
|
for clause in clauses:
|
||||||
)
|
payload = clause.get(kind, {}).get(field)
|
||||||
]
|
if isinstance(payload, dict) and payload.get("query") == "organic chemistry":
|
||||||
|
return float(payload.get("boost", 1.0))
|
||||||
|
return None
|
||||||
|
|
||||||
|
assert clause_boost(epo_should, "match_phrase", "title_en") == 5.0
|
||||||
|
assert clause_boost(epo_should, "match_phrase", "abstract") == 3.0
|
||||||
|
assert clause_boost(epo_should, "match", "title_en") == 1.5
|
||||||
|
assert clause_boost(uspto_should, "match_phrase", "title") == 5.0
|
||||||
|
assert epo["sort"][0] == {"_score": {"order": "desc"}}
|
||||||
|
|
||||||
|
|
||||||
|
def test_uncertain_mapping_uses_text_fallback_not_empty_list() -> None:
|
||||||
|
"""Fragmented IPC abstention must fall back to title/abstract search."""
|
||||||
|
patent = model.PatentEntry(
|
||||||
|
patent_id="EP123",
|
||||||
|
source="EPO",
|
||||||
|
title="Process for organic chemistry synthesis",
|
||||||
|
abstract="A catalytic method in organic chemistry.",
|
||||||
|
publication_date="20240101",
|
||||||
|
ipc=["C07C243/08"],
|
||||||
|
cpc=[],
|
||||||
)
|
)
|
||||||
ipc_matches = [
|
|
||||||
IpcCodeMatch(
|
|
||||||
"subgroup",
|
|
||||||
"C07C243/08",
|
|
||||||
0.90,
|
|
||||||
"organische Chemie",
|
|
||||||
"topic",
|
|
||||||
"TORG",
|
|
||||||
)
|
|
||||||
]
|
|
||||||
|
|
||||||
with patch(
|
async def fake_search_epo(query):
|
||||||
"inse.patents.keywords.logic.KeywordIpcReverseLookup.lookup_ipc_codes",
|
assert "match_phrase" in str(query) or "title_en" in str(query)
|
||||||
new=AsyncMock(return_value=ipc_matches),
|
return {
|
||||||
), patch(
|
"hits": {
|
||||||
"inse.patents.keywords.logic.BasePatentSearchClient.search_epo",
|
"hits": [
|
||||||
new=AsyncMock(side_effect=httpx.HTTPError("boom")),
|
{
|
||||||
), patch(
|
"_source": {
|
||||||
"inse.patents.keywords.logic.BasePatentSearchClient.search_uspto",
|
"doc_number": "123",
|
||||||
new=AsyncMock(return_value={"hits": {"hits": []}}),
|
"country": "EP",
|
||||||
):
|
"kind": "A1",
|
||||||
response = asyncio.run(get_patents_by_keywords(request))
|
"date_publication": "20240101",
|
||||||
|
"title_en": patent.title,
|
||||||
|
"abstract": patent.abstract,
|
||||||
|
"ipc": patent.ipc,
|
||||||
|
"cpc": [],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
assert response.mapping_status == "search_error"
|
async def fake_search_uspto(query):
|
||||||
assert response.patent_count == 0
|
return {"hits": {"hits": []}}
|
||||||
|
|
||||||
|
|
||||||
def test_no_ipc_search_terms_returns_without_text_fallback() -> None:
|
|
||||||
"""Without usable IPC symbols the search abstains — no title/abstract path."""
|
|
||||||
request = PatentsByKeywordsRequest(
|
|
||||||
keywords=[
|
|
||||||
KeywordPatentSearchItem(
|
|
||||||
keyword="organische Chemie",
|
|
||||||
keyword_level="coarse",
|
|
||||||
topic_id="https://openalex.org/TORG",
|
|
||||||
topic_display_name="Organic Chemistry",
|
|
||||||
field_name="Chemistry",
|
|
||||||
relevance_score=1.0,
|
|
||||||
)
|
|
||||||
]
|
|
||||||
)
|
|
||||||
search_epo = AsyncMock(return_value={"hits": {"hits": []}})
|
|
||||||
search_uspto = AsyncMock(return_value={"hits": {"hits": []}})
|
|
||||||
|
|
||||||
with patch(
|
|
||||||
"inse.patents.keywords.logic.KeywordIpcReverseLookup.lookup_ipc_codes",
|
|
||||||
new=AsyncMock(return_value=[]),
|
|
||||||
), patch(
|
|
||||||
"inse.patents.keywords.logic.BasePatentSearchClient.search_epo",
|
|
||||||
new=search_epo,
|
|
||||||
), patch(
|
|
||||||
"inse.patents.keywords.logic.BasePatentSearchClient.search_uspto",
|
|
||||||
new=search_uspto,
|
|
||||||
):
|
|
||||||
response = asyncio.run(get_patents_by_keywords(request))
|
|
||||||
|
|
||||||
assert response.mapping_status == "no_mapping"
|
|
||||||
assert response.patent_count == 0
|
|
||||||
assert response.patents == []
|
|
||||||
search_epo.assert_not_called()
|
|
||||||
search_uspto.assert_not_called()
|
|
||||||
|
|
||||||
|
|
||||||
def test_uncertain_ipc_cluster_abstention_returns_without_text_fallback() -> None:
|
|
||||||
"""Fragmented IPC mapping abstains without falling back to text retrieval."""
|
|
||||||
fragmented = [
|
fragmented = [
|
||||||
IpcCodeMatch(
|
IpcCodeMatch(
|
||||||
"subgroup",
|
"subgroup",
|
||||||
@@ -960,31 +1074,113 @@ def test_uncertain_ipc_cluster_abstention_returns_without_text_fallback() -> Non
|
|||||||
)
|
)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
search_epo = AsyncMock(return_value={"hits": {"hits": []}})
|
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"inse.patents.keywords.logic.KeywordIpcReverseLookup.lookup_ipc_codes",
|
"inse.patents.keywords.logic.KeywordIpcReverseLookup.lookup_ipc_codes",
|
||||||
new=AsyncMock(return_value=fragmented),
|
new=AsyncMock(return_value=fragmented),
|
||||||
), patch(
|
), patch(
|
||||||
"inse.patents.keywords.logic.BasePatentSearchClient.search_epo",
|
"inse.patents.keywords.logic.BasePatentSearchClient.search_epo",
|
||||||
new=search_epo,
|
new=AsyncMock(side_effect=fake_search_epo),
|
||||||
|
), patch(
|
||||||
|
"inse.patents.keywords.logic.BasePatentSearchClient.search_uspto",
|
||||||
|
new=AsyncMock(side_effect=fake_search_uspto),
|
||||||
|
), patch(
|
||||||
|
"inse.patents.keywords.logic.PatentOpenAlexMappingResolver.resolve_topics_for_patents",
|
||||||
|
new=AsyncMock(return_value={}),
|
||||||
|
), patch(
|
||||||
|
"inse.patents.keywords.logic.enrich_patents_classifications",
|
||||||
|
new=AsyncMock(),
|
||||||
|
), patch.object(
|
||||||
|
IpcPatentSearchQueries,
|
||||||
|
"epo_query_by_text_phrases",
|
||||||
|
wraps=IpcPatentSearchQueries().epo_query_by_text_phrases,
|
||||||
|
) as epo_text:
|
||||||
|
response = asyncio.run(get_patents_by_keywords(request))
|
||||||
|
|
||||||
|
epo_text.assert_called_once()
|
||||||
|
assert response.mapping_status == "uncertain"
|
||||||
|
assert response.patent_count == 1
|
||||||
|
assert response.patents[0].text_retrieval is True
|
||||||
|
assert response.patents[0].ipc_score == 0.0
|
||||||
|
assert response.patents[0].text_score > 0.0
|
||||||
|
assert response.patents[0].matched_ipc_symbols == []
|
||||||
|
assert response.patents[0].keyword_evidence is not None
|
||||||
|
assert response.patents[0].keyword_evidence.phrase_in_title is True
|
||||||
|
assert response.patents[0].keyword_evidence.text_match_kind == "phrase_title"
|
||||||
|
|
||||||
|
|
||||||
|
def test_text_fallback_empty_yields_no_patents_found() -> None:
|
||||||
|
request = PatentsByKeywordsRequest(
|
||||||
|
keywords=[
|
||||||
|
KeywordPatentSearchItem(
|
||||||
|
keyword="organische Chemie",
|
||||||
|
keyword_level="coarse",
|
||||||
|
topic_id="https://openalex.org/TORG",
|
||||||
|
topic_display_name="Organic Chemistry",
|
||||||
|
field_name="Chemistry",
|
||||||
|
relevance_score=1.0,
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
with patch(
|
||||||
|
"inse.patents.keywords.logic.KeywordIpcReverseLookup.lookup_ipc_codes",
|
||||||
|
new=AsyncMock(return_value=[]),
|
||||||
|
), patch(
|
||||||
|
"inse.patents.keywords.logic.BasePatentSearchClient.search_epo",
|
||||||
|
new=AsyncMock(return_value={"hits": {"hits": []}}),
|
||||||
|
), patch(
|
||||||
|
"inse.patents.keywords.logic.BasePatentSearchClient.search_uspto",
|
||||||
|
new=AsyncMock(return_value={"hits": {"hits": []}}),
|
||||||
|
), patch(
|
||||||
|
"inse.patents.keywords.logic.PatentOpenAlexMappingResolver.resolve_topics_for_patents",
|
||||||
|
new=AsyncMock(return_value={}),
|
||||||
|
), patch(
|
||||||
|
"inse.patents.keywords.logic.enrich_patents_classifications",
|
||||||
|
new=AsyncMock(),
|
||||||
|
):
|
||||||
|
response = asyncio.run(get_patents_by_keywords(request))
|
||||||
|
|
||||||
|
assert response.mapping_status == "no_patents_found"
|
||||||
|
assert response.patent_count == 0
|
||||||
|
assert response.patents == []
|
||||||
|
|
||||||
|
|
||||||
|
def test_technical_search_failure_returns_search_error_not_no_patents_found() -> None:
|
||||||
|
request = PatentsByKeywordsRequest(
|
||||||
|
keywords=[
|
||||||
|
KeywordPatentSearchItem(
|
||||||
|
keyword="organische Chemie",
|
||||||
|
keyword_level="coarse",
|
||||||
|
topic_id="https://openalex.org/TORG",
|
||||||
|
topic_display_name="Organic Chemistry",
|
||||||
|
field_name="Chemistry",
|
||||||
|
relevance_score=1.0,
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
with patch(
|
||||||
|
"inse.patents.keywords.logic.KeywordIpcReverseLookup.lookup_ipc_codes",
|
||||||
|
new=AsyncMock(return_value=[]),
|
||||||
|
), patch(
|
||||||
|
"inse.patents.keywords.logic.BasePatentSearchClient.search_epo",
|
||||||
|
new=AsyncMock(side_effect=httpx.HTTPError("boom")),
|
||||||
), patch(
|
), patch(
|
||||||
"inse.patents.keywords.logic.BasePatentSearchClient.search_uspto",
|
"inse.patents.keywords.logic.BasePatentSearchClient.search_uspto",
|
||||||
new=AsyncMock(return_value={"hits": {"hits": []}}),
|
new=AsyncMock(return_value={"hits": {"hits": []}}),
|
||||||
):
|
):
|
||||||
response = asyncio.run(get_patents_by_keywords(request))
|
response = asyncio.run(get_patents_by_keywords(request))
|
||||||
|
|
||||||
assert response.mapping_status == "uncertain"
|
assert response.mapping_status == "search_error"
|
||||||
assert response.patent_count == 0
|
assert response.patent_count == 0
|
||||||
assert response.patents == []
|
|
||||||
search_epo.assert_not_called()
|
|
||||||
|
|
||||||
|
|
||||||
def test_json_lookup_returns_empty_without_mapping(monkeypatch) -> None:
|
def test_json_lookup_returns_empty_without_mapping(monkeypatch) -> None:
|
||||||
clear_reverse_lookup_caches()
|
clear_reverse_lookup_caches()
|
||||||
monkeypatch.setattr(
|
monkeypatch.setattr(
|
||||||
"inse.patents.keywords.reverse_lookup.load_patents_openalex_keywords_json",
|
"inse.patents.keywords.reverse_lookup.load_patents_openalex_keywords_json",
|
||||||
lambda: {},
|
dict,
|
||||||
)
|
)
|
||||||
clear_reverse_lookup_caches()
|
clear_reverse_lookup_caches()
|
||||||
|
|
||||||
|
|||||||
@@ -944,7 +944,6 @@ async def search_eu_cordis_projects(
|
|||||||
sort_by: str = "title",
|
sort_by: str = "title",
|
||||||
sort_direction: str = "asc",
|
sort_direction: str = "asc",
|
||||||
fuzzy: bool = False,
|
fuzzy: bool = False,
|
||||||
skip_enrichment: bool = False,
|
|
||||||
) -> EuCordisProjectSearchPage:
|
) -> EuCordisProjectSearchPage:
|
||||||
"""
|
"""
|
||||||
Generic EU CORDIS project search across FP7, H2020 and Horizon Europe.
|
Generic EU CORDIS project search across FP7, H2020 and Horizon Europe.
|
||||||
@@ -1016,14 +1015,6 @@ async def search_eu_cordis_projects(
|
|||||||
hits = response.get("hits", {}).get("hits", [])
|
hits = response.get("hits", {}).get("hits", [])
|
||||||
total = response.get("hits", {}).get("total", {}).get("value", 0)
|
total = response.get("hits", {}).get("total", {}).get("value", 0)
|
||||||
|
|
||||||
if skip_enrichment:
|
|
||||||
return EuCordisProjectSearchPage(
|
|
||||||
elements=[EuCordisProjectSummary.from_hit(hit) for hit in hits],
|
|
||||||
total=total,
|
|
||||||
page=page,
|
|
||||||
size=size,
|
|
||||||
)
|
|
||||||
|
|
||||||
project_ids_by_type: dict[EuCordisProjectType, list[str]] = defaultdict(list)
|
project_ids_by_type: dict[EuCordisProjectType, list[str]] = defaultdict(list)
|
||||||
|
|
||||||
for hit in hits:
|
for hit in hits:
|
||||||
@@ -1342,4 +1333,4 @@ async def get_openalex_authors_for_projects_ids(
|
|||||||
result[(project_type, pid)] = author_pages_by_project_id.get(
|
result[(project_type, pid)] = author_pages_by_project_id.get(
|
||||||
pid, AuthorPage(elements=[], total=0, page=0, size=0)
|
pid, AuthorPage(elements=[], total=0, page=0, size=0)
|
||||||
)
|
)
|
||||||
return result
|
return result
|
||||||
@@ -359,53 +359,6 @@ async def get_person_institutes(
|
|||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
|
||||||
async def get_dfg_institutes_by_ids(
|
|
||||||
institute_ids: list[int],
|
|
||||||
) -> dict[str, dict]:
|
|
||||||
|
|
||||||
if not institute_ids:
|
|
||||||
return {}
|
|
||||||
|
|
||||||
response = await elasticsearch.search(
|
|
||||||
index=ESIndex.DFG_INSTITUTES,
|
|
||||||
cluster=ESCluster.INSE,
|
|
||||||
body={
|
|
||||||
"size": len(institute_ids),
|
|
||||||
"_source": [
|
|
||||||
"institute_id",
|
|
||||||
"root_id",
|
|
||||||
"root_name_de",
|
|
||||||
"root_name_en",
|
|
||||||
"institute_name_de",
|
|
||||||
"institute_name_en",
|
|
||||||
"address_country_de",
|
|
||||||
"address_country_en",
|
|
||||||
],
|
|
||||||
"query": {
|
|
||||||
"terms": {
|
|
||||||
"_id": institute_ids,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
result = {}
|
|
||||||
|
|
||||||
for hit in response["hits"]["hits"]:
|
|
||||||
source = hit["_source"]
|
|
||||||
|
|
||||||
result[source["institute_id"]] = {
|
|
||||||
"institute_id": source["institute_id"],
|
|
||||||
"root_id": source.get("root_id"),
|
|
||||||
"root_name_de": source.get("root_name_de"),
|
|
||||||
"root_name_en": source.get("root_name_en"),
|
|
||||||
"institute_name_de": source.get("institute_name_de"),
|
|
||||||
"institute_name_en": source.get("institute_name_en"),
|
|
||||||
"address_country_de": source.get("address_country_de"),
|
|
||||||
"address_country_en": source.get("address_country_en"),
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
#EU Cordis Projects
|
#EU Cordis Projects
|
||||||
|
|
||||||
|
|||||||
@@ -250,41 +250,12 @@ class DfgProjectSummary(BaseModel):
|
|||||||
def from_hit(cls, hit: dict) -> "DfgProjectSummary":
|
def from_hit(cls, hit: dict) -> "DfgProjectSummary":
|
||||||
source = hit.get("_source", {})
|
source = hit.get("_source", {})
|
||||||
fields = hit.get("fields", {})
|
fields = hit.get("fields", {})
|
||||||
|
|
||||||
names = []
|
names = []
|
||||||
institutions = {}
|
institutions = {}
|
||||||
project_persons = []
|
project_persons = []
|
||||||
persons = source.get("persons", [])
|
|
||||||
institutions_raw= source.get("institutions", [])
|
|
||||||
if isinstance(institutions_raw, list):
|
|
||||||
for institution in institutions_raw:
|
|
||||||
if not isinstance(institution, dict):
|
|
||||||
continue
|
|
||||||
|
|
||||||
institute_id = institution.get("institute_id")
|
persons = source.get("persons", [])
|
||||||
if institute_id is not None:
|
|
||||||
institutions[f"institute:{institute_id}"] = DfgInstitutionSummary(
|
|
||||||
id=institute_id,
|
|
||||||
institute_name_de=institution.get("institute_name_de"),
|
|
||||||
institute_name_en=institution.get("institute_name_en"),
|
|
||||||
address_country_de=institution.get("address_country_de"),
|
|
||||||
address_country_en=institution.get("address_country_en"),
|
|
||||||
root_id=institution.get("root_id"),
|
|
||||||
root_name_de=institution.get("root_name_de"),
|
|
||||||
root_name_en=institution.get("root_name_en"),
|
|
||||||
)
|
|
||||||
root_id = institution.get("root_id")
|
|
||||||
if root_id is not None:
|
|
||||||
institutions[f"root:{root_id}"] = DfgInstitutionSummary(
|
|
||||||
id=root_id,
|
|
||||||
institute_name_de=institution.get("root_name_de"),
|
|
||||||
institute_name_en=institution.get("root_name_en"),
|
|
||||||
address_country_de=institution.get("address_country_de"),
|
|
||||||
address_country_en=institution.get("address_country_en"),
|
|
||||||
root_id=None,
|
|
||||||
root_name_de=None,
|
|
||||||
root_name_en=None,
|
|
||||||
)
|
|
||||||
|
|
||||||
if isinstance(persons, list):
|
if isinstance(persons, list):
|
||||||
for person in persons:
|
for person in persons:
|
||||||
@@ -295,35 +266,35 @@ class DfgProjectSummary(BaseModel):
|
|||||||
|
|
||||||
if full_name:
|
if full_name:
|
||||||
names.append(full_name.strip())
|
names.append(full_name.strip())
|
||||||
# previously we were creating institution objects for each person, but now we are using the institutions from the institutions_raw list
|
|
||||||
#institution = None
|
|
||||||
# if person.get("institute_id") is not None:
|
|
||||||
# institute = DfgInstitutionSummary(
|
|
||||||
# id=person["institute_id"],
|
|
||||||
# institute_name_de=person.get("institute_name_de"),
|
|
||||||
# institute_name_en=person.get("institute_name_en"),
|
|
||||||
# address_country_de=person.get("address_country_de"),
|
|
||||||
# address_country_en=person.get("address_country_en"),
|
|
||||||
# root_id=None,
|
|
||||||
# root_name_de=None,
|
|
||||||
# root_name_en=None,
|
|
||||||
# )
|
|
||||||
|
|
||||||
# institutions[f"institute:{person['institute_id']}"] = institute
|
institution = None
|
||||||
|
if person.get("institute_id") is not None:
|
||||||
|
institute = DfgInstitutionSummary(
|
||||||
|
id=person["institute_id"],
|
||||||
|
institute_name_de=person.get("institute_name_de"),
|
||||||
|
institute_name_en=person.get("institute_name_en"),
|
||||||
|
address_country_de=person.get("address_country_de"),
|
||||||
|
address_country_en=person.get("address_country_en"),
|
||||||
|
root_id=None,
|
||||||
|
root_name_de=None,
|
||||||
|
root_name_en=None,
|
||||||
|
)
|
||||||
|
|
||||||
# if person.get("root_id") is not None:
|
institutions[f"institute:{person['institute_id']}"] = institute
|
||||||
# root_institution = DfgInstitutionSummary(
|
|
||||||
# id=person["root_id"],
|
|
||||||
# institute_name_de=person.get("root_name_de"),
|
|
||||||
# institute_name_en=person.get("root_name_en"),
|
|
||||||
# address_country_de=person.get("address_country_de"),
|
|
||||||
# address_country_en=person.get("address_country_en"),
|
|
||||||
# root_id=None,
|
|
||||||
# root_name_de=None,
|
|
||||||
# root_name_en=None,
|
|
||||||
# )
|
|
||||||
|
|
||||||
# institutions[f"root:{person['root_id']}"] = root_institution
|
if person.get("root_id") is not None:
|
||||||
|
root_institution = DfgInstitutionSummary(
|
||||||
|
id=person["root_id"],
|
||||||
|
institute_name_de=person.get("root_name_de"),
|
||||||
|
institute_name_en=person.get("root_name_en"),
|
||||||
|
address_country_de=person.get("address_country_de"),
|
||||||
|
address_country_en=person.get("address_country_en"),
|
||||||
|
root_id=None,
|
||||||
|
root_name_de=None,
|
||||||
|
root_name_en=None,
|
||||||
|
)
|
||||||
|
|
||||||
|
institutions[f"root:{person['root_id']}"] = root_institution
|
||||||
|
|
||||||
if person.get("person_id") is not None:
|
if person.get("person_id") is not None:
|
||||||
project_persons.append(
|
project_persons.append(
|
||||||
@@ -334,7 +305,7 @@ class DfgProjectSummary(BaseModel):
|
|||||||
full_name=full_name,
|
full_name=full_name,
|
||||||
role_label_en=person.get("role_label_en"),
|
role_label_en=person.get("role_label_en"),
|
||||||
role_label_de=person.get("role_label_de"),
|
role_label_de=person.get("role_label_de"),
|
||||||
institution=None,
|
institution=institution,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
topics_raw = source.get("topics") or []
|
topics_raw = source.get("topics") or []
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ from inse.projects.logic import (
|
|||||||
get_openalex_topics_for_bund_projects,
|
get_openalex_topics_for_bund_projects,
|
||||||
get_openalex_topics_for_dfg_projects,
|
get_openalex_topics_for_dfg_projects,
|
||||||
get_person_ids_by_institution_ids,
|
get_person_ids_by_institution_ids,
|
||||||
get_dfg_institutes_by_ids,
|
|
||||||
get_person_institutes,
|
get_person_institutes,
|
||||||
)
|
)
|
||||||
from inse.projects.model import (
|
from inse.projects.model import (
|
||||||
@@ -367,7 +366,6 @@ async def search_dfg_projects(
|
|||||||
sort_by: str = "id",
|
sort_by: str = "id",
|
||||||
sort_direction: str = "asc",
|
sort_direction: str = "asc",
|
||||||
fuzzy: bool = False,
|
fuzzy: bool = False,
|
||||||
skip_enrichment: bool = False,
|
|
||||||
) -> DfgProjectPage:
|
) -> DfgProjectPage:
|
||||||
"""Searches for DFG projects based on the provided filtering and sorting criteria.
|
"""Searches for DFG projects based on the provided filtering and sorting criteria.
|
||||||
|
|
||||||
@@ -413,7 +411,6 @@ async def search_dfg_projects(
|
|||||||
"subject_area_en",
|
"subject_area_en",
|
||||||
"persons",
|
"persons",
|
||||||
"subject_classifications",
|
"subject_classifications",
|
||||||
"institutions",
|
|
||||||
],
|
],
|
||||||
"query": {},
|
"query": {},
|
||||||
}
|
}
|
||||||
@@ -525,54 +522,34 @@ async def search_dfg_projects(
|
|||||||
)
|
)
|
||||||
if not matching_institution_ids:
|
if not matching_institution_ids:
|
||||||
return DfgProjectPage(elements=[], total=0, page=page, size=size)
|
return DfgProjectPage(elements=[], total=0, page=page, size=size)
|
||||||
#previously we were filtering by person_ids, but now we are filtering by institution_ids directly
|
matching_person_ids = await get_person_ids_by_institution_ids(
|
||||||
# matching_person_ids = await get_person_ids_by_institution_ids(
|
institution_ids=matching_institution_ids
|
||||||
# institution_ids=matching_institution_ids
|
)
|
||||||
# )
|
|
||||||
# must_clauses.append(
|
|
||||||
# {
|
|
||||||
# "nested": {
|
|
||||||
# "path": "persons",
|
|
||||||
# "query": {"terms": {"persons.person_id": matching_person_ids}},
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
# )
|
|
||||||
must_clauses.append(
|
must_clauses.append(
|
||||||
{
|
{
|
||||||
"nested": {
|
"nested": {
|
||||||
"path": "institutions",
|
"path": "persons",
|
||||||
"query": {"terms": {"institutions.institute_id": matching_institution_ids}},
|
"query": {"terms": {"persons.person_id": matching_person_ids}},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
print("MATCHING_INSTITUTION_IDS", matching_institution_ids)
|
|
||||||
|
|
||||||
if institution_ids:
|
if institution_ids:
|
||||||
#prevously we were filtering by person_ids, but now we are filtering by institution_ids directly
|
matching_person_ids = await get_person_ids_by_institution_ids(
|
||||||
# matching_person_ids = await get_person_ids_by_institution_ids(
|
institution_ids=institution_ids
|
||||||
# institution_ids=institution_ids
|
)
|
||||||
# )
|
|
||||||
|
|
||||||
# if not matching_person_ids:
|
if not matching_person_ids:
|
||||||
# return DfgProjectPage(elements=[], total=0, page=page, size=size)
|
return DfgProjectPage(elements=[], total=0, page=page, size=size)
|
||||||
|
|
||||||
# must_clauses.append(
|
|
||||||
# {
|
|
||||||
# "nested": {
|
|
||||||
# "path": "persons",
|
|
||||||
# "query": {"terms": {"persons.person_id": matching_person_ids}},
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
# )
|
|
||||||
must_clauses.append(
|
must_clauses.append(
|
||||||
{
|
{
|
||||||
"nested": {
|
"nested": {
|
||||||
"path": "institutions",
|
"path": "persons",
|
||||||
"query": {"terms": {"institutions.institute_id": institution_ids}},
|
"query": {"terms": {"persons.person_id": matching_person_ids}},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
body["query"] = (
|
body["query"] = (
|
||||||
{"bool": {"must": must_clauses}} if must_clauses else {"match_all": {}}
|
{"bool": {"must": must_clauses}} if must_clauses else {"match_all": {}}
|
||||||
@@ -599,7 +576,6 @@ async def search_dfg_projects(
|
|||||||
body["sort"] = [sort_config]
|
body["sort"] = [sort_config]
|
||||||
# print(f"Executing DFG project search with body: {json.dumps(body, indent=2)}")
|
# print(f"Executing DFG project search with body: {json.dumps(body, indent=2)}")
|
||||||
# === Execute Search ===
|
# === Execute Search ===
|
||||||
print(f"Executing DFG project search with body: {json.dumps(body, indent=2)}")
|
|
||||||
response = await elasticsearch.search(
|
response = await elasticsearch.search(
|
||||||
index=ESIndex.DFG_PROJECTS,
|
index=ESIndex.DFG_PROJECTS,
|
||||||
body=body,
|
body=body,
|
||||||
@@ -608,9 +584,6 @@ async def search_dfg_projects(
|
|||||||
|
|
||||||
hits = response.get("hits", {}).get("hits", [])
|
hits = response.get("hits", {}).get("hits", [])
|
||||||
|
|
||||||
if skip_enrichment:
|
|
||||||
return _complete_response_to_dfg_project_page(response, page, size)
|
|
||||||
|
|
||||||
project_ids = [hit["_source"]["id"] for hit in hits]
|
project_ids = [hit["_source"]["id"] for hit in hits]
|
||||||
topic_lookup = await get_openalex_topics_for_dfg_projects(project_ids=project_ids)
|
topic_lookup = await get_openalex_topics_for_dfg_projects(project_ids=project_ids)
|
||||||
|
|
||||||
@@ -626,28 +599,21 @@ async def search_dfg_projects(
|
|||||||
source = hit["_source"]
|
source = hit["_source"]
|
||||||
project_id = source["id"]
|
project_id = source["id"]
|
||||||
source["topics"] = topic_lookup.get(str(project_id), [])
|
source["topics"] = topic_lookup.get(str(project_id), [])
|
||||||
institutions = source.get("institutions", [])
|
|
||||||
for institution in institutions:
|
|
||||||
institute_id = institution.get("institute_id")
|
|
||||||
if institute_id is not None:
|
|
||||||
institute_info = await get_dfg_institutes_by_ids(institute_ids=[institute_id])
|
|
||||||
if institute_info:
|
|
||||||
institution.update(institute_info[institute_id])
|
|
||||||
persons = source.get("persons", [])
|
persons = source.get("persons", [])
|
||||||
for person in persons:
|
for person in persons:
|
||||||
person_id = person.get("person_id")
|
person_id = person.get("person_id")
|
||||||
institute = person_lookup.get(person_id)
|
institute = person_lookup.get(person_id)
|
||||||
|
|
||||||
# if institute:
|
if institute:
|
||||||
# person["root_id"] = institute.get("root_id")
|
person["root_id"] = institute.get("root_id")
|
||||||
# person["institute_id"] = institute.get("institute_id")
|
person["institute_id"] = institute.get("institute_id")
|
||||||
# person["root_name_de"] = institute.get("root_name_de")
|
person["root_name_de"] = institute.get("root_name_de")
|
||||||
# person["root_name_en"] = institute.get("root_name_en")
|
person["root_name_en"] = institute.get("root_name_en")
|
||||||
# person["institute_name_de"] = institute.get("institute_name_de")
|
person["institute_name_de"] = institute.get("institute_name_de")
|
||||||
# person["institute_name_en"] = institute.get("institute_name_en")
|
person["institute_name_en"] = institute.get("institute_name_en")
|
||||||
# person["address_country_de"] = institute.get("address_country_de")
|
person["address_country_de"] = institute.get("address_country_de")
|
||||||
# person["address_country_en"] = institute.get("address_country_en")
|
person["address_country_en"] = institute.get("address_country_en")
|
||||||
print("ENRIECHED",source.get("institutions", []))
|
|
||||||
return _complete_response_to_dfg_project_page(response, page, size)
|
return _complete_response_to_dfg_project_page(response, page, size)
|
||||||
|
|
||||||
def _complete_response_to_dfg_project_page(
|
def _complete_response_to_dfg_project_page(
|
||||||
@@ -688,128 +654,12 @@ async def get_dfg_project_by_id(project_id: str) -> DfgProjectDetails | None:
|
|||||||
)
|
)
|
||||||
hits = response.get("hits", {}).get("hits", [])
|
hits = response.get("hits", {}).get("hits", [])
|
||||||
|
|
||||||
if not hits:
|
if hits:
|
||||||
return None
|
hit = hits[0]
|
||||||
|
hit["_source"]["topics"] = topic_lookup.get(project_id, [])
|
||||||
hit = hits[0]
|
details = DfgProjectDetails.from_elastic_hit(hit=hit)
|
||||||
source = hit["_source"]
|
return details
|
||||||
source["topics"] = topic_lookup.get(project_id, [])
|
return None
|
||||||
|
|
||||||
persons = source.get("persons", [])
|
|
||||||
|
|
||||||
# --- Enrich persons with institute/root info (mirrors search_dfg_projects) ---
|
|
||||||
person_ids = {
|
|
||||||
person["person_id"]
|
|
||||||
for person in persons
|
|
||||||
if isinstance(person, dict) and person.get("person_id") is not None
|
|
||||||
}
|
|
||||||
person_lookup = await get_person_institutes(person_ids=list(person_ids))
|
|
||||||
|
|
||||||
institutions: dict[str, dict] = {}
|
|
||||||
|
|
||||||
for person in persons:
|
|
||||||
person_id = person.get("person_id")
|
|
||||||
institute = person_lookup.get(person_id)
|
|
||||||
if not institute:
|
|
||||||
continue
|
|
||||||
|
|
||||||
person["root_id"] = institute.get("root_id")
|
|
||||||
person["institute_id"] = institute.get("institute_id")
|
|
||||||
person["root_name_de"] = institute.get("root_name_de")
|
|
||||||
person["root_name_en"] = institute.get("root_name_en")
|
|
||||||
person["institute_name_de"] = institute.get("institute_name_de")
|
|
||||||
person["institute_name_en"] = institute.get("institute_name_en")
|
|
||||||
person["address_country_de"] = institute.get("address_country_de")
|
|
||||||
person["address_country_en"] = institute.get("address_country_en")
|
|
||||||
|
|
||||||
if institute.get("institute_id") is not None:
|
|
||||||
institutions[f"institute:{institute['institute_id']}"] = {
|
|
||||||
"institute_id": institute["institute_id"],
|
|
||||||
"institute_name_de": institute.get("institute_name_de"),
|
|
||||||
"institute_name_en": institute.get("institute_name_en"),
|
|
||||||
}
|
|
||||||
|
|
||||||
if institute.get("root_id") is not None:
|
|
||||||
institutions[f"root:{institute['root_id']}"] = {
|
|
||||||
"institute_id": institute["root_id"],
|
|
||||||
"institute_name_de": institute.get("root_name_de"),
|
|
||||||
"institute_name_en": institute.get("root_name_en"),
|
|
||||||
}
|
|
||||||
|
|
||||||
source["institutions"] = list(institutions.values())
|
|
||||||
|
|
||||||
return DfgProjectDetails.from_elastic_hit(hit=hit)
|
|
||||||
|
|
||||||
async def get_dfg_project_by_id(project_id: str) -> DfgProjectDetails | None:
|
|
||||||
"""Fetches the details of a single DFG project based on its project ID.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
project_id (str): The project ID to fetch.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
Optional[DfgProjectDetails]: The project details or None if not found.
|
|
||||||
"""
|
|
||||||
topic_lookup = await get_openalex_topics_for_dfg_projects(project_ids=[project_id])
|
|
||||||
query = {"ids": {"values": [project_id]}}
|
|
||||||
|
|
||||||
response = await elasticsearch.search(
|
|
||||||
index=ESIndex.DFG_PROJECTS,
|
|
||||||
query=query,
|
|
||||||
size=1,
|
|
||||||
)
|
|
||||||
hits = response.get("hits", {}).get("hits", [])
|
|
||||||
|
|
||||||
if not hits:
|
|
||||||
return None
|
|
||||||
|
|
||||||
hit = hits[0]
|
|
||||||
source = hit["_source"]
|
|
||||||
source["topics"] = topic_lookup.get(project_id, [])
|
|
||||||
|
|
||||||
persons = source.get("persons", [])
|
|
||||||
|
|
||||||
#Enrich persons with institute/root info
|
|
||||||
person_ids = {
|
|
||||||
person["person_id"]
|
|
||||||
for person in persons
|
|
||||||
if isinstance(person, dict) and person.get("person_id") is not None
|
|
||||||
}
|
|
||||||
person_lookup = await get_person_institutes(person_ids=list(person_ids))
|
|
||||||
|
|
||||||
institutions: dict[str, dict] = {}
|
|
||||||
|
|
||||||
for person in persons:
|
|
||||||
person_id = person.get("person_id")
|
|
||||||
institute = person_lookup.get(person_id)
|
|
||||||
if not institute:
|
|
||||||
continue
|
|
||||||
|
|
||||||
person["root_id"] = institute.get("root_id")
|
|
||||||
person["institute_id"] = institute.get("institute_id")
|
|
||||||
person["root_name_de"] = institute.get("root_name_de")
|
|
||||||
person["root_name_en"] = institute.get("root_name_en")
|
|
||||||
person["institute_name_de"] = institute.get("institute_name_de")
|
|
||||||
person["institute_name_en"] = institute.get("institute_name_en")
|
|
||||||
person["address_country_de"] = institute.get("address_country_de")
|
|
||||||
person["address_country_en"] = institute.get("address_country_en")
|
|
||||||
|
|
||||||
if institute.get("institute_id") is not None:
|
|
||||||
institutions[f"institute:{institute['institute_id']}"] = {
|
|
||||||
"institute_id": institute["institute_id"],
|
|
||||||
"institute_name_de": institute.get("institute_name_de"),
|
|
||||||
"institute_name_en": institute.get("institute_name_en"),
|
|
||||||
}
|
|
||||||
|
|
||||||
if institute.get("root_id") is not None:
|
|
||||||
institutions[f"root:{institute['root_id']}"] = {
|
|
||||||
"institute_id": institute["root_id"],
|
|
||||||
"institute_name_de": institute.get("root_name_de"),
|
|
||||||
"institute_name_en": institute.get("root_name_en"),
|
|
||||||
}
|
|
||||||
|
|
||||||
source["institutions"] = list(institutions.values())
|
|
||||||
|
|
||||||
return DfgProjectDetails.from_elastic_hit(hit=hit)
|
|
||||||
|
|
||||||
#BUND
|
#BUND
|
||||||
|
|
||||||
@@ -1201,4 +1051,4 @@ def _hit_to_funding_project(hit: dict[str, Any]) -> FundingProject:
|
|||||||
else:
|
else:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"The provided hit does not belong to a recognized project index."
|
"The provided hit does not belong to a recognized project index."
|
||||||
)
|
)
|
||||||
@@ -174,7 +174,6 @@ async def get_dfg_projects_by_author_id(
|
|||||||
sort_by: str = "topic",
|
sort_by: str = "topic",
|
||||||
sort_direction: str = "asc",
|
sort_direction: str = "asc",
|
||||||
fuzzy: bool = False,
|
fuzzy: bool = False,
|
||||||
skip_enrichment: bool = False,
|
|
||||||
) -> DfgProjectPage:
|
) -> DfgProjectPage:
|
||||||
logger.debug(
|
logger.debug(
|
||||||
"Fetching DFG projects for author_id=%s, author_filter_ids=%s, "
|
"Fetching DFG projects for author_id=%s, author_filter_ids=%s, "
|
||||||
@@ -249,7 +248,6 @@ async def get_dfg_projects_by_author_id(
|
|||||||
sort_by=sort_by,
|
sort_by=sort_by,
|
||||||
sort_direction=sort_direction,
|
sort_direction=sort_direction,
|
||||||
fuzzy=fuzzy,
|
fuzzy=fuzzy,
|
||||||
skip_enrichment=skip_enrichment,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
async def get_institution_cordis_eu_projects_funding_over_time(
|
async def get_institution_cordis_eu_projects_funding_over_time(
|
||||||
@@ -625,7 +623,6 @@ async def search_eu_cordis_projects(
|
|||||||
sort_by: str = "title",
|
sort_by: str = "title",
|
||||||
sort_direction: str = "asc",
|
sort_direction: str = "asc",
|
||||||
fuzzy: bool = False,
|
fuzzy: bool = False,
|
||||||
skip_enrichment: bool = False,
|
|
||||||
) -> EuCordisProjectSearchPage:
|
) -> EuCordisProjectSearchPage:
|
||||||
"""Single entry point for EU CORDIS project search.
|
"""Single entry point for EU CORDIS project search.
|
||||||
|
|
||||||
@@ -686,5 +683,4 @@ async def search_eu_cordis_projects(
|
|||||||
sort_by=sort_by,
|
sort_by=sort_by,
|
||||||
sort_direction=sort_direction,
|
sort_direction=sort_direction,
|
||||||
fuzzy=fuzzy,
|
fuzzy=fuzzy,
|
||||||
skip_enrichment=skip_enrichment,
|
)
|
||||||
)
|
|
||||||
@@ -3,10 +3,11 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from math import floor
|
|
||||||
from time import time
|
from time import time
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
from inse.authors.institution_membership_query import (
|
from inse.authors.institution_membership_query import (
|
||||||
build_active_institution_membership_query,
|
build_active_institution_membership_query,
|
||||||
)
|
)
|
||||||
@@ -745,29 +746,15 @@ def _bucket_to_ranked_author(author_bucket: dict) -> RankedAuthor:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _quantile(values: list[float], quantile: float) -> float:
|
def _min_max_normalize(values: pd.Series) -> pd.Series:
|
||||||
"""Returns a linearly interpolated quantile (the former pandas default)."""
|
|
||||||
ordered = sorted(values)
|
|
||||||
if not ordered:
|
|
||||||
return 0.0
|
|
||||||
position = (len(ordered) - 1) * quantile
|
|
||||||
lower_index = floor(position)
|
|
||||||
upper_index = min(lower_index + 1, len(ordered) - 1)
|
|
||||||
fraction = position - lower_index
|
|
||||||
return ordered[lower_index] + (
|
|
||||||
ordered[upper_index] - ordered[lower_index]
|
|
||||||
) * fraction
|
|
||||||
|
|
||||||
|
|
||||||
def _min_max_normalize(values: list[float]) -> list[float]:
|
|
||||||
"""Scales a numeric column to the range [0, 1] via min-max normalization."""
|
"""Scales a numeric column to the range [0, 1] via min-max normalization."""
|
||||||
minimum = min(values)
|
minimum = values.min()
|
||||||
maximum = max(values)
|
maximum = values.max()
|
||||||
# if all values are the same, return a series of 1.0 to avoid division by zero.
|
# if all values are the same, return a series of 1.0 to avoid division by zero.
|
||||||
if maximum == minimum:
|
if maximum == minimum:
|
||||||
return [1.0] * len(values)
|
return pd.Series([1.0] * len(values))
|
||||||
|
|
||||||
return [(value - minimum) / (maximum - minimum) for value in values]
|
return (values - minimum) / (maximum - minimum)
|
||||||
|
|
||||||
|
|
||||||
def _apply_scores(authors: list[RankedAuthor], weights: RankingWeights) -> None:
|
def _apply_scores(authors: list[RankedAuthor], weights: RankingWeights) -> None:
|
||||||
@@ -788,29 +775,38 @@ def _apply_scores(authors: list[RankedAuthor], weights: RankingWeights) -> None:
|
|||||||
news_counts.append(author.news_count)
|
news_counts.append(author.news_count)
|
||||||
patents_counts.append(author.patents_count)
|
patents_counts.append(author.patents_count)
|
||||||
|
|
||||||
|
frame = pd.DataFrame({
|
||||||
|
"works": works_counts,
|
||||||
|
"citations": citations_counts,
|
||||||
|
"companies": companies_counts,
|
||||||
|
"news": news_counts,
|
||||||
|
"patents": patents_counts,
|
||||||
|
})
|
||||||
|
|
||||||
quantile_value = 0.95
|
quantile_value = 0.95
|
||||||
metrics = [
|
|
||||||
works_counts,
|
frame["works"] = frame["works"].clip(upper=frame["works"].quantile(quantile_value))
|
||||||
citations_counts,
|
frame["citations"] = frame["citations"].clip(upper=frame["citations"].quantile(quantile_value))
|
||||||
companies_counts,
|
frame["companies"] = frame["companies"].clip(upper=frame["companies"].quantile(quantile_value))
|
||||||
news_counts,
|
frame["news"] = frame["news"].clip(upper=frame["news"].quantile(quantile_value))
|
||||||
patents_counts,
|
frame["patents"] = frame["patents"].clip(upper=frame["patents"].quantile(quantile_value))
|
||||||
]
|
|
||||||
normalized_metrics = [
|
works_normalized = _min_max_normalize(frame["works"])
|
||||||
_min_max_normalize(
|
citations_normalized = _min_max_normalize(frame["citations"])
|
||||||
[min(value, _quantile(values, quantile_value)) for value in values]
|
companies_normalized = _min_max_normalize(frame["companies"])
|
||||||
)
|
news_normalized = _min_max_normalize(frame["news"])
|
||||||
for values in metrics
|
patents_normalized = _min_max_normalize(frame["patents"])
|
||||||
]
|
|
||||||
|
scores = (
|
||||||
|
works_normalized * weights.works
|
||||||
|
+ citations_normalized * weights.citation
|
||||||
|
+ companies_normalized * weights.companies
|
||||||
|
+ news_normalized * weights.news
|
||||||
|
+ patents_normalized * weights.patents
|
||||||
|
)
|
||||||
|
|
||||||
for index, author in enumerate(authors):
|
for index, author in enumerate(authors):
|
||||||
author.score = float(
|
author.score = float(scores.iloc[index])
|
||||||
normalized_metrics[0][index] * weights.works
|
|
||||||
+ normalized_metrics[1][index] * weights.citation
|
|
||||||
+ normalized_metrics[2][index] * weights.companies
|
|
||||||
+ normalized_metrics[3][index] * weights.news
|
|
||||||
+ normalized_metrics[4][index] * weights.patents
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def _author_score(author: RankedAuthor) -> float:
|
def _author_score(author: RankedAuthor) -> float:
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ router = APIRouter(prefix=RouterPrefixes.WORKS_V2, tags=[Tags.WORKS_V2])
|
|||||||
|
|
||||||
|
|
||||||
@router.get(
|
@router.get(
|
||||||
"/single/{raw_oa_work_id}",
|
"/{raw_oa_work_id}",
|
||||||
operation_id="getWorkById",
|
operation_id="getWorkById",
|
||||||
summary="Returns a work based on its ID.",
|
summary="Returns a work based on its ID.",
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -103,11 +103,11 @@ model/dfgPersonSummary.ts
|
|||||||
model/dfgPersonSummaryPage.ts
|
model/dfgPersonSummaryPage.ts
|
||||||
model/dfgProjectDetails.ts
|
model/dfgProjectDetails.ts
|
||||||
model/dfgProjectInstitutionRole.ts
|
model/dfgProjectInstitutionRole.ts
|
||||||
model/dfgProjectKeyword.ts
|
|
||||||
model/dfgProjectPage.ts
|
model/dfgProjectPage.ts
|
||||||
model/dfgProjectPersonRole.ts
|
model/dfgProjectPersonRole.ts
|
||||||
model/dfgProjectPublicationSummary.ts
|
model/dfgProjectPublicationSummary.ts
|
||||||
model/dfgProjectStatusStatistics.ts
|
model/dfgProjectStatusStatistics.ts
|
||||||
|
model/dfgProjectSubjectArea.ts
|
||||||
model/dfgProjectSubprojectSummary.ts
|
model/dfgProjectSubprojectSummary.ts
|
||||||
model/dfgProjectSummary.ts
|
model/dfgProjectSummary.ts
|
||||||
model/dfgProjectTopic.ts
|
model/dfgProjectTopic.ts
|
||||||
|
|||||||
@@ -65,71 +65,6 @@ export class AuthService extends BaseService {
|
|||||||
super(basePath, configuration);
|
super(basePath, configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if user can fetch GDPR-relevant data
|
|
||||||
* Check if the authenticated user can fetch GDPR-relevant data for a given author and institution.
|
|
||||||
* @endpoint get /api/auth/v2/can-fetch-gdpr-relevant-data
|
|
||||||
* @param rawOaAuthorId OpenAlex author ID to check access for
|
|
||||||
* @param rawOaInstitutionId OpenAlex institution ID to check access for
|
|
||||||
* @param secureFgpAcc
|
|
||||||
* @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 canFetchGdprRelevantData(rawOaAuthorId?: string, rawOaInstitutionId?: string, secureFgpAcc?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<boolean>;
|
|
||||||
public canFetchGdprRelevantData(rawOaAuthorId?: string, rawOaInstitutionId?: string, secureFgpAcc?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<boolean>>;
|
|
||||||
public canFetchGdprRelevantData(rawOaAuthorId?: string, rawOaInstitutionId?: string, secureFgpAcc?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<boolean>>;
|
|
||||||
public canFetchGdprRelevantData(rawOaAuthorId?: string, rawOaInstitutionId?: string, secureFgpAcc?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
|
|
||||||
|
|
||||||
let localVarQueryParameters = new HttpParams({encoder: this.encoder});
|
|
||||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
|
||||||
<any>rawOaAuthorId, 'raw_oa_author_id');
|
|
||||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
|
||||||
<any>rawOaInstitutionId, 'raw_oa_institution_id');
|
|
||||||
|
|
||||||
let localVarHeaders = this.defaultHeaders;
|
|
||||||
|
|
||||||
// authentication (HTTPBearer) required
|
|
||||||
localVarHeaders = this.configuration.addCredentialToHeaders('HTTPBearer', 'Authorization', localVarHeaders, 'Bearer ');
|
|
||||||
|
|
||||||
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/auth/v2/can-fetch-gdpr-relevant-data`;
|
|
||||||
const { basePath, withCredentials } = this.configuration;
|
|
||||||
return this.httpClient.request<boolean>('get', `${basePath}${localVarPath}`,
|
|
||||||
{
|
|
||||||
context: localVarHttpContext,
|
|
||||||
params: localVarQueryParameters,
|
|
||||||
responseType: <any>responseType_,
|
|
||||||
...(withCredentials ? { withCredentials } : {}),
|
|
||||||
headers: localVarHeaders,
|
|
||||||
observe: observe,
|
|
||||||
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
|
|
||||||
reportProgress: reportProgress
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change Password
|
* Change Password
|
||||||
* Change the user\'s password and invalidate existing tokens.
|
* Change the user\'s password and invalidate existing tokens.
|
||||||
|
|||||||
@@ -511,7 +511,7 @@ export class WorksV2Service extends BaseService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a work based on its ID.
|
* Returns a work based on its ID.
|
||||||
* @endpoint get /api/works/v2/single/{raw_oa_work_id}
|
* @endpoint get /api/works/v2/{raw_oa_work_id}
|
||||||
* @param rawOaWorkId The raw OpenAlex work id.
|
* @param rawOaWorkId The raw OpenAlex work id.
|
||||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
* @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.
|
* @param reportProgress flag to report request and response progress.
|
||||||
@@ -549,7 +549,7 @@ export class WorksV2Service extends BaseService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let localVarPath = `/api/works/v2/single/${this.configuration.encodeParam({name: "rawOaWorkId", value: rawOaWorkId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`;
|
let localVarPath = `/api/works/v2/${this.configuration.encodeParam({name: "rawOaWorkId", value: rawOaWorkId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`;
|
||||||
const { basePath, withCredentials } = this.configuration;
|
const { basePath, withCredentials } = this.configuration;
|
||||||
return this.httpClient.request<Work>('get', `${basePath}${localVarPath}`,
|
return this.httpClient.request<Work>('get', `${basePath}${localVarPath}`,
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
import { DfgProjectPersonRole } from './dfgProjectPersonRole';
|
import { DfgProjectPersonRole } from './dfgProjectPersonRole';
|
||||||
import { DfgProjectSubprojectSummary } from './dfgProjectSubprojectSummary';
|
import { DfgProjectSubprojectSummary } from './dfgProjectSubprojectSummary';
|
||||||
import { DfgProjectInstitutionRole } from './dfgProjectInstitutionRole';
|
import { DfgProjectInstitutionRole } from './dfgProjectInstitutionRole';
|
||||||
import { DFGProjectFachgebieteInner } from './dFGProjectFachgebieteInner';
|
import { DfgProjectSubjectArea } from './dfgProjectSubjectArea';
|
||||||
import { Topic } from './topic';
|
import { Topic } from './topic';
|
||||||
import { DfgProjectPublicationSummary } from './dfgProjectPublicationSummary';
|
import { DfgProjectPublicationSummary } from './dfgProjectPublicationSummary';
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ export interface DfgProjectDetails {
|
|||||||
/**
|
/**
|
||||||
* Detailed DFG subject-area classification entries (Fachsystematik)
|
* Detailed DFG subject-area classification entries (Fachsystematik)
|
||||||
*/
|
*/
|
||||||
subject_classifications?: Array<DFGProjectFachgebieteInner>;
|
subject_classifications?: Array<DfgProjectSubjectArea>;
|
||||||
international_relation_de?: string | null;
|
international_relation_de?: string | null;
|
||||||
international_relation_en?: string | null;
|
international_relation_en?: string | null;
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
/**
|
|
||||||
* 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 DfgProjectKeyword {
|
|
||||||
name: string;
|
|
||||||
project_count: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A single subject-area classification entry (DFG \'Fachsystematik\').
|
||||||
|
*/
|
||||||
|
export interface DfgProjectSubjectArea {
|
||||||
|
fach?: string | null;
|
||||||
|
fachgebiet?: string | null;
|
||||||
|
fachkollegium?: string | null;
|
||||||
|
wissenschaftsbereich?: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -7,7 +7,6 @@
|
|||||||
* https://openapi-generator.tech
|
* https://openapi-generator.tech
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
import { DfgProjectKeyword } from './dfgProjectKeyword';
|
|
||||||
|
|
||||||
|
|
||||||
export interface DfgProjectTopic {
|
export interface DfgProjectTopic {
|
||||||
@@ -17,6 +16,5 @@ export interface DfgProjectTopic {
|
|||||||
field?: string | null;
|
field?: string | null;
|
||||||
domain?: string | null;
|
domain?: string | null;
|
||||||
project_count: number;
|
project_count: number;
|
||||||
keywords: Array<DfgProjectKeyword>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,11 +68,11 @@ export * from './dfgPersonSummary';
|
|||||||
export * from './dfgPersonSummaryPage';
|
export * from './dfgPersonSummaryPage';
|
||||||
export * from './dfgProjectDetails';
|
export * from './dfgProjectDetails';
|
||||||
export * from './dfgProjectInstitutionRole';
|
export * from './dfgProjectInstitutionRole';
|
||||||
export * from './dfgProjectKeyword';
|
|
||||||
export * from './dfgProjectPage';
|
export * from './dfgProjectPage';
|
||||||
export * from './dfgProjectPersonRole';
|
export * from './dfgProjectPersonRole';
|
||||||
export * from './dfgProjectPublicationSummary';
|
export * from './dfgProjectPublicationSummary';
|
||||||
export * from './dfgProjectStatusStatistics';
|
export * from './dfgProjectStatusStatistics';
|
||||||
|
export * from './dfgProjectSubjectArea';
|
||||||
export * from './dfgProjectSubprojectSummary';
|
export * from './dfgProjectSubprojectSummary';
|
||||||
export * from './dfgProjectSummary';
|
export * from './dfgProjectSummary';
|
||||||
export * from './dfgProjectTopic';
|
export * from './dfgProjectTopic';
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { personPatentsResolver } from './resolvers/person-patents.resolver';
|
|||||||
import { personResolver } from './resolvers/person.resolver';
|
import { personResolver } from './resolvers/person.resolver';
|
||||||
import { personNewsResolver } from './resolvers/person-news.resolver';
|
import { personNewsResolver } from './resolvers/person-news.resolver';
|
||||||
import { institutionResolver } from './resolvers/institution.resolver';
|
import { institutionResolver } from './resolvers/institution.resolver';
|
||||||
|
import { bundProjectPageResolver } from './resolvers/bund-project-page.resolver';
|
||||||
import {
|
import {
|
||||||
dfgProjectsResolver,
|
dfgProjectsResolver,
|
||||||
RESOLVING_PROJECT_PAGE_FOR,
|
RESOLVING_PROJECT_PAGE_FOR,
|
||||||
@@ -64,7 +65,6 @@ import {
|
|||||||
topicQueryParamKeys,
|
topicQueryParamKeys,
|
||||||
} from './resolvers/topic-page.resolver';
|
} from './resolvers/topic-page.resolver';
|
||||||
import { topicResolver } from './resolvers/topic.resolver';
|
import { topicResolver } from './resolvers/topic.resolver';
|
||||||
import { canFetchGdprRelevantDataResolver } from './resolvers/can-fetch-gdpr-relevant-data.resolver';
|
|
||||||
export const routes: Routes = [
|
export const routes: Routes = [
|
||||||
{
|
{
|
||||||
path: '',
|
path: '',
|
||||||
@@ -493,7 +493,6 @@ export const routes: Routes = [
|
|||||||
personData: personResolver,
|
personData: personResolver,
|
||||||
personBio: personBioResolver,
|
personBio: personBioResolver,
|
||||||
personPatents: personPatentsResolver,
|
personPatents: personPatentsResolver,
|
||||||
canFetchGdprRelevantData: canFetchGdprRelevantDataResolver,
|
|
||||||
},
|
},
|
||||||
runGuardsAndResolvers: (from, to) => from.params['id'] !== to.params['id'],
|
runGuardsAndResolvers: (from, to) => from.params['id'] !== to.params['id'],
|
||||||
children: [
|
children: [
|
||||||
@@ -659,12 +658,16 @@ export const routes: Routes = [
|
|||||||
import('./modules/institution/institution.component').then(
|
import('./modules/institution/institution.component').then(
|
||||||
(mod) => mod.InstitutionComponent,
|
(mod) => mod.InstitutionComponent,
|
||||||
),
|
),
|
||||||
resolve: {
|
resolve: { institution: institutionResolver },
|
||||||
institution: institutionResolver,
|
|
||||||
canFetchGdprRelevantData: canFetchGdprRelevantDataResolver,
|
|
||||||
},
|
|
||||||
children: [
|
children: [
|
||||||
{ path: '', pathMatch: 'full', redirectTo: 'publications' },
|
{ path: '', pathMatch: 'full', redirectTo: 'overview' },
|
||||||
|
{
|
||||||
|
path: 'overview',
|
||||||
|
loadComponent: () =>
|
||||||
|
import('./modules/institution-overview/institution-overview.component').then(
|
||||||
|
(mod) => mod.InstitutionOverviewComponent,
|
||||||
|
),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: 'publications',
|
path: 'publications',
|
||||||
loadComponent: () =>
|
loadComponent: () =>
|
||||||
|
|||||||
@@ -16,15 +16,15 @@
|
|||||||
<mat-divider />
|
<mat-divider />
|
||||||
|
|
||||||
<mat-tab-group>
|
<mat-tab-group>
|
||||||
<mat-tab label="Einstellungen">
|
<mat-tab [label]="'account.settings' | translate">
|
||||||
<div class="settings-tab">
|
<div class="settings-tab">
|
||||||
<h5>Passwort ändern</h5>
|
<h5>{{ 'account.changePassword' | translate }}</h5>
|
||||||
<form class="change-password-form" [formRoot]="changePasswordForm">
|
<form class="change-password-form" [formRoot]="changePasswordForm">
|
||||||
<mat-form-field subscriptSizing="dynamic">
|
<mat-form-field subscriptSizing="dynamic">
|
||||||
<mat-label>Altes Passwort</mat-label>
|
<mat-label>{{ 'account.currentPassword' | translate }}</mat-label>
|
||||||
<input
|
<input
|
||||||
matInput
|
matInput
|
||||||
aria-label="Altes Passwort"
|
[attr.aria-label]="'account.currentPassword' | translate"
|
||||||
[type]="inputFieldType()"
|
[type]="inputFieldType()"
|
||||||
[formField]="changePasswordForm.oldPassword" />
|
[formField]="changePasswordForm.oldPassword" />
|
||||||
@if (oldPasswordErrorMessage()) {
|
@if (oldPasswordErrorMessage()) {
|
||||||
@@ -34,10 +34,10 @@
|
|||||||
|
|
||||||
<div class="new-password-fields">
|
<div class="new-password-fields">
|
||||||
<mat-form-field subscriptSizing="dynamic">
|
<mat-form-field subscriptSizing="dynamic">
|
||||||
<mat-label>Neues Passwort</mat-label>
|
<mat-label>{{ 'accounts.newPassword' | translate }}</mat-label>
|
||||||
<input
|
<input
|
||||||
matInput
|
matInput
|
||||||
aria-label="Neues Passwort"
|
[attr.aria-label]="'accounts.newPassword' | translate"
|
||||||
[type]="inputFieldType()"
|
[type]="inputFieldType()"
|
||||||
[formField]="changePasswordForm.newPassword" />
|
[formField]="changePasswordForm.newPassword" />
|
||||||
@if (newPasswordErrorMessage()) {
|
@if (newPasswordErrorMessage()) {
|
||||||
@@ -46,10 +46,10 @@
|
|||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-form-field subscriptSizing="dynamic">
|
<mat-form-field subscriptSizing="dynamic">
|
||||||
<mat-label>Neues Passwort wiederholen</mat-label>
|
<mat-label>{{ 'account.repeatNewPassword' | translate }}</mat-label>
|
||||||
<input
|
<input
|
||||||
matInput
|
matInput
|
||||||
aria-label="Neues Passwort wiederholen"
|
[attr.aria-label]="'account.repeatNewPassword' | translate"
|
||||||
[type]="inputFieldType()"
|
[type]="inputFieldType()"
|
||||||
[formField]="changePasswordForm.newPasswordRepeat" />
|
[formField]="changePasswordForm.newPasswordRepeat" />
|
||||||
@if (newPasswordRepeatErrorMessage()) {
|
@if (newPasswordRepeatErrorMessage()) {
|
||||||
@@ -61,7 +61,7 @@
|
|||||||
<mat-slide-toggle
|
<mat-slide-toggle
|
||||||
labelPosition="before"
|
labelPosition="before"
|
||||||
[formField]="changePasswordForm.showPasswords"
|
[formField]="changePasswordForm.showPasswords"
|
||||||
>Passwörter anzeigen</mat-slide-toggle
|
>{{ 'account.showPasswords' | translate }}</mat-slide-toggle
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
mat-raised-button
|
mat-raised-button
|
||||||
@@ -70,7 +70,7 @@
|
|||||||
[disabled]="
|
[disabled]="
|
||||||
changePasswordForm().invalid() || changePasswordForm().submitting()
|
changePasswordForm().invalid() || changePasswordForm().submitting()
|
||||||
">
|
">
|
||||||
Passwort ändern
|
{{ 'account.changePassword' | translate }}
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
<mat-divider />
|
<mat-divider />
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ import { MatSlideToggleModule } from '@angular/material/slide-toggle';
|
|||||||
import { CredentialService } from '../../shared/services/credential.service';
|
import { CredentialService } from '../../shared/services/credential.service';
|
||||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
import { LanguageService } from '../../shared/i18n/language.service';
|
||||||
|
import { TranslatePipe } from '../../shared/i18n/translate.pipe';
|
||||||
|
import { TranslationKey } from '../../shared/i18n/translations';
|
||||||
|
|
||||||
interface ChangePasswordForm {
|
interface ChangePasswordForm {
|
||||||
oldPassword: string;
|
oldPassword: string;
|
||||||
@@ -54,6 +57,7 @@ interface ChangePasswordForm {
|
|||||||
MatSlideToggleModule,
|
MatSlideToggleModule,
|
||||||
FormField,
|
FormField,
|
||||||
FormRoot,
|
FormRoot,
|
||||||
|
TranslatePipe,
|
||||||
],
|
],
|
||||||
templateUrl: './account.component.html',
|
templateUrl: './account.component.html',
|
||||||
styleUrl: './account.component.scss',
|
styleUrl: './account.component.scss',
|
||||||
@@ -64,6 +68,7 @@ export class AccountComponent {
|
|||||||
private readonly _credentialService = inject(CredentialService);
|
private readonly _credentialService = inject(CredentialService);
|
||||||
private readonly _snackBar = inject(MatSnackBar);
|
private readonly _snackBar = inject(MatSnackBar);
|
||||||
private readonly _router = inject(Router);
|
private readonly _router = inject(Router);
|
||||||
|
private readonly languageService = inject(LanguageService);
|
||||||
|
|
||||||
roles: UserRole[] = [];
|
roles: UserRole[] = [];
|
||||||
|
|
||||||
@@ -76,37 +81,37 @@ export class AccountComponent {
|
|||||||
|
|
||||||
oldPasswordErrorMessage = computed<string | null>(() => {
|
oldPasswordErrorMessage = computed<string | null>(() => {
|
||||||
const errors = this.changePasswordForm.oldPassword().errors();
|
const errors = this.changePasswordForm.oldPassword().errors();
|
||||||
return errors.length > 0 && errors[0].message ? errors[0].message : null;
|
return this.translateValidationError(errors[0]?.message);
|
||||||
});
|
});
|
||||||
|
|
||||||
newPasswordErrorMessage = computed<string | null>(() => {
|
newPasswordErrorMessage = computed<string | null>(() => {
|
||||||
const errors = this.changePasswordForm.newPassword().errors();
|
const errors = this.changePasswordForm.newPassword().errors();
|
||||||
return errors.length > 0 && errors[0].message ? errors[0].message : null;
|
return this.translateValidationError(errors[0]?.message);
|
||||||
});
|
});
|
||||||
|
|
||||||
newPasswordRepeatErrorMessage = computed<string | null>(() => {
|
newPasswordRepeatErrorMessage = computed<string | null>(() => {
|
||||||
const errors = this.changePasswordForm.newPasswordRepeat().errors();
|
const errors = this.changePasswordForm.newPasswordRepeat().errors();
|
||||||
return errors.length > 0 && errors[0].message ? errors[0].message : null;
|
return this.translateValidationError(errors[0]?.message);
|
||||||
});
|
});
|
||||||
|
|
||||||
changePasswordForm = form(
|
changePasswordForm = form(
|
||||||
this.changePasswordModel,
|
this.changePasswordModel,
|
||||||
(schemaPath) => {
|
(schemaPath) => {
|
||||||
required(schemaPath.oldPassword, {
|
required(schemaPath.oldPassword, {
|
||||||
message: 'Altes Passwort ist erforderlich.',
|
message: 'account.currentPasswordRequired',
|
||||||
});
|
});
|
||||||
required(schemaPath.newPassword, {
|
required(schemaPath.newPassword, {
|
||||||
message: 'Neues Passwort ist erforderlich.',
|
message: 'account.newPasswordRequired',
|
||||||
});
|
});
|
||||||
required(schemaPath.newPasswordRepeat, {
|
required(schemaPath.newPasswordRepeat, {
|
||||||
message: 'Neues Passwort wiederholen ist erforderlich.',
|
message: 'account.repeatPasswordRequired',
|
||||||
});
|
});
|
||||||
|
|
||||||
minLength(schemaPath.newPassword, 8, {
|
minLength(schemaPath.newPassword, 8, {
|
||||||
message: 'Neues Passwort muss mindestens 8 Zeichen lang sein.',
|
message: 'account.passwordMinLength',
|
||||||
});
|
});
|
||||||
maxLength(schemaPath.newPassword, 64, {
|
maxLength(schemaPath.newPassword, 64, {
|
||||||
message: 'Neues Passwort darf maximal 64 Zeichen lang sein.',
|
message: 'account.passwordMaxLength',
|
||||||
});
|
});
|
||||||
|
|
||||||
validate(schemaPath.newPasswordRepeat, ({ value, valueOf }) => {
|
validate(schemaPath.newPasswordRepeat, ({ value, valueOf }) => {
|
||||||
@@ -116,7 +121,7 @@ export class AccountComponent {
|
|||||||
if (newPassword !== newPasswordRepeat) {
|
if (newPassword !== newPasswordRepeat) {
|
||||||
return {
|
return {
|
||||||
kind: 'passwordMismatch',
|
kind: 'passwordMismatch',
|
||||||
message: 'Passwörter stimmen nicht überein.',
|
message: 'account.passwordMismatch',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,8 +135,7 @@ export class AccountComponent {
|
|||||||
if (oldPassword && newPassword && oldPassword === newPassword) {
|
if (oldPassword && newPassword && oldPassword === newPassword) {
|
||||||
return {
|
return {
|
||||||
kind: 'passwordSameAsOld',
|
kind: 'passwordSameAsOld',
|
||||||
message:
|
message: 'account.passwordSameAsOld',
|
||||||
'Neues Passwort darf nicht dasselbe wie das alte Passwort sein.',
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,8 +161,10 @@ export class AccountComponent {
|
|||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
this._snackBar.open(
|
this._snackBar.open(
|
||||||
'Fehler beim Aktualisieren des Zugriffstokens. Bitte melden Sie sich erneut an.',
|
this.languageService.translate(
|
||||||
'OK',
|
'account.tokenRefreshError',
|
||||||
|
),
|
||||||
|
this.languageService.translate('common.ok'),
|
||||||
{ duration: 7000 },
|
{ duration: 7000 },
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -167,8 +173,10 @@ export class AccountComponent {
|
|||||||
error: (error) => {
|
error: (error) => {
|
||||||
console.error('Error changing password:', error);
|
console.error('Error changing password:', error);
|
||||||
this._snackBar.open(
|
this._snackBar.open(
|
||||||
'Fehler beim Ändern des Passworts. Bitte versuchen Sie es erneut.',
|
this.languageService.translate(
|
||||||
'OK',
|
'account.changePasswordError',
|
||||||
|
),
|
||||||
|
this.languageService.translate('common.ok'),
|
||||||
{ duration: 7000 },
|
{ duration: 7000 },
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -184,6 +192,11 @@ export class AccountComponent {
|
|||||||
this.changePasswordModel().showPasswords ? 'text' : 'password',
|
this.changePasswordModel().showPasswords ? 'text' : 'password',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
private translateValidationError(message?: string): string | null {
|
||||||
|
if (!message) return null;
|
||||||
|
return this.languageService.translate(message as TranslationKey);
|
||||||
|
}
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
effect(() => {
|
effect(() => {
|
||||||
this.roles = this.accountProfile().roles;
|
this.roles = this.accountProfile().roles;
|
||||||
|
|||||||
@@ -1,29 +1,33 @@
|
|||||||
<h2 mat-dialog-title>
|
<h2 mat-dialog-title>
|
||||||
{{ data.mode === 'create' ? 'Account erstellen' : 'Account bearbeiten' }}
|
{{
|
||||||
|
data.mode === 'create'
|
||||||
|
? ('accounts.create' | translate)
|
||||||
|
: ('accounts.edit' | translate)
|
||||||
|
}}
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
<mat-dialog-content>
|
<mat-dialog-content>
|
||||||
<form class="account-form" [formGroup]="form" (ngSubmit)="submit()">
|
<form class="account-form" [formGroup]="form" (ngSubmit)="submit()">
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<mat-label>E-Mail</mat-label>
|
<mat-label>{{ 'accounts.email' | translate }}</mat-label>
|
||||||
<input matInput type="email" formControlName="email" />
|
<input matInput type="email" formControlName="email" />
|
||||||
@if (form.controls.email.hasError('required')) {
|
@if (form.controls.email.hasError('required')) {
|
||||||
<mat-error>E-Mail ist erforderlich.</mat-error>
|
<mat-error>{{ 'accounts.emailRequired' | translate }}</mat-error>
|
||||||
} @else if (form.controls.email.hasError('email')) {
|
} @else if (form.controls.email.hasError('email')) {
|
||||||
<mat-error>Bitte gültige E-Mail eingeben.</mat-error>
|
<mat-error>{{ 'accounts.emailInvalid' | translate }}</mat-error>
|
||||||
}
|
}
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<mat-label>Name</mat-label>
|
<mat-label>{{ 'organizations.name' | translate }}</mat-label>
|
||||||
<input matInput formControlName="name" />
|
<input matInput formControlName="name" />
|
||||||
@if (form.controls.name.hasError('required')) {
|
@if (form.controls.name.hasError('required')) {
|
||||||
<mat-error>Name ist erforderlich.</mat-error>
|
<mat-error>{{ 'accounts.nameRequired' | translate }}</mat-error>
|
||||||
}
|
}
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<mat-label>Rolle</mat-label>
|
<mat-label>{{ 'accounts.role' | translate }}</mat-label>
|
||||||
<mat-select formControlName="roles" multiple>
|
<mat-select formControlName="roles" multiple>
|
||||||
@for (role of data.roles; track role) {
|
@for (role of data.roles; track role) {
|
||||||
<mat-option [value]="role">{{ role }}</mat-option>
|
<mat-option [value]="role">{{ role }}</mat-option>
|
||||||
@@ -33,7 +37,7 @@
|
|||||||
|
|
||||||
@if (data.canSelectOrganization) {
|
@if (data.canSelectOrganization) {
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<mat-label>Organisation</mat-label>
|
<mat-label>{{ 'accounts.organization' | translate }}</mat-label>
|
||||||
<mat-select formControlName="organizationId">
|
<mat-select formControlName="organizationId">
|
||||||
@for (organization of data.organizations; track organization.id) {
|
@for (organization of data.organizations; track organization.id) {
|
||||||
<mat-option [value]="organization.id">
|
<mat-option [value]="organization.id">
|
||||||
@@ -46,22 +50,28 @@
|
|||||||
|
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<mat-label>
|
<mat-label>
|
||||||
{{ data.mode === 'create' ? 'Initiales Passwort' : 'Neues Passwort' }}
|
{{
|
||||||
|
data.mode === 'create'
|
||||||
|
? ('accounts.initialPassword' | translate)
|
||||||
|
: ('accounts.newPassword' | translate)
|
||||||
|
}}
|
||||||
</mat-label>
|
</mat-label>
|
||||||
<input matInput type="password" formControlName="password" />
|
<input matInput type="password" formControlName="password" />
|
||||||
@if (form.controls.password.hasError('required')) {
|
@if (form.controls.password.hasError('required')) {
|
||||||
<mat-error>Passwort ist erforderlich.</mat-error>
|
<mat-error>{{ 'accounts.passwordRequired' | translate }}</mat-error>
|
||||||
} @else if (form.controls.password.hasError('minlength')) {
|
} @else if (form.controls.password.hasError('minlength')) {
|
||||||
<mat-error>Mindestens 8 Zeichen.</mat-error>
|
<mat-error>{{ 'accounts.passwordMinLength' | translate }}</mat-error>
|
||||||
}
|
}
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</form>
|
</form>
|
||||||
</mat-dialog-content>
|
</mat-dialog-content>
|
||||||
|
|
||||||
<mat-dialog-actions align="end">
|
<mat-dialog-actions align="end">
|
||||||
<button mat-button type="button" (click)="close()">Abbrechen</button>
|
<button mat-button type="button" (click)="close()">
|
||||||
|
{{ 'common.cancel' | translate }}
|
||||||
|
</button>
|
||||||
<button mat-flat-button color="primary" type="button" (click)="submit()">
|
<button mat-flat-button color="primary" type="button" (click)="submit()">
|
||||||
<mat-icon>save</mat-icon>
|
<mat-icon>save</mat-icon>
|
||||||
Speichern
|
{{ 'common.save' | translate }}
|
||||||
</button>
|
</button>
|
||||||
</mat-dialog-actions>
|
</mat-dialog-actions>
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import {
|
|||||||
InseAccountManagementModelOrganizationProfile,
|
InseAccountManagementModelOrganizationProfile,
|
||||||
UserRole,
|
UserRole,
|
||||||
} from '../../api';
|
} from '../../api';
|
||||||
|
import { TranslatePipe } from '../../shared/i18n/translate.pipe';
|
||||||
|
|
||||||
export type AccountDialogMode = 'create' | 'edit';
|
export type AccountDialogMode = 'create' | 'edit';
|
||||||
|
|
||||||
@@ -65,6 +66,7 @@ export type AccountDialogResult =
|
|||||||
MatIconModule,
|
MatIconModule,
|
||||||
MatInputModule,
|
MatInputModule,
|
||||||
MatSelectModule,
|
MatSelectModule,
|
||||||
|
TranslatePipe,
|
||||||
],
|
],
|
||||||
templateUrl: './account-dialog.component.html',
|
templateUrl: './account-dialog.component.html',
|
||||||
styleUrl: './account-dialog.component.scss',
|
styleUrl: './account-dialog.component.scss',
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
<section class="accounts-page">
|
<section class="accounts-page">
|
||||||
<header class="page-header">
|
<header class="page-header">
|
||||||
<div>
|
<div>
|
||||||
<h1>Accounts</h1>
|
<h1>{{ 'accounts.title' | translate }}</h1>
|
||||||
<p>
|
<p>
|
||||||
{{
|
{{
|
||||||
isReadOnly
|
isReadOnly
|
||||||
? 'Personen der eigenen Organisation ansehen.'
|
? ('accounts.readOnlyDescription' | translate)
|
||||||
: 'Account-Zugänge verwalten, Rollen setzen und Impersonation starten.'
|
: ('accounts.description' | translate)
|
||||||
}}
|
}}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -15,10 +15,10 @@
|
|||||||
mat-flat-button
|
mat-flat-button
|
||||||
color="primary"
|
color="primary"
|
||||||
type="button"
|
type="button"
|
||||||
matTooltip="Neuen Account anlegen"
|
[matTooltip]="'accounts.newTooltip' | translate"
|
||||||
(click)="startCreate()">
|
(click)="startCreate()">
|
||||||
<mat-icon>person_add</mat-icon>
|
<mat-icon>person_add</mat-icon>
|
||||||
Neuer Account
|
{{ 'accounts.new' | translate }}
|
||||||
</button>
|
</button>
|
||||||
}
|
}
|
||||||
</header>
|
</header>
|
||||||
@@ -26,12 +26,12 @@
|
|||||||
<section style="display: flex; gap: 1rem; align-items: center">
|
<section style="display: flex; gap: 1rem; align-items: center">
|
||||||
<app-query-param-input
|
<app-query-param-input
|
||||||
queryParamKey="search"
|
queryParamKey="search"
|
||||||
label="Nach Name oder E-Mail suchen"
|
[label]="'accounts.search' | translate"
|
||||||
style="width: 35%" />
|
style="width: 35%" />
|
||||||
<app-query-param-selector
|
<app-query-param-selector
|
||||||
queryParamKey="organization_id"
|
queryParamKey="organization_id"
|
||||||
[options]="selectorOptions()"
|
[options]="selectorOptions()"
|
||||||
label="Organisation"
|
[label]="'accounts.organization' | translate"
|
||||||
[allowEmptyValue]="true"
|
[allowEmptyValue]="true"
|
||||||
style="width: 25%" />
|
style="width: 25%" />
|
||||||
</section>
|
</section>
|
||||||
@@ -65,14 +65,14 @@
|
|||||||
<button
|
<button
|
||||||
mat-icon-button
|
mat-icon-button
|
||||||
type="button"
|
type="button"
|
||||||
aria-label="Bearbeiten"
|
[attr.aria-label]="'common.edit' | translate"
|
||||||
(click)="startEdit(row)">
|
(click)="startEdit(row)">
|
||||||
<mat-icon>edit</mat-icon>
|
<mat-icon>edit</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
mat-icon-button
|
mat-icon-button
|
||||||
type="button"
|
type="button"
|
||||||
aria-label="Impersonate"
|
[attr.aria-label]="'accounts.impersonate' | translate"
|
||||||
[disabled]="!canImpersonate(row)"
|
[disabled]="!canImpersonate(row)"
|
||||||
(click)="impersonate(row)">
|
(click)="impersonate(row)">
|
||||||
<mat-icon>switch_account</mat-icon>
|
<mat-icon>switch_account</mat-icon>
|
||||||
@@ -80,7 +80,11 @@
|
|||||||
<button
|
<button
|
||||||
mat-icon-button
|
mat-icon-button
|
||||||
type="button"
|
type="button"
|
||||||
[attr.aria-label]="row.activated ? 'Deaktivieren' : 'Aktivieren'"
|
[attr.aria-label]="
|
||||||
|
row.activated
|
||||||
|
? ('common.deactivate' | translate)
|
||||||
|
: ('common.activate' | translate)
|
||||||
|
"
|
||||||
[disabled]="row.is_current || row.deleted"
|
[disabled]="row.is_current || row.deleted"
|
||||||
(click)="toggleAccountActivation(row)">
|
(click)="toggleAccountActivation(row)">
|
||||||
<mat-icon>{{ row.activated ? 'person_off' : 'person_check' }}</mat-icon>
|
<mat-icon>{{ row.activated ? 'person_off' : 'person_check' }}</mat-icon>
|
||||||
@@ -88,7 +92,7 @@
|
|||||||
<button
|
<button
|
||||||
mat-icon-button
|
mat-icon-button
|
||||||
type="button"
|
type="button"
|
||||||
aria-label="Deaktivieren"
|
[attr.aria-label]="'common.deactivate' | translate"
|
||||||
[disabled]="row.is_current || row.deleted"
|
[disabled]="row.is_current || row.deleted"
|
||||||
(click)="deleteAccount(row)">
|
(click)="deleteAccount(row)">
|
||||||
<mat-icon>delete</mat-icon>
|
<mat-icon>delete</mat-icon>
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ import {
|
|||||||
OnInit,
|
OnInit,
|
||||||
TemplateRef,
|
TemplateRef,
|
||||||
computed,
|
computed,
|
||||||
|
effect,
|
||||||
inject,
|
inject,
|
||||||
|
Injector,
|
||||||
input,
|
input,
|
||||||
viewChild,
|
viewChild,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
@@ -44,6 +46,8 @@ import {
|
|||||||
UserRole,
|
UserRole,
|
||||||
} from '../../api';
|
} from '../../api';
|
||||||
import { StatusPipe } from '../../shared/pipes/status.pipe';
|
import { StatusPipe } from '../../shared/pipes/status.pipe';
|
||||||
|
import { LanguageService } from '../../shared/i18n/language.service';
|
||||||
|
import { TranslatePipe } from '../../shared/i18n/translate.pipe';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-accounts',
|
selector: 'app-accounts',
|
||||||
@@ -65,6 +69,7 @@ import { StatusPipe } from '../../shared/pipes/status.pipe';
|
|||||||
QueryParamSelectorComponent,
|
QueryParamSelectorComponent,
|
||||||
MatCardModule,
|
MatCardModule,
|
||||||
StatusPipe,
|
StatusPipe,
|
||||||
|
TranslatePipe,
|
||||||
],
|
],
|
||||||
templateUrl: './accounts.component.html',
|
templateUrl: './accounts.component.html',
|
||||||
styleUrl: './accounts.component.scss',
|
styleUrl: './accounts.component.scss',
|
||||||
@@ -76,6 +81,8 @@ export class AccountsComponent implements OnInit {
|
|||||||
private readonly router = inject(Router);
|
private readonly router = inject(Router);
|
||||||
private readonly dialog = inject(MatDialog);
|
private readonly dialog = inject(MatDialog);
|
||||||
private readonly authService = inject(AuthService);
|
private readonly authService = inject(AuthService);
|
||||||
|
private readonly languageService = inject(LanguageService);
|
||||||
|
private readonly injector = inject(Injector);
|
||||||
|
|
||||||
protected get isReadOnly(): boolean {
|
protected get isReadOnly(): boolean {
|
||||||
return this.credentialService.isEffectiveManager();
|
return this.credentialService.isEffectiveManager();
|
||||||
@@ -106,41 +113,51 @@ export class AccountsComponent implements OnInit {
|
|||||||
input.required<InseAccountManagementModelOrganizationProfile[]>();
|
input.required<InseAccountManagementModelOrganizationProfile[]>();
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
effect(
|
||||||
|
() => {
|
||||||
|
this.languageService.language();
|
||||||
|
this.setAccountColumns();
|
||||||
|
},
|
||||||
|
{ injector: this.injector },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private setAccountColumns(): void {
|
||||||
this.accountColumns = [
|
this.accountColumns = [
|
||||||
{
|
{
|
||||||
id: 'name',
|
id: 'name',
|
||||||
header: 'Name',
|
header: this.languageService.translate('organizations.name'),
|
||||||
type: 'accessor',
|
type: 'accessor',
|
||||||
accessorKey: 'name',
|
accessorKey: 'name',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'email',
|
id: 'email',
|
||||||
header: 'E-Mail',
|
header: this.languageService.translate('accounts.email'),
|
||||||
type: 'accessor',
|
type: 'accessor',
|
||||||
accessorKey: 'email',
|
accessorKey: 'email',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'organization_name',
|
id: 'organization_name',
|
||||||
header: 'Organisation',
|
header: this.languageService.translate('accounts.organization'),
|
||||||
type: 'accessor',
|
type: 'accessor',
|
||||||
accessorKey: 'organization_name',
|
accessorKey: 'organization_name',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'roles',
|
id: 'roles',
|
||||||
header: 'Rolle',
|
header: this.languageService.translate('accounts.role'),
|
||||||
type: 'accessor',
|
type: 'accessor',
|
||||||
accessorKey: 'roles',
|
accessorKey: 'roles',
|
||||||
cellTemplate: this.accountRoleTmp(),
|
cellTemplate: this.accountRoleTmp(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'status',
|
id: 'status',
|
||||||
header: 'Status',
|
header: this.languageService.translate('common.status'),
|
||||||
type: 'display',
|
type: 'display',
|
||||||
cellTemplate: this.accountStatusTmp(),
|
cellTemplate: this.accountStatusTmp(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'actions',
|
id: 'actions',
|
||||||
header: 'Aktionen',
|
header: this.languageService.translate('common.actions'),
|
||||||
type: 'display',
|
type: 'display',
|
||||||
cellTemplate: this.accountActionsTmp(),
|
cellTemplate: this.accountActionsTmp(),
|
||||||
},
|
},
|
||||||
@@ -163,9 +180,13 @@ export class AccountsComponent implements OnInit {
|
|||||||
|
|
||||||
request.subscribe({
|
request.subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.snackBar.open('Account wurde gespeichert.', 'OK', {
|
this.snackBar.open(
|
||||||
|
this.languageService.translate('accounts.saved'),
|
||||||
|
this.languageService.translate('common.ok'),
|
||||||
|
{
|
||||||
duration: 3000,
|
duration: 3000,
|
||||||
});
|
},
|
||||||
|
);
|
||||||
this.router.navigate([], {
|
this.router.navigate([], {
|
||||||
queryParams: { page: 0 },
|
queryParams: { page: 0 },
|
||||||
queryParamsHandling: 'merge',
|
queryParamsHandling: 'merge',
|
||||||
@@ -174,9 +195,13 @@ export class AccountsComponent implements OnInit {
|
|||||||
error: (error) => {
|
error: (error) => {
|
||||||
const message =
|
const message =
|
||||||
error.status === 409
|
error.status === 409
|
||||||
? 'Diese E-Mail-Adresse wird bereits verwendet.'
|
? this.languageService.translate('accounts.emailConflict')
|
||||||
: 'Account konnte nicht gespeichert werden.';
|
: this.languageService.translate('accounts.saveError');
|
||||||
this.snackBar.open(message, 'OK', { duration: 5000 });
|
this.snackBar.open(
|
||||||
|
message,
|
||||||
|
this.languageService.translate('common.ok'),
|
||||||
|
{ duration: 5000 },
|
||||||
|
);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -222,18 +247,24 @@ export class AccountsComponent implements OnInit {
|
|||||||
|
|
||||||
this.authService.deleteAccount(account.id).subscribe({
|
this.authService.deleteAccount(account.id).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.snackBar.open('Account wurde deaktiviert.', 'OK', {
|
this.snackBar.open(
|
||||||
|
this.languageService.translate('accounts.deactivated'),
|
||||||
|
this.languageService.translate('common.ok'),
|
||||||
|
{
|
||||||
duration: 3000,
|
duration: 3000,
|
||||||
});
|
},
|
||||||
|
);
|
||||||
this.router.navigate([], {
|
this.router.navigate([], {
|
||||||
queryParams: { page: 0 },
|
queryParams: { page: 0 },
|
||||||
queryParamsHandling: 'merge',
|
queryParamsHandling: 'merge',
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
error: () => {
|
error: () => {
|
||||||
this.snackBar.open('Account konnte nicht deaktiviert werden.', 'OK', {
|
this.snackBar.open(
|
||||||
duration: 5000,
|
this.languageService.translate('accounts.deactivateError'),
|
||||||
});
|
this.languageService.translate('common.ok'),
|
||||||
|
{ duration: 5000 },
|
||||||
|
);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -248,16 +279,25 @@ export class AccountsComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const activated = !account.activated;
|
const activated = !account.activated;
|
||||||
const action = activated ? 'aktivieren' : 'deaktivieren';
|
|
||||||
|
|
||||||
import('../../shared/ui/confirmation-dialog/confirmation-dialog.component').then(
|
import('../../shared/ui/confirmation-dialog/confirmation-dialog.component').then(
|
||||||
({ ConfirmationDialogComponent }) => {
|
({ ConfirmationDialogComponent }) => {
|
||||||
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
||||||
data: {
|
data: {
|
||||||
title: activated ? 'Account aktivieren' : 'Account deaktivieren',
|
title: this.languageService.translate(
|
||||||
message: `Möchtest Du den Account „${account.name}“ wirklich ${action}?`,
|
activated
|
||||||
confirmText: activated ? 'Aktivieren' : 'Deaktivieren',
|
? 'accounts.activateTitle'
|
||||||
cancelText: 'Abbrechen',
|
: 'accounts.deactivateTitle',
|
||||||
|
),
|
||||||
|
message: this.languageService.translate(
|
||||||
|
activated
|
||||||
|
? 'accounts.activateQuestion'
|
||||||
|
: 'accounts.deactivateQuestion',
|
||||||
|
{ name: account.name },
|
||||||
|
),
|
||||||
|
confirmText: this.languageService.translate(
|
||||||
|
activated ? 'common.activate' : 'common.deactivate',
|
||||||
|
),
|
||||||
|
cancelText: this.languageService.translate('common.cancel'),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -275,8 +315,10 @@ export class AccountsComponent implements OnInit {
|
|||||||
this.authService.updateAccount(account.id, { activated }).subscribe({
|
this.authService.updateAccount(account.id, { activated }).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.snackBar.open(
|
this.snackBar.open(
|
||||||
activated ? 'Account wurde aktiviert.' : 'Account wurde deaktiviert.',
|
this.languageService.translate(
|
||||||
'OK',
|
activated ? 'accounts.activated' : 'accounts.deactivated',
|
||||||
|
),
|
||||||
|
this.languageService.translate('common.ok'),
|
||||||
{ duration: 3000 },
|
{ duration: 3000 },
|
||||||
);
|
);
|
||||||
this.router.navigate([], {
|
this.router.navigate([], {
|
||||||
@@ -286,8 +328,8 @@ export class AccountsComponent implements OnInit {
|
|||||||
},
|
},
|
||||||
error: () => {
|
error: () => {
|
||||||
this.snackBar.open(
|
this.snackBar.open(
|
||||||
'Account-Status konnte nicht geändert werden.',
|
this.languageService.translate('accounts.statusError'),
|
||||||
'OK',
|
this.languageService.translate('common.ok'),
|
||||||
{ duration: 5000 },
|
{ duration: 5000 },
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -301,15 +343,21 @@ export class AccountsComponent implements OnInit {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await this.credentialService.impersonateAccount(account.id);
|
await this.credentialService.impersonateAccount(account.id);
|
||||||
this.snackBar.open(`Impersonation aktiv: ${account.name}`, 'OK', {
|
this.snackBar.open(
|
||||||
duration: 4000,
|
this.languageService.translate('accounts.impersonationActive', {
|
||||||
});
|
name: account.name,
|
||||||
|
}),
|
||||||
|
this.languageService.translate('common.ok'),
|
||||||
|
{ duration: 4000 },
|
||||||
|
);
|
||||||
this.router.navigate(['/dashboard']);
|
this.router.navigate(['/dashboard']);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Impersonation failed:', error);
|
console.error('Impersonation failed:', error);
|
||||||
this.snackBar.open('Impersonation konnte nicht gestartet werden.', 'OK', {
|
this.snackBar.open(
|
||||||
duration: 5000,
|
this.languageService.translate('accounts.impersonationError'),
|
||||||
});
|
this.languageService.translate('common.ok'),
|
||||||
|
{ duration: 5000 },
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +1,22 @@
|
|||||||
<section class="login-page">
|
<section class="login-page">
|
||||||
<div class="login-panel">
|
<div class="login-panel">
|
||||||
<div class="brand-block">
|
<div class="brand-block">
|
||||||
<span class="eyebrow">SmartGuide Account Portal</span>
|
<span class="eyebrow">{{ 'login.portal' | translate }}</span>
|
||||||
<h1>Login</h1>
|
<h1>{{ 'login.title' | translate }}</h1>
|
||||||
<p>
|
<p>
|
||||||
Melde Dich mit Deiner Organisation an. Nach den Zugangsdaten erhältst Du
|
{{ 'login.description' | translate }}
|
||||||
einen einmaligen Code per E-Mail.
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="stepper" aria-label="Login-Fortschritt">
|
<div class="stepper" [attr.aria-label]="'login.progress' | translate">
|
||||||
<div class="step" [class.step--active]="currentStep === 'credentials'">
|
<div class="step" [class.step--active]="currentStep === 'credentials'">
|
||||||
<span>1</span>
|
<span>1</span>
|
||||||
<strong>Zugangsdaten</strong>
|
<strong>{{ 'login.credentials' | translate }}</strong>
|
||||||
</div>
|
</div>
|
||||||
<div class="step-line"></div>
|
<div class="step-line"></div>
|
||||||
<div class="step" [class.step--active]="currentStep === 'otk'">
|
<div class="step" [class.step--active]="currentStep === 'otk'">
|
||||||
<span>2</span>
|
<span>2</span>
|
||||||
<strong>OTK-Code</strong>
|
<strong>{{ 'login.otkCode' | translate }}</strong>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -27,7 +26,7 @@
|
|||||||
[formGroup]="credentialsForm"
|
[formGroup]="credentialsForm"
|
||||||
(ngSubmit)="requestOtk()">
|
(ngSubmit)="requestOtk()">
|
||||||
<mat-form-field class="field" appearance="outline">
|
<mat-form-field class="field" appearance="outline">
|
||||||
<mat-label>E-Mail-Adresse</mat-label>
|
<mat-label>{{ 'login.email' | translate }}</mat-label>
|
||||||
<input
|
<input
|
||||||
id="login-email"
|
id="login-email"
|
||||||
matInput
|
matInput
|
||||||
@@ -35,14 +34,14 @@
|
|||||||
autocomplete="email"
|
autocomplete="email"
|
||||||
formControlName="email" />
|
formControlName="email" />
|
||||||
@if (credentialsForm.controls.email.hasError('required')) {
|
@if (credentialsForm.controls.email.hasError('required')) {
|
||||||
<mat-error>E-Mail-Adresse ist erforderlich.</mat-error>
|
<mat-error>{{ 'login.emailRequired' | translate }}</mat-error>
|
||||||
} @else if (credentialsForm.controls.email.hasError('email')) {
|
} @else if (credentialsForm.controls.email.hasError('email')) {
|
||||||
<mat-error>Bitte gib eine gültige E-Mail-Adresse ein.</mat-error>
|
<mat-error>{{ 'login.emailInvalid' | translate }}</mat-error>
|
||||||
}
|
}
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-form-field class="field" appearance="outline">
|
<mat-form-field class="field" appearance="outline">
|
||||||
<mat-label>Passwort</mat-label>
|
<mat-label>{{ 'login.password' | translate }}</mat-label>
|
||||||
<input
|
<input
|
||||||
id="login-password"
|
id="login-password"
|
||||||
matInput
|
matInput
|
||||||
@@ -54,7 +53,7 @@
|
|||||||
matSuffix
|
matSuffix
|
||||||
type="button"
|
type="button"
|
||||||
[attr.aria-label]="
|
[attr.aria-label]="
|
||||||
showPassword ? 'Passwort verbergen' : 'Passwort anzeigen'
|
(showPassword ? 'login.hidePassword' : 'login.showPassword') | translate
|
||||||
"
|
"
|
||||||
(click)="showPassword = !showPassword">
|
(click)="showPassword = !showPassword">
|
||||||
<mat-icon>{{
|
<mat-icon>{{
|
||||||
@@ -62,9 +61,9 @@
|
|||||||
}}</mat-icon>
|
}}</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
@if (credentialsForm.controls.password.hasError('required')) {
|
@if (credentialsForm.controls.password.hasError('required')) {
|
||||||
<mat-error>Passwort ist erforderlich.</mat-error>
|
<mat-error>{{ 'login.passwordRequired' | translate }}</mat-error>
|
||||||
} @else if (credentialsForm.controls.password.hasError('minlength')) {
|
} @else if (credentialsForm.controls.password.hasError('minlength')) {
|
||||||
<mat-error>Passwort muss mindestens 8 Zeichen haben.</mat-error>
|
<mat-error>{{ 'login.passwordLength' | translate }}</mat-error>
|
||||||
}
|
}
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
@@ -75,16 +74,16 @@
|
|||||||
type="submit"
|
type="submit"
|
||||||
[disabled]="credentialsForm.invalid || isSubmitting">
|
[disabled]="credentialsForm.invalid || isSubmitting">
|
||||||
@if (isSubmitting) {
|
@if (isSubmitting) {
|
||||||
Code wird gesendet...
|
{{ 'login.sendingCode' | translate }}
|
||||||
} @else {
|
} @else {
|
||||||
Code per E-Mail senden
|
{{ 'login.sendCode' | translate }}
|
||||||
}
|
}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<span></span>
|
<span></span>
|
||||||
<a class="auth-link" routerLink="/forgot-password"
|
<a class="auth-link" routerLink="/forgot-password"
|
||||||
>Passwort vergessen?</a
|
>{{ 'login.forgotPassword' | translate }}</a
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
@@ -93,19 +92,19 @@
|
|||||||
<div class="code-intro">
|
<div class="code-intro">
|
||||||
<mat-icon>mark_email_unread</mat-icon>
|
<mat-icon>mark_email_unread</mat-icon>
|
||||||
<div>
|
<div>
|
||||||
<strong>Code eingeben</strong>
|
<strong>{{ 'login.enterCode' | translate }}</strong>
|
||||||
<span>
|
<span>
|
||||||
Wir haben den Code an
|
{{ 'login.sentTo' | translate }}
|
||||||
{{
|
{{
|
||||||
credentialsForm.controls.email.value || 'Deine E-Mail-Adresse'
|
credentialsForm.controls.email.value || ('login.yourEmail' | translate)
|
||||||
}}
|
}}
|
||||||
gesendet.
|
{{ 'login.sentSuffix' | translate }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<mat-form-field class="field" appearance="outline">
|
<mat-form-field class="field" appearance="outline">
|
||||||
<mat-label>OTK-Code</mat-label>
|
<mat-label>{{ 'login.otkCode' | translate }}</mat-label>
|
||||||
<input
|
<input
|
||||||
id="login-otk"
|
id="login-otk"
|
||||||
matInput
|
matInput
|
||||||
@@ -113,9 +112,9 @@
|
|||||||
autocomplete="one-time-code"
|
autocomplete="one-time-code"
|
||||||
formControlName="code" />
|
formControlName="code" />
|
||||||
@if (otkForm.controls.code.hasError('required')) {
|
@if (otkForm.controls.code.hasError('required')) {
|
||||||
<mat-error>OTK-Code ist erforderlich.</mat-error>
|
<mat-error>{{ 'login.codeRequired' | translate }}</mat-error>
|
||||||
} @else if (otkForm.controls.code.hasError('pattern')) {
|
} @else if (otkForm.controls.code.hasError('pattern')) {
|
||||||
<mat-error>Bitte gib den Code aus der E-Mail ein.</mat-error>
|
<mat-error>{{ 'login.codeInvalid' | translate }}</mat-error>
|
||||||
}
|
}
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
@@ -125,9 +124,9 @@
|
|||||||
aria-live="polite">
|
aria-live="polite">
|
||||||
<mat-icon>timer</mat-icon>
|
<mat-icon>timer</mat-icon>
|
||||||
@if (codeExpiresIn > 0) {
|
@if (codeExpiresIn > 0) {
|
||||||
<span>Code läuft in {{ formatCountdown() }} ab.</span>
|
<span>{{ 'login.codeExpiresIn' | translate }} {{ formatCountdown() }}.</span>
|
||||||
} @else {
|
} @else {
|
||||||
<span>Code ist abgelaufen. Bitte neuen Code anfordern.</span>
|
<span>{{ 'login.codeExpired' | translate }}</span>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -138,9 +137,9 @@
|
|||||||
type="submit"
|
type="submit"
|
||||||
[disabled]="otkForm.invalid || isSubmitting || codeExpiresIn === 0">
|
[disabled]="otkForm.invalid || isSubmitting || codeExpiresIn === 0">
|
||||||
@if (isSubmitting) {
|
@if (isSubmitting) {
|
||||||
Anmeldung wird geprüft...
|
{{ 'login.checking' | translate }}
|
||||||
} @else {
|
} @else {
|
||||||
Anmelden
|
{{ 'login.signIn' | translate }}
|
||||||
}
|
}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
@@ -150,10 +149,10 @@
|
|||||||
type="button"
|
type="button"
|
||||||
(click)="resendCode()"
|
(click)="resendCode()"
|
||||||
[disabled]="isSubmitting">
|
[disabled]="isSubmitting">
|
||||||
Code erneut senden
|
{{ 'login.resend' | translate }}
|
||||||
</button>
|
</button>
|
||||||
<button mat-button type="button" (click)="editCredentials()">
|
<button mat-button type="button" (click)="editCredentials()">
|
||||||
E-Mail ändern
|
{{ 'login.changeEmail' | translate }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ import { finalize, Subscription } from 'rxjs';
|
|||||||
import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar';
|
import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar';
|
||||||
import { Router, RouterLink } from '@angular/router';
|
import { Router, RouterLink } from '@angular/router';
|
||||||
import { HttpErrorResponse } from '@angular/common/http';
|
import { HttpErrorResponse } from '@angular/common/http';
|
||||||
|
import { LanguageService } from '../../shared/i18n/language.service';
|
||||||
|
import { TranslatePipe } from '../../shared/i18n/translate.pipe';
|
||||||
|
|
||||||
type LoginStep = 'credentials' | 'otk';
|
type LoginStep = 'credentials' | 'otk';
|
||||||
|
|
||||||
@@ -29,6 +31,7 @@ type LoginStep = 'credentials' | 'otk';
|
|||||||
MatIconModule,
|
MatIconModule,
|
||||||
MatSnackBarModule,
|
MatSnackBarModule,
|
||||||
RouterLink,
|
RouterLink,
|
||||||
|
TranslatePipe,
|
||||||
],
|
],
|
||||||
templateUrl: './app-login.component.html',
|
templateUrl: './app-login.component.html',
|
||||||
styleUrl: './app-login.component.scss',
|
styleUrl: './app-login.component.scss',
|
||||||
@@ -64,6 +67,7 @@ export class AppLoginComponent implements OnDestroy {
|
|||||||
protected credentialService: CredentialService,
|
protected credentialService: CredentialService,
|
||||||
protected router: Router,
|
protected router: Router,
|
||||||
protected snackBar: MatSnackBar,
|
protected snackBar: MatSnackBar,
|
||||||
|
private readonly languageService: LanguageService,
|
||||||
) {
|
) {
|
||||||
effect(() => {
|
effect(() => {
|
||||||
if (this.credentialService.isValidating()) {
|
if (this.credentialService.isValidating()) {
|
||||||
@@ -119,7 +123,7 @@ export class AppLoginComponent implements OnDestroy {
|
|||||||
this.otkForm.reset();
|
this.otkForm.reset();
|
||||||
this.startCountdown();
|
this.startCountdown();
|
||||||
this.snackBar.open(
|
this.snackBar.open(
|
||||||
'OTK-Code wurde an die E-Mail-Adresse gesendet.',
|
this.languageService.translate('login.codeSent'),
|
||||||
'OK',
|
'OK',
|
||||||
{
|
{
|
||||||
duration: 4000,
|
duration: 4000,
|
||||||
@@ -154,7 +158,7 @@ export class AppLoginComponent implements OnDestroy {
|
|||||||
|
|
||||||
if (this.codeExpiresIn <= 0) {
|
if (this.codeExpiresIn <= 0) {
|
||||||
this.snackBar.open(
|
this.snackBar.open(
|
||||||
'Der Code ist abgelaufen. Bitte fordere einen neuen Code an.',
|
this.languageService.translate('login.codeExpiredRequest'),
|
||||||
'OK',
|
'OK',
|
||||||
{ duration: 5000 },
|
{ duration: 5000 },
|
||||||
);
|
);
|
||||||
@@ -162,7 +166,7 @@ export class AppLoginComponent implements OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!this.accountId) {
|
if (!this.accountId) {
|
||||||
this.snackBar.open('Bitte fordere zuerst einen neuen Code an.', 'OK', {
|
this.snackBar.open(this.languageService.translate('login.requestFirst'), 'OK', {
|
||||||
duration: 5000,
|
duration: 5000,
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@@ -242,13 +246,13 @@ export class AppLoginComponent implements OnDestroy {
|
|||||||
private getLoginErrorMessage(error: HttpErrorResponse): string {
|
private getLoginErrorMessage(error: HttpErrorResponse): string {
|
||||||
console.error('Login error:', error);
|
console.error('Login error:', error);
|
||||||
if (error.status === 401) {
|
if (error.status === 401) {
|
||||||
return 'E-Mail, Passwort oder OTK-Code ist ungültig.';
|
return this.languageService.translate('login.invalidCredentials');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error.status === 403) {
|
if (error.status === 403) {
|
||||||
return 'Dieser Account ist deaktiviert und kann sich nicht anmelden.';
|
return this.languageService.translate('login.accountDisabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'Die Anmeldung konnte nicht abgeschlossen werden. Bitte versuche es erneut.';
|
return this.languageService.translate('login.failed');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,26 @@
|
|||||||
<main class="bookmarks-page">
|
<main class="bookmarks-page">
|
||||||
<header class="page-header">
|
<header class="page-header">
|
||||||
<div>
|
<div>
|
||||||
<p class="eyebrow">Meine Sammlung</p>
|
<p class="eyebrow">{{ 'bookmarks.eyebrow' | translate }}</p>
|
||||||
<h1>Bookmarks</h1>
|
<h1>{{ 'bookmarks.title' | translate }}</h1>
|
||||||
<p>Gespeicherte Personen für den schnellen Zugriff.</p>
|
<p>{{ 'bookmarks.description' | translate }}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="bookmark-count">
|
<div class="bookmark-count">
|
||||||
<mat-icon>bookmarks</mat-icon>
|
<mat-icon>bookmarks</mat-icon>
|
||||||
<strong>{{ persons().length }}</strong>
|
<strong>{{ persons().length }}</strong>
|
||||||
<span>Personen</span>
|
<span>{{ 'bookmarks.people' | translate }}</span>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
@if (loading()) {
|
@if (loading()) {
|
||||||
<app-loading
|
<div class="loading-state">
|
||||||
text="Bookmarks werden geladen …"
|
<mat-spinner diameter="42"></mat-spinner>
|
||||||
icon="bookmarks"
|
<p>{{ 'bookmarks.loading' | translate }}</p>
|
||||||
[size]="60"
|
</div>
|
||||||
[diameter]="60" />
|
|
||||||
} @else if (persons().length) {
|
} @else if (persons().length) {
|
||||||
<section class="person-grid" aria-label="Gespeicherte Personen">
|
<section
|
||||||
|
class="person-grid"
|
||||||
|
[attr.aria-label]="'bookmarks.savedPeopleLabel' | translate">
|
||||||
@for (person of persons(); track person.id) {
|
@for (person of persons(); track person.id) {
|
||||||
<app-person-card
|
<app-person-card
|
||||||
[person]="person"
|
[person]="person"
|
||||||
@@ -31,10 +32,8 @@
|
|||||||
} @else {
|
} @else {
|
||||||
<section class="empty-state">
|
<section class="empty-state">
|
||||||
<mat-icon>bookmark_border</mat-icon>
|
<mat-icon>bookmark_border</mat-icon>
|
||||||
<h2>Noch keine Bookmarks</h2>
|
<h2>{{ 'bookmarks.emptyTitle' | translate }}</h2>
|
||||||
<p>
|
<p>{{ 'bookmarks.emptyDescription' | translate }}</p>
|
||||||
Speichere Personen über das Bookmark-Symbol auf einer Personenkarte.
|
|
||||||
</p>
|
|
||||||
</section>
|
</section>
|
||||||
}
|
}
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@@ -65,6 +65,7 @@
|
|||||||
gap: 20px;
|
gap: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.loading-state,
|
||||||
.empty-state {
|
.empty-state {
|
||||||
display: flex;
|
display: flex;
|
||||||
min-height: 320px;
|
min-height: 320px;
|
||||||
|
|||||||
@@ -2,12 +2,13 @@ import { CommonModule } from '@angular/common';
|
|||||||
import { Component, DestroyRef, inject, signal } from '@angular/core';
|
import { Component, DestroyRef, inject, signal } from '@angular/core';
|
||||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||||
import { MatIconModule } from '@angular/material/icon';
|
import { MatIconModule } from '@angular/material/icon';
|
||||||
|
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||||
import { catchError, forkJoin, map, of, switchMap } from 'rxjs';
|
import { catchError, forkJoin, map, of, switchMap } from 'rxjs';
|
||||||
|
|
||||||
import { CustomAuthor, PersonsService } from '../../api';
|
import { CustomAuthor, PersonsService } from '../../api';
|
||||||
import { BookmarkService } from '../../shared/services/bookmark.service';
|
import { BookmarkService } from '../../shared/services/bookmark.service';
|
||||||
import { PersonCardComponent } from '../person-card/person-card.component';
|
import { PersonCardComponent } from '../person-card/person-card.component';
|
||||||
import { LoadingComponent } from '../../shared/ui/loading/loading.component';
|
import { TranslatePipe } from '../../shared/i18n/translate.pipe';
|
||||||
|
|
||||||
const PERSON_INCLUDE_TAGS =
|
const PERSON_INCLUDE_TAGS =
|
||||||
'display_name,works_count,cited_by_count,summary_stats,ids,' +
|
'display_name,works_count,cited_by_count,summary_stats,ids,' +
|
||||||
@@ -17,7 +18,13 @@ const PERSON_INCLUDE_TAGS =
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'app-bookmarks',
|
selector: 'app-bookmarks',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, MatIconModule, PersonCardComponent, LoadingComponent],
|
imports: [
|
||||||
|
CommonModule,
|
||||||
|
MatIconModule,
|
||||||
|
MatProgressSpinnerModule,
|
||||||
|
PersonCardComponent,
|
||||||
|
TranslatePipe,
|
||||||
|
],
|
||||||
templateUrl: './bookmarks.component.html',
|
templateUrl: './bookmarks.component.html',
|
||||||
styleUrl: './bookmarks.component.scss',
|
styleUrl: './bookmarks.component.scss',
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { EChartsCoreOption } from 'echarts';
|
|||||||
import { MatIconModule } from '@angular/material/icon';
|
import { MatIconModule } from '@angular/material/icon';
|
||||||
import { NgxEchartsDirective } from 'ngx-echarts';
|
import { NgxEchartsDirective } from 'ngx-echarts';
|
||||||
import { ChartThemeService } from '../../shared/services/chart-theme.service';
|
import { ChartThemeService } from '../../shared/services/chart-theme.service';
|
||||||
|
import { LanguageService } from '../../shared/i18n/language.service';
|
||||||
|
|
||||||
import * as echarts from 'echarts/core';
|
import * as echarts from 'echarts/core';
|
||||||
import {
|
import {
|
||||||
@@ -49,13 +50,14 @@ export class CollaborationGraphComponent {
|
|||||||
handleNodeClick = output<NodeClickEvent>();
|
handleNodeClick = output<NodeClickEvent>();
|
||||||
|
|
||||||
private readonly chartTheme = inject(ChartThemeService);
|
private readonly chartTheme = inject(ChartThemeService);
|
||||||
|
private readonly languageService = inject(LanguageService);
|
||||||
|
|
||||||
categoryLabels: Record<string, string> = {
|
categoryLabels = computed<Record<string, string>>(() => ({
|
||||||
author: 'Autor',
|
author: this.languageService.translate('publications.author'),
|
||||||
collaborator: 'Kollaborierender',
|
collaborator: this.languageService.translate('personNetwork.collaborator'),
|
||||||
institution: 'Institution',
|
institution: this.languageService.translate('publications.institution'),
|
||||||
work: 'Publikation',
|
work: this.languageService.translate('researchTimeline.publication'),
|
||||||
};
|
}));
|
||||||
|
|
||||||
private readonly graphNodes = computed<GraphNode[]>(() => {
|
private readonly graphNodes = computed<GraphNode[]>(() => {
|
||||||
const graph = this.collaborationGraph();
|
const graph = this.collaborationGraph();
|
||||||
@@ -151,7 +153,7 @@ export class CollaborationGraphComponent {
|
|||||||
data: categories.map((category) => category.name),
|
data: categories.map((category) => category.name),
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
orient: 'horizontal',
|
orient: 'horizontal',
|
||||||
formatter: (name: string) => this.categoryLabels[name] || name,
|
formatter: (name: string) => this.categoryLabels()[name] || name,
|
||||||
itemGap: 20,
|
itemGap: 20,
|
||||||
textStyle: { color: textColor },
|
textStyle: { color: textColor },
|
||||||
inactiveColor: colors.mutedTextColor,
|
inactiveColor: colors.mutedTextColor,
|
||||||
|
|||||||
@@ -1,23 +1,25 @@
|
|||||||
<div class="dashboard-wrapper">
|
<div class="dashboard-wrapper">
|
||||||
<section class="dashboard-period-filter" aria-label="Dashboard-Zeitraum">
|
<section
|
||||||
|
class="dashboard-period-filter"
|
||||||
|
[attr.aria-label]="'dashboard.period' | translate">
|
||||||
<div class="dashboard-period-presets">
|
<div class="dashboard-period-presets">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
[class.active]="dashboardPeriodMode === 'all_time'"
|
[class.active]="dashboardPeriodMode === 'all_time'"
|
||||||
(click)="setDashboardPeriodMode('all_time')">
|
(click)="setDashboardPeriodMode('all_time')">
|
||||||
Alle Zeiten
|
{{ 'dashboard.allTime' | translate }}
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
[class.active]="dashboardPeriodMode === 'last_10_years'"
|
[class.active]="dashboardPeriodMode === 'last_10_years'"
|
||||||
(click)="setDashboardPeriodMode('last_10_years')">
|
(click)="setDashboardPeriodMode('last_10_years')">
|
||||||
Letzte 10 Jahre
|
{{ 'dashboard.last10Years' | translate }}
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
[class.active]="dashboardPeriodMode === 'last_5_years'"
|
[class.active]="dashboardPeriodMode === 'last_5_years'"
|
||||||
(click)="setDashboardPeriodMode('last_5_years')">
|
(click)="setDashboardPeriodMode('last_5_years')">
|
||||||
Letzte 5 Jahre
|
{{ 'dashboard.last5Years' | translate }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="dashboard-period-slider">
|
<div class="dashboard-period-slider">
|
||||||
@@ -32,20 +34,24 @@
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="statistics-grid" aria-label="Kennzahlen">
|
<section
|
||||||
|
class="statistics-grid"
|
||||||
|
[attr.aria-label]="'dashboard.metrics' | translate">
|
||||||
<a
|
<a
|
||||||
class="statistics-card"
|
class="statistics-card"
|
||||||
[routerLink]="['/institution', institutionRouteId(), 'publications']"
|
[routerLink]="['/institution', institutionRouteId(), 'publications']"
|
||||||
[class.disabled]="!institutionRouteId()"
|
[class.disabled]="!institutionRouteId()"
|
||||||
[attr.aria-disabled]="!institutionRouteId()"
|
[attr.aria-disabled]="!institutionRouteId()"
|
||||||
[attr.aria-label]="
|
[attr.aria-label]="
|
||||||
'Publikationen von ' + organizationName() + ' anzeigen'
|
languageService.translate('dashboard.showPublications', {
|
||||||
|
name: organizationName(),
|
||||||
|
})
|
||||||
">
|
">
|
||||||
<div class="statistics-icon statistics-icon--publications">
|
<div class="statistics-icon statistics-icon--publications">
|
||||||
<mat-icon>menu_book</mat-icon>
|
<mat-icon>menu_book</mat-icon>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<span>Publikationen</span>
|
<span>{{ 'dashboard.publications' | translate }}</span>
|
||||||
<strong>
|
<strong>
|
||||||
{{
|
{{
|
||||||
isStatisticLoading('publications')
|
isStatisticLoading('publications')
|
||||||
@@ -60,12 +66,16 @@
|
|||||||
class="statistics-card"
|
class="statistics-card"
|
||||||
routerLink="/persons"
|
routerLink="/persons"
|
||||||
[queryParams]="personListQueryParams()"
|
[queryParams]="personListQueryParams()"
|
||||||
[attr.aria-label]="'Personen von ' + organizationName() + ' anzeigen'">
|
[attr.aria-label]="
|
||||||
|
languageService.translate('dashboard.showPeople', {
|
||||||
|
name: organizationName(),
|
||||||
|
})
|
||||||
|
">
|
||||||
<div class="statistics-icon statistics-icon--persons">
|
<div class="statistics-icon statistics-icon--persons">
|
||||||
<mat-icon>groups</mat-icon>
|
<mat-icon>groups</mat-icon>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<span>Personen</span>
|
<span>{{ 'dashboard.people' | translate }}</span>
|
||||||
<strong>
|
<strong>
|
||||||
{{
|
{{
|
||||||
isStatisticLoading('persons')
|
isStatisticLoading('persons')
|
||||||
@@ -81,12 +91,16 @@
|
|||||||
[routerLink]="['/institution', institutionRouteId(), 'patents']"
|
[routerLink]="['/institution', institutionRouteId(), 'patents']"
|
||||||
[class.disabled]="!institutionRouteId()"
|
[class.disabled]="!institutionRouteId()"
|
||||||
[attr.aria-disabled]="!institutionRouteId()"
|
[attr.aria-disabled]="!institutionRouteId()"
|
||||||
[attr.aria-label]="'Patente von ' + organizationName() + ' anzeigen'">
|
[attr.aria-label]="
|
||||||
|
languageService.translate('dashboard.showPatents', {
|
||||||
|
name: organizationName(),
|
||||||
|
})
|
||||||
|
">
|
||||||
<div class="statistics-icon statistics-icon--patents">
|
<div class="statistics-icon statistics-icon--patents">
|
||||||
<mat-icon>description</mat-icon>
|
<mat-icon>description</mat-icon>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<span>Patente</span>
|
<span>{{ 'dashboard.patents' | translate }}</span>
|
||||||
<strong>
|
<strong>
|
||||||
{{
|
{{
|
||||||
isStatisticLoading('patents')
|
isStatisticLoading('patents')
|
||||||
@@ -101,12 +115,12 @@
|
|||||||
class="statistics-card"
|
class="statistics-card"
|
||||||
routerLink="/projects"
|
routerLink="/projects"
|
||||||
[queryParams]="{ selected_project_types: 'eu' }"
|
[queryParams]="{ selected_project_types: 'eu' }"
|
||||||
aria-label="EU-Projekte anzeigen">
|
[attr.aria-label]="'dashboard.showEuProjects' | translate">
|
||||||
<div class="statistics-icon statistics-icon--eu-projects">
|
<div class="statistics-icon statistics-icon--eu-projects">
|
||||||
<mat-icon>public</mat-icon>
|
<mat-icon>public</mat-icon>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<span>EU-Projekte</span>
|
<span>{{ 'dashboard.euProjects' | translate }}</span>
|
||||||
<strong>
|
<strong>
|
||||||
{{
|
{{
|
||||||
isStatisticLoading('eu_projects')
|
isStatisticLoading('eu_projects')
|
||||||
@@ -121,12 +135,12 @@
|
|||||||
class="statistics-card"
|
class="statistics-card"
|
||||||
routerLink="/projects"
|
routerLink="/projects"
|
||||||
[queryParams]="{ selected_project_types: 'bund' }"
|
[queryParams]="{ selected_project_types: 'bund' }"
|
||||||
aria-label="Bund-Projekte anzeigen">
|
[attr.aria-label]="'dashboard.showFederalProjects' | translate">
|
||||||
<div class="statistics-icon statistics-icon--bund-projects">
|
<div class="statistics-icon statistics-icon--bund-projects">
|
||||||
<mat-icon>account_balance</mat-icon>
|
<mat-icon>account_balance</mat-icon>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<span>Bund-Projekte</span>
|
<span>{{ 'dashboard.federalProjects' | translate }}</span>
|
||||||
<strong>
|
<strong>
|
||||||
{{
|
{{
|
||||||
isStatisticLoading('bmbf_projects')
|
isStatisticLoading('bmbf_projects')
|
||||||
@@ -141,12 +155,12 @@
|
|||||||
class="statistics-card"
|
class="statistics-card"
|
||||||
routerLink="/projects"
|
routerLink="/projects"
|
||||||
[queryParams]="{ selected_project_types: 'dfg' }"
|
[queryParams]="{ selected_project_types: 'dfg' }"
|
||||||
aria-label="DFG-Projekte anzeigen">
|
[attr.aria-label]="'dashboard.showDfgProjects' | translate">
|
||||||
<div class="statistics-icon statistics-icon--dfg-projects">
|
<div class="statistics-icon statistics-icon--dfg-projects">
|
||||||
<mat-icon>science</mat-icon>
|
<mat-icon>science</mat-icon>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<span>DFG-Projekte</span>
|
<span>{{ 'dashboard.dfgProjects' | translate }}</span>
|
||||||
<strong>
|
<strong>
|
||||||
{{
|
{{
|
||||||
isStatisticLoading('dfg_projects')
|
isStatisticLoading('dfg_projects')
|
||||||
@@ -159,7 +173,7 @@
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
@if (statisticsError) {
|
@if (statisticsError) {
|
||||||
<p class="statistics-error">Die Kennzahlen konnten nicht geladen werden.</p>
|
<p class="statistics-error">{{ 'dashboard.metricsError' | translate }}</p>
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (
|
@if (
|
||||||
@@ -174,11 +188,8 @@
|
|||||||
<section class="topic-heatmap-section">
|
<section class="topic-heatmap-section">
|
||||||
<header class="topic-heatmap-header">
|
<header class="topic-heatmap-header">
|
||||||
<div>
|
<div>
|
||||||
<h2>Projektstatus nach Fördergeber</h2>
|
<h2>{{ 'dashboard.projectStatusTitle' | translate }}</h2>
|
||||||
<p>
|
<p>{{ 'dashboard.projectStatusDescription' | translate }}</p>
|
||||||
Laufende, kommende und abgeschlossene EU-, Bund- und DFG-Projekte
|
|
||||||
Ihrer Organisation.
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
@if (euProjectStatuses && bmbfProjectStatuses && dfgProjectStatuses) {
|
@if (euProjectStatuses && bmbfProjectStatuses && dfgProjectStatuses) {
|
||||||
<div class="project-status-summary">
|
<div class="project-status-summary">
|
||||||
@@ -217,7 +228,7 @@
|
|||||||
) {
|
) {
|
||||||
<div class="project-status-loading" role="status" aria-live="polite">
|
<div class="project-status-loading" role="status" aria-live="polite">
|
||||||
<app-loading
|
<app-loading
|
||||||
text="Projektstatus wird geladen …"
|
[text]="'dashboard.projectStatusLoading' | translate"
|
||||||
icon="stacked_bar_chart"
|
icon="stacked_bar_chart"
|
||||||
size="64"
|
size="64"
|
||||||
diameter="64"></app-loading>
|
diameter="64"></app-loading>
|
||||||
@@ -228,8 +239,7 @@
|
|||||||
dfgProjectStatusesError
|
dfgProjectStatusesError
|
||||||
) {
|
) {
|
||||||
<p class="statistics-error">
|
<p class="statistics-error">
|
||||||
Der Status der EU-, Bund- und DFG-Projekte konnte nicht geladen
|
{{ 'dashboard.projectStatusError' | translate }}
|
||||||
werden.
|
|
||||||
</p>
|
</p>
|
||||||
} @else if (
|
} @else if (
|
||||||
euProjectStatuses && bmbfProjectStatuses && dfgProjectStatuses
|
euProjectStatuses && bmbfProjectStatuses && dfgProjectStatuses
|
||||||
@@ -246,22 +256,22 @@
|
|||||||
<section class="topic-heatmap-section">
|
<section class="topic-heatmap-section">
|
||||||
<header class="topic-heatmap-header">
|
<header class="topic-heatmap-header">
|
||||||
<div>
|
<div>
|
||||||
<h2>Field Treemap</h2>
|
<h2>{{ 'dashboard.treemapTitle' | translate }}</h2>
|
||||||
<p>Publikationen Ihrer Organisation nach Field.</p>
|
<p>{{ 'dashboard.treemapDescription' | translate }}</p>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
@if (topicTreemapLoading) {
|
@if (topicTreemapLoading) {
|
||||||
<div class="topic-heatmap-loading" role="status" aria-live="polite">
|
<div class="topic-heatmap-loading" role="status" aria-live="polite">
|
||||||
<app-loading
|
<app-loading
|
||||||
text="Treemap-Daten für den gewählten Zeitraum werden geladen …"
|
[text]="'dashboard.treemapLoading' | translate"
|
||||||
icon="account_tree"
|
icon="account_tree"
|
||||||
size="72"
|
size="72"
|
||||||
diameter="72"></app-loading>
|
diameter="72"></app-loading>
|
||||||
</div>
|
</div>
|
||||||
} @else if (topicTreemapError) {
|
} @else if (topicTreemapError) {
|
||||||
<p class="statistics-error">
|
<p class="statistics-error">
|
||||||
Die Field-Treemap konnte nicht geladen werden.
|
{{ 'dashboard.treemapError' | translate }}
|
||||||
</p>
|
</p>
|
||||||
} @else {
|
} @else {
|
||||||
<app-topic-treemap
|
<app-topic-treemap
|
||||||
@@ -278,16 +288,17 @@
|
|||||||
<section class="topic-heatmap-section">
|
<section class="topic-heatmap-section">
|
||||||
<header class="topic-heatmap-header">
|
<header class="topic-heatmap-header">
|
||||||
<div>
|
<div>
|
||||||
<h2>DFG-Projekt-Topics</h2>
|
<h2>{{ 'dashboard.dfgTopicsTitle' | translate }}</h2>
|
||||||
<p>
|
<p>{{ 'dashboard.dfgTopicsDescription' | translate }}</p>
|
||||||
Gematchte DFG-Projekte nach Field, Subfield und Topic. Ein Klick
|
|
||||||
auf ein Topic zeigt die zugehörigen Keywords.
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
@if (dfgProjectTopics) {
|
@if (dfgProjectTopics) {
|
||||||
<p class="dfg-topic-summary">
|
<p class="dfg-topic-summary">
|
||||||
{{ dfgProjectTopics.matched_project_count | number }} von
|
{{
|
||||||
{{ dfgProjectTopics.project_count | number }} Projekten gematcht
|
languageService.translate('dashboard.dfgMatched', {
|
||||||
|
matched: dfgProjectTopics.matched_project_count,
|
||||||
|
total: dfgProjectTopics.project_count,
|
||||||
|
})
|
||||||
|
}}
|
||||||
</p>
|
</p>
|
||||||
}
|
}
|
||||||
</header>
|
</header>
|
||||||
@@ -295,20 +306,20 @@
|
|||||||
@if (dfgTopicsLoading) {
|
@if (dfgTopicsLoading) {
|
||||||
<div class="topic-heatmap-loading" role="status" aria-live="polite">
|
<div class="topic-heatmap-loading" role="status" aria-live="polite">
|
||||||
<app-loading
|
<app-loading
|
||||||
text="DFG-Topics werden geladen …"
|
[text]="'dashboard.dfgTopicsLoading' | translate"
|
||||||
icon="account_tree"
|
icon="account_tree"
|
||||||
size="72"
|
size="72"
|
||||||
diameter="72"></app-loading>
|
diameter="72"></app-loading>
|
||||||
</div>
|
</div>
|
||||||
} @else if (dfgTopicsError) {
|
} @else if (dfgTopicsError) {
|
||||||
<p class="statistics-error">
|
<p class="statistics-error">
|
||||||
Die DFG-Topic-Treemap konnte nicht geladen werden.
|
{{ 'dashboard.dfgTopicsError' | translate }}
|
||||||
</p>
|
</p>
|
||||||
} @else {
|
} @else {
|
||||||
<app-topic-treemap
|
<app-topic-treemap
|
||||||
[data]="dfgTopicTreemap"
|
[data]="dfgTopicTreemap"
|
||||||
[selectedNodeId]="selectedDfgTopicTreemapNode"
|
[selectedNodeId]="selectedDfgTopicTreemapNode"
|
||||||
countLabel="DFG-Projekte"
|
[countLabel]="'dashboard.dfgProjects' | translate"
|
||||||
[showCountInTooltip]="false"
|
[showCountInTooltip]="false"
|
||||||
(selectedNodeIdChange)="onDfgTopicTreemapNodeChange($event)"
|
(selectedNodeIdChange)="onDfgTopicTreemapNodeChange($event)"
|
||||||
(topicSelect)="onDfgTopicTreemapTopicSelect($event)">
|
(topicSelect)="onDfgTopicTreemapTopicSelect($event)">
|
||||||
@@ -321,17 +332,14 @@
|
|||||||
<section class="top-authors-section">
|
<section class="top-authors-section">
|
||||||
<header class="top-authors-header">
|
<header class="top-authors-header">
|
||||||
<div>
|
<div>
|
||||||
<h2>Top 10 Personen</h2>
|
<h2>{{ 'dashboard.topPeopleTitle' | translate }}</h2>
|
||||||
<p>
|
<p>{{ 'dashboard.topPeopleDescription' | translate }}</p>
|
||||||
Nach Anzahl der Works, DFG-Projekte, Patente und News Ihrer
|
|
||||||
Organisation.
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
@if (topAuthorsError) {
|
@if (topAuthorsError) {
|
||||||
<p class="statistics-error">
|
<p class="statistics-error">
|
||||||
Die Autorenstatistiken konnten nicht geladen werden.
|
{{ 'dashboard.topPeopleError' | translate }}
|
||||||
</p>
|
</p>
|
||||||
} @else {
|
} @else {
|
||||||
<div class="top-authors-grid" [class.loading]="topAuthorsLoading">
|
<div class="top-authors-grid" [class.loading]="topAuthorsLoading">
|
||||||
@@ -380,8 +388,8 @@
|
|||||||
<p class="empty-chart">
|
<p class="empty-chart">
|
||||||
{{
|
{{
|
||||||
topAuthorsLoading
|
topAuthorsLoading
|
||||||
? 'Wird geladen …'
|
? ('dashboard.loading' | translate)
|
||||||
: 'Keine Daten vorhanden.'
|
: ('dashboard.noData' | translate)
|
||||||
}}
|
}}
|
||||||
</p>
|
</p>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, inject, OnInit } from '@angular/core';
|
||||||
import { DecimalPipe } from '@angular/common';
|
import { DecimalPipe } from '@angular/common';
|
||||||
import { MatIconModule } from '@angular/material/icon';
|
import { MatIconModule } from '@angular/material/icon';
|
||||||
import { Observable, finalize } from 'rxjs';
|
import { Observable, finalize } from 'rxjs';
|
||||||
@@ -33,6 +33,8 @@ import {
|
|||||||
institutionPersonListQueryParamsForPeriod,
|
institutionPersonListQueryParamsForPeriod,
|
||||||
PersonListQueryParams,
|
PersonListQueryParams,
|
||||||
} from '../../shared/person-list-query-params';
|
} from '../../shared/person-list-query-params';
|
||||||
|
import { LanguageService } from '../../shared/i18n/language.service';
|
||||||
|
import { TranslatePipe } from '../../shared/i18n/translate.pipe';
|
||||||
type DashboardStatisticKey =
|
type DashboardStatisticKey =
|
||||||
| 'publications'
|
| 'publications'
|
||||||
| 'persons'
|
| 'persons'
|
||||||
@@ -61,11 +63,13 @@ type DashboardPeriodMode =
|
|||||||
EuProjectStatusChartComponent,
|
EuProjectStatusChartComponent,
|
||||||
TopicTreemapComponent,
|
TopicTreemapComponent,
|
||||||
YearRangeSliderComponent,
|
YearRangeSliderComponent,
|
||||||
|
TranslatePipe,
|
||||||
],
|
],
|
||||||
templateUrl: './dashboard.component.html',
|
templateUrl: './dashboard.component.html',
|
||||||
styleUrl: './dashboard.component.scss',
|
styleUrl: './dashboard.component.scss',
|
||||||
})
|
})
|
||||||
export class DashboardComponent implements OnInit {
|
export class DashboardComponent implements OnInit {
|
||||||
|
protected readonly languageService = inject(LanguageService);
|
||||||
statistics?: Partial<DashboardStatistics>;
|
statistics?: Partial<DashboardStatistics>;
|
||||||
statisticsLoading = false;
|
statisticsLoading = false;
|
||||||
statisticsError = false;
|
statisticsError = false;
|
||||||
@@ -108,7 +112,7 @@ export class DashboardComponent implements OnInit {
|
|||||||
readonly topicTreemapMinYear = 1900;
|
readonly topicTreemapMinYear = 1900;
|
||||||
readonly topicTreemapMaxYear = new Date().getFullYear();
|
readonly topicTreemapMaxYear = new Date().getFullYear();
|
||||||
dashboardPeriodMode: DashboardPeriodMode = 'all_time';
|
dashboardPeriodMode: DashboardPeriodMode = 'all_time';
|
||||||
dashboardFromYear = this.topicTreemapMinYear;
|
dashboardFromYear = this.topicTreemapMaxYear - 4;
|
||||||
dashboardToYear = this.topicTreemapMaxYear;
|
dashboardToYear = this.topicTreemapMaxYear;
|
||||||
selectedTopicTreemapNode?: string;
|
selectedTopicTreemapNode?: string;
|
||||||
selectedDfgTopicTreemapNode?: string;
|
selectedDfgTopicTreemapNode?: string;
|
||||||
@@ -169,22 +173,22 @@ export class DashboardComponent implements OnInit {
|
|||||||
topAuthorDatasets(): TopAuthorDataset[] {
|
topAuthorDatasets(): TopAuthorDataset[] {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
title: 'Publikationen',
|
title: this.languageService.translate('dashboard.publications'),
|
||||||
icon: 'menu_book',
|
icon: 'menu_book',
|
||||||
entries: this.topAuthors?.works ?? [],
|
entries: this.topAuthors?.works ?? [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'EU-Projekte',
|
title: this.languageService.translate('dashboard.euProjects'),
|
||||||
icon: 'public',
|
icon: 'public',
|
||||||
entries: this.topAuthors?.eu_projects ?? [],
|
entries: this.topAuthors?.eu_projects ?? [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Patente',
|
title: this.languageService.translate('dashboard.patents'),
|
||||||
icon: 'description',
|
icon: 'description',
|
||||||
entries: this.topAuthors?.patents ?? [],
|
entries: this.topAuthors?.patents ?? [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'DFG Projekte',
|
title: this.languageService.translate('dashboard.dfgProjects'),
|
||||||
icon: 'account_tree',
|
icon: 'account_tree',
|
||||||
entries: this.topAuthors?.projects ?? [],
|
entries: this.topAuthors?.projects ?? [],
|
||||||
stripAuthorTitle: true,
|
stripAuthorTitle: true,
|
||||||
@@ -225,8 +229,12 @@ export class DashboardComponent implements OnInit {
|
|||||||
Map<string, { topics: DfgProjectTopic[] }>
|
Map<string, { topics: DfgProjectTopic[] }>
|
||||||
>();
|
>();
|
||||||
for (const topic of projectTopics.topics) {
|
for (const topic of projectTopics.topics) {
|
||||||
const fieldName = topic.field?.trim() || 'Ohne Field';
|
const fieldName =
|
||||||
const subfieldName = topic.subfield?.trim() || 'Ohne Subfield';
|
topic.field?.trim() ||
|
||||||
|
this.languageService.translate('dashboard.withoutField');
|
||||||
|
const subfieldName =
|
||||||
|
topic.subfield?.trim() ||
|
||||||
|
this.languageService.translate('dashboard.withoutSubfield');
|
||||||
const subfields =
|
const subfields =
|
||||||
fields.get(fieldName) ??
|
fields.get(fieldName) ??
|
||||||
new Map<string, { topics: DfgProjectTopic[] }>();
|
new Map<string, { topics: DfgProjectTopic[] }>();
|
||||||
@@ -310,7 +318,10 @@ export class DashboardComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
organizationName(): string {
|
organizationName(): string {
|
||||||
return this.statistics?.organization_name ?? 'Ihre Organisation';
|
return (
|
||||||
|
this.statistics?.organization_name ??
|
||||||
|
this.languageService.translate('dashboard.yourOrganization')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
institutionRouteId(): string {
|
institutionRouteId(): string {
|
||||||
@@ -406,16 +417,14 @@ export class DashboardComponent implements OnInit {
|
|||||||
this.dashboardPeriodMode = mode;
|
this.dashboardPeriodMode = mode;
|
||||||
}
|
}
|
||||||
this.applyPresetPeriod();
|
this.applyPresetPeriod();
|
||||||
if (this.dashboardPeriodMode !== 'all_time') {
|
this.dashboardFromYear = this.parseDashboardYear(
|
||||||
this.dashboardFromYear = this.parseDashboardYear(
|
params.get('fromYear'),
|
||||||
params.get('fromYear'),
|
this.dashboardFromYear,
|
||||||
this.dashboardFromYear,
|
);
|
||||||
);
|
this.dashboardToYear = this.parseDashboardYear(
|
||||||
this.dashboardToYear = this.parseDashboardYear(
|
params.get('toYear'),
|
||||||
params.get('toYear'),
|
this.dashboardToYear,
|
||||||
this.dashboardToYear,
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
if (this.dashboardFromYear > this.dashboardToYear) {
|
if (this.dashboardFromYear > this.dashboardToYear) {
|
||||||
this.dashboardFromYear = this.dashboardToYear;
|
this.dashboardFromYear = this.dashboardToYear;
|
||||||
}
|
}
|
||||||
@@ -424,10 +433,7 @@ export class DashboardComponent implements OnInit {
|
|||||||
|
|
||||||
private applyPresetPeriod(): void {
|
private applyPresetPeriod(): void {
|
||||||
const currentYear = this.topicTreemapMaxYear;
|
const currentYear = this.topicTreemapMaxYear;
|
||||||
if (this.dashboardPeriodMode === 'all_time') {
|
if (this.dashboardPeriodMode === 'last_10_years') {
|
||||||
this.dashboardFromYear = this.topicTreemapMinYear;
|
|
||||||
this.dashboardToYear = currentYear;
|
|
||||||
} else if (this.dashboardPeriodMode === 'last_10_years') {
|
|
||||||
this.dashboardFromYear = currentYear - 9;
|
this.dashboardFromYear = currentYear - 9;
|
||||||
this.dashboardToYear = currentYear;
|
this.dashboardToYear = currentYear;
|
||||||
} else if (this.dashboardPeriodMode === 'last_5_years') {
|
} else if (this.dashboardPeriodMode === 'last_5_years') {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
@if (topics.length) {
|
@if (topics.length) {
|
||||||
<div echarts [options]="options" class="dfg-topic-donut-chart"></div>
|
<div echarts [options]="options" class="dfg-topic-donut-chart"></div>
|
||||||
} @else {
|
} @else {
|
||||||
<p class="dfg-topic-donut-empty">Keine gematchten DFG-Topics vorhanden.</p>
|
<p class="dfg-topic-donut-empty">
|
||||||
|
{{ 'dashboard.noDfgTopics' | translate }}
|
||||||
|
</p>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,14 @@ import { Component, Input, OnChanges, effect, inject } from '@angular/core';
|
|||||||
import { EChartsOption } from 'echarts';
|
import { EChartsOption } from 'echarts';
|
||||||
import { NgxEchartsDirective } from 'ngx-echarts';
|
import { NgxEchartsDirective } from 'ngx-echarts';
|
||||||
import { ChartThemeService } from '../../../shared/services/chart-theme.service';
|
import { ChartThemeService } from '../../../shared/services/chart-theme.service';
|
||||||
|
import { LanguageService } from '../../../shared/i18n/language.service';
|
||||||
|
import { TranslatePipe } from '../../../shared/i18n/translate.pipe';
|
||||||
|
|
||||||
import { DfgProjectTopic } from '../dashboard-statistics.service';
|
import { DfgProjectTopic } from '../dashboard-statistics.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dfg-topic-donut',
|
selector: 'app-dfg-topic-donut',
|
||||||
imports: [NgxEchartsDirective],
|
imports: [NgxEchartsDirective, TranslatePipe],
|
||||||
templateUrl: './dfg-topic-donut.component.html',
|
templateUrl: './dfg-topic-donut.component.html',
|
||||||
styleUrl: './dfg-topic-donut.component.scss',
|
styleUrl: './dfg-topic-donut.component.scss',
|
||||||
})
|
})
|
||||||
@@ -15,6 +17,7 @@ export class DfgTopicDonutComponent implements OnChanges {
|
|||||||
@Input() topics: DfgProjectTopic[] = [];
|
@Input() topics: DfgProjectTopic[] = [];
|
||||||
|
|
||||||
private chartTheme = inject(ChartThemeService);
|
private chartTheme = inject(ChartThemeService);
|
||||||
|
private languageService = inject(LanguageService);
|
||||||
options: EChartsOption = {};
|
options: EChartsOption = {};
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -51,7 +54,9 @@ export class DfgTopicDonutComponent implements OnChanges {
|
|||||||
borderColor: theme.tooltipBorder,
|
borderColor: theme.tooltipBorder,
|
||||||
textStyle: { color: theme.tooltipTextColor },
|
textStyle: { color: theme.tooltipTextColor },
|
||||||
formatter: (params: any) =>
|
formatter: (params: any) =>
|
||||||
`<strong>${this.escapeHtml(String(params.name ?? ''))}</strong><br>${Number(params.value ?? 0).toLocaleString('de-DE')} DFG-Projekte`,
|
`<strong>${this.escapeHtml(String(params.name ?? ''))}</strong><br>${Number(params.value ?? 0).toLocaleString(
|
||||||
|
this.languageService.language() === 'de' ? 'de-DE' : 'en-US',
|
||||||
|
)} ${this.languageService.translate('dashboard.dfgProjects')}`,
|
||||||
},
|
},
|
||||||
legend: {
|
legend: {
|
||||||
type: 'scroll',
|
type: 'scroll',
|
||||||
@@ -68,7 +73,7 @@ export class DfgTopicDonutComponent implements OnChanges {
|
|||||||
left: '30%',
|
left: '30%',
|
||||||
top: '46%',
|
top: '46%',
|
||||||
style: {
|
style: {
|
||||||
text: `${this.topics.length}\nTopics`,
|
text: `${this.topics.length}\n${this.languageService.translate('nav.topics')}`,
|
||||||
align: 'center',
|
align: 'center',
|
||||||
fill: theme.textColor,
|
fill: theme.textColor,
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
@@ -79,7 +84,7 @@ export class DfgTopicDonutComponent implements OnChanges {
|
|||||||
],
|
],
|
||||||
series: [
|
series: [
|
||||||
{
|
{
|
||||||
name: 'DFG-Topics',
|
name: this.languageService.translate('dashboard.dfgTopicsTitle'),
|
||||||
type: 'pie',
|
type: 'pie',
|
||||||
radius: ['42%', '72%'],
|
radius: ['42%', '72%'],
|
||||||
center: ['32%', '50%'],
|
center: ['32%', '50%'],
|
||||||
@@ -95,7 +100,7 @@ export class DfgTopicDonutComponent implements OnChanges {
|
|||||||
scaleSize: 8,
|
scaleSize: 8,
|
||||||
label: {
|
label: {
|
||||||
show: true,
|
show: true,
|
||||||
formatter: '{b}\n{c} Projekte',
|
formatter: `{b}\n{c} ${this.languageService.translate('dashboard.projects')}`,
|
||||||
fontWeight: 700,
|
fontWeight: 700,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
+1
-1
@@ -3,4 +3,4 @@
|
|||||||
[options]="options"
|
[options]="options"
|
||||||
class="eu-project-status-chart"
|
class="eu-project-status-chart"
|
||||||
role="img"
|
role="img"
|
||||||
aria-label="Gestapeltes Balkendiagramm zum Status der EU- und Bund-Projekte"></div>
|
[attr.aria-label]="'dashboard.projectStatusChartLabel' | translate"></div>
|
||||||
|
|||||||
+16
-7
@@ -2,6 +2,8 @@ import { Component, Input, OnChanges, effect, inject } from '@angular/core';
|
|||||||
import { EChartsOption } from 'echarts';
|
import { EChartsOption } from 'echarts';
|
||||||
import { NgxEchartsDirective } from 'ngx-echarts';
|
import { NgxEchartsDirective } from 'ngx-echarts';
|
||||||
import { ChartThemeService } from '../../../shared/services/chart-theme.service';
|
import { ChartThemeService } from '../../../shared/services/chart-theme.service';
|
||||||
|
import { LanguageService } from '../../../shared/i18n/language.service';
|
||||||
|
import { TranslatePipe } from '../../../shared/i18n/translate.pipe';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
BmbfProjectStatusStatistics,
|
BmbfProjectStatusStatistics,
|
||||||
@@ -11,7 +13,7 @@ import {
|
|||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-eu-project-status-chart',
|
selector: 'app-eu-project-status-chart',
|
||||||
imports: [NgxEchartsDirective],
|
imports: [NgxEchartsDirective, TranslatePipe],
|
||||||
templateUrl: './eu-project-status-chart.component.html',
|
templateUrl: './eu-project-status-chart.component.html',
|
||||||
styleUrl: './eu-project-status-chart.component.scss',
|
styleUrl: './eu-project-status-chart.component.scss',
|
||||||
})
|
})
|
||||||
@@ -21,6 +23,7 @@ export class EuProjectStatusChartComponent implements OnChanges {
|
|||||||
@Input({ required: true }) dfgStatuses!: DfgProjectStatusStatistics;
|
@Input({ required: true }) dfgStatuses!: DfgProjectStatusStatistics;
|
||||||
|
|
||||||
private chartTheme = inject(ChartThemeService);
|
private chartTheme = inject(ChartThemeService);
|
||||||
|
private languageService = inject(LanguageService);
|
||||||
options: EChartsOption = {};
|
options: EChartsOption = {};
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -39,7 +42,7 @@ export class EuProjectStatusChartComponent implements OnChanges {
|
|||||||
|
|
||||||
const values = [
|
const values = [
|
||||||
{
|
{
|
||||||
name: 'Laufend',
|
name: this.languageService.translate('dashboard.ongoing'),
|
||||||
data: [
|
data: [
|
||||||
this.statuses?.ongoing ?? 0,
|
this.statuses?.ongoing ?? 0,
|
||||||
this.bmbfStatuses?.ongoing ?? 0,
|
this.bmbfStatuses?.ongoing ?? 0,
|
||||||
@@ -48,7 +51,7 @@ export class EuProjectStatusChartComponent implements OnChanges {
|
|||||||
color: '#2563eb',
|
color: '#2563eb',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Kommend',
|
name: this.languageService.translate('dashboard.upcoming'),
|
||||||
data: [
|
data: [
|
||||||
this.statuses?.upcoming ?? 0,
|
this.statuses?.upcoming ?? 0,
|
||||||
this.bmbfStatuses?.upcoming ?? 0,
|
this.bmbfStatuses?.upcoming ?? 0,
|
||||||
@@ -57,7 +60,7 @@ export class EuProjectStatusChartComponent implements OnChanges {
|
|||||||
color: '#f59e0b',
|
color: '#f59e0b',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Abgeschlossen',
|
name: this.languageService.translate('dashboard.completed'),
|
||||||
data: [
|
data: [
|
||||||
this.statuses?.completed ?? 0,
|
this.statuses?.completed ?? 0,
|
||||||
this.bmbfStatuses?.completed ?? 0,
|
this.bmbfStatuses?.completed ?? 0,
|
||||||
@@ -79,7 +82,9 @@ export class EuProjectStatusChartComponent implements OnChanges {
|
|||||||
borderColor: theme.tooltipBorder,
|
borderColor: theme.tooltipBorder,
|
||||||
textStyle: { color: theme.tooltipTextColor },
|
textStyle: { color: theme.tooltipTextColor },
|
||||||
valueFormatter: (value) =>
|
valueFormatter: (value) =>
|
||||||
`${Number(value ?? 0).toLocaleString('de-DE')} Projekte`,
|
`${Number(value ?? 0).toLocaleString(
|
||||||
|
this.languageService.language() === 'de' ? 'de-DE' : 'en-US',
|
||||||
|
)} ${this.languageService.translate('dashboard.projects')}`,
|
||||||
},
|
},
|
||||||
legend: {
|
legend: {
|
||||||
top: 0,
|
top: 0,
|
||||||
@@ -91,7 +96,7 @@ export class EuProjectStatusChartComponent implements OnChanges {
|
|||||||
xAxis: {
|
xAxis: {
|
||||||
type: 'value',
|
type: 'value',
|
||||||
minInterval: 1,
|
minInterval: 1,
|
||||||
name: 'Anzahl Projekte',
|
name: this.languageService.translate('dashboard.projectCount'),
|
||||||
nameLocation: 'middle',
|
nameLocation: 'middle',
|
||||||
nameGap: 28,
|
nameGap: 28,
|
||||||
axisLabel: { color: theme.mutedTextColor },
|
axisLabel: { color: theme.mutedTextColor },
|
||||||
@@ -100,7 +105,11 @@ export class EuProjectStatusChartComponent implements OnChanges {
|
|||||||
},
|
},
|
||||||
yAxis: {
|
yAxis: {
|
||||||
type: 'category',
|
type: 'category',
|
||||||
data: ['EU-Projekte', 'Bund-Projekte', 'DFG-Projekte'],
|
data: [
|
||||||
|
this.languageService.translate('dashboard.euProjects'),
|
||||||
|
this.languageService.translate('dashboard.federalProjects'),
|
||||||
|
this.languageService.translate('dashboard.dfgProjects'),
|
||||||
|
],
|
||||||
axisTick: { show: false },
|
axisTick: { show: false },
|
||||||
axisLine: { show: false },
|
axisLine: { show: false },
|
||||||
axisLabel: { color: theme.textColor, fontWeight: 600 },
|
axisLabel: { color: theme.textColor, fontWeight: 600 },
|
||||||
|
|||||||
+44
-32
@@ -1,17 +1,19 @@
|
|||||||
<div class="dialog-title" mat-dialog-title>
|
<div class="dialog-title" mat-dialog-title>
|
||||||
<div class="dialog-heading">
|
<div class="dialog-heading">
|
||||||
<div>
|
<div>
|
||||||
<span class="dialog-eyebrow">Topic Insights</span>
|
<span class="dialog-eyebrow">{{ 'wordcloud.insights' | translate }}</span>
|
||||||
<h2>
|
<h2>
|
||||||
{{
|
{{
|
||||||
data.source === 'dfg' ? 'DFG-Keyword Wordcloud' : 'Keyword Wordcloud'
|
data.source === 'dfg'
|
||||||
|
? ('wordcloud.dfgTitle' | translate)
|
||||||
|
: ('wordcloud.title' | translate)
|
||||||
}}
|
}}
|
||||||
</h2>
|
</h2>
|
||||||
<p>
|
<p>
|
||||||
{{
|
{{
|
||||||
data.source === 'dfg'
|
data.source === 'dfg'
|
||||||
? 'Keywords der DFG-Projekte zum ausgewählten Topic'
|
? ('wordcloud.dfgDescription' | translate)
|
||||||
: 'Die wichtigsten Begriffe zum ausgewählten Forschungsthema'
|
: ('wordcloud.description' | translate)
|
||||||
}}
|
}}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -20,14 +22,16 @@
|
|||||||
class="dialog-close"
|
class="dialog-close"
|
||||||
mat-icon-button
|
mat-icon-button
|
||||||
type="button"
|
type="button"
|
||||||
aria-label="Dialog schließen"
|
[attr.aria-label]="'wordcloud.close' | translate"
|
||||||
mat-dialog-close>
|
mat-dialog-close>
|
||||||
<mat-icon>close</mat-icon>
|
<mat-icon>close</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<mat-dialog-content>
|
<mat-dialog-content>
|
||||||
<div class="topic-context-card" aria-label="Ausgewählte Themenhierarchie">
|
<div
|
||||||
|
class="topic-context-card"
|
||||||
|
[attr.aria-label]="'wordcloud.hierarchy' | translate">
|
||||||
<div class="topic-context-item">
|
<div class="topic-context-item">
|
||||||
<span
|
<span
|
||||||
class="topic-context-icon topic-context-icon--field"
|
class="topic-context-icon topic-context-icon--field"
|
||||||
@@ -76,14 +80,20 @@
|
|||||||
<section class="word-cloud-panel" aria-labelledby="word-cloud-heading">
|
<section class="word-cloud-panel" aria-labelledby="word-cloud-heading">
|
||||||
<div class="word-cloud-panel-header">
|
<div class="word-cloud-panel-header">
|
||||||
<div>
|
<div>
|
||||||
<h3 id="word-cloud-heading">Top Keywords</h3>
|
<h3 id="word-cloud-heading">
|
||||||
|
{{ 'wordcloud.topKeywords' | translate }}
|
||||||
|
</h3>
|
||||||
<p>
|
<p>
|
||||||
Die Schriftgröße entspricht der Anzahl der
|
{{
|
||||||
{{ data.source === 'dfg' ? 'DFG-Projekte' : 'Publikationen' }}.
|
(data.source === 'dfg'
|
||||||
|
? 'wordcloud.sizeDescriptionDfg'
|
||||||
|
: 'wordcloud.sizeDescriptionPublications'
|
||||||
|
) | translate
|
||||||
|
}}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
@if (!loading && !loadFailed && words.length) {
|
@if (!loading && !loadFailed && words.length) {
|
||||||
<span class="word-count">{{ words.length }} Begriffe</span>
|
<span class="word-count">{{ termCountLabel() }}</span>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -92,27 +102,26 @@
|
|||||||
<span class="state-icon state-icon--loading" aria-hidden="true">
|
<span class="state-icon state-icon--loading" aria-hidden="true">
|
||||||
<mat-icon>hourglass_top</mat-icon>
|
<mat-icon>hourglass_top</mat-icon>
|
||||||
</span>
|
</span>
|
||||||
<strong>Wordcloud wird erstellt</strong>
|
<strong>{{ 'wordcloud.creating' | translate }}</strong>
|
||||||
<span>Die wichtigsten Keywords werden geladen …</span>
|
<span>{{ 'wordcloud.loading' | translate }}</span>
|
||||||
</div>
|
</div>
|
||||||
} @else if (loadFailed) {
|
} @else if (loadFailed) {
|
||||||
<div class="word-cloud-state word-cloud-state--error">
|
<div class="word-cloud-state word-cloud-state--error">
|
||||||
<span class="state-icon" aria-hidden="true"
|
<span class="state-icon" aria-hidden="true"
|
||||||
><mat-icon>cloud_off</mat-icon></span
|
><mat-icon>cloud_off</mat-icon></span
|
||||||
>
|
>
|
||||||
<strong>Wordcloud nicht verfügbar</strong>
|
<strong>{{ 'wordcloud.unavailable' | translate }}</strong>
|
||||||
<span>Die Keywords konnten nicht geladen werden.</span>
|
<span>{{ 'wordcloud.loadError' | translate }}</span>
|
||||||
</div>
|
</div>
|
||||||
} @else if (words.length) {
|
} @else if (words.length) {
|
||||||
<div class="keyword-toolbar" aria-label="Ausgewählte Keywords">
|
<div
|
||||||
|
class="keyword-toolbar"
|
||||||
|
[attr.aria-label]="'wordcloud.selectedKeywords' | translate">
|
||||||
<div class="keyword-toolbar-label">
|
<div class="keyword-toolbar-label">
|
||||||
<mat-icon aria-hidden="true">tune</mat-icon>
|
<mat-icon aria-hidden="true">tune</mat-icon>
|
||||||
<span>
|
<span>
|
||||||
<strong>Keyword-Auswahl</strong>
|
<strong>{{ 'wordcloud.selection' | translate }}</strong>
|
||||||
<small
|
<small>{{ 'wordcloud.selectionHelp' | translate }}</small>
|
||||||
>Klicken Sie auf Begriffe in der Wordcloud, um sie
|
|
||||||
auszuwählen.</small
|
|
||||||
>
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -121,13 +130,15 @@
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="keyword-chip"
|
class="keyword-chip"
|
||||||
[attr.aria-label]="word.name + ' aus Auswahl entfernen'"
|
[attr.aria-label]="removeWordLabel(word.name)"
|
||||||
(click)="toggleWord(word)">
|
(click)="toggleWord(word)">
|
||||||
{{ word.name }}
|
{{ word.name }}
|
||||||
<mat-icon aria-hidden="true">close</mat-icon>
|
<mat-icon aria-hidden="true">close</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
} @empty {
|
} @empty {
|
||||||
<span class="keyword-selection-empty">Noch nichts ausgewählt</span>
|
<span class="keyword-selection-empty">
|
||||||
|
{{ 'wordcloud.nothingSelected' | translate }}
|
||||||
|
</span>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -138,7 +149,7 @@
|
|||||||
type="button"
|
type="button"
|
||||||
class="keyword-clear"
|
class="keyword-clear"
|
||||||
(click)="clearSelection()">
|
(click)="clearSelection()">
|
||||||
Auswahl löschen
|
{{ 'wordcloud.clearSelection' | translate }}
|
||||||
</button>
|
</button>
|
||||||
}
|
}
|
||||||
<a
|
<a
|
||||||
@@ -158,7 +169,7 @@
|
|||||||
: closeForSearchNavigation()
|
: closeForSearchNavigation()
|
||||||
">
|
">
|
||||||
<mat-icon aria-hidden="true">manage_search</mat-icon>
|
<mat-icon aria-hidden="true">manage_search</mat-icon>
|
||||||
Suche in Keywords
|
{{ 'wordcloud.searchKeywords' | translate }}
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
mat-flat-button
|
mat-flat-button
|
||||||
@@ -179,12 +190,14 @@
|
|||||||
: closeForSearchNavigation()
|
: closeForSearchNavigation()
|
||||||
">
|
">
|
||||||
<mat-icon aria-hidden="true">search</mat-icon>
|
<mat-icon aria-hidden="true">search</mat-icon>
|
||||||
Suche in Themen
|
{{ 'wordcloud.searchTopics' | translate }}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="word-cloud-chart" aria-label="Wordcloud verwandter Themen">
|
<div
|
||||||
|
class="word-cloud-chart"
|
||||||
|
[attr.aria-label]="'wordcloud.relatedTopics' | translate">
|
||||||
@for (word of words; track word.id) {
|
@for (word of words; track word.id) {
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
@@ -198,7 +211,9 @@
|
|||||||
word.name +
|
word.name +
|
||||||
': ' +
|
': ' +
|
||||||
word.count +
|
word.count +
|
||||||
(data.source === 'dfg' ? ' DFG-Projekte' : ' Publikationen')
|
(data.source === 'dfg'
|
||||||
|
? ' ' + languageService.translate('dashboard.dfgProjects')
|
||||||
|
: ' ' + languageService.translate('dashboard.publications'))
|
||||||
"
|
"
|
||||||
(click)="toggleWord(word)">
|
(click)="toggleWord(word)">
|
||||||
{{ word.name }}
|
{{ word.name }}
|
||||||
@@ -210,11 +225,8 @@
|
|||||||
<span class="state-icon" aria-hidden="true"
|
<span class="state-icon" aria-hidden="true"
|
||||||
><mat-icon>search_off</mat-icon></span
|
><mat-icon>search_off</mat-icon></span
|
||||||
>
|
>
|
||||||
<strong>Keine Keywords gefunden</strong>
|
<strong>{{ 'wordcloud.noKeywords' | translate }}</strong>
|
||||||
<span
|
<span>{{ 'wordcloud.noData' | translate }}</span>
|
||||||
>Für dieses Topic sind im gewählten Zeitraum keine Daten
|
|
||||||
vorhanden.</span
|
|
||||||
>
|
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
+16
@@ -14,6 +14,8 @@ import {
|
|||||||
DashboardStatisticsService,
|
DashboardStatisticsService,
|
||||||
TopicWordCloudWord,
|
TopicWordCloudWord,
|
||||||
} from '../dashboard-statistics.service';
|
} from '../dashboard-statistics.service';
|
||||||
|
import { LanguageService } from '../../../shared/i18n/language.service';
|
||||||
|
import { TranslatePipe } from '../../../shared/i18n/translate.pipe';
|
||||||
|
|
||||||
export interface TopicWordCloudDialogData {
|
export interface TopicWordCloudDialogData {
|
||||||
topicId: string;
|
topicId: string;
|
||||||
@@ -41,6 +43,7 @@ interface DisplayWord extends TopicWordCloudWord {
|
|||||||
MatDialogModule,
|
MatDialogModule,
|
||||||
MatIconModule,
|
MatIconModule,
|
||||||
RouterLink,
|
RouterLink,
|
||||||
|
TranslatePipe,
|
||||||
],
|
],
|
||||||
templateUrl: './topic-wordcloud-dialog.component.html',
|
templateUrl: './topic-wordcloud-dialog.component.html',
|
||||||
styleUrl: './topic-wordcloud-dialog.component.scss',
|
styleUrl: './topic-wordcloud-dialog.component.scss',
|
||||||
@@ -52,6 +55,7 @@ export class TopicWordCloudDialogComponent {
|
|||||||
);
|
);
|
||||||
private readonly statisticsService = inject(DashboardStatisticsService);
|
private readonly statisticsService = inject(DashboardStatisticsService);
|
||||||
private readonly destroyRef = inject(DestroyRef);
|
private readonly destroyRef = inject(DestroyRef);
|
||||||
|
protected readonly languageService = inject(LanguageService);
|
||||||
|
|
||||||
words: DisplayWord[] = [];
|
words: DisplayWord[] = [];
|
||||||
selectedWordIds = new Set<string>();
|
selectedWordIds = new Set<string>();
|
||||||
@@ -122,6 +126,18 @@ export class TopicWordCloudDialogComponent {
|
|||||||
return this.selectedWords().map((word) => word.name);
|
return this.selectedWords().map((word) => word.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
termCountLabel(): string {
|
||||||
|
return this.languageService.translate('wordcloud.termCount', {
|
||||||
|
count: this.words.length,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
removeWordLabel(name: string): string {
|
||||||
|
return this.languageService.translate('wordcloud.removeFromSelection', {
|
||||||
|
name,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
clearSelection(): void {
|
clearSelection(): void {
|
||||||
this.selectedWordIds = new Set<string>();
|
this.selectedWordIds = new Set<string>();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
<mat-icon class="error-icon">warning</mat-icon>
|
<mat-icon class="error-icon">warning</mat-icon>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<span class="status-code">Fehler {{ statusCode() }}</span>
|
<span class="status-code">{{ 'errorPage.error' | translate }} {{ statusCode() }}</span>
|
||||||
<h1 class="error-title">{{ title() }}</h1>
|
<h1 class="error-title">{{ localizedTitle() }}</h1>
|
||||||
<p class="error-message">{{ message() }}</p>
|
<p class="error-message">{{ localizedMessage() }}</p>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
class="back-button"
|
class="back-button"
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
color="primary"
|
color="primary"
|
||||||
(click)="goBack()">
|
(click)="goBack()">
|
||||||
<mat-icon>arrow_back</mat-icon>
|
<mat-icon>arrow_back</mat-icon>
|
||||||
Zurück
|
{{ 'common.back' | translate }}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
@if (errorDetails()) {
|
@if (errorDetails()) {
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
appearance="outlined">
|
appearance="outlined">
|
||||||
<mat-expansion-panel-header>
|
<mat-expansion-panel-header>
|
||||||
<mat-panel-title class="diagnostics-title">
|
<mat-panel-title class="diagnostics-title">
|
||||||
ERWEITERTE DIAGNOSE
|
{{ 'errorPage.diagnostics' | translate }}
|
||||||
</mat-panel-title>
|
</mat-panel-title>
|
||||||
</mat-expansion-panel-header>
|
</mat-expansion-panel-header>
|
||||||
|
|
||||||
|
|||||||
@@ -4,20 +4,20 @@ import { MatCardModule } from '@angular/material/card';
|
|||||||
import { MatExpansionModule } from '@angular/material/expansion';
|
import { MatExpansionModule } from '@angular/material/expansion';
|
||||||
import { MatIconModule } from '@angular/material/icon';
|
import { MatIconModule } from '@angular/material/icon';
|
||||||
import { ErrorService } from '../../shared/services/error.service';
|
import { ErrorService } from '../../shared/services/error.service';
|
||||||
|
import { TranslatePipe } from '../../shared/i18n/translate.pipe';
|
||||||
|
import { LanguageService } from '../../shared/i18n/language.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-error-page',
|
selector: 'app-error-page',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [MatButtonModule, MatCardModule, MatIconModule, MatExpansionModule],
|
imports: [MatButtonModule, MatCardModule, MatIconModule, MatExpansionModule, TranslatePipe],
|
||||||
templateUrl: './error-page.component.html',
|
templateUrl: './error-page.component.html',
|
||||||
styleUrl: './error-page.component.scss',
|
styleUrl: './error-page.component.scss',
|
||||||
})
|
})
|
||||||
export class ErrorPageComponent implements OnInit {
|
export class ErrorPageComponent implements OnInit {
|
||||||
routeStatusCode = input<number>(500);
|
routeStatusCode = input<number>(500);
|
||||||
routeTitle = input<string>('Da ist was schiefgelaufen');
|
routeTitle = input<string | undefined>(undefined);
|
||||||
routeMessage = input<string>(
|
routeMessage = input<string | undefined>(undefined);
|
||||||
'Ein unerwarteter Fehler ist aufgetreten. Bitte versuchen Sie es später erneut.',
|
|
||||||
);
|
|
||||||
routeErrorDetails = input<string | undefined>(undefined);
|
routeErrorDetails = input<string | undefined>(undefined);
|
||||||
|
|
||||||
statusCode = signal<number>(500);
|
statusCode = signal<number>(500);
|
||||||
@@ -28,6 +28,27 @@ export class ErrorPageComponent implements OnInit {
|
|||||||
isDetailsOpen = signal<boolean>(false);
|
isDetailsOpen = signal<boolean>(false);
|
||||||
|
|
||||||
private readonly errorService = inject(ErrorService);
|
private readonly errorService = inject(ErrorService);
|
||||||
|
private readonly languageService = inject(LanguageService);
|
||||||
|
|
||||||
|
localizedTitle(): string {
|
||||||
|
if (this.statusCode() === 404) {
|
||||||
|
return this.languageService.translate('errorPage.notFound');
|
||||||
|
}
|
||||||
|
if (!this.title()) {
|
||||||
|
return this.languageService.translate('errorPage.title');
|
||||||
|
}
|
||||||
|
return this.title();
|
||||||
|
}
|
||||||
|
|
||||||
|
localizedMessage(): string {
|
||||||
|
if (this.statusCode() === 404) {
|
||||||
|
return this.languageService.translate('errorPage.notFoundMessage');
|
||||||
|
}
|
||||||
|
if (!this.message()) {
|
||||||
|
return this.languageService.translate('errorPage.message');
|
||||||
|
}
|
||||||
|
return this.message();
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
const savedError = this.errorService.getError();
|
const savedError = this.errorService.getError();
|
||||||
@@ -37,11 +58,11 @@ export class ErrorPageComponent implements OnInit {
|
|||||||
this.title.set(savedError.title);
|
this.title.set(savedError.title);
|
||||||
this.message.set(savedError.message);
|
this.message.set(savedError.message);
|
||||||
this.errorDetails.set(savedError.errorDetails);
|
this.errorDetails.set(savedError.errorDetails);
|
||||||
this.errorService.clearError(); // Speicher aufräumen
|
this.errorService.clearError();
|
||||||
} else {
|
} else {
|
||||||
this.statusCode.set(this.routeStatusCode());
|
this.statusCode.set(this.routeStatusCode());
|
||||||
this.title.set(this.routeTitle());
|
this.title.set(this.routeTitle() ?? '');
|
||||||
this.message.set(this.routeMessage());
|
this.message.set(this.routeMessage() ?? '');
|
||||||
this.errorDetails.set(this.routeErrorDetails());
|
this.errorDetails.set(this.routeErrorDetails());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
<section class="login-page">
|
<section class="login-page">
|
||||||
<div class="login-panel">
|
<div class="login-panel">
|
||||||
<div class="brand-block">
|
<div class="brand-block">
|
||||||
<span class="eyebrow">SmartGuide Account Portal</span>
|
<span class="eyebrow">{{ 'login.portal' | translate }}</span>
|
||||||
<h1>Passwort vergessen</h1>
|
<h1>{{ 'forgotPassword.title' | translate }}</h1>
|
||||||
<p>
|
<p>
|
||||||
Gib Deine E-Mail-Adresse ein. Wenn ein Konto existiert, senden wir Dir
|
{{ 'forgotPassword.description' | translate }}
|
||||||
einen Link zum Zurücksetzen des Passworts.
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -17,17 +16,14 @@
|
|||||||
</mat-icon>
|
</mat-icon>
|
||||||
<div>
|
<div>
|
||||||
@if (rateLimited()) {
|
@if (rateLimited()) {
|
||||||
<strong>Zu viele Anfragen</strong>
|
<strong>{{ 'forgotPassword.tooMany' | translate }}</strong>
|
||||||
<span>
|
<span>
|
||||||
Es wurden bereits mehrere Links angefordert. Bitte prüfe Dein
|
{{ 'forgotPassword.rateLimitPrefix' | translate }} {{ retryAfterText() }} {{ 'forgotPassword.retrySuffix' | translate }}
|
||||||
Postfach oder versuche es in {{ retryAfterText() }} erneut.
|
|
||||||
</span>
|
</span>
|
||||||
} @else {
|
} @else {
|
||||||
<strong>E-Mail wurde versendet</strong>
|
<strong>{{ 'forgotPassword.emailSent' | translate }}</strong>
|
||||||
<span>
|
<span>
|
||||||
Falls ein Konto mit dieser E-Mail-Adresse existiert, wurde ein
|
{{ 'forgotPassword.emailSentMessage' | translate }}
|
||||||
Link zum Zurücksetzen des Passworts versendet. Bitte prüfe Dein
|
|
||||||
Postfach.
|
|
||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
@@ -37,20 +33,20 @@
|
|||||||
<div class="code-intro">
|
<div class="code-intro">
|
||||||
<mat-icon>error_outline</mat-icon>
|
<mat-icon>error_outline</mat-icon>
|
||||||
<div>
|
<div>
|
||||||
<strong>Fehler</strong>
|
<strong>{{ 'errorPage.error' | translate }}</strong>
|
||||||
<span>{{ errorMessage() }}</span>
|
<span>{{ errorMessage() }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<a class="auth-link" routerLink="/login">Zurück zum Login</a>
|
<a class="auth-link" routerLink="/login">{{ 'forgotPassword.backLogin' | translate }}</a>
|
||||||
|
|
||||||
<a
|
<a
|
||||||
class="auth-link"
|
class="auth-link"
|
||||||
href="#"
|
href="#"
|
||||||
(click)="$event.preventDefault(); requestPasswordResetAgain()">
|
(click)="$event.preventDefault(); requestPasswordResetAgain()">
|
||||||
E-Mail nicht bekommen?
|
{{ 'forgotPassword.notReceived' | translate }}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -60,16 +56,16 @@
|
|||||||
[formGroup]="form"
|
[formGroup]="form"
|
||||||
(ngSubmit)="requestPasswordReset()">
|
(ngSubmit)="requestPasswordReset()">
|
||||||
<mat-form-field class="field" appearance="outline">
|
<mat-form-field class="field" appearance="outline">
|
||||||
<mat-label>E-Mail-Adresse</mat-label>
|
<mat-label>{{ 'login.email' | translate }}</mat-label>
|
||||||
<input
|
<input
|
||||||
matInput
|
matInput
|
||||||
type="email"
|
type="email"
|
||||||
autocomplete="email"
|
autocomplete="email"
|
||||||
formControlName="email" />
|
formControlName="email" />
|
||||||
@if (form.controls.email.hasError('required')) {
|
@if (form.controls.email.hasError('required')) {
|
||||||
<mat-error>E-Mail-Adresse ist erforderlich.</mat-error>
|
<mat-error>{{ 'login.emailRequired' | translate }}</mat-error>
|
||||||
} @else if (form.controls.email.hasError('email')) {
|
} @else if (form.controls.email.hasError('email')) {
|
||||||
<mat-error>Bitte gib eine gültige E-Mail-Adresse ein.</mat-error>
|
<mat-error>{{ 'login.emailInvalid' | translate }}</mat-error>
|
||||||
}
|
}
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
@@ -77,7 +73,7 @@
|
|||||||
<div class="code-intro">
|
<div class="code-intro">
|
||||||
<mat-icon>error_outline</mat-icon>
|
<mat-icon>error_outline</mat-icon>
|
||||||
<div>
|
<div>
|
||||||
<strong>Fehler</strong>
|
<strong>{{ 'errorPage.error' | translate }}</strong>
|
||||||
<span>{{ errorMessage() }}</span>
|
<span>{{ errorMessage() }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -90,14 +86,14 @@
|
|||||||
type="submit"
|
type="submit"
|
||||||
[disabled]="form.invalid || isSubmitting()">
|
[disabled]="form.invalid || isSubmitting()">
|
||||||
@if (isSubmitting()) {
|
@if (isSubmitting()) {
|
||||||
Link wird gesendet...
|
{{ 'forgotPassword.sending' | translate }}
|
||||||
} @else {
|
} @else {
|
||||||
Link zum Zurücksetzen senden
|
{{ 'forgotPassword.send' | translate }}
|
||||||
}
|
}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<a class="auth-link" routerLink="/login">Zurück zum Login</a>
|
<a class="auth-link" routerLink="/login">{{ 'forgotPassword.backLogin' | translate }}</a>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ import { MatInputModule } from '@angular/material/input';
|
|||||||
import { MatIconModule } from '@angular/material/icon';
|
import { MatIconModule } from '@angular/material/icon';
|
||||||
import { CredentialService } from '../../shared/services/credential.service';
|
import { CredentialService } from '../../shared/services/credential.service';
|
||||||
import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar';
|
import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar';
|
||||||
|
import { TranslatePipe } from '../../shared/i18n/translate.pipe';
|
||||||
|
import { LanguageService } from '../../shared/i18n/language.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-forgot-password',
|
selector: 'app-forgot-password',
|
||||||
@@ -24,6 +26,7 @@ import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar';
|
|||||||
MatButtonModule,
|
MatButtonModule,
|
||||||
MatIconModule,
|
MatIconModule,
|
||||||
MatSnackBarModule,
|
MatSnackBarModule,
|
||||||
|
TranslatePipe,
|
||||||
],
|
],
|
||||||
templateUrl: './forgot-password.component.html',
|
templateUrl: './forgot-password.component.html',
|
||||||
styleUrl: '../app-login/app-login.component.scss',
|
styleUrl: '../app-login/app-login.component.scss',
|
||||||
@@ -32,6 +35,7 @@ import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar';
|
|||||||
export class ForgotPasswordComponent {
|
export class ForgotPasswordComponent {
|
||||||
private readonly credentialService = inject(CredentialService);
|
private readonly credentialService = inject(CredentialService);
|
||||||
private readonly snackBar = inject(MatSnackBar);
|
private readonly snackBar = inject(MatSnackBar);
|
||||||
|
private readonly languageService = inject(LanguageService);
|
||||||
|
|
||||||
form = new FormGroup({
|
form = new FormGroup({
|
||||||
email: new FormControl<string>('', [Validators.required, Validators.email]),
|
email: new FormControl<string>('', [Validators.required, Validators.email]),
|
||||||
@@ -68,11 +72,14 @@ export class ForgotPasswordComponent {
|
|||||||
const seconds = this.retryAfterSeconds();
|
const seconds = this.retryAfterSeconds();
|
||||||
|
|
||||||
if (!seconds) {
|
if (!seconds) {
|
||||||
return 'einigen Minuten';
|
return this.languageService.translate('forgotPassword.someMinutes');
|
||||||
}
|
}
|
||||||
|
|
||||||
const minutes = Math.max(1, Math.ceil(seconds / 60));
|
const minutes = Math.max(1, Math.ceil(seconds / 60));
|
||||||
return `${minutes} ${minutes === 1 ? 'Minute' : 'Minuten'}`;
|
return this.languageService.translate(
|
||||||
|
minutes === 1 ? 'forgotPassword.minute' : 'forgotPassword.minutes',
|
||||||
|
{ count: minutes },
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private sendPasswordResetRequest(email: string): void {
|
private sendPasswordResetRequest(email: string): void {
|
||||||
@@ -102,7 +109,7 @@ export class ForgotPasswordComponent {
|
|||||||
|
|
||||||
if (response.rate_limited) {
|
if (response.rate_limited) {
|
||||||
this.snackBar.open(
|
this.snackBar.open(
|
||||||
`Es wurden bereits mehrere Links angefordert. Bitte versuche es in ${this.retryAfterText()} erneut.`,
|
this.languageService.translate('forgotPassword.rateLimitMessage', { time: this.retryAfterText() }),
|
||||||
'OK',
|
'OK',
|
||||||
{ duration: 7000 },
|
{ duration: 7000 },
|
||||||
);
|
);
|
||||||
@@ -111,7 +118,7 @@ export class ForgotPasswordComponent {
|
|||||||
|
|
||||||
if (wasAlreadySent) {
|
if (wasAlreadySent) {
|
||||||
this.snackBar.open(
|
this.snackBar.open(
|
||||||
'Wir haben Dir einen neuen Link zum Zurücksetzen des Passworts gesendet.',
|
this.languageService.translate('forgotPassword.newLinkSent'),
|
||||||
'OK',
|
'OK',
|
||||||
{ duration: 5000 },
|
{ duration: 5000 },
|
||||||
);
|
);
|
||||||
@@ -119,7 +126,7 @@ export class ForgotPasswordComponent {
|
|||||||
},
|
},
|
||||||
error: () => {
|
error: () => {
|
||||||
this.errorMessage.set(
|
this.errorMessage.set(
|
||||||
'Der Link zum Zurücksetzen des Passworts konnte nicht angefordert werden. Bitte versuche es später erneut.',
|
this.languageService.translate('forgotPassword.requestError'),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!wasAlreadySent) {
|
if (!wasAlreadySent) {
|
||||||
@@ -127,7 +134,7 @@ export class ForgotPasswordComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.snackBar.open(
|
this.snackBar.open(
|
||||||
'Die Anfrage konnte nicht gesendet werden. Bitte versuche es später erneut.',
|
this.languageService.translate('forgotPassword.sendError'),
|
||||||
'OK',
|
'OK',
|
||||||
{ duration: 7000 },
|
{ duration: 7000 },
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
<p>{{ 'institutionOverview.placeholder' | translate }}</p>
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { InstitutionOverviewComponent } from './institution-overview.component';
|
||||||
|
|
||||||
|
describe('InstitutionOverviewComponent', () => {
|
||||||
|
let component: InstitutionOverviewComponent;
|
||||||
|
let fixture: ComponentFixture<InstitutionOverviewComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
imports: [InstitutionOverviewComponent],
|
||||||
|
}).compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(InstitutionOverviewComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import { Component } from '@angular/core';
|
||||||
|
import { TranslatePipe } from '../../shared/i18n/translate.pipe';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-institution-overview',
|
||||||
|
imports: [TranslatePipe],
|
||||||
|
templateUrl: './institution-overview.component.html',
|
||||||
|
styleUrl: './institution-overview.component.scss',
|
||||||
|
})
|
||||||
|
export class InstitutionOverviewComponent {}
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
@if (loading) {
|
@if (loading) {
|
||||||
<app-loading
|
<app-loading
|
||||||
text="Patentdaten werden geladen..."
|
[text]="'personPatents.loading' | translate"
|
||||||
icon="workspace_premium"
|
icon="workspace_premium"
|
||||||
[size]="150"
|
[size]="150"
|
||||||
[diameter]="150" />
|
[diameter]="150" />
|
||||||
} @else if (error) {
|
} @else if (error) {
|
||||||
<p class="message">Fehler beim Laden der Patente.</p>
|
<p class="message">{{ 'personPatents.loadError' | translate }}</p>
|
||||||
} @else if (patents.length === 0) {
|
} @else if (patents.length === 0) {
|
||||||
<p class="message">
|
<p class="message">
|
||||||
Keine Patente in org_patents für diese Institution gefunden.
|
{{ 'institutionPatents.empty' | translate }}
|
||||||
</p>
|
</p>
|
||||||
<p class="message message-hint">
|
<p class="message message-hint">
|
||||||
Der Index muss zuerst befüllt werden:
|
{{ 'institutionPatents.indexHint' | translate }}
|
||||||
<code
|
<code
|
||||||
>python service/scripts/index_org_patents.py --institution-id
|
>python service/scripts/index_org_patents.py --institution-id
|
||||||
{{ institutionId }}</code
|
{{ institutionId }}</code
|
||||||
@@ -30,10 +30,10 @@
|
|||||||
[value]="activeMatchType"
|
[value]="activeMatchType"
|
||||||
(selectionChange)="setMatchType($event.value)">
|
(selectionChange)="setMatchType($event.value)">
|
||||||
<mat-select-trigger>Matching</mat-select-trigger>
|
<mat-select-trigger>Matching</mat-select-trigger>
|
||||||
<mat-option value="all">Alle</mat-option>
|
<mat-option value="all">{{ 'common.all' | translate }}</mat-option>
|
||||||
<mat-option value="institution">Institution</mat-option>
|
<mat-option value="institution">{{ 'publications.institution' | translate }}</mat-option>
|
||||||
<mat-option value="name">Name</mat-option>
|
<mat-option value="name">{{ 'jobs.name' | translate }}</mat-option>
|
||||||
<mat-option value="both">Beides</mat-option>
|
<mat-option value="both">{{ 'institutionPatents.both' | translate }}</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<mat-form-field
|
<mat-form-field
|
||||||
@@ -43,8 +43,8 @@
|
|||||||
<mat-select
|
<mat-select
|
||||||
[value]="activeFilter"
|
[value]="activeFilter"
|
||||||
(selectionChange)="setFilter($event.value)">
|
(selectionChange)="setFilter($event.value)">
|
||||||
<mat-select-trigger>Filter nach Quelle</mat-select-trigger>
|
<mat-select-trigger>{{ 'personPatents.filterSource' | translate }}</mat-select-trigger>
|
||||||
<mat-option value="all">Alle</mat-option>
|
<mat-option value="all">{{ 'common.all' | translate }}</mat-option>
|
||||||
<mat-option value="EPO">EPO</mat-option>
|
<mat-option value="EPO">EPO</mat-option>
|
||||||
<mat-option value="USPTO">USPTO</mat-option>
|
<mat-option value="USPTO">USPTO</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
@@ -56,9 +56,9 @@
|
|||||||
<mat-select
|
<mat-select
|
||||||
[value]="sortMode"
|
[value]="sortMode"
|
||||||
(selectionChange)="setSortMode($event.value)">
|
(selectionChange)="setSortMode($event.value)">
|
||||||
<mat-select-trigger>Sortieren nach</mat-select-trigger>
|
<mat-select-trigger>{{ 'personPatents.sortBy' | translate }}</mat-select-trigger>
|
||||||
<mat-option value="date">Datum</mat-option>
|
<mat-option value="date">{{ 'publicationDetail.date' | translate }}</mat-option>
|
||||||
<mat-option value="title">Titel</mat-option>
|
<mat-option value="title">{{ 'projects.columnTitle' | translate }}</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
@@ -66,13 +66,13 @@
|
|||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Patent</th>
|
<th>{{ 'personPatents.patent' | translate }}</th>
|
||||||
<th>Quelle</th>
|
<th>{{ 'patents.source' | translate }}</th>
|
||||||
<th>Jahr</th>
|
<th>{{ 'publications.year' | translate }}</th>
|
||||||
<th>Erfinder</th>
|
<th>{{ 'patents.inventors' | translate }}</th>
|
||||||
<th>Applicant/Assignee</th>
|
<th>{{ 'institutionPatents.applicantAssignee' | translate }}</th>
|
||||||
<th>Match-Typ</th>
|
<th>{{ 'institutionPatents.matchType' | translate }}</th>
|
||||||
<th>Personen</th>
|
<th>{{ 'nav.people' | translate }}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -103,29 +103,24 @@
|
|||||||
{{ getMatchTypeLabel(patent) }}
|
{{ getMatchTypeLabel(patent) }}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td class="cell-authors">
|
||||||
<div class="cell-authors">
|
@if (
|
||||||
@if (
|
patent.matched_authors && patent.matched_authors.length
|
||||||
patent.matched_authors && patent.matched_authors.length
|
) {
|
||||||
|
@for (
|
||||||
|
author of patent.matched_authors.slice(0, 2);
|
||||||
|
track author.openalex_author_id
|
||||||
) {
|
) {
|
||||||
@for (
|
<a
|
||||||
author of patent.matched_authors.slice(0, 2);
|
class="author-link"
|
||||||
track author.openalex_author_id
|
[routerLink]="['/person', author.openalex_author_id]"
|
||||||
) {
|
(click)="$event.stopPropagation()">
|
||||||
<a
|
{{ author.author_name }}
|
||||||
class="author-link"
|
</a>
|
||||||
[routerLink]="[
|
|
||||||
'/person',
|
|
||||||
author.openalex_author_id,
|
|
||||||
]"
|
|
||||||
(click)="$event.stopPropagation()">
|
|
||||||
{{ author.author_name }}
|
|
||||||
</a>
|
|
||||||
}
|
|
||||||
} @else {
|
|
||||||
<span>-</span>
|
|
||||||
}
|
}
|
||||||
</div>
|
} @else {
|
||||||
|
<span>-</span>
|
||||||
|
}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
@@ -145,7 +140,7 @@
|
|||||||
<h3>{{ selectedPatent.title ?? selectedPatent.patent_id }}</h3>
|
<h3>{{ selectedPatent.title ?? selectedPatent.patent_id }}</h3>
|
||||||
<div class="detail-stats">
|
<div class="detail-stats">
|
||||||
<div class="stat">
|
<div class="stat">
|
||||||
<span class="stat-label">Quelle</span>
|
<span class="stat-label">{{ 'patents.source' | translate }}</span>
|
||||||
<span class="stat-value">
|
<span class="stat-value">
|
||||||
<span
|
<span
|
||||||
class="source-badge source-badge--{{
|
class="source-badge source-badge--{{
|
||||||
@@ -156,11 +151,11 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="stat">
|
<div class="stat">
|
||||||
<span class="stat-label">Patent-Nr.</span>
|
<span class="stat-label">{{ 'patents.number' | translate }}</span>
|
||||||
<span class="stat-value">{{ selectedPatent.patent_id }}</span>
|
<span class="stat-value">{{ selectedPatent.patent_id }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="stat">
|
<div class="stat">
|
||||||
<span class="stat-label">Datum</span>
|
<span class="stat-label">{{ 'publicationDetail.date' | translate }}</span>
|
||||||
@if (selectedPatent.publication_date) {
|
@if (selectedPatent.publication_date) {
|
||||||
<span class="stat-value">{{
|
<span class="stat-value">{{
|
||||||
formatDate(selectedPatent.publication_date)
|
formatDate(selectedPatent.publication_date)
|
||||||
@@ -168,7 +163,7 @@
|
|||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<div class="stat">
|
<div class="stat">
|
||||||
<span class="stat-label">Match-Typ</span>
|
<span class="stat-label">{{ 'institutionPatents.matchType' | translate }}</span>
|
||||||
<span class="stat-value">
|
<span class="stat-value">
|
||||||
<span
|
<span
|
||||||
class="match-badge match-badge--{{
|
class="match-badge match-badge--{{
|
||||||
@@ -180,7 +175,7 @@
|
|||||||
</div>
|
</div>
|
||||||
@if (getPublicationStageLabel(selectedPatent); as stageLabel) {
|
@if (getPublicationStageLabel(selectedPatent); as stageLabel) {
|
||||||
<div class="stat">
|
<div class="stat">
|
||||||
<span class="stat-label">Publikationsstufe</span>
|
<span class="stat-label">{{ 'patents.publicationStage' | translate }}</span>
|
||||||
<span class="stat-value">{{ stageLabel }}</span>
|
<span class="stat-value">{{ stageLabel }}</span>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@@ -188,7 +183,7 @@
|
|||||||
|
|
||||||
@if (selectedPatent.matched_authors?.length) {
|
@if (selectedPatent.matched_authors?.length) {
|
||||||
<div class="detail-section">
|
<div class="detail-section">
|
||||||
<h4>Verknüpfte Personen</h4>
|
<h4>{{ 'institutionPatents.linkedPeople' | translate }}</h4>
|
||||||
<ul class="tag-list tag-list--compact">
|
<ul class="tag-list tag-list--compact">
|
||||||
@for (
|
@for (
|
||||||
author of selectedPatent.matched_authors;
|
author of selectedPatent.matched_authors;
|
||||||
@@ -218,46 +213,46 @@
|
|||||||
class="patent-detail-action"
|
class="patent-detail-action"
|
||||||
(click)="openDetail()">
|
(click)="openDetail()">
|
||||||
<span class="patent-detail-action__label"
|
<span class="patent-detail-action__label"
|
||||||
>Patentdetails anzeigen</span
|
>{{ 'personPatents.showDetails' | translate }}</span
|
||||||
>
|
>
|
||||||
<mat-icon aria-hidden="true">chevron_right</mat-icon>
|
<mat-icon aria-hidden="true">chevron_right</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
<p class="patent-detail-hint">
|
<p class="patent-detail-hint">
|
||||||
Abstract, Erfinder, Anmelder und IPC/CPC-Klassifikation
|
{{ 'personPatents.detailHint' | translate }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
} @else {
|
} @else {
|
||||||
<div class="patent-detail overview">
|
<div class="patent-detail overview">
|
||||||
<p class="overview-title">Patentübersicht</p>
|
<p class="overview-title">{{ 'personPatents.overview' | translate }}</p>
|
||||||
<p class="overview-subtitle">
|
<p class="overview-subtitle">
|
||||||
@if (institutionName) {
|
@if (institutionName) {
|
||||||
Alle Patente von {{ institutionName }} im Überblick.
|
{{ 'institutionPatents.allBy' | translate }} {{ institutionName }}.
|
||||||
} @else {
|
} @else {
|
||||||
Alle Patente dieser Institution im Überblick.
|
{{ 'institutionPatents.allInstitution' | translate }}
|
||||||
}
|
}
|
||||||
</p>
|
</p>
|
||||||
<div class="overview-stats">
|
<div class="overview-stats">
|
||||||
<div class="overview-stat overview-stat--total">
|
<div class="overview-stat overview-stat--total">
|
||||||
<span class="overview-value">{{ totalPatents }}</span>
|
<span class="overview-value">{{ totalPatents }}</span>
|
||||||
<span class="overview-label">Patente</span>
|
<span class="overview-label">{{ 'patents.title' | translate }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="overview-stat overview-stat--institution">
|
<div class="overview-stat overview-stat--institution">
|
||||||
<span class="overview-value">{{
|
<span class="overview-value">{{
|
||||||
getInstitutionMatchCount()
|
getInstitutionMatchCount()
|
||||||
}}</span>
|
}}</span>
|
||||||
<span class="overview-label">Institution</span>
|
<span class="overview-label">{{ 'publications.institution' | translate }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="overview-stat overview-stat--name">
|
<div class="overview-stat overview-stat--name">
|
||||||
<span class="overview-value">{{ getNameMatchCount() }}</span>
|
<span class="overview-value">{{ getNameMatchCount() }}</span>
|
||||||
<span class="overview-label">Name</span>
|
<span class="overview-label">{{ 'jobs.name' | translate }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="overview-stat overview-stat--both">
|
<div class="overview-stat overview-stat--both">
|
||||||
<span class="overview-value">{{ getBothMatchCount() }}</span>
|
<span class="overview-value">{{ getBothMatchCount() }}</span>
|
||||||
<span class="overview-label">Beides</span>
|
<span class="overview-label">{{ 'institutionPatents.both' | translate }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p class="overview-hint">
|
<p class="overview-hint">
|
||||||
Wähle links ein Patent aus, um Kurzinfos und Details zu sehen.
|
{{ 'institutionPatents.selectHint' | translate }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,14 +60,21 @@ app-query-param-paginator {
|
|||||||
|
|
||||||
table {
|
table {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border-collapse: collapse;
|
border-collapse: separate;
|
||||||
|
border-spacing: 0;
|
||||||
|
border: 1px solid var(--sg-border);
|
||||||
|
border-radius: var(--sg-radius-sm);
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
th {
|
th {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
padding: 12px 16px;
|
padding: 12px 16px;
|
||||||
|
background: var(--sg-surface-muted);
|
||||||
border-bottom: 1px solid var(--sg-border);
|
border-bottom: 1px solid var(--sg-border);
|
||||||
font-size: 13px;
|
font-size: 12px;
|
||||||
font-weight: 600;
|
font-weight: 700;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.02em;
|
||||||
color: var(--sg-text-muted);
|
color: var(--sg-text-muted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,6 +90,10 @@ app-query-param-paginator {
|
|||||||
&.selected td {
|
&.selected td {
|
||||||
background: var(--sg-primary-soft);
|
background: var(--sg-primary-soft);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&:last-child td {
|
||||||
|
border-bottom: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
td {
|
td {
|
||||||
@@ -96,9 +107,10 @@ app-query-param-paginator {
|
|||||||
.patent-title {
|
.patent-title {
|
||||||
color: var(--sg-text);
|
color: var(--sg-text);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
max-width: 320px;
|
max-width: 280px;
|
||||||
white-space: normal;
|
white-space: nowrap;
|
||||||
word-break: break-word;
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cell-preview {
|
.cell-preview {
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ import {
|
|||||||
import { LoadingComponent } from '../../shared/ui/loading/loading.component';
|
import { LoadingComponent } from '../../shared/ui/loading/loading.component';
|
||||||
import { PageEvent } from '@angular/material/paginator';
|
import { PageEvent } from '@angular/material/paginator';
|
||||||
import { QueryParamPaginatorComponent } from '../../shared/ui/query-param-paginator/query-param-paginator.component';
|
import { QueryParamPaginatorComponent } from '../../shared/ui/query-param-paginator/query-param-paginator.component';
|
||||||
|
import { TranslatePipe } from '../../shared/i18n/translate.pipe';
|
||||||
|
import { LanguageService } from '../../shared/i18n/language.service';
|
||||||
|
|
||||||
type SortMode = 'date' | 'title';
|
type SortMode = 'date' | 'title';
|
||||||
type SourceFilter = 'all' | 'EPO' | 'USPTO';
|
type SourceFilter = 'all' | 'EPO' | 'USPTO';
|
||||||
@@ -28,6 +30,7 @@ type OrgPatentMatchTypeFilter = 'all' | 'institution' | 'name' | 'both';
|
|||||||
MatSelectModule,
|
MatSelectModule,
|
||||||
MatIconModule,
|
MatIconModule,
|
||||||
QueryParamPaginatorComponent,
|
QueryParamPaginatorComponent,
|
||||||
|
TranslatePipe,
|
||||||
],
|
],
|
||||||
templateUrl: './institution-patents.component.html',
|
templateUrl: './institution-patents.component.html',
|
||||||
styleUrl: './institution-patents.component.scss',
|
styleUrl: './institution-patents.component.scss',
|
||||||
@@ -36,6 +39,7 @@ export class InstitutionPatentsComponent implements OnInit {
|
|||||||
private route = inject(ActivatedRoute);
|
private route = inject(ActivatedRoute);
|
||||||
private router = inject(Router);
|
private router = inject(Router);
|
||||||
private patentsApi = inject(PatentsService);
|
private patentsApi = inject(PatentsService);
|
||||||
|
private languageService = inject(LanguageService);
|
||||||
|
|
||||||
patents: OrgPatentEntry[] = [];
|
patents: OrgPatentEntry[] = [];
|
||||||
filteredPatents: OrgPatentEntry[] = [];
|
filteredPatents: OrgPatentEntry[] = [];
|
||||||
@@ -170,7 +174,7 @@ export class InstitutionPatentsComponent implements OnInit {
|
|||||||
private sortPatents(patents: OrgPatentEntry[]): OrgPatentEntry[] {
|
private sortPatents(patents: OrgPatentEntry[]): OrgPatentEntry[] {
|
||||||
if (this.sortMode === 'title') {
|
if (this.sortMode === 'title') {
|
||||||
return [...patents].sort((a, b) =>
|
return [...patents].sort((a, b) =>
|
||||||
(a.title ?? '').localeCompare(b.title ?? '', 'de', {
|
(a.title ?? '').localeCompare(b.title ?? '', this.languageService.language(), {
|
||||||
sensitivity: 'base',
|
sensitivity: 'base',
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
@@ -223,7 +227,7 @@ export class InstitutionPatentsComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
formatDate(date: string | null | undefined): string {
|
formatDate(date: string | null | undefined): string {
|
||||||
return formatPatentDate(date);
|
return formatPatentDate(date, this.languageService.language() === 'de' ? 'de-DE' : 'en-US');
|
||||||
}
|
}
|
||||||
|
|
||||||
getEpoCount(): number {
|
getEpoCount(): number {
|
||||||
@@ -277,11 +281,11 @@ export class InstitutionPatentsComponent implements OnInit {
|
|||||||
getMatchTypeLabel(patent: OrgPatentEntry): string {
|
getMatchTypeLabel(patent: OrgPatentEntry): string {
|
||||||
switch (patent.match_type) {
|
switch (patent.match_type) {
|
||||||
case 'institution':
|
case 'institution':
|
||||||
return 'Institution';
|
return this.languageService.translate('publications.institution');
|
||||||
case 'name':
|
case 'name':
|
||||||
return 'Name';
|
return this.languageService.translate('jobs.name');
|
||||||
case 'both':
|
case 'both':
|
||||||
return 'Beides';
|
return this.languageService.translate('institutionPatents.both');
|
||||||
default:
|
default:
|
||||||
return patent.match_type;
|
return patent.match_type;
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-4
@@ -1,4 +1,4 @@
|
|||||||
import { Component, effect, input } from '@angular/core';
|
import { Component, effect, inject, input } from '@angular/core';
|
||||||
|
|
||||||
import * as echarts from 'echarts/core';
|
import * as echarts from 'echarts/core';
|
||||||
import { EChartsOption } from 'echarts';
|
import { EChartsOption } from 'echarts';
|
||||||
@@ -7,6 +7,7 @@ import { GridComponent, LegendComponent } from 'echarts/components';
|
|||||||
import { CanvasRenderer } from 'echarts/renderers';
|
import { CanvasRenderer } from 'echarts/renderers';
|
||||||
import { NgxEchartsDirective } from 'ngx-echarts';
|
import { NgxEchartsDirective } from 'ngx-echarts';
|
||||||
import { InstitutionFunderSummary } from '../../api';
|
import { InstitutionFunderSummary } from '../../api';
|
||||||
|
import { LanguageService } from '../../shared/i18n/language.service';
|
||||||
|
|
||||||
echarts.use([GridComponent, CanvasRenderer, LegendComponent]);
|
echarts.use([GridComponent, CanvasRenderer, LegendComponent]);
|
||||||
|
|
||||||
@@ -22,6 +23,7 @@ type FunderData = {
|
|||||||
styleUrl: './institution-projects-funding-graph.component.scss',
|
styleUrl: './institution-projects-funding-graph.component.scss',
|
||||||
})
|
})
|
||||||
export class InstitutionProjectsFundingGraphComponent {
|
export class InstitutionProjectsFundingGraphComponent {
|
||||||
|
private readonly languageService = inject(LanguageService);
|
||||||
options!: EChartsOption;
|
options!: EChartsOption;
|
||||||
|
|
||||||
fundings = input.required<InstitutionFunderSummary[]>();
|
fundings = input.required<InstitutionFunderSummary[]>();
|
||||||
@@ -36,7 +38,7 @@ export class InstitutionProjectsFundingGraphComponent {
|
|||||||
generateChartOptions(fundings: InstitutionFunderSummary[]): void {
|
generateChartOptions(fundings: InstitutionFunderSummary[]): void {
|
||||||
const floorToTwoDecimals = (value: number): string => {
|
const floorToTwoDecimals = (value: number): string => {
|
||||||
const floored = Math.floor(value * 100) / 100;
|
const floored = Math.floor(value * 100) / 100;
|
||||||
return floored.toLocaleString(undefined, {
|
return floored.toLocaleString(this.languageService.language() === 'de' ? 'de-DE' : 'en-US', {
|
||||||
style: 'currency',
|
style: 'currency',
|
||||||
currency: 'EUR',
|
currency: 'EUR',
|
||||||
minimumFractionDigits: 2,
|
minimumFractionDigits: 2,
|
||||||
@@ -83,7 +85,7 @@ export class InstitutionProjectsFundingGraphComponent {
|
|||||||
label: {
|
label: {
|
||||||
show: true,
|
show: true,
|
||||||
position: 'end',
|
position: 'end',
|
||||||
formatter: 'Aktuelles Jahr',
|
formatter: this.languageService.translate('institutionProjects.currentYear'),
|
||||||
backgroundColor: '#333',
|
backgroundColor: '#333',
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
padding: [4, 6],
|
padding: [4, 6],
|
||||||
@@ -139,7 +141,7 @@ export class InstitutionProjectsFundingGraphComponent {
|
|||||||
type: 'value',
|
type: 'value',
|
||||||
axisLabel: {
|
axisLabel: {
|
||||||
formatter: (value: number) =>
|
formatter: (value: number) =>
|
||||||
value.toLocaleString(undefined, {
|
value.toLocaleString(this.languageService.language() === 'de' ? 'de-DE' : 'en-US', {
|
||||||
style: 'currency',
|
style: 'currency',
|
||||||
currency: 'EUR',
|
currency: 'EUR',
|
||||||
maximumFractionDigits: 0,
|
maximumFractionDigits: 0,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<div class="content">
|
<div class="content">
|
||||||
<h3>Projekte</h3>
|
<h3>{{ 'nav.projects' | translate }}</h3>
|
||||||
|
|
||||||
<div class="funding-area">
|
<div class="funding-area">
|
||||||
<div class="person-projects">
|
<div class="person-projects">
|
||||||
@@ -8,16 +8,11 @@
|
|||||||
<a
|
<a
|
||||||
matTabLink
|
matTabLink
|
||||||
[routerLink]="[route.path]"
|
[routerLink]="[route.path]"
|
||||||
[queryParams]="{
|
|
||||||
authorId: null,
|
|
||||||
institutionId: null,
|
|
||||||
agency: null,
|
|
||||||
}"
|
|
||||||
queryParamsHandling="merge"
|
queryParamsHandling="merge"
|
||||||
routerLinkActive
|
routerLinkActive
|
||||||
#rla="routerLinkActive"
|
#rla="routerLinkActive"
|
||||||
[active]="rla.isActive">
|
[active]="rla.isActive">
|
||||||
{{ route.label }}
|
{{ route.labelKey | translate }}
|
||||||
</a>
|
</a>
|
||||||
}
|
}
|
||||||
</nav>
|
</nav>
|
||||||
@@ -28,7 +23,7 @@
|
|||||||
<div class="funding-info-section">
|
<div class="funding-info-section">
|
||||||
<mat-card appearance="outlined">
|
<mat-card appearance="outlined">
|
||||||
<mat-card-header>
|
<mat-card-header>
|
||||||
<mat-card-title>Förderung über Zeit</mat-card-title>
|
<mat-card-title>{{ 'institutionProjects.fundingOverTime' | translate }}</mat-card-title>
|
||||||
</mat-card-header>
|
</mat-card-header>
|
||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
<app-institution-projects-funding-graph
|
<app-institution-projects-funding-graph
|
||||||
@@ -38,28 +33,28 @@
|
|||||||
|
|
||||||
<div class="funding-info-cards">
|
<div class="funding-info-cards">
|
||||||
<app-info-card
|
<app-info-card
|
||||||
[description]="'Gesamte Förderung durch Bund'"
|
[description]="'institutionProjects.totalFederal' | translate"
|
||||||
[value]="
|
[value]="
|
||||||
(bundTotalFunding()
|
(bundTotalFunding()
|
||||||
| currency: 'EUR' : 'symbol' : '1.0-0' : 'de') ?? undefined
|
| currency: 'EUR' : 'symbol' : '1.0-0' : locale()) ?? undefined
|
||||||
" />
|
" />
|
||||||
<app-info-card
|
<app-info-card
|
||||||
[description]="'Durchschnittliche jährliche Förderung durch Bund'"
|
[description]="'institutionProjects.averageFederal' | translate"
|
||||||
[value]="
|
[value]="
|
||||||
(bundAverageAnnualFunding()
|
(bundAverageAnnualFunding()
|
||||||
| currency: 'EUR' : 'symbol' : '1.0-0' : 'de') ?? undefined
|
| currency: 'EUR' : 'symbol' : '1.0-0' : locale()) ?? undefined
|
||||||
" />
|
" />
|
||||||
<app-info-card
|
<app-info-card
|
||||||
[description]="'Gesamte Förderung durch die Europäische Union'"
|
[description]="'institutionProjects.totalEu' | translate"
|
||||||
[value]="
|
[value]="
|
||||||
(euTotalFunding()
|
(euTotalFunding()
|
||||||
| currency: 'EUR' : 'symbol' : '1.0-0' : 'de') ?? undefined
|
| currency: 'EUR' : 'symbol' : '1.0-0' : locale()) ?? undefined
|
||||||
" />
|
" />
|
||||||
<app-info-card
|
<app-info-card
|
||||||
[description]="'Durchschnittliche jährliche Förderung durch die Europäische Union'"
|
[description]="'institutionProjects.averageEu' | translate"
|
||||||
[value]="
|
[value]="
|
||||||
(euAverageAnnualFunding()
|
(euAverageAnnualFunding()
|
||||||
| currency: 'EUR' : 'symbol' : '1.0-0' : 'de') ?? undefined
|
| currency: 'EUR' : 'symbol' : '1.0-0' : locale()) ?? undefined
|
||||||
" />
|
" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -73,7 +68,7 @@
|
|||||||
{{ row.funding_end | date: 'dd.MM.yyyy' }}
|
{{ row.funding_end | date: 'dd.MM.yyyy' }}
|
||||||
</ng-template>
|
</ng-template>
|
||||||
<ng-template #fundingAmountTmp let-row>
|
<ng-template #fundingAmountTmp let-row>
|
||||||
{{ row.funding_amount | currency: 'EUR' : 'symbol' : '1.0-0' : 'de' }}
|
{{ row.funding_amount | currency: 'EUR' : 'symbol' : '1.0-0' : locale() }}
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
|
||||||
<ng-template #euProjectActionsTmp let-row>
|
<ng-template #euProjectActionsTmp let-row>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import {
|
|||||||
OnInit,
|
OnInit,
|
||||||
TemplateRef,
|
TemplateRef,
|
||||||
viewChild,
|
viewChild,
|
||||||
|
inject,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { ActivatedRoute, Router, RouterModule } from '@angular/router';
|
import { ActivatedRoute, Router, RouterModule } from '@angular/router';
|
||||||
import {
|
import {
|
||||||
@@ -27,6 +28,9 @@ import { MatIconModule } from '@angular/material/icon';
|
|||||||
import { MatButtonModule } from '@angular/material/button';
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
import { InstitutionProjectsFundingGraphComponent } from '../institution-projects-funding-graph/institution-projects-funding-graph.component';
|
import { InstitutionProjectsFundingGraphComponent } from '../institution-projects-funding-graph/institution-projects-funding-graph.component';
|
||||||
import { AppInfoCardComponent } from '../../shared/ui/app-info-card/app-info-card.component';
|
import { AppInfoCardComponent } from '../../shared/ui/app-info-card/app-info-card.component';
|
||||||
|
import { TranslatePipe } from '../../shared/i18n/translate.pipe';
|
||||||
|
import { LanguageService } from '../../shared/i18n/language.service';
|
||||||
|
import { TranslationKey } from '../../shared/i18n/translations';
|
||||||
|
|
||||||
type BundProjectRow = {
|
type BundProjectRow = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -60,11 +64,14 @@ type EuProjectRow = {
|
|||||||
InstitutionProjectsFundingGraphComponent,
|
InstitutionProjectsFundingGraphComponent,
|
||||||
AppInfoCardComponent,
|
AppInfoCardComponent,
|
||||||
RouterModule,
|
RouterModule,
|
||||||
|
TranslatePipe,
|
||||||
],
|
],
|
||||||
templateUrl: './institution-projects.component.html',
|
templateUrl: './institution-projects.component.html',
|
||||||
styleUrl: './institution-projects.component.scss',
|
styleUrl: './institution-projects.component.scss',
|
||||||
})
|
})
|
||||||
export class InstitutionProjectsComponent implements OnInit {
|
export class InstitutionProjectsComponent implements OnInit {
|
||||||
|
private readonly languageService = inject(LanguageService);
|
||||||
|
locale = computed(() => this.languageService.language() === 'de' ? 'de-DE' : 'en-US');
|
||||||
fundingStartTmp = viewChild.required<TemplateRef<any>>('fundingStartTmp');
|
fundingStartTmp = viewChild.required<TemplateRef<any>>('fundingStartTmp');
|
||||||
fundingEndTmp = viewChild.required<TemplateRef<any>>('fundingEndTmp');
|
fundingEndTmp = viewChild.required<TemplateRef<any>>('fundingEndTmp');
|
||||||
fundingAmountTmp = viewChild.required<TemplateRef<any>>('fundingAmountTmp');
|
fundingAmountTmp = viewChild.required<TemplateRef<any>>('fundingAmountTmp');
|
||||||
@@ -111,15 +118,15 @@ export class InstitutionProjectsComponent implements OnInit {
|
|||||||
readonly childRoutes = [
|
readonly childRoutes = [
|
||||||
{
|
{
|
||||||
path: 'dfg',
|
path: 'dfg',
|
||||||
label: 'DFG-Projekte',
|
labelKey: 'personProjects.dfg' as TranslationKey,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'eu',
|
path: 'eu',
|
||||||
label: 'EU-Projekte',
|
labelKey: 'personProjects.eu' as TranslationKey,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'bund',
|
path: 'bund',
|
||||||
label: 'BUND-Projekte',
|
labelKey: 'institutionProjects.federalProjects' as TranslationKey,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
constructor(
|
constructor(
|
||||||
@@ -168,28 +175,28 @@ export class InstitutionProjectsComponent implements OnInit {
|
|||||||
this.euProjectColumns = [
|
this.euProjectColumns = [
|
||||||
{
|
{
|
||||||
id: 'title',
|
id: 'title',
|
||||||
header: 'Titel',
|
header: this.languageService.translate('projects.columnTitle'),
|
||||||
type: 'accessor',
|
type: 'accessor',
|
||||||
accessorKey: 'topic',
|
accessorKey: 'topic',
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
id: 'funding_start',
|
id: 'funding_start',
|
||||||
header: 'Förderbeginn',
|
header: this.languageService.translate('projects.fundingStart'),
|
||||||
type: 'accessor',
|
type: 'accessor',
|
||||||
accessorKey: 'funding_start',
|
accessorKey: 'funding_start',
|
||||||
cellTemplate: this.fundingStartTmp(),
|
cellTemplate: this.fundingStartTmp(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'funding_end',
|
id: 'funding_end',
|
||||||
header: 'Förderende',
|
header: this.languageService.translate('projects.fundingEnd'),
|
||||||
type: 'accessor',
|
type: 'accessor',
|
||||||
accessorKey: 'funding_end',
|
accessorKey: 'funding_end',
|
||||||
cellTemplate: this.fundingEndTmp(),
|
cellTemplate: this.fundingEndTmp(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'funding_amount',
|
id: 'funding_amount',
|
||||||
header: 'Fördersumme (EC)',
|
header: this.languageService.translate('institutionProjects.fundingAmountEc'),
|
||||||
type: 'accessor',
|
type: 'accessor',
|
||||||
accessorKey: 'funding_amount',
|
accessorKey: 'funding_amount',
|
||||||
cellTemplate: this.fundingAmountTmp(),
|
cellTemplate: this.fundingAmountTmp(),
|
||||||
@@ -204,27 +211,27 @@ export class InstitutionProjectsComponent implements OnInit {
|
|||||||
this.bundProjectColumns = [
|
this.bundProjectColumns = [
|
||||||
{
|
{
|
||||||
id: 'title',
|
id: 'title',
|
||||||
header: 'Titel',
|
header: this.languageService.translate('projects.columnTitle'),
|
||||||
type: 'accessor',
|
type: 'accessor',
|
||||||
accessorKey: 'topic',
|
accessorKey: 'topic',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'funding_start',
|
id: 'funding_start',
|
||||||
header: 'Förderbeginn',
|
header: this.languageService.translate('projects.fundingStart'),
|
||||||
type: 'accessor',
|
type: 'accessor',
|
||||||
accessorKey: 'funding_start',
|
accessorKey: 'funding_start',
|
||||||
cellTemplate: this.fundingStartTmp(),
|
cellTemplate: this.fundingStartTmp(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'funding_end',
|
id: 'funding_end',
|
||||||
header: 'Fördersende',
|
header: this.languageService.translate('projects.fundingEnd'),
|
||||||
type: 'accessor',
|
type: 'accessor',
|
||||||
accessorKey: 'funding_end',
|
accessorKey: 'funding_end',
|
||||||
cellTemplate: this.fundingEndTmp(),
|
cellTemplate: this.fundingEndTmp(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'funding_amount',
|
id: 'funding_amount',
|
||||||
header: 'Fördersumme',
|
header: this.languageService.translate('institutionProjects.fundingAmount'),
|
||||||
type: 'accessor',
|
type: 'accessor',
|
||||||
accessorKey: 'funding_amount',
|
accessorKey: 'funding_amount',
|
||||||
cellTemplate: this.fundingAmountTmp(),
|
cellTemplate: this.fundingAmountTmp(),
|
||||||
|
|||||||
+6
-6
@@ -1,13 +1,13 @@
|
|||||||
<div class="content">
|
<div class="content">
|
||||||
<div>
|
<div>
|
||||||
<h6>Publikationen</h6>
|
<h6>{{ 'publications.publications' | translate }}</h6>
|
||||||
<p>Übersicht der wissenschaftlichen Veröffentlichungen.</p>
|
<p>{{ 'institutionPublications.description' | translate }}</p>
|
||||||
</div>
|
</div>
|
||||||
@if (canViewClassificationChart()) {
|
@if (canViewClassificationChart()) {
|
||||||
<mat-accordion multi>
|
<mat-accordion multi>
|
||||||
<mat-expansion-panel class="mat-elevation-z1">
|
<mat-expansion-panel class="mat-elevation-z1">
|
||||||
<mat-expansion-panel-header>
|
<mat-expansion-panel-header>
|
||||||
<mat-panel-title>Forschungszwecke</mat-panel-title>
|
<mat-panel-title>{{ 'publications.researchPurposes' | translate }}</mat-panel-title>
|
||||||
</mat-expansion-panel-header>
|
</mat-expansion-panel-header>
|
||||||
<app-primary-category-year-aggregation-chart
|
<app-primary-category-year-aggregation-chart
|
||||||
[page]="primaryCategoryYearAggregationPage()" />
|
[page]="primaryCategoryYearAggregationPage()" />
|
||||||
@@ -15,10 +15,10 @@
|
|||||||
|
|
||||||
<mat-expansion-panel class="mat-elevation-z1" [expanded]="true">
|
<mat-expansion-panel class="mat-elevation-z1" [expanded]="true">
|
||||||
<mat-expansion-panel-header>
|
<mat-expansion-panel-header>
|
||||||
<mat-panel-title>Publikationsliste</mat-panel-title>
|
<mat-panel-title>{{ 'publications.list' | translate }}</mat-panel-title>
|
||||||
<mat-panel-description
|
<mat-panel-description
|
||||||
>{{ total() >= 10000 ? 'mehr als' : '' }}
|
>{{ total() >= 10000 ? ('publications.moreThan' | translate) : '' }}
|
||||||
{{ total() }} Publikationen</mat-panel-description
|
{{ total() }} {{ 'publications.publications' | translate }}</mat-panel-description
|
||||||
>
|
>
|
||||||
</mat-expansion-panel-header>
|
</mat-expansion-panel-header>
|
||||||
<ng-container *ngTemplateOutlet="filterTableAndPaginator" />
|
<ng-container *ngTemplateOutlet="filterTableAndPaginator" />
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import { PrimaryCategoryYearAggregationChartComponent } from '../../shared/ui/pr
|
|||||||
import { MatExpansionModule } from '@angular/material/expansion';
|
import { MatExpansionModule } from '@angular/material/expansion';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
import { TranslatePipe } from '../../shared/i18n/translate.pipe';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-institution-publications',
|
selector: 'app-institution-publications',
|
||||||
@@ -22,6 +23,7 @@ import { ActivatedRoute } from '@angular/router';
|
|||||||
PrimaryCategoryYearAggregationChartComponent,
|
PrimaryCategoryYearAggregationChartComponent,
|
||||||
MatExpansionModule,
|
MatExpansionModule,
|
||||||
CommonModule,
|
CommonModule,
|
||||||
|
TranslatePipe,
|
||||||
],
|
],
|
||||||
templateUrl: './institution-publications.component.html',
|
templateUrl: './institution-publications.component.html',
|
||||||
styleUrl: './institution-publications.component.scss',
|
styleUrl: './institution-publications.component.scss',
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
<div class="content">
|
<div class="content">
|
||||||
<h1>{{ institution().display_name }}</h1>
|
<h1>{{ institution.display_name }}</h1>
|
||||||
<mat-card appearance="outlined">
|
<mat-card appearance="outlined">
|
||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
<p>{{ institution().homepage_url }}</p>
|
<p>{{ institution.homepage_url }}</p>
|
||||||
<p>{{ institution().display_name_alternatives }}</p>
|
<p>{{ institution.display_name_alternatives }}</p>
|
||||||
<p>And many more useful details...</p>
|
<p>{{ 'institution.moreDetails' | translate }}</p>
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
</mat-card>
|
</mat-card>
|
||||||
|
|
||||||
<nav mat-tab-nav-bar [tabPanel]="tabPanel">
|
<nav mat-tab-nav-bar [tabPanel]="tabPanel">
|
||||||
@for (link of _links(); track link.path) {
|
@for (link of links; track link.path) {
|
||||||
<a
|
<a
|
||||||
mat-tab-link
|
mat-tab-link
|
||||||
[routerLink]="link.path"
|
[routerLink]="link.path"
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
#rla="routerLinkActive"
|
#rla="routerLinkActive"
|
||||||
[active]="rla.isActive"
|
[active]="rla.isActive"
|
||||||
[disabled]="link.disabled">
|
[disabled]="link.disabled">
|
||||||
{{ link.label }}
|
{{ link.labelKey | translate }}
|
||||||
</a>
|
</a>
|
||||||
}
|
}
|
||||||
</nav>
|
</nav>
|
||||||
|
|||||||
@@ -1,15 +1,18 @@
|
|||||||
import { Component, computed, input } from '@angular/core';
|
import { Component, OnInit, inject } from '@angular/core';
|
||||||
import { RouterLink, RouterOutlet, RouterLinkActive } from '@angular/router';
|
import {
|
||||||
|
ActivatedRoute,
|
||||||
|
RouterLink,
|
||||||
|
RouterOutlet,
|
||||||
|
RouterLinkActive,
|
||||||
|
} from '@angular/router';
|
||||||
import { Institution } from '../../api';
|
import { Institution } from '../../api';
|
||||||
|
import { PatentsService } from '../../api/api/patents.service';
|
||||||
import { MatCardModule } from '@angular/material/card';
|
import { MatCardModule } from '@angular/material/card';
|
||||||
import { MatTabsModule } from '@angular/material/tabs';
|
import { MatTabsModule } from '@angular/material/tabs';
|
||||||
|
import { TranslatePipe } from '../../shared/i18n/translate.pipe';
|
||||||
|
import { TranslationKey } from '../../shared/i18n/translations';
|
||||||
|
|
||||||
type TabLink = {
|
const PATENTS_LINK = { labelKey: 'patents.title' as TranslationKey, path: 'patents', disabled: false };
|
||||||
label: string;
|
|
||||||
path: string;
|
|
||||||
disabled: boolean;
|
|
||||||
queryParams?: Record<string, any>;
|
|
||||||
};
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-institution',
|
selector: 'app-institution',
|
||||||
@@ -19,36 +22,56 @@ type TabLink = {
|
|||||||
RouterLink,
|
RouterLink,
|
||||||
RouterOutlet,
|
RouterOutlet,
|
||||||
RouterLinkActive,
|
RouterLinkActive,
|
||||||
|
TranslatePipe,
|
||||||
],
|
],
|
||||||
templateUrl: './institution.component.html',
|
templateUrl: './institution.component.html',
|
||||||
styleUrl: './institution.component.scss',
|
styleUrl: './institution.component.scss',
|
||||||
})
|
})
|
||||||
export class InstitutionComponent {
|
export class InstitutionComponent implements OnInit {
|
||||||
institution = input.required<Institution>();
|
private readonly patentsApi = inject(PatentsService);
|
||||||
canFetchGdprRelevantData = input.required<boolean>();
|
|
||||||
|
|
||||||
_links = computed<TabLink[]>(() => {
|
institution!: Institution;
|
||||||
const links: TabLink[] = [
|
|
||||||
{ label: 'Publikationen', path: 'publications', disabled: false },
|
links = [
|
||||||
];
|
{ labelKey: 'personCard.overview' as TranslationKey, path: 'overview', disabled: false },
|
||||||
if (this.canFetchGdprRelevantData()) {
|
{ labelKey: 'publications.publications' as TranslationKey, path: 'publications', disabled: false },
|
||||||
links.push(
|
{
|
||||||
{
|
labelKey: 'nav.projects' as TranslationKey,
|
||||||
label: 'Projekte',
|
path: 'projects',
|
||||||
path: 'projects',
|
disabled: false,
|
||||||
disabled: false,
|
queryParams: {
|
||||||
queryParams: {
|
project_tab: 'bund',
|
||||||
project_tab: 'bund',
|
page: 0,
|
||||||
page: 0,
|
size: 10,
|
||||||
size: 10,
|
search: '',
|
||||||
search: '',
|
sort_by: 'title',
|
||||||
sort_by: 'title',
|
sort_direction: 'asc',
|
||||||
sort_direction: 'asc',
|
},
|
||||||
},
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
constructor(private readonly activatedRoute: ActivatedRoute) {}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.activatedRoute.data.subscribe(({ institution }) => {
|
||||||
|
this.institution = institution;
|
||||||
|
});
|
||||||
|
|
||||||
|
const institutionId =
|
||||||
|
this.activatedRoute.snapshot.paramMap.get('institutionId');
|
||||||
|
if (!institutionId) return;
|
||||||
|
|
||||||
|
// The "Patente" tab only makes sense once org_patents has been indexed for
|
||||||
|
// this institution (currently a manual, ~30-40 min-per-institution process),
|
||||||
|
// so only show it once we know there is actually data behind it.
|
||||||
|
this.patentsApi
|
||||||
|
.getOrgPatentsByInstitution(institutionId, undefined, 0, 0)
|
||||||
|
.subscribe({
|
||||||
|
next: (result) => {
|
||||||
|
if ((result.patent_count ?? 0) > 0) {
|
||||||
|
this.links = [...this.links, PATENTS_LINK];
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{ label: 'Patente', path: 'patents', disabled: false },
|
});
|
||||||
);
|
}
|
||||||
}
|
|
||||||
return links;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<div class="content">
|
<div class="content">
|
||||||
<h1>Passende Institutionen finden</h1>
|
<h1>{{ 'institutions.title' | translate }}</h1>
|
||||||
|
|
||||||
<mat-divider />
|
<mat-divider />
|
||||||
|
|
||||||
@@ -9,9 +9,11 @@
|
|||||||
[cardTmp]="cardTmp"
|
[cardTmp]="cardTmp"
|
||||||
[observers]="observers"
|
[observers]="observers"
|
||||||
[cardMinWidth]="550"
|
[cardMinWidth]="550"
|
||||||
searchLabel="Suche nach Namen"
|
[searchLabel]="'institutions.searchName' | translate"
|
||||||
[sortingOptions]="sortingOptions"
|
[sortingOptions]="sortingOptions()"
|
||||||
[sortingDirectionOptions]="sortingDirectionOptions" />
|
[sortByLabel]="'personPatents.sortBy' | translate"
|
||||||
|
[sortingDirectionOptions]="sortingDirectionOptions()"
|
||||||
|
[sortingDirectionLabel]="'persons.sortOrder' | translate" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ng-template #cardTmp let-institution>
|
<ng-template #cardTmp let-institution>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Component, computed, input } from '@angular/core';
|
import { Component, computed, inject, input } from '@angular/core';
|
||||||
import { InstitutionPage } from '../../api';
|
import { InstitutionPage } from '../../api';
|
||||||
import { MatButtonModule } from '@angular/material/button';
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
import { MatCardModule } from '@angular/material/card';
|
import { MatCardModule } from '@angular/material/card';
|
||||||
@@ -13,6 +13,8 @@ import {
|
|||||||
} from '../../shared/ui/card-search/card-search.component';
|
} from '../../shared/ui/card-search/card-search.component';
|
||||||
import { FilterObserver } from '../../shared/ui/selected-filters/selected-filters.component';
|
import { FilterObserver } from '../../shared/ui/selected-filters/selected-filters.component';
|
||||||
import { AppInstitutionCardComponent } from '../../shared/ui/app-institution-card/app-institution-card.component';
|
import { AppInstitutionCardComponent } from '../../shared/ui/app-institution-card/app-institution-card.component';
|
||||||
|
import { TranslatePipe } from '../../shared/i18n/translate.pipe';
|
||||||
|
import { LanguageService } from '../../shared/i18n/language.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-institutions',
|
selector: 'app-institutions',
|
||||||
@@ -24,11 +26,13 @@ import { AppInstitutionCardComponent } from '../../shared/ui/app-institution-car
|
|||||||
RouterModule,
|
RouterModule,
|
||||||
CardSearchComponent,
|
CardSearchComponent,
|
||||||
AppInstitutionCardComponent,
|
AppInstitutionCardComponent,
|
||||||
|
TranslatePipe,
|
||||||
],
|
],
|
||||||
templateUrl: './institutions.component.html',
|
templateUrl: './institutions.component.html',
|
||||||
styleUrl: './institutions.component.scss',
|
styleUrl: './institutions.component.scss',
|
||||||
})
|
})
|
||||||
export class InstitutionsComponent {
|
export class InstitutionsComponent {
|
||||||
|
private readonly languageService = inject(LanguageService);
|
||||||
institutionPage = input.required<InstitutionPage>();
|
institutionPage = input.required<InstitutionPage>();
|
||||||
|
|
||||||
observers: FilterObserver[] = [
|
observers: FilterObserver[] = [
|
||||||
@@ -46,14 +50,14 @@ export class InstitutionsComponent {
|
|||||||
elements: this.institutionPage().elements || [],
|
elements: this.institutionPage().elements || [],
|
||||||
}));
|
}));
|
||||||
|
|
||||||
sortingOptions: SelectorOption[] = [
|
sortingOptions = computed<SelectorOption[]>(() => [
|
||||||
{ value: 'relevance', display_name: 'Relevanz' },
|
{ value: 'relevance', display_name: this.languageService.translate('institutions.relevance') },
|
||||||
{ value: 'name', display_name: 'Name' },
|
{ value: 'name', display_name: this.languageService.translate('jobs.name') },
|
||||||
{ value: 'works_count', display_name: 'Anzahl Publikationen' },
|
{ value: 'works_count', display_name: this.languageService.translate('institutions.publicationCount') },
|
||||||
{ value: 'citations_count', display_name: 'Anzahl Zitationen' },
|
{ value: 'citations_count', display_name: this.languageService.translate('institutions.citationCount') },
|
||||||
];
|
]);
|
||||||
sortingDirectionOptions: SelectorOption[] = [
|
sortingDirectionOptions = computed<SelectorOption[]>(() => [
|
||||||
{ value: 'asc', display_name: 'Aufsteigend' },
|
{ value: 'asc', display_name: this.languageService.translate('persons.ascending') },
|
||||||
{ value: 'desc', display_name: 'Absteigend' },
|
{ value: 'desc', display_name: this.languageService.translate('persons.descending') },
|
||||||
];
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,18 +2,19 @@
|
|||||||
|
|
||||||
<mat-dialog-content>
|
<mat-dialog-content>
|
||||||
@if (runsLoading() && runs().length === 0) {
|
@if (runsLoading() && runs().length === 0) {
|
||||||
<app-loading
|
<div class="runs-loading">
|
||||||
text="Läufe werden geladen …"
|
<mat-progress-spinner
|
||||||
icon="history"
|
diameter="24"
|
||||||
[size]="48"
|
mode="indeterminate"></mat-progress-spinner>
|
||||||
[diameter]="48" />
|
<span>{{ 'jobs.runsLoading' | translate }}</span>
|
||||||
|
</div>
|
||||||
} @else if (runsError()) {
|
} @else if (runsError()) {
|
||||||
<p class="logs-error">{{ runsError() }}</p>
|
<p class="logs-error">{{ runsError() }}</p>
|
||||||
} @else if (runs().length === 0) {
|
} @else if (runs().length === 0) {
|
||||||
<p class="no-logs">Für diesen Job liegt noch kein Lauf vor.</p>
|
<p class="no-logs">{{ 'jobs.noRuns' | translate }}</p>
|
||||||
} @else {
|
} @else {
|
||||||
<mat-form-field appearance="outline" class="run-select">
|
<mat-form-field appearance="outline" class="run-select">
|
||||||
<mat-label>Lauf auswählen</mat-label>
|
<mat-label>{{ 'jobs.selectRun' | translate }}</mat-label>
|
||||||
<mat-select
|
<mat-select
|
||||||
[value]="selectedRunId()"
|
[value]="selectedRunId()"
|
||||||
(selectionChange)="onRunSelected($event.value)">
|
(selectionChange)="onRunSelected($event.value)">
|
||||||
@@ -34,7 +35,7 @@
|
|||||||
|
|
||||||
<div class="logs-header">
|
<div class="logs-header">
|
||||||
<div class="run-meta">
|
<div class="run-meta">
|
||||||
<span>Lauf #{{ selectedRunId() }}</span>
|
<span>{{ 'jobs.run' | translate }} #{{ selectedRunId() }}</span>
|
||||||
@if (runStatus()) {
|
@if (runStatus()) {
|
||||||
<span
|
<span
|
||||||
class="task-status"
|
class="task-status"
|
||||||
@@ -46,13 +47,13 @@
|
|||||||
@if (selectedRun(); as run) {
|
@if (selectedRun(); as run) {
|
||||||
@if (runStatus() === 'running' || runStatus() === 'stopping') {
|
@if (runStatus() === 'running' || runStatus() === 'stopping') {
|
||||||
@if (formatRunElapsed(run, nowMs()); as elapsed) {
|
@if (formatRunElapsed(run, nowMs()); as elapsed) {
|
||||||
<span class="run-duration">läuft seit {{ elapsed }}</span>
|
<span class="run-duration">{{ runningSinceLabel(elapsed) }}</span>
|
||||||
}
|
}
|
||||||
} @else if (formatRunDuration(run); as dur) {
|
} @else if (formatRunDuration(run); as dur) {
|
||||||
<span class="run-duration">Dauer: {{ dur }}</span>
|
<span class="run-duration">{{ durationLabel(dur) }}</span>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
<span class="logs-hint">zeigt letzte 200 Zeilen</span>
|
<span class="logs-hint">{{ 'jobs.lastLines' | translate }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="logs-actions">
|
<div class="logs-actions">
|
||||||
<button
|
<button
|
||||||
@@ -61,13 +62,13 @@
|
|||||||
[disabled]="selectedRunId() == null"
|
[disabled]="selectedRunId() == null"
|
||||||
(click)="downloadLogs()">
|
(click)="downloadLogs()">
|
||||||
<mat-icon>download</mat-icon>
|
<mat-icon>download</mat-icon>
|
||||||
Herunterladen
|
{{ 'jobs.download' | translate }}
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
mat-icon-button
|
mat-icon-button
|
||||||
type="button"
|
type="button"
|
||||||
aria-label="Logs aktualisieren"
|
[attr.aria-label]="'jobs.refreshLogs' | translate"
|
||||||
matTooltip="Logs aktualisieren"
|
[matTooltip]="'jobs.refreshLogs' | translate"
|
||||||
matTooltipPosition="above"
|
matTooltipPosition="above"
|
||||||
[disabled]="loading() || runsLoading()"
|
[disabled]="loading() || runsLoading()"
|
||||||
(click)="loadRuns()">
|
(click)="loadRuns()">
|
||||||
@@ -78,11 +79,12 @@
|
|||||||
|
|
||||||
<div #logsPanel class="logs-panel" (scroll)="onLogsScroll()">
|
<div #logsPanel class="logs-panel" (scroll)="onLogsScroll()">
|
||||||
@if (loading() && !logs()) {
|
@if (loading() && !logs()) {
|
||||||
<app-loading
|
<div class="logs-loading">
|
||||||
text="Logs werden geladen …"
|
<mat-progress-spinner
|
||||||
icon="description"
|
diameter="20"
|
||||||
[size]="48"
|
mode="indeterminate"></mat-progress-spinner>
|
||||||
[diameter]="48" />
|
<span>{{ 'jobs.logsLoading' | translate }}</span>
|
||||||
|
</div>
|
||||||
} @else {
|
} @else {
|
||||||
<pre>{{ logs() }}</pre>
|
<pre>{{ logs() }}</pre>
|
||||||
}
|
}
|
||||||
@@ -91,5 +93,5 @@
|
|||||||
</mat-dialog-content>
|
</mat-dialog-content>
|
||||||
|
|
||||||
<mat-dialog-actions align="end">
|
<mat-dialog-actions align="end">
|
||||||
<button mat-button type="button" (click)="close()">Schließen</button>
|
<button mat-button type="button" (click)="close()">{{ 'common.close' | translate }}</button>
|
||||||
</mat-dialog-actions>
|
</mat-dialog-actions>
|
||||||
|
|||||||
@@ -3,6 +3,14 @@
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.runs-loading {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
min-height: 120px;
|
||||||
|
color: var(--sg-text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
.logs-error {
|
.logs-error {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
@@ -85,6 +93,18 @@
|
|||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.logs-loading {
|
||||||
|
color: var(--sg-text-muted);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.logs-loading {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
color: var(--sg-text-muted);
|
||||||
|
font-size: 13px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.run-select {
|
.run-select {
|
||||||
|
|||||||
@@ -18,17 +18,19 @@ import {
|
|||||||
} from '@angular/material/dialog';
|
} from '@angular/material/dialog';
|
||||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||||
import { MatIconModule } from '@angular/material/icon';
|
import { MatIconModule } from '@angular/material/icon';
|
||||||
|
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||||
import { MatSelectModule } from '@angular/material/select';
|
import { MatSelectModule } from '@angular/material/select';
|
||||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||||
import { finalize, timer } from 'rxjs';
|
import { finalize, timer } from 'rxjs';
|
||||||
import { BackgroundJobsService, BackgroundJobTask, JobRun } from '../../../api';
|
import { BackgroundJobsService, BackgroundJobTask, JobRun } from '../../../api';
|
||||||
import { LoadingComponent } from '../../../shared/ui/loading/loading.component';
|
|
||||||
import {
|
import {
|
||||||
formatRunDuration,
|
formatRunDuration,
|
||||||
formatRunElapsed,
|
formatRunElapsed,
|
||||||
formatUtcDateAsLocal,
|
formatUtcDateAsLocal,
|
||||||
statusMeta,
|
statusMeta,
|
||||||
} from '../jobs.utils';
|
} from '../jobs.utils';
|
||||||
|
import { LanguageService } from '../../../shared/i18n/language.service';
|
||||||
|
import { TranslatePipe } from '../../../shared/i18n/translate.pipe';
|
||||||
|
|
||||||
export interface JobLogsDialogData {
|
export interface JobLogsDialogData {
|
||||||
task: BackgroundJobTask;
|
task: BackgroundJobTask;
|
||||||
@@ -42,9 +44,10 @@ export interface JobLogsDialogData {
|
|||||||
MatDialogModule,
|
MatDialogModule,
|
||||||
MatFormFieldModule,
|
MatFormFieldModule,
|
||||||
MatIconModule,
|
MatIconModule,
|
||||||
|
MatProgressSpinnerModule,
|
||||||
MatSelectModule,
|
MatSelectModule,
|
||||||
MatTooltipModule,
|
MatTooltipModule,
|
||||||
LoadingComponent,
|
TranslatePipe,
|
||||||
],
|
],
|
||||||
templateUrl: './job-logs-dialog.component.html',
|
templateUrl: './job-logs-dialog.component.html',
|
||||||
styleUrl: './job-logs-dialog.component.scss',
|
styleUrl: './job-logs-dialog.component.scss',
|
||||||
@@ -54,10 +57,9 @@ export class JobLogsDialogComponent implements OnInit {
|
|||||||
private readonly dialogRef = inject(MatDialogRef<JobLogsDialogComponent>);
|
private readonly dialogRef = inject(MatDialogRef<JobLogsDialogComponent>);
|
||||||
private readonly backgroundJobsService = inject(BackgroundJobsService);
|
private readonly backgroundJobsService = inject(BackgroundJobsService);
|
||||||
private readonly destroyRef = inject(DestroyRef);
|
private readonly destroyRef = inject(DestroyRef);
|
||||||
|
private readonly languageService = inject(LanguageService);
|
||||||
protected readonly data = inject<JobLogsDialogData>(MAT_DIALOG_DATA);
|
protected readonly data = inject<JobLogsDialogData>(MAT_DIALOG_DATA);
|
||||||
|
|
||||||
protected readonly statusMeta = statusMeta;
|
|
||||||
protected readonly formatUtcDateAsLocal = formatUtcDateAsLocal;
|
|
||||||
protected readonly formatRunDuration = formatRunDuration;
|
protected readonly formatRunDuration = formatRunDuration;
|
||||||
protected readonly formatRunElapsed = formatRunElapsed;
|
protected readonly formatRunElapsed = formatRunElapsed;
|
||||||
|
|
||||||
@@ -114,7 +116,7 @@ export class JobLogsDialogComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: () => {
|
error: () => {
|
||||||
this.runsError.set('Läufe konnten nicht geladen werden.');
|
this.runsError.set(this.languageService.translate('jobs.runsError'));
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -162,15 +164,15 @@ export class JobLogsDialogComponent implements OnInit {
|
|||||||
.subscribe({
|
.subscribe({
|
||||||
next: (result) => {
|
next: (result) => {
|
||||||
if (!result) {
|
if (!result) {
|
||||||
this.logs.set('Die Log-Anfrage hat keine Daten zurückgegeben.');
|
this.logs.set(this.languageService.translate('jobs.emptyLogResponse'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.logs.set(result.logs || 'Keine Logs vorhanden.');
|
this.logs.set(result.logs || this.languageService.translate('jobs.noLogs'));
|
||||||
this.runStatus.set(result.status);
|
this.runStatus.set(result.status);
|
||||||
if (this.followTail) this.scrollToBottom();
|
if (this.followTail) this.scrollToBottom();
|
||||||
},
|
},
|
||||||
error: () => {
|
error: () => {
|
||||||
this.logs.set('Logs konnten nicht geladen werden.');
|
this.logs.set(this.languageService.translate('jobs.logsError'));
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -193,4 +195,26 @@ export class JobLogsDialogComponent implements OnInit {
|
|||||||
protected close(): void {
|
protected close(): void {
|
||||||
this.dialogRef.close();
|
this.dialogRef.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected statusMeta(status: string) {
|
||||||
|
const meta = statusMeta(status);
|
||||||
|
const keys: Record<string, 'jobs.statusRunning' | 'jobs.statusStopping' | 'jobs.statusSucceeded' | 'jobs.statusFailed' | 'jobs.statusStopped' | 'jobs.statusIdle'> = {
|
||||||
|
running: 'jobs.statusRunning', stopping: 'jobs.statusStopping',
|
||||||
|
succeeded: 'jobs.statusSucceeded', failed: 'jobs.statusFailed',
|
||||||
|
stopped: 'jobs.statusStopped', idle: 'jobs.statusIdle',
|
||||||
|
};
|
||||||
|
return { ...meta, label: this.languageService.translate(keys[status] ?? 'jobs.statusIdle') };
|
||||||
|
}
|
||||||
|
|
||||||
|
protected formatUtcDateAsLocal(value: string | null | undefined): string {
|
||||||
|
return formatUtcDateAsLocal(value, this.languageService.language() === 'de' ? 'de-DE' : 'en-US');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected runningSinceLabel(duration: string): string {
|
||||||
|
return this.languageService.translate('jobs.runningSince', { duration });
|
||||||
|
}
|
||||||
|
|
||||||
|
protected durationLabel(duration: string): string {
|
||||||
|
return this.languageService.translate('jobs.duration', { duration });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
<section class="jobs-page">
|
<section class="jobs-page">
|
||||||
<header class="page-header">
|
<header class="page-header">
|
||||||
<div>
|
<div>
|
||||||
<h1>Jobs</h1>
|
<h1>{{ 'jobs.title' | translate }}</h1>
|
||||||
<p>
|
<p>{{ 'jobs.description' | translate }}</p>
|
||||||
Background-Jobs zur Aufbereitung und Indizierung der Daten manuell
|
|
||||||
ausführen oder per Cron-Zeitplan automatisieren.
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
mat-flat-button
|
mat-flat-button
|
||||||
@@ -14,7 +11,7 @@
|
|||||||
class="new-job-button"
|
class="new-job-button"
|
||||||
(click)="openCreateDialog()">
|
(click)="openCreateDialog()">
|
||||||
<mat-icon>add</mat-icon>
|
<mat-icon>add</mat-icon>
|
||||||
Neuer Job
|
{{ 'jobs.new' | translate }}
|
||||||
</button>
|
</button>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
@@ -33,7 +30,9 @@
|
|||||||
<strong>Docker-Daemon</strong>
|
<strong>Docker-Daemon</strong>
|
||||||
<div class="health-detail">
|
<div class="health-detail">
|
||||||
{{
|
{{
|
||||||
dockerHealth()?.reachable ? 'Erreichbar' : 'Nicht erreichbar'
|
dockerHealth()?.reachable
|
||||||
|
? ('jobs.reachable' | translate)
|
||||||
|
: ('jobs.unreachable' | translate)
|
||||||
}}
|
}}
|
||||||
@if (dockerHealth()?.detail) {
|
@if (dockerHealth()?.detail) {
|
||||||
<span> · {{ dockerHealth()?.detail }}</span>
|
<span> · {{ dockerHealth()?.detail }}</span>
|
||||||
@@ -44,8 +43,8 @@
|
|||||||
<button
|
<button
|
||||||
mat-icon-button
|
mat-icon-button
|
||||||
type="button"
|
type="button"
|
||||||
aria-label="Docker-Status aktualisieren"
|
[attr.aria-label]="'jobs.refreshDocker' | translate"
|
||||||
matTooltip="Docker-Status aktualisieren"
|
[matTooltip]="'jobs.refreshDocker' | translate"
|
||||||
[disabled]="dockerHealthLoading()"
|
[disabled]="dockerHealthLoading()"
|
||||||
(click)="refreshDockerHealth()">
|
(click)="refreshDockerHealth()">
|
||||||
<mat-icon>refresh</mat-icon>
|
<mat-icon>refresh</mat-icon>
|
||||||
@@ -72,12 +71,12 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="health-detail">
|
<div class="health-detail">
|
||||||
@if (registryHealthLoading() && !registryHealth()) {
|
@if (registryHealthLoading() && !registryHealth()) {
|
||||||
<span>Wird geprüft …</span>
|
<span>{{ 'jobs.checking' | translate }}</span>
|
||||||
} @else {
|
} @else {
|
||||||
{{
|
{{
|
||||||
registryHealth()?.reachable
|
registryHealth()?.reachable
|
||||||
? 'Erreichbar'
|
? ('jobs.reachable' | translate)
|
||||||
: 'Nicht erreichbar'
|
: ('jobs.unreachable' | translate)
|
||||||
}}
|
}}
|
||||||
@if (registryHealth()?.detail) {
|
@if (registryHealth()?.detail) {
|
||||||
<span> · {{ registryHealth()?.detail }}</span>
|
<span> · {{ registryHealth()?.detail }}</span>
|
||||||
@@ -89,8 +88,8 @@
|
|||||||
<button
|
<button
|
||||||
mat-icon-button
|
mat-icon-button
|
||||||
type="button"
|
type="button"
|
||||||
aria-label="Nexus-Status aktualisieren"
|
[attr.aria-label]="'jobs.refreshNexus' | translate"
|
||||||
matTooltip="Nexus-Status aktualisieren"
|
[matTooltip]="'jobs.refreshNexus' | translate"
|
||||||
[disabled]="registryHealthLoading()"
|
[disabled]="registryHealthLoading()"
|
||||||
(click)="refreshRegistryHealth()">
|
(click)="refreshRegistryHealth()">
|
||||||
<mat-icon>refresh</mat-icon>
|
<mat-icon>refresh</mat-icon>
|
||||||
@@ -111,8 +110,8 @@
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="edit-name-action"
|
class="edit-name-action"
|
||||||
aria-label="Job bearbeiten"
|
[attr.aria-label]="'jobs.edit' | translate"
|
||||||
matTooltip="Job bearbeiten"
|
[matTooltip]="'jobs.edit' | translate"
|
||||||
matTooltipPosition="above"
|
matTooltipPosition="above"
|
||||||
[disabled]="row.status === 'running' || row.status === 'stopping'"
|
[disabled]="row.status === 'running' || row.status === 'stopping'"
|
||||||
(click)="openEditDialog(row)">
|
(click)="openEditDialog(row)">
|
||||||
@@ -131,16 +130,20 @@
|
|||||||
@if (row.schedule) {
|
@if (row.schedule) {
|
||||||
<span class="schedule-cron">{{ row.schedule }}</span>
|
<span class="schedule-cron">{{ row.schedule }}</span>
|
||||||
} @else {
|
} @else {
|
||||||
<span>Nur manuell</span>
|
<span>{{ 'jobs.manualOnly' | translate }}</span>
|
||||||
}
|
}
|
||||||
@if (row.next_run_at) {
|
@if (row.next_run_at) {
|
||||||
<span class="next-run">
|
<span class="next-run">
|
||||||
Nächster Lauf: {{ formatUtcDateAsLocal(row.next_run_at) }}
|
{{ nextRunLabel(row.next_run_at) }}
|
||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
@if (row.schedule) {
|
@if (row.schedule) {
|
||||||
<span class="enabled-badge" [class.enabled-badge--on]="row.enabled">
|
<span class="enabled-badge" [class.enabled-badge--on]="row.enabled">
|
||||||
{{ row.enabled ? 'Aktiv' : 'Inaktiv' }}
|
{{
|
||||||
|
row.enabled
|
||||||
|
? ('status.active' | translate)
|
||||||
|
: ('status.inactive' | translate)
|
||||||
|
}}
|
||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
@@ -165,10 +168,10 @@
|
|||||||
<span>{{ formatUtcDateAsLocal(row.last_run.started_at) }}</span>
|
<span>{{ formatUtcDateAsLocal(row.last_run.started_at) }}</span>
|
||||||
@if (row.status === 'running' || row.status === 'stopping') {
|
@if (row.status === 'running' || row.status === 'stopping') {
|
||||||
@if (formatRunElapsed(row.last_run, nowMs()); as elapsed) {
|
@if (formatRunElapsed(row.last_run, nowMs()); as elapsed) {
|
||||||
<span class="last-run-message">läuft seit {{ elapsed }}</span>
|
<span class="last-run-message">{{ runningSinceLabel(elapsed) }}</span>
|
||||||
}
|
}
|
||||||
} @else if (formatRunDuration(row.last_run); as duration) {
|
} @else if (formatRunDuration(row.last_run); as duration) {
|
||||||
<span class="last-run-message">Dauer: {{ duration }}</span>
|
<span class="last-run-message">{{ durationLabel(duration) }}</span>
|
||||||
}
|
}
|
||||||
@if (row.last_run.exit_code != null) {
|
@if (row.last_run.exit_code != null) {
|
||||||
<span class="last-run-message"
|
<span class="last-run-message"
|
||||||
@@ -177,18 +180,18 @@
|
|||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
} @else {
|
} @else {
|
||||||
<span class="last-run-empty">Noch nicht ausgeführt</span>
|
<span class="last-run-empty">{{ 'jobs.neverRun' | translate }}</span>
|
||||||
}
|
}
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
|
||||||
<ng-template #taskActionsHeaderTmp>
|
<ng-template #taskActionsHeaderTmp>
|
||||||
<div class="actions-header">
|
<div class="actions-header">
|
||||||
<span>Aktionen</span>
|
<span>{{ 'common.actions' | translate }}</span>
|
||||||
<button
|
<button
|
||||||
mat-icon-button
|
mat-icon-button
|
||||||
type="button"
|
type="button"
|
||||||
aria-label="Jobs aktualisieren"
|
[attr.aria-label]="'jobs.refresh' | translate"
|
||||||
matTooltip="Jobs aktualisieren"
|
[matTooltip]="'jobs.refresh' | translate"
|
||||||
matTooltipPosition="above"
|
matTooltipPosition="above"
|
||||||
(click)="refreshTasks()">
|
(click)="refreshTasks()">
|
||||||
<mat-icon>refresh</mat-icon>
|
<mat-icon>refresh</mat-icon>
|
||||||
@@ -201,8 +204,8 @@
|
|||||||
<button
|
<button
|
||||||
mat-icon-button
|
mat-icon-button
|
||||||
type="button"
|
type="button"
|
||||||
aria-label="Jetzt ausführen"
|
[attr.aria-label]="'jobs.runNow' | translate"
|
||||||
matTooltip="Jetzt ausführen"
|
[matTooltip]="'jobs.runNow' | translate"
|
||||||
matTooltipPosition="above"
|
matTooltipPosition="above"
|
||||||
[disabled]="row.status === 'running' || row.status === 'stopping'"
|
[disabled]="row.status === 'running' || row.status === 'stopping'"
|
||||||
(click)="runNow(row)">
|
(click)="runNow(row)">
|
||||||
@@ -211,8 +214,8 @@
|
|||||||
<button
|
<button
|
||||||
mat-icon-button
|
mat-icon-button
|
||||||
type="button"
|
type="button"
|
||||||
aria-label="Stoppen"
|
[attr.aria-label]="'jobs.stop' | translate"
|
||||||
matTooltip="Stoppen"
|
[matTooltip]="'jobs.stop' | translate"
|
||||||
matTooltipPosition="above"
|
matTooltipPosition="above"
|
||||||
[disabled]="row.status !== 'running'"
|
[disabled]="row.status !== 'running'"
|
||||||
(click)="stopNow(row)">
|
(click)="stopNow(row)">
|
||||||
@@ -221,8 +224,8 @@
|
|||||||
<button
|
<button
|
||||||
mat-icon-button
|
mat-icon-button
|
||||||
type="button"
|
type="button"
|
||||||
aria-label="Logs anzeigen"
|
[attr.aria-label]="'jobs.showLogs' | translate"
|
||||||
matTooltip="Logs anzeigen"
|
[matTooltip]="'jobs.showLogs' | translate"
|
||||||
matTooltipPosition="above"
|
matTooltipPosition="above"
|
||||||
[disabled]="!row.last_run"
|
[disabled]="!row.last_run"
|
||||||
(click)="openLogsDialog(row)">
|
(click)="openLogsDialog(row)">
|
||||||
@@ -231,8 +234,8 @@
|
|||||||
<button
|
<button
|
||||||
mat-icon-button
|
mat-icon-button
|
||||||
type="button"
|
type="button"
|
||||||
aria-label="Zeitplan bearbeiten"
|
[attr.aria-label]="'jobs.editSchedule' | translate"
|
||||||
matTooltip="Zeitplan bearbeiten"
|
[matTooltip]="'jobs.editSchedule' | translate"
|
||||||
matTooltipPosition="above"
|
matTooltipPosition="above"
|
||||||
(click)="openScheduleDialog(row)">
|
(click)="openScheduleDialog(row)">
|
||||||
<mat-icon>edit_calendar</mat-icon>
|
<mat-icon>edit_calendar</mat-icon>
|
||||||
@@ -241,8 +244,8 @@
|
|||||||
mat-icon-button
|
mat-icon-button
|
||||||
type="button"
|
type="button"
|
||||||
class="delete-action"
|
class="delete-action"
|
||||||
aria-label="Job löschen"
|
[attr.aria-label]="'jobs.delete' | translate"
|
||||||
matTooltip="Job löschen"
|
[matTooltip]="'jobs.delete' | translate"
|
||||||
matTooltipPosition="above"
|
matTooltipPosition="above"
|
||||||
[disabled]="
|
[disabled]="
|
||||||
row.status === 'running' ||
|
row.status === 'running' ||
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import { CommonModule } from '@angular/common';
|
|||||||
import {
|
import {
|
||||||
Component,
|
Component,
|
||||||
DestroyRef,
|
DestroyRef,
|
||||||
|
effect,
|
||||||
|
Injector,
|
||||||
OnInit,
|
OnInit,
|
||||||
TemplateRef,
|
TemplateRef,
|
||||||
inject,
|
inject,
|
||||||
@@ -58,6 +60,8 @@ import {
|
|||||||
TaskEditDialogComponent,
|
TaskEditDialogComponent,
|
||||||
TaskEditDialogData,
|
TaskEditDialogData,
|
||||||
} from './task-edit-dialog/task-edit-dialog.component';
|
} from './task-edit-dialog/task-edit-dialog.component';
|
||||||
|
import { LanguageService } from '../../shared/i18n/language.service';
|
||||||
|
import { TranslatePipe } from '../../shared/i18n/translate.pipe';
|
||||||
|
|
||||||
const MAX_IDLE_POLL_WAIT_MS = 60000;
|
const MAX_IDLE_POLL_WAIT_MS = 60000;
|
||||||
|
|
||||||
@@ -73,6 +77,7 @@ const MAX_IDLE_POLL_WAIT_MS = 60000;
|
|||||||
MatSnackBarModule,
|
MatSnackBarModule,
|
||||||
MatTooltipModule,
|
MatTooltipModule,
|
||||||
DataTableComponent,
|
DataTableComponent,
|
||||||
|
TranslatePipe,
|
||||||
],
|
],
|
||||||
templateUrl: './jobs.component.html',
|
templateUrl: './jobs.component.html',
|
||||||
styleUrl: './jobs.component.scss',
|
styleUrl: './jobs.component.scss',
|
||||||
@@ -83,6 +88,8 @@ export class JobsComponent implements OnInit {
|
|||||||
private readonly snackBar = inject(MatSnackBar);
|
private readonly snackBar = inject(MatSnackBar);
|
||||||
private readonly backgroundJobsService = inject(BackgroundJobsService);
|
private readonly backgroundJobsService = inject(BackgroundJobsService);
|
||||||
private readonly destroyRef = inject(DestroyRef);
|
private readonly destroyRef = inject(DestroyRef);
|
||||||
|
private readonly languageService = inject(LanguageService);
|
||||||
|
private readonly injector = inject(Injector);
|
||||||
|
|
||||||
tasksInput = input.required<BackgroundJobTask[]>({ alias: 'tasks' });
|
tasksInput = input.required<BackgroundJobTask[]>({ alias: 'tasks' });
|
||||||
dockerHealthInput = input.required<DockerHealth>({ alias: 'dockerHealth' });
|
dockerHealthInput = input.required<DockerHealth>({ alias: 'dockerHealth' });
|
||||||
@@ -95,9 +102,7 @@ export class JobsComponent implements OnInit {
|
|||||||
protected readonly deletingTaskIds = signal<ReadonlySet<number>>(new Set());
|
protected readonly deletingTaskIds = signal<ReadonlySet<number>>(new Set());
|
||||||
protected readonly nowMs = signal(Date.now());
|
protected readonly nowMs = signal(Date.now());
|
||||||
|
|
||||||
protected readonly statusMeta = statusMeta;
|
|
||||||
protected readonly formatScheduleCron = formatScheduleCron;
|
protected readonly formatScheduleCron = formatScheduleCron;
|
||||||
protected readonly formatUtcDateAsLocal = formatUtcDateAsLocal;
|
|
||||||
protected readonly formatRunDuration = formatRunDuration;
|
protected readonly formatRunDuration = formatRunDuration;
|
||||||
protected readonly formatRunElapsed = formatRunElapsed;
|
protected readonly formatRunElapsed = formatRunElapsed;
|
||||||
|
|
||||||
@@ -137,7 +142,9 @@ export class JobsComponent implements OnInit {
|
|||||||
})
|
})
|
||||||
.pipe(
|
.pipe(
|
||||||
catchError(() => {
|
catchError(() => {
|
||||||
this.showError('Jobs konnten nicht aktualisiert werden.');
|
this.showError(
|
||||||
|
this.languageService.translate('jobs.refreshError'),
|
||||||
|
);
|
||||||
return EMPTY;
|
return EMPTY;
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
@@ -151,34 +158,44 @@ export class JobsComponent implements OnInit {
|
|||||||
|
|
||||||
this.syncBackgroundWork();
|
this.syncBackgroundWork();
|
||||||
|
|
||||||
|
effect(
|
||||||
|
() => {
|
||||||
|
this.languageService.language();
|
||||||
|
this.setTaskColumns();
|
||||||
|
},
|
||||||
|
{ injector: this.injector },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private setTaskColumns(): void {
|
||||||
this.taskColumns = [
|
this.taskColumns = [
|
||||||
{
|
{
|
||||||
id: 'name',
|
id: 'name',
|
||||||
header: 'Job',
|
header: this.languageService.translate('jobs.columnJob'),
|
||||||
type: 'display',
|
type: 'display',
|
||||||
cellTemplate: this.taskNameTmp(),
|
cellTemplate: this.taskNameTmp(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'schedule',
|
id: 'schedule',
|
||||||
header: 'Zeitplan',
|
header: this.languageService.translate('jobs.columnSchedule'),
|
||||||
type: 'display',
|
type: 'display',
|
||||||
cellTemplate: this.taskScheduleTmp(),
|
cellTemplate: this.taskScheduleTmp(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'status',
|
id: 'status',
|
||||||
header: 'Status',
|
header: this.languageService.translate('common.status'),
|
||||||
type: 'display',
|
type: 'display',
|
||||||
cellTemplate: this.taskStatusTmp(),
|
cellTemplate: this.taskStatusTmp(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'lastRun',
|
id: 'lastRun',
|
||||||
header: 'Letzter Lauf',
|
header: this.languageService.translate('jobs.columnLastRun'),
|
||||||
type: 'display',
|
type: 'display',
|
||||||
cellTemplate: this.taskLastRunTmp(),
|
cellTemplate: this.taskLastRunTmp(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'actions',
|
id: 'actions',
|
||||||
header: 'Aktionen',
|
header: this.languageService.translate('common.actions'),
|
||||||
type: 'display',
|
type: 'display',
|
||||||
headerTemplate: this.taskActionsHeaderTmp(),
|
headerTemplate: this.taskActionsHeaderTmp(),
|
||||||
cellTemplate: this.taskActionsTmp(),
|
cellTemplate: this.taskActionsTmp(),
|
||||||
@@ -248,7 +265,7 @@ export class JobsComponent implements OnInit {
|
|||||||
},
|
},
|
||||||
error: () => {
|
error: () => {
|
||||||
this.dockerHealthLoading.set(false);
|
this.dockerHealthLoading.set(false);
|
||||||
this.showError('Docker-Status konnte nicht abgerufen werden.');
|
this.showError(this.languageService.translate('jobs.dockerError'));
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -265,7 +282,7 @@ export class JobsComponent implements OnInit {
|
|||||||
},
|
},
|
||||||
error: () => {
|
error: () => {
|
||||||
this.registryHealthLoading.set(false);
|
this.registryHealthLoading.set(false);
|
||||||
this.showError('Nexus-Status konnte nicht abgerufen werden.');
|
this.showError(this.languageService.translate('jobs.nexusError'));
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -279,7 +296,9 @@ export class JobsComponent implements OnInit {
|
|||||||
this.registryHealth.set(health);
|
this.registryHealth.set(health);
|
||||||
if (!health.reachable) {
|
if (!health.reachable) {
|
||||||
this.showError(
|
this.showError(
|
||||||
`Nexus-Registry nicht erreichbar: ${health.detail}. Die Image-Auswahl bleibt leer.`,
|
this.languageService.translate('jobs.registryDown', {
|
||||||
|
detail: health.detail,
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -299,11 +318,11 @@ export class JobsComponent implements OnInit {
|
|||||||
}));
|
}));
|
||||||
if (status === 'failed') {
|
if (status === 'failed') {
|
||||||
this.showError(
|
this.showError(
|
||||||
`„${task.name}“ ist fehlgeschlagen — Details in den Logs.`,
|
this.languageService.translate('jobs.runFailed', { name: task.name }),
|
||||||
);
|
);
|
||||||
this.refreshRegistryHealth();
|
this.refreshRegistryHealth();
|
||||||
} else {
|
} else {
|
||||||
this.snackBar.open(`„${task.name}“ wurde gestartet.`, 'OK', {
|
this.snackBar.open(this.languageService.translate('jobs.started', { name: task.name }), this.languageService.translate('common.ok'), {
|
||||||
duration: 3000,
|
duration: 3000,
|
||||||
horizontalPosition: 'center',
|
horizontalPosition: 'center',
|
||||||
verticalPosition: 'bottom',
|
verticalPosition: 'bottom',
|
||||||
@@ -314,8 +333,8 @@ export class JobsComponent implements OnInit {
|
|||||||
error: (error) =>
|
error: (error) =>
|
||||||
this.showError(
|
this.showError(
|
||||||
error.status === 409
|
error.status === 409
|
||||||
? `„${task.name}“ läuft bereits.`
|
? this.languageService.translate('jobs.alreadyRunning', { name: task.name })
|
||||||
: `„${task.name}“ konnte nicht gestartet werden.`,
|
: this.languageService.translate('jobs.startError', { name: task.name }),
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -340,9 +359,9 @@ export class JobsComponent implements OnInit {
|
|||||||
}));
|
}));
|
||||||
const message =
|
const message =
|
||||||
run.status === 'stopped'
|
run.status === 'stopped'
|
||||||
? `„${task.name}“ wurde gestoppt.`
|
? this.languageService.translate('jobs.stopped', { name: task.name })
|
||||||
: `„${task.name}“ war bereits beendet.`;
|
: this.languageService.translate('jobs.alreadyFinished', { name: task.name });
|
||||||
this.snackBar.open(message, 'OK', {
|
this.snackBar.open(message, this.languageService.translate('common.ok'), {
|
||||||
duration: 3000,
|
duration: 3000,
|
||||||
horizontalPosition: 'center',
|
horizontalPosition: 'center',
|
||||||
verticalPosition: 'bottom',
|
verticalPosition: 'bottom',
|
||||||
@@ -357,8 +376,8 @@ export class JobsComponent implements OnInit {
|
|||||||
}));
|
}));
|
||||||
this.showError(
|
this.showError(
|
||||||
error.status === 409
|
error.status === 409
|
||||||
? `„${task.name}“ läuft nicht.`
|
? this.languageService.translate('jobs.notRunning', { name: task.name })
|
||||||
: `„${task.name}“ konnte nicht gestoppt werden.`,
|
: this.languageService.translate('jobs.stopError', { name: task.name }),
|
||||||
);
|
);
|
||||||
this.refreshTasks();
|
this.refreshTasks();
|
||||||
},
|
},
|
||||||
@@ -394,7 +413,7 @@ export class JobsComponent implements OnInit {
|
|||||||
if (!task) return;
|
if (!task) return;
|
||||||
|
|
||||||
this.tasks.update((tasks) => [...tasks, task]);
|
this.tasks.update((tasks) => [...tasks, task]);
|
||||||
this.snackBar.open(`„${task.name}“ wurde angelegt.`, 'OK', {
|
this.snackBar.open(this.languageService.translate('jobs.created', { name: task.name }), this.languageService.translate('common.ok'), {
|
||||||
duration: 3000,
|
duration: 3000,
|
||||||
horizontalPosition: 'center',
|
horizontalPosition: 'center',
|
||||||
verticalPosition: 'bottom',
|
verticalPosition: 'bottom',
|
||||||
@@ -422,7 +441,7 @@ export class JobsComponent implements OnInit {
|
|||||||
if (!updatedTask) return;
|
if (!updatedTask) return;
|
||||||
|
|
||||||
this.updateTask(updatedTask.id, () => updatedTask);
|
this.updateTask(updatedTask.id, () => updatedTask);
|
||||||
this.snackBar.open(`„${updatedTask.name}“ wurde gespeichert.`, 'OK', {
|
this.snackBar.open(this.languageService.translate('jobs.saved', { name: updatedTask.name }), this.languageService.translate('common.ok'), {
|
||||||
duration: 3000,
|
duration: 3000,
|
||||||
horizontalPosition: 'center',
|
horizontalPosition: 'center',
|
||||||
verticalPosition: 'bottom',
|
verticalPosition: 'bottom',
|
||||||
@@ -452,7 +471,7 @@ export class JobsComponent implements OnInit {
|
|||||||
.subscribe({
|
.subscribe({
|
||||||
next: (updatedTask) => {
|
next: (updatedTask) => {
|
||||||
this.updateTask(result.taskId, () => updatedTask);
|
this.updateTask(result.taskId, () => updatedTask);
|
||||||
this.snackBar.open('Zeitplan wurde gespeichert.', 'OK', {
|
this.snackBar.open(this.languageService.translate('jobs.scheduleSaved'), this.languageService.translate('common.ok'), {
|
||||||
duration: 3000,
|
duration: 3000,
|
||||||
horizontalPosition: 'center',
|
horizontalPosition: 'center',
|
||||||
verticalPosition: 'bottom',
|
verticalPosition: 'bottom',
|
||||||
@@ -461,7 +480,7 @@ export class JobsComponent implements OnInit {
|
|||||||
error: (error) =>
|
error: (error) =>
|
||||||
this.showError(
|
this.showError(
|
||||||
error?.error?.detail ??
|
error?.error?.detail ??
|
||||||
'Zeitplan konnte nicht gespeichert werden.',
|
this.languageService.translate('jobs.scheduleSaveError'),
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -481,10 +500,10 @@ export class JobsComponent implements OnInit {
|
|||||||
width: '520px',
|
width: '520px',
|
||||||
maxWidth: 'calc(100vw - 32px)',
|
maxWidth: 'calc(100vw - 32px)',
|
||||||
data: {
|
data: {
|
||||||
title: 'Job löschen',
|
title: this.languageService.translate('jobs.delete'),
|
||||||
message: `Möchtest Du „${task.name}“ wirklich löschen? Alle Laufdaten und gespeicherten Logs werden dauerhaft gelöscht.`,
|
message: this.languageService.translate('jobs.deleteQuestion', { name: task.name }),
|
||||||
confirmText: 'Löschen',
|
confirmText: this.languageService.translate('common.remove'),
|
||||||
cancelText: 'Abbrechen',
|
cancelText: this.languageService.translate('common.cancel'),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -514,7 +533,7 @@ export class JobsComponent implements OnInit {
|
|||||||
this.tasks.update((tasks) =>
|
this.tasks.update((tasks) =>
|
||||||
tasks.filter((current) => current.id !== task.id),
|
tasks.filter((current) => current.id !== task.id),
|
||||||
);
|
);
|
||||||
this.snackBar.open(`„${task.name}“ wurde gelöscht.`, 'OK', {
|
this.snackBar.open(this.languageService.translate('jobs.deleted', { name: task.name }), this.languageService.translate('common.ok'), {
|
||||||
duration: 3000,
|
duration: 3000,
|
||||||
horizontalPosition: 'center',
|
horizontalPosition: 'center',
|
||||||
verticalPosition: 'bottom',
|
verticalPosition: 'bottom',
|
||||||
@@ -525,8 +544,8 @@ export class JobsComponent implements OnInit {
|
|||||||
this.finishDeletingTask(task.id);
|
this.finishDeletingTask(task.id);
|
||||||
this.showError(
|
this.showError(
|
||||||
error.status === 409
|
error.status === 409
|
||||||
? `„${task.name}“ läuft noch und kann nicht gelöscht werden.`
|
? this.languageService.translate('jobs.deleteRunningError', { name: task.name })
|
||||||
: `„${task.name}“ konnte nicht gelöscht werden.`,
|
: this.languageService.translate('jobs.deleteError', { name: task.name }),
|
||||||
);
|
);
|
||||||
this.refreshTasks();
|
this.refreshTasks();
|
||||||
},
|
},
|
||||||
@@ -552,10 +571,36 @@ export class JobsComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private showError(message: string): void {
|
private showError(message: string): void {
|
||||||
this.snackBar.open(message, 'OK', {
|
this.snackBar.open(message, this.languageService.translate('common.ok'), {
|
||||||
duration: 5000,
|
duration: 5000,
|
||||||
horizontalPosition: 'center',
|
horizontalPosition: 'center',
|
||||||
verticalPosition: 'bottom',
|
verticalPosition: 'bottom',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected statusMeta(status: string) {
|
||||||
|
const meta = statusMeta(status);
|
||||||
|
const keys: Record<string, 'jobs.statusRunning' | 'jobs.statusStopping' | 'jobs.statusSucceeded' | 'jobs.statusFailed' | 'jobs.statusStopped' | 'jobs.statusIdle'> = {
|
||||||
|
running: 'jobs.statusRunning', stopping: 'jobs.statusStopping',
|
||||||
|
succeeded: 'jobs.statusSucceeded', failed: 'jobs.statusFailed',
|
||||||
|
stopped: 'jobs.statusStopped', idle: 'jobs.statusIdle',
|
||||||
|
};
|
||||||
|
return { ...meta, label: this.languageService.translate(keys[status] ?? 'jobs.statusIdle') };
|
||||||
|
}
|
||||||
|
|
||||||
|
protected formatUtcDateAsLocal(value: string | null | undefined): string {
|
||||||
|
return formatUtcDateAsLocal(value, this.languageService.language() === 'de' ? 'de-DE' : 'en-US');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected nextRunLabel(value: string | null | undefined): string {
|
||||||
|
return this.languageService.translate('jobs.nextRun', { date: this.formatUtcDateAsLocal(value) });
|
||||||
|
}
|
||||||
|
|
||||||
|
protected runningSinceLabel(duration: string): string {
|
||||||
|
return this.languageService.translate('jobs.runningSince', { duration });
|
||||||
|
}
|
||||||
|
|
||||||
|
protected durationLabel(duration: string): string {
|
||||||
|
return this.languageService.translate('jobs.duration', { duration });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,9 +47,12 @@ export function toUtcMs(value: string): number {
|
|||||||
return new Date(appendUtcZ(value)).getTime();
|
return new Date(appendUtcZ(value)).getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function formatUtcDateAsLocal(value: string | null | undefined): string {
|
export function formatUtcDateAsLocal(
|
||||||
|
value: string | null | undefined,
|
||||||
|
locale = 'de-DE',
|
||||||
|
): string {
|
||||||
if (!value) return '';
|
if (!value) return '';
|
||||||
return new Intl.DateTimeFormat('de-DE', {
|
return new Intl.DateTimeFormat(locale, {
|
||||||
day: '2-digit',
|
day: '2-digit',
|
||||||
month: '2-digit',
|
month: '2-digit',
|
||||||
year: 'numeric',
|
year: 'numeric',
|
||||||
|
|||||||
@@ -1,23 +1,23 @@
|
|||||||
<h2 mat-dialog-title>Neuer Job</h2>
|
<h2 mat-dialog-title>{{ 'jobs.new' | translate }}</h2>
|
||||||
|
|
||||||
<mat-dialog-content>
|
<mat-dialog-content>
|
||||||
<form class="create-form" [formGroup]="form">
|
<form class="create-form" [formGroup]="form">
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<mat-label>Name</mat-label>
|
<mat-label>{{ 'jobs.name' | translate }}</mat-label>
|
||||||
<input matInput formControlName="name" />
|
<input matInput formControlName="name" />
|
||||||
<mat-icon
|
<mat-icon
|
||||||
matSuffix
|
matSuffix
|
||||||
class="field-info"
|
class="field-info"
|
||||||
matTooltip="Eindeutiger Anzeigename des Jobs, z.B. „News-Themen-Mapping (Testlauf)“."
|
[matTooltip]="'jobs.nameHelp' | translate"
|
||||||
>info_outline</mat-icon
|
>info_outline</mat-icon
|
||||||
>
|
>
|
||||||
@if (form.controls.name.invalid) {
|
@if (form.controls.name.invalid) {
|
||||||
<mat-error>Bitte einen Namen eingeben.</mat-error>
|
<mat-error>{{ 'jobs.nameRequired' | translate }}</mat-error>
|
||||||
}
|
}
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<mat-label>Befehl</mat-label>
|
<mat-label>{{ 'jobs.command' | translate }}</mat-label>
|
||||||
<textarea
|
<textarea
|
||||||
matInput
|
matInput
|
||||||
class="command-input"
|
class="command-input"
|
||||||
@@ -27,13 +27,13 @@
|
|||||||
<mat-icon
|
<mat-icon
|
||||||
matSuffix
|
matSuffix
|
||||||
class="field-info"
|
class="field-info"
|
||||||
matTooltip="Wird beim Start direkt im Container ausgeführt — wie in einem Terminal, z.B. „python sync.py --update-keywords --target-index docker-job_test“. Leer = Standard-Befehl des Images."
|
[matTooltip]="'jobs.commandHelp' | translate"
|
||||||
>info_outline</mat-icon
|
>info_outline</mat-icon
|
||||||
>
|
>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<mat-label>Image</mat-label>
|
<mat-label>{{ 'jobs.image' | translate }}</mat-label>
|
||||||
<input
|
<input
|
||||||
matInput
|
matInput
|
||||||
class="image-input"
|
class="image-input"
|
||||||
@@ -47,39 +47,39 @@
|
|||||||
<mat-icon
|
<mat-icon
|
||||||
matSuffix
|
matSuffix
|
||||||
class="field-info"
|
class="field-info"
|
||||||
matTooltip="Docker-Image für den Job. Tippen filtert die aus Nexus verfügbaren Images; du kannst auch einen eigenen Wert eingeben. Images aus unserer Registry (docker.nes.uni-due.de) erhalten die INSE-Zugangsdaten (Elasticsearch/LLM) automatisch, fremde Images nicht."
|
[matTooltip]="'jobs.imageHelp' | translate"
|
||||||
>info_outline</mat-icon
|
>info_outline</mat-icon
|
||||||
>
|
>
|
||||||
@if (form.controls.image.invalid && form.controls.image.touched) {
|
@if (form.controls.image.invalid && form.controls.image.touched) {
|
||||||
<mat-error>Bitte ein Image auswählen oder eingeben.</mat-error>
|
<mat-error>{{ 'jobs.imageRequired' | translate }}</mat-error>
|
||||||
}
|
}
|
||||||
<mat-hint>Aus Nexus wählen oder eigenes Image eingeben.</mat-hint>
|
<mat-hint>{{ 'jobs.imageHint' | translate }}</mat-hint>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<mat-label>Beschreibung (optional)</mat-label>
|
<mat-label>{{ 'jobs.descriptionOptional' | translate }}</mat-label>
|
||||||
<textarea matInput rows="2" formControlName="description"></textarea>
|
<textarea matInput rows="2" formControlName="description"></textarea>
|
||||||
<mat-icon
|
<mat-icon
|
||||||
matSuffix
|
matSuffix
|
||||||
class="field-info"
|
class="field-info"
|
||||||
matTooltip="Freitext für die Job-Tabelle: Was macht der Job, was sollte man vor dem Start wissen?"
|
[matTooltip]="'jobs.descriptionHelp' | translate"
|
||||||
>info_outline</mat-icon
|
>info_outline</mat-icon
|
||||||
>
|
>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<mat-label>Ziel-Index (optional)</mat-label>
|
<mat-label>{{ 'jobs.targetIndexOptional' | translate }}</mat-label>
|
||||||
<input matInput formControlName="targetIndex" />
|
<input matInput formControlName="targetIndex" />
|
||||||
<mat-icon
|
<mat-icon
|
||||||
matSuffix
|
matSuffix
|
||||||
class="field-info"
|
class="field-info"
|
||||||
matTooltip="Reine Anzeige-Info in der Tabelle. In welchen Index der Job wirklich schreibt, bestimmt allein der Befehl (z.B. --target-index / --output-index)."
|
[matTooltip]="'jobs.targetHelp' | translate"
|
||||||
>info_outline</mat-icon
|
>info_outline</mat-icon
|
||||||
>
|
>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<mat-label>Umgebungsvariablen (optional)</mat-label>
|
<mat-label>{{ 'jobs.environmentOptional' | translate }}</mat-label>
|
||||||
<textarea
|
<textarea
|
||||||
matInput
|
matInput
|
||||||
rows="3"
|
rows="3"
|
||||||
@@ -88,12 +88,12 @@
|
|||||||
<mat-icon
|
<mat-icon
|
||||||
matSuffix
|
matSuffix
|
||||||
class="field-info"
|
class="field-info"
|
||||||
matTooltip="Zusätzliche Umgebungsvariablen für den Container, eine pro Zeile im Format KEY=value. Das Standard-Image bekommt die INSE-Zugangsdaten (Elasticsearch/LLM) automatisch — hier ist nur Spezielles nötig."
|
[matTooltip]="'jobs.envHelp' | translate"
|
||||||
>info_outline</mat-icon
|
>info_outline</mat-icon
|
||||||
>
|
>
|
||||||
<mat-hint>Eine Variable pro Zeile im Format KEY=value.</mat-hint>
|
<mat-hint>{{ 'jobs.envHint' | translate }}</mat-hint>
|
||||||
@if (form.controls.env.hasError('invalidEnv')) {
|
@if (form.controls.env.hasError('invalidEnv')) {
|
||||||
<mat-error>Ungültige Zeile — Format: KEY=value.</mat-error>
|
<mat-error>{{ 'jobs.envInvalid' | translate }}</mat-error>
|
||||||
}
|
}
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</form>
|
</form>
|
||||||
@@ -104,7 +104,7 @@
|
|||||||
</mat-dialog-content>
|
</mat-dialog-content>
|
||||||
|
|
||||||
<mat-dialog-actions align="end">
|
<mat-dialog-actions align="end">
|
||||||
<button mat-button type="button" (click)="close()">Abbrechen</button>
|
<button mat-button type="button" (click)="close()">{{ 'common.cancel' | translate }}</button>
|
||||||
<button
|
<button
|
||||||
mat-flat-button
|
mat-flat-button
|
||||||
color="primary"
|
color="primary"
|
||||||
@@ -112,6 +112,6 @@
|
|||||||
[disabled]="creating()"
|
[disabled]="creating()"
|
||||||
(click)="submit()">
|
(click)="submit()">
|
||||||
<mat-icon>add</mat-icon>
|
<mat-icon>add</mat-icon>
|
||||||
Anlegen
|
{{ 'jobs.create' | translate }}
|
||||||
</button>
|
</button>
|
||||||
</mat-dialog-actions>
|
</mat-dialog-actions>
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ import { MatIconModule } from '@angular/material/icon';
|
|||||||
import { MatInputModule } from '@angular/material/input';
|
import { MatInputModule } from '@angular/material/input';
|
||||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||||
import { BackgroundJobTask, BackgroundJobsService } from '../../../api';
|
import { BackgroundJobTask, BackgroundJobsService } from '../../../api';
|
||||||
|
import { LanguageService } from '../../../shared/i18n/language.service';
|
||||||
|
import { TranslatePipe } from '../../../shared/i18n/translate.pipe';
|
||||||
|
|
||||||
const ENV_LINE_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*=.*$/;
|
const ENV_LINE_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*=.*$/;
|
||||||
|
|
||||||
@@ -30,6 +32,7 @@ const ENV_LINE_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*=.*$/;
|
|||||||
MatIconModule,
|
MatIconModule,
|
||||||
MatInputModule,
|
MatInputModule,
|
||||||
MatTooltipModule,
|
MatTooltipModule,
|
||||||
|
TranslatePipe,
|
||||||
],
|
],
|
||||||
templateUrl: './task-create-dialog.component.html',
|
templateUrl: './task-create-dialog.component.html',
|
||||||
styleUrl: './task-create-dialog.component.scss',
|
styleUrl: './task-create-dialog.component.scss',
|
||||||
@@ -41,6 +44,7 @@ export class TaskCreateDialogComponent implements OnInit {
|
|||||||
MatDialogRef<TaskCreateDialogComponent, BackgroundJobTask | undefined>
|
MatDialogRef<TaskCreateDialogComponent, BackgroundJobTask | undefined>
|
||||||
>(MatDialogRef);
|
>(MatDialogRef);
|
||||||
private readonly backgroundJobsService = inject(BackgroundJobsService);
|
private readonly backgroundJobsService = inject(BackgroundJobsService);
|
||||||
|
private readonly languageService = inject(LanguageService);
|
||||||
|
|
||||||
protected readonly creating = signal(false);
|
protected readonly creating = signal(false);
|
||||||
protected readonly serverError = signal('');
|
protected readonly serverError = signal('');
|
||||||
@@ -119,7 +123,7 @@ export class TaskCreateDialogComponent implements OnInit {
|
|||||||
this.serverError.set(
|
this.serverError.set(
|
||||||
typeof detail === 'string'
|
typeof detail === 'string'
|
||||||
? detail
|
? detail
|
||||||
: 'Der Job konnte nicht angelegt werden.',
|
: this.languageService.translate('jobs.createError'),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,23 +1,23 @@
|
|||||||
<h2 mat-dialog-title>Job bearbeiten</h2>
|
<h2 mat-dialog-title>{{ 'jobs.edit' | translate }}</h2>
|
||||||
|
|
||||||
<mat-dialog-content>
|
<mat-dialog-content>
|
||||||
<form class="edit-form" [formGroup]="form">
|
<form class="edit-form" [formGroup]="form">
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<mat-label>Name</mat-label>
|
<mat-label>{{ 'jobs.name' | translate }}</mat-label>
|
||||||
<input matInput formControlName="name" />
|
<input matInput formControlName="name" />
|
||||||
<mat-icon
|
<mat-icon
|
||||||
matSuffix
|
matSuffix
|
||||||
class="field-info"
|
class="field-info"
|
||||||
matTooltip="Eindeutiger Anzeigename des Jobs, z.B. „News-Themen-Mapping (Testlauf)“."
|
[matTooltip]="'jobs.nameHelp' | translate"
|
||||||
>info_outline</mat-icon
|
>info_outline</mat-icon
|
||||||
>
|
>
|
||||||
@if (form.controls.name.invalid) {
|
@if (form.controls.name.invalid) {
|
||||||
<mat-error>Bitte einen Namen eingeben.</mat-error>
|
<mat-error>{{ 'jobs.nameRequired' | translate }}</mat-error>
|
||||||
}
|
}
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<mat-label>Befehl</mat-label>
|
<mat-label>{{ 'jobs.command' | translate }}</mat-label>
|
||||||
<textarea
|
<textarea
|
||||||
matInput
|
matInput
|
||||||
class="command-input"
|
class="command-input"
|
||||||
@@ -27,13 +27,13 @@
|
|||||||
<mat-icon
|
<mat-icon
|
||||||
matSuffix
|
matSuffix
|
||||||
class="field-info"
|
class="field-info"
|
||||||
matTooltip="Wird beim Start direkt im Container ausgeführt — wie in einem Terminal, z.B. „python sync.py --update-keywords --target-index docker-job_test“. Leer = Standard-Befehl des Images."
|
[matTooltip]="'jobs.commandHelp' | translate"
|
||||||
>info_outline</mat-icon
|
>info_outline</mat-icon
|
||||||
>
|
>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<mat-label>Image</mat-label>
|
<mat-label>{{ 'jobs.image' | translate }}</mat-label>
|
||||||
<input
|
<input
|
||||||
matInput
|
matInput
|
||||||
class="image-input"
|
class="image-input"
|
||||||
@@ -47,39 +47,39 @@
|
|||||||
<mat-icon
|
<mat-icon
|
||||||
matSuffix
|
matSuffix
|
||||||
class="field-info"
|
class="field-info"
|
||||||
matTooltip="Docker-Image für den Job. Tippen filtert die aus Nexus verfügbaren Images; du kannst auch einen eigenen Wert eingeben. Images aus unserer Registry (docker.nes.uni-due.de) erhalten die INSE-Zugangsdaten (Elasticsearch/LLM) automatisch, fremde Images nicht."
|
[matTooltip]="'jobs.imageHelp' | translate"
|
||||||
>info_outline</mat-icon
|
>info_outline</mat-icon
|
||||||
>
|
>
|
||||||
@if (form.controls.image.invalid && form.controls.image.touched) {
|
@if (form.controls.image.invalid && form.controls.image.touched) {
|
||||||
<mat-error>Bitte ein Image auswählen oder eingeben.</mat-error>
|
<mat-error>{{ 'jobs.imageRequired' | translate }}</mat-error>
|
||||||
}
|
}
|
||||||
<mat-hint>Aus Nexus wählen oder eigenes Image eingeben.</mat-hint>
|
<mat-hint>{{ 'jobs.imageHint' | translate }}</mat-hint>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<mat-label>Beschreibung (optional)</mat-label>
|
<mat-label>{{ 'jobs.descriptionOptional' | translate }}</mat-label>
|
||||||
<textarea matInput rows="2" formControlName="description"></textarea>
|
<textarea matInput rows="2" formControlName="description"></textarea>
|
||||||
<mat-icon
|
<mat-icon
|
||||||
matSuffix
|
matSuffix
|
||||||
class="field-info"
|
class="field-info"
|
||||||
matTooltip="Freitext für die Job-Tabelle: Was macht der Job, was sollte man vor dem Start wissen?"
|
[matTooltip]="'jobs.descriptionHelp' | translate"
|
||||||
>info_outline</mat-icon
|
>info_outline</mat-icon
|
||||||
>
|
>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<mat-label>Ziel-Index (optional)</mat-label>
|
<mat-label>{{ 'jobs.targetIndexOptional' | translate }}</mat-label>
|
||||||
<input matInput formControlName="targetIndex" />
|
<input matInput formControlName="targetIndex" />
|
||||||
<mat-icon
|
<mat-icon
|
||||||
matSuffix
|
matSuffix
|
||||||
class="field-info"
|
class="field-info"
|
||||||
matTooltip="Reine Anzeige-Info in der Tabelle. In welchen Index der Job wirklich schreibt, bestimmt allein der Befehl (z.B. --target-index / --output-index)."
|
[matTooltip]="'jobs.targetHelp' | translate"
|
||||||
>info_outline</mat-icon
|
>info_outline</mat-icon
|
||||||
>
|
>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<mat-label>Umgebungsvariablen (optional)</mat-label>
|
<mat-label>{{ 'jobs.environmentOptional' | translate }}</mat-label>
|
||||||
<textarea
|
<textarea
|
||||||
matInput
|
matInput
|
||||||
rows="3"
|
rows="3"
|
||||||
@@ -88,12 +88,12 @@
|
|||||||
<mat-icon
|
<mat-icon
|
||||||
matSuffix
|
matSuffix
|
||||||
class="field-info"
|
class="field-info"
|
||||||
matTooltip="Zusätzliche Umgebungsvariablen für den Container, eine pro Zeile im Format KEY=value. Das Standard-Image bekommt die INSE-Zugangsdaten (Elasticsearch/LLM) automatisch — hier ist nur Spezielles nötig."
|
[matTooltip]="'jobs.envHelp' | translate"
|
||||||
>info_outline</mat-icon
|
>info_outline</mat-icon
|
||||||
>
|
>
|
||||||
<mat-hint>Eine Variable pro Zeile im Format KEY=value.</mat-hint>
|
<mat-hint>{{ 'jobs.envHint' | translate }}</mat-hint>
|
||||||
@if (form.controls.env.hasError('invalidEnv')) {
|
@if (form.controls.env.hasError('invalidEnv')) {
|
||||||
<mat-error>Ungültige Zeile — Format: KEY=value.</mat-error>
|
<mat-error>{{ 'jobs.envInvalid' | translate }}</mat-error>
|
||||||
}
|
}
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</form>
|
</form>
|
||||||
@@ -104,7 +104,7 @@
|
|||||||
</mat-dialog-content>
|
</mat-dialog-content>
|
||||||
|
|
||||||
<mat-dialog-actions align="end">
|
<mat-dialog-actions align="end">
|
||||||
<button mat-button type="button" (click)="close()">Abbrechen</button>
|
<button mat-button type="button" (click)="close()">{{ 'common.cancel' | translate }}</button>
|
||||||
<button
|
<button
|
||||||
mat-flat-button
|
mat-flat-button
|
||||||
color="primary"
|
color="primary"
|
||||||
@@ -112,6 +112,6 @@
|
|||||||
[disabled]="saving()"
|
[disabled]="saving()"
|
||||||
(click)="submit()">
|
(click)="submit()">
|
||||||
<mat-icon>save</mat-icon>
|
<mat-icon>save</mat-icon>
|
||||||
Speichern
|
{{ 'common.save' | translate }}
|
||||||
</button>
|
</button>
|
||||||
</mat-dialog-actions>
|
</mat-dialog-actions>
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ import { MatIconModule } from '@angular/material/icon';
|
|||||||
import { MatInputModule } from '@angular/material/input';
|
import { MatInputModule } from '@angular/material/input';
|
||||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||||
import { BackgroundJobTask, BackgroundJobsService } from '../../../api';
|
import { BackgroundJobTask, BackgroundJobsService } from '../../../api';
|
||||||
|
import { LanguageService } from '../../../shared/i18n/language.service';
|
||||||
|
import { TranslatePipe } from '../../../shared/i18n/translate.pipe';
|
||||||
|
|
||||||
const ENV_LINE_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*=.*$/;
|
const ENV_LINE_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*=.*$/;
|
||||||
|
|
||||||
@@ -38,6 +40,7 @@ export interface TaskEditDialogData {
|
|||||||
MatIconModule,
|
MatIconModule,
|
||||||
MatInputModule,
|
MatInputModule,
|
||||||
MatTooltipModule,
|
MatTooltipModule,
|
||||||
|
TranslatePipe,
|
||||||
],
|
],
|
||||||
templateUrl: './task-edit-dialog.component.html',
|
templateUrl: './task-edit-dialog.component.html',
|
||||||
styleUrl: './task-edit-dialog.component.scss',
|
styleUrl: './task-edit-dialog.component.scss',
|
||||||
@@ -49,6 +52,7 @@ export class TaskEditDialogComponent implements OnInit {
|
|||||||
MatDialogRef<TaskEditDialogComponent, BackgroundJobTask | undefined>
|
MatDialogRef<TaskEditDialogComponent, BackgroundJobTask | undefined>
|
||||||
>(MatDialogRef);
|
>(MatDialogRef);
|
||||||
private readonly backgroundJobsService = inject(BackgroundJobsService);
|
private readonly backgroundJobsService = inject(BackgroundJobsService);
|
||||||
|
private readonly languageService = inject(LanguageService);
|
||||||
protected readonly data = inject<TaskEditDialogData>(MAT_DIALOG_DATA);
|
protected readonly data = inject<TaskEditDialogData>(MAT_DIALOG_DATA);
|
||||||
|
|
||||||
protected readonly saving = signal(false);
|
protected readonly saving = signal(false);
|
||||||
@@ -135,7 +139,7 @@ export class TaskEditDialogComponent implements OnInit {
|
|||||||
this.serverError.set(
|
this.serverError.set(
|
||||||
typeof detail === 'string'
|
typeof detail === 'string'
|
||||||
? detail
|
? detail
|
||||||
: 'Der Job konnte nicht gespeichert werden.',
|
: this.languageService.translate('jobs.saveError'),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
+23
-23
@@ -5,30 +5,30 @@
|
|||||||
|
|
||||||
<form class="schedule-form" [formGroup]="form">
|
<form class="schedule-form" [formGroup]="form">
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<mat-label>Ausführung</mat-label>
|
<mat-label>{{ 'jobs.scheduleExecution' | translate }}</mat-label>
|
||||||
<mat-select formControlName="mode" panelClass="schedule-mode-panel">
|
<mat-select formControlName="mode" panelClass="schedule-mode-panel">
|
||||||
<mat-option value="manual">Nur manuell</mat-option>
|
<mat-option value="manual">{{ 'jobs.manualOnly' | translate }}</mat-option>
|
||||||
<mat-option value="hourly">Stündlich</mat-option>
|
<mat-option value="hourly">{{ 'jobs.hourly' | translate }}</mat-option>
|
||||||
<mat-option value="daily">Täglich</mat-option>
|
<mat-option value="daily">{{ 'jobs.daily' | translate }}</mat-option>
|
||||||
<mat-option value="weekly">Wöchentlich</mat-option>
|
<mat-option value="weekly">{{ 'jobs.weekly' | translate }}</mat-option>
|
||||||
<mat-option value="monthly">Monatlich</mat-option>
|
<mat-option value="monthly">{{ 'jobs.monthly' | translate }}</mat-option>
|
||||||
<mat-option value="advanced">Erweiterter Cron-Ausdruck</mat-option>
|
<mat-option value="advanced">{{ 'jobs.advancedCron' | translate }}</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
@switch (form.controls.mode.value) {
|
@switch (form.controls.mode.value) {
|
||||||
@case ('hourly') {
|
@case ('hourly') {
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<mat-label>Minute der Stunde</mat-label>
|
<mat-label>{{ 'jobs.minute' | translate }}</mat-label>
|
||||||
<input
|
<input
|
||||||
matInput
|
matInput
|
||||||
type="number"
|
type="number"
|
||||||
min="0"
|
min="0"
|
||||||
max="59"
|
max="59"
|
||||||
formControlName="minute" />
|
formControlName="minute" />
|
||||||
<mat-hint>Angabe in UTC, zwischen 0 und 59.</mat-hint>
|
<mat-hint>{{ 'jobs.minuteHint' | translate }}</mat-hint>
|
||||||
@if (form.controls.minute.invalid) {
|
@if (form.controls.minute.invalid) {
|
||||||
<mat-error>Bitte eine Minute zwischen 0 und 59 eingeben.</mat-error>
|
<mat-error>{{ 'jobs.minuteError' | translate }}</mat-error>
|
||||||
}
|
}
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
}
|
}
|
||||||
@@ -38,9 +38,9 @@
|
|||||||
@case ('weekly') {
|
@case ('weekly') {
|
||||||
<div class="schedule-fields">
|
<div class="schedule-fields">
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<mat-label>Wochentag</mat-label>
|
<mat-label>{{ 'jobs.weekday' | translate }}</mat-label>
|
||||||
<mat-select formControlName="weekday">
|
<mat-select formControlName="weekday">
|
||||||
@for (weekday of weekdays; track weekday.value) {
|
@for (weekday of weekdays(); track weekday.value) {
|
||||||
<mat-option [value]="weekday.value">
|
<mat-option [value]="weekday.value">
|
||||||
{{ weekday.label }}
|
{{ weekday.label }}
|
||||||
</mat-option>
|
</mat-option>
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
@case ('monthly') {
|
@case ('monthly') {
|
||||||
<div class="schedule-fields">
|
<div class="schedule-fields">
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<mat-label>Tag des Monats</mat-label>
|
<mat-label>{{ 'jobs.monthDay' | translate }}</mat-label>
|
||||||
<input
|
<input
|
||||||
matInput
|
matInput
|
||||||
type="number"
|
type="number"
|
||||||
@@ -61,7 +61,7 @@
|
|||||||
max="31"
|
max="31"
|
||||||
formControlName="monthDay" />
|
formControlName="monthDay" />
|
||||||
@if (form.controls.monthDay.invalid) {
|
@if (form.controls.monthDay.invalid) {
|
||||||
<mat-error>Bitte einen Tag zwischen 1 und 31 eingeben.</mat-error>
|
<mat-error>{{ 'jobs.monthDayError' | translate }}</mat-error>
|
||||||
}
|
}
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<ng-container *ngTemplateOutlet="timeField"></ng-container>
|
<ng-container *ngTemplateOutlet="timeField"></ng-container>
|
||||||
@@ -72,14 +72,14 @@
|
|||||||
}
|
}
|
||||||
@case ('advanced') {
|
@case ('advanced') {
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<mat-label>Cron-Ausdruck (UTC)</mat-label>
|
<mat-label>{{ 'jobs.cron' | translate }}</mat-label>
|
||||||
<input
|
<input
|
||||||
matInput
|
matInput
|
||||||
formControlName="cronExpression"
|
formControlName="cronExpression"
|
||||||
placeholder="0 3 * * *" />
|
placeholder="0 3 * * *" />
|
||||||
<mat-hint>Minute · Stunde · Tag · Monat · Wochentag</mat-hint>
|
<mat-hint>{{ 'jobs.cronHint' | translate }}</mat-hint>
|
||||||
@if (form.controls.cronExpression.hasError('invalidCron')) {
|
@if (form.controls.cronExpression.hasError('invalidCron')) {
|
||||||
<mat-error>Ungültiger Cron-Ausdruck, z. B. „0 3 * * *“.</mat-error>
|
<mat-error>{{ 'jobs.cronError' | translate }}</mat-error>
|
||||||
}
|
}
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
}
|
}
|
||||||
@@ -92,12 +92,12 @@
|
|||||||
class="enabled-toggle"
|
class="enabled-toggle"
|
||||||
[class.enabled-toggle--on]="form.controls.enabled.value"
|
[class.enabled-toggle--on]="form.controls.enabled.value"
|
||||||
[attr.aria-checked]="form.controls.enabled.value"
|
[attr.aria-checked]="form.controls.enabled.value"
|
||||||
aria-label="Automatische Ausführung"
|
[attr.aria-label]="'jobs.autoExecution' | translate"
|
||||||
(click)="form.controls.enabled.setValue(!form.controls.enabled.value)">
|
(click)="form.controls.enabled.setValue(!form.controls.enabled.value)">
|
||||||
<span class="enabled-toggle__track">
|
<span class="enabled-toggle__track">
|
||||||
<span class="enabled-toggle__thumb"></span>
|
<span class="enabled-toggle__thumb"></span>
|
||||||
</span>
|
</span>
|
||||||
<span class="enabled-toggle__label">Automatische Ausführung aktiv</span>
|
<span class="enabled-toggle__label">{{ 'jobs.autoExecutionActive' | translate }}</span>
|
||||||
</button>
|
</button>
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,10 +110,10 @@
|
|||||||
|
|
||||||
<ng-template #timeField>
|
<ng-template #timeField>
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<mat-label>Uhrzeit (UTC)</mat-label>
|
<mat-label>{{ 'jobs.timeUtc' | translate }}</mat-label>
|
||||||
<input matInput type="time" formControlName="time" />
|
<input matInput type="time" formControlName="time" />
|
||||||
@if (form.controls.time.invalid) {
|
@if (form.controls.time.invalid) {
|
||||||
<mat-error>Bitte eine gültige Uhrzeit eingeben.</mat-error>
|
<mat-error>{{ 'jobs.timeError' | translate }}</mat-error>
|
||||||
}
|
}
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
@@ -121,9 +121,9 @@
|
|||||||
</mat-dialog-content>
|
</mat-dialog-content>
|
||||||
|
|
||||||
<mat-dialog-actions align="end">
|
<mat-dialog-actions align="end">
|
||||||
<button mat-button type="button" (click)="close()">Abbrechen</button>
|
<button mat-button type="button" (click)="close()">{{ 'common.cancel' | translate }}</button>
|
||||||
<button mat-flat-button color="primary" type="button" (click)="submit()">
|
<button mat-flat-button color="primary" type="button" (click)="submit()">
|
||||||
<mat-icon>save</mat-icon>
|
<mat-icon>save</mat-icon>
|
||||||
Speichern
|
{{ 'common.save' | translate }}
|
||||||
</button>
|
</button>
|
||||||
</mat-dialog-actions>
|
</mat-dialog-actions>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { Component, inject } from '@angular/core';
|
import { Component, computed, inject } from '@angular/core';
|
||||||
import {
|
import {
|
||||||
FormControl,
|
FormControl,
|
||||||
FormGroup,
|
FormGroup,
|
||||||
@@ -18,6 +18,8 @@ import { MatInputModule } from '@angular/material/input';
|
|||||||
import { MatSelectModule } from '@angular/material/select';
|
import { MatSelectModule } from '@angular/material/select';
|
||||||
import { BackgroundJobTask } from '../../../api';
|
import { BackgroundJobTask } from '../../../api';
|
||||||
import { formatUtcDateAsLocal } from '../jobs.utils';
|
import { formatUtcDateAsLocal } from '../jobs.utils';
|
||||||
|
import { LanguageService } from '../../../shared/i18n/language.service';
|
||||||
|
import { TranslatePipe } from '../../../shared/i18n/translate.pipe';
|
||||||
|
|
||||||
export interface TaskScheduleDialogData {
|
export interface TaskScheduleDialogData {
|
||||||
task: BackgroundJobTask;
|
task: BackgroundJobTask;
|
||||||
@@ -121,12 +123,14 @@ function toTime(hour: string, minute: string): string {
|
|||||||
MatIconModule,
|
MatIconModule,
|
||||||
MatInputModule,
|
MatInputModule,
|
||||||
MatSelectModule,
|
MatSelectModule,
|
||||||
|
TranslatePipe,
|
||||||
],
|
],
|
||||||
templateUrl: './task-schedule-dialog.component.html',
|
templateUrl: './task-schedule-dialog.component.html',
|
||||||
styleUrl: './task-schedule-dialog.component.scss',
|
styleUrl: './task-schedule-dialog.component.scss',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
})
|
})
|
||||||
export class TaskScheduleDialogComponent {
|
export class TaskScheduleDialogComponent {
|
||||||
|
private readonly languageService = inject(LanguageService);
|
||||||
private readonly dialogRef =
|
private readonly dialogRef =
|
||||||
inject<
|
inject<
|
||||||
MatDialogRef<
|
MatDialogRef<
|
||||||
@@ -135,7 +139,19 @@ export class TaskScheduleDialogComponent {
|
|||||||
>
|
>
|
||||||
>(MatDialogRef);
|
>(MatDialogRef);
|
||||||
protected readonly data = inject<TaskScheduleDialogData>(MAT_DIALOG_DATA);
|
protected readonly data = inject<TaskScheduleDialogData>(MAT_DIALOG_DATA);
|
||||||
protected readonly weekdays = WEEKDAYS;
|
protected readonly weekdays = computed(() =>
|
||||||
|
WEEKDAYS.map((day, index) => ({
|
||||||
|
...day,
|
||||||
|
label: this.languageService.translate(
|
||||||
|
[
|
||||||
|
'jobs.monday', 'jobs.tuesday', 'jobs.wednesday', 'jobs.thursday',
|
||||||
|
'jobs.friday', 'jobs.saturday', 'jobs.sunday',
|
||||||
|
][index] as
|
||||||
|
| 'jobs.monday' | 'jobs.tuesday' | 'jobs.wednesday'
|
||||||
|
| 'jobs.thursday' | 'jobs.friday' | 'jobs.saturday' | 'jobs.sunday',
|
||||||
|
),
|
||||||
|
})),
|
||||||
|
);
|
||||||
protected readonly formatUtcDateAsLocal = formatUtcDateAsLocal;
|
protected readonly formatUtcDateAsLocal = formatUtcDateAsLocal;
|
||||||
|
|
||||||
private readonly initialSchedule = parseSchedule(this.data.task.schedule);
|
private readonly initialSchedule = parseSchedule(this.data.task.schedule);
|
||||||
|
|||||||
+86
-83
@@ -1,63 +1,46 @@
|
|||||||
@if (loading()) {
|
@if (loading()) {
|
||||||
<app-loading
|
<div class="patents-container">
|
||||||
text="Patentdaten werden geladen..."
|
<ng-container *ngTemplateOutlet="patentsHeader" />
|
||||||
icon="workspace_premium"
|
<app-loading
|
||||||
[size]="150"
|
text="Patentdaten werden geladen..."
|
||||||
[diameter]="150" />
|
icon="workspace_premium"
|
||||||
|
[size]="150"
|
||||||
|
[diameter]="150" />
|
||||||
|
</div>
|
||||||
} @else if (error()) {
|
} @else if (error()) {
|
||||||
<p class="message">Fehler beim Laden der Patente.</p>
|
<div class="patents-container">
|
||||||
|
<ng-container *ngTemplateOutlet="patentsHeader" />
|
||||||
|
<p class="message">Fehler beim Laden der Patente.</p>
|
||||||
|
</div>
|
||||||
} @else if (matches().length === 0) {
|
} @else if (matches().length === 0) {
|
||||||
<p class="message">{{ emptyMessage() }}</p>
|
<div class="patents-container">
|
||||||
|
<ng-container *ngTemplateOutlet="patentsHeader" />
|
||||||
|
<p class="message">{{ emptyMessage() }}</p>
|
||||||
|
</div>
|
||||||
} @else {
|
} @else {
|
||||||
<div class="patents-container">
|
<div class="patents-container">
|
||||||
|
<ng-container *ngTemplateOutlet="patentsHeader" />
|
||||||
|
|
||||||
<div class="patents-content">
|
<div class="patents-content">
|
||||||
<div class="patents-list">
|
<div class="patents-list">
|
||||||
<div class="patents-list-toolbar">
|
|
||||||
<mat-form-field
|
|
||||||
class="patents-toolbar-field"
|
|
||||||
subscriptSizing="dynamic">
|
|
||||||
<mat-icon matPrefix fontIcon="filter_alt"></mat-icon>
|
|
||||||
<mat-select
|
|
||||||
[value]="activeFilter()"
|
|
||||||
(selectionChange)="setFilter($event.value)">
|
|
||||||
<mat-select-trigger>Filter nach Quelle</mat-select-trigger>
|
|
||||||
<mat-option value="all">Alle</mat-option>
|
|
||||||
<mat-option value="EPO">EPO</mat-option>
|
|
||||||
<mat-option value="USPTO">USPTO</mat-option>
|
|
||||||
</mat-select>
|
|
||||||
</mat-form-field>
|
|
||||||
<mat-form-field
|
|
||||||
class="patents-toolbar-field"
|
|
||||||
subscriptSizing="dynamic">
|
|
||||||
<mat-icon matPrefix fontIcon="sort"></mat-icon>
|
|
||||||
<mat-select
|
|
||||||
[value]="sortMode()"
|
|
||||||
(selectionChange)="setSortMode($event.value)">
|
|
||||||
<mat-select-trigger>Sortieren nach</mat-select-trigger>
|
|
||||||
<mat-option value="date">Datum</mat-option>
|
|
||||||
<mat-option value="title">Titel</mat-option>
|
|
||||||
</mat-select>
|
|
||||||
</mat-form-field>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Patent</th>
|
<th>Patent</th>
|
||||||
|
<th>Score</th>
|
||||||
<th>Quelle</th>
|
<th>Quelle</th>
|
||||||
<th>Jahr</th>
|
<th>Jahr</th>
|
||||||
<th>Erfinder</th>
|
|
||||||
<th>Anmelder</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@for (item of getPagedMatches(); track trackMatch($index, item)) {
|
@for (item of pagedMatches(); track trackMatch($index, item)) {
|
||||||
<tr
|
<tr
|
||||||
[class.selected]="selectedMatch() === item"
|
[class.selected]="selectedMatch() === item"
|
||||||
(click)="selectMatch(item)">
|
(click)="selectMatch(item)">
|
||||||
<td class="patent-title">
|
<td class="patent-title">
|
||||||
{{ item.patent.title ?? item.patent.patent_id }}
|
{{ item.patent.title ?? item.patent.patent_id }}
|
||||||
</td>
|
</td>
|
||||||
|
<td class="match-score">{{ formatScore(item.match_score) }}</td>
|
||||||
<td>
|
<td>
|
||||||
<span
|
<span
|
||||||
class="source-badge source-badge--{{
|
class="source-badge source-badge--{{
|
||||||
@@ -67,33 +50,50 @@
|
|||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td>{{ item.patent.publication_year ?? '-' }}</td>
|
<td>{{ item.patent.publication_year ?? '-' }}</td>
|
||||||
<td
|
|
||||||
class="patent-people"
|
|
||||||
[title]="getInventorsLabel(item.patent)">
|
|
||||||
{{ getInventorsLabel(item.patent) }}
|
|
||||||
</td>
|
|
||||||
<td
|
|
||||||
class="patent-people"
|
|
||||||
[title]="getAssigneesLabel(item.patent)">
|
|
||||||
{{ getAssigneesLabel(item.patent) }}
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<app-query-param-paginator
|
@if (hasPagination()) {
|
||||||
[total]="filteredMatches().length"
|
<div class="pagination">
|
||||||
queryParamPageKey="page"
|
<button
|
||||||
queryParamSizeKey="size"
|
[disabled]="selectedPage() === 1"
|
||||||
[pageSizeOptions]="[10, 25, 50]"
|
(click)="setPage(selectedPage() - 1)">
|
||||||
(handlePageChange)="onPatentPageChange($event)" />
|
Zurück
|
||||||
|
</button>
|
||||||
|
<span>Seite {{ selectedPage() }} von {{ pageCount() }}</span>
|
||||||
|
<button
|
||||||
|
[disabled]="selectedPage() === pageCount()"
|
||||||
|
(click)="setPage(selectedPage() + 1)">
|
||||||
|
Weiter
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if (selectedMatch(); as match) {
|
@if (selectedMatch(); as match) {
|
||||||
<div class="patent-detail">
|
<div class="patent-detail">
|
||||||
<h3>{{ match.patent.title ?? match.patent.patent_id }}</h3>
|
<h3>{{ match.patent.title ?? match.patent.patent_id }}</h3>
|
||||||
<div class="detail-stats">
|
<div class="detail-stats">
|
||||||
|
<div class="stat">
|
||||||
|
<span class="stat-label">Match-Score</span>
|
||||||
|
<span class="stat-value">{{
|
||||||
|
formatScore(match.match_score)
|
||||||
|
}}</span>
|
||||||
|
</div>
|
||||||
|
<div class="stat">
|
||||||
|
<span class="stat-label">Gematchte Keywords</span>
|
||||||
|
<span class="stat-value">{{
|
||||||
|
formatMatchList(match.matched_keywords)
|
||||||
|
}}</span>
|
||||||
|
</div>
|
||||||
|
<div class="stat">
|
||||||
|
<span class="stat-label">Gematchte IPC/CPC</span>
|
||||||
|
<span class="stat-value">{{
|
||||||
|
formatMatchList(match.matched_ipc_symbols)
|
||||||
|
}}</span>
|
||||||
|
</div>
|
||||||
<div class="stat">
|
<div class="stat">
|
||||||
<span class="stat-label">Quelle</span>
|
<span class="stat-label">Quelle</span>
|
||||||
<span class="stat-value">
|
<span class="stat-value">
|
||||||
@@ -123,10 +123,6 @@
|
|||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if (getAbstractPreview(match.patent.abstract); as abstractPreview) {
|
|
||||||
<p class="patent-detail-preview">{{ abstractPreview }}</p>
|
|
||||||
}
|
|
||||||
|
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="patent-detail-action"
|
class="patent-detail-action"
|
||||||
@@ -136,33 +132,40 @@
|
|||||||
>
|
>
|
||||||
<mat-icon aria-hidden="true">chevron_right</mat-icon>
|
<mat-icon aria-hidden="true">chevron_right</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
<p class="patent-detail-hint">
|
|
||||||
Abstract, Erfinder, Anmelder und IPC/CPC-Klassifikation
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
} @else {
|
|
||||||
<div class="patent-detail overview">
|
|
||||||
<p class="overview-title">Patentübersicht</p>
|
|
||||||
<p class="overview-subtitle">Patente mit passenden Keywords.</p>
|
|
||||||
<div class="overview-stats">
|
|
||||||
<div class="overview-stat overview-stat--total">
|
|
||||||
<span class="overview-value">{{ matches().length }}</span>
|
|
||||||
<span class="overview-label">Patente</span>
|
|
||||||
</div>
|
|
||||||
<div class="overview-stat overview-stat--epo">
|
|
||||||
<span class="overview-value">{{ getEpoCount() }}</span>
|
|
||||||
<span class="overview-label">EPO</span>
|
|
||||||
</div>
|
|
||||||
<div class="overview-stat overview-stat--uspto">
|
|
||||||
<span class="overview-value">{{ getUsptoCount() }}</span>
|
|
||||||
<span class="overview-label">USPTO</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<p class="overview-hint">
|
|
||||||
Wähle links ein Patent aus, um Details zu sehen.
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<ng-template #patentsHeader>
|
||||||
|
<div class="patents-header">
|
||||||
|
<h2 class="section-title">Passende Patente</h2>
|
||||||
|
<div class="patents-header-actions">
|
||||||
|
@if (matches().length > 0) {
|
||||||
|
<label class="sort-control">
|
||||||
|
<span>Filter nach Quelle:</span>
|
||||||
|
<select
|
||||||
|
[value]="activeFilter()"
|
||||||
|
(change)="setFilter($any($event.target).value)">
|
||||||
|
<option value="all">Alle</option>
|
||||||
|
<option value="EPO">EPO</option>
|
||||||
|
<option value="USPTO">USPTO</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
}
|
||||||
|
|
||||||
|
@if (showReload()) {
|
||||||
|
<button
|
||||||
|
mat-stroked-button
|
||||||
|
type="button"
|
||||||
|
class="reload-btn"
|
||||||
|
[disabled]="reloadDisabled()"
|
||||||
|
(click)="onReload()">
|
||||||
|
<mat-icon>refresh</mat-icon>
|
||||||
|
Neu laden
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</ng-template>
|
||||||
|
|||||||
+35
-231
@@ -25,25 +25,24 @@
|
|||||||
background: var(--sg-card-bg);
|
background: var(--sg-card-bg);
|
||||||
border: 1px solid var(--sg-border);
|
border: 1px solid var(--sg-border);
|
||||||
box-shadow: var(--sg-shadow-sm);
|
box-shadow: var(--sg-shadow-sm);
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 16px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.patents-header {
|
.patents-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-wrap: wrap;
|
||||||
gap: 16px;
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 12px;
|
||||||
|
margin-bottom: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
app-query-param-paginator {
|
.patents-header-actions {
|
||||||
display: block;
|
display: flex;
|
||||||
margin-top: 14px;
|
flex-wrap: wrap;
|
||||||
}
|
align-items: center;
|
||||||
|
justify-content: flex-end;
|
||||||
.patents-toolbar-field {
|
gap: 10px;
|
||||||
width: fit-content;
|
margin-left: auto;
|
||||||
min-width: 180px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.reload-btn {
|
.reload-btn {
|
||||||
@@ -78,66 +77,10 @@ app-query-param-paginator {
|
|||||||
|
|
||||||
.patents-list {
|
.patents-list {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 0;
|
|
||||||
|
|
||||||
.patents-list-toolbar {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
gap: 16px;
|
|
||||||
margin-bottom: 18px;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
table {
|
table {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
|
|
||||||
th {
|
|
||||||
text-align: left;
|
|
||||||
padding: 12px 16px;
|
|
||||||
border-bottom: 1px solid var(--sg-border);
|
|
||||||
font-size: 13px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--sg-text-muted);
|
|
||||||
}
|
|
||||||
|
|
||||||
tr {
|
|
||||||
cursor: pointer;
|
|
||||||
transition: background-color 0.15s ease;
|
|
||||||
|
|
||||||
&:hover td {
|
|
||||||
background: rgba(16, 26, 61, 0.04);
|
|
||||||
}
|
|
||||||
|
|
||||||
&.selected td {
|
|
||||||
background: var(--sg-primary-soft);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
td {
|
|
||||||
padding: 12px 16px;
|
|
||||||
border-bottom: 1px solid var(--sg-border);
|
|
||||||
color: var(--sg-text);
|
|
||||||
font-size: 13px;
|
|
||||||
transition: background-color 0.15s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.patent-title {
|
|
||||||
color: var(--sg-text);
|
|
||||||
font-weight: 600;
|
|
||||||
max-width: 400px;
|
|
||||||
white-space: normal;
|
|
||||||
word-break: break-word;
|
|
||||||
}
|
|
||||||
|
|
||||||
.patent-people {
|
|
||||||
max-width: 220px;
|
|
||||||
color: var(--sg-text-muted);
|
|
||||||
white-space: nowrap;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
th {
|
th {
|
||||||
@@ -171,161 +114,42 @@ app-query-param-paginator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.source-badge {
|
.source-badge {
|
||||||
display: inline-flex;
|
display: inline-block;
|
||||||
align-items: center;
|
padding: 2px 8px;
|
||||||
padding: 3px 10px;
|
|
||||||
border-radius: 999px;
|
border-radius: 999px;
|
||||||
font-size: 0.75rem;
|
font-size: 12px;
|
||||||
font-weight: 700;
|
font-weight: 600;
|
||||||
|
|
||||||
&--epo {
|
&--epo {
|
||||||
background: var(--sg-primary-soft);
|
background: var(--sg-primary-soft);
|
||||||
color: var(--sg-blue-highlight);
|
color: var(--sg-blue-highlight);
|
||||||
background: #effaf3;
|
|
||||||
color: #24834f;
|
|
||||||
border: 1px solid #bdebcf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&--uspto {
|
&--uspto {
|
||||||
background: var(--sg-success-soft);
|
background: var(--sg-success-soft);
|
||||||
color: var(--sg-success);
|
color: var(--sg-success);
|
||||||
background: #f0f6ff;
|
|
||||||
color: #0b63ce;
|
|
||||||
border: 1px solid #bdd4ff;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pagination {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
margin-top: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
.patent-detail {
|
.patent-detail {
|
||||||
flex: 0 0 320px;
|
flex: 0 0 320px;
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
background: var(--sg-surface-muted);
|
background: var(--sg-surface-muted);
|
||||||
border: 1px solid var(--sg-border);
|
border: 1px solid var(--sg-border);
|
||||||
width: 440px;
|
|
||||||
padding: 24px;
|
|
||||||
background: var(--sg-surface);
|
|
||||||
box-shadow: var(--sg-shadow-sm);
|
|
||||||
border-radius: var(--sg-radius-sm);
|
|
||||||
|
|
||||||
&.overview {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 12px;
|
|
||||||
|
|
||||||
.overview-title {
|
|
||||||
font-size: 15px;
|
|
||||||
font-weight: 700;
|
|
||||||
color: var(--sg-text);
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.overview-subtitle {
|
|
||||||
font-size: 13px;
|
|
||||||
color: var(--sg-text-muted);
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.overview-stats {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 1fr 1fr 1fr;
|
|
||||||
gap: 10px;
|
|
||||||
margin-top: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.overview-stat {
|
|
||||||
background: var(--sg-surface);
|
|
||||||
border: 1px solid var(--sg-border);
|
|
||||||
border-radius: var(--sg-radius-sm);
|
|
||||||
padding: 12px 8px;
|
|
||||||
text-align: center;
|
|
||||||
|
|
||||||
.overview-value {
|
|
||||||
display: block;
|
|
||||||
font-size: 22px;
|
|
||||||
font-weight: 700;
|
|
||||||
color: var(--sg-text);
|
|
||||||
}
|
|
||||||
|
|
||||||
.overview-label {
|
|
||||||
display: block;
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--sg-text-muted);
|
|
||||||
margin-top: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
&--total {
|
|
||||||
.overview-value,
|
|
||||||
.overview-label {
|
|
||||||
color: #7255d9;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&--epo {
|
|
||||||
.overview-value,
|
|
||||||
.overview-label {
|
|
||||||
color: #24834f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&--uspto {
|
|
||||||
.overview-value,
|
|
||||||
.overview-label {
|
|
||||||
color: #0b63ce;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.overview-hint {
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--sg-text-muted);
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
h3 {
|
|
||||||
margin: 0 0 16px 0;
|
|
||||||
font-size: 16px;
|
|
||||||
font-weight: 700;
|
|
||||||
color: var(--sg-text);
|
|
||||||
line-height: 1.4;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.detail-stats {
|
.detail-stats {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr 1fr;
|
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
|
margin: 12px 0;
|
||||||
.stat {
|
|
||||||
background: var(--sg-surface);
|
|
||||||
border: 1px solid var(--sg-border);
|
|
||||||
border-radius: var(--sg-radius-sm);
|
|
||||||
padding: 10px;
|
|
||||||
text-align: center;
|
|
||||||
|
|
||||||
.stat-label {
|
|
||||||
display: block;
|
|
||||||
font-size: 11px;
|
|
||||||
color: var(--sg-text-muted);
|
|
||||||
margin-bottom: 4px;
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.03em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.stat-value {
|
|
||||||
display: block;
|
|
||||||
font-size: 15px;
|
|
||||||
font-weight: bold;
|
|
||||||
color: var(--sg-text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.patent-detail-preview {
|
|
||||||
margin: 14px 0 0;
|
|
||||||
font-size: 13px;
|
|
||||||
line-height: 1.55;
|
|
||||||
color: var(--sg-text-muted);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.match-score {
|
.match-score {
|
||||||
@@ -350,7 +174,6 @@ app-query-param-paginator {
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
gap: 8px;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin-top: 12px;
|
margin-top: 12px;
|
||||||
padding: 10px 12px;
|
padding: 10px 12px;
|
||||||
@@ -358,45 +181,26 @@ app-query-param-paginator {
|
|||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
background: var(--sg-primary);
|
background: var(--sg-primary);
|
||||||
color: var(--sg-card-bg);
|
color: var(--sg-card-bg);
|
||||||
margin-top: 16px;
|
|
||||||
padding: 12px 14px;
|
|
||||||
border: 1px solid #bdd4ff;
|
|
||||||
border-radius: 10px;
|
|
||||||
background: linear-gradient(180deg, #f8fbff 0%, #eef4ff 100%);
|
|
||||||
color: #0b63ce;
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 600;
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition:
|
|
||||||
border-color 0.15s,
|
|
||||||
background 0.15s,
|
|
||||||
box-shadow 0.15s;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
border-color: #0b63ce;
|
|
||||||
background: #f0f6ff;
|
|
||||||
box-shadow: 0 2px 8px rgba(11, 99, 206, 0.12);
|
|
||||||
}
|
|
||||||
|
|
||||||
.material-icons {
|
|
||||||
font-size: 20px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.patent-detail-hint {
|
@media (max-width: 900px) {
|
||||||
margin: 8px 0 0;
|
.patents-header {
|
||||||
font-size: 12px;
|
flex-direction: column;
|
||||||
line-height: 1.4;
|
align-items: stretch;
|
||||||
color: #888;
|
}
|
||||||
text-align: center;
|
|
||||||
}
|
.patents-header-actions {
|
||||||
|
margin-left: 0;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 960px) {
|
|
||||||
.patents-content {
|
.patents-content {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
.patent-detail {
|
.patent-detail {
|
||||||
|
flex: 1;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+47
-96
@@ -1,14 +1,11 @@
|
|||||||
import { Component, computed, inject, input, output, signal } from '@angular/core';
|
import { NgTemplateOutlet } from '@angular/common';
|
||||||
import { toSignal } from '@angular/core/rxjs-interop';
|
import { Component, input, output, signal } from '@angular/core';
|
||||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
import { MatIconModule } from '@angular/material/icon';
|
import { MatIconModule } from '@angular/material/icon';
|
||||||
import { MatSelectModule } from '@angular/material/select';
|
import { Router } from '@angular/router';
|
||||||
import { PageEvent } from '@angular/material/paginator';
|
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
|
||||||
import { PatentEntry } from '../../../api/model/patentEntry';
|
import { PatentEntry } from '../../../api/model/patentEntry';
|
||||||
import { KeywordPatentMatch } from '../../../api/model/keywordPatentMatch';
|
import { KeywordPatentMatch } from '../../../api/model/keywordPatentMatch';
|
||||||
import { LoadingComponent } from '../../../shared/ui/loading/loading.component';
|
import { LoadingComponent } from '../../../shared/ui/loading/loading.component';
|
||||||
import { QueryParamPaginatorComponent } from '../../../shared/ui/query-param-paginator/query-param-paginator.component';
|
|
||||||
import {
|
import {
|
||||||
formatPatentDate,
|
formatPatentDate,
|
||||||
getPublicationStageLabel,
|
getPublicationStageLabel,
|
||||||
@@ -16,25 +13,14 @@ import {
|
|||||||
import { KeywordPatentMappingStatus } from '../../../api';
|
import { KeywordPatentMappingStatus } from '../../../api';
|
||||||
|
|
||||||
type SourceFilter = 'all' | 'EPO' | 'USPTO';
|
type SourceFilter = 'all' | 'EPO' | 'USPTO';
|
||||||
type SortMode = 'date' | 'title';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-keywords-patents',
|
selector: 'app-keywords-patents',
|
||||||
imports: [
|
imports: [NgTemplateOutlet, MatButtonModule, MatIconModule, LoadingComponent],
|
||||||
MatFormFieldModule,
|
|
||||||
MatIconModule,
|
|
||||||
MatSelectModule,
|
|
||||||
LoadingComponent,
|
|
||||||
QueryParamPaginatorComponent,
|
|
||||||
],
|
|
||||||
templateUrl: './keywords-patents.component.html',
|
templateUrl: './keywords-patents.component.html',
|
||||||
styleUrl: './keywords-patents.component.scss',
|
styleUrl: './keywords-patents.component.scss',
|
||||||
})
|
})
|
||||||
export class KeywordsPatentsComponent {
|
export class KeywordsPatentsComponent {
|
||||||
private readonly route = inject(ActivatedRoute);
|
|
||||||
private readonly router = inject(Router);
|
|
||||||
private readonly queryParams = toSignal(this.route.queryParams);
|
|
||||||
|
|
||||||
readonly matches = input<KeywordPatentMatch[]>([]);
|
readonly matches = input<KeywordPatentMatch[]>([]);
|
||||||
readonly mappingStatus = input<KeywordPatentMappingStatus | null>(null);
|
readonly mappingStatus = input<KeywordPatentMappingStatus | null>(null);
|
||||||
readonly loading = input(false);
|
readonly loading = input(false);
|
||||||
@@ -44,65 +30,54 @@ export class KeywordsPatentsComponent {
|
|||||||
readonly reload = output<void>();
|
readonly reload = output<void>();
|
||||||
|
|
||||||
activeFilter = signal<SourceFilter>('all');
|
activeFilter = signal<SourceFilter>('all');
|
||||||
sortMode = signal<SortMode>('date');
|
|
||||||
selectedMatch = signal<KeywordPatentMatch | null>(null);
|
selectedMatch = signal<KeywordPatentMatch | null>(null);
|
||||||
|
selectedPage = signal(1);
|
||||||
|
readonly pageSize = 10;
|
||||||
|
|
||||||
readonly pageIndex = computed(() => {
|
constructor(private readonly router: Router) {}
|
||||||
const params = this.queryParams();
|
|
||||||
return params?.['page'] ? +params['page'] || 0 : 0;
|
|
||||||
});
|
|
||||||
|
|
||||||
readonly pageSize = computed(() => {
|
|
||||||
const params = this.queryParams();
|
|
||||||
return params?.['size'] ? +params['size'] || 10 : 10;
|
|
||||||
});
|
|
||||||
|
|
||||||
readonly filteredMatches = computed(() => {
|
|
||||||
const filter = this.activeFilter();
|
|
||||||
let items = this.matches();
|
|
||||||
if (filter !== 'all') {
|
|
||||||
items = items.filter((item) => item.patent.source === filter);
|
|
||||||
}
|
|
||||||
return this.sortMatches(items);
|
|
||||||
});
|
|
||||||
|
|
||||||
emptyMessage(): string {
|
emptyMessage(): string {
|
||||||
switch (this.mappingStatus()) {
|
switch (this.mappingStatus()) {
|
||||||
case 'search_error':
|
case 'search_error':
|
||||||
return 'Die Patentrecherche ist technisch fehlgeschlagen. Bitte später erneut versuchen.';
|
return 'Die Patentrecherche ist technisch fehlgeschlagen. Bitte später erneut versuchen.';
|
||||||
default:
|
default:
|
||||||
return 'Keine passenden Patente gefunden.';
|
return 'Keine passenden Patente gefunden';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getPagedMatches(): KeywordPatentMatch[] {
|
filteredMatches(): KeywordPatentMatch[] {
|
||||||
const start = this.pageIndex() * this.pageSize();
|
const filter = this.activeFilter();
|
||||||
return this.filteredMatches().slice(start, start + this.pageSize());
|
const items = this.matches();
|
||||||
|
if (filter === 'all') {
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
return items.filter((item) => item.patent.source === filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
pagedMatches(): KeywordPatentMatch[] {
|
||||||
|
const start = (this.selectedPage() - 1) * this.pageSize;
|
||||||
|
return this.filteredMatches().slice(start, start + this.pageSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
pageCount(): number {
|
||||||
|
return Math.max(
|
||||||
|
1,
|
||||||
|
Math.ceil(this.filteredMatches().length / this.pageSize),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
hasPagination(): boolean {
|
||||||
|
return this.pageCount() > 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
setFilter(filter: SourceFilter): void {
|
setFilter(filter: SourceFilter): void {
|
||||||
this.activeFilter.set(filter);
|
this.activeFilter.set(filter);
|
||||||
this.selectedMatch.set(null);
|
this.selectedPage.set(1);
|
||||||
this.resetPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
setSortMode(sortMode: SortMode): void {
|
|
||||||
this.sortMode.set(sortMode);
|
|
||||||
this.selectedMatch.set(null);
|
|
||||||
this.resetPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
onPatentPageChange(_event: PageEvent): void {
|
|
||||||
this.selectedMatch.set(null);
|
this.selectedMatch.set(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private resetPage(): void {
|
setPage(page: number): void {
|
||||||
void this.router.navigate([], {
|
this.selectedPage.set(Math.min(Math.max(page, 1), this.pageCount()));
|
||||||
relativeTo: this.route,
|
|
||||||
queryParams: { page: 0 },
|
|
||||||
queryParamsHandling: 'merge',
|
|
||||||
replaceUrl: true,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
selectMatch(item: KeywordPatentMatch): void {
|
selectMatch(item: KeywordPatentMatch): void {
|
||||||
@@ -115,21 +90,8 @@ export class KeywordsPatentsComponent {
|
|||||||
void this.router.navigate(['/patent', match.patent.patent_id]);
|
void this.router.navigate(['/patent', match.patent.patent_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
getEpoCount(): number {
|
onReload(): void {
|
||||||
return this.matches().filter((item) => item.patent.source === 'EPO').length;
|
this.reload.emit();
|
||||||
}
|
|
||||||
|
|
||||||
getUsptoCount(): number {
|
|
||||||
return this.matches().filter((item) => item.patent.source === 'USPTO')
|
|
||||||
.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
getInventorsLabel(patent: PatentEntry): string {
|
|
||||||
return patent.inventors?.length ? patent.inventors.join(', ') : '-';
|
|
||||||
}
|
|
||||||
|
|
||||||
getAssigneesLabel(patent: PatentEntry): string {
|
|
||||||
return patent.assignees?.length ? patent.assignees.join(', ') : '-';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
formatDate(date: string | null | undefined): string {
|
formatDate(date: string | null | undefined): string {
|
||||||
@@ -140,15 +102,18 @@ export class KeywordsPatentsComponent {
|
|||||||
return getPublicationStageLabel(patent);
|
return getPublicationStageLabel(patent);
|
||||||
}
|
}
|
||||||
|
|
||||||
getAbstractPreview(abstract: string | null | undefined): string | null {
|
formatScore(score: number | null | undefined): string {
|
||||||
if (!abstract?.trim()) {
|
if (score == null || Number.isNaN(score)) {
|
||||||
return null;
|
return '-';
|
||||||
}
|
}
|
||||||
const text = abstract.trim();
|
return score.toFixed(2);
|
||||||
if (text.length <= 160) {
|
}
|
||||||
return text;
|
|
||||||
|
formatMatchList(values: string[] | null | undefined): string {
|
||||||
|
if (!values || values.length === 0) {
|
||||||
|
return '-';
|
||||||
}
|
}
|
||||||
return `${text.slice(0, 160).trimEnd()}…`;
|
return values.join(', ');
|
||||||
}
|
}
|
||||||
|
|
||||||
trackMatch(_index: number, item: KeywordPatentMatch): string {
|
trackMatch(_index: number, item: KeywordPatentMatch): string {
|
||||||
@@ -161,18 +126,4 @@ export class KeywordsPatentsComponent {
|
|||||||
item.match_score,
|
item.match_score,
|
||||||
].join('|');
|
].join('|');
|
||||||
}
|
}
|
||||||
|
|
||||||
private sortMatches(items: KeywordPatentMatch[]): KeywordPatentMatch[] {
|
|
||||||
const mode = this.sortMode();
|
|
||||||
return [...items].sort((a, b) => {
|
|
||||||
if (mode === 'date') {
|
|
||||||
return (b.patent.publication_date ?? '').localeCompare(
|
|
||||||
a.patent.publication_date ?? '',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return (a.patent.title ?? '').localeCompare(b.patent.title ?? '', 'de', {
|
|
||||||
sensitivity: 'base',
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -423,16 +423,16 @@ export class KeywordsSearchComponent {
|
|||||||
limit: undefined,
|
limit: undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.statusMessage.set('Files uploaded. Extracting keywords...');
|
this.statusMessage.set('Dateien hochgeladen. Keywords werden extrahiert...');
|
||||||
|
|
||||||
this.websocketService
|
this.websocketService
|
||||||
.sendRequest(keywordsRequest)
|
.sendRequest(keywordsRequest)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.statusMessage.set('Extracting keywords...');
|
this.statusMessage.set('Keywords werden extrahiert...');
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.error('WebSocket error: OPA', err);
|
console.error('WebSocket error: OPA', err);
|
||||||
this.errorMessage.set('Failed to send content');
|
this.errorMessage.set('Inhalt konnte nicht gesendet werden');
|
||||||
this.isExtracting.set(false);
|
this.isExtracting.set(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,3 +108,81 @@ function sameKeywordSet(a: string[], b: string[]): boolean {
|
|||||||
const setA = new Set(a.map((keyword) => normalizeKeyword(keyword)));
|
const setA = new Set(a.map((keyword) => normalizeKeyword(keyword)));
|
||||||
return b.every((keyword) => setA.has(normalizeKeyword(keyword)));
|
return b.every((keyword) => setA.has(normalizeKeyword(keyword)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface PatentScoreWeights {
|
||||||
|
ipc: number;
|
||||||
|
topic: number;
|
||||||
|
text: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const DEFAULT_PATENT_SCORE_WEIGHTS: PatentScoreWeights = {
|
||||||
|
ipc: 0.6,
|
||||||
|
topic: 0.25,
|
||||||
|
text: 0.15,
|
||||||
|
};
|
||||||
|
|
||||||
|
export function normalizePatentScoreWeights(
|
||||||
|
raw: Record<string, number>,
|
||||||
|
): PatentScoreWeights {
|
||||||
|
const ipc = raw['ipc'] ?? DEFAULT_PATENT_SCORE_WEIGHTS.ipc;
|
||||||
|
const topic = raw['topic'] ?? DEFAULT_PATENT_SCORE_WEIGHTS.topic;
|
||||||
|
const text = raw['text'] ?? DEFAULT_PATENT_SCORE_WEIGHTS.text;
|
||||||
|
const sum = ipc + topic + text;
|
||||||
|
if (sum <= 0) {
|
||||||
|
return { ...DEFAULT_PATENT_SCORE_WEIGHTS };
|
||||||
|
}
|
||||||
|
return { ipc: ipc / sum, topic: topic / sum, text: text / sum };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function computePatentMatchScore(
|
||||||
|
match: Pick<KeywordPatentMatch, 'ipc_score' | 'topic_score' | 'text_score'>,
|
||||||
|
weights: PatentScoreWeights,
|
||||||
|
): number {
|
||||||
|
return (
|
||||||
|
Math.round(
|
||||||
|
(weights.ipc * match.ipc_score +
|
||||||
|
weights.topic * match.topic_score +
|
||||||
|
weights.text * match.text_score) *
|
||||||
|
10000,
|
||||||
|
) / 10000
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function applyPatentScoreWeights(
|
||||||
|
matches: KeywordPatentMatch[],
|
||||||
|
weights: PatentScoreWeights,
|
||||||
|
): KeywordPatentMatch[] {
|
||||||
|
return [...matches]
|
||||||
|
.map((match) => ({
|
||||||
|
...match,
|
||||||
|
match_score: computePatentMatchScore(match, weights),
|
||||||
|
}))
|
||||||
|
.sort((a, b) => {
|
||||||
|
const scoreDiff = b.match_score - a.match_score;
|
||||||
|
if (scoreDiff !== 0) {
|
||||||
|
return scoreDiff;
|
||||||
|
}
|
||||||
|
|
||||||
|
const dateA = a.patent.publication_date ?? '';
|
||||||
|
const dateB = b.patent.publication_date ?? '';
|
||||||
|
if (dateA !== dateB) {
|
||||||
|
return dateB.localeCompare(dateA);
|
||||||
|
}
|
||||||
|
|
||||||
|
return a.patent.patent_id.localeCompare(b.patent.patent_id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function hasPatentComponentScores(match: KeywordPatentMatch): boolean {
|
||||||
|
return (
|
||||||
|
typeof match.ipc_score === 'number' &&
|
||||||
|
typeof match.topic_score === 'number' &&
|
||||||
|
typeof match.text_score === 'number'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function canReweightPatentMatches(
|
||||||
|
matches: KeywordPatentMatch[],
|
||||||
|
): boolean {
|
||||||
|
return matches.length > 0 && matches.every(hasPatentComponentScores);
|
||||||
|
}
|
||||||
|
|||||||
+20
@@ -1,4 +1,24 @@
|
|||||||
<div class="result-layout">
|
<div class="result-layout">
|
||||||
|
<mat-card class="weights-card">
|
||||||
|
<mat-card-content>
|
||||||
|
<app-weights-sliders
|
||||||
|
[options]="weightOptions"
|
||||||
|
[initialWeights]="defaultWeights"
|
||||||
|
title="Patenten-Gewichtung"
|
||||||
|
description="Steuert die Gewichtung von IPC/CPC-Match, OpenAlex-Topic und Text-Match für den Gesamt-Score."
|
||||||
|
resetLabel="Standard"
|
||||||
|
applyLabel="Neu gewichten"
|
||||||
|
normalizedTitle="Normalisiert"
|
||||||
|
queryParamPrefix="patentW_"
|
||||||
|
[persistInQueryParams]="true"
|
||||||
|
[showApplyButton]="true"
|
||||||
|
[showResetButton]="true"
|
||||||
|
[showNormalizedPreview]="true"
|
||||||
|
(weightsChange)="onWeightsChange($event)"
|
||||||
|
(applyWeights)="onApplyWeights($event)" />
|
||||||
|
</mat-card-content>
|
||||||
|
</mat-card>
|
||||||
|
|
||||||
<div class="results-card">
|
<div class="results-card">
|
||||||
<app-keywords-patents
|
<app-keywords-patents
|
||||||
[matches]="patentMatches()"
|
[matches]="patentMatches()"
|
||||||
|
|||||||
+13
-1
@@ -1,8 +1,20 @@
|
|||||||
|
/* ============================================================
|
||||||
|
RESULT LAYOUT
|
||||||
|
============================================================ */
|
||||||
.result-layout {
|
.result-layout {
|
||||||
display: block;
|
display: grid;
|
||||||
|
grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
|
||||||
|
grid-template-areas: 'summary results';
|
||||||
|
gap: 0.75rem;
|
||||||
|
align-items: start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.weights-card {
|
||||||
|
grid-area: summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
.results-card {
|
.results-card {
|
||||||
|
grid-area: results;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+96
-3
@@ -1,12 +1,26 @@
|
|||||||
import { Component, inject, OnInit, signal } from '@angular/core';
|
import { Component, inject, OnInit, signal } from '@angular/core';
|
||||||
|
|
||||||
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
|
import { MatCardModule } from '@angular/material/card';
|
||||||
|
import { MatIconModule } from '@angular/material/icon';
|
||||||
|
|
||||||
import { KeywordsService } from '../../../../api/api/keywords.service';
|
import { KeywordsService } from '../../../../api/api/keywords.service';
|
||||||
import { KeywordPatentMatch } from '../../../../api/model/keywordPatentMatch';
|
import { KeywordPatentMatch } from '../../../../api/model/keywordPatentMatch';
|
||||||
import { PatentsByKeywordsResponse } from '../../../../api/model/patentsByKeywordsResponse';
|
import { PatentsByKeywordsResponse } from '../../../../api/model/patentsByKeywordsResponse';
|
||||||
|
import {
|
||||||
|
WeightMap,
|
||||||
|
WeightSliderOption,
|
||||||
|
WeightsSlidersComponent,
|
||||||
|
WeightsSlidersValue,
|
||||||
|
} from '../../../../shared/ui/weights-sliders/weights-sliders.component';
|
||||||
import { KeywordsPatentsComponent } from '../../keywords-patents/keywords-patents.component';
|
import { KeywordsPatentsComponent } from '../../keywords-patents/keywords-patents.component';
|
||||||
import {
|
import {
|
||||||
|
applyPatentScoreWeights,
|
||||||
buildPatentSearchItemsFromPayload,
|
buildPatentSearchItemsFromPayload,
|
||||||
|
canReweightPatentMatches,
|
||||||
clearPatentsCache,
|
clearPatentsCache,
|
||||||
|
DEFAULT_PATENT_SCORE_WEIGHTS,
|
||||||
|
normalizePatentScoreWeights,
|
||||||
readPatentsCache,
|
readPatentsCache,
|
||||||
writePatentsCache,
|
writePatentsCache,
|
||||||
} from '../../patent-search.utils';
|
} from '../../patent-search.utils';
|
||||||
@@ -15,7 +29,13 @@ import { KeywordPatentMappingStatus } from '../../../../api';
|
|||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-patents-results',
|
selector: 'app-patents-results',
|
||||||
imports: [KeywordsPatentsComponent],
|
imports: [
|
||||||
|
MatCardModule,
|
||||||
|
MatIconModule,
|
||||||
|
MatButtonModule,
|
||||||
|
WeightsSlidersComponent,
|
||||||
|
KeywordsPatentsComponent,
|
||||||
|
],
|
||||||
templateUrl: './patents-results.component.html',
|
templateUrl: './patents-results.component.html',
|
||||||
styleUrl: './patents-results.component.scss',
|
styleUrl: './patents-results.component.scss',
|
||||||
})
|
})
|
||||||
@@ -23,11 +43,53 @@ export class KeywordsToPatentsResultsComponent implements OnInit {
|
|||||||
protected readonly state = inject(SearchResultsStateService);
|
protected readonly state = inject(SearchResultsStateService);
|
||||||
private readonly keywordsService = inject(KeywordsService);
|
private readonly keywordsService = inject(KeywordsService);
|
||||||
|
|
||||||
|
readonly defaultWeights: WeightMap = { ...DEFAULT_PATENT_SCORE_WEIGHTS };
|
||||||
|
|
||||||
|
readonly weightOptions: WeightSliderOption[] = [
|
||||||
|
{
|
||||||
|
key: 'ipc',
|
||||||
|
label: 'IPC/CPC-Match',
|
||||||
|
icon: 'category',
|
||||||
|
description:
|
||||||
|
'Gewichtet die Übereinstimmung der Patent-Klassifikation (IPC/CPC) mit den Keywords.',
|
||||||
|
defaultValue: DEFAULT_PATENT_SCORE_WEIGHTS.ipc,
|
||||||
|
queryParamName: 'wIpc',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'topic',
|
||||||
|
label: 'OpenAlex-Topic',
|
||||||
|
icon: 'hub',
|
||||||
|
description:
|
||||||
|
'Gewichtet die thematische Übereinstimmung über OpenAlex-Topics und Fachgebiete.',
|
||||||
|
defaultValue: DEFAULT_PATENT_SCORE_WEIGHTS.topic,
|
||||||
|
queryParamName: 'wTopic',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'text',
|
||||||
|
label: 'Text-Match',
|
||||||
|
icon: 'article',
|
||||||
|
description:
|
||||||
|
'Gewichtet Treffer der Keywords im Patenttitel und in der Zusammenfassung.',
|
||||||
|
defaultValue: DEFAULT_PATENT_SCORE_WEIGHTS.text,
|
||||||
|
queryParamName: 'wText',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
readonly currentWeights = signal<WeightsSlidersValue>({
|
||||||
|
raw: this.defaultWeights,
|
||||||
|
normalized: { ...DEFAULT_PATENT_SCORE_WEIGHTS },
|
||||||
|
rawSum: 1,
|
||||||
|
normalizedSum: 1,
|
||||||
|
valid: true,
|
||||||
|
});
|
||||||
|
|
||||||
readonly patentMatches = signal<KeywordPatentMatch[]>([]);
|
readonly patentMatches = signal<KeywordPatentMatch[]>([]);
|
||||||
readonly mappingStatus = signal<KeywordPatentMappingStatus | null>(null);
|
readonly mappingStatus = signal<KeywordPatentMappingStatus | null>(null);
|
||||||
readonly loadingPatents = signal(false);
|
readonly loadingPatents = signal(false);
|
||||||
readonly patentsError = signal(false);
|
readonly patentsError = signal(false);
|
||||||
|
|
||||||
|
private readonly patentMatchesBase = signal<KeywordPatentMatch[]>([]);
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
const cached = readPatentsCache(this.state.keywords());
|
const cached = readPatentsCache(this.state.keywords());
|
||||||
if (cached) {
|
if (cached) {
|
||||||
@@ -38,6 +100,19 @@ export class KeywordsToPatentsResultsComponent implements OnInit {
|
|||||||
this.loadMatchingPatents();
|
this.loadMatchingPatents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onWeightsChange(value: WeightsSlidersValue): void {
|
||||||
|
this.currentWeights.set(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
onApplyWeights(value: WeightsSlidersValue): void {
|
||||||
|
this.currentWeights.set(value);
|
||||||
|
if (!canReweightPatentMatches(this.patentMatchesBase())) {
|
||||||
|
this.reloadPatents();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.updateDisplayedMatches();
|
||||||
|
}
|
||||||
|
|
||||||
reloadPatents(): void {
|
reloadPatents(): void {
|
||||||
clearPatentsCache();
|
clearPatentsCache();
|
||||||
this.loadMatchingPatents();
|
this.loadMatchingPatents();
|
||||||
@@ -74,8 +149,26 @@ export class KeywordsToPatentsResultsComponent implements OnInit {
|
|||||||
matches: KeywordPatentMatch[],
|
matches: KeywordPatentMatch[],
|
||||||
mappingStatus: KeywordPatentMappingStatus | null = null,
|
mappingStatus: KeywordPatentMappingStatus | null = null,
|
||||||
): void {
|
): void {
|
||||||
this.patentMatches.set(matches);
|
this.patentMatchesBase.set(matches);
|
||||||
this.mappingStatus.set(mappingStatus);
|
this.mappingStatus.set(mappingStatus);
|
||||||
writePatentsCache(this.state.keywords(), matches, mappingStatus);
|
this.updateDisplayedMatches();
|
||||||
|
writePatentsCache(
|
||||||
|
this.state.keywords(),
|
||||||
|
this.patentMatchesBase(),
|
||||||
|
mappingStatus,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private updateDisplayedMatches(): void {
|
||||||
|
const base = this.patentMatchesBase();
|
||||||
|
if (!canReweightPatentMatches(base)) {
|
||||||
|
this.patentMatches.set(base);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const weights = normalizePatentScoreWeights(
|
||||||
|
this.currentWeights().normalized,
|
||||||
|
);
|
||||||
|
this.patentMatches.set(applyPatentScoreWeights(base, weights));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-5
@@ -9,11 +9,6 @@
|
|||||||
<a
|
<a
|
||||||
matTabLink
|
matTabLink
|
||||||
[routerLink]="[route.path]"
|
[routerLink]="[route.path]"
|
||||||
[queryParams]="{
|
|
||||||
authorId: null,
|
|
||||||
institutionId: null,
|
|
||||||
agency: null,
|
|
||||||
}"
|
|
||||||
queryParamsHandling="merge"
|
queryParamsHandling="merge"
|
||||||
routerLinkActive
|
routerLinkActive
|
||||||
#rla="routerLinkActive"
|
#rla="routerLinkActive"
|
||||||
|
|||||||
@@ -3,23 +3,24 @@
|
|||||||
type="button"
|
type="button"
|
||||||
class="back-link"
|
class="back-link"
|
||||||
(click)="navigateBack()"
|
(click)="navigateBack()"
|
||||||
aria-label="Zurück zu den Nachrichten">
|
[attr.aria-label]="'news.back' | translate">
|
||||||
<mat-icon>arrow_back</mat-icon>
|
<mat-icon>arrow_back</mat-icon>
|
||||||
Alle Nachrichten
|
{{ 'news.all' | translate }}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
@if (loading) {
|
@if (loading) {
|
||||||
<app-loading
|
<div class="state">
|
||||||
text="Nachricht wird geladen..."
|
<mat-spinner diameter="42"></mat-spinner>
|
||||||
icon="newspaper"
|
<p>{{ 'news.loading' | translate }}</p>
|
||||||
[size]="60"
|
</div>
|
||||||
[diameter]="60" />
|
|
||||||
} @else if (notFound || !article) {
|
} @else if (notFound || !article) {
|
||||||
<div class="state error-state">
|
<div class="state error-state">
|
||||||
<mat-icon>search_off</mat-icon>
|
<mat-icon>search_off</mat-icon>
|
||||||
<h2>Nachricht nicht gefunden</h2>
|
<h2>{{ 'news.notFound' | translate }}</h2>
|
||||||
<p>Der Artikel konnte nicht geladen werden.</p>
|
<p>{{ 'news.articleLoadError' | translate }}</p>
|
||||||
<a mat-stroked-button routerLink="/persons">Zur Personensuche</a>
|
<a mat-stroked-button routerLink="/persons">
|
||||||
|
{{ 'news.peopleSearch' | translate }}
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
} @else {
|
} @else {
|
||||||
<div class="detail-layout">
|
<div class="detail-layout">
|
||||||
@@ -33,22 +34,24 @@
|
|||||||
<span>{{ formatDate(article.date) }}</span>
|
<span>{{ formatDate(article.date) }}</span>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<p class="article-heading">{{ article.maintitle || 'Kein Titel' }}</p>
|
<p class="article-heading">
|
||||||
|
{{ article.maintitle || ('news.noTitle' | translate) }}
|
||||||
|
</p>
|
||||||
|
|
||||||
@if (article.relevant === true) {
|
@if (article.relevant === true) {
|
||||||
<span class="relevance-badge is-relevant">
|
<span class="relevance-badge is-relevant">
|
||||||
<mat-icon>check_circle</mat-icon>
|
<mat-icon>check_circle</mat-icon>
|
||||||
Relevant
|
{{ 'news.relevant' | translate }}
|
||||||
</span>
|
</span>
|
||||||
} @else if (article.relevant === false) {
|
} @else if (article.relevant === false) {
|
||||||
<span class="relevance-badge not-relevant">
|
<span class="relevance-badge not-relevant">
|
||||||
<mat-icon>cancel</mat-icon>
|
<mat-icon>cancel</mat-icon>
|
||||||
Nicht relevant
|
{{ 'news.notRelevant' | translate }}
|
||||||
</span>
|
</span>
|
||||||
} @else {
|
} @else {
|
||||||
<span class="relevance-badge undetermined">
|
<span class="relevance-badge undetermined">
|
||||||
<mat-icon>help</mat-icon>
|
<mat-icon>help</mat-icon>
|
||||||
Relevanz nicht bestimmt
|
{{ 'news.relevanceUndetermined' | translate }}
|
||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
</header>
|
</header>
|
||||||
@@ -60,7 +63,7 @@
|
|||||||
class="content"
|
class="content"
|
||||||
[innerHTML]="highlightedContent"></p>
|
[innerHTML]="highlightedContent"></p>
|
||||||
} @else {
|
} @else {
|
||||||
<p class="placeholder">Kein Inhalt verfügbar.</p>
|
<p class="placeholder">{{ 'news.noContent' | translate }}</p>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -72,7 +75,7 @@
|
|||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener">
|
rel="noopener">
|
||||||
<mat-icon>open_in_new</mat-icon>
|
<mat-icon>open_in_new</mat-icon>
|
||||||
Originalartikel öffnen
|
{{ 'news.openOriginal' | translate }}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@@ -87,10 +90,12 @@
|
|||||||
(click)="openPanel = openPanel === 'persons' ? null : 'persons'"
|
(click)="openPanel = openPanel === 'persons' ? null : 'persons'"
|
||||||
[attr.aria-expanded]="openPanel === 'persons'">
|
[attr.aria-expanded]="openPanel === 'persons'">
|
||||||
<mat-icon>group</mat-icon>
|
<mat-icon>group</mat-icon>
|
||||||
<span class="accordion-title">Erwähnte Personen</span>
|
<span class="accordion-title">
|
||||||
|
{{ 'news.mentionedPeople' | translate }}
|
||||||
|
</span>
|
||||||
<mat-icon
|
<mat-icon
|
||||||
class="info-icon"
|
class="info-icon"
|
||||||
matTooltip="Personen, die im Text erwähnt wurden. Klicke auf eine der UDE angehörige Person, um zu ihrem Profil zu gelangen."
|
[matTooltip]="'news.mentionedPeopleHelp' | translate"
|
||||||
matTooltipPosition="above"
|
matTooltipPosition="above"
|
||||||
(click)="$event.stopPropagation()"
|
(click)="$event.stopPropagation()"
|
||||||
>info_outline</mat-icon
|
>info_outline</mat-icon
|
||||||
@@ -155,7 +160,9 @@
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
} @else {
|
} @else {
|
||||||
<p class="placeholder">Keine erwähnten Personen gefunden.</p>
|
<p class="placeholder">
|
||||||
|
{{ 'news.noMentionedPeople' | translate }}
|
||||||
|
</p>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@@ -170,10 +177,12 @@
|
|||||||
(click)="openPanel = openPanel === 'topics' ? null : 'topics'"
|
(click)="openPanel = openPanel === 'topics' ? null : 'topics'"
|
||||||
[attr.aria-expanded]="openPanel === 'topics'">
|
[attr.aria-expanded]="openPanel === 'topics'">
|
||||||
<mat-icon>label</mat-icon>
|
<mat-icon>label</mat-icon>
|
||||||
<span class="accordion-title">Themen & Schlüsselwörter</span>
|
<span class="accordion-title">
|
||||||
|
{{ 'news.topicsAndKeywords' | translate }}
|
||||||
|
</span>
|
||||||
<mat-icon
|
<mat-icon
|
||||||
class="info-icon"
|
class="info-icon"
|
||||||
matTooltip="Themen, die mit den extrahierten Schlüsselwörtern des Artikels assoziiert werden. Klicke auf ein Schlüsselwort, um zum hervorgehobenen Begriff im Text zu springen."
|
[matTooltip]="'news.topicsHelp' | translate"
|
||||||
matTooltipPosition="above"
|
matTooltipPosition="above"
|
||||||
(click)="$event.stopPropagation()"
|
(click)="$event.stopPropagation()"
|
||||||
>info_outline</mat-icon
|
>info_outline</mat-icon
|
||||||
@@ -214,12 +223,12 @@
|
|||||||
<div class="topic-item-body">
|
<div class="topic-item-body">
|
||||||
@if (topic.source_keyword) {
|
@if (topic.source_keyword) {
|
||||||
<p class="kw-suggestion-label">
|
<p class="kw-suggestion-label">
|
||||||
Vorgeschlagen durch das Schlüsselwort im Text:
|
{{ 'news.suggestedByKeyword' | translate }}
|
||||||
</p>
|
</p>
|
||||||
<button
|
<button
|
||||||
mat-icon-button
|
mat-icon-button
|
||||||
class="analyse-btn"
|
class="analyse-btn"
|
||||||
matTooltip="Suche nach dem Schlüsselwort"
|
[matTooltip]="'news.searchKeyword' | translate"
|
||||||
(click)="analyseKeyword(topic.source_keyword)">
|
(click)="analyseKeyword(topic.source_keyword)">
|
||||||
<mat-icon>search</mat-icon>
|
<mat-icon>search</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
@@ -230,12 +239,11 @@
|
|||||||
»{{ topic.source_keyword }}«
|
»{{ topic.source_keyword }}«
|
||||||
</button>
|
</button>
|
||||||
<p class="kw-hint">
|
<p class="kw-hint">
|
||||||
Im Artikel hervorgehoben · klicken zum Suche zu
|
{{ 'news.keywordHint' | translate }}
|
||||||
öffnen
|
|
||||||
</p>
|
</p>
|
||||||
} @else {
|
} @else {
|
||||||
<p class="placeholder">
|
<p class="placeholder">
|
||||||
Kein Schlüsselwort verknüpft.
|
{{ 'news.noLinkedKeyword' | translate }}
|
||||||
</p>
|
</p>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
@@ -245,7 +253,7 @@
|
|||||||
</div>
|
</div>
|
||||||
} @else {
|
} @else {
|
||||||
<p class="placeholder">
|
<p class="placeholder">
|
||||||
Keine Themen oder Schlüsselwörter gefunden.
|
{{ 'news.noTopicsOrKeywords' | translate }}
|
||||||
</p>
|
</p>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -11,13 +11,15 @@ import { HttpClient } from '@angular/common/http';
|
|||||||
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
|
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
|
||||||
import { MatButtonModule } from '@angular/material/button';
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
import { MatIconModule } from '@angular/material/icon';
|
import { MatIconModule } from '@angular/material/icon';
|
||||||
|
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||||
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
|
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
|
||||||
|
|
||||||
import { WorksService } from '../../api';
|
import { WorksService } from '../../api';
|
||||||
import { topicHierarchyColor } from '../../resolvers/utils/topic-colors';
|
import { topicHierarchyColor } from '../../resolvers/utils/topic-colors';
|
||||||
import { LoadingComponent } from '../../shared/ui/loading/loading.component';
|
import { LanguageService } from '../../shared/i18n/language.service';
|
||||||
|
import { TranslatePipe } from '../../shared/i18n/translate.pipe';
|
||||||
|
|
||||||
interface MentionedPerson {
|
interface MentionedPerson {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -52,9 +54,10 @@ interface NewsArticleDetail {
|
|||||||
imports: [
|
imports: [
|
||||||
MatButtonModule,
|
MatButtonModule,
|
||||||
MatIconModule,
|
MatIconModule,
|
||||||
|
MatProgressSpinnerModule,
|
||||||
MatTooltipModule,
|
MatTooltipModule,
|
||||||
RouterLink,
|
RouterLink,
|
||||||
LoadingComponent,
|
TranslatePipe,
|
||||||
],
|
],
|
||||||
templateUrl: './news-detail.component.html',
|
templateUrl: './news-detail.component.html',
|
||||||
styleUrl: './news-detail.component.scss',
|
styleUrl: './news-detail.component.scss',
|
||||||
@@ -68,6 +71,7 @@ export class NewsDetailComponent implements OnInit {
|
|||||||
private readonly worksService = inject(WorksService);
|
private readonly worksService = inject(WorksService);
|
||||||
private readonly location = inject(Location);
|
private readonly location = inject(Location);
|
||||||
private readonly sanitizer = inject(DomSanitizer);
|
private readonly sanitizer = inject(DomSanitizer);
|
||||||
|
private readonly languageService = inject(LanguageService);
|
||||||
|
|
||||||
article: NewsArticleDetail | null = null;
|
article: NewsArticleDetail | null = null;
|
||||||
highlightedContent: SafeHtml = this.sanitizer.bypassSecurityTrustHtml('');
|
highlightedContent: SafeHtml = this.sanitizer.bypassSecurityTrustHtml('');
|
||||||
@@ -157,11 +161,14 @@ export class NewsDetailComponent implements OnInit {
|
|||||||
if (!dateStr) return '-';
|
if (!dateStr) return '-';
|
||||||
const date = new Date(dateStr);
|
const date = new Date(dateStr);
|
||||||
if (isNaN(date.getTime())) return dateStr;
|
if (isNaN(date.getTime())) return dateStr;
|
||||||
return new Intl.DateTimeFormat('de-DE', {
|
return new Intl.DateTimeFormat(
|
||||||
|
this.languageService.language() === 'de' ? 'de-DE' : 'en-US',
|
||||||
|
{
|
||||||
day: '2-digit',
|
day: '2-digit',
|
||||||
month: 'long',
|
month: 'long',
|
||||||
year: 'numeric',
|
year: 'numeric',
|
||||||
}).format(date);
|
},
|
||||||
|
).format(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
private fetchArticle(id: string): void {
|
private fetchArticle(id: string): void {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<div class="page">
|
<div class="page">
|
||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<h1>Nachrichten</h1>
|
<h1>{{ 'news.title' | translate }}</h1>
|
||||||
<p>Aktuelle Nachrichten aus Campus-Aktuell.</p>
|
<p>{{ 'news.description' | translate }}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ng-template #snippetTpl let-article>
|
<ng-template #snippetTpl let-article>
|
||||||
@@ -18,36 +18,49 @@
|
|||||||
|
|
||||||
<ng-template #additionalFiltersTmp>
|
<ng-template #additionalFiltersTmp>
|
||||||
<div class="additional-filters">
|
<div class="additional-filters">
|
||||||
<mat-form-field
|
<mat-form-field appearance="outline" class="relevance-field">
|
||||||
appearance="outline"
|
|
||||||
subscriptSizing="dynamic"
|
|
||||||
class="relevance-field">
|
|
||||||
<mat-select
|
<mat-select
|
||||||
[formControl]="relevanceFilter"
|
[formControl]="relevanceFilter"
|
||||||
placeholder="Relevanz"
|
[placeholder]="'news.relevance' | translate"
|
||||||
multiple>
|
multiple>
|
||||||
<mat-option value="relevant">Relevant</mat-option>
|
<mat-option value="relevant">{{ 'news.relevant' | translate }}</mat-option>
|
||||||
<mat-option value="not_relevant">Nicht relevant</mat-option>
|
<mat-option value="not_relevant">
|
||||||
|
{{ 'news.notRelevant' | translate }}
|
||||||
|
</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<app-year-range-slider
|
<div class="year-field">
|
||||||
class="year-field"
|
<div class="year-field__head">
|
||||||
[minYear]="minYear"
|
<span class="year-field__label">{{ 'news.date' | translate }}</span>
|
||||||
[maxYear]="maxYear"
|
<span class="year-field__range">
|
||||||
[startYear]="yearFrom.value"
|
{{ yearFrom.value }} – {{ yearTo.value }}
|
||||||
[endYear]="yearTo.value"
|
</span>
|
||||||
(startYearChange)="yearFrom.setValue($event)"
|
</div>
|
||||||
(endYearChange)="yearTo.setValue($event)" />
|
<mat-slider [min]="minYear" [max]="maxYear" step="1" discrete>
|
||||||
|
<input matSliderStartThumb [formControl]="yearFrom" />
|
||||||
|
<input matSliderEndThumb [formControl]="yearTo" />
|
||||||
|
</mat-slider>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button
|
||||||
|
class="reset-filter-btn"
|
||||||
|
mat-stroked-button
|
||||||
|
type="button"
|
||||||
|
(click)="resetFilters()"
|
||||||
|
[attr.aria-label]="'news.resetFilters' | translate">
|
||||||
|
<mat-icon>filter_alt_off</mat-icon>
|
||||||
|
<span>{{ 'news.reset' | translate }}</span>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
|
||||||
<ng-template #noResultsTmp>
|
<ng-template #noResultsTmp>
|
||||||
<div class="no-results">
|
<div class="no-results">
|
||||||
@if (isSearching()) {
|
@if (isSearching()) {
|
||||||
<span>Keine Ergebnisse für „{{ searchQuery().trim() }}" gefunden.</span>
|
<span>{{ noSearchResultsLabel() }}</span>
|
||||||
} @else {
|
} @else {
|
||||||
<span>Keine Nachrichten gefunden.</span>
|
<span>{{ 'news.noResults' | translate }}</span>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
@@ -60,6 +73,6 @@
|
|||||||
[noResultsTmp]="noResultsTmp"
|
[noResultsTmp]="noResultsTmp"
|
||||||
[cardMinWidth]="380"
|
[cardMinWidth]="380"
|
||||||
[sortingDirectionOptions]="sortingDirectionOptions()"
|
[sortingDirectionOptions]="sortingDirectionOptions()"
|
||||||
sortingDirectionLabel="Sortierung"
|
[sortingDirectionLabel]="'news.sorting' | translate"
|
||||||
searchLabel="Nachrichten durchsuchen" />
|
[searchLabel]="'news.search' | translate" />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
gap: 40px;
|
gap: 12px;
|
||||||
padding: 0 1rem 1rem;
|
padding: 0 1rem 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,7 +57,54 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.year-field {
|
.year-field {
|
||||||
min-width: 280px;
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
min-width: 220px;
|
||||||
|
padding: 0 6px;
|
||||||
|
margin-top: -20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.year-field__head {
|
||||||
|
display: flex;
|
||||||
|
align-items: baseline;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 10px;
|
||||||
|
font-size: 12px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.year-field__label {
|
||||||
|
color: var(--sg-text-muted);
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.year-field__range {
|
||||||
|
color: var(--sg-text);
|
||||||
|
font-weight: 600;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.year-field mat-slider {
|
||||||
|
width: 100%;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reset-filter-btn {
|
||||||
|
min-width: 132px;
|
||||||
|
height: 42px;
|
||||||
|
padding: 0 14px;
|
||||||
|
border: 1px solid var(--sg-border);
|
||||||
|
border-radius: var(--sg-radius-sm);
|
||||||
|
color: var(--sg-text);
|
||||||
|
background: var(--sg-surface);
|
||||||
|
|
||||||
|
mat-icon {
|
||||||
|
margin-right: 6px;
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 600px) {
|
@media (max-width: 600px) {
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|||||||
import { debounceTime, merge } from 'rxjs';
|
import { debounceTime, merge } from 'rxjs';
|
||||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||||
import { MatSelectModule } from '@angular/material/select';
|
import { MatSelectModule } from '@angular/material/select';
|
||||||
|
import { MatSliderModule } from '@angular/material/slider';
|
||||||
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
|
import { MatIconModule } from '@angular/material/icon';
|
||||||
|
|
||||||
import { WorksService } from '../../api';
|
import { WorksService } from '../../api';
|
||||||
import {
|
import {
|
||||||
@@ -25,7 +28,8 @@ import {
|
|||||||
NEWS_MIN_YEAR,
|
NEWS_MIN_YEAR,
|
||||||
} from '../../shared/ui/news-card/news-card.component';
|
} from '../../shared/ui/news-card/news-card.component';
|
||||||
import { SelectorOption } from '../../shared/ui/query-param-selector/query-param-selector.component';
|
import { SelectorOption } from '../../shared/ui/query-param-selector/query-param-selector.component';
|
||||||
import { YearRangeSliderComponent } from '../../shared/ui/year-range-slider/year-range-slider.component';
|
import { LanguageService } from '../../shared/i18n/language.service';
|
||||||
|
import { TranslatePipe } from '../../shared/i18n/translate.pipe';
|
||||||
|
|
||||||
interface NewsArticle extends NewsArticleBase {
|
interface NewsArticle extends NewsArticleBase {
|
||||||
author?: string | null;
|
author?: string | null;
|
||||||
@@ -47,9 +51,12 @@ type SortOrder = 'desc' | 'asc';
|
|||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
MatFormFieldModule,
|
MatFormFieldModule,
|
||||||
MatSelectModule,
|
MatSelectModule,
|
||||||
|
MatSliderModule,
|
||||||
|
MatButtonModule,
|
||||||
|
MatIconModule,
|
||||||
CardSearchComponent,
|
CardSearchComponent,
|
||||||
NewsCardComponent,
|
NewsCardComponent,
|
||||||
YearRangeSliderComponent,
|
TranslatePipe,
|
||||||
],
|
],
|
||||||
templateUrl: './news.component.html',
|
templateUrl: './news.component.html',
|
||||||
styleUrl: './news.component.scss',
|
styleUrl: './news.component.scss',
|
||||||
@@ -60,14 +67,23 @@ export class NewsComponent implements OnInit {
|
|||||||
private readonly router = inject(Router);
|
private readonly router = inject(Router);
|
||||||
private readonly httpClient = inject(HttpClient);
|
private readonly httpClient = inject(HttpClient);
|
||||||
private readonly worksService = inject(WorksService);
|
private readonly worksService = inject(WorksService);
|
||||||
|
private readonly languageService = inject(LanguageService);
|
||||||
|
|
||||||
readonly minYear = NEWS_MIN_YEAR;
|
readonly minYear = NEWS_MIN_YEAR;
|
||||||
readonly maxYear = new Date().getFullYear();
|
readonly maxYear = new Date().getFullYear();
|
||||||
|
|
||||||
private readonly sortingDirectionOptionsAll: SelectorOption[] = [
|
private readonly sortingDirectionOptionsAll = computed<SelectorOption[]>(
|
||||||
{ value: 'desc', display_name: 'Neueste zuerst' },
|
() => [
|
||||||
{ value: 'asc', display_name: 'Älteste zuerst' },
|
{
|
||||||
];
|
value: 'desc',
|
||||||
|
display_name: this.languageService.translate('news.newestFirst'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'asc',
|
||||||
|
display_name: this.languageService.translate('news.oldestFirst'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
readonly relevanceFilter = new FormControl<string[]>([], {
|
readonly relevanceFilter = new FormControl<string[]>([], {
|
||||||
nonNullable: true,
|
nonNullable: true,
|
||||||
@@ -86,7 +102,13 @@ export class NewsComponent implements OnInit {
|
|||||||
|
|
||||||
readonly isSearching = computed(() => this.searchQuery().trim().length > 0);
|
readonly isSearching = computed(() => this.searchQuery().trim().length > 0);
|
||||||
readonly sortingDirectionOptions = computed<SelectorOption[]>(() =>
|
readonly sortingDirectionOptions = computed<SelectorOption[]>(() =>
|
||||||
this.isSearching() ? [] : this.sortingDirectionOptionsAll,
|
this.isSearching() ? [] : this.sortingDirectionOptionsAll(),
|
||||||
|
);
|
||||||
|
|
||||||
|
readonly noSearchResultsLabel = computed(() =>
|
||||||
|
this.languageService.translate('news.noSearchResults', {
|
||||||
|
query: this.searchQuery().trim(),
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
readonly page = computed<Page>(() => ({
|
readonly page = computed<Page>(() => ({
|
||||||
@@ -134,6 +156,12 @@ export class NewsComponent implements OnInit {
|
|||||||
.subscribe(() => this.applyFilters());
|
.subscribe(() => this.applyFilters());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resetFilters(): void {
|
||||||
|
this.relevanceFilter.setValue([]);
|
||||||
|
this.yearFrom.setValue(this.minYear);
|
||||||
|
this.yearTo.setValue(this.maxYear);
|
||||||
|
}
|
||||||
|
|
||||||
private applyFilters(): void {
|
private applyFilters(): void {
|
||||||
const relevance =
|
const relevance =
|
||||||
this.relevanceFilter.value.length > 0
|
this.relevanceFilter.value.length > 0
|
||||||
|
|||||||
+12
-8
@@ -1,38 +1,42 @@
|
|||||||
<h2 mat-dialog-title>
|
<h2 mat-dialog-title>
|
||||||
{{
|
{{
|
||||||
data.mode === 'create'
|
data.mode === 'create'
|
||||||
? 'Organisation erstellen'
|
? ('organizations.create' | translate)
|
||||||
: 'Organisation bearbeiten'
|
: ('organizations.edit' | translate)
|
||||||
}}
|
}}
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
<mat-dialog-content>
|
<mat-dialog-content>
|
||||||
<form class="organization-form" [formGroup]="form" (ngSubmit)="submit()">
|
<form class="organization-form" [formGroup]="form" (ngSubmit)="submit()">
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<mat-label>Name</mat-label>
|
<mat-label>{{ 'organizations.name' | translate }}</mat-label>
|
||||||
<input matInput formControlName="name" />
|
<input matInput formControlName="name" />
|
||||||
@if (form.controls.name.hasError('required')) {
|
@if (form.controls.name.hasError('required')) {
|
||||||
<mat-error>Name ist erforderlich.</mat-error>
|
<mat-error>{{ 'organizations.nameRequired' | translate }}</mat-error>
|
||||||
}
|
}
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<mat-label>Externe Institutions-ID</mat-label>
|
<mat-label>
|
||||||
|
{{ 'organizations.externalInstitutionId' | translate }}
|
||||||
|
</mat-label>
|
||||||
<input matInput formControlName="otherInstId" />
|
<input matInput formControlName="otherInstId" />
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
@if (data.mode === 'edit') {
|
@if (data.mode === 'edit') {
|
||||||
<mat-checkbox formControlName="deleted">
|
<mat-checkbox formControlName="deleted">
|
||||||
Organisation als gelöscht markieren
|
{{ 'organizations.markDeleted' | translate }}
|
||||||
</mat-checkbox>
|
</mat-checkbox>
|
||||||
}
|
}
|
||||||
</form>
|
</form>
|
||||||
</mat-dialog-content>
|
</mat-dialog-content>
|
||||||
|
|
||||||
<mat-dialog-actions align="end">
|
<mat-dialog-actions align="end">
|
||||||
<button mat-button type="button" (click)="close()">Abbrechen</button>
|
<button mat-button type="button" (click)="close()">
|
||||||
|
{{ 'common.cancel' | translate }}
|
||||||
|
</button>
|
||||||
<button mat-flat-button color="primary" type="button" (click)="submit()">
|
<button mat-flat-button color="primary" type="button" (click)="submit()">
|
||||||
<mat-icon>save</mat-icon>
|
<mat-icon>save</mat-icon>
|
||||||
Speichern
|
{{ 'common.save' | translate }}
|
||||||
</button>
|
</button>
|
||||||
</mat-dialog-actions>
|
</mat-dialog-actions>
|
||||||
|
|||||||
+2
@@ -17,6 +17,7 @@ import { MatFormFieldModule } from '@angular/material/form-field';
|
|||||||
import { MatIconModule } from '@angular/material/icon';
|
import { MatIconModule } from '@angular/material/icon';
|
||||||
import { MatInputModule } from '@angular/material/input';
|
import { MatInputModule } from '@angular/material/input';
|
||||||
import { InseOrganizationManagementModelOrganizationProfile } from '../../../api';
|
import { InseOrganizationManagementModelOrganizationProfile } from '../../../api';
|
||||||
|
import { TranslatePipe } from '../../../shared/i18n/translate.pipe';
|
||||||
|
|
||||||
export interface CreateOrganizationPayload {
|
export interface CreateOrganizationPayload {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -53,6 +54,7 @@ export type OrganizationDialogResult =
|
|||||||
MatFormFieldModule,
|
MatFormFieldModule,
|
||||||
MatIconModule,
|
MatIconModule,
|
||||||
MatInputModule,
|
MatInputModule,
|
||||||
|
TranslatePipe,
|
||||||
],
|
],
|
||||||
templateUrl: './organization-dialog.component.html',
|
templateUrl: './organization-dialog.component.html',
|
||||||
styleUrl: './organization-dialog.component.scss',
|
styleUrl: './organization-dialog.component.scss',
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<section class="organizations-page">
|
<section class="organizations-page">
|
||||||
<header class="page-header">
|
<header class="page-header">
|
||||||
<div>
|
<div>
|
||||||
<h1>Organisationen</h1>
|
<h1>{{ 'organizations.title' | translate }}</h1>
|
||||||
<p>Mandanten, externe Institutions-IDs und Status verwalten.</p>
|
<p>{{ 'organizations.description' | translate }}</p>
|
||||||
<!-- Was meinte die KI mit Mandanten? -->
|
<!-- Was meinte die KI mit Mandanten? -->
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
type="button"
|
type="button"
|
||||||
(click)="startCreate()">
|
(click)="startCreate()">
|
||||||
<mat-icon>add_business</mat-icon>
|
<mat-icon>add_business</mat-icon>
|
||||||
Neue Organisation
|
{{ 'organizations.new' | translate }}
|
||||||
</button>
|
</button>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
@@ -36,14 +36,14 @@
|
|||||||
<button
|
<button
|
||||||
mat-icon-button
|
mat-icon-button
|
||||||
type="button"
|
type="button"
|
||||||
aria-label="Bearbeiten"
|
[attr.aria-label]="'common.edit' | translate"
|
||||||
(click)="startEdit(row)">
|
(click)="startEdit(row)">
|
||||||
<mat-icon>edit</mat-icon>
|
<mat-icon>edit</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
mat-icon-button
|
mat-icon-button
|
||||||
type="button"
|
type="button"
|
||||||
aria-label="Deaktivieren"
|
[attr.aria-label]="'common.deactivate' | translate"
|
||||||
[disabled]="row.deleted"
|
[disabled]="row.deleted"
|
||||||
(click)="deleteOrganization(row)">
|
(click)="deleteOrganization(row)">
|
||||||
<mat-icon>delete</mat-icon>
|
<mat-icon>delete</mat-icon>
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import {
|
import {
|
||||||
Component,
|
Component,
|
||||||
|
effect,
|
||||||
inject,
|
inject,
|
||||||
|
Injector,
|
||||||
input,
|
input,
|
||||||
OnInit,
|
OnInit,
|
||||||
TemplateRef,
|
TemplateRef,
|
||||||
@@ -29,6 +31,8 @@ import { MatCardModule } from '@angular/material/card';
|
|||||||
import { StatusPipe } from '../../shared/pipes/status.pipe';
|
import { StatusPipe } from '../../shared/pipes/status.pipe';
|
||||||
import { QueryParamPaginatorComponent } from '../../shared/ui/query-param-paginator/query-param-paginator.component';
|
import { QueryParamPaginatorComponent } from '../../shared/ui/query-param-paginator/query-param-paginator.component';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
import { LanguageService } from '../../shared/i18n/language.service';
|
||||||
|
import { TranslatePipe } from '../../shared/i18n/translate.pipe';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-organizations',
|
selector: 'app-organizations',
|
||||||
@@ -42,6 +46,7 @@ import { Router } from '@angular/router';
|
|||||||
MatCardModule,
|
MatCardModule,
|
||||||
StatusPipe,
|
StatusPipe,
|
||||||
QueryParamPaginatorComponent,
|
QueryParamPaginatorComponent,
|
||||||
|
TranslatePipe,
|
||||||
],
|
],
|
||||||
templateUrl: './organizations.component.html',
|
templateUrl: './organizations.component.html',
|
||||||
styleUrl: './organizations.component.scss',
|
styleUrl: './organizations.component.scss',
|
||||||
@@ -52,6 +57,8 @@ export class OrganizationsComponent implements OnInit {
|
|||||||
private readonly dialog = inject(MatDialog);
|
private readonly dialog = inject(MatDialog);
|
||||||
private readonly snackBar = inject(MatSnackBar);
|
private readonly snackBar = inject(MatSnackBar);
|
||||||
private readonly organizationService = inject(OrganizationService);
|
private readonly organizationService = inject(OrganizationService);
|
||||||
|
private readonly languageService = inject(LanguageService);
|
||||||
|
private readonly injector = inject(Injector);
|
||||||
|
|
||||||
organizationPage = input.required<OrganizationPage>();
|
organizationPage = input.required<OrganizationPage>();
|
||||||
organizationColumns: GenericColumn<InseOrganizationManagementModelOrganizationProfile>[] =
|
organizationColumns: GenericColumn<InseOrganizationManagementModelOrganizationProfile>[] =
|
||||||
@@ -65,35 +72,45 @@ export class OrganizationsComponent implements OnInit {
|
|||||||
);
|
);
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
effect(
|
||||||
|
() => {
|
||||||
|
this.languageService.language();
|
||||||
|
this.setOrganizationColumns();
|
||||||
|
},
|
||||||
|
{ injector: this.injector },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private setOrganizationColumns(): void {
|
||||||
this.organizationColumns = [
|
this.organizationColumns = [
|
||||||
{
|
{
|
||||||
id: 'name',
|
id: 'name',
|
||||||
header: 'Name',
|
header: this.languageService.translate('organizations.name'),
|
||||||
type: 'accessor',
|
type: 'accessor',
|
||||||
accessorKey: 'name',
|
accessorKey: 'name',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'other_inst_id',
|
id: 'other_inst_id',
|
||||||
header: 'Externe ID',
|
header: this.languageService.translate('organizations.externalId'),
|
||||||
type: 'accessor',
|
type: 'accessor',
|
||||||
accessorKey: 'other_inst_id',
|
accessorKey: 'other_inst_id',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'member_count',
|
id: 'member_count',
|
||||||
header: 'Mitglieder',
|
header: this.languageService.translate('organizations.members'),
|
||||||
type: 'accessor',
|
type: 'accessor',
|
||||||
accessorKey: 'member_count',
|
accessorKey: 'member_count',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'deleted',
|
id: 'deleted',
|
||||||
header: 'Status',
|
header: this.languageService.translate('common.status'),
|
||||||
type: 'accessor',
|
type: 'accessor',
|
||||||
accessorKey: 'deleted',
|
accessorKey: 'deleted',
|
||||||
cellTemplate: this.organizationStatusTmp(),
|
cellTemplate: this.organizationStatusTmp(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'actions',
|
id: 'actions',
|
||||||
header: 'Aktionen',
|
header: this.languageService.translate('common.actions'),
|
||||||
type: 'display',
|
type: 'display',
|
||||||
cellTemplate: this.organizationActionsTmp(),
|
cellTemplate: this.organizationActionsTmp(),
|
||||||
},
|
},
|
||||||
@@ -119,10 +136,15 @@ export class OrganizationsComponent implements OnInit {
|
|||||||
({ ConfirmationDialogComponent }) => {
|
({ ConfirmationDialogComponent }) => {
|
||||||
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
||||||
data: {
|
data: {
|
||||||
title: 'Organisation deaktivieren',
|
title: this.languageService.translate(
|
||||||
message: `Möchtest Du die Organisation „${organization.name}“ wirklich deaktivieren?`,
|
'organizations.deactivateTitle',
|
||||||
confirmText: 'Deaktivieren',
|
),
|
||||||
cancelText: 'Abbrechen',
|
message: this.languageService.translate(
|
||||||
|
'organizations.deactivateQuestion',
|
||||||
|
{ name: organization.name },
|
||||||
|
),
|
||||||
|
confirmText: this.languageService.translate('common.deactivate'),
|
||||||
|
cancelText: this.languageService.translate('common.cancel'),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -138,16 +160,22 @@ export class OrganizationsComponent implements OnInit {
|
|||||||
): void {
|
): void {
|
||||||
this.organizationService.deleteOrganisation(organization.id).subscribe({
|
this.organizationService.deleteOrganisation(organization.id).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.snackBar.open('Organisation wurde deaktiviert.', 'OK', {
|
this.snackBar.open(
|
||||||
|
this.languageService.translate('organizations.deactivated'),
|
||||||
|
this.languageService.translate('common.ok'),
|
||||||
|
{
|
||||||
duration: 3000,
|
duration: 3000,
|
||||||
});
|
},
|
||||||
|
);
|
||||||
this.router.navigate([], {
|
this.router.navigate([], {
|
||||||
queryParams: { page: 0 },
|
queryParams: { page: 0 },
|
||||||
queryParamsHandling: 'merge',
|
queryParamsHandling: 'merge',
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
error: () =>
|
error: () =>
|
||||||
this.showError('Organisation konnte nicht deaktiviert werden.'),
|
this.showError(
|
||||||
|
this.languageService.translate('organizations.deactivateError'),
|
||||||
|
),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,9 +210,13 @@ export class OrganizationsComponent implements OnInit {
|
|||||||
|
|
||||||
request.subscribe({
|
request.subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.snackBar.open('Organisation wurde gespeichert.', 'OK', {
|
this.snackBar.open(
|
||||||
|
this.languageService.translate('organizations.saved'),
|
||||||
|
this.languageService.translate('common.ok'),
|
||||||
|
{
|
||||||
duration: 3000,
|
duration: 3000,
|
||||||
});
|
},
|
||||||
|
);
|
||||||
this.router.navigate([], {
|
this.router.navigate([], {
|
||||||
queryParams: { page: 0 },
|
queryParams: { page: 0 },
|
||||||
queryParamsHandling: 'merge',
|
queryParamsHandling: 'merge',
|
||||||
@@ -193,13 +225,17 @@ export class OrganizationsComponent implements OnInit {
|
|||||||
error: (error) =>
|
error: (error) =>
|
||||||
this.showError(
|
this.showError(
|
||||||
error.status === 409
|
error.status === 409
|
||||||
? 'Eine Organisation mit diesem Namen existiert bereits.'
|
? this.languageService.translate('organizations.nameConflict')
|
||||||
: 'Organisation konnte nicht gespeichert werden.',
|
: this.languageService.translate('organizations.saveError'),
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private showError(message: string): void {
|
private showError(message: string): void {
|
||||||
this.snackBar.open(message, 'OK', { duration: 5000 });
|
this.snackBar.open(
|
||||||
|
message,
|
||||||
|
this.languageService.translate('common.ok'),
|
||||||
|
{ duration: 5000 },
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user