From 8edab70a63f6f2bb021ba0f81f94c3c227f98869 Mon Sep 17 00:00:00 2001 From: Wilco Louwerse Date: Tue, 30 Jul 2024 17:10:49 +0200 Subject: [PATCH 1/7] Use $this->client not $client --- lib/Service/SearchService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Service/SearchService.php b/lib/Service/SearchService.php index bd03bcb7..4d0ca09f 100644 --- a/lib/Service/SearchService.php +++ b/lib/Service/SearchService.php @@ -109,7 +109,7 @@ public function search(array $parameters, array $elasticConfig, array $dbConfig, $parameters['_catalogi'] = $catalogi; - $promises[] = $client->getAsync($searchEndpoint, ['query' => $parameters]); + $promises[] = $this->client->getAsync($searchEndpoint, ['query' => $parameters]); } $responses = Utils::settle($promises)->wait(); From 7b3e1761eecfe4d0f1c48e0a60309c5b387d938a Mon Sep 17 00:00:00 2001 From: Barry Brands Date: Fri, 2 Aug 2024 17:00:37 +0200 Subject: [PATCH 2/7] Validate elastic config --- lib/Controller/SearchController.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/lib/Controller/SearchController.php b/lib/Controller/SearchController.php index 47bf9253..eb5572bc 100644 --- a/lib/Controller/SearchController.php +++ b/lib/Controller/SearchController.php @@ -72,6 +72,20 @@ public function index(SearchService $searchService): JSONResponse $filters = array_combine(keys: $keys, values: $values); + $requiredElasticConfig = ['location', 'key', 'index']; + $missingFields = null; + foreach ($requiredElasticConfig as $key) { + if (isset($elasticConfig[$key]) === false || empty($elasticConfig[$key])) { + $missingFields .= "$key, "; + } + } + + if ($missingFields !== null) { + $errorMessage = "Missing the following elastic configuration: {$missingFields}please update your elastic connection in application settings."; + $response = new JSONResponse(data: ['code' => 403, 'message' => $errorMessage], statusCode: 403); + + return $response; + } $data = $searchService->search(parameters: $filters, elasticConfig: $elasticConfig, dbConfig: $dbConfig); @@ -94,6 +108,19 @@ public function show(string|int $id, SearchService $searchService): JSONResponse $filters = ['_id' => (string) $id]; + $requiredElasticConfig = ['location', 'key', 'index']; + $missingFields = null; + foreach ($requiredElasticConfig as $key) { + if (isset($elasticConfig[$key]) === false) { + $missingFields .= "$key "; + } + } + + if ($missingFields !== null) { + $errorMessage = "Missing the following elastic configuration: {$missingFields}please update your elastic connection in application settings."; + return new JSONResponse(['message' => $errorMessage], 403); + } + $data = $searchService->search(parameters: $filters, elasticConfig: $elasticConfig, dbConfig: $dbConfig); if(count($data['results']) > 0) { From b4aff181b7d57ebc7c81c49239c4e8e2f9adf65a Mon Sep 17 00:00:00 2001 From: Barry Brands Date: Fri, 2 Aug 2024 17:11:30 +0200 Subject: [PATCH 3/7] Search federatief improvements --- src/sidebars/dashboard/DashboardSideBar.vue | 9 +++++--- src/sidebars/search/SearchSideBar.vue | 10 ++++++--- src/store/modules/search.js | 12 +++++++++- src/views/dashboard/DashboardIndex.vue | 25 +++++++++++++++++++++ 4 files changed, 49 insertions(+), 7 deletions(-) diff --git a/src/sidebars/dashboard/DashboardSideBar.vue b/src/sidebars/dashboard/DashboardSideBar.vue index d8855344..481c7db9 100644 --- a/src/sidebars/dashboard/DashboardSideBar.vue +++ b/src/sidebars/dashboard/DashboardSideBar.vue @@ -9,11 +9,14 @@ import { navigationStore, searchStore, publicationStore } from '../../store/stor - Zoek snel in het voor uw beschickbare federatieve netwerk + test2 + Zoek snel in het voor uw beschikbare federatieve netwerk
+ label="Zoeken" /> + +

{{ searchStore.searchError }}

+
test1 + Zoek snel in het voor uw beschikbare federatieve netwerk
+ label="Zoeken" /> + +

{{ searchStore.searchError }}

+
+ Zoek snel in het voor uw beschikbare federatieve netwerk
test1 + Zoek snel in het voor uw beschikbare federatieve netwerk
Date: Tue, 6 Aug 2024 12:55:13 +0200 Subject: [PATCH 6/7] Small cleanup --- src/views/catalogi/CatalogiList.vue | 11 +++++------ src/views/directory/DirectoryList.vue | 11 +++++------ src/views/metaData/MetaDataList.vue | 11 +++++------ src/views/publications/PublicationList.vue | 15 +++++++-------- 4 files changed, 22 insertions(+), 26 deletions(-) diff --git a/src/views/catalogi/CatalogiList.vue b/src/views/catalogi/CatalogiList.vue index eb11bb68..980f1b80 100644 --- a/src/views/catalogi/CatalogiList.vue +++ b/src/views/catalogi/CatalogiList.vue @@ -108,6 +108,10 @@ export default { Pencil, Delete, }, + beforeRouteLeave(to, from, next) { + search = ''; + next(); + }, props: { search: { type: String, @@ -118,7 +122,6 @@ export default { return { loading: false, catalogi: [], - search: '', } }, watch: { @@ -141,12 +144,8 @@ export default { }, debouncedFetchData: debounce(function(search) { this.fetchData(search); - }, 500), + }, 500), }, - beforeRouteLeave(to, from, next) { - search = ''; - next(); - }, }