-
-
- @if (api.description) {
-
{{ api.description }}
- }
-
-
{{ api.type }}
-
{{ api.status }}
+ @if (!searchLoading()) {
+
+ @if (searchCategoryResults().length > 0) {
+ @if (searchResults().length > 0) {
+
Dossiers
+ }
+
+ @for (cat of searchCategoryResults(); track cat.id) {
+
+
+
+
+
+ @if (cat.description) {
+
{{ cat.description }}
+ }
+
-
+ }
}
-
- @if (searchTotalPages() > 1) {
-
-
- Page {{ searchPage() }} / {{ searchTotalPages() }}
-
-
+
+
+ @if (searchResults().length > 0) {
+ @if (searchCategoryResults().length > 0) {
+
APIs
+ }
+
+ @for (api of searchResults(); track api.id) {
+
+
+
+
+
+ @if (api.description) {
+
{{ api.description }}
+ }
+
+ {{ api.type }}
+ {{ api.status }}
+
+
+
+
+
+ }
+
+ @if (searchTotalPages() > 1) {
+
+
+ Page {{ searchPage() }} / {{ searchTotalPages() }}
+
+
+ }
+ }
+
+
+ @if (searchCategoryResults().length === 0 && searchResults().length === 0) {
+
Aucun résultat pour « {{ searchQuery() }} »
+ }
}
}
@@ -255,6 +289,7 @@ export class BrowseComponent implements OnInit {
/* Signaux recherche */
searchQuery = signal('');
searchResults = signal
([]);
+ searchCategoryResults = signal([]);
searchTotal = signal(0);
searchPage = signal(1);
searchLoading = signal(false);
@@ -373,20 +408,32 @@ export class BrowseComponent implements OnInit {
this.searchPage.set(1);
if (this.searchDebounce) clearTimeout(this.searchDebounce);
if (value.trim()) {
+ this.searchLoading.set(true);
this.searchDebounce = setTimeout(() => this.loadSearch(), 400);
+ } else {
+ this.searchLoading.set(false);
+ this.searchCategoryResults.set([]);
}
}
loadSearch() {
this.searchLoading.set(true);
- this.apiService.list({
- search: this.searchQuery(),
- page: this.searchPage(),
- limit: this.searchLimit,
+ const q = this.searchQuery().trim().toLowerCase();
+
+ forkJoin({
+ apis: this.apiService.list({ search: this.searchQuery(), page: this.searchPage(), limit: this.searchLimit }),
+ categories: this.categoryService.list(),
}).subscribe({
- next: (res) => {
- this.searchResults.set(res.items);
- this.searchTotal.set(res.total);
+ next: ({ apis, categories }) => {
+ this.searchResults.set(apis.items);
+ this.searchTotal.set(apis.total);
+ this.searchCategoryResults.set(
+ categories.items.filter(
+ (c) =>
+ c.name.toLowerCase().includes(q) ||
+ (c.description ?? '').toLowerCase().includes(q),
+ ),
+ );
this.searchLoading.set(false);
},
error: () => this.searchLoading.set(false),