diff --git a/service/src/main/inse/authors/v2/router.py b/service/src/main/inse/authors/v2/router.py
index 3474728c..9fd0aa3d 100644
--- a/service/src/main/inse/authors/v2/router.py
+++ b/service/src/main/inse/authors/v2/router.py
@@ -30,7 +30,7 @@ async def get_author_by_id(
Path(description="The ID of the author to retrieve."),
],
) -> Author:
- return await authors_service.get_author_by_id_strict(
+ return await authors_service.get_author_by_id_strict_or_raise(
raw_oa_author_id=raw_oa_author_id
)
diff --git a/service/src/main/inse/authors/v2/service.py b/service/src/main/inse/authors/v2/service.py
index 3fe2600c..f2abbaba 100644
--- a/service/src/main/inse/authors/v2/service.py
+++ b/service/src/main/inse/authors/v2/service.py
@@ -86,7 +86,7 @@ async def get_author_by_id(raw_oa_author_id: str) -> Author | None:
return Author.from_dict(response.get("_source", {})) # type: ignore
-async def get_author_by_id_strict(raw_oa_author_id: str) -> Author:
+async def get_author_by_id_strict_or_raise(raw_oa_author_id: str) -> Author:
"""Retrieves an author from the OpenAlex Elasticsearch index based on the provided author ID.
Args:
diff --git a/service/src/main/inse/institutions/v2/router.py b/service/src/main/inse/institutions/v2/router.py
index c6119a40..6cd9ad36 100644
--- a/service/src/main/inse/institutions/v2/router.py
+++ b/service/src/main/inse/institutions/v2/router.py
@@ -25,7 +25,7 @@ async def get_institution_by_id(
Path(description="The ID of the institution to retrieve."),
],
) -> Institution:
- return await institutions_service.get_institution_by_id_strict(
+ return await institutions_service.get_institution_by_id_or_raise(
raw_oa_institution_id=institution_id,
source=[
"id",
diff --git a/service/src/main/inse/institutions/v2/service.py b/service/src/main/inse/institutions/v2/service.py
index b4bacd50..7b6876d0 100644
--- a/service/src/main/inse/institutions/v2/service.py
+++ b/service/src/main/inse/institutions/v2/service.py
@@ -29,7 +29,7 @@ async def get_institution_by_id(
return Institution.from_dict(response.get("_source", {})) # type: ignore
-async def get_institution_by_id_strict(
+async def get_institution_by_id_or_raise(
raw_oa_institution_id: str, source: list[str] | None = None
) -> Institution:
"""Retrieves an institution by its ID from the OpenAlex Elasticsearch index, raising an exception if not found.
diff --git a/service/src/main/inse/topics/v2/model.py b/service/src/main/inse/topics/v2/model.py
index 92931d63..7c005cb9 100644
--- a/service/src/main/inse/topics/v2/model.py
+++ b/service/src/main/inse/topics/v2/model.py
@@ -1,6 +1,14 @@
+from enum import StrEnum
+
from inse.model import Page
from inse.models.openalex.topic import Topic
+class TopicSortBy(StrEnum):
+ DISPLAY_NAME = "display_name"
+ WORKS_COUNT = "works_count"
+ CITED_BY_COUNT = "cited_by_count"
+
+
class TopicPageV2(Page[Topic]):
pass
diff --git a/service/src/main/inse/topics/v2/router.py b/service/src/main/inse/topics/v2/router.py
index 770b8af8..f382d5a0 100644
--- a/service/src/main/inse/topics/v2/router.py
+++ b/service/src/main/inse/topics/v2/router.py
@@ -2,10 +2,12 @@ import logging
from typing import Annotated
import inse.topics.v2.service as topics_service
-from fastapi import APIRouter, Query
+from fastapi import APIRouter, Path, Query
+from inse.model import SortDirection
+from inse.models.openalex.topic import Topic
from inse.router_prefixes import RouterPrefixes
from inse.tags import Tags
-from inse.topics.v2.model import TopicPageV2
+from inse.topics.v2.model import TopicPageV2, TopicSortBy
logger = logging.getLogger(__name__)
@@ -13,6 +15,69 @@ logger = logging.getLogger(__name__)
router = APIRouter(prefix=RouterPrefixes.TOPICS_V2, tags=[Tags.TOPICS_V2])
+@router.get(
+ "/search",
+ operation_id="searchTopics",
+ summary="Searches for topics based on the provided criteria.",
+)
+async def search_topics(
+ search_term: Annotated[
+ str | None,
+ Query(description="The term to search for in topic display names."),
+ ] = None,
+ page: Annotated[
+ int,
+ Query(
+ description="The page number to retrieve.",
+ ge=0,
+ ),
+ ] = 0,
+ size: Annotated[
+ int,
+ Query(
+ description="The number of topics to retrieve per page.",
+ ge=1,
+ le=100,
+ ),
+ ] = 10,
+ sort_by: Annotated[
+ TopicSortBy,
+ Query(
+ description="The field to sort by.",
+ ),
+ ] = TopicSortBy.WORKS_COUNT,
+ sort_direction: Annotated[
+ SortDirection,
+ Query(
+ description="The direction to sort.",
+ ),
+ ] = SortDirection.DESCENDING,
+) -> TopicPageV2:
+ return await topics_service.search_topics(
+ search_term=search_term,
+ page=page,
+ size=size,
+ sort_by=sort_by,
+ sort_direction=sort_direction,
+ )
+
+
+@router.get(
+ "/single/{raw_oa_topic_id}",
+ operation_id="getTopicById",
+ summary="Returns a topic for a given topic ID.",
+)
+async def get_topic_by_id(
+ raw_oa_topic_id: Annotated[
+ str,
+ Path(description="The ID of the topic to retrieve."),
+ ],
+) -> Topic:
+ return await topics_service.get_topic_by_id_or_raise(
+ raw_oa_topic_id=raw_oa_topic_id
+ )
+
+
@router.get(
"/topics/id",
operation_id="getTopicsByIds",
diff --git a/service/src/main/inse/topics/v2/service.py b/service/src/main/inse/topics/v2/service.py
index 8ffb73e3..d8f3f604 100644
--- a/service/src/main/inse/topics/v2/service.py
+++ b/service/src/main/inse/topics/v2/service.py
@@ -1,11 +1,11 @@
-
+from inse.exceptions import NotFoundException
from inse.integrations import elasticsearch
-from inse.model import ESIndex
+from inse.model import ESIndex, SortDirection
from inse.models.openalex.topic import Topic
-from inse.topics.v2.model import TopicPageV2
+from inse.topics.v2.model import TopicPageV2, TopicSortBy
-async def search_topics(
+async def _search_topics(
page: int = 0,
size: int = 10,
query: dict | None = None,
@@ -45,6 +45,54 @@ async def search_topics(
return TopicPageV2(elements=topics, total=len(topics), page=page, size=size)
+async def search_topics(
+ search_term: str | None = None,
+ page: int = 0,
+ size: int = 10,
+ sort_by: TopicSortBy = TopicSortBy.WORKS_COUNT,
+ sort_direction: SortDirection = SortDirection.DESCENDING,
+) -> TopicPageV2:
+ """Searches for topics based on a search term.
+
+ Args:
+ search_term (str | None): The term to search for in topic display names. Defaults to None.
+ page (int, optional): The page number to retrieve. Defaults to 0.
+ size (int, optional): The number of topics to retrieve per page. Defaults to 10.
+ sort_by (TopicSortBy, optional): The field to sort by. Defaults to TopicSortBy.WORKS_COUNT.
+ sort_direction (SortDirection, optional): The direction to sort. Defaults to SortDirection.DESCENDING.
+
+ Returns:
+ TopicPageV2: A page of topics matching the search term.
+ """
+
+ sort = None
+ if sort_by in [TopicSortBy.DISPLAY_NAME]:
+ sort = [{f"{sort_by.value}.keyword": {"order": sort_direction.value}}]
+ else:
+ sort = [{sort_by.value: {"order": sort_direction.value}}]
+
+ query = None
+ if search_term:
+ query = {"match_phrase_prefix": {"display_name": search_term}}
+
+ return await _search_topics(
+ page=page,
+ size=size,
+ query=query,
+ source=[
+ "id",
+ "display_name",
+ "description",
+ "subfield",
+ "field",
+ "domain",
+ "works_count",
+ "cited_by_count",
+ ],
+ sort=sort,
+ )
+
+
async def autocomplete_topics_for_selector(query: str) -> TopicPageV2:
"""Autocompletes topics based on a search term for use in a selector component.
@@ -54,7 +102,7 @@ async def autocomplete_topics_for_selector(query: str) -> TopicPageV2:
Returns:
TopicPageV2: A page of topics matching the autocomplete criteria.
"""
- return await search_topics(
+ return await _search_topics(
page=0,
size=10,
query={"match_phrase_prefix": {"display_name": query}},
@@ -68,6 +116,53 @@ async def autocomplete_topics_for_selector(query: str) -> TopicPageV2:
)
+async def get_topic_by_id(raw_oa_topic_id: str) -> Topic | None:
+ """Retrieves a topic based on its ID.
+
+ Args:
+ raw_oa_topic_id (str): The ID of the topic to retrieve.
+
+ Returns:
+ Topic | None: The topic matching the provided ID, or None if not found.
+ """
+ response = await elasticsearch.get(
+ index=ESIndex.OPENALEX_TOPICS,
+ doc_id=raw_oa_topic_id,
+ source=[
+ "id",
+ "display_name",
+ "description",
+ "subfield",
+ "field",
+ "domain",
+ "works_count",
+ "cited_by_count",
+ ],
+ )
+ if response.get("found"):
+ _source = response.get("_source", {})
+ return Topic.from_dict(_source) # type: ignore
+ return None
+
+
+async def get_topic_by_id_or_raise(raw_oa_topic_id: str) -> Topic:
+ """Retrieves a topic based on its ID, raising an exception if not found.
+
+ Args:
+ raw_oa_topic_id (str): The ID of the topic to retrieve.
+
+ Raises:
+ NotFoundException: If the topic with the specified ID is not found.
+
+ Returns:
+ Topic: The topic matching the provided ID.
+ """
+ topic = await get_topic_by_id(raw_oa_topic_id)
+ if topic is None:
+ raise NotFoundException(f"Topic with ID {raw_oa_topic_id} not found.")
+ return topic
+
+
async def get_topics_by_ids(topic_ids: list[str]) -> TopicPageV2:
"""Retrieves topics based on a list of topic IDs.
@@ -80,7 +175,7 @@ async def get_topics_by_ids(topic_ids: list[str]) -> TopicPageV2:
if not topic_ids:
return TopicPageV2(elements=[], total=0, page=0, size=0)
- return await search_topics(
+ return await _search_topics(
page=0,
size=len(topic_ids),
query={"terms": {"id": topic_ids}},
diff --git a/webapp/src/app/api/.openapi-generator/FILES b/webapp/src/app/api/.openapi-generator/FILES
index ebf76e14..aa27aeaa 100644
--- a/webapp/src/app/api/.openapi-generator/FILES
+++ b/webapp/src/app/api/.openapi-generator/FILES
@@ -249,6 +249,7 @@ model/topicHeatmapTopic.ts
model/topicHeatmapValue.ts
model/topicIds.ts
model/topicPageV2.ts
+model/topicSortBy.ts
model/topicSubfield.ts
model/topicWordCloud.ts
model/topicWordCloudWord.ts
diff --git a/webapp/src/app/api/api/topicsV2.service.ts b/webapp/src/app/api/api/topicsV2.service.ts
index 92f5b93f..674c4906 100644
--- a/webapp/src/app/api/api/topicsV2.service.ts
+++ b/webapp/src/app/api/api/topicsV2.service.ts
@@ -19,7 +19,13 @@ import { Observable } from 'rxjs';
// @ts-ignore
import { HTTPValidationError } from '../model/hTTPValidationError';
// @ts-ignore
+import { SortDirection } from '../model/sortDirection';
+// @ts-ignore
+import { Topic } from '../model/topic';
+// @ts-ignore
import { TopicPageV2 } from '../model/topicPageV2';
+// @ts-ignore
+import { TopicSortBy } from '../model/topicSortBy';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
@@ -94,6 +100,61 @@ export class TopicsV2Service extends BaseService {
);
}
+ /**
+ * Returns a topic for a given topic ID.
+ * @endpoint get /api/topics/v2/single/{raw_oa_topic_id}
+ * @param rawOaTopicId The ID of the topic to retrieve.
+ * @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 getTopicById(rawOaTopicId: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable;
+ public getTopicById(rawOaTopicId: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>;
+ public getTopicById(rawOaTopicId: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>;
+ public getTopicById(rawOaTopicId: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable {
+ if (rawOaTopicId === null || rawOaTopicId === undefined) {
+ throw new Error('Required parameter rawOaTopicId was null or undefined when calling getTopicById.');
+ }
+
+ let localVarHeaders = this.defaultHeaders;
+
+ const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
+ 'application/json'
+ ]);
+ if (localVarHttpHeaderAcceptSelected !== undefined) {
+ localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
+ }
+
+ const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();
+
+ const localVarTransferCache: boolean = options?.transferCache ?? true;
+
+
+ let responseType_: 'text' | 'json' | 'blob' = 'json';
+ if (localVarHttpHeaderAcceptSelected) {
+ if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
+ responseType_ = 'text';
+ } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
+ responseType_ = 'json';
+ } else {
+ responseType_ = 'blob';
+ }
+ }
+
+ let localVarPath = `/api/topics/v2/single/${this.configuration.encodeParam({name: "rawOaTopicId", value: rawOaTopicId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`;
+ const { basePath, withCredentials } = this.configuration;
+ return this.httpClient.request('get', `${basePath}${localVarPath}`,
+ {
+ context: localVarHttpContext,
+ responseType: responseType_,
+ ...(withCredentials ? { withCredentials } : {}),
+ headers: localVarHeaders,
+ observe: observe,
+ ...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
+ reportProgress: reportProgress
+ }
+ );
+ }
+
/**
* Returns a paginated list of topics for a given list of topic IDs.
* @endpoint get /api/topics/v2/topics/id
@@ -155,4 +216,73 @@ export class TopicsV2Service extends BaseService {
);
}
+ /**
+ * Searches for topics based on the provided criteria.
+ * @endpoint get /api/topics/v2/search
+ * @param searchTerm The term to search for in topic display names.
+ * @param page The page number to retrieve.
+ * @param size The number of topics to retrieve per page.
+ * @param sortBy The field to sort by.
+ * @param sortDirection The direction to sort.
+ * @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 searchTopics(searchTerm?: string, page?: number, size?: number, sortBy?: TopicSortBy, sortDirection?: SortDirection, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable;
+ public searchTopics(searchTerm?: string, page?: number, size?: number, sortBy?: TopicSortBy, sortDirection?: SortDirection, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>;
+ public searchTopics(searchTerm?: string, page?: number, size?: number, sortBy?: TopicSortBy, sortDirection?: SortDirection, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>;
+ public searchTopics(searchTerm?: string, page?: number, size?: number, sortBy?: TopicSortBy, sortDirection?: SortDirection, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable {
+
+ let localVarQueryParameters = new HttpParams({encoder: this.encoder});
+ localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
+ searchTerm, 'search_term');
+ localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
+ page, 'page');
+ localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
+ size, 'size');
+ localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
+ sortBy, 'sort_by');
+ localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
+ sortDirection, 'sort_direction');
+
+ let localVarHeaders = this.defaultHeaders;
+
+ const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
+ 'application/json'
+ ]);
+ if (localVarHttpHeaderAcceptSelected !== undefined) {
+ localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
+ }
+
+ const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();
+
+ const localVarTransferCache: boolean = options?.transferCache ?? true;
+
+
+ let responseType_: 'text' | 'json' | 'blob' = 'json';
+ if (localVarHttpHeaderAcceptSelected) {
+ if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
+ responseType_ = 'text';
+ } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
+ responseType_ = 'json';
+ } else {
+ responseType_ = 'blob';
+ }
+ }
+
+ let localVarPath = `/api/topics/v2/search`;
+ const { basePath, withCredentials } = this.configuration;
+ return this.httpClient.request('get', `${basePath}${localVarPath}`,
+ {
+ context: localVarHttpContext,
+ params: localVarQueryParameters,
+ responseType: responseType_,
+ ...(withCredentials ? { withCredentials } : {}),
+ headers: localVarHeaders,
+ observe: observe,
+ ...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
+ reportProgress: reportProgress
+ }
+ );
+ }
+
}
diff --git a/webapp/src/app/api/model/models.ts b/webapp/src/app/api/model/models.ts
index e20b3035..8d3b5ec2 100644
--- a/webapp/src/app/api/model/models.ts
+++ b/webapp/src/app/api/model/models.ts
@@ -214,6 +214,7 @@ export * from './topicHeatmapTopic';
export * from './topicHeatmapValue';
export * from './topicIds';
export * from './topicPageV2';
+export * from './topicSortBy';
export * from './topicSubfield';
export * from './topicWordCloud';
export * from './topicWordCloudWord';
diff --git a/webapp/src/app/api/model/topicSortBy.ts b/webapp/src/app/api/model/topicSortBy.ts
new file mode 100644
index 00000000..be83fa8e
--- /dev/null
+++ b/webapp/src/app/api/model/topicSortBy.ts
@@ -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.
+ */
+
+
+export const TopicSortBy = {
+ DisplayName: 'display_name',
+ WorksCount: 'works_count',
+ CitedByCount: 'cited_by_count'
+} as const;
+export type TopicSortBy = typeof TopicSortBy[keyof typeof TopicSortBy];
+
diff --git a/webapp/src/app/app.routes.ts b/webapp/src/app/app.routes.ts
index fc5488c8..43ef3e86 100644
--- a/webapp/src/app/app.routes.ts
+++ b/webapp/src/app/app.routes.ts
@@ -58,6 +58,11 @@ import {
collaborationGraphQueryParamKeys,
collaborationGraphResolver,
} from './resolvers/collaboration-graph.resolver';
+import {
+ topicPageResolver,
+ topicQueryParamKeys,
+} from './resolvers/topic-page.resolver';
+import { topicResolver } from './resolvers/topic.resolver';
export const routes: Routes = [
{
path: '',
@@ -704,6 +709,47 @@ export const routes: Routes = [
},
],
},
+ {
+ path: 'topics',
+ canActivate: [
+ roleGuard([
+ UserRole.User,
+ UserRole.Manager,
+ UserRole.Admin,
+ UserRole.SuperAdmin,
+ ]),
+ ],
+ loadComponent: () =>
+ import('./modules/topics/topics.component').then(
+ (mod) => mod.TopicsComponent,
+ ),
+ resolve: {
+ topicPage: topicPageResolver,
+ },
+ runGuardsAndResolvers: (from, to) => {
+ return Object.values(topicQueryParamKeys).some(
+ (key) => from.queryParamMap.get(key) !== to.queryParamMap.get(key),
+ );
+ },
+ },
+ {
+ path: 'topic/:topicId',
+ canActivate: [
+ roleGuard([
+ UserRole.User,
+ UserRole.Manager,
+ UserRole.Admin,
+ UserRole.SuperAdmin,
+ ]),
+ ],
+ loadComponent: () =>
+ import('./modules/topic/topic.component').then(
+ (mod) => mod.TopicComponent,
+ ),
+ resolve: {
+ topic: topicResolver,
+ },
+ },
{
path: 'projects',
canActivate: [
diff --git a/webapp/src/app/modules/institutions/institutions.component.scss b/webapp/src/app/modules/institutions/institutions.component.scss
index ce9afb83..080f9ff6 100644
--- a/webapp/src/app/modules/institutions/institutions.component.scss
+++ b/webapp/src/app/modules/institutions/institutions.component.scss
@@ -3,54 +3,4 @@
flex-direction: column;
gap: 1rem;
padding: 1rem;
-}
-
-.cards {
- display: grid;
- gap: 1.5rem;
- grid-template-columns: repeat(auto-fit, minmax(550px, 1fr));
- padding: 0 1rem;
-}
-
-.card {
- padding: 0.5rem;
- background-color: var(--sg-background);
- transition: transform 0.3s ease;
- display: flex;
- flex-direction: column;
- gap: 0.5rem;
-}
-
-.card:hover {
- cursor: pointer;
- transform: scale(1.05);
-}
-
-.card-content {
- display: flex;
- flex-direction: column;
- justify-content: flex-end;
- gap: 0.5rem;
- flex: 1;
-}
-
-.card-metadata {
- display: flex;
- flex-direction: column;
- gap: 0.2rem;
- font-size: 0.9rem;
- color: var(--sg-text-secondary);
-}
-
-mat-card-actions {
- padding-top: 0.5rem;
- display: flex;
- gap: 0.5rem;
-}
-
-mat-card-actions a {
- width: 100%;
- text-decoration: none;
- border: 1px solid var(--sg-border);
- border-radius: var(--sg-radius-sm);
-}
+}
\ No newline at end of file
diff --git a/webapp/src/app/modules/person-publications/person-publications.component.html b/webapp/src/app/modules/person-publications/person-publications.component.html
index 57660c31..97c89212 100644
--- a/webapp/src/app/modules/person-publications/person-publications.component.html
+++ b/webapp/src/app/modules/person-publications/person-publications.component.html
@@ -32,6 +32,7 @@
topic works!
diff --git a/webapp/src/app/modules/topic/topic.component.scss b/webapp/src/app/modules/topic/topic.component.scss
new file mode 100644
index 00000000..e69de29b
diff --git a/webapp/src/app/modules/topic/topic.component.ts b/webapp/src/app/modules/topic/topic.component.ts
new file mode 100644
index 00000000..c1827f18
--- /dev/null
+++ b/webapp/src/app/modules/topic/topic.component.ts
@@ -0,0 +1,11 @@
+import { Component } from '@angular/core';
+
+@Component({
+ selector: 'app-topic',
+ imports: [],
+ templateUrl: './topic.component.html',
+ styleUrl: './topic.component.scss',
+})
+export class TopicComponent {
+
+}
diff --git a/webapp/src/app/modules/topics/topics.component.html b/webapp/src/app/modules/topics/topics.component.html
new file mode 100644
index 00000000..c0c6ff23
--- /dev/null
+++ b/webapp/src/app/modules/topics/topics.component.html
@@ -0,0 +1,22 @@
+
+
Passende Themen finden
+
+
+
+
+
+
+
+
+
diff --git a/webapp/src/app/modules/topics/topics.component.scss b/webapp/src/app/modules/topics/topics.component.scss
new file mode 100644
index 00000000..ef8c12a0
--- /dev/null
+++ b/webapp/src/app/modules/topics/topics.component.scss
@@ -0,0 +1,6 @@
+.content {
+ display: flex;
+ flex-direction: column;
+ gap: 1rem;
+ padding: 1rem;
+}
diff --git a/webapp/src/app/modules/topics/topics.component.ts b/webapp/src/app/modules/topics/topics.component.ts
new file mode 100644
index 00000000..1e017d27
--- /dev/null
+++ b/webapp/src/app/modules/topics/topics.component.ts
@@ -0,0 +1,52 @@
+import { Component, computed, input } from '@angular/core';
+import {
+ CardSearchComponent,
+ Page,
+} from '../../shared/ui/card-search/card-search.component';
+import { MatDividerModule } from '@angular/material/divider';
+import { AppTopicCardComponent } from '../../shared/ui/app-topic-card/app-topic-card.component';
+import { SortDirection, TopicPageV2, TopicSortBy } from '../../api';
+import { FilterObserver } from '../../shared/ui/selected-filters/selected-filters.component';
+import { topicQueryParamKeys } from '../../resolvers/topic-page.resolver';
+import { SelectorOption } from '../../shared/ui/query-param-selector/query-param-selector.component';
+
+@Component({
+ selector: 'app-topics',
+ imports: [CardSearchComponent, MatDividerModule, AppTopicCardComponent],
+ templateUrl: './topics.component.html',
+ styleUrl: './topics.component.scss',
+})
+export class TopicsComponent {
+ topicPage = input.required();
+
+ observers: FilterObserver[] = [
+ {
+ id: 'query',
+ queryParamKey: topicQueryParamKeys.query,
+ icon: 'search',
+ },
+ ];
+
+ readonly topicSearchQueryParamKey = topicQueryParamKeys.query;
+ readonly topicSortByQueryParamKey = topicQueryParamKeys.sortBy;
+ readonly topicSortingDirectionQueryParamKey =
+ topicQueryParamKeys.sortDirection;
+
+ page = computed(() => ({
+ page: this.topicPage().page || 0,
+ size: this.topicPage().size || 10,
+ total: this.topicPage().total || 0,
+ elements: this.topicPage().elements || [],
+ }));
+
+ sortingOptions: SelectorOption[] = [
+ { value: TopicSortBy.DisplayName, display_name: 'Name' },
+ { value: TopicSortBy.WorksCount, display_name: 'Anzahl Publikationen' },
+ { value: TopicSortBy.CitedByCount, display_name: 'Anzahl Zitationen' },
+ ];
+
+ sortingDirectionOptions: SelectorOption[] = [
+ { value: SortDirection.Asc, display_name: 'Aufsteigend' },
+ { value: SortDirection.Desc, display_name: 'Absteigend' },
+ ];
+}
diff --git a/webapp/src/app/resolvers/topic-page.resolver.ts b/webapp/src/app/resolvers/topic-page.resolver.ts
new file mode 100644
index 00000000..42122955
--- /dev/null
+++ b/webapp/src/app/resolvers/topic-page.resolver.ts
@@ -0,0 +1,39 @@
+import { ResolveFn } from '@angular/router';
+import {
+ SortDirection,
+ TopicPageV2,
+ TopicSortBy,
+ TopicsV2Service,
+} from '../api';
+import { inject } from '@angular/core';
+
+export const topicQueryParamKeys = {
+ query: 'query',
+ page: 'page',
+ size: 'size',
+ sortBy: 'sortBy',
+ sortDirection: 'sortDirection',
+} as const;
+
+export const topicPageResolver: ResolveFn = (route, state) => {
+ const query = route.queryParamMap.get(topicQueryParamKeys.query) || undefined;
+ const page = Number(route.queryParamMap.get(topicQueryParamKeys.page) ?? '0');
+ const size = Number(
+ route.queryParamMap.get(topicQueryParamKeys.size) ?? '10',
+ );
+ const sortBy: TopicSortBy =
+ (route.queryParamMap.get(topicQueryParamKeys.sortBy) as TopicSortBy) ??
+ TopicSortBy.WorksCount;
+ const sortDirection =
+ (route.queryParamMap.get(
+ topicQueryParamKeys.sortDirection,
+ ) as SortDirection) ?? SortDirection.Desc;
+
+ return inject(TopicsV2Service).searchTopics(
+ query,
+ page,
+ size,
+ sortBy,
+ sortDirection,
+ );
+};
diff --git a/webapp/src/app/resolvers/topic.resolver.ts b/webapp/src/app/resolvers/topic.resolver.ts
new file mode 100644
index 00000000..62bb4050
--- /dev/null
+++ b/webapp/src/app/resolvers/topic.resolver.ts
@@ -0,0 +1,12 @@
+import { ResolveFn } from '@angular/router';
+import { Topic, TopicsV2Service } from '../api';
+import { inject } from '@angular/core';
+
+export const topicResolver: ResolveFn = (route, state) => {
+ const topicId = route.paramMap.get('topicId');
+ if (!topicId) {
+ throw new Error('Topic ID is required');
+ }
+
+ return inject(TopicsV2Service).getTopicById(topicId);
+};
diff --git a/webapp/src/app/shared/ui/app-author-card/app-author-card.component.html b/webapp/src/app/shared/ui/app-author-card/app-author-card.component.html
index 6197f645..b0db0217 100644
--- a/webapp/src/app/shared/ui/app-author-card/app-author-card.component.html
+++ b/webapp/src/app/shared/ui/app-author-card/app-author-card.component.html
@@ -1,9 +1,11 @@
+@let author = this.author();
+
- {{ author().display_name }}
- @if (author()?.last_known_institutions?.[0]?.display_name) {
+ {{ author.display_name }}
+ @if (author.last_known_institutions?.[0]?.display_name) {
- {{ author()?.last_known_institutions?.[0]?.display_name }}
+ {{ author.last_known_institutions?.[0]?.display_name }}
}
@@ -11,22 +13,22 @@
- @if (author().works_count) {
+ @if (author.works_count) {
menu_book
- {{ author().works_count }} Publikationen
+ {{ author.works_count }} Publikationen
}
- @if (author().cited_by_count) {
+ @if (author.cited_by_count) {
format_quote
- {{ author().cited_by_count }} Zitationen
+ {{ author.cited_by_count }} Zitationen
}
- @if (author().summary_stats?.h_index) {
+ @if (author.summary_stats?.h_index) {
trending_up
- h-Index: {{ author().summary_stats?.h_index }}
+ h-Index: {{ author.summary_stats?.h_index }}
}
@@ -37,21 +39,21 @@
info
Übersicht
menu_book
Publikationen
work
Projekte
diff --git a/webapp/src/app/shared/ui/app-author-chip/app-author-chip.component.html b/webapp/src/app/shared/ui/app-author-chip/app-author-chip.component.html
index 470511be..f7f171da 100644
--- a/webapp/src/app/shared/ui/app-author-chip/app-author-chip.component.html
+++ b/webapp/src/app/shared/ui/app-author-chip/app-author-chip.component.html
@@ -4,7 +4,7 @@
[tooltipInputs]="{ authorId: rawOaAuthorId() }"
(keydown)="_onChipClick($event)"
(click)="_onChipClick($event)">
-
+
@if (showIcon()) {
{{ icon() }}
}
diff --git a/webapp/src/app/shared/ui/app-author-chip/app-author-chip.component.scss b/webapp/src/app/shared/ui/app-author-chip/app-author-chip.component.scss
index db1e34d7..6414ee8a 100644
--- a/webapp/src/app/shared/ui/app-author-chip/app-author-chip.component.scss
+++ b/webapp/src/app/shared/ui/app-author-chip/app-author-chip.component.scss
@@ -24,3 +24,33 @@
cursor: pointer;
}
}
+
+.chip-content {
+ display: flex;
+ align-items: center;
+ gap: 0.5rem;
+}
+
+:host.is-mini-size {
+ ::ng-deep .mat-mdc-chip {
+ height: 1.5rem;
+ }
+
+ .chip-content {
+ font-size: 0.75rem;
+ }
+
+ mat-icon {
+ font-size: 0.75rem;
+ width: 0.75rem;
+ height: 0.75rem;
+ }
+}
+
+.topic-icon {
+ --icon-size: 1rem;
+
+ font-size: var(--icon-size);
+ height: var(--icon-size);
+ width: var(--icon-size);
+}
diff --git a/webapp/src/app/shared/ui/app-author-chip/app-author-chip.component.ts b/webapp/src/app/shared/ui/app-author-chip/app-author-chip.component.ts
index cf63887b..60995687 100644
--- a/webapp/src/app/shared/ui/app-author-chip/app-author-chip.component.ts
+++ b/webapp/src/app/shared/ui/app-author-chip/app-author-chip.component.ts
@@ -19,6 +19,7 @@ import { MatChipsModule } from '@angular/material/chips';
'[style.--border-color]':
'isSelected() ? "var(--sg-primary)" : "var(--sg-border)"',
'[class.is-clickable]': 'isClickable()',
+ '[class.is-mini-size]': 'isMiniSize()',
},
selector: 'app-author-chip',
imports: [MatIconModule, MatChipsModule, ComponentTooltipDirective],
@@ -45,6 +46,9 @@ export class AppAuthorChipComponent {
_author = signal(undefined);
+ size = input<'normal' | 'mini'>('normal');
+ isMiniSize = computed(() => this.size() === 'mini');
+
constructor() {
effect(() => {
const author = this.author();
diff --git a/webapp/src/app/shared/ui/app-institution-chip/app-institution-chip.component.html b/webapp/src/app/shared/ui/app-institution-chip/app-institution-chip.component.html
index 3e07cb38..b643580c 100644
--- a/webapp/src/app/shared/ui/app-institution-chip/app-institution-chip.component.html
+++ b/webapp/src/app/shared/ui/app-institution-chip/app-institution-chip.component.html
@@ -1,10 +1,10 @@
-
+
@if (showIcon()) {
{{ icon() }}
}
diff --git a/webapp/src/app/shared/ui/app-institution-chip/app-institution-chip.component.scss b/webapp/src/app/shared/ui/app-institution-chip/app-institution-chip.component.scss
index c919dcbc..5ec57954 100644
--- a/webapp/src/app/shared/ui/app-institution-chip/app-institution-chip.component.scss
+++ b/webapp/src/app/shared/ui/app-institution-chip/app-institution-chip.component.scss
@@ -24,3 +24,25 @@
cursor: pointer;
}
}
+
+.chip-content {
+ display: flex;
+ align-items: center;
+ gap: 0.5rem;
+}
+
+:host.is-mini-size {
+ ::ng-deep .mat-mdc-chip {
+ height: 1.5rem;
+ }
+
+ .chip-content {
+ font-size: 0.75rem;
+ }
+
+ mat-icon {
+ font-size: 0.75rem;
+ width: 0.75rem;
+ height: 0.75rem;
+ }
+}
diff --git a/webapp/src/app/shared/ui/app-institution-chip/app-institution-chip.component.ts b/webapp/src/app/shared/ui/app-institution-chip/app-institution-chip.component.ts
index 9200dd3b..5a2a333b 100644
--- a/webapp/src/app/shared/ui/app-institution-chip/app-institution-chip.component.ts
+++ b/webapp/src/app/shared/ui/app-institution-chip/app-institution-chip.component.ts
@@ -19,6 +19,7 @@ import { ComponentTooltipDirective } from '../../../directives/component-tooltip
'[style.--border-color]':
'isSelected() ? "var(--sg-primary)" : "var(--sg-border)"',
'[class.is-clickable]': 'isClickable()',
+ '[class.is-mini-size]': 'isMiniSize()',
},
selector: 'app-institution-chip',
imports: [MatIconModule, MatChipsModule, ComponentTooltipDirective],
@@ -26,7 +27,7 @@ import { ComponentTooltipDirective } from '../../../directives/component-tooltip
styleUrl: './app-institution-chip.component.scss',
})
export class AppInstitutionChipComponent {
- readonly InstitutionTooltipComponent = AppInstitutionTooltipComponent;
+ readonly AppInstitutionTooltipComponent = AppInstitutionTooltipComponent;
private readonly institutionsService = inject(InstitutionsV2Service);
isSelected = input(false);
@@ -45,6 +46,9 @@ export class AppInstitutionChipComponent {
_institution = signal(undefined);
+ size = input<'normal' | 'mini'>('normal');
+ isMiniSize = computed(() => this.size() === 'mini');
+
constructor() {
effect(() => {
const institution = this.institution();
diff --git a/webapp/src/app/shared/ui/app-institution-tooltip/app-institution-tooltip.component.ts b/webapp/src/app/shared/ui/app-institution-tooltip/app-institution-tooltip.component.ts
index 4a35f5d9..2204746e 100644
--- a/webapp/src/app/shared/ui/app-institution-tooltip/app-institution-tooltip.component.ts
+++ b/webapp/src/app/shared/ui/app-institution-tooltip/app-institution-tooltip.component.ts
@@ -32,11 +32,4 @@ export class AppInstitutionTooltipComponent {
});
});
}
-
- stripOpenAlexId(id: string | null | undefined): string | undefined {
- if (!id) {
- return undefined;
- }
- return id.replace('https://openalex.org/', '');
- }
}
diff --git a/webapp/src/app/shared/ui/app-menu/app-menu.component.ts b/webapp/src/app/shared/ui/app-menu/app-menu.component.ts
index 25b9782e..df9ee95e 100644
--- a/webapp/src/app/shared/ui/app-menu/app-menu.component.ts
+++ b/webapp/src/app/shared/ui/app-menu/app-menu.component.ts
@@ -12,6 +12,8 @@ import { ConfirmationDialogComponent } from '../confirmation-dialog/confirmation
import { MatCardContent, MatCardModule } from '@angular/material/card';
import { MatProgressSpinner } from '@angular/material/progress-spinner';
import { activeInstitutionPersonListQueryParams } from '../../person-list-query-params';
+import { topicQueryParamKeys } from '../../../resolvers/topic-page.resolver';
+import { SortDirection, TopicSortBy } from '../../../api';
type NavItem = {
label: string;
@@ -101,7 +103,20 @@ export class AppMenuComponent {
page: 0,
size: 10,
sort_by: 'works_count',
- sorting_order: 'desc',
+ sorting_order: SortDirection.Desc,
+ },
+ },
+ {
+ label: 'Themen',
+ icon: 'topic',
+ route: '/topics',
+ disabled: false,
+ queryParams: {
+ [topicQueryParamKeys.query]: '',
+ [topicQueryParamKeys.page]: 0,
+ [topicQueryParamKeys.size]: 10,
+ [topicQueryParamKeys.sortBy]: TopicSortBy.CitedByCount,
+ [topicQueryParamKeys.sortDirection]: SortDirection.Desc,
},
},
{
diff --git a/webapp/src/app/shared/ui/app-topic-card/app-topic-card.component.html b/webapp/src/app/shared/ui/app-topic-card/app-topic-card.component.html
new file mode 100644
index 00000000..66b53915
--- /dev/null
+++ b/webapp/src/app/shared/ui/app-topic-card/app-topic-card.component.html
@@ -0,0 +1,52 @@
+@let topic = this.topic();
+
+
+
+ {{ topic.display_name }}
+ {{ subtitle() }}
+
+
+
+
+
+ {{ description() }}
+
+
+ menu_book
+ {{
+ topic.works_count | number: undefined : 'de'
+ }}
+ Publikationen
+
+
+ format_quote
+ {{
+ topic.cited_by_count | number: undefined : 'de'
+ }}
+ Zitationen
+
+
+
+
+
+
+
+
+
+ info
+ Übersicht
+
+
+
+
diff --git a/webapp/src/app/shared/ui/app-topic-card/app-topic-card.component.scss b/webapp/src/app/shared/ui/app-topic-card/app-topic-card.component.scss
new file mode 100644
index 00000000..4545bac8
--- /dev/null
+++ b/webapp/src/app/shared/ui/app-topic-card/app-topic-card.component.scss
@@ -0,0 +1,49 @@
+:host {
+ --topic-border: color-mix(in srgb, hsl(var(--topic-color)) 72%, #ffffff);
+ --topic-background: color-mix(in srgb, hsl(var(--topic-color)) 8%, #ffffff);
+
+ --mat-divider-color: var(--topic-border);
+
+ ::ng-deep .mdc-button--outlined {
+ border-color: var(--topic-border) !important;
+ }
+}
+
+.card-content {
+ display: flex;
+ flex-direction: column;
+ gap: 1rem;
+
+ background-color: var(--topic-background);
+ border: 1px solid var(--topic-border);
+}
+
+.subtitle {
+ display: flex;
+ align-items: center;
+ gap: 0.5rem;
+ color: var(--sg-text-muted);
+}
+
+.metrics {
+ display: flex;
+ flex-direction: column;
+ gap: 0.5rem;
+ font-size: 0.875rem;
+}
+
+.metric-item {
+ display: flex;
+ align-items: center;
+ gap: 0.25rem;
+ color: var(--sg-text-muted);
+}
+
+.card-actions {
+ display: flex;
+ gap: 0.5rem;
+}
+
+.card-action {
+ width: 100%;
+}
diff --git a/webapp/src/app/shared/ui/app-topic-card/app-topic-card.component.ts b/webapp/src/app/shared/ui/app-topic-card/app-topic-card.component.ts
new file mode 100644
index 00000000..ecf8affe
--- /dev/null
+++ b/webapp/src/app/shared/ui/app-topic-card/app-topic-card.component.ts
@@ -0,0 +1,58 @@
+import { Component, computed, input } from '@angular/core';
+import { Topic } from '../../../api';
+import { MatCardModule } from '@angular/material/card';
+import { MatDividerModule } from '@angular/material/divider';
+import { MatIconModule } from '@angular/material/icon';
+import { RouterModule } from '@angular/router';
+import { DecimalPipe } from '@angular/common';
+import { MatButtonModule } from '@angular/material/button';
+import { topicHierarchyColor } from '../../../resolvers/utils/topic-colors';
+
+@Component({
+ host: {
+ '[style.--topic-color]': 'color()',
+ },
+ selector: 'app-topic-card',
+ imports: [
+ MatCardModule,
+ MatDividerModule,
+ MatIconModule,
+ MatButtonModule,
+ RouterModule,
+ DecimalPipe,
+ ],
+ templateUrl: './app-topic-card.component.html',
+ styleUrl: './app-topic-card.component.scss',
+})
+export class AppTopicCardComponent {
+ topic = input.required();
+
+ stripOpenAlexId(id: string | null | undefined): string | undefined {
+ if (!id) {
+ return undefined;
+ }
+ return id.replace('https://openalex.org/', '');
+ }
+
+ subtitle = computed(() => {
+ return `${this.topic().subfield?.display_name} - ${this.topic().field?.display_name} - ${this.topic().domain?.display_name}`;
+ });
+
+ description = computed(() => {
+ return this.topic().description || 'Keine Beschreibung verfügbar';
+ });
+
+ color = computed(() => {
+ const topic = this.topic();
+ return topicHierarchyColor({
+ id: topic.id ?? undefined,
+ name: topic.display_name ?? undefined,
+ field_id: topic.field?.id ?? undefined,
+ field_name: topic.field?.display_name ?? undefined,
+ domain_id: topic.domain?.id ?? undefined,
+ domain_name: topic.domain?.display_name ?? undefined,
+ })
+ .replace('hsl(', '')
+ .replace(')', '');
+ });
+}
diff --git a/webapp/src/app/shared/ui/app-topic-chip/app-topic-chip.component.html b/webapp/src/app/shared/ui/app-topic-chip/app-topic-chip.component.html
index 007218f5..11bbb37d 100644
--- a/webapp/src/app/shared/ui/app-topic-chip/app-topic-chip.component.html
+++ b/webapp/src/app/shared/ui/app-topic-chip/app-topic-chip.component.html
@@ -1,10 +1,10 @@
-
+
@if (showIcon()) {
{{ icon() }}
}
diff --git a/webapp/src/app/shared/ui/app-topic-chip/app-topic-chip.component.scss b/webapp/src/app/shared/ui/app-topic-chip/app-topic-chip.component.scss
index e8ee4118..f6e768ce 100644
--- a/webapp/src/app/shared/ui/app-topic-chip/app-topic-chip.component.scss
+++ b/webapp/src/app/shared/ui/app-topic-chip/app-topic-chip.component.scss
@@ -6,6 +6,9 @@
background-color: var(--topic-background);
border: 1px solid var(--topic-border);
border-radius: var(--sg-radius-sm);
+ display: flex;
+ align-items: center;
+ gap: 0.5rem;
}
:host.is-clickable {
@@ -13,3 +16,41 @@
cursor: pointer;
}
}
+
+:host.is-selected {
+ --topic-border: color-mix(in srgb, hsl(var(--topic-color)) 72%, #ffffff);
+
+ border: 1px solid white;
+ border-radius: var(--sg-radius-sm);
+ box-shadow: 0 0 0 2px var(--topic-border);
+}
+
+.chip-content {
+ display: flex;
+ align-items: center;
+ gap: 0.5rem;
+}
+
+:host.is-mini-size {
+ ::ng-deep .mat-mdc-chip {
+ height: 1.5rem;
+ }
+
+ .chip-content {
+ font-size: 0.75rem;
+ }
+
+ mat-icon {
+ font-size: 0.75rem;
+ width: 0.75rem;
+ height: 0.75rem;
+ }
+}
+
+.topic-icon {
+ --icon-size: 1rem;
+
+ font-size: var(--icon-size);
+ height: var(--icon-size);
+ width: var(--icon-size);
+}
diff --git a/webapp/src/app/shared/ui/app-topic-chip/app-topic-chip.component.ts b/webapp/src/app/shared/ui/app-topic-chip/app-topic-chip.component.ts
index 793ff652..d0859901 100644
--- a/webapp/src/app/shared/ui/app-topic-chip/app-topic-chip.component.ts
+++ b/webapp/src/app/shared/ui/app-topic-chip/app-topic-chip.component.ts
@@ -1,15 +1,26 @@
-import { Component, computed, input, output } from '@angular/core';
-import { Topic } from '../../../api';
-import { TopicTooltipComponent } from '../topic-tooltip/topic-tooltip.component';
+import {
+ Component,
+ computed,
+ effect,
+ inject,
+ input,
+ output,
+ signal,
+} from '@angular/core';
+import { Topic, TopicsV2Service } from '../../../api';
import { MatChipsModule } from '@angular/material/chips';
import { ComponentTooltipDirective } from '../../../directives/component-tooltip.directive';
import { topicHierarchyColor } from '../../../resolvers/utils/topic-colors';
import { MatIconModule } from '@angular/material/icon';
+import { AppTopicTooltipComponent } from '../app-topic-tooltip/app-topic-tooltip.component';
@Component({
host: {
'[style.--topic-color]': 'color()',
+ '[style.--border-width]': 'isSelected() ? "3px" : "1px"',
'[class.is-clickable]': 'isClickable()',
+ '[class.is-selected]': 'isSelected()',
+ '[class.is-mini-size]': 'isMiniSize()',
},
selector: 'app-topic-chip-2',
imports: [MatChipsModule, ComponentTooltipDirective, MatIconModule],
@@ -17,9 +28,18 @@ import { MatIconModule } from '@angular/material/icon';
styleUrl: './app-topic-chip.component.scss',
})
export class AppTopicChipComponent {
- readonly TopicToolTipComponent = TopicTooltipComponent;
+ readonly AppTopicTooltipComponent = AppTopicTooltipComponent;
+ private readonly topicsService = inject(TopicsV2Service);
topic = input.required();
+ rawOaTopicId = computed(() => {
+ return this.stripOpenAlexId(this.topic()?.id);
+ });
+ topicId = input(undefined);
+ _topic = signal(undefined);
+
+ size = input<'normal' | 'mini'>('normal');
+ isMiniSize = computed(() => this.size() === 'mini');
isSelected = input(false);
@@ -27,11 +47,29 @@ export class AppTopicChipComponent {
handleChipClick = output();
showIcon = input(false);
- icon = input('label');
+ icon = input('topic');
showCount = input(false);
count = input(0);
+ constructor() {
+ effect(() => {
+ const topic = this.topic();
+ const topicId = this.topicId();
+ if (!topic && !topicId) {
+ this._topic.set(undefined);
+ }
+
+ if (topic) {
+ this._topic.set(topic);
+ } else if (topicId) {
+ this.topicsService.getTopicById(topicId).subscribe((fetchedTopic) => {
+ this._topic.set(fetchedTopic);
+ });
+ }
+ });
+ }
+
color = computed(() => {
const topic = this.topic();
return topicHierarchyColor({
@@ -47,10 +85,16 @@ export class AppTopicChipComponent {
});
_onChipClick(event: MouseEvent | KeyboardEvent) {
- if (this.handleChipClick) {
- this.handleChipClick.emit(this.topic());
+ const topic = this.topic();
+ if (this.isClickable() && this.handleChipClick && topic) {
+ this.handleChipClick.emit(topic);
}
+ }
- console.log('Chip clicked:', event);
+ stripOpenAlexId(id: string | null | undefined): string | undefined {
+ if (!id) {
+ return undefined;
+ }
+ return id.replace('https://openalex.org/', '');
}
}
diff --git a/webapp/src/app/shared/ui/app-topic-tooltip/app-topic-tooltip.component.html b/webapp/src/app/shared/ui/app-topic-tooltip/app-topic-tooltip.component.html
new file mode 100644
index 00000000..e34a20b3
--- /dev/null
+++ b/webapp/src/app/shared/ui/app-topic-tooltip/app-topic-tooltip.component.html
@@ -0,0 +1,5 @@
+@let topic = this._topic();
+
+@if (topic) {
+
+}
diff --git a/webapp/src/app/shared/ui/app-topic-tooltip/app-topic-tooltip.component.scss b/webapp/src/app/shared/ui/app-topic-tooltip/app-topic-tooltip.component.scss
new file mode 100644
index 00000000..e69de29b
diff --git a/webapp/src/app/shared/ui/app-topic-tooltip/app-topic-tooltip.component.ts b/webapp/src/app/shared/ui/app-topic-tooltip/app-topic-tooltip.component.ts
new file mode 100644
index 00000000..f86a6750
--- /dev/null
+++ b/webapp/src/app/shared/ui/app-topic-tooltip/app-topic-tooltip.component.ts
@@ -0,0 +1,32 @@
+import { Component, effect, inject, input, signal } from '@angular/core';
+import { Topic, TopicsV2Service } from '../../../api';
+import { AppTopicCardComponent } from '../app-topic-card/app-topic-card.component';
+
+@Component({
+ selector: 'app-app-topic-tooltip',
+ imports: [AppTopicCardComponent],
+ templateUrl: './app-topic-tooltip.component.html',
+ styleUrl: './app-topic-tooltip.component.scss',
+})
+export class AppTopicTooltipComponent {
+ private readonly topicsService = inject(TopicsV2Service);
+
+ topicId = input.required();
+
+ _topic = signal(undefined);
+
+ _isLoading = signal(false);
+ constructor() {
+ effect(() => {
+ const topicId = this.topicId();
+ if (!topicId) {
+ this._topic.set(undefined);
+ }
+ this._isLoading.set(true);
+ this.topicsService.getTopicById(topicId).subscribe((topic) => {
+ this._topic.set(topic);
+ this._isLoading.set(false);
+ });
+ });
+ }
+}
diff --git a/webapp/src/app/shared/ui/publication-table/publication-table.component.html b/webapp/src/app/shared/ui/publication-table/publication-table.component.html
index 9b7cb52e..a54e65a6 100644
--- a/webapp/src/app/shared/ui/publication-table/publication-table.component.html
+++ b/webapp/src/app/shared/ui/publication-table/publication-table.component.html
@@ -79,15 +79,16 @@
? publicationInstitutions
: publicationInstitutions.slice(0, 3);