From e7a118ad7f78411bd3b2b9ffdba40ea6f9c9520e Mon Sep 17 00:00:00 2001 From: argirok Date: Tue, 14 Nov 2023 15:07:34 +0200 Subject: [PATCH] [WIP]Researcher: add institutions, improvements in search UX, clear search, --- src/app/researcher/researcher.component.ts | 22 ++++++++++------ src/app/researcher/researcher.module.ts | 3 ++- .../search-researcher.component.html | 20 +++++++------- .../search-researcher.component.ts | 26 +++++++++++-------- 4 files changed, 41 insertions(+), 30 deletions(-) diff --git a/src/app/researcher/researcher.component.ts b/src/app/researcher/researcher.component.ts index d116098..3f5a0a2 100644 --- a/src/app/researcher/researcher.component.ts +++ b/src/app/researcher/researcher.component.ts @@ -10,7 +10,6 @@ import {SearchOrcidService} from "../openaireLibrary/claims/claim-utils/service/ import {CustomFilterService} from "../shared/customFilter.service"; import {LinksResolver} from "../search/links-resolver"; -import {map} from "rxjs/operators"; import {SearchResearchResultsService} from "../openaireLibrary/services/searchResearchResults.service"; import {StringUtils} from "../openaireLibrary/utils/string-utils.class"; @@ -20,11 +19,11 @@ import {StringUtils} from "../openaireLibrary/utils/string-utils.class";
-
+
-
+
{{author.authorGivenName}} {{author.authorFamilyName}}
@@ -45,6 +44,7 @@ import {StringUtils} from "../openaireLibrary/utils/string-utils.class";
Researcher Monitors
Lorem ipsum...
+
@@ -57,6 +57,7 @@ export class ResearcherComponent extends BaseComponent implements OnInit { properties = properties; totalResults; openResults; + loading = false; constructor(protected _router: Router, protected _route: ActivatedRoute, protected seoService: SEOService, @@ -73,24 +74,28 @@ export class ResearcherComponent extends BaseComponent implements OnInit { ngOnInit() { this.params.subscribe(params => { + this.authorId = params['stakeholder']; + this.author = null; this._customFilterService.setCustomFilter([]); - if(this.authorId) { + if (this.authorId) { + this.loading = true; LinksResolver.resetProperties(); - LinksResolver.setSearchAndResultLanding("researcher/"+this.authorId); + LinksResolver.setSearchAndResultLanding("researcher/" + this.authorId); this.subscriptions.push(this._searchOrcidService.searchOrcidSingleAuthor(this.authorId, properties, true).subscribe(data => { this.author = data; this._customFilterService.setCustomFilter( - [ new SearchCustomFilter("National", "country", "IE", "Irish National Monitor", false ), + [new SearchCustomFilter("National", "country", "IE", "Irish National Monitor", false), new SearchCustomFilter("Orcid", "authorId", this.authorId, this.author.authorGivenName + " " + this.author.authorFamilyName) - ]); + ]); - this.getResultsForAuthor(); + this.getResultsForAuthor(); // TODO not correct id/ no author // no irish author? }, err => { this._router.navigate([properties.errorLink]); })); } + }); } @@ -102,6 +107,7 @@ export class ResearcherComponent extends BaseComponent implements OnInit { if(this.totalResults ==0 ){ this._router.navigate([properties.errorLink]); }else{ + this.loading = false; this.subscriptions.push(this._searchResearchResultsService.numOfResearchOutcomes(param + ' and (resultbestaccessright exact "Open Access")', properties, null).subscribe(res => { this.openResults = res; })); diff --git a/src/app/researcher/researcher.module.ts b/src/app/researcher/researcher.module.ts index 1aa867b..1218325 100644 --- a/src/app/researcher/researcher.module.ts +++ b/src/app/researcher/researcher.module.ts @@ -4,6 +4,7 @@ import {CommonModule} from "@angular/common"; import {ResearcherComponent} from "./researcher.component"; import {SearchOrcidServiceModule} from "../openaireLibrary/claims/claim-utils/service/searchOrcidService.module"; import {SearchResearchResultsServiceModule} from "../openaireLibrary/services/searchResearchResultsService.module"; +import {LoadingModule} from "../openaireLibrary/utils/loading/loading.module"; const routes: Route[] = [ { @@ -16,7 +17,7 @@ const routes: Route[] = [ ]; @NgModule({ - imports: [CommonModule, RouterModule.forChild(routes), SearchOrcidServiceModule, SearchResearchResultsServiceModule], + imports: [CommonModule, RouterModule.forChild(routes), SearchOrcidServiceModule, SearchResearchResultsServiceModule, LoadingModule], declarations: [ResearcherComponent], exports: [ResearcherComponent], }) diff --git a/src/app/researcher/search-researcher/search-researcher.component.html b/src/app/researcher/search-researcher/search-researcher.component.html index 84c4e4a..16c51f9 100644 --- a/src/app/researcher/search-researcher/search-researcher.component.html +++ b/src/app/researcher/search-researcher/search-researcher.component.html @@ -1,12 +1,9 @@
-
+
- -
+
{{author.authorGivenName}} {{author.authorFamilyName}}
- + {{author.resultsCount}} research outcomes - +
+ {{author.institutions.join(", ")}}
@@ -54,9 +52,11 @@
- +
- +
diff --git a/src/app/researcher/search-researcher/search-researcher.component.ts b/src/app/researcher/search-researcher/search-researcher.component.ts index 7e2b16e..5262a2d 100644 --- a/src/app/researcher/search-researcher/search-researcher.component.ts +++ b/src/app/researcher/search-researcher/search-researcher.component.ts @@ -46,10 +46,8 @@ export class SearchResearcherComponent extends BaseComponent implements OnInit this.description = 'Researcher Monitors'; this.setMetadata(); this.subscriptions.push(this._route.queryParams.subscribe(params => { - if (params['keyword']) { - this.keyword = params['keyword']; + this.keyword = params['keyword']? decodeURIComponent( params['keyword']):""; this.search(); - } })); } @@ -61,21 +59,27 @@ export class SearchResearcherComponent extends BaseComponent implements OnInit }); } - keywordChanged(){ - this._router.navigate(['/researcher'], {queryParams: {keyword:this.keyword}}); + checkForReset() { + if(this.keyword == ""){ + this.searchByKeyword() + } + } + searchByKeyword(){ + this._router.navigate(['/researcher'], {queryParams: {keyword:encodeURIComponent(this.keyword)}}); } search() { //uncomment to disable search with no keyword - if (this.keyword.length == 0) { - return; - } this.warningMessage = ""; this.infoMessage = ""; - this.orcidStatus = this.errorCodes.LOADING; this.authors = []; this.authorsToShow = []; this.page = 1; this.authorsRendered = 0; + if (this.keyword.length == 0) { + this.orcidStatus = null; + return; + } + this.orcidStatus = this.errorCodes.LOADING; if(Identifier.isValidORCID(this.keyword)){ this.getOrcidAuthor(this.keyword.indexOf(properties.orcidURL)!=-1?this.keyword.split(properties.orcidURL)[1]:this.keyword, true, -1); }else{ @@ -169,8 +173,8 @@ private getOpenaireResultsFor(start, end){ } } private getOpenaireResultsObs(author){ - let param = '(authorid="' + StringUtils.URIEncode(author.id) + '")'; - // +' and (country exact "IE")'; + let param = '(authorid="' + StringUtils.URIEncode(author.id) + '")' + +' and (country exact "IE")'; return this._searchResearchResultsService.numOfResearchOutcomes(param, properties, null).pipe(map(res => { author.resultsCount = res; return author;