From f57e7d4d607c44b01a769895a317f01f1087db2c Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Wed, 10 Feb 2021 09:26:47 +0000 Subject: [PATCH] [Trunk | Library]: 1. [NEW] Added folder and files for "recommend-orcid-links". 2. searchResearchResults.component.ts: Added input fields "usedBy", "orcidQuery", "identifiers" (needed for recommend orcid links page). 3. newSearchPage.component.html: Add cases for "usedBy=='orcid'" | call component when "usedBy == 'orcid'". 4. newSearchPage.module.ts: Import "SearchResultsForOrcidModule". git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@60395 d315682c-612b-4755-9ff5-7f18f6832af3 --- ...rchRecommendedResultsForOrcid.component.ts | 173 ++++++++++++++++++ ...searchRecommendedResultsForOrcid.module.ts | 31 ++++ .../searchResultsForOrcid.component.html | 18 ++ .../searchResultsForOrcid.component.ts | 71 +++++++ .../searchResultsForOrcid.module.ts | 25 +++ .../searchResearchResults.component.ts | 25 ++- .../searchUtils/newSearchPage.component.html | 19 +- .../searchUtils/newSearchPage.module.ts | 6 +- 8 files changed, 356 insertions(+), 12 deletions(-) create mode 100644 orcid/recommend-orcid-links/searchRecommendedResultsForOrcid.component.ts create mode 100644 orcid/recommend-orcid-links/searchRecommendedResultsForOrcid.module.ts create mode 100644 orcid/recommend-orcid-links/searchResultsForOrcid.component.html create mode 100644 orcid/recommend-orcid-links/searchResultsForOrcid.component.ts create mode 100644 orcid/recommend-orcid-links/searchResultsForOrcid.module.ts diff --git a/orcid/recommend-orcid-links/searchRecommendedResultsForOrcid.component.ts b/orcid/recommend-orcid-links/searchRecommendedResultsForOrcid.component.ts new file mode 100644 index 00000000..911f3079 --- /dev/null +++ b/orcid/recommend-orcid-links/searchRecommendedResultsForOrcid.component.ts @@ -0,0 +1,173 @@ +import {Component, Input, ViewChild} from '@angular/core'; +import {ActivatedRoute, Router} from '@angular/router'; +import {Location} from '@angular/common'; +import {ErrorCodes} from "../../utils/properties/errorCodes"; +import {ErrorMessagesComponent} from "../../utils/errorMessages.component"; +import {SearchUtilsClass} from "../../searchPages/searchUtils/searchUtils.class"; +import {RouterHelper} from "../../utils/routerHelper.class"; +import {EnvProperties} from "../../utils/properties/env-properties"; +import {properties} from "../../../../environments/environment"; +import {OrcidService} from "../orcid.service"; +import {Identifier} from "../../utils/string-utils.class"; + +@Component({ + selector: 'search-recommended-results-for-orcid', + template: ` + + + + + + + + +
+
+ + +
+ +
+ +
+ +
+ + +
+
+ +
+ +
+
+ + + + + +
+ ` +}) +export class SearchRecommendedResultsForOrcidComponent { + private errorCodes: ErrorCodes; + private errorMessages: ErrorMessagesComponent; + @Input() piwikSiteId = null; + public results =[]; + public totalResults:number = 0 ; + public baseUrl:string; + public searchUtils:SearchUtilsClass = new SearchUtilsClass(); + public subscriptions: any[] = []; + public _location:Location; + + public disableForms: boolean = false; + public loadPaging: boolean = true; + public oldTotalResults: number = 0; + pagingLimit = 0; + + properties:EnvProperties; + + @Input() public communityId: string = null; + + depositLearnHowPage: string = null; + public routerHelper:RouterHelper = new RouterHelper(); + // breadcrumbs:Breadcrumb[] = []; + parameters = {}; + keyword = ""; + + identifiers: string[] = []; + + orcidQuery: string = ""; + public showLoading: boolean = true; + + constructor (private route: ActivatedRoute, private router: Router, private _orcidService: OrcidService) { + this.errorCodes = new ErrorCodes(); + this.errorMessages = new ErrorMessagesComponent(); + this.searchUtils.status = this.errorCodes.LOADING; + this.searchUtils.page =1; + } + + public ngOnInit() { + this.properties = properties; + this.depositLearnHowPage = this.properties.depositLearnHowPage; + this.baseUrl = this.properties.depositSearchPage; + this.pagingLimit = this.properties.pagingLimit; + // this.breadcrumbs.push({name: 'home', route: '/'}, { + // name: "Deposit", + // route: this.depositLearnHowPage + // }, {name: "Browse repositories", route: null}); + + // this.subscriptions.push(this._orcidService.getLocalWorks().subscribe( + // works => { + // console.debug(works); + // for(let work of works) { + // for(let pid of work['pids']) { + // let identifier: Identifier = Identifier.getIdentifierFromString(pid); + // this.pidsQuery += (this.pidsQuery ? " or " : "") + '(pidclassid exact "'+identifier.class+'" and pid="'+identifier.id+'")' + // } + // } + // }, + // error => { + // this.handleError("Could not get user's ORCID works", error); + // } + // )); + + this.subscriptions.push(this._orcidService.getUserOrcid().subscribe( + orcidId => { + orcidId = "0000-0001-7291-3210";//"0000-0002-0458-1004"; + // console.debug("mocked orcidIdrcidId: "+orcidId); + this.orcidQuery = 'authorid exact "'+orcidId+'" and (authoridtype exact "orcid_pending")'; + this.showLoading = false; + }, + error => { + this.handleError("Could not get user's ORCID iD", error); + this.showLoading = false; + } + )); + + this.subscriptions.push(this.route.queryParams.subscribe(params => { + this.parameters = Object.assign({}, params); + this.keyword = params["fv0"]?params["fv0"]:''; + })); + } + + public ngOnDestroy() { + for(let sub of this.subscriptions){ + sub.unsubscribe(); + } + } + keywordChanged() { + + if (this.keyword.length > 0) { + this.parameters["fv0"] = this.keyword; + this.parameters["f0"] = "q"; + } else { + delete this.parameters['fv0']; + delete this.parameters['f0']; + } + + if (this.parameters["page"]) { + //GO to first page + delete this.parameters['page']; + } + + this.router.navigate(['/recommended-orcid-links'], {queryParams: this.parameters}); + } + + private handleError(message: string, error) { + console.error("Search My Results in Orcid Page: "+message, error); + } +} diff --git a/orcid/recommend-orcid-links/searchRecommendedResultsForOrcid.module.ts b/orcid/recommend-orcid-links/searchRecommendedResultsForOrcid.module.ts new file mode 100644 index 00000000..d23ade61 --- /dev/null +++ b/orcid/recommend-orcid-links/searchRecommendedResultsForOrcid.module.ts @@ -0,0 +1,31 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; +import { RouterModule } from '@angular/router'; + +import {SearchRecommendedResultsForOrcidComponent} from './searchRecommendedResultsForOrcid.component'; + +import {SearchResultsModule } from '../../searchPages/searchUtils/searchResults.module'; + +import {SearchFormModule} from '../../searchPages/searchUtils/searchForm.module'; +import {IsRouteEnabled} from '../../error/isRouteEnabled.guard'; +import {SearchResearchResultsModule} from "../../searchPages/searchResearchResults.module"; +import {OrcidService} from "../orcid.service"; +// import {BreadcrumbsModule} from "../utils/breadcrumbs/breadcrumbs.module"; + +@NgModule({ + imports: [ + CommonModule, FormsModule, + RouterModule, + SearchFormModule, SearchResearchResultsModule, + // , BreadcrumbsModule + ], + declarations: [ + SearchRecommendedResultsForOrcidComponent + ], + providers:[ IsRouteEnabled, OrcidService], + exports: [ + SearchRecommendedResultsForOrcidComponent + ] +}) +export class SearchRecommendedResultsForOrcidModule { } diff --git a/orcid/recommend-orcid-links/searchResultsForOrcid.component.html b/orcid/recommend-orcid-links/searchResultsForOrcid.component.html new file mode 100644 index 00000000..4678c819 --- /dev/null +++ b/orcid/recommend-orcid-links/searchResultsForOrcid.component.html @@ -0,0 +1,18 @@ + +
+

There are no repositories for your preferences

+ +

We suggest to deposit your research in

+ + +

The OpenAIRE Catch-all repository hosted at CERN cloud infrastructure. Whatever your field of research is, you can deposit any type of research product, select the proper license, ask for a DOI and link it to the funding projects for easy reporting.

+
+ diff --git a/orcid/recommend-orcid-links/searchResultsForOrcid.component.ts b/orcid/recommend-orcid-links/searchResultsForOrcid.component.ts new file mode 100644 index 00000000..23dea6a1 --- /dev/null +++ b/orcid/recommend-orcid-links/searchResultsForOrcid.component.ts @@ -0,0 +1,71 @@ +import {Component, Input} from '@angular/core'; +import {ActivatedRoute} from "@angular/router"; +import {Subscriber} from "rxjs"; +import {SearchResult} from "../../utils/entities/searchResult"; +import {EnvProperties} from "../../utils/properties/env-properties"; +import {RouterHelper} from "../../utils/routerHelper.class"; +import {ErrorCodes} from "../../utils/properties/errorCodes"; +import {ResultPreview} from "../../utils/result-preview/result-preview"; +import {properties} from "../../../../environments/environment"; + +@Component({ + selector: 'orcid-result', + templateUrl:'searchResultsForOrcid.component.html' +}) + +export class SearchResultsForOrcidComponent { + @Input() results: SearchResult[]; + @Input() status: number; + @Input() type: string; + @Input() properties:EnvProperties; + + + public urlParam: string; + public linkToAdvancedSearchPage: string; + public errorCodes:ErrorCodes = new ErrorCodes(); + public routerHelper:RouterHelper = new RouterHelper(); + public errorMessage: string = "No results found"; + + sub; + constructor (private route: ActivatedRoute) {} + ngOnDestroy() { + if (this.sub instanceof Subscriber) { + this.sub.unsubscribe(); + } + } + ngOnInit() { + if(this.type == "publication") { + this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedPublications; + this.urlParam = "articleId"; + } else if(this.type == "dataset") { + this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedDatasets; + this.urlParam = "datasetId"; + } else if(this.type == "software") { + this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedSoftware; + this.urlParam = "softwareId"; + } else if(this.type == "other") { + this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedOrps; + this.urlParam = "orpId"; + } else if(this.type == "project") { + this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedProjects; + this.urlParam = "projectId"; + } else if(this.type == "organization") { + this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedOrganizations; + this.urlParam = "organizationId"; + } else if(this.type == "dataprovider") { + this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedDataProviders; + this.urlParam = "datasourceId"; + } + + this.properties = properties; + + } + + public quote(params: string):string { + return '"'+params+'"'; + } + public getResultPreview(result: SearchResult): ResultPreview { + return ResultPreview.searchResultConvert(result, (result.entityType)?result.entityType:this.type); + } + +} diff --git a/orcid/recommend-orcid-links/searchResultsForOrcid.module.ts b/orcid/recommend-orcid-links/searchResultsForOrcid.module.ts new file mode 100644 index 00000000..51aef780 --- /dev/null +++ b/orcid/recommend-orcid-links/searchResultsForOrcid.module.ts @@ -0,0 +1,25 @@ +import {NgModule} from '@angular/core'; +import {CommonModule} from '@angular/common'; +import {FormsModule} from '@angular/forms'; +import {RouterModule} from '@angular/router'; + +import {SearchResultsForOrcidComponent} from './searchResultsForOrcid.component'; +import {ResultPreviewModule} from "../../utils/result-preview/result-preview.module"; +import {ErrorMessagesModule} from "../../utils/errorMessages.module"; + +@NgModule({ + imports: [ + CommonModule, FormsModule, + RouterModule, ErrorMessagesModule, + ResultPreviewModule + ], + declarations: [ + SearchResultsForOrcidComponent + ], + providers:[ + ], + exports: [ + SearchResultsForOrcidComponent + ] +}) +export class SearchResultsForOrcidModule { } diff --git a/searchPages/searchResearchResults.component.ts b/searchPages/searchResearchResults.component.ts index ddc0d4c7..f41192f3 100644 --- a/searchPages/searchResearchResults.component.ts +++ b/searchPages/searchResearchResults.component.ts @@ -1,5 +1,5 @@ import {Component, EventEmitter, Input, OnChanges, Output, SimpleChanges, ViewChild} from '@angular/core'; -import {ActivatedRoute} from '@angular/router'; +import {ActivatedRoute, Router} from '@angular/router'; import {AdvancedField, Filter} from './searchUtils/searchHelperClasses.class'; import {SearchResearchResultsService} from '../services/searchResearchResults.service'; import {ErrorCodes} from '../utils/properties/errorCodes'; @@ -98,7 +98,12 @@ export class SearchResearchResultsComponent { private promise: Promise = null; private publicCommunities = null; - constructor(private route: ActivatedRoute, private _searchResearchResultsService: SearchResearchResultsService, + @Input() usedBy: string = "search"; + @Input() orcidQuery: string = ""; + @Input() identifiers: string[] = []; + + constructor(private route: ActivatedRoute, private _router: Router, + private _searchResearchResultsService: SearchResearchResultsService, private _contextService: ContextsService) { this.results = []; this.errorCodes = new ErrorCodes(); @@ -107,6 +112,10 @@ export class SearchResearchResultsComponent { this.searchUtils.refineStatus = this.errorCodes.LOADING; this.getPublicCommunities(); } + + getRoute(){ + return this._router.url.split("?")[0]; + } ngOnInit() { //TODO add checks about which result types are enabled! @@ -117,11 +126,15 @@ export class SearchResearchResultsComponent { this.simpleSearchLink = this.properties.searchLinkToResults; } this.advancedSearchLink = this.properties.searchLinkToAdvancedResults; - this.searchUtils.baseUrl = (this.simpleView) ? this.simpleSearchLink : this.advancedSearchLink; + this.searchUtils.baseUrl = this.getRoute();//(this.simpleView) ? this.simpleSearchLink : this.advancedSearchLink; this.searchUtils.status = this.errorCodes.LOADING; var firstLoad = true; this.subs.push(this.route.queryParams.subscribe(params => { + if(this.usedBy == "orcid"){ + this.searchPage.usedBy = "orcid"; + } + //this.subs.push(this.route.queryParams.switchMap(params => { this.loadPaging = true; if (params['page'] && this.searchUtils.page != params['page']) { @@ -206,6 +219,9 @@ export class SearchResearchResultsComponent { public _getFilters(parameters: string, page: number, size: number, sortBy: string, refine: boolean, refineFieldsFilterQuery = null) { + if(this.usedBy == "orcid" && this.orcidQuery) { + parameters += (parameters ? ' and ' : '') + "(" + this.orcidQuery + ")"; + } if (page <= this.pagingLimit || this.searchUtils.refineStatus == this.errorCodes.LOADING) { this.searchUtils.refineStatus = this.errorCodes.LOADING; this.disableRefineForms = true; @@ -302,6 +318,9 @@ export class SearchResearchResultsComponent { } public _getResults(parameters: string, page: number, size: number, sortBy: string, refine: boolean, refineFieldsFilterQuery = null) { + if(this.usedBy == "orcid" && this.orcidQuery) { + parameters += (parameters ? ' and ' : '') + "(" + this.orcidQuery + ")"; + } if (page > this.pagingLimit) { size = 0; } diff --git a/searchPages/searchUtils/newSearchPage.component.html b/searchPages/searchUtils/newSearchPage.component.html index 78d7877a..5c8c2454 100644 --- a/searchPages/searchUtils/newSearchPage.component.html +++ b/searchPages/searchUtils/newSearchPage.component.html @@ -146,17 +146,16 @@ -
@@ -368,6 +367,12 @@ [zenodoInformation]="zenodoInformation" [properties]=properties> + +