[Trunk|Library]:

1. Other Research Products Landing page: Add 'References' tab. 
2. publication.service & parsingFunctions.class: 
	Move parsing of res['result']['metadata']['oaf:entity']['extraInfo']['citations'] (aka 'References' tab) from publication.service to parsingFunctions file.
3. library.css: Remove 'margin-bottom: 5px;' from 'pseudo-external' class.


git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@54905 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
konstantina.galouni 2019-02-26 12:06:21 +00:00
parent 9627d08570
commit 5a685c160c
7 changed files with 97 additions and 20 deletions

View File

@ -602,4 +602,32 @@ export class ParsingFunctions {
}
return pLanguages;
}
parseReferences(citations: any): {"name": string, "url": string}[] {
let references = new Array<{"name": string, "url": string}>();
let citation;
let length = Array.isArray(citations) ? citations.length : 1;
for(let i=0; i<length; i++) {
citation = Array.isArray(citations) ? citations[i] : citations;
let url;
if(citation.hasOwnProperty("id")) {
let citationId;
let length1 = Array.isArray(citation['id']) ? citation['id'].length : 1;
for(let j=0; j<length1; j++) {
citationId = Array.isArray(citation['id']) ? citation['id'][j] : citation['id'];
if(citationId.type == "pmid") {
url = "http://www.ncbi.nlm.nih.gov/pubmed/"+citationId.value;
}
}
}
references[citation.position-1] = { "name": "", "url": ""};
references[citation.position-1]['name'] = citation.rawText;
references[citation.position-1]['url'] = url;
}
return references;
}
}

View File

@ -46,6 +46,32 @@
</div>
<ul class="custom-accordion" uk-accordion>
<li *ngIf="orpInfo.references" (click)="activeTab='References'">
<a class="uk-accordion-title" href="#">
References ({{orpInfo.references.length | number}})
</a>
<div class="uk-accordion-content">
<div>
<div *ngIf="orpInfo.references.length > pageSize" class="uk-margin-bottom">
<span class="uk-h6">{{orpInfo.references.length | number}} references, page {{referencesPage | number}} of {{totalPages(orpInfo.references.length) | number}}</span>
<paging-no-load class="uk-float-right" [currentPage]="referencesPage" [totalResults]="orpInfo.references.length" [size]="pageSize" (pageChange)="updateReferencesPage($event)"></paging-no-load>
</div>
<div *ngFor="let item of orpInfo.references.slice((referencesPage-1)*pageSize, referencesPage*pageSize)">
<p *ngIf=" item && item['url']"
class="custom-external custom-icon">
<a href="{{item['url']}}" target="_blank">
{{item['name']}}
</a>
</p>
<p *ngIf="!item['url']" class="pseudo-external custom-icon">
{{item['name']}}
</p>
</div>
</div>
</div>
</li>
<li *ngIf="orpInfo.relatedResearchResults" (click)="activeTab='Related Research Results'">
<a class="uk-accordion-title" href="#">
Related Research Results

View File

@ -37,8 +37,12 @@ export class OrpComponent {
public totalDownloads: number;
public pageViews: number;
// Custom tab paging variables
public referencesPage: number = 1;
public pageSize: number = 10;
// Active tab variable for responsiveness
public activeTab: string = "Related Research Results";
public activeTab: string = "References";
// Map counting variable
public relatedResearchResultsNum: number = 0;
@ -186,4 +190,16 @@ export class OrpComponent {
private handleError(message: string, error) {
console.error("Other Research Product Landing Page: "+message, error);
}
public updateReferencesPage($event) {
this.referencesPage = $event.value;
}
public totalPages(totalResults: number): number {
let totalPages:any = totalResults/this.pageSize;
if(!(Number.isInteger(totalPages))) {
totalPages = (parseInt(totalPages, this.pageSize) + 1);
}
return totalPages;
}
}

View File

@ -14,6 +14,7 @@ import {MetricsModule} from '../landing-utils/metrics.module';
import {AltMetricsModule} from '../../utils/altmetrics.module';
import {ConfigurationServiceModule} from '../../utils/configuration/configurationService.module';
import {IFrameModule} from '../../utils/iframe.module';
import {PagingModule} from '../../utils/paging.module';
import {OrpService} from './orp.service';
@ -26,7 +27,7 @@ import { SEOServiceModule } from '../../sharedComponents/SEO/SEOService.module';
@NgModule({
imports: [
CommonModule, FormsModule, SharedModule, RouterModule, LandingModule,
CiteThisModule, ResultLandingModule, MetricsModule, IFrameModule,
CiteThisModule, ResultLandingModule, MetricsModule, IFrameModule, PagingModule,
AltMetricsModule, ConfigurationServiceModule, Schema2jsonldModule, SEOServiceModule
],
declarations: [

View File

@ -26,21 +26,22 @@ export class OrpService {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => [res['result']['header']['dri:status'], res['result']['metadata']['oaf:entity']['oaf:result'],res])
.map(res => [res[1],
res[1]['title'],
res[1]['rels']['rel'],
res[1]['children'],
res[1]['pid'],
res[1]['subject'],
res[1]['bestaccessright'],
res[1]['collectedfrom'],
res[1]['context'],
res[0],
res[1]['creator'],
res[1]['language'],
res[1]['country'],
res[2]
.map(res => [res['result']['header']['dri:status'], res['result']['metadata']['oaf:entity'],res])
.map(res => [res[1]['oaf:result'], //0
res[1]['oaf:result']['title'], //1
res[1]['oaf:result']['rels']['rel'], //2
res[1]['oaf:result']['children'], //3
res[1]['oaf:result']['pid'], //4
res[1]['oaf:result']['subject'], //5
res[1]['oaf:result']['bestaccessright'], //6
res[1]['oaf:result']['collectedfrom'], //7
res[1]['oaf:result']['context'], //8
res[0], //9
res[1]['oaf:result']['creator'], //10
res[1]['oaf:result']['language'], //11
res[1]['oaf:result']['country'], //12
res[2], //13
(res[1]['extraInfo']!= undefined && res[1]['extraInfo']['citations']!= undefined)? res[1]['extraInfo']['citations']['citation']:null //14
]).map(res => this.parseOrpInfo(res));
}
@ -190,6 +191,10 @@ export class OrpService {
this.orpInfo.countries = this.parsingFunctions.parseCountries(data[12]);
}
if(data[14] != null) {
this.orpInfo.references = this.parsingFunctions.parseReferences(data[14]);
}
if(this.orpInfo.relatedResearchResults) {
let self = this;
this.orpInfo.relatedResearchResults.forEach(function (value, key, map) {

View File

@ -216,7 +216,7 @@ export class PublicationService {
this.publicationInfo.title*/);
if(data[10] != null) {
this.publicationInfo.references = this.parseReferences(data[10]);
this.publicationInfo.references = this.parsingFunctions.parseReferences(data[10]);
}
if(data[11] != null) {
@ -325,7 +325,7 @@ export class PublicationService {
return [bioentities, software];
}
/*
parseReferences(citations: any): {"name": string, "url": string}[] {
let references = new Array<{"name": string, "url": string}>();
@ -353,7 +353,7 @@ export class PublicationService {
}
return references;
}
*/
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;

View File

@ -44,5 +44,6 @@ export class OrpInfo {
relatedResearchResults: Map<string, { "name": string, "id": string, "date": string, "percentage": number, "class": string}[]>; // percentage is for trust
similarResearchResults: { "name": string, "id": string, "date": string, "percentage": number, "class": string}[]; // percentage is for similarity
contexts: { "labelContext": string, "labelCategory": string, "labelConcept": string, "inline": boolean}[];
references: { "name": string, "url": string}[];
record;
}