Publication landing page: *NEW* Add 'Open Citations' tab.

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@54432 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
konstantina.galouni 2018-12-17 11:03:46 +00:00
parent 4ab2393242
commit 4af92166e6
4 changed files with 135 additions and 2 deletions

View File

@ -87,9 +87,9 @@
</li>
</ul>
<hr *ngIf="publicationInfo.description">
<div *ngIf="publicationInfo.description" class="uk-margin-bottom uk-text-justify descriptionText">
<!-- <div *ngIf="publicationInfo.description" class="uk-margin-bottom uk-text-justify descriptionText">
{{publicationInfo.description}}
</div>
</div> -->
@ -317,6 +317,62 @@
</div>
</li>
<li *ngIf="publicationInfo.openCitations && publicationInfo.openCitations.length > 0">
<a class="uk-accordion-title" href="#">
Open Citations
({{publicationInfo.openCitations.length | number}})
</a>
<div class="uk-accordion-content">
<div *ngIf="publicationInfo.openCitations.length > pageSize" class="uk-margin-bottom">
<span class="uk-h6">{{publicationInfo.openCitations.length | number}} open citations, page {{openCitationsPage | number}} of {{totalPages(publicationInfo.openCitations.length) | number}}</span>
<paging-no-load class="uk-float-right" [currentPage]="openCitationsPage" [totalResults]="publicationInfo.openCitations.length" [size]="pageSize" (pageChange)="updateOpenCitationsPage($event)"></paging-no-load>
</div>
<ul class="uk-list uk-list-divider uk-margin">
<li *ngFor="let result of publicationInfo.openCitations.slice((openCitationsPage-1)*pageSize, openCitationsPage*pageSize)">
<!-- <h5>
<span *ngIf="result.url" class="custom-external custom-icon" >
<a target="_blank" [href]="result.url" *ngIf="result['title']" [innerHTML]="result['title']"></a>
<a target="_blank" [href]="result.url" *ngIf="!result['title']">[no title available]</a>
</span>
<p *ngIf="!result.url && result['title']"><span [innerHTML]="result['title']"></span></p>
<p *ngIf="!result.url && !result['title']">[no title available]</p>
</h5> -->
<h5 *ngIf="result.title">
<span *ngIf="result.url"
class="custom-external">
<a *ngIf="result.title" href="{{result.url}}" target="_blank"
[innerHTML]="result.title">
</a>
<a *ngIf="!result.title" href="{{result.url}}" target="_blank">
[no title available]
</a>
</span>
<span *ngIf="result.title && !result.url" [innerHTML]="result.title"></span>
<span *ngIf="!result.title && !result.url">
[no title available]
</span>
</h5>
<div>
<span *ngIf="result['authors']">
<span *ngFor="let author of result['authors'].slice(0,15)">
{{author}};
</span>
<span *ngIf="result['authors'].length > 15">...</span>
</span>
<span *ngIf="result.year">
({{result.year}})
</span>
</div>
<span *ngIf="result.doi">Identifier: <a *ngIf="result.doi" target="_blank" class="custom-external custom-icon" href="{{doiURL}}{{result.doi}}">doi: {{result.doi}}</a></span>
</li>
</ul>
</div>
</li>
<li (click)="metricsClicked=true; activeTab='Metrics'">
<a class="uk-accordion-title" href="#">
Metrics

View File

@ -42,6 +42,7 @@ export class PublicationComponent {
public organizationsPage: number = 1;
public softwarePage: number = 1;
public bioentitiesPage: number = 1;
public openCitationsPage: number = 1;
public pageSize: number = 10;
/*
public startt: number = 0;
@ -63,6 +64,7 @@ export class PublicationComponent {
public routerHelper:RouterHelper = new RouterHelper();
private doi: string;
public doiURL: string;
private result;
sub: any; piwiksub: any; infoSub: any;
properties:EnvProperties;
@ -81,6 +83,7 @@ export class PublicationComponent {
this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
this.doiURL = this.properties.doiURL;
this.updateUrl(data.envSpecific.baseLink+this._router.url);
});
@ -128,6 +131,18 @@ export class PublicationComponent {
}
}
private getOpenCitations(id: string) {
this._publicationService.getOpenCitations(this.articleId, this.properties).subscribe(
data => {
console.info("OpenCitations: "+data[0]);
this.publicationInfo.openCitations = data[1];
},
err => {
console.log(err);
}
);
}
private getPublicationInfo(id:string) {
this.warningMessage = '';
this.errorMessage=""
@ -139,6 +154,10 @@ export class PublicationComponent {
data => {
this.publicationInfo = data;
if((this.properties.environment == "beta") && (typeof document !== 'undefined')) {
this.getOpenCitations(this.articleId);
}
// this.result = []
// this.result = {id: id, type :"dataset", source : "openaire", title: this.publicationInfo.title,url: '', result: '', accessRights: this.publicationInfo.bestaccessright, embargoEndDate: ''};
/*if(this.publicationInfo.title.name != undefined && this.publicationInfo.title.name!= ''){
@ -260,6 +279,10 @@ export class PublicationComponent {
this.bioentitiesPage = $event.value;
}
public updateOpenCitationsPage($event) {
this.openCitationsPage = $event.value;
}
public keysToArray(bioentities: Map<string, string>) : string[] {
let keys: string[] = [];
bioentities.forEach(function (value, key, map) {

View File

@ -354,4 +354,55 @@ export class PublicationService {
}
return references;
}
getOpenCitations(id: string, properties:EnvProperties) {
//https://services.openaire.eu/opencitations/getCitations?id=doajarticles::2634200c24772ee8f10232d3e184ec65
let url = /*properties.searchAPIURLLAst*/ "https://services.openaire.eu/opencitations/getCitations?id=" + id;
let key = url;
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.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; i<length; i++) {
openCitation = Array.isArray(openCitations) ? openCitations[i] : openCitations;
let citation: {"url": string, "title": string, "year": string, "doi": string, "authors": string[]} = {"url": "", "title": "", "year": "", "doi": "", "authors": []};
citation.url = openCitation.id;
citation.title = openCitation.title;
//citation.type = openCitation.type;
citation.year = (openCitation.pubDate && (openCitation.pubDate).indexOf('-') !== -1)?openCitation.pubDate.split('-')[0]:openCitation.pubDate;
citation.doi = openCitation.doi;
let authorsLength = Array.isArray(openCitation.authors) ? openCitation.authors.length : 1;
for(let i=0; i<authorsLength; i++) {
let author = Array.isArray(openCitation.authors) ? openCitation.authors[i] : openCitation.authors;
let lastFirstName: string = "";
if(author.lastName) {
lastFirstName = author.lastName;
}
if(author.lastName && author.firstName) {
lastFirstName += ", ";
}
if(author.firstName) {
lastFirstName += author.firstName;
}
if(lastFirstName) {
citation.authors.push(lastFirstName);
}
}
citations.push(citation);
}
return citations;
}
}

View File

@ -58,5 +58,8 @@ export class PublicationInfo {
references: { "name": string, "url": string}[];
contexts: { "labelContext": string, "labelCategory": string, "labelConcept": string, "inline": boolean}[];
organizations: {"name": string, "shortname":string, "id": string, "websiteUrl": string, "country": string, "trust": number}[];
openCitations: {"url": string, "title": string, "year": string, "doi": string, "authors": string[]}[];
record;
}