From cff2dc80484375be97b8cfda03b0b7050df9e745 Mon Sep 17 00:00:00 2001 From: argirok Date: Mon, 13 Nov 2023 14:54:52 +0200 Subject: [PATCH 1/2] Search researcher add keyword as URL parameter --- .../search-researcher.component.html | 2 +- .../search-researcher.component.ts | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/app/researcher/search-researcher/search-researcher.component.html b/src/app/researcher/search-researcher/search-researcher.component.html index c77468a..3138540 100644 --- a/src/app/researcher/search-researcher/search-researcher.component.html +++ b/src/app/researcher/search-researcher/search-researcher.component.html @@ -1,6 +1,6 @@
+ [searchInputClass]="'inner background'" (searchEmitter)="keywordChanged()" class="uk-width-xlarge@l uk-width-large@m">
diff --git a/src/app/researcher/search-researcher/search-researcher.component.ts b/src/app/researcher/search-researcher/search-researcher.component.ts index 578a0ab..7e2b16e 100644 --- a/src/app/researcher/search-researcher/search-researcher.component.ts +++ b/src/app/researcher/search-researcher/search-researcher.component.ts @@ -7,7 +7,7 @@ import {SearchResearchResultsService} from "../../openaireLibrary/services/searc import {forkJoin, Subscriber} from "rxjs"; import {properties} from "../../../environments/environment"; import {BaseComponent} from "../../openaireLibrary/sharedComponents/base/base.component"; -import {Router} from "@angular/router"; +import {ActivatedRoute, Router} from "@angular/router"; import {SEOService} from "../../openaireLibrary/sharedComponents/SEO/SEO.service"; import {PiwikService} from "../../openaireLibrary/utils/piwik/piwik.service"; import {Meta, Title} from "@angular/platform-browser"; @@ -33,6 +33,8 @@ export class SearchResearcherComponent extends BaseComponent implements OnInit constructor(private _searchOrcidService: SearchOrcidService, private _searchResearchResultsService: SearchResearchResultsService, protected _router: Router, + protected _route: ActivatedRoute, + protected seoService: SEOService, protected _piwikService: PiwikService, protected _title: Title, @@ -43,10 +45,12 @@ export class SearchResearcherComponent extends BaseComponent implements OnInit this.title = 'Researcher Monitors'; this.description = 'Researcher Monitors'; this.setMetadata(); - - if (this.keyword != null && this.keyword.length > 0) { - this.search(); - } + this.subscriptions.push(this._route.queryParams.subscribe(params => { + if (params['keyword']) { + this.keyword = params['keyword']; + this.search(); + } + })); } ngOnDestroy() { @@ -56,6 +60,10 @@ export class SearchResearcherComponent extends BaseComponent implements OnInit } }); } + + keywordChanged(){ + this._router.navigate(['/researcher'], {queryParams: {keyword:this.keyword}}); + } search() { //uncomment to disable search with no keyword if (this.keyword.length == 0) { From 418cf7873a760bb19e48b1333910c27af794517b Mon Sep 17 00:00:00 2001 From: argirok Date: Mon, 13 Nov 2023 14:55:47 +0200 Subject: [PATCH 2/2] Researcher: navigate to error when there is no author --- src/app/app-routing.module.ts | 3 +++ src/app/researcher/researcher.component.ts | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index fb9153b..826c5d2 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -1,6 +1,7 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; import {Irish} from "./shared/irish"; +import {ErrorPageComponent} from "./openaireLibrary/error/errorPage.component"; const routes: Routes = [ { @@ -30,6 +31,8 @@ const routes: Routes = [ loadChildren: () => import('./admin/admin.module').then(m => m.AdminModule), data: {title: Irish.METADATA_PREFIX + ' Admin | '}, }, + {path: 'error', component: ErrorPageComponent}, + {path: '**', pathMatch: 'full', component: ErrorPageComponent} ]; @NgModule({ diff --git a/src/app/researcher/researcher.component.ts b/src/app/researcher/researcher.component.ts index a522d9b..47ba0a7 100644 --- a/src/app/researcher/researcher.component.ts +++ b/src/app/researcher/researcher.component.ts @@ -66,7 +66,6 @@ export class ResearcherComponent extends BaseComponent implements OnInit { if(this.authorId) { LinksResolver.resetProperties(); LinksResolver.setSearchAndResultLanding("researcher/"+this.authorId); - console.log(properties.searchLinkToPublication); this.subscriptions.push(this._searchOrcidService.searchOrcidSingleAuthor(this.authorId, properties, true).subscribe(data => { this.author = data; this._customFilterService.setCustomFilter( @@ -76,6 +75,8 @@ export class ResearcherComponent extends BaseComponent implements OnInit { // TODO not correct id/ no author // no irish author? + }, err => { + this._router.navigate([properties.errorLink]); })); } });