implement keyword select and dfg status diagramm #250

Merged
farajollahi merged 2 commits from dfg-status-dashboard into dev 2026-07-28 11:06:25 +02:00
16 changed files with 676 additions and 24 deletions
+8
View File
@@ -34,6 +34,14 @@ class BmbfProjectStatusStatistics(BaseModel):
completed: int
class DfgProjectStatusStatistics(BaseModel):
institution_id: str
organization_name: str
ongoing: int
upcoming: int
completed: int
class DfgProjectTopic(BaseModel):
id: str
name: str
+22
View File
@@ -12,6 +12,7 @@ from .model import (
BmbfProjectStatusStatistics,
DashboardStatisticValue,
DashboardStatistics,
DfgProjectStatusStatistics,
DfgProjectTopics,
EuProjectStatusStatistics,
TopAuthorStatistics,
@@ -22,6 +23,7 @@ from .service import (
get_dashboard_bmbf_project_statuses,
get_dashboard_bmbf_projects,
get_dashboard_dfg_projects,
get_dashboard_dfg_project_statuses,
get_dashboard_dfg_topics,
get_dashboard_eu_projects,
get_dashboard_eu_project_statuses,
@@ -210,6 +212,26 @@ async def dashboard_dfg_projects(
)
@router.get(
"/projects/dfg/status",
operation_id="getDashboardDfgProjectStatuses",
response_model=DfgProjectStatusStatistics,
)
async def dashboard_dfg_project_statuses(
from_year: int | None = Query(default=None, ge=1900, le=2100),
to_year: int | None = Query(default=None, ge=1900, le=2100),
session: Session = Depends(get_session),
access_token: AccessToken = auth_service.CurrentUserAccessTokenPayloadDep,
) -> DfgProjectStatusStatistics:
organization = get_dashboard_organization(session, access_token)
return await get_dashboard_dfg_project_statuses(
organization.openalex_institution_id,
organization.name,
from_year=from_year,
to_year=to_year,
)
@router.get(
"/projects/dfg/topics",
operation_id="getDashboardDfgProjectTopics",
+103
View File
@@ -25,6 +25,7 @@ from .model import (
DashboardStatisticValue,
DashboardStatistics,
DfgProjectTopic,
DfgProjectStatusStatistics,
DfgProjectTopics,
EuProjectStatusStatistics,
TopAuthor,
@@ -495,6 +496,108 @@ async def get_dashboard_dfg_projects(
)
async def get_dashboard_dfg_project_statuses(
institution_id: str,
organization_name: str,
from_year: int | None = None,
to_year: int | None = None,
) -> DfgProjectStatusStatistics:
normalized_id = _normalize_institution_id(institution_id)
period = _dashboard_period(from_year, to_year)
project_ids = await _get_dfg_project_ids_for_institution(
normalized_id,
)
if not project_ids:
return DfgProjectStatusStatistics(
institution_id=normalized_id,
organization_name=organization_name,
ongoing=0,
upcoming=0,
completed=0,
)
selected_project_filters: list[dict[str, Any]] = [
{
"terms": {
"projects.project_id": [
int(project_id) for project_id in project_ids
]
}
}
]
if period_filter := _project_overlap_filter(
"projects.funding_start",
"projects.funding_end",
period,
missing_end_is_ongoing=True,
):
selected_project_filters.append(period_filter)
response = await elasticsearch.search(
index=ESIndex.DFG_INSTITUTES_V2,
body={
"size": 0,
"aggs": {
"projects_nested": {
"nested": {"path": "projects"},
"aggs": {
"selected_projects": {
"filter": (
selected_project_filters[0]
if len(selected_project_filters) == 1
else {"bool": {"filter": selected_project_filters}}
),
"aggs": {
"ongoing": {
"filter": {
"match_phrase": {
"projects.status_de": "laufend"
}
},
"aggs": {
"projects": {
"cardinality": {
"field": "projects.project_id"
}
}
},
},
"completed": {
"filter": {
"match_phrase": {
"projects.status_de": "abgeschlossen"
}
},
"aggs": {
"projects": {
"cardinality": {
"field": "projects.project_id"
}
}
},
},
},
}
},
}
},
},
cluster=ESCluster.INSE,
)
aggregations = (
response.get("aggregations", {})
.get("projects_nested", {})
.get("selected_projects", {})
)
return DfgProjectStatusStatistics(
institution_id=normalized_id,
organization_name=organization_name,
ongoing=_project_status_count(aggregations, "ongoing"),
upcoming=0,
completed=_project_status_count(aggregations, "completed"),
)
async def get_dashboard_dfg_topics(
institution_id: str,
organization_name: str,
@@ -14,6 +14,7 @@ from inse.authors.institution_membership_query import (
from inse.dashboard.service import (
get_dashboard_bmbf_project_statuses,
get_dashboard_organization,
get_dashboard_dfg_project_statuses,
get_dashboard_dfg_topics,
get_dashboard_eu_project_statuses,
get_dashboard_patents,
@@ -227,6 +228,102 @@ async def test_dashboard_bmbf_project_statuses_uses_funding_dates():
}
@pytest.mark.anyio
async def test_dashboard_dfg_project_statuses_uses_nested_status_de():
with patch(
"inse.dashboard.service._get_dfg_project_ids_for_institution",
new=AsyncMock(return_value=["123", "456"]),
) as project_ids, patch(
"inse.dashboard.service.elasticsearch.search",
new=AsyncMock(
return_value={
"aggregations": {
"projects_nested": {
"selected_projects": {
"ongoing": {"projects": {"value": 1}},
"completed": {"projects": {"value": 1}},
}
}
}
}
),
) as search:
result = await get_dashboard_dfg_project_statuses(
ORG_INSTITUTION_ID,
"Example Org",
from_year=2020,
to_year=2024,
)
project_ids.assert_awaited_once_with(
ORG_INSTITUTION_ID,
)
assert result.model_dump() == {
"institution_id": ORG_INSTITUTION_ID,
"organization_name": "Example Org",
"ongoing": 1,
"upcoming": 0,
"completed": 1,
}
call = search.await_args
assert call.kwargs["index"] == ESIndex.DFG_INSTITUTES_V2
selected = call.kwargs["body"]["aggs"]["projects_nested"]["aggs"][
"selected_projects"
]
assert selected["filter"] == {
"bool": {
"filter": [
{"terms": {"projects.project_id": [123, 456]}},
{
"bool": {
"filter": [
{
"range": {
"projects.funding_start": {"lte": 2024}
}
},
{
"bool": {
"should": [
{
"range": {
"projects.funding_end": {
"gte": 2020
}
}
},
{
"bool": {
"must_not": {
"exists": {
"field": "projects.funding_end"
}
}
}
},
],
"minimum_should_match": 1,
}
},
]
}
},
]
}
}
assert selected["aggs"]["ongoing"]["filter"] == {
"match_phrase": {"projects.status_de": "laufend"}
}
assert selected["aggs"]["completed"]["filter"] == {
"match_phrase": {"projects.status_de": "abgeschlossen"}
}
assert all(
selected["aggs"][status]["aggs"]["projects"]["cardinality"]["field"]
== "projects.project_id"
for status in ("ongoing", "completed")
)
@pytest.mark.anyio
async def test_dashboard_statistics_counts_organization_data_and_all_projects():
async def search(**kwargs):
+21 -1
View File
@@ -74,7 +74,27 @@ async def search_topics(
query = None
if search_term:
query = {"match_phrase_prefix": {"display_name": search_term}}
search_terms = [
term.strip() for term in search_term.split(",") if term.strip()
]
if len(search_terms) == 1:
query = {
"match_phrase_prefix": {"display_name": search_terms[0]}
}
elif search_terms:
query = {
"bool": {
"should": [
{
"match_phrase_prefix": {
"display_name": search_term
}
}
for search_term in search_terms
],
"minimum_should_match": 1,
}
}
return await _search_topics(
page=page,
@@ -0,0 +1,41 @@
from unittest.mock import AsyncMock, patch
import pytest
from inse.topics.v2.service import search_topics
@pytest.fixture
def anyio_backend():
return "asyncio"
@pytest.mark.anyio
async def test_search_topics_treats_comma_separated_terms_as_alternatives():
with patch(
"inse.topics.v2.service.elasticsearch.search",
new=AsyncMock(
return_value={
"hits": {"hits": [], "total": {"value": 0}}
}
),
) as search:
await search_topics("Artificial Intelligence, Machine Learning")
assert search.await_args.kwargs["query"] == {
"bool": {
"should": [
{
"match_phrase_prefix": {
"display_name": "Artificial Intelligence"
}
},
{
"match_phrase_prefix": {
"display_name": "Machine Learning"
}
},
],
"minimum_should_match": 1,
}
}
+8 -3
View File
@@ -758,9 +758,14 @@ export const routes: Routes = [
topicPage: topicPageResolver,
},
runGuardsAndResolvers: (from, to) => {
return Object.values(topicQueryParamKeys).some(
(key) => from.queryParamMap.get(key) !== to.queryParamMap.get(key),
);
return Object.values(topicQueryParamKeys).some((key) => {
const fromValues = from.queryParamMap.getAll(key);
const toValues = to.queryParamMap.getAll(key);
return (
fromValues.length !== toValues.length ||
fromValues.some((value, index) => value !== toValues[index])
);
});
},
},
{
@@ -44,6 +44,14 @@ export interface BmbfProjectStatusStatistics {
completed: number;
}
export interface DfgProjectStatusStatistics {
institution_id: string;
organization_name: string;
ongoing: number;
upcoming: number;
completed: number;
}
export interface DfgProjectTopic {
id: string;
name: string;
@@ -149,6 +157,15 @@ export class DashboardStatisticsService {
);
}
getDfgProjectStatuses(
period: DashboardPeriodBounds = {},
): Observable<DfgProjectStatusStatistics> {
return this.httpClient.get<DfgProjectStatusStatistics>(
`${this.apiConfiguration?.basePath ?? ''}/api/dashboard/projects/dfg/status`,
{ params: this.periodParams(period) },
);
}
getBmbfProjectCount(
period: DashboardPeriodBounds = {},
): Observable<DashboardStatisticValue> {
@@ -165,20 +165,22 @@
@if (
euProjectStatusesLoading ||
bmbfProjectStatusesLoading ||
dfgProjectStatusesLoading ||
euProjectStatusesError ||
bmbfProjectStatusesError ||
(euProjectStatuses && bmbfProjectStatuses)
dfgProjectStatusesError ||
(euProjectStatuses && bmbfProjectStatuses && dfgProjectStatuses)
) {
<section class="topic-heatmap-section">
<header class="topic-heatmap-header">
<div>
<h2>Projektstatus nach Fördergeber</h2>
<p>
Laufende, kommende und abgeschlossene EU- und Bund-Projekte Ihrer
Organisation.
Laufende, kommende und abgeschlossene EU-, Bund- und DFG-Projekte
Ihrer Organisation.
</p>
</div>
@if (euProjectStatuses && bmbfProjectStatuses) {
@if (euProjectStatuses && bmbfProjectStatuses && dfgProjectStatuses) {
<div class="project-status-summary">
<span>
EU:
@@ -196,11 +198,23 @@
bmbfProjectStatuses.completed | number
}}
</span>
<span>
DFG:
{{
dfgProjectStatuses.ongoing +
dfgProjectStatuses.upcoming +
dfgProjectStatuses.completed | number
}}
</span>
</div>
}
</header>
@if (euProjectStatusesLoading || bmbfProjectStatusesLoading) {
@if (
euProjectStatusesLoading ||
bmbfProjectStatusesLoading ||
dfgProjectStatusesLoading
) {
<div class="project-status-loading" role="status" aria-live="polite">
<app-loading
text="Projektstatus wird geladen …"
@@ -208,14 +222,22 @@
size="64"
diameter="64"></app-loading>
</div>
} @else if (euProjectStatusesError || bmbfProjectStatusesError) {
} @else if (
euProjectStatusesError ||
bmbfProjectStatusesError ||
dfgProjectStatusesError
) {
<p class="statistics-error">
Der Status der EU- und Bund-Projekte konnte nicht geladen werden.
Der Status der EU-, Bund- und DFG-Projekte konnte nicht geladen
werden.
</p>
} @else if (euProjectStatuses && bmbfProjectStatuses) {
} @else if (
euProjectStatuses && bmbfProjectStatuses && dfgProjectStatuses
) {
<app-eu-project-status-chart
[statuses]="euProjectStatuses"
[bmbfStatuses]="bmbfProjectStatuses"></app-eu-project-status-chart>
[bmbfStatuses]="bmbfProjectStatuses"
[dfgStatuses]="dfgProjectStatuses"></app-eu-project-status-chart>
}
</section>
}
@@ -23,6 +23,7 @@ import {
DashboardStatisticValue,
DashboardStatistics,
DashboardStatisticsService,
DfgProjectStatusStatistics,
DfgProjectTopics,
EuProjectStatusStatistics,
TopAuthor,
@@ -101,6 +102,9 @@ export class DashboardComponent implements OnInit {
bmbfProjectStatuses?: BmbfProjectStatusStatistics;
bmbfProjectStatusesLoading = false;
bmbfProjectStatusesError = false;
dfgProjectStatuses?: DfgProjectStatusStatistics;
dfgProjectStatusesLoading = false;
dfgProjectStatusesError = false;
readonly topicTreemapMinYear = 1900;
readonly topicTreemapMaxYear = new Date().getFullYear();
dashboardPeriodMode: DashboardPeriodMode = 'all_time';
@@ -125,6 +129,7 @@ export class DashboardComponent implements OnInit {
this.loadDfgProjectTopics();
this.loadEuProjectStatuses();
this.loadBmbfProjectStatuses();
this.loadDfgProjectStatuses();
}
private loadStatistics(): void {
@@ -281,12 +286,17 @@ export class DashboardComponent implements OnInit {
}
onTopicTreemapTopicSelect(topic: TopicTreemapTopicSelect): void {
const period = this.selectedPeriodBounds();
this.dialog.open<TopicWordCloudDialogComponent, TopicWordCloudDialogData>(
TopicWordCloudDialogComponent,
{
width: '85vw',
maxWidth: '92vw',
data: topic,
data: {
...topic,
fromYear: period.fromYear,
toYear: period.toYear,
},
},
);
}
@@ -368,6 +378,7 @@ export class DashboardComponent implements OnInit {
this.loadDfgProjectTopics();
this.loadEuProjectStatuses();
this.loadBmbfProjectStatuses();
this.loadDfgProjectStatuses();
}
private loadStatistic(
@@ -479,6 +490,22 @@ export class DashboardComponent implements OnInit {
});
}
private loadDfgProjectStatuses(): void {
this.dfgProjectStatusesLoading = true;
this.dfgProjectStatusesError = false;
this.statisticsService
.getDfgProjectStatuses(this.selectedPeriodBounds())
.pipe(finalize(() => (this.dfgProjectStatusesLoading = false)))
.subscribe({
next: (statuses) => {
this.dfgProjectStatuses = statuses;
},
error: () => {
this.dfgProjectStatusesError = true;
},
});
}
private loadTopicTreemap(): void {
if (this.dashboardFromYear > this.dashboardToYear) {
this.topicTreemapLoading = false;
@@ -4,6 +4,7 @@ import { NgxEchartsDirective } from 'ngx-echarts';
import {
BmbfProjectStatusStatistics,
DfgProjectStatusStatistics,
EuProjectStatusStatistics,
} from '../dashboard-statistics.service';
@@ -16,6 +17,7 @@ import {
export class EuProjectStatusChartComponent implements OnChanges {
@Input({ required: true }) statuses!: EuProjectStatusStatistics;
@Input({ required: true }) bmbfStatuses!: BmbfProjectStatusStatistics;
@Input({ required: true }) dfgStatuses!: DfgProjectStatusStatistics;
options: EChartsOption = {};
@@ -23,12 +25,20 @@ export class EuProjectStatusChartComponent implements OnChanges {
const values = [
{
name: 'Laufend',
data: [this.statuses?.ongoing ?? 0, this.bmbfStatuses?.ongoing ?? 0],
data: [
this.statuses?.ongoing ?? 0,
this.bmbfStatuses?.ongoing ?? 0,
this.dfgStatuses?.ongoing ?? 0,
],
color: '#2563eb',
},
{
name: 'Kommend',
data: [this.statuses?.upcoming ?? 0, this.bmbfStatuses?.upcoming ?? 0],
data: [
this.statuses?.upcoming ?? 0,
this.bmbfStatuses?.upcoming ?? 0,
this.dfgStatuses?.upcoming ?? 0,
],
color: '#f59e0b',
},
{
@@ -36,6 +46,7 @@ export class EuProjectStatusChartComponent implements OnChanges {
data: [
this.statuses?.completed ?? 0,
this.bmbfStatuses?.completed ?? 0,
this.dfgStatuses?.completed ?? 0,
],
color: '#64748b',
},
@@ -69,7 +80,7 @@ export class EuProjectStatusChartComponent implements OnChanges {
},
yAxis: {
type: 'category',
data: ['EU-Projekte', 'Bund-Projekte'],
data: ['EU-Projekte', 'Bund-Projekte', 'DFG-Projekte'],
axisTick: { show: false },
axisLine: { show: false },
axisLabel: { color: '#334155', fontWeight: 600 },
@@ -91,16 +91,100 @@
<span>Die Keywords konnten nicht geladen werden.</span>
</div>
} @else if (words.length) {
<div class="keyword-toolbar" aria-label="Ausgewählte Keywords">
<div class="keyword-toolbar-label">
<mat-icon aria-hidden="true">tune</mat-icon>
<span>
<strong>Keyword-Auswahl</strong>
<small
>Klicken Sie auf Begriffe in der Wordcloud, um sie
auszuwählen.</small
>
</span>
</div>
<div class="keyword-selection" aria-live="polite">
@for (word of selectedWords(); track word.id) {
<button
type="button"
class="keyword-chip"
[attr.aria-label]="word.name + ' aus Auswahl entfernen'"
(click)="toggleWord(word)">
{{ word.name }}
<mat-icon aria-hidden="true">close</mat-icon>
</button>
} @empty {
<span class="keyword-selection-empty">Noch nichts ausgewählt</span>
}
</div>
<div class="keyword-toolbar-actions">
@if (selectedWordIds.size) {
<button
mat-button
type="button"
class="keyword-clear"
(click)="clearSelection()">
Auswahl löschen
</button>
}
<a
mat-stroked-button
class="keyword-search keyword-search--secondary"
routerLink="/keywords"
[queryParams]="{
manual: selectedWordsQuery(),
selected: selectedWordsQuery(),
}"
[class.keyword-search--disabled]="!selectedWordIds.size"
[attr.aria-disabled]="!selectedWordIds.size"
[attr.tabindex]="selectedWordIds.size ? 0 : -1"
(click)="
!selectedWordIds.size
? $event.preventDefault()
: closeForSearchNavigation()
">
<mat-icon aria-hidden="true">manage_search</mat-icon>
Suche in Keywords
</a>
<a
mat-flat-button
class="keyword-search"
routerLink="/topics"
[queryParams]="{
query: selectedWordNames(),
page: 0,
sortBy: 'works_count',
sortDirection: 'desc',
}"
[class.keyword-search--disabled]="!selectedWordIds.size"
[attr.aria-disabled]="!selectedWordIds.size"
[attr.tabindex]="selectedWordIds.size ? 0 : -1"
(click)="
!selectedWordIds.size
? $event.preventDefault()
: closeForSearchNavigation()
">
<mat-icon aria-hidden="true">search</mat-icon>
Suche in Themen
</a>
</div>
</div>
<div class="word-cloud-chart" aria-label="Wordcloud verwandter Themen">
@for (word of words; track word.id) {
<span
<button
type="button"
class="word-cloud-word"
[class.word-cloud-word--selected]="isWordSelected(word)"
[attr.aria-pressed]="isWordSelected(word)"
[style.color]="word.color"
[style.fontSize.px]="word.fontSize"
[style.fontWeight]="word.fontWeight"
[title]="word.name + ': ' + word.count + ' Publikationen'">
[title]="word.name + ': ' + word.count + ' Publikationen'"
(click)="toggleWord(word)">
{{ word.name }}
</span>
</button>
}
</div>
} @else {
@@ -187,6 +187,113 @@ mat-dialog-content {
font-weight: 700;
}
.keyword-toolbar {
display: grid;
grid-template-columns: auto minmax(160px, 1fr) auto;
align-items: center;
gap: 14px;
padding: 10px 14px;
border-bottom: 1px solid #e8edf5;
background: #f8faff;
}
.keyword-toolbar-label {
display: flex;
align-items: center;
gap: 8px;
color: #334155;
> mat-icon {
width: 19px;
height: 19px;
color: #7255d9;
font-size: 19px;
}
> span {
display: flex;
flex-direction: column;
gap: 1px;
}
strong {
font-size: 0.75rem;
}
small {
color: var(--sg-text-muted, #64708f);
font-size: 0.6875rem;
}
}
.keyword-selection {
display: flex;
min-width: 0;
flex-wrap: wrap;
align-items: center;
gap: 6px;
}
.keyword-chip {
display: inline-flex;
min-height: 28px;
align-items: center;
gap: 4px;
padding: 4px 7px 4px 9px;
border: 1px solid #c9bafa;
border-radius: 999px;
background: #f6f0ff;
color: #6347c8;
cursor: pointer;
font: inherit;
font-size: 0.6875rem;
font-weight: 600;
mat-icon {
width: 14px;
height: 14px;
font-size: 14px;
}
&:hover {
border-color: #a992ef;
background: #eee7ff;
}
}
.keyword-selection-empty {
color: var(--sg-text-soft, #8a95b3);
font-size: 0.75rem;
font-style: italic;
}
.keyword-clear {
white-space: nowrap;
}
.keyword-toolbar-actions {
display: flex;
align-items: center;
justify-content: flex-end;
gap: 4px;
white-space: nowrap;
}
.keyword-search {
mat-icon {
margin-right: 5px;
}
}
.keyword-search--secondary {
background: #ffffff;
}
.keyword-search--disabled {
pointer-events: none;
opacity: 0.45;
}
.word-cloud-chart {
display: flex;
min-height: 280px;
@@ -211,9 +318,13 @@ mat-dialog-content {
}
.word-cloud-word {
appearance: none;
padding: 3px 5px;
border: 1px solid transparent;
border-radius: 6px;
cursor: help;
background: transparent;
cursor: pointer;
font-family: inherit;
line-height: 1.1;
text-align: center;
transition:
@@ -224,6 +335,18 @@ mat-dialog-content {
background: rgba(241, 243, 247, 0.9);
transform: translateY(-2px);
}
&:focus-visible {
outline: 3px solid rgba(114, 85, 217, 0.25);
outline-offset: 2px;
}
}
.word-cloud-word--selected {
border-color: currentColor;
background: #ffffff;
box-shadow: 0 2px 8px rgba(51, 65, 85, 0.16);
transform: translateY(-2px);
}
.word-cloud-state {
@@ -303,6 +426,20 @@ mat-dialog-content {
gap: 10px 14px;
padding: 24px 18px;
}
.keyword-toolbar {
grid-template-columns: 1fr auto;
}
.keyword-toolbar-actions {
grid-column: 2;
grid-row: 1;
}
.keyword-selection {
grid-column: 1 / -1;
grid-row: 2;
}
}
@media (prefers-reduced-motion: reduce) {
@@ -1,9 +1,14 @@
import { CommonModule } from '@angular/common';
import { Component, DestroyRef, inject } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';
import {
MAT_DIALOG_DATA,
MatDialogModule,
MatDialogRef,
} from '@angular/material/dialog';
import { MatIconModule } from '@angular/material/icon';
import { MatButtonModule } from '@angular/material/button';
import { RouterLink } from '@angular/router';
import {
DashboardStatisticsService,
@@ -28,16 +33,26 @@ interface DisplayWord extends TopicWordCloudWord {
@Component({
selector: 'app-topic-wordcloud-dialog',
standalone: true,
imports: [CommonModule, MatButtonModule, MatDialogModule, MatIconModule],
imports: [
CommonModule,
MatButtonModule,
MatDialogModule,
MatIconModule,
RouterLink,
],
templateUrl: './topic-wordcloud-dialog.component.html',
styleUrl: './topic-wordcloud-dialog.component.scss',
})
export class TopicWordCloudDialogComponent {
readonly data = inject<TopicWordCloudDialogData>(MAT_DIALOG_DATA);
private readonly dialogRef = inject(
MatDialogRef<TopicWordCloudDialogComponent>,
);
private readonly statisticsService = inject(DashboardStatisticsService);
private readonly destroyRef = inject(DestroyRef);
words: DisplayWord[] = [];
selectedWordIds = new Set<string>();
loading = true;
loadFailed = false;
@@ -74,6 +89,42 @@ export class TopicWordCloudDialogComponent {
});
}
toggleWord(word: DisplayWord): void {
const selected = new Set(this.selectedWordIds);
if (selected.has(word.id)) {
selected.delete(word.id);
} else {
selected.add(word.id);
}
this.selectedWordIds = selected;
}
isWordSelected(word: DisplayWord): boolean {
return this.selectedWordIds.has(word.id);
}
selectedWords(): DisplayWord[] {
return this.words.filter((word) => this.selectedWordIds.has(word.id));
}
selectedWordsQuery(): string {
return this.selectedWordNames().join(', ');
}
selectedWordNames(): string[] {
return this.selectedWords().map((word) => word.name);
}
clearSelection(): void {
this.selectedWordIds = new Set<string>();
}
closeForSearchNavigation(): void {
if (this.selectedWordIds.size) {
this.dialogRef.close();
}
}
private buildWords(words: TopicWordCloudWord[]): DisplayWord[] {
if (!words.length) return [];
const values = words.map((word) => word.count);
@@ -24,6 +24,7 @@ export class TopicsComponent {
id: 'query',
queryParamKey: topicQueryParamKeys.query,
icon: 'search',
removable: true,
},
];
@@ -16,7 +16,13 @@ export const topicQueryParamKeys = {
} as const;
export const topicPageResolver: ResolveFn<TopicPageV2> = (route, state) => {
const query = route.queryParamMap.get(topicQueryParamKeys.query) || undefined;
const query =
route.queryParamMap
.getAll(topicQueryParamKeys.query)
.flatMap((value) => value.split(','))
.map((value) => value.trim())
.filter(Boolean)
.join(', ') || undefined;
const page = Number(route.queryParamMap.get(topicQueryParamKeys.page) ?? '0');
const size = Number(
route.queryParamMap.get(topicQueryParamKeys.size) ?? '10',