From dea00ca988933e64e977b684187b5ddf408542d8 Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Mon, 20 Jun 2022 15:56:29 +0300 Subject: [PATCH] [Library | new-theme]: Bug fixes in orcid (when work was deleted from ORCID ui, problem in "View orcid work" button & on grant (when not granting, but click on logout, success notification was appearing) | Deleted unused code. 1. resultLanding.component.ts & resultLanding.service.ts: Deleted code related to Open Citations (unused and deprecated). 2. myOrcidLinks.component.ts & orcid-work.component.ts: [Bug fix] On method "openGrantWindow()", condition changed to show success notification if (ev.isTrusted && ev.origin == location.origin && ev.data == 'success') - notification was appearing on logout. 3. orcid-work.component.ts: a. In #workModal set large="true". b. [Bug fix] In method "getPutCode()", called in "View orcid work" button, added check and warning notification if response is null - used to open empty modal. c. [Bug fix] In handleError() method, messages fixed -- used to show ...with pids: {{title}}... 4. datasourcesHelper.class.ts: In method "getQueryPrefix()" deleted commented conditional code for the environment. --- .../result/resultLanding.component.ts | 17 ------ landingPages/result/resultLanding.service.ts | 56 ------------------- .../my-orcid-links/myOrcidLinks.component.ts | 20 +++---- orcid/orcid-work.component.ts | 54 ++++++++++-------- .../searchUtils/datasourcesHelper.class.ts | 42 ++++---------- 5 files changed, 53 insertions(+), 136 deletions(-) diff --git a/landingPages/result/resultLanding.component.ts b/landingPages/result/resultLanding.component.ts index 290c61e7..414d3ac2 100644 --- a/landingPages/result/resultLanding.component.ts +++ b/landingPages/result/resultLanding.component.ts @@ -353,17 +353,6 @@ export class ResultLandingComponent { return array.filter(value => value.toLowerCase() !== type); } - private getOpenCitations() { - this.subscriptions.push(this._resultLandingService.getOpenCitations(this.id, this.properties).subscribe( - data => { - this.resultLandingInfo.openCitations = data[1]; - }, - err => { - this.handleError("Error getting open citation for " + this.type + " with id: " + this.id, err); - } - )); - } - private getVocabulariesAndResultLandingInfo() { this.errorMessage = ''; this.showLoading = true; @@ -460,9 +449,6 @@ export class ResultLandingComponent { (this.linkToLandingPage + this.resultLandingInfo.relcanId)); this.seoService.createLinkForCanonicalURL(this.canonicalUrl); this.updateUrl(this.canonicalUrl); - if ((this.type == "publication") && (this.properties.environment == "beta" || this.properties.environment == "development") && (typeof document !== 'undefined')) { - // this.getOpenCitations(); - } this.addNoIndexFilter(); if (this.resultLandingInfo.title) { this.updateTitle(this.resultLandingInfo.title); @@ -628,9 +614,6 @@ export class ResultLandingComponent { this.organizationsPage = $event.value; } - public updateOpenCitationsPage($event) { - this.openCitationsPage = $event.value; - } scrollToTabTop(tabId:string){ setTimeout(() => { window.scrollTo({ diff --git a/landingPages/result/resultLanding.service.ts b/landingPages/result/resultLanding.service.ts index 9cb0e20b..0a85ab77 100644 --- a/landingPages/result/resultLanding.service.ts +++ b/landingPages/result/resultLanding.service.ts @@ -470,62 +470,6 @@ export class ResultLandingService { return bioentities; } - getOpenCitations(id: string, properties:EnvProperties) { - //https://services.openaire.eu/opencitations/getCitations?id=doajarticles::2634200c24772ee8f10232d3e184ec65 - let url = properties.openCitationsAPIURL+id;// "https://services.openaire.eu/opencitations/getCitations?id=" + id; - let key = url; - - //return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) - return this.http.get(url) - .pipe(map(res => [res['total'], this.parseOpenCitations(res['results'])])); - } - - parseOpenCitations(openCitations: any): {"url": string, "title": string, "year": string, "doi": string, "authors": string[]}[] { - //title, doi, authors - let citations = new Array<{"url": string, "title": string, "year": string, "doi": string, "authors": string[]}>(); - - let openCitation; - - let length = Array.isArray(openCitations) ? openCitations.length : 1; - for(let i=0; iconnecting your ORCID iD with OpenAIRE!', - status: 'success', - timeout: 6000, - pos: 'bottom-right' - }); - self.getLocalWorks(); + if (ev.isTrusted && ev.origin == location.origin && ev.data == 'success') { + self.requestGrant = false; + UIkit.notification({ + message: 'Thank you for connecting your ORCID iD with OpenAIRE!', + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); + self.getLocalWorks(); + } }; } diff --git a/orcid/orcid-work.component.ts b/orcid/orcid-work.component.ts index 2439599f..a0bf7a33 100644 --- a/orcid/orcid-work.component.ts +++ b/orcid/orcid-work.component.ts @@ -164,7 +164,7 @@ declare var UIkit: any; - +
@@ -410,23 +410,23 @@ export class OrcidWorkComponent { let self = this; window.onmessage = function (ev) { - if (ev.isTrusted && ev.origin !== location.origin && ev.data !== 'success') - return; - self.requestGrant = false; - UIkit.notification({ - message: 'Thank you for connecting your ORCID iD with OpenAIRE!', - status: 'success', - timeout: 6000, - pos: 'bottom-right' - }); - if (self.currentAction == "add") { - self.saveWorkPreparation(); - } else if (self.currentAction == "delete") { - self.deleteWorks(); - } else if(self.currentAction == "update") { - self.updateWorkPreparation(); + if (ev.isTrusted && ev.origin == location.origin && ev.data == 'success') { + self.requestGrant = false; + UIkit.notification({ + message: 'Thank you for connecting your ORCID iD with OpenAIRE!', + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); + if (self.currentAction == "add") { + self.saveWorkPreparation(); + } else if (self.currentAction == "delete") { + self.deleteWorks(); + } else if (self.currentAction == "update") { + self.updateWorkPreparation(); + } } - }; + } } } @@ -597,9 +597,17 @@ export class OrcidWorkComponent { this.showLoading = true; this.subscriptions.push(this.orcidService.getOrcidWorks(this.putCodes).subscribe( (response: WorkV3_0[]) => { - this.orcidWorks = response; - - this.openWorkModal(); + if(response) { + this.orcidWorks = response; + this.openWorkModal(); + } else { + UIkit.notification({ + message: 'There was an error getting this work.
Please make sure you have not deleted it from your ORCID iD.', + status: 'warning', + timeout: 6000, + pos: 'bottom-right' + }); + } this.showLoading = false; }, error => { @@ -755,13 +763,13 @@ export class OrcidWorkComponent { this.message += "There was an error getting work \"" + this.resultTitle + "\" from your ORCID record.
Please try again later."; } else if(this.currentAction == "add") { // this.message += "There was an error adding work with pids: "+this.pids+" to your ORCID record.
Please try again later."; - this.message += "There was an error adding work with pids: \""+this.resultTitle+"\" to your ORCID record.
Please try again later."; + this.message += "There was an error adding work with pids: \""+this.pids+"\" to your ORCID record.
Please try again later."; } else if(this.currentAction == "update") { // this.message += "There was an error updating work with pids: "+this.pids+" to your ORCID record.
Please try again later."; - this.message += "There was an error updating work with pids: \""+this.resultTitle+"\" to your ORCID record.
Please try again later."; + this.message += "There was an error updating work \""+this.resultTitle+"\" to your ORCID record.
Please try again later."; } else if(this.currentAction == "delete") { // this.message += "There was an error deleting work with pids: "+this.pids+" from your ORCID record.
Please try again later."; - this.message += "There was an error deleting work with pids: \""+this.resultTitle+"\" from your ORCID record.
Please try again later."; + this.message += "There was an error deleting work \""+this.resultTitle+"\" from your ORCID record.
Please try again later."; } else { this.message += "There was an error. Please try again later." } diff --git a/searchPages/searchUtils/datasourcesHelper.class.ts b/searchPages/searchUtils/datasourcesHelper.class.ts index 603996b3..6c298c0a 100644 --- a/searchPages/searchUtils/datasourcesHelper.class.ts +++ b/searchPages/searchUtils/datasourcesHelper.class.ts @@ -47,37 +47,19 @@ export class DatasourcesHelperClass { } } public static getQueryPrefix(type: "all" | "registries" | "journals" | "compatible" | "deposit" | "services"): string { - // if(properties.environment == "production") { - // if (type == "registries") { - // return ' (datasourcetypeuiid = "entityregistry" or datasourcetypeuiid = "entityregistry::products" or datasourcetypeuiid = "entityregistry::repositories" ' + - // 'or datasourcetypeuiid = "entityregistry::organizations" or datasourcetypeuiid = "entityregistry::researchers" ) '; - // - // } else if (type == "journals") { - // // return ' not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) and (datasourcetypeuiid exact "pubsrepository::journal" or datasourcetypeuiid exact "aggregator::pubsrepository::journals" ) '; - // return 'oaftype exact datasource not datasourcecompatibilityid = notCompatible and (datasourcetypeuiid exact "pubsrepository::journal" or datasourcetypeuiid exact "aggregator::pubsrepository::journals" ) '; - // - // } else if (type == "compatible") { - // return ' oaftype exact datasource and datasourcecompatibilityid <> notCompatible and datasourcetypeuiid <> other and datasourcetypeuiid <> "pubsrepository::journal" and datasourcetypeuiid <> "aggregator::pubsrepository::journals" '; - // } else if (type == "deposit") { - // return ' oaftype exact datasource '; - // } else { - // return ""; - // } - // }else{ - if (type == "registries") { - return 'datasourcetypeuiname exact "Registry"'; - } else if (type == "journals") { - // return ' not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) and (datasourcetypeuiid exact "pubsrepository::journal" or datasourcetypeuiid exact "aggregator::pubsrepository::journals" ) '; - return 'oaftype exact datasource not datasourcecompatibilityid = notCompatible and datasourcetypeuiname exact "Journal archive" '; + if (type == "registries") { + return 'datasourcetypeuiname exact "Registry"'; + } else if (type == "journals") { + // return ' not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) and (datasourcetypeuiid exact "pubsrepository::journal" or datasourcetypeuiid exact "aggregator::pubsrepository::journals" ) '; + return 'oaftype exact datasource not datasourcecompatibilityid = notCompatible and datasourcetypeuiname exact "Journal archive" '; - } else if (type == "compatible") { - return ' oaftype exact datasource and datasourcecompatibilityid <> notCompatible and datasourcetypeuiname exact "Repository" '; - }else if (type == "deposit") { - return ' oaftype exact datasource and (datasourcetypeuiname exact "Journal archive" or datasourcetypeuiname exact "Repository")'; - } else { - return ""; - } - // } + } else if (type == "compatible") { + return ' oaftype exact datasource and datasourcecompatibilityid <> notCompatible and datasourcetypeuiname exact "Repository" '; + }else if (type == "deposit") { + return ' oaftype exact datasource and (datasourcetypeuiname exact "Journal archive" or datasourcetypeuiname exact "Repository")'; + } else { + return ""; + } } public static createFilters(type: "all" | "registries" | "journals" | "compatible" | "deposit" | "services"): Filter[] {