From 93c996c304cf692330fb611c8111976741d7688d Mon Sep 17 00:00:00 2001 From: Rongrong Chai Date: Mon, 22 Apr 2024 21:23:37 +0000 Subject: [PATCH 1/6] add input data type filters --- .../src/lib/challenge-search-data.service.ts | 66 +++++++--- .../src/lib/challenge-search-filter-panels.ts | 53 ++++---- .../src/lib/challenge-search.component.html | 16 +++ .../src/lib/challenge-search.component.ts | 123 +++++++++++------- 4 files changed, 165 insertions(+), 93 deletions(-) diff --git a/libs/openchallenges/challenge-search/src/lib/challenge-search-data.service.ts b/libs/openchallenges/challenge-search/src/lib/challenge-search-data.service.ts index ed9a59fe40..dbafc84db8 100644 --- a/libs/openchallenges/challenge-search/src/lib/challenge-search-data.service.ts +++ b/libs/openchallenges/challenge-search/src/lib/challenge-search-data.service.ts @@ -11,6 +11,8 @@ import { ChallengePlatformSearchQuery, ChallengePlatformService, ChallengePlatformSort, + EdamConceptSearchQuery, + EdamConceptService, Image, ImageAspectRatio, ImageHeight, @@ -28,44 +30,48 @@ import { Filter } from '@sagebionetworks/openchallenges/ui'; providedIn: 'root', }) export class ChallengeSearchDataService { - private platformSearchTerms: BehaviorSubject = - new BehaviorSubject(''); + private edamConceptSearchTerms: BehaviorSubject = + new BehaviorSubject({ searchTerms: '' }); private organizationSearchTerms: BehaviorSubject = new BehaviorSubject(''); + private platformSearchTerms: BehaviorSubject = + new BehaviorSubject(''); + constructor( + private edamConceptService: EdamConceptService, private challengePlatformService: ChallengePlatformService, private organizationService: OrganizationService, private imageService: ImageService ) {} - setPlatformSearchTerms(searchTerms: string) { - this.platformSearchTerms.next(searchTerms); + setEdamConceptSearchTerms(searchQuery: EdamConceptSearchQuery) { + this.edamConceptSearchTerms.next(searchQuery); } setOriganizationSearchTerms(searchTerms: string) { this.organizationSearchTerms.next(searchTerms); } - searchPlatforms(): Observable { - return this.platformSearchTerms.pipe( + setPlatformSearchTerms(searchTerms: string) { + this.platformSearchTerms.next(searchTerms); + } + + searchEdamConcepts(): Observable { + return this.edamConceptSearchTerms.pipe( debounceTime(400), distinctUntilChanged(), - switchMap((searchTerm: string) => { - const sortedBy: ChallengePlatformSort = 'name'; - const platformQuery: ChallengePlatformSearchQuery = { - searchTerms: searchTerm, - sort: sortedBy, - }; - return this.challengePlatformService.listChallengePlatforms( - platformQuery - ); + switchMap((searchQuery: EdamConceptSearchQuery) => { + // const sortedBy: EdamSort = 'name'; + const edamQuery: EdamConceptSearchQuery = searchQuery; + console.log(edamQuery); + return this.edamConceptService.listEdamConcepts(edamQuery); }), map((page) => - page.challengePlatforms.map((platform) => ({ - value: platform.slug, - label: platform.name, + page.edamConcepts.map((edamConcept) => ({ + value: edamConcept.classId, + label: edamConcept.preferredLabel, active: false, })) ) @@ -123,4 +129,28 @@ export class ChallengeSearchDataService { }) ); } + + searchPlatforms(): Observable { + return this.platformSearchTerms.pipe( + debounceTime(400), + distinctUntilChanged(), + switchMap((searchTerm: string) => { + const sortedBy: ChallengePlatformSort = 'name'; + const platformQuery: ChallengePlatformSearchQuery = { + searchTerms: searchTerm, + sort: sortedBy, + }; + return this.challengePlatformService.listChallengePlatforms( + platformQuery + ); + }), + map((page) => + page.challengePlatforms.map((platform) => ({ + value: platform.slug, + label: platform.name, + active: false, + })) + ) + ); + } } diff --git a/libs/openchallenges/challenge-search/src/lib/challenge-search-filter-panels.ts b/libs/openchallenges/challenge-search/src/lib/challenge-search-filter-panels.ts index bc0139893a..9fa42eb0c5 100644 --- a/libs/openchallenges/challenge-search/src/lib/challenge-search-filter-panels.ts +++ b/libs/openchallenges/challenge-search/src/lib/challenge-search-filter-panels.ts @@ -18,18 +18,10 @@ export const challengeStartYearRangeFilterPanel: FilterPanel = { collapsed: false, }; -// checkbox filters -export const challengeStatusFilterPanel: FilterPanel = { - query: 'status', - label: 'Status', - options: challengeStatusFilter, - collapsed: false, -}; - -export const challengeSubmissionTypesFilterPanel: FilterPanel = { - query: 'submissionTypes', - label: 'Submission Type', - options: challengeSubmissionTypesFilter, +export const challengeCategoriesFilterPanel: FilterPanel = { + query: 'categories', + label: 'Category', + options: challengeCategoriesFilter, collapsed: false, }; @@ -40,27 +32,11 @@ export const challengeIncentivesFilterPanel: FilterPanel = { collapsed: false, }; -export const challengePlatformsFilterPanel: FilterPanel = { - query: 'platforms', - label: 'Platform', - options: challengePlatformsFilter, - collapsed: false, -}; - -// dropdown filters export const challengeInputDataTypesFilterPanel: FilterPanel = { query: 'inputDataTypes', label: 'Input Data Type', options: challengeInputDataTypesFilter, collapsed: false, - showAvatar: false, -}; - -export const challengeCategoriesFilterPanel: FilterPanel = { - query: 'categories', - label: 'Category', - options: challengeCategoriesFilter, - collapsed: false, }; export const challengeOrganizationsFilterPanel: FilterPanel = { @@ -78,3 +54,24 @@ export const challengeOrganizatersFilterPanel: FilterPanel = { collapsed: false, showAvatar: true, }; + +export const challengePlatformsFilterPanel: FilterPanel = { + query: 'platforms', + label: 'Platform', + options: challengePlatformsFilter, + collapsed: false, +}; + +export const challengeStatusFilterPanel: FilterPanel = { + query: 'status', + label: 'Status', + options: challengeStatusFilter, + collapsed: false, +}; + +export const challengeSubmissionTypesFilterPanel: FilterPanel = { + query: 'submissionTypes', + label: 'Submission Type', + options: challengeSubmissionTypesFilter, + collapsed: false, +}; diff --git a/libs/openchallenges/challenge-search/src/lib/challenge-search.component.html b/libs/openchallenges/challenge-search/src/lib/challenge-search.component.html index 225a188b17..6e9588045b 100644 --- a/libs/openchallenges/challenge-search/src/lib/challenge-search.component.html +++ b/libs/openchallenges/challenge-search/src/lib/challenge-search.component.html @@ -89,6 +89,22 @@

Challenges

/> + + + + (); + @ViewChild('calendar') calendar?: Calendar; + @ViewChild('paginator', { static: false }) paginator!: PaginatorComponent; + challenges: Challenge[] = []; totalChallengesCount = 0; searchResultsCount!: number; - @ViewChild('calendar') calendar?: Calendar; customMonthRange!: Date[] | undefined; isCustomYear = false; refreshed = true; - selectedYear!: DateRange | string | undefined; - selectedMinStartDate!: string | undefined; - selectedMaxStartDate!: string | undefined; searchedTerms!: string; + selectedMaxStartDate!: string | undefined; + selectedMinStartDate!: string | undefined; selectedPageNumber!: number; selectedPageSize!: number; + selectedYear!: DateRange | string | undefined; sortedBy!: ChallengeSort; // set default values - defaultSelectedYear = undefined; - defaultSortedBy: ChallengeSort = 'relevance'; defaultPageNumber = 0; defaultPageSize = 24; - @ViewChild('paginator', { static: false }) paginator!: PaginatorComponent; + defaultSelectedYear = undefined; + defaultSortedBy: ChallengeSort = 'relevance'; // define filters sortFilters: Filter[] = challengeSortFilter; startYearRangeFilter: FilterPanel = challengeStartYearRangeFilterPanel; // checkbox filters + categoriesFilter = challengeCategoriesFilterPanel; + incentivesFilter = challengeIncentivesFilterPanel; statusFilter = challengeStatusFilterPanel; submissionTypesFilter = challengeSubmissionTypesFilterPanel; - incentivesFilter = challengeIncentivesFilterPanel; - categoriesFilter = challengeCategoriesFilterPanel; // dropdown filters - platformsFilter = challengePlatformsFilterPanel; + inputDataTypesFilter = challengeInputDataTypesFilterPanel; organizationsFilter = challengeOrganizationsFilterPanel; + platformsFilter = challengePlatformsFilterPanel; // define selected filter values - selectedStatus!: ChallengeStatus[]; - selectedSubmissionTypes!: ChallengeSubmissionType[]; - selectedIncentives!: ChallengeIncentive[]; + selectedCategories!: ChallengeCategory[]; - selectedPlatforms!: string[]; + selectedIncentives!: ChallengeIncentive[]; + // selectedInputDataTypes!: ChallengeInputDataType[]; + selectedInputDataTypes!: any[]; selectedOrgs!: number[]; + selectedPlatforms!: string[]; + selectedStatus!: ChallengeStatus[]; + selectedSubmissionTypes!: ChallengeSubmissionType[]; constructor( private activatedRoute: ActivatedRoute, @@ -194,32 +202,34 @@ export class ChallengeSearchComponent } // update selected filter values based on params in url - this.selectedStatus = this.splitParam(params['status']); - this.selectedSubmissionTypes = this.splitParam(params['submissionTypes']); - this.selectedIncentives = this.splitParam(params['incentives']); - this.selectedPlatforms = this.splitParam(params['platforms']); + this.searchedTerms = params['searchTerms']; this.selectedCategories = this.splitParam(params['categories']); + this.selectedIncentives = this.splitParam(params['incentives']); + this.selectedInputDataTypes = this.splitParam(params['inputDataTypes']); this.selectedOrgs = this.splitParam(params['organizations']).map( (idString) => +idString ); - this.searchedTerms = params['searchTerms']; this.selectedPageNumber = +params['pageNumber'] || this.defaultPageNumber; this.selectedPageSize = this.defaultPageSize; // no available pageSize options for users + this.selectedPlatforms = this.splitParam(params['platforms']); + this.selectedStatus = this.splitParam(params['status']); + this.selectedSubmissionTypes = this.splitParam(params['submissionTypes']); this.sortedBy = params['sort'] || this.defaultSortedBy; const defaultQuery: ChallengeSearchQuery = { + categories: this.selectedCategories, + incentives: this.selectedIncentives, + // inputDataTypes: this.selectedInputDataTypes, + maxStartDate: this.selectedMaxStartDate, + minStartDate: this.selectedMinStartDate, + organizations: this.selectedOrgs, pageNumber: this.selectedPageNumber, pageSize: this.selectedPageSize, - sort: this.sortedBy, + platforms: this.selectedPlatforms, searchTerms: this.searchedTerms, - minStartDate: this.selectedMinStartDate, - maxStartDate: this.selectedMaxStartDate, + sort: this.sortedBy, status: this.selectedStatus, submissionTypes: this.selectedSubmissionTypes, - platforms: this.selectedPlatforms, - incentives: this.selectedIncentives, - categories: this.selectedCategories, - organizations: this.selectedOrgs, }; this.query.next(defaultQuery); @@ -232,15 +242,17 @@ export class ChallengeSearchComponent this.totalChallengesCount = page.totalElements; }); - // update platform filter values this.challengeSearchDataService - .searchPlatforms() + .searchEdamConcepts() .pipe(takeUntil(this.destroy)) .subscribe((options) => { - const selectedPlatformValues = options.filter((option) => - this.selectedPlatforms.includes(option.value as string) + const selectedInputDataTypesValues = options.filter((option) => + this.selectedInputDataTypes.includes(option.value as string) + ); + this.inputDataTypesFilter.options = union( + options, + selectedInputDataTypesValues ); - this.platformsFilter.options = union(options, selectedPlatformValues); }); // update organization filter values @@ -253,6 +265,17 @@ export class ChallengeSearchComponent ); this.organizationsFilter.options = union(options, selectedOrgValues); }); + + // update platform filter values + this.challengeSearchDataService + .searchPlatforms() + .pipe(takeUntil(this.destroy)) + .subscribe((options) => { + const selectedPlatformValues = options.filter((option) => + this.selectedPlatforms.includes(option.value as string) + ); + this.platformsFilter.options = union(options, selectedPlatformValues); + }); } ngAfterContentInit(): void { @@ -358,19 +381,25 @@ export class ChallengeSearchComponent } onSearchChange( - searchType: 'challenges' | 'platforms' | 'organizations', + searchType: 'challenges' | 'inputDataTypes' | 'organizations' | 'platforms', searched: string ): void { switch (searchType) { case 'challenges': this.challengeSearchTerms.next(searched); break; - case 'platforms': - this.challengeSearchDataService.setPlatformSearchTerms(searched); + case 'inputDataTypes': + this.challengeSearchDataService.setEdamConceptSearchTerms({ + searchTerms: searched, + sections: [EdamSection.Data], + }); break; case 'organizations': this.challengeSearchDataService.setOriganizationSearchTerms(searched); break; + case 'platforms': + this.challengeSearchDataService.setPlatformSearchTerms(searched); + break; } } From f6945a9140dfcd8f792e7a2fe8ab3f8df60e1fa7 Mon Sep 17 00:00:00 2001 From: Rongrong Chai Date: Tue, 23 Apr 2024 17:52:15 +0000 Subject: [PATCH 2/6] no need to define sort in search term --- .../challenge-search/src/lib/challenge-search-data.service.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libs/openchallenges/challenge-search/src/lib/challenge-search-data.service.ts b/libs/openchallenges/challenge-search/src/lib/challenge-search-data.service.ts index dbafc84db8..1478d5a2e1 100644 --- a/libs/openchallenges/challenge-search/src/lib/challenge-search-data.service.ts +++ b/libs/openchallenges/challenge-search/src/lib/challenge-search-data.service.ts @@ -31,7 +31,7 @@ import { Filter } from '@sagebionetworks/openchallenges/ui'; }) export class ChallengeSearchDataService { private edamConceptSearchTerms: BehaviorSubject = - new BehaviorSubject({ searchTerms: '' }); + new BehaviorSubject({}); private organizationSearchTerms: BehaviorSubject = new BehaviorSubject(''); @@ -63,9 +63,7 @@ export class ChallengeSearchDataService { debounceTime(400), distinctUntilChanged(), switchMap((searchQuery: EdamConceptSearchQuery) => { - // const sortedBy: EdamSort = 'name'; const edamQuery: EdamConceptSearchQuery = searchQuery; - console.log(edamQuery); return this.edamConceptService.listEdamConcepts(edamQuery); }), map((page) => From 06d97383bd6babe4400d6b24f353f90de1ef7d3e Mon Sep 17 00:00:00 2001 From: Rongrong Chai Date: Mon, 22 Apr 2024 21:23:37 +0000 Subject: [PATCH 3/6] add input data type filters --- .../src/lib/challenge-search-data.service.ts | 66 +++++++--- .../src/lib/challenge-search-filter-panels.ts | 53 ++++---- .../src/lib/challenge-search.component.html | 16 +++ .../src/lib/challenge-search.component.ts | 123 +++++++++++------- 4 files changed, 165 insertions(+), 93 deletions(-) diff --git a/libs/openchallenges/challenge-search/src/lib/challenge-search-data.service.ts b/libs/openchallenges/challenge-search/src/lib/challenge-search-data.service.ts index ed9a59fe40..dbafc84db8 100644 --- a/libs/openchallenges/challenge-search/src/lib/challenge-search-data.service.ts +++ b/libs/openchallenges/challenge-search/src/lib/challenge-search-data.service.ts @@ -11,6 +11,8 @@ import { ChallengePlatformSearchQuery, ChallengePlatformService, ChallengePlatformSort, + EdamConceptSearchQuery, + EdamConceptService, Image, ImageAspectRatio, ImageHeight, @@ -28,44 +30,48 @@ import { Filter } from '@sagebionetworks/openchallenges/ui'; providedIn: 'root', }) export class ChallengeSearchDataService { - private platformSearchTerms: BehaviorSubject = - new BehaviorSubject(''); + private edamConceptSearchTerms: BehaviorSubject = + new BehaviorSubject({ searchTerms: '' }); private organizationSearchTerms: BehaviorSubject = new BehaviorSubject(''); + private platformSearchTerms: BehaviorSubject = + new BehaviorSubject(''); + constructor( + private edamConceptService: EdamConceptService, private challengePlatformService: ChallengePlatformService, private organizationService: OrganizationService, private imageService: ImageService ) {} - setPlatformSearchTerms(searchTerms: string) { - this.platformSearchTerms.next(searchTerms); + setEdamConceptSearchTerms(searchQuery: EdamConceptSearchQuery) { + this.edamConceptSearchTerms.next(searchQuery); } setOriganizationSearchTerms(searchTerms: string) { this.organizationSearchTerms.next(searchTerms); } - searchPlatforms(): Observable { - return this.platformSearchTerms.pipe( + setPlatformSearchTerms(searchTerms: string) { + this.platformSearchTerms.next(searchTerms); + } + + searchEdamConcepts(): Observable { + return this.edamConceptSearchTerms.pipe( debounceTime(400), distinctUntilChanged(), - switchMap((searchTerm: string) => { - const sortedBy: ChallengePlatformSort = 'name'; - const platformQuery: ChallengePlatformSearchQuery = { - searchTerms: searchTerm, - sort: sortedBy, - }; - return this.challengePlatformService.listChallengePlatforms( - platformQuery - ); + switchMap((searchQuery: EdamConceptSearchQuery) => { + // const sortedBy: EdamSort = 'name'; + const edamQuery: EdamConceptSearchQuery = searchQuery; + console.log(edamQuery); + return this.edamConceptService.listEdamConcepts(edamQuery); }), map((page) => - page.challengePlatforms.map((platform) => ({ - value: platform.slug, - label: platform.name, + page.edamConcepts.map((edamConcept) => ({ + value: edamConcept.classId, + label: edamConcept.preferredLabel, active: false, })) ) @@ -123,4 +129,28 @@ export class ChallengeSearchDataService { }) ); } + + searchPlatforms(): Observable { + return this.platformSearchTerms.pipe( + debounceTime(400), + distinctUntilChanged(), + switchMap((searchTerm: string) => { + const sortedBy: ChallengePlatformSort = 'name'; + const platformQuery: ChallengePlatformSearchQuery = { + searchTerms: searchTerm, + sort: sortedBy, + }; + return this.challengePlatformService.listChallengePlatforms( + platformQuery + ); + }), + map((page) => + page.challengePlatforms.map((platform) => ({ + value: platform.slug, + label: platform.name, + active: false, + })) + ) + ); + } } diff --git a/libs/openchallenges/challenge-search/src/lib/challenge-search-filter-panels.ts b/libs/openchallenges/challenge-search/src/lib/challenge-search-filter-panels.ts index bc0139893a..9fa42eb0c5 100644 --- a/libs/openchallenges/challenge-search/src/lib/challenge-search-filter-panels.ts +++ b/libs/openchallenges/challenge-search/src/lib/challenge-search-filter-panels.ts @@ -18,18 +18,10 @@ export const challengeStartYearRangeFilterPanel: FilterPanel = { collapsed: false, }; -// checkbox filters -export const challengeStatusFilterPanel: FilterPanel = { - query: 'status', - label: 'Status', - options: challengeStatusFilter, - collapsed: false, -}; - -export const challengeSubmissionTypesFilterPanel: FilterPanel = { - query: 'submissionTypes', - label: 'Submission Type', - options: challengeSubmissionTypesFilter, +export const challengeCategoriesFilterPanel: FilterPanel = { + query: 'categories', + label: 'Category', + options: challengeCategoriesFilter, collapsed: false, }; @@ -40,27 +32,11 @@ export const challengeIncentivesFilterPanel: FilterPanel = { collapsed: false, }; -export const challengePlatformsFilterPanel: FilterPanel = { - query: 'platforms', - label: 'Platform', - options: challengePlatformsFilter, - collapsed: false, -}; - -// dropdown filters export const challengeInputDataTypesFilterPanel: FilterPanel = { query: 'inputDataTypes', label: 'Input Data Type', options: challengeInputDataTypesFilter, collapsed: false, - showAvatar: false, -}; - -export const challengeCategoriesFilterPanel: FilterPanel = { - query: 'categories', - label: 'Category', - options: challengeCategoriesFilter, - collapsed: false, }; export const challengeOrganizationsFilterPanel: FilterPanel = { @@ -78,3 +54,24 @@ export const challengeOrganizatersFilterPanel: FilterPanel = { collapsed: false, showAvatar: true, }; + +export const challengePlatformsFilterPanel: FilterPanel = { + query: 'platforms', + label: 'Platform', + options: challengePlatformsFilter, + collapsed: false, +}; + +export const challengeStatusFilterPanel: FilterPanel = { + query: 'status', + label: 'Status', + options: challengeStatusFilter, + collapsed: false, +}; + +export const challengeSubmissionTypesFilterPanel: FilterPanel = { + query: 'submissionTypes', + label: 'Submission Type', + options: challengeSubmissionTypesFilter, + collapsed: false, +}; diff --git a/libs/openchallenges/challenge-search/src/lib/challenge-search.component.html b/libs/openchallenges/challenge-search/src/lib/challenge-search.component.html index 225a188b17..6e9588045b 100644 --- a/libs/openchallenges/challenge-search/src/lib/challenge-search.component.html +++ b/libs/openchallenges/challenge-search/src/lib/challenge-search.component.html @@ -89,6 +89,22 @@

Challenges

/>
+ + + + (); + @ViewChild('calendar') calendar?: Calendar; + @ViewChild('paginator', { static: false }) paginator!: PaginatorComponent; + challenges: Challenge[] = []; totalChallengesCount = 0; searchResultsCount!: number; - @ViewChild('calendar') calendar?: Calendar; customMonthRange!: Date[] | undefined; isCustomYear = false; refreshed = true; - selectedYear!: DateRange | string | undefined; - selectedMinStartDate!: string | undefined; - selectedMaxStartDate!: string | undefined; searchedTerms!: string; + selectedMaxStartDate!: string | undefined; + selectedMinStartDate!: string | undefined; selectedPageNumber!: number; selectedPageSize!: number; + selectedYear!: DateRange | string | undefined; sortedBy!: ChallengeSort; // set default values - defaultSelectedYear = undefined; - defaultSortedBy: ChallengeSort = 'relevance'; defaultPageNumber = 0; defaultPageSize = 24; - @ViewChild('paginator', { static: false }) paginator!: PaginatorComponent; + defaultSelectedYear = undefined; + defaultSortedBy: ChallengeSort = 'relevance'; // define filters sortFilters: Filter[] = challengeSortFilter; startYearRangeFilter: FilterPanel = challengeStartYearRangeFilterPanel; // checkbox filters + categoriesFilter = challengeCategoriesFilterPanel; + incentivesFilter = challengeIncentivesFilterPanel; statusFilter = challengeStatusFilterPanel; submissionTypesFilter = challengeSubmissionTypesFilterPanel; - incentivesFilter = challengeIncentivesFilterPanel; - categoriesFilter = challengeCategoriesFilterPanel; // dropdown filters - platformsFilter = challengePlatformsFilterPanel; + inputDataTypesFilter = challengeInputDataTypesFilterPanel; organizationsFilter = challengeOrganizationsFilterPanel; + platformsFilter = challengePlatformsFilterPanel; // define selected filter values - selectedStatus!: ChallengeStatus[]; - selectedSubmissionTypes!: ChallengeSubmissionType[]; - selectedIncentives!: ChallengeIncentive[]; + selectedCategories!: ChallengeCategory[]; - selectedPlatforms!: string[]; + selectedIncentives!: ChallengeIncentive[]; + // selectedInputDataTypes!: ChallengeInputDataType[]; + selectedInputDataTypes!: any[]; selectedOrgs!: number[]; + selectedPlatforms!: string[]; + selectedStatus!: ChallengeStatus[]; + selectedSubmissionTypes!: ChallengeSubmissionType[]; constructor( private activatedRoute: ActivatedRoute, @@ -194,32 +202,34 @@ export class ChallengeSearchComponent } // update selected filter values based on params in url - this.selectedStatus = this.splitParam(params['status']); - this.selectedSubmissionTypes = this.splitParam(params['submissionTypes']); - this.selectedIncentives = this.splitParam(params['incentives']); - this.selectedPlatforms = this.splitParam(params['platforms']); + this.searchedTerms = params['searchTerms']; this.selectedCategories = this.splitParam(params['categories']); + this.selectedIncentives = this.splitParam(params['incentives']); + this.selectedInputDataTypes = this.splitParam(params['inputDataTypes']); this.selectedOrgs = this.splitParam(params['organizations']).map( (idString) => +idString ); - this.searchedTerms = params['searchTerms']; this.selectedPageNumber = +params['pageNumber'] || this.defaultPageNumber; this.selectedPageSize = this.defaultPageSize; // no available pageSize options for users + this.selectedPlatforms = this.splitParam(params['platforms']); + this.selectedStatus = this.splitParam(params['status']); + this.selectedSubmissionTypes = this.splitParam(params['submissionTypes']); this.sortedBy = params['sort'] || this.defaultSortedBy; const defaultQuery: ChallengeSearchQuery = { + categories: this.selectedCategories, + incentives: this.selectedIncentives, + // inputDataTypes: this.selectedInputDataTypes, + maxStartDate: this.selectedMaxStartDate, + minStartDate: this.selectedMinStartDate, + organizations: this.selectedOrgs, pageNumber: this.selectedPageNumber, pageSize: this.selectedPageSize, - sort: this.sortedBy, + platforms: this.selectedPlatforms, searchTerms: this.searchedTerms, - minStartDate: this.selectedMinStartDate, - maxStartDate: this.selectedMaxStartDate, + sort: this.sortedBy, status: this.selectedStatus, submissionTypes: this.selectedSubmissionTypes, - platforms: this.selectedPlatforms, - incentives: this.selectedIncentives, - categories: this.selectedCategories, - organizations: this.selectedOrgs, }; this.query.next(defaultQuery); @@ -232,15 +242,17 @@ export class ChallengeSearchComponent this.totalChallengesCount = page.totalElements; }); - // update platform filter values this.challengeSearchDataService - .searchPlatforms() + .searchEdamConcepts() .pipe(takeUntil(this.destroy)) .subscribe((options) => { - const selectedPlatformValues = options.filter((option) => - this.selectedPlatforms.includes(option.value as string) + const selectedInputDataTypesValues = options.filter((option) => + this.selectedInputDataTypes.includes(option.value as string) + ); + this.inputDataTypesFilter.options = union( + options, + selectedInputDataTypesValues ); - this.platformsFilter.options = union(options, selectedPlatformValues); }); // update organization filter values @@ -253,6 +265,17 @@ export class ChallengeSearchComponent ); this.organizationsFilter.options = union(options, selectedOrgValues); }); + + // update platform filter values + this.challengeSearchDataService + .searchPlatforms() + .pipe(takeUntil(this.destroy)) + .subscribe((options) => { + const selectedPlatformValues = options.filter((option) => + this.selectedPlatforms.includes(option.value as string) + ); + this.platformsFilter.options = union(options, selectedPlatformValues); + }); } ngAfterContentInit(): void { @@ -358,19 +381,25 @@ export class ChallengeSearchComponent } onSearchChange( - searchType: 'challenges' | 'platforms' | 'organizations', + searchType: 'challenges' | 'inputDataTypes' | 'organizations' | 'platforms', searched: string ): void { switch (searchType) { case 'challenges': this.challengeSearchTerms.next(searched); break; - case 'platforms': - this.challengeSearchDataService.setPlatformSearchTerms(searched); + case 'inputDataTypes': + this.challengeSearchDataService.setEdamConceptSearchTerms({ + searchTerms: searched, + sections: [EdamSection.Data], + }); break; case 'organizations': this.challengeSearchDataService.setOriganizationSearchTerms(searched); break; + case 'platforms': + this.challengeSearchDataService.setPlatformSearchTerms(searched); + break; } } From 51aa20630be3656f965b284e4925e50867ad9b45 Mon Sep 17 00:00:00 2001 From: Rongrong Chai Date: Tue, 23 Apr 2024 17:52:15 +0000 Subject: [PATCH 4/6] no need to define sort in search term --- .../challenge-search/src/lib/challenge-search-data.service.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libs/openchallenges/challenge-search/src/lib/challenge-search-data.service.ts b/libs/openchallenges/challenge-search/src/lib/challenge-search-data.service.ts index dbafc84db8..1478d5a2e1 100644 --- a/libs/openchallenges/challenge-search/src/lib/challenge-search-data.service.ts +++ b/libs/openchallenges/challenge-search/src/lib/challenge-search-data.service.ts @@ -31,7 +31,7 @@ import { Filter } from '@sagebionetworks/openchallenges/ui'; }) export class ChallengeSearchDataService { private edamConceptSearchTerms: BehaviorSubject = - new BehaviorSubject({ searchTerms: '' }); + new BehaviorSubject({}); private organizationSearchTerms: BehaviorSubject = new BehaviorSubject(''); @@ -63,9 +63,7 @@ export class ChallengeSearchDataService { debounceTime(400), distinctUntilChanged(), switchMap((searchQuery: EdamConceptSearchQuery) => { - // const sortedBy: EdamSort = 'name'; const edamQuery: EdamConceptSearchQuery = searchQuery; - console.log(edamQuery); return this.edamConceptService.listEdamConcepts(edamQuery); }), map((page) => From 73ba74eaac5badc69b2c924eb5b2028c429ea3a8 Mon Sep 17 00:00:00 2001 From: Rongrong Chai Date: Wed, 24 Apr 2024 14:58:13 +0000 Subject: [PATCH 5/6] update to use EDAM id to filter challenges --- .../src/lib/challenge-search-data.service.ts | 9 +++++---- .../src/lib/challenge-search.component.ts | 14 +++++++------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/libs/openchallenges/challenge-search/src/lib/challenge-search-data.service.ts b/libs/openchallenges/challenge-search/src/lib/challenge-search-data.service.ts index 1478d5a2e1..b49bfcada4 100644 --- a/libs/openchallenges/challenge-search/src/lib/challenge-search-data.service.ts +++ b/libs/openchallenges/challenge-search/src/lib/challenge-search-data.service.ts @@ -13,6 +13,7 @@ import { ChallengePlatformSort, EdamConceptSearchQuery, EdamConceptService, + EdamSection, Image, ImageAspectRatio, ImageHeight, @@ -58,17 +59,17 @@ export class ChallengeSearchDataService { this.platformSearchTerms.next(searchTerms); } - searchEdamConcepts(): Observable { + searchEdamConcepts(sections?: EdamSection): Observable { return this.edamConceptSearchTerms.pipe( debounceTime(400), distinctUntilChanged(), switchMap((searchQuery: EdamConceptSearchQuery) => { - const edamQuery: EdamConceptSearchQuery = searchQuery; - return this.edamConceptService.listEdamConcepts(edamQuery); + searchQuery.sections = sections ? [sections] : searchQuery.sections; + return this.edamConceptService.listEdamConcepts(searchQuery); }), map((page) => page.edamConcepts.map((edamConcept) => ({ - value: edamConcept.classId, + value: edamConcept.id, label: edamConcept.preferredLabel, active: false, })) diff --git a/libs/openchallenges/challenge-search/src/lib/challenge-search.component.ts b/libs/openchallenges/challenge-search/src/lib/challenge-search.component.ts index 8864fb42a3..c974256756 100644 --- a/libs/openchallenges/challenge-search/src/lib/challenge-search.component.ts +++ b/libs/openchallenges/challenge-search/src/lib/challenge-search.component.ts @@ -10,7 +10,6 @@ import { Challenge, ChallengeCategory, ChallengeIncentive, - // ChallengeInputDataType, ChallengeSearchQuery, ChallengeService, ChallengeSort, @@ -154,8 +153,7 @@ export class ChallengeSearchComponent selectedCategories!: ChallengeCategory[]; selectedIncentives!: ChallengeIncentive[]; - // selectedInputDataTypes!: ChallengeInputDataType[]; - selectedInputDataTypes!: any[]; + selectedInputDataTypes!: number[]; selectedOrgs!: number[]; selectedPlatforms!: string[]; selectedStatus!: ChallengeStatus[]; @@ -205,7 +203,9 @@ export class ChallengeSearchComponent this.searchedTerms = params['searchTerms']; this.selectedCategories = this.splitParam(params['categories']); this.selectedIncentives = this.splitParam(params['incentives']); - this.selectedInputDataTypes = this.splitParam(params['inputDataTypes']); + this.selectedInputDataTypes = this.splitParam( + params['inputDataTypes'] + ).map((idString) => +idString); this.selectedOrgs = this.splitParam(params['organizations']).map( (idString) => +idString ); @@ -219,7 +219,7 @@ export class ChallengeSearchComponent const defaultQuery: ChallengeSearchQuery = { categories: this.selectedCategories, incentives: this.selectedIncentives, - // inputDataTypes: this.selectedInputDataTypes, + inputDataTypes: this.selectedInputDataTypes, maxStartDate: this.selectedMaxStartDate, minStartDate: this.selectedMinStartDate, organizations: this.selectedOrgs, @@ -243,11 +243,11 @@ export class ChallengeSearchComponent }); this.challengeSearchDataService - .searchEdamConcepts() + .searchEdamConcepts(EdamSection.Data) .pipe(takeUntil(this.destroy)) .subscribe((options) => { const selectedInputDataTypesValues = options.filter((option) => - this.selectedInputDataTypes.includes(option.value as string) + this.selectedInputDataTypes.includes(option.value as number) ); this.inputDataTypesFilter.options = union( options, From 86e9970a663b84fd5a0f2dd903a93e41fe70447a Mon Sep 17 00:00:00 2001 From: Rongrong Chai Date: Wed, 24 Apr 2024 15:10:32 +0000 Subject: [PATCH 6/6] sort variables --- .../src/lib/challenge-search-data.service.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/openchallenges/challenge-search/src/lib/challenge-search-data.service.ts b/libs/openchallenges/challenge-search/src/lib/challenge-search-data.service.ts index b49bfcada4..c8f01f4adb 100644 --- a/libs/openchallenges/challenge-search/src/lib/challenge-search-data.service.ts +++ b/libs/openchallenges/challenge-search/src/lib/challenge-search-data.service.ts @@ -41,10 +41,10 @@ export class ChallengeSearchDataService { new BehaviorSubject(''); constructor( - private edamConceptService: EdamConceptService, private challengePlatformService: ChallengePlatformService, - private organizationService: OrganizationService, - private imageService: ImageService + private edamConceptService: EdamConceptService, + private imageService: ImageService, + private organizationService: OrganizationService ) {} setEdamConceptSearchTerms(searchQuery: EdamConceptSearchQuery) {