diff --git a/service/src/main/inse/news/logic.py b/service/src/main/inse/news/logic.py
index 77cf31a0..ccbc8ea6 100644
--- a/service/src/main/inse/news/logic.py
+++ b/service/src/main/inse/news/logic.py
@@ -80,7 +80,14 @@ async def search_news(
clauses = await _filter_clauses(year_from, year_to, relevance_values)
exact_query = {
"bool": {
- "must": [{"match": {"full_content": query_text}}],
+ "must": [
+ {
+ "multi_match": {
+ "query": query_text,
+ "fields": ["maintitle^2", "full_content"],
+ }
+ }
+ ],
"filter": clauses,
}
}
diff --git a/webapp/src/app/modules/news/news.component.html b/webapp/src/app/modules/news/news.component.html
index c77377f2..7db1c785 100644
--- a/webapp/src/app/modules/news/news.component.html
+++ b/webapp/src/app/modules/news/news.component.html
@@ -1,6 +1,6 @@
-
-
Nachrichten
+
@@ -12,23 +12,65 @@
}
-
-
+
+
+
+
+
+
+
+
+ Relevant
+ Nicht relevant
+
+
+
+
+
+
+
+
+
+
+
+ @if (isSearching()) {
+ Keine Ergebnisse für „{{ searchQuery().trim() }}" gefunden.
+ } @else {
+ Keine Nachrichten gefunden.
+ }
+
+
+
+
diff --git a/webapp/src/app/modules/news/news.component.scss b/webapp/src/app/modules/news/news.component.scss
index 3ed0d40d..f45a7218 100644
--- a/webapp/src/app/modules/news/news.component.scss
+++ b/webapp/src/app/modules/news/news.component.scss
@@ -4,22 +4,27 @@
margin: 0 auto;
}
-h6 {
- margin: 0 0 6px;
- font-size: 22px;
- line-height: 1.2;
- font-weight: 700;
-}
+.page-header {
+ padding: 0 1rem;
+ margin-bottom: 10px;
-.page > div:first-child p {
- margin: 0;
- color: var(--sg-text-muted);
- font-size: 14px;
+ h1 {
+ margin: 0;
+ font-size: 26px;
+ font-weight: 700;
+ color: var(--sg-text);
+ }
+
+ p {
+ margin: 4px 0 0;
+ color: var(--sg-text-muted);
+ font-size: 14px;
+ }
}
.snippet {
display: -webkit-box;
- -webkit-line-clamp: 2;
+ -webkit-line-clamp: 5;
-webkit-box-orient: vertical;
overflow: hidden;
color: var(--sg-text-muted);
@@ -38,6 +43,69 @@ h6 {
color: var(--sg-text-muted);
}
+.additional-filters {
+ display: flex;
+ align-items: center;
+ flex-wrap: wrap;
+ gap: 12px;
+ padding: 0 1rem 1rem;
+}
+
+.relevance-field {
+ width: 180px;
+}
+
+.year-field {
+ 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-color: #d9e2f0;
+ border-radius: var(--sg-radius-sm);
+ color: var(--sg-text);
+ background: #fff;
+
+ mat-icon {
+ margin-right: 6px;
+ width: 20px;
+ height: 20px;
+ font-size: 20px;
+ }
+}
+
@media (max-width: 600px) {
.page {
padding: 16px;
diff --git a/webapp/src/app/modules/news/news.component.ts b/webapp/src/app/modules/news/news.component.ts
index c75cf38f..f1072f5d 100644
--- a/webapp/src/app/modules/news/news.component.ts
+++ b/webapp/src/app/modules/news/news.component.ts
@@ -1,20 +1,33 @@
-import { Component, DestroyRef, OnInit, inject } from '@angular/core';
+import {
+ Component,
+ DestroyRef,
+ OnInit,
+ computed,
+ inject,
+ signal,
+} from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http';
import { FormControl, ReactiveFormsModule } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
-import { PageEvent } from '@angular/material/paginator';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
-import { debounceTime, distinctUntilChanged } from 'rxjs';
+import { debounceTime, merge } from 'rxjs';
+import { MatFormFieldModule } from '@angular/material/form-field';
+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 { PaginationService } from '../../shared/services/pagination.service';
+import {
+ CardSearchComponent,
+ Page,
+} from '../../shared/ui/card-search/card-search.component';
import {
NewsArticleBase,
- NewsFilterState,
- NewsListComponent,
+ NewsCardComponent,
NEWS_MIN_YEAR,
- SortOrder,
-} from '../../shared/ui/news-list/news-list.component';
+} from '../../shared/ui/news-card/news-card.component';
+import { SelectorOption } from '../../shared/ui/query-param-selector/query-param-selector.component';
interface NewsArticle extends NewsArticleBase {
author?: string | null;
@@ -28,11 +41,20 @@ interface NewsPage {
results: NewsArticle[];
}
-const DEFAULT_SORT_ORDER: SortOrder = 'desc';
+type SortOrder = 'desc' | 'asc';
@Component({
selector: 'app-news',
- imports: [ReactiveFormsModule, NewsListComponent],
+ imports: [
+ ReactiveFormsModule,
+ MatFormFieldModule,
+ MatSelectModule,
+ MatSliderModule,
+ MatButtonModule,
+ MatIconModule,
+ CardSearchComponent,
+ NewsCardComponent,
+ ],
templateUrl: './news.component.html',
styleUrl: './news.component.scss',
})
@@ -42,188 +64,160 @@ export class NewsComponent implements OnInit {
private readonly router = inject(Router);
private readonly httpClient = inject(HttpClient);
private readonly worksService = inject(WorksService);
- readonly paginationService = inject(PaginationService);
- readonly searchControl = new FormControl('', { nonNullable: true });
+ readonly minYear = NEWS_MIN_YEAR;
+ readonly maxYear = new Date().getFullYear();
- readonly displayedColumns: string[] = [
- 'maintitle',
- 'snippet',
- 'relevance',
- 'date',
+ private readonly sortingDirectionOptionsAll: SelectorOption[] = [
+ { value: 'desc', display_name: 'Neueste zuerst' },
+ { value: 'asc', display_name: 'Älteste zuerst' },
];
- articles: NewsArticle[] = [];
- total = 0;
- loading = false;
+ readonly relevanceFilter = new FormControl
([], {
+ nonNullable: true,
+ });
+ readonly yearFrom = new FormControl(this.minYear, {
+ nonNullable: true,
+ });
+ readonly yearTo = new FormControl(this.maxYear, {
+ nonNullable: true,
+ });
- currentPage = 1;
- sortOrder: SortOrder = DEFAULT_SORT_ORDER;
+ private readonly articles = signal([]);
+ private readonly total = signal(0);
+ readonly loading = signal(false);
+ readonly searchQuery = signal('');
- relevanceValues: string[] = [];
- yearFrom: number | null = null;
- yearTo: number | null = null;
+ readonly isSearching = computed(() => this.searchQuery().trim().length > 0);
+ readonly sortingDirectionOptions = computed(() =>
+ this.isSearching() ? [] : this.sortingDirectionOptionsAll,
+ );
- private readonly minYear = NEWS_MIN_YEAR;
- private readonly maxYear = new Date().getFullYear();
+ readonly page = computed(() => ({
+ page: this.currentPage,
+ size: this.currentSize,
+ total: this.total(),
+ elements: this.articles(),
+ }));
+
+ private currentPage = 0;
+ private currentSize = 10;
+ private sortOrder: SortOrder = 'desc';
ngOnInit(): void {
this.route.queryParamMap
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((params) => {
- this.currentPage = this.parsePage(params.get('page'));
- this.paginationService.selection = this.parsePageSize(
- params.get('pageSize'),
+ this.currentPage = this.parseIndex(params.get('page'), 0);
+ this.currentSize = this.parseIndex(params.get('size'), 10);
+ this.sortOrder = params.get('sorting_order') === 'asc' ? 'asc' : 'desc';
+ this.searchQuery.set(params.get('search') ?? '');
+
+ this.relevanceFilter.setValue(
+ this.parseRelevance(params.get('relevance')),
+ { emitEvent: false },
);
- this.sortOrder = this.parseSortOrder(params.get('sortOrder'));
- this.relevanceValues = this.parseRelevance(params.get('relevance'));
- this.yearFrom = this.parseYear(params.get('yearFrom'));
- this.yearTo = this.parseYear(params.get('yearTo'));
- this.searchControl.setValue(params.get('q') ?? '', {
- emitEvent: false,
- });
+ this.yearFrom.setValue(
+ this.parseYear(params.get('yearFrom')) ?? this.minYear,
+ { emitEvent: false },
+ );
+ this.yearTo.setValue(
+ this.parseYear(params.get('yearTo')) ?? this.maxYear,
+ { emitEvent: false },
+ );
+
this.load();
});
- this.searchControl.valueChanges
- .pipe(
- debounceTime(300),
- distinctUntilChanged(),
- takeUntilDestroyed(this.destroyRef),
- )
- .subscribe((query) => {
- this.router.navigate([], {
- relativeTo: this.route,
- queryParams: { q: query.trim() || null, page: 1 },
- queryParamsHandling: 'merge',
- });
- });
+ merge(
+ this.relevanceFilter.valueChanges,
+ this.yearFrom.valueChanges,
+ this.yearTo.valueChanges,
+ )
+ .pipe(debounceTime(300), takeUntilDestroyed(this.destroyRef))
+ .subscribe(() => this.applyFilters());
}
- load(): void {
- this.loading = true;
- const query = this.searchControl.value.trim();
+ resetFilters(): void {
+ this.relevanceFilter.setValue([]);
+ this.yearFrom.setValue(this.minYear);
+ this.yearTo.setValue(this.maxYear);
+ }
+
+ private applyFilters(): void {
+ const relevance =
+ this.relevanceFilter.value.length > 0
+ ? this.relevanceFilter.value.join(',')
+ : null;
+ const yearFrom =
+ this.yearFrom.value > this.minYear ? this.yearFrom.value : null;
+ const yearTo = this.yearTo.value < this.maxYear ? this.yearTo.value : null;
+
+ this.router.navigate([], {
+ relativeTo: this.route,
+ queryParams: { relevance, yearFrom, yearTo, page: 0 },
+ queryParamsHandling: 'merge',
+ });
+ }
+
+ private load(): void {
+ this.loading.set(true);
+ const query = this.searchQuery().trim();
const basePath = this.worksService.configuration.basePath ?? '';
+ const backendPage = this.currentPage + 1;
if (query) {
let params = new HttpParams()
.set('query', query)
- .set('page', this.currentPage)
- .set('pageSize', this.paginationService.selection);
+ .set('page', backendPage)
+ .set('pageSize', this.currentSize);
params = this.appendFilters(params);
this.httpClient
.get(`${basePath}/api/news/search`, { params })
.subscribe({
- next: (page) => {
- this.articles = page.results ?? [];
- this.total = page.total ?? 0;
- this.loading = false;
- },
- error: () => {
- this.articles = [];
- this.total = 0;
- this.loading = false;
- },
+ next: (page) => this.applyResult(page),
+ error: () => this.applyResult(null),
});
} else {
let params = new HttpParams()
- .set('page', this.currentPage)
- .set('pageSize', this.paginationService.selection)
+ .set('page', backendPage)
+ .set('pageSize', this.currentSize)
.set('sortOrder', this.sortOrder);
params = this.appendFilters(params);
this.httpClient
.get(`${basePath}/api/news`, { params })
.subscribe({
- next: (page) => {
- this.articles = page.results ?? [];
- this.total = page.total ?? 0;
- this.loading = false;
- },
- error: () => {
- this.articles = [];
- this.total = 0;
- this.loading = false;
- },
+ next: (page) => this.applyResult(page),
+ error: () => this.applyResult(null),
});
}
}
+ private applyResult(page: NewsPage | null): void {
+ this.articles.set(page?.results ?? []);
+ this.total.set(page?.total ?? 0);
+ this.loading.set(false);
+ }
+
private appendFilters(params: HttpParams): HttpParams {
- if (this.relevanceValues.length > 0) {
- params = params.set('relevance', this.relevanceValues.join(','));
+ const relevance = this.relevanceFilter.value;
+ if (relevance.length > 0) {
+ params = params.set('relevance', relevance.join(','));
}
- if (this.yearFrom !== null) {
- params = params.set('yearFrom', this.yearFrom);
+ if (this.yearFrom.value > this.minYear) {
+ params = params.set('yearFrom', this.yearFrom.value);
}
- if (this.yearTo !== null) {
- params = params.set('yearTo', this.yearTo);
+ if (this.yearTo.value < this.maxYear) {
+ params = params.set('yearTo', this.yearTo.value);
}
return params;
}
- onPage(event: PageEvent): void {
- this.router.navigate([], {
- relativeTo: this.route,
- queryParams: {
- page: event.pageIndex + 1,
- pageSize: event.pageSize,
- },
- queryParamsHandling: 'merge',
- });
- }
-
- onSortChange(order: SortOrder): void {
- this.router.navigate([], {
- relativeTo: this.route,
- queryParams: {
- sortOrder: order,
- page: 1,
- },
- queryParamsHandling: 'merge',
- });
- }
-
- onFiltersChange(state: NewsFilterState): void {
- const relevance =
- state.relevance.length > 0 ? state.relevance.join(',') : null;
- const yearFrom = state.yearFrom > this.minYear ? state.yearFrom : null;
- const yearTo = state.yearTo < this.maxYear ? state.yearTo : null;
-
- this.router.navigate([], {
- relativeTo: this.route,
- queryParams: {
- relevance,
- yearFrom,
- yearTo,
- page: 1,
- },
- queryParamsHandling: 'merge',
- });
- }
-
- private parsePage(value: string | null): number {
- const page = Number.parseInt(value ?? '', 10);
- if (Number.isNaN(page) || page < 1) {
- return 1;
- }
- return page;
- }
-
- private parsePageSize(value: string | null): number {
- const pageSize = Number.parseInt(value ?? '', 10);
- if (this.paginationService.options.includes(pageSize)) {
- return pageSize;
- }
- return 10;
- }
-
- private parseSortOrder(value: string | null): SortOrder {
- if (value === 'asc' || value === 'desc') {
- return value;
- }
- return DEFAULT_SORT_ORDER;
+ private parseIndex(value: string | null, fallback: number): number {
+ const parsed = Number.parseInt(value ?? '', 10);
+ return Number.isNaN(parsed) || parsed < 0 ? fallback : parsed;
}
private parseRelevance(value: string | null): string[] {
@@ -239,9 +233,6 @@ export class NewsComponent implements OnInit {
private parseYear(value: string | null): number | null {
const year = Number.parseInt(value ?? '', 10);
- if (Number.isNaN(year)) {
- return null;
- }
- return year;
+ return Number.isNaN(year) ? null : year;
}
}
diff --git a/webapp/src/app/modules/person-news/person-news.component.html b/webapp/src/app/modules/person-news/person-news.component.html
index 651e39d4..c20ba733 100644
--- a/webapp/src/app/modules/person-news/person-news.component.html
+++ b/webapp/src/app/modules/person-news/person-news.component.html
@@ -4,15 +4,16 @@
Aktuelle Nachrichten zu dieser Person.
-