From 0315b2a23d263cc98925a6d31858a5f22230a0d6 Mon Sep 17 00:00:00 2001 From: Camille Moinier Date: Tue, 25 Jun 2024 16:03:02 +0200 Subject: [PATCH 1/7] feat: filter by category in dataset page --- .../dataset-information.component.html | 7 +++++-- .../dataset-information.component.ts | 20 +++++++++++++++++-- resources/styles.css | 3 --- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.html b/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.html index a668cc7a..6b1b0d47 100644 --- a/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.html +++ b/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.html @@ -18,9 +18,12 @@ mel.dataset.categories
@for(topic of displayCategories; track $index) { - + }
diff --git a/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.ts b/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.ts index 7a4aacec..3a14eead 100644 --- a/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.ts +++ b/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.ts @@ -1,5 +1,12 @@ -import { ChangeDetectionStrategy, Component, Input } from '@angular/core' +import { + ChangeDetectionStrategy, + Component, + Input, + Optional, +} from '@angular/core' +import { goFromHomeToSearch } from '@mel-dataplatform/mel' import { TranslateService } from '@ngx-translate/core' +import { RouterFacade } from 'geonetwork-ui' import { CatalogRecord } from 'geonetwork-ui/libs/common/domain/src/lib/model/record' @Component({ @@ -12,7 +19,10 @@ export class DatasetInformationComponent { @Input() record: Partial iconsUrl = 'assets/icons/' - constructor(public translateService: TranslateService) {} + constructor( + public translateService: TranslateService, + @Optional() protected routerFacade: RouterFacade + ) {} get lastUpdate() { return this.record?.resourceUpdated?.toLocaleDateString( @@ -31,4 +41,10 @@ export class DatasetInformationComponent { return categoryKeywords?.map((keyword) => keyword.label) } + + onInfoKeywordClick(keyword: string) { + this.routerFacade + ? this.routerFacade.updateSearch({ q: keyword }) + : goFromHomeToSearch(keyword) + } } diff --git a/resources/styles.css b/resources/styles.css index 9f803a4a..27fd4d5a 100644 --- a/resources/styles.css +++ b/resources/styles.css @@ -29,9 +29,6 @@ .mel-badge { @apply inline-block bg-white py-1.5 px-2 rounded font-medium text-sm leading-none transition-colors; } - .mel-badge-primary { - @apply mel-badge text-primary border border-primary; - } .mel-badge-secondary { @apply mel-badge text-secondary border border-secondary; } From d9cd5f46d2ab70bdc930efa5bcf222e52456ae99 Mon Sep 17 00:00:00 2001 From: Camille Moinier Date: Thu, 27 Jun 2024 15:55:45 +0200 Subject: [PATCH 2/7] feat: changes from review --- .../dataset-information/dataset-information.component.html | 6 +++--- .../dataset-information/dataset-information.component.ts | 6 ++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.html b/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.html index 6b1b0d47..a89ec5cc 100644 --- a/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.html +++ b/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.html @@ -17,12 +17,12 @@
mel.dataset.categories
- @for(topic of displayCategories; track $index) { + @for(category of displayCategories; track $index) { }
diff --git a/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.ts b/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.ts index 3a14eead..9650ded7 100644 --- a/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.ts +++ b/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.ts @@ -42,9 +42,7 @@ export class DatasetInformationComponent { return categoryKeywords?.map((keyword) => keyword.label) } - onInfoKeywordClick(keyword: string) { - this.routerFacade - ? this.routerFacade.updateSearch({ q: keyword }) - : goFromHomeToSearch(keyword) + onCategoryKeywordClick(category: string) { + this.routerFacade.updateSearch({ q: category }) } } From 9cacb6cd4d26b8bb3ae17bbb74faecc5aa4a2125 Mon Sep 17 00:00:00 2001 From: Camille Moinier Date: Mon, 1 Jul 2024 15:18:19 +0200 Subject: [PATCH 3/7] feat: remove unused imports --- .../dataset/dataset-information/dataset-information.component.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.ts b/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.ts index 9650ded7..abc56020 100644 --- a/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.ts +++ b/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.ts @@ -4,7 +4,6 @@ import { Input, Optional, } from '@angular/core' -import { goFromHomeToSearch } from '@mel-dataplatform/mel' import { TranslateService } from '@ngx-translate/core' import { RouterFacade } from 'geonetwork-ui' import { CatalogRecord } from 'geonetwork-ui/libs/common/domain/src/lib/model/record' From a4251dfc9ef0c9cdd120de99b65e2e5b59a04a1c Mon Sep 17 00:00:00 2001 From: Camille Moinier Date: Wed, 3 Jul 2024 14:01:40 +0200 Subject: [PATCH 4/7] feat: use categoryKeyword instead of q --- .../dataset-information/dataset-information.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.ts b/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.ts index abc56020..f9355375 100644 --- a/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.ts +++ b/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.ts @@ -42,6 +42,6 @@ export class DatasetInformationComponent { } onCategoryKeywordClick(category: string) { - this.routerFacade.updateSearch({ q: category }) + this.routerFacade.updateSearch({ categoryKeyword: category }) } } From 6216f71bbb99b3cdcbd7a90e46537e5833dd5f29 Mon Sep 17 00:00:00 2001 From: Camille Moinier Date: Thu, 4 Jul 2024 14:04:36 +0200 Subject: [PATCH 5/7] feat: use keyword key in facade --- .../dataset-information/dataset-information.component.html | 4 ++-- .../dataset-information/dataset-information.component.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.html b/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.html index a89ec5cc..55d10efc 100644 --- a/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.html +++ b/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.html @@ -20,9 +20,9 @@ @for(category of displayCategories; track $index) { }
diff --git a/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.ts b/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.ts index f9355375..1276c557 100644 --- a/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.ts +++ b/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.ts @@ -38,7 +38,7 @@ export class DatasetInformationComponent { (keyword) => keyword.thesaurus?.name === 'Catégories' ) - return categoryKeywords?.map((keyword) => keyword.label) + return categoryKeywords } onCategoryKeywordClick(category: string) { From 23e957a25b47b4bd69121f368b8861b5f9118afd Mon Sep 17 00:00:00 2001 From: Camille Moinier Date: Tue, 16 Jul 2024 10:06:47 +0200 Subject: [PATCH 6/7] feat: upgrade gn-ui and make search work --- .../dataset-information.component.html | 2 +- .../dataset-information/dataset-information.component.ts | 9 ++++++--- .../search/search-filters/search-filters.component.ts | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.html b/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.html index 55d10efc..5c40b6d4 100644 --- a/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.html +++ b/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.html @@ -20,7 +20,7 @@ @for(category of displayCategories; track $index) { diff --git a/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.ts b/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.ts index 1276c557..4ba72588 100644 --- a/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.ts +++ b/apps/datahub/src/app/dataset/dataset-information/dataset-information.component.ts @@ -6,7 +6,10 @@ import { } from '@angular/core' import { TranslateService } from '@ngx-translate/core' import { RouterFacade } from 'geonetwork-ui' -import { CatalogRecord } from 'geonetwork-ui/libs/common/domain/src/lib/model/record' +import { + CatalogRecord, + Keyword, +} from 'geonetwork-ui/libs/common/domain/src/lib/model/record' @Component({ selector: 'mel-datahub-dataset-information', @@ -41,7 +44,7 @@ export class DatasetInformationComponent { return categoryKeywords } - onCategoryKeywordClick(category: string) { - this.routerFacade.updateSearch({ categoryKeyword: category }) + onCategoryKeywordClick(category: Keyword) { + this.routerFacade.updateSearch({ categoryKeyword: category.key }) } } diff --git a/apps/datahub/src/app/search/search-filters/search-filters.component.ts b/apps/datahub/src/app/search/search-filters/search-filters.component.ts index 8db7e08d..ec383d27 100644 --- a/apps/datahub/src/app/search/search-filters/search-filters.component.ts +++ b/apps/datahub/src/app/search/search-filters/search-filters.component.ts @@ -22,7 +22,7 @@ export class SearchFiltersComponent { constructor(private routerFacade: RouterFacade) {} displayCount = 3 searchConfig = [ - 'topic', + 'categoryKeyword', 'organization', 'publicationYear', 'license', From 5afa39c4998046db84d87568e0d1ca9266227c0a Mon Sep 17 00:00:00 2001 From: Camille Moinier Date: Tue, 16 Jul 2024 12:02:35 +0200 Subject: [PATCH 7/7] feat: add e2e testing --- apps/datahub-e2e/src/e2e/search.cy.ts | 28 +++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/apps/datahub-e2e/src/e2e/search.cy.ts b/apps/datahub-e2e/src/e2e/search.cy.ts index efcf1fba..a653249b 100644 --- a/apps/datahub-e2e/src/e2e/search.cy.ts +++ b/apps/datahub-e2e/src/e2e/search.cy.ts @@ -149,8 +149,24 @@ describe('search', () => { it('should display the search form', () => { cy.get('mel-datahub-search-form').should('be.visible') }) - it('should display the search filters', () => { - cy.get('mel-datahub-search-filters').should('be.visible') + it('should display the base search filters', () => { + cy.get('[data-cy="filterExpandBtn"]').click() + cy.get('mel-datahub-search-filters') + .find('mel-datahub-filter-dropdown') + .children() + .then(($dropdowns) => + $dropdowns + .toArray() + .map((dropdown) => dropdown.getAttribute('data-cy-field')) + ) + .should('eql', [ + 'categoryKeyword', + 'organization', + 'publicationYear', + 'license', + 'qualityScore', + 'territories', + ]) }) it('should display the search results', () => { cy.get('mel-datahub-search-results').should('be.visible') @@ -179,6 +195,14 @@ describe('search', () => { cy.get('@options').eq(2).click() cy.get('mel-datahub-results-card-search').should('have.length', 3) }) + it('should filter by quality score', () => { + cy.get('[data-cy="filterExpandBtn"]').click() + cy.get('@filters').eq(4).click() + cy.get('gn-ui-text-input input').first().type('5') + cy.get('gn-ui-text-input input').last().type('7') + cy.get('mel-datahub-button').last().click() + cy.get('mel-datahub-results-card-search').should('have.length', 3) + }) it('should filter the results when executing a search', () => { cy.get('mel-datahub-autocomplete input').type('velo') cy.get('mel-datahub-autocomplete .material-symbols-outlined')