[Trunk | Library]:

1. orcidWork.ts: When description is >5000 characters, do not send it to ORCID work.
2. orcid.component.ts: When redirecting to /orcid by ORCID UI (source in not "openaire"), do not query for new tokens if user already has valid tokens in OpenAIRE.


git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@60480 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
konstantina.galouni 2021-02-23 15:50:37 +00:00
parent 889a58cb37
commit a856f29fc3
2 changed files with 54 additions and 31 deletions

View File

@ -27,6 +27,8 @@ export class OrcidComponent {
public orcidMessage: string = "";
public source: string = "";
public code: string = "";
public gotToken: boolean = false;
public routerHelper:RouterHelper = new RouterHelper();
@ -42,9 +44,16 @@ export class OrcidComponent {
this.updateUrl( properties.domain + properties.baseLink + this.route.url);
this.subscriptions.push(this.route.queryParams.subscribe(params => {
this.gotToken = false;
this.source = params['source'];
if (params['code']) {
this.getToken(params['code']);
this.code = params['code'];
if (this.code) {
if(this.source == "openaire") {
this.getToken(params['code']);
} else {
this.getPersonalDetails();
}
} else if(params['error']) {
this.showLoading = false;
this.orcidMessage = params['error_description'];
@ -70,6 +79,7 @@ export class OrcidComponent {
this.showLoading = true;
this.orcidService.getToken(code).subscribe(
gotTokens => {
this.gotToken = true;
if(gotTokens == null || gotTokens['value'] == false) {
this.showLoading = false;
this.message = "<div>An error occured while trying to connect your ORCID iD with OpenAIRE. Please try again!</div>" +
@ -89,39 +99,14 @@ export class OrcidComponent {
this.message = "<div>Thank you for connecting your ORCID iD with OpenAIRE!</div>" +
"<div class='uk-margin-small-top'>You will automatically be redirected to our advanced search page where you can link OpenAIRE research results with your ORCID iD.</div>";
//get author name
this.subscriptions.push(this.orcidService.getPersonalDetails().subscribe(
details => {
let author: string = "";
if(details && details['name']) {
let name: string = details['name'];
if(name['given-names'] && name['given-names']['value']) {
author = name['given-names']['value'];
}
if(name['family-name'] && name['family-name']['value']) {
author += (author ? " " : "") + name['family-name']['value'];
}
}
let params = this.routerHelper.createQueryParams(['f0', 'fv0'], ['resultauthor', author]);
this._router.navigate([properties.searchLinkToAdvancedResults], {queryParams: params});
},
error => {
console.error("Error getting personal details", error);
this._router.navigate([properties.searchLinkToAdvancedResults], {});
},
() => {
setTimeout(() => {
this.message += "<div class='uk-margin-top'>If you are not authomatically redirected, please navigate to our search pages.</div>";
}, 3000);
}
));
this.getPersonalDetails();
}
// this.message = "Thank you for connecting your ORCID iD with OpenAIRE! Please close this window and continue!";
}
},
error => {
this.gotToken = true;
console.error("Error getting token from code: "+code, error);
this.message = "An error occured while trying to connect your ORCID iD with OpenAIRE. Please try again!";
},
@ -131,6 +116,42 @@ export class OrcidComponent {
)
}
private getPersonalDetails() {
//get author name
this.subscriptions.push(this.orcidService.getPersonalDetails().subscribe(
details => {
let author: string = "";
if(details && details['name']) {
let name: string = details['name'];
if(name['given-names'] && name['given-names']['value']) {
author = name['given-names']['value'];
}
if(name['family-name'] && name['family-name']['value']) {
author += (author ? " " : "") + name['family-name']['value'];
}
}
let params = this.routerHelper.createQueryParams(['f0', 'fv0'], ['resultauthor', author]);
this._router.navigate([properties.searchLinkToAdvancedResults], {queryParams: params});
},
error => {
console.error("Error getting personal details", error);
if(this.gotToken) {
this._router.navigate([properties.searchLinkToAdvancedResults], {});
} else {
this.getToken(this.code);
}
},
() => {
if(this.gotToken) {
setTimeout(() => {
this.message += "<div class='uk-margin-top'>If you are not authomatically redirected, please navigate to our search pages.</div>";
}, 3000);
}
}
));
}
private updateTitle(title: string) {
this._title.setTitle(title);

View File

@ -62,6 +62,8 @@ export class WorkV3_0 {
}
public static resultLandingInfoConvert(resultLandingInfo: ResultLandingInfo, putCode: string) : WorkV3_0 {
let description_limit: number = 5000;
let work: WorkV3_0 = {};
// let work = {};
@ -104,7 +106,7 @@ export class WorkV3_0 {
work['journal-title'] = { "value": resultLandingInfo.journal.journal };
}
if(resultLandingInfo.description) {
if(resultLandingInfo.description && resultLandingInfo.description.length < description_limit) {
work['short-description'] = resultLandingInfo.description;
}