[Trunk | Library]: [NEW] Added "my-orcid-links" folder and files.
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@60394 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
ba229df685
commit
290df028ad
|
@ -0,0 +1,538 @@
|
|||
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, StringUtils} from "../../utils/string-utils.class";
|
||||
import {SearchResearchResultsService} from "../../services/searchResearchResults.service";
|
||||
import {Session} from "../../login/utils/helper.class";
|
||||
import {LoginErrorCodes} from "../../login/utils/guardHelper.class";
|
||||
import {SearchResult} from "../../utils/entities/searchResult";
|
||||
import {ResultPreview} from "../../utils/result-preview/result-preview";
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
|
||||
declare var UIkit: any;
|
||||
|
||||
@Component({
|
||||
selector: 'my-orcid-links',
|
||||
template: `
|
||||
|
||||
<!-- <div class="uk-section uk-padding-remove-bottom uk-padding-remove-top">-->
|
||||
<!-- <div class="explorePanelBackground communityPanelBackground uk-padding-small">-->
|
||||
<!-- <div class="uk-container uk-container-large uk-margin-small-top uk-margin-small-bottom">-->
|
||||
<!-- <breadcrumbs [light]="!!(this.communityId)" [breadcrumbs]="breadcrumbs"></breadcrumbs>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<div class="">
|
||||
<div class="uk-container uk-container-large uk-margin-top">
|
||||
<div *ngIf="showErrorMessage" class="uk-animation-fade uk-alert uk-alert-warning" role="alert">
|
||||
An Error Occurred
|
||||
</div>
|
||||
<div *ngIf="!showLoading && !orcidQuery && !requestGrant && !showErrorMessage"
|
||||
class="uk-animation-fade uk-alert uk-alert-primary" role="alert">
|
||||
No ORCID links found
|
||||
</div>
|
||||
<div *ngIf="requestGrant" class="">
|
||||
<div class="uk-text-center uk-padding-small">
|
||||
<div>
|
||||
This is a private page, only for users that have connected their ORCID iD with OpenAIRE.
|
||||
Please grant OpenAIRE to access and update your ORCID works.
|
||||
</div>
|
||||
|
||||
<div class="uk-margin-medium-top uk-align-center">
|
||||
<button (click)="openGrantWindow()" type="submit"
|
||||
class="uk-button uk-padding-small uk-padding-remove-vertical uk-margin-left uk-button-primary">
|
||||
<span>Grant OpenAIRE</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <div *ngIf="orcidQuery" class="uk-container uk-container-large uk-margin-top">-->
|
||||
|
||||
<!-- <form -->
|
||||
<!-- class="uk-margin-top uk-grid uk-margin-small-left ng-untouched ng-pristine ng-valid uk-form-width-large uk-float-right">-->
|
||||
<!-- -->
|
||||
<!-- <div class=" uk-padding-remove-left uk-margin-small-top uk-inline uk-width-expand">-->
|
||||
<!-- <a *ngIf="keyword.length > 0" class="uk-form-icon uk-form-icon-flip"-->
|
||||
<!-- (click)="keyword = ''"-->
|
||||
<!-- uk-icon="icon: close"></a>-->
|
||||
<!-- <input type="text" class="uk-input text-input-box uk-width-expand"-->
|
||||
<!-- placeholder="Search by name, description, subject..." aria-describedby="sizing-addon2"-->
|
||||
<!-- [(ngModel)]="keyword" name="keyword">-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="uk-padding-remove-left"> -->
|
||||
<!-- <button (click)="keywordChanged()" type="submit"-->
|
||||
<!-- class="portal-button uk-margin-small-left uk-margin-small-top uk-button">Search-->
|
||||
<!-- </button>-->
|
||||
<!-- </div>-->
|
||||
<!-- -->
|
||||
<!-- </form>-->
|
||||
<!-- </div>-->
|
||||
|
||||
|
||||
<!-- <div id="tm-main" class=" tm-middle" [class.uk-margin-top]="stickyForm">-->
|
||||
<!-- <div uk-grid>-->
|
||||
<!-- <div class="tm-main uk-width-1-1@s uk-width-1-1@m uk-width-1-1@l uk-row-first ">-->
|
||||
<!-- <div class="uk-container uk-container-large">-->
|
||||
<!-- <my-orcid-result [results]="results"-->
|
||||
<!-- [status]="searchUtils.status"-->
|
||||
<!-- [type]="resultType"-->
|
||||
<!-- [properties]=properties>-->
|
||||
<!-- </my-orcid-result>-->
|
||||
<!-- </div> -->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
</div>
|
||||
|
||||
<div *ngIf="orcidQuery" class="tm-middle" id="tm-main">
|
||||
<div uk-grid="" class="uk-grid uk-grid-stack">
|
||||
<div class="tm-main uk-width-1-1@s uk-width-1-1@m uk-width-1-1@l uk-row-first uk-first-column">
|
||||
<div class="uk-container uk-container-large">
|
||||
<my-orcid-result [previewResults]="currentResults"
|
||||
[status]="searchUtils.status"
|
||||
[type]="resultType"
|
||||
[properties]=properties
|
||||
[currentPage]="currentPage"
|
||||
[totalResults]="totalOrcidResults"
|
||||
[resultsPerPage]="resultsPerPage"
|
||||
(pageChange)="pageChanged($event)">
|
||||
</my-orcid-result>
|
||||
|
||||
<div class="uk-text-center uk-margin-medium-top uk-margin-medium-bottom uk-animation-fade uk-alert" role="alert">
|
||||
Your ORCID links will be visible in the OpenAIRE research results as soon as we synchronize our data with ORCID.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
})
|
||||
export class MyOrcidLinksComponent {
|
||||
public resultType: string = "result";
|
||||
|
||||
private errorCodes: ErrorCodes;
|
||||
private errorMessages: ErrorMessagesComponent;
|
||||
@Input() piwikSiteId = null;
|
||||
public results =[];
|
||||
public currentResults = [];
|
||||
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[] = [];
|
||||
works: any[] = [];
|
||||
|
||||
orcidQuery: string = "";
|
||||
typeQuery: string = "";
|
||||
|
||||
public showLoading: boolean = true;
|
||||
|
||||
currentPage: number = 1;
|
||||
totalOrcidResults: number;
|
||||
resultsPerPage: number = 5;
|
||||
|
||||
public requestGrant: boolean = false;
|
||||
public window: any;
|
||||
private tokenUrl: string;
|
||||
private clientId: string = "APP-A5M3KTX6NCN67L91";
|
||||
|
||||
public showErrorMessage: boolean = false;
|
||||
|
||||
constructor (private route: ActivatedRoute, private router: Router,
|
||||
private _orcidService: OrcidService,
|
||||
private _searchResearchResultsService: SearchResearchResultsService
|
||||
// ,private http: HttpClient/*ATHENA CODE*/
|
||||
) {
|
||||
this.errorCodes = new ErrorCodes();
|
||||
this.errorMessages = new ErrorMessagesComponent();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
this.searchUtils.page =1;
|
||||
|
||||
if(typeof document !== 'undefined') {
|
||||
this.tokenUrl = "https://sandbox.orcid.org/oauth/authorize?"
|
||||
+ "client_id="+this.clientId
|
||||
// + "&response_type=code&scope=/activities/update"
|
||||
// + "&response_type=code&scope=/authenticate /activities/update /person/update /read-limited"
|
||||
+ "&response_type=code&scope=/activities/update /read-limited"
|
||||
+ "&redirect_uri="+location.origin+"/orcid?source=openaire";
|
||||
}
|
||||
}
|
||||
|
||||
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.route.queryParams.subscribe(
|
||||
// params => {
|
||||
// this.searchUtils.page = params['page'] ? params['page']-1 : 1;
|
||||
// this.searchUtils.size = params['size'] ? params['size'] : 5;
|
||||
|
||||
// let page = (params['page'] === undefined) ? 1 : +params['page'];
|
||||
// this.searchUtils.page = (page <= 0) ? 1 : page;
|
||||
// let size = (params['size'] === undefined) ? 5 : +params['size'];
|
||||
// this.searchUtils.size = (size <= 0) ? 1 : size;
|
||||
//
|
||||
// if (params["type"]) {
|
||||
// let types = params["type"];
|
||||
// types = Array.isArray(types) ? types.join(',').split(","):types.split(",");
|
||||
// types.map( function (t) {
|
||||
// return StringUtils.unquote(StringUtils.URIDecode(t));
|
||||
// } );
|
||||
//
|
||||
// if(types.indexOf("publications")!=-1 && types.indexOf("datasets")!=-1 && types.indexOf("software")!=-1 && types.indexOf("other")!=-1 ){
|
||||
// this.typeQuery += "&type=results";
|
||||
// }else{
|
||||
// for (let type of types) {
|
||||
// this.typeQuery += "&type=" + StringUtils.unquote(StringUtils.URIDecode(type));
|
||||
// }
|
||||
// }
|
||||
// }else{
|
||||
// this.typeQuery += "&type=results";
|
||||
// }
|
||||
|
||||
this.typeQuery = "&type=results";
|
||||
// this.getLocalWorks(this.currentPage, this.resultsPerPage);
|
||||
// }));
|
||||
this.typeQuery = "&type=results";
|
||||
this.getLocalWorks();
|
||||
}
|
||||
|
||||
public ngOnDestroy() {
|
||||
for(let sub of this.subscriptions){
|
||||
sub.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
openGrantWindow() {
|
||||
this.window = window.open(this.tokenUrl, '_blank',
|
||||
'location=yes,height=700,width=540,left=500,top=100,scrollbars=yes,status=yes');
|
||||
|
||||
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 <strong>connecting your ORCID iD</strong> with OpenAIRE!',
|
||||
status: 'success',
|
||||
timeout: 6000,
|
||||
pos: 'bottom-right'
|
||||
});
|
||||
self.getLocalWorks();
|
||||
};
|
||||
}
|
||||
|
||||
getLocalWorks() {
|
||||
this.showErrorMessage = false;
|
||||
|
||||
this.showLoading = true;
|
||||
this.subscriptions.push(this._orcidService.getLocalWorks().subscribe(
|
||||
(response: any[]) => {
|
||||
|
||||
this.works = response;//['results'];
|
||||
this.totalOrcidResults = this.works.length;//response['total'];
|
||||
|
||||
this.prepareOrcidQuery();
|
||||
},
|
||||
error => {
|
||||
this.handleError(error, "Could not get locally stored user's ORCID works");
|
||||
this.showLoading = false;
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
public prepareOrcidQuery() {
|
||||
|
||||
if(this.results.length >= this.currentPage) {
|
||||
this.currentResults = this.results[this.currentPage-1];
|
||||
return;
|
||||
}
|
||||
|
||||
this.showLoading = true;
|
||||
|
||||
this.orcidQuery = "";
|
||||
|
||||
let from: number = (this.currentPage-1)*this.resultsPerPage;
|
||||
if(from >= this.works.length) {
|
||||
this.searchUtils.status = this.errorCodes.OUT_OF_BOUND;
|
||||
}
|
||||
let to: number = this.currentPage*this.resultsPerPage;
|
||||
|
||||
if(to > this.works.length) {
|
||||
to = this.works.length;
|
||||
}
|
||||
|
||||
let works = this.works.slice(from, to);
|
||||
|
||||
for(let work of works) {
|
||||
for(let pid of work['pids']) {
|
||||
let identifier: Identifier = Identifier.getIdentifierFromString(pid);
|
||||
this.orcidQuery += (this.orcidQuery ? " or " : "") + ('(pidclassid exact "'+identifier.class+'" and pid="'+StringUtils.URIEncode(identifier.id)+'")');
|
||||
//this.orcidQuery = '(pidclassid exact "doi" and pid="10.1007/978-3-030-55814-7_16")';
|
||||
// console.debug(this.orcidQuery);
|
||||
}
|
||||
}
|
||||
this.showLoading = false;
|
||||
this._getResults(works);
|
||||
}
|
||||
|
||||
public _getResults(works: any) {
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
this.disableForms = true;
|
||||
this.currentResults = [];
|
||||
this.searchUtils.totalResults = 0;
|
||||
|
||||
// let params: string = this.orcidQuery + this.typeQuery;
|
||||
//this.subs.push(this._searchResearchResultsService.advancedSearchResults(this.resultType, parameters, page, size, sortBy, this.properties, (refine) ? this.searchPage.getRefineFieldsQuery() : null, this.searchPage.getFields(), refineFieldsFilterQuery)
|
||||
this.subscriptions.push(this._searchResearchResultsService.searchForMyOrcidLinks(this.resultType, this.orcidQuery, this.typeQuery, 1, 50)
|
||||
//this.subs.push(this._searchResearchResultsService.advancedSearchResults(this.resultType, parameters, page, size, sortBy, this.properties, null, this.searchPage.getFields(), refineFieldsFilterQuery)
|
||||
.subscribe(
|
||||
data => {
|
||||
let totalResults = data[0];
|
||||
let results = data[1];
|
||||
|
||||
this.resultsReturned(results, totalResults, works);
|
||||
},
|
||||
err => {
|
||||
// this.handleError("Error getting " + this.getEntityName(this.resultType, true, true), err);
|
||||
console.error("Error getting " + this.getEntityName(this.resultType, true, true));
|
||||
this.showLoading = false;
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
this.disableForms = false;
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public resultsReturned(results: any, totalResults, works: any[]) {
|
||||
this.searchUtils.totalResults = totalResults;
|
||||
|
||||
let resultsFound: Map<string[], number> = new Map<string[], number>();
|
||||
|
||||
for(let work of works) {
|
||||
results.forEach(result => {
|
||||
let identifierValues: string[] = [].concat(...Array.from(result.identifiers.values()));
|
||||
if(work['pids'].some(pid => identifierValues.includes(pid))) {
|
||||
|
||||
let index: number = resultsFound.get(identifierValues);
|
||||
if(!index) {
|
||||
this.currentResults.push(this.getResultPreview(result));
|
||||
index = this.currentResults.length - 1;
|
||||
|
||||
this.currentResults[index].orcidPutCodes = [];
|
||||
this.currentResults[index].orcidCreationDates = [];
|
||||
this.currentResults[index].orcidUpdateDates = [];
|
||||
}
|
||||
|
||||
if (work['putCode']) {
|
||||
this.currentResults[index].orcidPutCodes.push(work['putCode']);
|
||||
}
|
||||
if (work['creationDate']) {
|
||||
this.currentResults[index].orcidCreationDates.push(work['creationDate']);
|
||||
}
|
||||
if (work['updateDate']) {
|
||||
this.currentResults[index].orcidUpdateDates.push(work['updateDate']);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// /////////////////////// ATHENA CODE ///////////////////////
|
||||
// // console.log(data[1]);
|
||||
// let dois = encodeURIComponent(results.map((result) => result.DOIs).join(","));
|
||||
// console.log(dois);
|
||||
// console.log(this.properties.impactFactorsAPIURL);
|
||||
// if(dois.length > 0 && (this.properties.impactFactorsAPIURL && this.properties.impactFactorsAPIURL.length > 0) ) {
|
||||
// let url = this.properties.impactFactorsAPIURL + dois;
|
||||
// this.http.get((this.properties.useCache?(this.properties.cacheUrl+(encodeURIComponent(url))):url)).subscribe((data_received:any[]) => {
|
||||
// let impact =[];
|
||||
// data_received.forEach(function (result) {
|
||||
// if(result.doi && result.doi.length > 0 && result.pop_class!=null && result.inf_class!=null)
|
||||
// impact[result.doi]=result;
|
||||
// });
|
||||
// this.currentResults.forEach(function (result) {
|
||||
// if(result.identifiers) {
|
||||
// result.identifiers.get("doi").forEach(function (doi) {
|
||||
// if (impact[doi]) {
|
||||
// result.DOI = doi;
|
||||
// }
|
||||
//
|
||||
// })
|
||||
// }
|
||||
// });
|
||||
// for (let i = 0; i < this.currentResults.length; i++) {
|
||||
// if (this.currentResults[i].DOI) {
|
||||
// this.currentResults[i].pop_inf = new Array<string>();
|
||||
// this.currentResults[i].pop_inf.push(impact[this.currentResults[i].DOI].pop_class, impact[this.currentResults[i].DOI].inf_class);
|
||||
// if(this.currentResults[i].pop_inf[0]=="A"){
|
||||
// // this.previewResults[i].pop_inf.push("High");
|
||||
// this.currentResults[i].pop_inf.push("Exceptional");
|
||||
// }else if(this.currentResults[i].pop_inf[0]=="B"){
|
||||
// // this.previewResults[i].pop_inf.push("Average");
|
||||
// this.currentResults[i].pop_inf.push("Substantial");
|
||||
// }else{
|
||||
// // this.previewResults[i].pop_inf.push("low");
|
||||
// this.currentResults[i].pop_inf.push("Average");
|
||||
// }
|
||||
// if(this.currentResults[i].pop_inf[1]=="A"){
|
||||
// // this.previewResults[i].pop_inf.push("Strong");
|
||||
// this.currentResults[i].pop_inf.push("Exceptional");
|
||||
// }else if(this.currentResults[i].pop_inf[1]=="B"){
|
||||
// // this.previewResults[i].pop_inf.push("Average");
|
||||
// this.currentResults[i].pop_inf.push("Substantial");
|
||||
// }else{
|
||||
// // this.previewResults[i].pop_inf.push("Weak");
|
||||
// this.currentResults[i].pop_inf.push("Average");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }, error1 => {
|
||||
// console.error("Failed to get Impact factors for elixir-gr")
|
||||
// });
|
||||
// // console.log(researchResults[1]);
|
||||
//
|
||||
// }
|
||||
// /////////////////////// ATHENA CODE ///////////////////////
|
||||
|
||||
|
||||
this.results[this.currentPage-1] = this.currentResults;
|
||||
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if (this.searchUtils.totalResults == 0) {
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
|
||||
this.disableForms = false;
|
||||
}
|
||||
|
||||
public resultsReturned2(results: any, totalResults, works: any[]) {
|
||||
this.searchUtils.totalResults = totalResults;
|
||||
|
||||
for(let result of results) {
|
||||
let identifierValues: string[] = [].concat(...Array.from(result.identifiers.values()));
|
||||
|
||||
this.currentResults.push(this.getResultPreview(result));
|
||||
|
||||
let filteredWorks = works.filter(work => {
|
||||
return work['pids'].some(pid => identifierValues.includes(pid));
|
||||
})
|
||||
|
||||
this.currentResults[this.currentResults.length - 1].orcidPutCodes = [];
|
||||
this.currentResults[this.currentResults.length - 1].orcidCreationDates = [];
|
||||
this.currentResults[this.currentResults.length - 1].orcidUpdateDates = [];
|
||||
|
||||
filteredWorks.forEach(work => {
|
||||
if(work['putCode']) {
|
||||
this.currentResults[this.currentResults.length - 1].orcidPutCodes.push(work['putCode']);
|
||||
}
|
||||
if(work['creationDate']) {
|
||||
this.currentResults[this.currentResults.length - 1].orcidCreationDates.push(work['creationDate']);
|
||||
}
|
||||
if(work['updateDate']) {
|
||||
this.currentResults[this.currentResults.length - 1].orcidUpdateDates.push(work['updateDate']);
|
||||
}
|
||||
|
||||
// this.currentResults[this.currentResults.length - 1].orcidPutCodes.push(work['putCode']);
|
||||
// this.currentResults[this.currentResults.length - 1].orcidCreationDates.push(work['creationDate']);
|
||||
// this.currentResults[this.currentResults.length - 1].orcidUpdateDates.push(work['creationDate']);
|
||||
});
|
||||
}
|
||||
|
||||
this.results[this.currentPage-1] = this.currentResults;
|
||||
// if(!refine) {
|
||||
// this.searchPage.buildPageURLParameters(this.filters, this.rangeFilters, false);
|
||||
// }
|
||||
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if (this.searchUtils.totalResults == 0) {
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
|
||||
this.disableForms = false;
|
||||
}
|
||||
|
||||
public getResultPreview(result: SearchResult): ResultPreview {
|
||||
return ResultPreview.searchResultConvert(result, (result.entityType)?result.entityType:this.resultType);
|
||||
}
|
||||
|
||||
// private handleError(message: string, error) {
|
||||
// if(error && error.status == "401") {
|
||||
// this.requestGrant = true;
|
||||
// this.requestGrantMessage = "Please grant OpenAIRE to access and update your ORCID record and works. ";
|
||||
// // + "If you have already granted OpenAIRE, you just need to login again to ORCID!";
|
||||
// } else if(error && error.status == "403") {
|
||||
// this.requestGrant = true;
|
||||
// this.requestGrantMessage = "Please login again to ORCID."
|
||||
// }
|
||||
// console.error("My ORCID links Page: "+message, error);
|
||||
// }
|
||||
|
||||
public getEntityName(entityType: string, plural: boolean, full: boolean): string {
|
||||
if (entityType == "publication") {
|
||||
return "publication" + (plural ? "s" : "");
|
||||
} else if (entityType == "dataset") {
|
||||
return (full ? "research data" : ("dataset" + (plural ? "s" : "")));
|
||||
} else if (entityType == "software") {
|
||||
return "software";
|
||||
} else if (entityType == "other") {
|
||||
return (full ? ("other research product" + (plural ? "s" : "")) : "other");
|
||||
} else if (entityType == "result") {
|
||||
return (full ? ("research outcome" + (plural ? "s" : "")) : "result");
|
||||
}
|
||||
}
|
||||
|
||||
public pageChanged($event) {
|
||||
this.currentPage = $event.value;
|
||||
this.prepareOrcidQuery();
|
||||
// this.getLocalWorks(this.currentPage, this.resultsPerPage);
|
||||
}
|
||||
|
||||
handleError(error, errorMsg: string) {
|
||||
if(error && (error.status == "401" || error.status == "403")) {
|
||||
this.requestGrant = true;
|
||||
} else {
|
||||
this.showErrorMessage = true;
|
||||
|
||||
// UIkit.notification({
|
||||
// message: errorMsg,
|
||||
// status: 'warning',
|
||||
// timeout: 6000,
|
||||
// pos: 'bottom-right'
|
||||
// });
|
||||
}
|
||||
this.showLoading = false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
import {NgModule} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {RouterModule} from '@angular/router';
|
||||
|
||||
import {ResultPreviewModule} from "../../utils/result-preview/result-preview.module";
|
||||
import {ErrorMessagesModule} from "../../utils/errorMessages.module";
|
||||
import {MyOrcidLinksComponent} from "./myOrcidLinks.component";
|
||||
import {SearchResearchResultsServiceModule} from "../../services/searchResearchResultsService.module";
|
||||
import {SearchMyOrcidResultsModule} from "./searchMyOrcidResults.module";
|
||||
import {AlertModalModule} from "../../utils/modal/alertModal.module";
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule, FormsModule,
|
||||
RouterModule, ErrorMessagesModule,
|
||||
ResultPreviewModule, SearchResearchResultsServiceModule, SearchMyOrcidResultsModule,
|
||||
AlertModalModule
|
||||
],
|
||||
declarations: [
|
||||
MyOrcidLinksComponent
|
||||
],
|
||||
providers:[
|
||||
],
|
||||
exports: [
|
||||
MyOrcidLinksComponent
|
||||
]
|
||||
})
|
||||
export class MyOrcidLinksModule { }
|
|
@ -0,0 +1,41 @@
|
|||
<!--<div *ngIf="status == errorCodes.NONE" class="uk-text-center uk-margin-large-top uk-width-3-5">-->
|
||||
<!-- <p class="uk-text-large uk-text-muted uk-margin">There are no repositories for your preferences</p>-->
|
||||
|
||||
<!-- <p class="uk-text-large uk-text-muted">We suggest to deposit your research in</p>-->
|
||||
<!-- <!– <a href="{{zenodoInformation.url}}" target="_blank" class="custom-external custom-icon">{{zenodoInformation.name}}</a>–>-->
|
||||
<!-- <svg xmlns="http://www.w3.org/2000/svg" width="173" height="56.685" viewBox="0 0 173 56.685"><defs><style>.a{fill:#191919;}</style></defs><path class="a" d="M171.749,22.311a16.158,16.158,0,0,0-3.364-4.953A15.511,15.511,0,0,0,157.4,12.837a15.213,15.213,0,0,0-6.074,1.206,16.4,16.4,0,0,0-2.63,1.424,16.2,16.2,0,0,0-2.325,1.891,14.893,14.893,0,0,0-1.242,1.383,19.241,19.241,0,0,0-1.173,1.7,19.372,19.372,0,0,0-1.482,3.343c.048-1.943.332-4.842,1.482-6.468V3.272a3.081,3.081,0,0,0-.993-2.323,3.251,3.251,0,0,0-5.556,2.323V15.765a17.084,17.084,0,0,0-4.261-2.156,14.8,14.8,0,0,0-4.781-.773,15.314,15.314,0,0,0-6.028,1.206,15.575,15.575,0,0,0-4.959,3.316,16.056,16.056,0,0,0-3.352,4.953c-.063.142-.118.286-.177.43-.056-.144-.111-.288-.173-.43a16.158,16.158,0,0,0-3.364-4.953,15.519,15.519,0,0,0-4.95-3.316,15.795,15.795,0,0,0-12.105,0,16.068,16.068,0,0,0-4.954,3.316,15.182,15.182,0,0,0-3.359,4.953c-.058.136-.109.272-.162.407-.056-.135-.109-.271-.167-.407a16.056,16.056,0,0,0-3.357-4.953,15.532,15.532,0,0,0-4.956-3.316,15.795,15.795,0,0,0-12.105,0,16.084,16.084,0,0,0-4.948,3.316,15.129,15.129,0,0,0-3.366,4.953c-.051.125-.1.253-.148.378-.051-.125-.1-.253-.155-.378a16.165,16.165,0,0,0-3.366-4.953,15.489,15.489,0,0,0-10.979-4.521,15.185,15.185,0,0,0-6.072,1.206,16.01,16.01,0,0,0-4.622,3.017v-.521A3.335,3.335,0,0,0,27.211,13.2H3.837a3.334,3.334,0,0,0,0,6.669h18.37L.658,48.884A3.333,3.333,0,0,0,0,50.872v2.176a3.337,3.337,0,0,0,3.336,3.336H28.214a3.335,3.335,0,0,0,3.324-3.09,15.693,15.693,0,0,0,3.675,2.184,15.189,15.189,0,0,0,6.031,1.207A14.892,14.892,0,0,0,49.857,54.1a15.447,15.447,0,0,0,4.827-5.188v4.5a3.245,3.245,0,0,0,3.277,3.275,3.194,3.194,0,0,0,2.281-.949,3.077,3.077,0,0,0,.991-2.326V41.733h-.012a.087.087,0,0,1,.012-.015h-8.17a3.175,3.175,0,0,0-1.851.558,3.007,3.007,0,0,0-1.161,1.507l-.535,1.1a8.969,8.969,0,0,1-8.271,5.254,9.141,9.141,0,0,1-3.493-.684,8.463,8.463,0,0,1-2.883-1.939,9.963,9.963,0,0,1-1.94-2.888,8.4,8.4,0,0,1-.729-3.447V38.252H61.234V28.34a8.74,8.74,0,0,1,.688-3.442,8.959,8.959,0,0,1,8.355-5.515,9.117,9.117,0,0,1,3.493.687,8.459,8.459,0,0,1,2.883,1.94,10.032,10.032,0,0,1,1.94,2.889,8.36,8.36,0,0,1,.734,3.442V53.409A3.233,3.233,0,0,0,82.6,56.684a3.211,3.211,0,0,0,2.286-.949,3.107,3.107,0,0,0,.986-2.326v-4.5a15.828,15.828,0,0,0,2.482,3.249,15.454,15.454,0,0,0,4.954,3.314,15.671,15.671,0,0,0,12.061,0,16.035,16.035,0,0,0,5-3.314,15.226,15.226,0,0,0,3.359-4.951c.044-.112.087-.225.129-.338.046.113.087.226.134.338a15.068,15.068,0,0,0,3.359,4.951,16.075,16.075,0,0,0,4.951,3.314,15.79,15.79,0,0,0,12.109,0,15.476,15.476,0,0,0,4.946-3.314,16.166,16.166,0,0,0,3.366-4.951c.06-.142.116-.283.173-.426.058.143.111.284.173.426a16.07,16.07,0,0,0,3.359,4.951,15.454,15.454,0,0,0,4.954,3.314,15.671,15.671,0,0,0,12.061,0,16.008,16.008,0,0,0,5-3.314A15.314,15.314,0,0,0,173,41.178V28.341A14.991,14.991,0,0,0,171.749,22.311ZM8.35,49.716,25.794,26.224a16.054,16.054,0,0,0-.143,2.117V41.178A14.759,14.759,0,0,0,26.9,47.211a16.514,16.514,0,0,0,1.366,2.5H8.35ZM50.285,31.7H32.2V28.34a8.738,8.738,0,0,1,.686-3.442,8.951,8.951,0,0,1,8.36-5.515,9.1,9.1,0,0,1,3.486.687,8.423,8.423,0,0,1,2.885,1.94,10.033,10.033,0,0,1,1.94,2.889,8.318,8.318,0,0,1,.729,3.442V31.7Zm58.093,9.48a8.7,8.7,0,0,1-.688,3.447,8.941,8.941,0,0,1-8.352,5.511,9.141,9.141,0,0,1-3.493-.684,8.417,8.417,0,0,1-2.883-1.939,9.917,9.917,0,0,1-1.94-2.888,8.353,8.353,0,0,1-.729-3.447V28.341A8.74,8.74,0,0,1,90.98,24.9a8.935,8.935,0,0,1,1.937-2.889,9.165,9.165,0,0,1,9.9-1.94,8.433,8.433,0,0,1,2.888,1.94,10.129,10.129,0,0,1,1.94,2.889,8.356,8.356,0,0,1,.729,3.442V41.178Zm29.035,0a8.32,8.32,0,0,1-.729,3.447,9.947,9.947,0,0,1-1.94,2.888,8.358,8.358,0,0,1-2.888,1.939,9.337,9.337,0,0,1-7.018,0,9.046,9.046,0,0,1-4.825-4.826,8.735,8.735,0,0,1-.69-3.447V28.341a8.439,8.439,0,0,1,.732-3.442,10.1,10.1,0,0,1,1.94-2.889,8.522,8.522,0,0,1,2.883-1.94,9.152,9.152,0,0,1,3.493-.687,8.985,8.985,0,0,1,8.357,5.515,8.775,8.775,0,0,1,.686,3.442V41.178Zm29.035,0a8.82,8.82,0,0,1-.686,3.447,9.129,9.129,0,0,1-11.85,4.826,8.424,8.424,0,0,1-2.882-1.939,9.946,9.946,0,0,1-1.942-2.888,8.337,8.337,0,0,1-.732-3.447V28.341a8.742,8.742,0,0,1,.69-3.442,8.935,8.935,0,0,1,1.937-2.889,9.169,9.169,0,0,1,9.905-1.94,8.423,8.423,0,0,1,2.885,1.94,10.088,10.088,0,0,1,1.942,2.889,8.356,8.356,0,0,1,.729,3.442V41.178Z"/></svg>-->
|
||||
<!-- <p>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.</p>-->
|
||||
<!--</div>-->
|
||||
|
||||
<div class="uk-margin-top uk-margin">
|
||||
<div class="uk-clearfix ">
|
||||
<paging-no-load [currentPage]="currentPage" [totalResults]="totalResults" [size]="resultsPerPage"
|
||||
(pageChange)="pageChanged($event)" class="uk-float-right"></paging-no-load>
|
||||
</div>
|
||||
|
||||
<ul class="uk-list search-results uk-margin-remove-top">
|
||||
<errorMessages *ngIf="status != errorCodes.NONE" [status]="[status]" [type]="'results'"></errorMessages>
|
||||
|
||||
<li *ngFor="let result of previewResults" class="uk-animation-fade">
|
||||
<div class="uk-card uk-card-default uk-padding uk-card-hover">
|
||||
<div class="uk-grid uk-grid-divider">
|
||||
<div class="uk-width-3-4 uk-first-column">
|
||||
<result-preview [properties]="properties" [showOrcid]="false" [showOrganizations]="true"
|
||||
[showSubjects]="true" [result]="result" [promoteWebsiteURL]="true">
|
||||
</result-preview>
|
||||
</div>
|
||||
|
||||
<div class="uk-width-1-4">
|
||||
<div class="uk-height-1-1 uk-padding-small uk-flex uk-flex-center uk-flex-column uk-flex-middle">
|
||||
<orcid-work [resultId]="result.id" [type]="result.resultType" [pageType]="'my_search'"
|
||||
[putCodes]="result.orcidPutCodes" [givenPutCode]="true"
|
||||
[identifiers]="result.identifiers"
|
||||
[creationDates]="result.orcidCreationDates" [updateDates]="result.orcidUpdateDates">
|
||||
</orcid-work>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
|
@ -0,0 +1,117 @@
|
|||
import {Component, EventEmitter, Input, Output, SimpleChanges} 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";
|
||||
import {Session} from "../../login/utils/helper.class";
|
||||
import {OrcidService} from "../orcid.service";
|
||||
|
||||
@Component({
|
||||
selector: 'my-orcid-result',
|
||||
templateUrl:'searchMyOrcidResults.component.html'
|
||||
})
|
||||
|
||||
export class searcMyOrcidResultsComponent {
|
||||
@Input() results: SearchResult[];
|
||||
@Input() status: number;
|
||||
@Input() type: string;
|
||||
@Input() properties:EnvProperties;
|
||||
|
||||
@Input() previewResults:ResultPreview[];
|
||||
|
||||
public urlParam: string;
|
||||
public linkToAdvancedSearchPage: string;
|
||||
public errorCodes:ErrorCodes = new ErrorCodes();
|
||||
public routerHelper:RouterHelper = new RouterHelper();
|
||||
public errorMessage: string = "No results found";
|
||||
@Output() pageChange = new EventEmitter();
|
||||
@Input() currentPage: number = 0;
|
||||
@Input() totalResults: number;
|
||||
@Input() resultsPerPage: number = 5;
|
||||
|
||||
sub;
|
||||
constructor (private route: ActivatedRoute, private orcidService: OrcidService) {}
|
||||
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";
|
||||
}
|
||||
|
||||
this.properties = properties;
|
||||
|
||||
}
|
||||
|
||||
// ngOnChanges(changes: SimpleChanges): void {
|
||||
// if (changes.results) {
|
||||
// this.initialize();
|
||||
// }
|
||||
// }
|
||||
|
||||
public quote(params: string):string {
|
||||
return '"'+params+'"';
|
||||
}
|
||||
public getResultPreview(result: SearchResult): ResultPreview {
|
||||
return ResultPreview.searchResultConvert(result, (result.entityType)?result.entityType:this.type);
|
||||
}
|
||||
|
||||
initialize() {
|
||||
this.previewResults = [];
|
||||
for (let result of this.results) {
|
||||
this.previewResults.push(this.getResultPreview(result));
|
||||
}
|
||||
|
||||
if (this.properties.environment == 'development' && Session.isLoggedIn() && this.results && this.results.length > 0) {
|
||||
this.orcidService.getLocalWorksByPids(this.previewResults.map(
|
||||
previewResult => {
|
||||
if (previewResult.identifiers) {
|
||||
let pidsArray: string[] = [];
|
||||
for (let key of Array.from(previewResult.identifiers.keys())) {
|
||||
pidsArray = pidsArray.concat(previewResult.identifiers.get(key));
|
||||
}
|
||||
return pidsArray;//.join();
|
||||
}
|
||||
})).subscribe(
|
||||
works => {
|
||||
for (let i = 0; i < this.previewResults.length; i++) {
|
||||
if (this.previewResults[i].identifiers) {
|
||||
this.previewResults[i].orcidPutCodes = [];
|
||||
this.previewResults[i].orcidUpdateDates = [];
|
||||
|
||||
works[i].forEach(work => {
|
||||
this.previewResults[i].orcidPutCodes.push(work['putCode']);
|
||||
this.previewResults[i].orcidUpdateDates.push(work['creationDate']);
|
||||
});
|
||||
// this.previewResults[i].orcidPutCodes = works[i].map(work => work['putCode']);
|
||||
// this.previewResults[i].orcidUpdateDates = works[i]
|
||||
// console.debug(i, this.previewResults[i].orcidPutCodes);
|
||||
}
|
||||
}
|
||||
}, error => {
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public pageChanged($event) {
|
||||
this.pageChange.emit($event);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
import {NgModule} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {RouterModule} from '@angular/router';
|
||||
|
||||
import {ResultPreviewModule} from "../../utils/result-preview/result-preview.module";
|
||||
import {ErrorMessagesModule} from "../../utils/errorMessages.module";
|
||||
import {searcMyOrcidResultsComponent} from "./searchMyOrcidResults.component";
|
||||
import {OrcidModule} from "../orcid.module";
|
||||
import {PagingModule} from "../../utils/paging.module";
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule, FormsModule,
|
||||
RouterModule, ErrorMessagesModule,
|
||||
ResultPreviewModule, OrcidModule, PagingModule
|
||||
],
|
||||
declarations: [
|
||||
searcMyOrcidResultsComponent
|
||||
],
|
||||
providers:[
|
||||
],
|
||||
exports: [
|
||||
searcMyOrcidResultsComponent
|
||||
]
|
||||
})
|
||||
export class SearchMyOrcidResultsModule { }
|
Loading…
Reference in New Issue