Merge branch 'dev' of https://project.nes.uni-due.de/gitea/lbs/smartguide into dev
LocationBasedServices/smartguide/pipeline/head This commit looks good
LocationBasedServices/smartguide/pipeline/head This commit looks good
This commit is contained in:
@@ -52,6 +52,9 @@ class ESIndex(StrEnum):
|
||||
OPENALEX_CONTINENTS = "openalex-continents"
|
||||
OPENALEX_TOPICS = "openalex-topics"
|
||||
OPENALEX_TOPIC_VECTORS = "topicvectors"
|
||||
OPENALEX_DOMAINS = "openalex-domains"
|
||||
OPENALEX_FIELDS = "openalex-fields"
|
||||
OPENALEX_SUBFIELDS = "openalex-subfields"
|
||||
|
||||
EPO_INDEX = "epo_index_1.0"
|
||||
USPTO_INDEX = "uspto_patents_3.0"
|
||||
|
||||
@@ -648,7 +648,7 @@ async def search_dfg_projects(
|
||||
# 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")
|
||||
print("ENRIECHED",source.get("institutions", []))
|
||||
|
||||
return _complete_response_to_dfg_project_page(response, page, size)
|
||||
|
||||
def _complete_response_to_dfg_project_page(
|
||||
|
||||
@@ -4,6 +4,9 @@ from typing import Annotated
|
||||
import inse.topics.v2.service as topics_service
|
||||
from fastapi import APIRouter, Path, Query
|
||||
from inse.model import SortDirection
|
||||
from inse.models.openalex.domain import Domain
|
||||
from inse.models.openalex.model_field import ModelField
|
||||
from inse.models.openalex.subfield import Subfield
|
||||
from inse.models.openalex.topic import Topic
|
||||
from inse.router_prefixes import RouterPrefixes
|
||||
from inse.tags import Tags
|
||||
@@ -78,6 +81,48 @@ async def get_topic_by_id(
|
||||
)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/domains/single/{domain_id}",
|
||||
operation_id="getDomainById",
|
||||
summary="Returns a domain for a given domain ID.",
|
||||
)
|
||||
async def get_domain_by_id(
|
||||
domain_id: Annotated[
|
||||
str,
|
||||
Path(description="The ID of the domain to retrieve."),
|
||||
],
|
||||
) -> Domain:
|
||||
return await topics_service.get_domain_by_id_or_raise(domain_id=domain_id)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/fields/single/{field_id}",
|
||||
operation_id="getFieldById",
|
||||
summary="Returns a field for a given field ID.",
|
||||
)
|
||||
async def get_field_by_id(
|
||||
field_id: Annotated[
|
||||
str,
|
||||
Path(description="The ID of the field to retrieve."),
|
||||
],
|
||||
) -> ModelField:
|
||||
return await topics_service.get_field_by_id_or_raise(field_id=field_id)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/subfields/single/{subfield_id}",
|
||||
operation_id="getSubfieldById",
|
||||
summary="Returns a subfield for a given subfield ID.",
|
||||
)
|
||||
async def get_subfield_by_id(
|
||||
subfield_id: Annotated[
|
||||
str,
|
||||
Path(description="The ID of the subfield to retrieve."),
|
||||
],
|
||||
) -> Subfield:
|
||||
return await topics_service.get_subfield_by_id_or_raise(subfield_id=subfield_id)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/topics/id",
|
||||
operation_id="getTopicsByIds",
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
from inse.exceptions import NotFoundException
|
||||
from inse.integrations import elasticsearch
|
||||
from inse.model import ESIndex, SortDirection
|
||||
from inse.models.openalex.domain import Domain
|
||||
from inse.models.openalex.model_field import ModelField
|
||||
from inse.models.openalex.subfield import Subfield
|
||||
from inse.models.openalex.topic import Topic
|
||||
from inse.topics.v2.model import TopicPageV2, TopicSortBy
|
||||
|
||||
@@ -184,6 +187,117 @@ async def get_topic_by_id_or_raise(raw_oa_topic_id: str) -> Topic:
|
||||
return topic
|
||||
|
||||
|
||||
async def get_domain_by_id(domain_id: str) -> Domain | None:
|
||||
"""Retrieves a domain based on its ID.
|
||||
|
||||
Args:
|
||||
domain_id (str): The numeric OpenAlex ID of the domain to retrieve (e.g. "4").
|
||||
|
||||
Returns:
|
||||
Domain | None: The domain matching the provided ID, or None if not found.
|
||||
"""
|
||||
response = await elasticsearch.get(
|
||||
index=ESIndex.OPENALEX_DOMAINS,
|
||||
doc_id=domain_id,
|
||||
source=["id", "display_name", "description"],
|
||||
)
|
||||
if response.get("found"):
|
||||
return Domain.from_dict(response.get("_source", {}))
|
||||
return None
|
||||
|
||||
|
||||
async def get_domain_by_id_or_raise(domain_id: str) -> Domain:
|
||||
"""Retrieves a domain based on its ID, raising an exception if not found.
|
||||
|
||||
Args:
|
||||
domain_id (str): The ID of the domain to retrieve.
|
||||
|
||||
Raises:
|
||||
NotFoundException: If the domain with the specified ID is not found.
|
||||
|
||||
Returns:
|
||||
Domain: The domain matching the provided ID.
|
||||
"""
|
||||
domain = await get_domain_by_id(domain_id)
|
||||
if domain is None:
|
||||
raise NotFoundException(f"Domain with ID {domain_id} not found.")
|
||||
return domain
|
||||
|
||||
|
||||
async def get_field_by_id(field_id: str) -> ModelField | None:
|
||||
"""Retrieves a field based on its ID.
|
||||
|
||||
Args:
|
||||
field_id (str): The numeric OpenAlex ID of the field to retrieve (e.g. "27").
|
||||
|
||||
Returns:
|
||||
ModelField | None: The field matching the provided ID, or None if not found.
|
||||
"""
|
||||
response = await elasticsearch.get(
|
||||
index=ESIndex.OPENALEX_FIELDS,
|
||||
doc_id=field_id,
|
||||
source=["id", "display_name", "description"],
|
||||
)
|
||||
if response.get("found"):
|
||||
return ModelField.from_dict(response.get("_source", {}))
|
||||
return None
|
||||
|
||||
|
||||
async def get_field_by_id_or_raise(field_id: str) -> ModelField:
|
||||
"""Retrieves a field based on its ID, raising an exception if not found.
|
||||
|
||||
Args:
|
||||
field_id (str): The ID of the field to retrieve.
|
||||
|
||||
Raises:
|
||||
NotFoundException: If the field with the specified ID is not found.
|
||||
|
||||
Returns:
|
||||
ModelField: The field matching the provided ID.
|
||||
"""
|
||||
field = await get_field_by_id(field_id)
|
||||
if field is None:
|
||||
raise NotFoundException(f"Field with ID {field_id} not found.")
|
||||
return field
|
||||
|
||||
|
||||
async def get_subfield_by_id(subfield_id: str) -> Subfield | None:
|
||||
"""Retrieves a subfield based on its ID.
|
||||
|
||||
Args:
|
||||
subfield_id (str): The numeric OpenAlex ID of the subfield to retrieve (e.g. "2743").
|
||||
|
||||
Returns:
|
||||
Subfield | None: The subfield matching the provided ID, or None if not found.
|
||||
"""
|
||||
response = await elasticsearch.get(
|
||||
index=ESIndex.OPENALEX_SUBFIELDS,
|
||||
doc_id=subfield_id,
|
||||
source=["id", "display_name", "description"],
|
||||
)
|
||||
if response.get("found"):
|
||||
return Subfield.from_dict(response.get("_source", {}))
|
||||
return None
|
||||
|
||||
|
||||
async def get_subfield_by_id_or_raise(subfield_id: str) -> Subfield:
|
||||
"""Retrieves a subfield based on its ID, raising an exception if not found.
|
||||
|
||||
Args:
|
||||
subfield_id (str): The ID of the subfield to retrieve.
|
||||
|
||||
Raises:
|
||||
NotFoundException: If the subfield with the specified ID is not found.
|
||||
|
||||
Returns:
|
||||
Subfield: The subfield matching the provided ID.
|
||||
"""
|
||||
subfield = await get_subfield_by_id(subfield_id)
|
||||
if subfield is None:
|
||||
raise NotFoundException(f"Subfield with ID {subfield_id} not found.")
|
||||
return subfield
|
||||
|
||||
|
||||
async def get_topics_by_ids(topic_ids: list[str]) -> TopicPageV2:
|
||||
"""Retrieves topics based on a list of topic IDs.
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
import { DomainFieldsInner } from './domainFieldsInner';
|
||||
import { DomainIds } from './domainIds';
|
||||
|
||||
/**
|
||||
* Top-level category in the topic hierarchy (4 total)
|
||||
*/
|
||||
export interface Domain {
|
||||
id?: string | null;
|
||||
display_name?: string | null;
|
||||
description?: string | null;
|
||||
display_name_alternatives?: Array<string> | null;
|
||||
fields?: Array<DomainFieldsInner> | null;
|
||||
siblings?: Array<DomainFieldsInner> | null;
|
||||
ids?: DomainIds | null;
|
||||
works_count?: number | null;
|
||||
cited_by_count?: number | null;
|
||||
works_api_url?: string | null;
|
||||
created_date?: string | null;
|
||||
updated_date?: string | null;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* DomainFieldsInner
|
||||
*/
|
||||
export interface DomainFieldsInner {
|
||||
id?: string | null;
|
||||
display_name?: string | null;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* External identifiers:
|
||||
*/
|
||||
export interface DomainIds {
|
||||
openalex?: string | null;
|
||||
wikidata?: string | null;
|
||||
wikipedia?: string | null;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
import { DomainFieldsInner } from './domainFieldsInner';
|
||||
import { DomainIds } from './domainIds';
|
||||
import { WorkTopicDomain } from './workTopicDomain';
|
||||
|
||||
/**
|
||||
* Second-level category in the topic hierarchy (26 total)
|
||||
*/
|
||||
export interface ModelField {
|
||||
id?: string | null;
|
||||
display_name?: string | null;
|
||||
description?: string | null;
|
||||
display_name_alternatives?: Array<string> | null;
|
||||
domain?: WorkTopicDomain | null;
|
||||
subfields?: Array<DomainFieldsInner> | null;
|
||||
siblings?: Array<DomainFieldsInner> | null;
|
||||
ids?: DomainIds | null;
|
||||
works_count?: number | null;
|
||||
cited_by_count?: number | null;
|
||||
works_api_url?: string | null;
|
||||
created_date?: string | null;
|
||||
updated_date?: string | null;
|
||||
}
|
||||
@@ -78,6 +78,9 @@ export * from './dfgProjectSummary';
|
||||
export * from './dfgProjectTopic';
|
||||
export * from './dfgProjectTopics';
|
||||
export * from './dockerHealth';
|
||||
export * from './domain';
|
||||
export * from './domainFieldsInner';
|
||||
export * from './domainIds';
|
||||
export * from './edge';
|
||||
export * from './euCordisEurosciVocSummary';
|
||||
export * from './euCordisOrganizationSelectorPage';
|
||||
@@ -174,6 +177,7 @@ export * from './matchedTopic';
|
||||
export * from './mentionedPerson';
|
||||
export * from './meta';
|
||||
export * from './model2YrMeanCitedness';
|
||||
export * from './modelField';
|
||||
export * from './newsArticle';
|
||||
export * from './newsArticleDetail';
|
||||
export * from './newsPage';
|
||||
@@ -208,6 +212,9 @@ export * from './score';
|
||||
export * from './selectedAuthorsRequest';
|
||||
export * from './sortDirection';
|
||||
export * from './startCollaborationGraphResponse';
|
||||
export * from './subfield';
|
||||
export * from './subfieldDomain';
|
||||
export * from './subfieldField';
|
||||
export * from './subfieldShare';
|
||||
export * from './timespan';
|
||||
export * from './tokenType';
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
import { DomainFieldsInner } from './domainFieldsInner';
|
||||
import { DomainIds } from './domainIds';
|
||||
import { SubfieldDomain } from './subfieldDomain';
|
||||
import { SubfieldField } from './subfieldField';
|
||||
|
||||
/**
|
||||
* Third-level category in the topic hierarchy (254 total)
|
||||
*/
|
||||
export interface Subfield {
|
||||
id?: string | null;
|
||||
display_name?: string | null;
|
||||
description?: string | null;
|
||||
display_name_alternatives?: Array<string> | null;
|
||||
field?: SubfieldField | null;
|
||||
domain?: SubfieldDomain | null;
|
||||
topics?: Array<DomainFieldsInner> | null;
|
||||
siblings?: Array<DomainFieldsInner> | null;
|
||||
ids?: DomainIds | null;
|
||||
works_count?: number | null;
|
||||
cited_by_count?: number | null;
|
||||
works_api_url?: string | null;
|
||||
created_date?: string | null;
|
||||
updated_date?: string | null;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The domain containing this subfield (top level of hierarchy).
|
||||
*/
|
||||
export interface SubfieldDomain {
|
||||
id?: string | null;
|
||||
display_name?: string | null;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The field containing this subfield (parent level).
|
||||
*/
|
||||
export interface SubfieldField {
|
||||
id?: string | null;
|
||||
display_name?: string | null;
|
||||
}
|
||||
@@ -35,18 +35,20 @@
|
||||
</div>
|
||||
</mat-card-content>
|
||||
|
||||
<mat-divider />
|
||||
@if (topic.id) {
|
||||
<mat-divider />
|
||||
|
||||
<mat-card-footer>
|
||||
<mat-card-actions class="card-actions">
|
||||
<a
|
||||
class="card-action"
|
||||
[routerLink]="['/topic', stripOpenAlexId(topic.id), 'publications']"
|
||||
matButton="outlined"
|
||||
(click)="$event.stopPropagation()">
|
||||
<mat-icon>menu_book</mat-icon>
|
||||
Publikationen
|
||||
</a>
|
||||
</mat-card-actions>
|
||||
</mat-card-footer>
|
||||
<mat-card-footer>
|
||||
<mat-card-actions class="card-actions">
|
||||
<a
|
||||
class="card-action"
|
||||
[routerLink]="['/topic', stripOpenAlexId(topic.id), 'publications']"
|
||||
matButton="outlined"
|
||||
(click)="$event.stopPropagation()">
|
||||
<mat-icon>menu_book</mat-icon>
|
||||
Publikationen
|
||||
</a>
|
||||
</mat-card-actions>
|
||||
</mat-card-footer>
|
||||
}
|
||||
</mat-card>
|
||||
|
||||
@@ -35,7 +35,13 @@ export class AppTopicCardComponent {
|
||||
}
|
||||
|
||||
subtitle = computed(() => {
|
||||
return `${this.topic().subfield?.display_name} - ${this.topic().field?.display_name} - ${this.topic().domain?.display_name}`;
|
||||
return [
|
||||
this.topic().subfield?.display_name,
|
||||
this.topic().field?.display_name,
|
||||
this.topic().domain?.display_name,
|
||||
]
|
||||
.filter((part) => Boolean(part))
|
||||
.join(' - ');
|
||||
});
|
||||
|
||||
description = computed(() => {
|
||||
|
||||
@@ -24,9 +24,12 @@ export class AppTopicTooltipComponent {
|
||||
|
||||
const hasCompleteMetrics = Boolean(
|
||||
topicObj &&
|
||||
(topicObj.description ||
|
||||
topicObj.works_count !== undefined ||
|
||||
topicObj.cited_by_count !== undefined),
|
||||
topicObj.description &&
|
||||
topicObj.works_count !== undefined &&
|
||||
topicObj.cited_by_count !== undefined &&
|
||||
topicObj.subfield &&
|
||||
topicObj.field &&
|
||||
topicObj.domain,
|
||||
);
|
||||
|
||||
if (hasCompleteMetrics && topicObj) {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<div class="legend-tooltip-card">
|
||||
<div class="legend-tooltip-title">{{ name() }}</div>
|
||||
@if (hierarchy()) {
|
||||
<div class="legend-tooltip-hierarchy">{{ hierarchy() }}</div>
|
||||
}
|
||||
@if (_description()) {
|
||||
<hr class="legend-tooltip-divider" />
|
||||
<p class="legend-tooltip-description">{{ _description() }}</p>
|
||||
}
|
||||
</div>
|
||||
@@ -0,0 +1,46 @@
|
||||
:host {
|
||||
--topic-border: color-mix(
|
||||
in srgb,
|
||||
hsl(var(--topic-color)) 72%,
|
||||
var(--sg-color-mix-base)
|
||||
);
|
||||
--topic-background: color-mix(
|
||||
in srgb,
|
||||
hsl(var(--topic-color)) 8%,
|
||||
var(--sg-color-mix-base)
|
||||
);
|
||||
}
|
||||
|
||||
.legend-tooltip-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
padding: 1rem;
|
||||
border-radius: var(--sg-radius-sm);
|
||||
background-color: var(--topic-background);
|
||||
border: 1px solid var(--topic-border);
|
||||
color: var(--sg-text);
|
||||
}
|
||||
|
||||
.legend-tooltip-title {
|
||||
font-weight: 600;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.legend-tooltip-hierarchy {
|
||||
color: var(--sg-text-muted);
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.legend-tooltip-divider {
|
||||
margin: 0;
|
||||
border: none;
|
||||
border-top: 1px solid var(--topic-border);
|
||||
}
|
||||
|
||||
.legend-tooltip-description {
|
||||
margin: 0;
|
||||
color: var(--sg-text);
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.4;
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
import {
|
||||
Component,
|
||||
computed,
|
||||
effect,
|
||||
inject,
|
||||
input,
|
||||
signal,
|
||||
} from '@angular/core';
|
||||
import { TopicsV2Service } from '../../../api';
|
||||
|
||||
@Component({
|
||||
host: {
|
||||
'[style.--topic-color]': 'topicColorVar()',
|
||||
},
|
||||
selector: 'app-legend-tooltip',
|
||||
standalone: true,
|
||||
templateUrl: './legend-tooltip.component.html',
|
||||
styleUrl: './legend-tooltip.component.scss',
|
||||
})
|
||||
export class LegendTooltipComponent {
|
||||
private readonly topicsService = inject(TopicsV2Service);
|
||||
|
||||
readonly name = input.required<string>();
|
||||
readonly hierarchy = input<string | null | undefined>(null);
|
||||
readonly description = input<string | null | undefined>(null);
|
||||
readonly fieldId = input<string | null | undefined>(null);
|
||||
readonly subfieldId = input<string | null | undefined>(null);
|
||||
readonly color = input<string | null | undefined>(null);
|
||||
|
||||
readonly _description = signal<string | null | undefined>(undefined);
|
||||
|
||||
readonly topicColorVar = computed(() => {
|
||||
const color = this.color();
|
||||
if (!color) return '';
|
||||
return color.replace('hsl(', '').replace(')', '');
|
||||
});
|
||||
|
||||
constructor() {
|
||||
effect(() => {
|
||||
const description = this.description();
|
||||
if (description) {
|
||||
this._description.set(description);
|
||||
return;
|
||||
}
|
||||
|
||||
const rawSubfieldId = this.extractOpenAlexShortId(this.subfieldId());
|
||||
if (rawSubfieldId) {
|
||||
this.topicsService.getSubfieldById(rawSubfieldId).subscribe({
|
||||
next: (subfield) => this._description.set(subfield.description),
|
||||
error: () => this._description.set(undefined),
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const rawFieldId = this.extractOpenAlexShortId(this.fieldId());
|
||||
if (rawFieldId) {
|
||||
this.topicsService.getFieldById(rawFieldId).subscribe({
|
||||
next: (field) => this._description.set(field.description),
|
||||
error: () => this._description.set(undefined),
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
this._description.set(undefined);
|
||||
});
|
||||
}
|
||||
|
||||
private extractOpenAlexShortId(
|
||||
id: string | null | undefined,
|
||||
): string | undefined {
|
||||
if (!id || !id.includes('openalex.org')) {
|
||||
return undefined;
|
||||
}
|
||||
return id.split('/').pop() || undefined;
|
||||
}
|
||||
}
|
||||
@@ -54,10 +54,16 @@
|
||||
class="topic-legend-field"
|
||||
[class.topic-legend-entry-active]="isFieldActive(group)"
|
||||
[attr.aria-pressed]="selectable ? isFieldActive(group) : null"
|
||||
[matTooltip]="group.tooltip"
|
||||
[matTooltipDisabled]="!group.tooltip"
|
||||
matTooltipClass="topic-chip-tooltip"
|
||||
matTooltipPosition="above"
|
||||
[appComponentTooltip]="LegendTooltipComponent"
|
||||
[tooltipInputs]="{
|
||||
name: group.name,
|
||||
hierarchy: group.domainName,
|
||||
description: group.description,
|
||||
fieldId: group.id,
|
||||
color: group.color,
|
||||
}"
|
||||
[tooltipDisabled]="!hasTooltipContent(group.description, group.id)"
|
||||
[tooltipMaxWidth]="'420px'"
|
||||
(click)="toggleField(group)">
|
||||
<span
|
||||
class="topic-legend-dot"
|
||||
@@ -73,10 +79,16 @@
|
||||
class="topic-legend-item"
|
||||
[class.topic-legend-entry-active]="isSubfieldActive(item)"
|
||||
[attr.aria-pressed]="selectable ? isSubfieldActive(item) : null"
|
||||
[matTooltip]="item.tooltip"
|
||||
[matTooltipDisabled]="!item.tooltip"
|
||||
matTooltipClass="topic-chip-tooltip"
|
||||
matTooltipPosition="above"
|
||||
[appComponentTooltip]="LegendTooltipComponent"
|
||||
[tooltipInputs]="{
|
||||
name: item.name,
|
||||
hierarchy: group.name + ' - ' + group.domainName,
|
||||
description: item.description,
|
||||
subfieldId: item.id,
|
||||
color: group.color,
|
||||
}"
|
||||
[tooltipDisabled]="!hasTooltipContent(item.description, item.id)"
|
||||
[tooltipMaxWidth]="'420px'"
|
||||
(click)="toggleSubfield(group, item)">
|
||||
{{ item.name }}
|
||||
</button>
|
||||
|
||||
@@ -2,6 +2,8 @@ import { CommonModule } from '@angular/common';
|
||||
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { ComponentTooltipDirective } from '../../../directives/component-tooltip.directive';
|
||||
import { LegendTooltipComponent } from '../legend-tooltip/legend-tooltip.component';
|
||||
import {
|
||||
TopicLegendGroup,
|
||||
TopicLegendItem,
|
||||
@@ -13,11 +15,17 @@ export type TopicLegendVariant = 'default' | 'compact';
|
||||
@Component({
|
||||
selector: 'app-topic-legend',
|
||||
standalone: true,
|
||||
imports: [CommonModule, MatIconModule, MatTooltipModule],
|
||||
imports: [
|
||||
CommonModule,
|
||||
MatIconModule,
|
||||
MatTooltipModule,
|
||||
ComponentTooltipDirective,
|
||||
],
|
||||
templateUrl: './topic-legend.component.html',
|
||||
styleUrl: './topic-legend.component.scss',
|
||||
})
|
||||
export class TopicLegendComponent {
|
||||
readonly LegendTooltipComponent = LegendTooltipComponent;
|
||||
@Input() groups: TopicLegendGroup[] = [];
|
||||
@Input() title = 'Farben nach Fachgebiet';
|
||||
@Input() infoTooltip =
|
||||
@@ -107,6 +115,10 @@ export class TopicLegendComponent {
|
||||
return item.id;
|
||||
}
|
||||
|
||||
hasTooltipContent(description: string, id: string): boolean {
|
||||
return Boolean(description) || id.includes('openalex.org');
|
||||
}
|
||||
|
||||
private isActiveLegendId(
|
||||
activeIds: ReadonlySet<string> | readonly string[],
|
||||
id: string,
|
||||
|
||||
Reference in New Issue
Block a user