From 7f9d1e7c5a68d0b6157f92264e31d316906242d5 Mon Sep 17 00:00:00 2001 From: Tobias Messner Date: Tue, 6 Aug 2024 16:39:32 +0200 Subject: [PATCH] feat: Make project view searchable and sorted This sorts the project cards alphabetically and adds a basic search bar to filter projects. It partially addresses #402, but I haven't implemented project favorites yet. --- .../project-overview.component.html | 20 ++++++++++-- .../project-overview.component.ts | 32 +++++++++++++++++++ 2 files changed, 49 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/projects/project-overview/project-overview.component.html b/frontend/src/app/projects/project-overview/project-overview.component.html index ff608fe0c..f950f8d69 100644 --- a/frontend/src/app/projects/project-overview/project-overview.component.html +++ b/frontend/src/app/projects/project-overview/project-overview.component.html @@ -3,6 +3,20 @@ ~ SPDX-License-Identifier: Apache-2.0 --> +
+ + Search + + search + +
+
@@ -15,12 +29,12 @@
- +
this.searchAndSortProjects(query!)), + ); + + searchAndSortProjects(query: string) { + return this.projectService.projects$.pipe( + map((projects) => + projects?.filter((project) => + project.name.toLocaleLowerCase().includes(query.toLocaleLowerCase()), + ), + ), + map((projects) => projects?.sort((a, b) => a.name.localeCompare(b.name))), + ); + } + constructor(public projectService: ProjectWrapperService) {} ngOnInit() {