[Trunk|Library]:

1. [new] #4216: Create component for 'Other Versions' (deleted by inference) in research results (currently available only in Publication Landing Page).
2. publicationInfo.ts: Add field 'deletedByInferenceIds' (will be removed later possibly).
3. env-properties.json: change environment to 'development' and search service to 'rudie' local development machine.
4. publication.component: Add 'Other Versions' tab (section).
5. tabResult.component.html: Changes in css style and sequence of details in tab results according to search results.


git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@54962 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
konstantina.galouni 2019-03-05 09:45:42 +00:00
parent ac0c8181e3
commit 780c5c15bd
10 changed files with 486 additions and 32 deletions

View File

@ -0,0 +1,185 @@
import {Component, ViewChild} from '@angular/core';
import {ElementRef, Input} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {Observable} from 'rxjs/Observable';
import {EnvProperties} from '../../../utils/properties/env-properties';
import {DeletedByInferenceResult} from '../../../utils/entities/deletedByInferenceResult';
import {RouterHelper} from '../../../utils/routerHelper.class';
import {ErrorCodes} from '../../../utils/properties/errorCodes';
import {DeletedByInferenceService} from './deletedByInference.service';
//import {zip} from 'rxjs';
import 'rxjs/add/observable/zip';
@Component({
selector: 'deletedByInference',
template: `
<errorMessages [status]="[status]" [type]="type" tab_error_class=true></errorMessages>
<div>
<div *ngIf="results.length > pageSize" class="uk-margin-bottom">
<span class="uk-h6">{{results.length | number}} {{type}}, page {{page | number}} of {{totalPages(results.length) | number}}</span>
<paging-no-load class="uk-float-right" [currentPage]="page" [totalResults]="results.length" [size]="pageSize" (pageChange)="updatePage($event)"></paging-no-load>
</div>
<ul class="uk-list uk-list-divider uk-margin">
<li *ngFor="let result of results.slice((page-1)*pageSize, page*pageSize)">
<h5 *ngIf="result.title" class="uk-margin-remove-bottom">
<span [innerHTML]="result.title"></span>
</h5>
<h5 *ngIf="!result.title">
<span>[no title available]</span>
</h5>
<span *ngIf="result.types && result.types.length > 0"class="uk-label custom-label label-blue label-publication" title="Type">{{result.types.join(", ")}}</span>
<span *ngIf="result.languages && result.languages.length > 0" class="uk-label custom-label label-language " title="Language">{{result.languages.join(", ")}}</span>
<span *ngIf="result.countries && result.countries.length > 0" class="uk-label custom-label label-country " title="Country">{{result.countries.join(", ")}}</span>
<span *ngIf="result.accessMode" [class]="'uk-label custom-label label-'+ result.accessMode " title="Access Mode">{{result.accessMode}}</span>
<div>
<showAuthors [authors]="result.authors"></showAuthors>
<span *ngIf="result.date != ''">({{result.date}})</span>
</div>
<div *ngIf="result.identifiers && result.identifiers.size > 0">
<showIdentifiers [identifiers]="result.identifiers"></showIdentifiers>
</div>
<div *ngIf="result['fundedByProjects'] != undefined">
<span class="uk-text-bold"> Project: </span>
<span *ngFor="let project of result['fundedByProjects'].slice(0,15) let i=index">
{{project['funderShortname']?project['funderShortname']:project['funderName']}}
| {{ project['acronym']?project['acronym']:(project['title'].length>25?project['title'].substring(0,25)+'...':project['title'])}} ({{project.code}})<span
*ngIf="!project.id">{{project['funderShortname']?project['funderShortname']:project['funderName']}}<span
*ngIf="project['acronym'] || project['title']"> | {{ project['acronym']?project['acronym']:(project['title'].length>25?project['title'].substring(0,25)+'...':project['title'])}}</span><span
*ngIf="project.code">({{project.code}})</span></span><span
*ngIf="i < result['fundedByProjects'].length-1">,</span>
</span>
<span *ngIf="result['fundedByProjects'].length > 15">...</span>
</div>
<!--div class="uk-margin-top" *ngIf="result.hostedBy_collectedFrom && result.hostedBy_collectedFrom.length > 0">
<availableOn [availableOn]="result.hostedBy_collectedFrom"></availableOn>
</div-->
<div *ngIf="result.hostedBy_collectedFrom != undefined">
<span class="uk-text-bold"> Collected From: </span>
<span *ngFor="let available of result.hostedBy_collectedFrom let i=index">
<span *ngIf="available.downloadUrl.length > 1"
class="custom-external custom-icon">
{{available.downloadName}}
<span *ngFor="let url of available.downloadUrl; let i=index;">
<a href="{{url}}" target="_blank"
attr.uk-tooltip="pos:right; delay:10">
[{{(i+1) | number}}]
</a>
</span>
</span><a
class="custom-external custom-icon"
*ngIf="available['downloadUrl'].length == 1"
href="{{available['downloadUrl']}}"
target="_blank"
attr.uk-tooltip="pos:right; delay:10">
{{available.downloadName}}</a><span
*ngIf="i < result['hostedBy_collectedFrom'].length-1">,</span>
</span>
<span *ngIf="result['hostedBy_collectedFrom'].length > 15">...</span>
</div>
<div *ngIf="result.description" class="uk-margin-bottom uk-text-justify descriptionText">
{{result.description}}
</div>
</li>
</ul>
</div>
`
})
export class DeletedByInferenceComponent {
public results: DeletedByInferenceResult[] = [];
@Input() id: string;
@Input() ids: string[] = [];
@Input() type: string;
// Custom tab paging variables
public page: number = 1;
public pageSize: number = 10;
public status: number;
public routerHelper:RouterHelper = new RouterHelper();
public errorCodes:ErrorCodes = new ErrorCodes();
sub: any;
properties:EnvProperties;
constructor ( private element: ElementRef,
private _deletedByInferenceService: DeletedByInferenceService,
private route: ActivatedRoute,
private _router: Router) {
}
ngOnInit() {
this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
});
this.sub = this.route.queryParams.subscribe(data => {
this.errorCodes = new ErrorCodes();
this.status = this.errorCodes.LOADING;
this.getDeletedByInference();
});
}
ngOnDestroy() {}
getDeletedByInference() {
this.results = [];
this.status = this.errorCodes.LOADING;
if(this.ids) {
var allRequests = [];
for(let id of this.ids) {
allRequests.push(this._deletedByInferenceService.getDeletedByInferencePublications(id, this.properties));
}
Observable.zip.apply(null, allRequests).subscribe(
// this._deletedByInferenceService.getDeletedByInferencePublications(id, this.properties).subscribe(
data => {
this.results = data;
this.status = this.errorCodes.DONE;
},
error => {
if(error.status == '404') {
this.status = this.errorCodes.NOT_FOUND;
} else if(error.status == '500') {
this.status = this.errorCodes.ERROR;
} else {
this.status = this.errorCodes.NOT_AVAILABLE;
}
}
);
}
}
public totalPages(totalResults: number): number {
let totalPages:any = totalResults/this.pageSize;
if(!(Number.isInteger(totalPages))) {
totalPages = (parseInt(totalPages, this.pageSize) + 1);
}
return totalPages;
}
public updatePage($event) {
this.page = $event.value;
}
}

View File

@ -0,0 +1,31 @@
/* This module contains all common components for all landing pages */
import { NgModule} from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { DeletedByInferenceComponent } from './deletedByInference.component';
import { DeletedByInferenceService } from './deletedByInference.service';
import {ResultLandingModule} from '../resultLanding.module';
import {PagingModule} from '../../../utils/paging.module';
import {ErrorMessagesModule} from '../../../utils/errorMessages.module';
@NgModule({
imports: [
CommonModule, FormsModule, ResultLandingModule,
PagingModule, ErrorMessagesModule
],
declarations: [
DeletedByInferenceComponent
],
providers:[
DeletedByInferenceService
],
exports: [
DeletedByInferenceComponent
]
})
export class DeletedByInferenceModule { }

View File

@ -0,0 +1,165 @@
import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import {DeletedByInferenceResult} from '../../../utils/entities/deletedByInferenceResult';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import 'rxjs/add/operator/map';
import{EnvProperties} from '../../../utils/properties/env-properties';
import { ParsingFunctions } from '../parsingFunctions.class';
@Injectable()
export class DeletedByInferenceService {
private sizeOfDescription: number = 270;
constructor(private http: Http ) {
this.parsingFunctions = new ParsingFunctions();
}
public parsingFunctions: ParsingFunctions;
getDeletedByInferencePublications (id: string, properties:EnvProperties):any {
let url = properties.searchAPIURLLAst + 'deletedByInferencePublications/' +id+"?format=json";
let key = url;
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => res['result']['metadata']['oaf:entity'])
.map(res => this.parseDeletedByInferencePublications(res));
}
parseDeletedByInferencePublications (result: any): DeletedByInferenceResult {
/*title, authors, abstract, List of projects, PIDs,
collectedfrom (link pointing to the download url), access rights*/
//let publications: DeletedByInferenceResult[] = [];
//if(results) {
let publication : DeletedByInferenceResult;
//let length = Array.isArray(results) ? results.length : 1;
//for(let i=0; i<length; i++) {
//var result = Array.isArray(results) ? results[i] : results;
publication = new DeletedByInferenceResult();
if(result) {
if(result['oaf:result']) {
let data = result['oaf:result'];
var date:string = (data.dateofacceptance)+""; // transform to string in case it is an integer
publication.date = (date && (date).indexOf('-') !== -1)?date.split('-')[0]:date;
publication.dateofacceptance = data.dateofacceptance;
publication.embargoEndDate = data.embargoenddate;
if(!Array.isArray(data.description)) {
publication.description = data.description;
} else {
publication.description = data.description[0];
}
if(publication.description && publication.description.length > this.sizeOfDescription) {
publication.description = publication.description.substring(0, this.sizeOfDescription) + "...";
}
if(data['bestaccessright'] && data['bestaccessright'].hasOwnProperty("classid")) {
publication.accessMode = data['bestaccessright'].classid;
}
}
if(result['oaf:result'] && result['oaf:result']['title']) {
let title = result['oaf:result']['title'];
if(Array.isArray(title)) {
publication.title = title[0].content;
} else {
publication.title = title.content;
}
}
if(result['oaf:result'] && result['oaf:result']['language']) {
publication.languages = this.parsingFunctions.parseLanguages(result['oaf:result']['language']);
}
if(result['oaf:result'] && result['oaf:result']['country']) {
publication.countries = this.parsingFunctions.parseCountries(result['oaf:result']['country']);
}
if(result['oaf:result'] && result['oaf:result']['rels'] && result['oaf:result']['rels']['rel']) {
let relation;
let length = Array.isArray(result['oaf:result']['rels']['rel']) ? result['oaf:result']['rels']['rel'].length : 1;
for(let i=0; i<length; i++) {
relation = Array.isArray(result['oaf:result']['rels']['rel']) ? result['oaf:result']['rels']['rel'][i] : result['oaf:result']['rels']['rel'];
if(relation.hasOwnProperty("to")) {
if(relation['to'].class == "isProducedBy") {
publication.fundedByProjects = this.parsingFunctions.parseFundingByProjects(publication.fundedByProjects, relation, publication.projectsProvenanceVocabulary);
}
}
}
}
if(result['oaf:result'] && result['oaf:result']['children']) {
let children = result['oaf:result']['children'];
if(children.hasOwnProperty("instance")) {
publication.types = new Array<string>();
let types = new Set<string>();
publication.hostedBy_collectedFrom = new Array<{"downloadName": string, "downloadUrl": string[], "collectedName": string, "collectedId": string, "accessMode": string[], "bestAccessMode": string, "type": string, "year":string}>();
let counter = 0;
let instance;
let length = Array.isArray(children['instance']) ? children['instance'].length : 1;
for(let i=0; i<length; i++) {
instance = Array.isArray(children['instance']) ? children['instance'][i] : children['instance'];
this.parsingFunctions.parseTypes(publication.types, types, instance);
if(instance.hasOwnProperty("webresource")) {
let url;
if(!Array.isArray(instance['webresource'])) {
url = instance['webresource'].url;
} else{
url = instance['webresource'][0].url;
}
if(instance.hasOwnProperty("hostedby")) {
counter = this.parsingFunctions.parseHostedBy_collectedFrom(publication.hostedBy_collectedFrom, instance, result['oaf:result'], url, counter, publication.accessMode);
}
}
}
}
}
if(result['oaf:result'] && result['oaf:result']['pid']) {
publication.identifiers = this.parsingFunctions.parseIdentifiers(result['oaf:result']['pid']);
}
if(result['oaf:result'] && result['oaf:result']['creator']) {
if(publication.authors == undefined) {
publication.authors = new Array<string>();
}
let authors = result['oaf:result']['creator'];
let length = Array.isArray(authors) ? authors.length : 1;
for(let i=0; i<length; i++) {
let author = Array.isArray(authors) ? authors[i] : authors;
publication.authors[author.rank] = author.content;
}
publication.authors = publication.authors.filter(function (item) {
return (item != undefined);
});
}
//}
//publications.push(publication);
//}
}
return publication;
}
}

View File

@ -317,7 +317,7 @@
</div>
</li>
<li *ngIf="publicationInfo.openCitations && publicationInfo.openCitations.length > 0">
<li (click)="activeTab='Other Citations'" *ngIf="publicationInfo.openCitations && publicationInfo.openCitations.length > 0">
<a class="uk-accordion-title" href="#">
Open Citations
({{publicationInfo.openCitations.length | number}})
@ -390,7 +390,17 @@
[url]=downloadsFrameUrl width="100%" height="250">
</i-frame>
</div>
</li>
</li>
<li (click)="activeTab='Other Versions'" *ngIf="properties.environment == 'development' && publicationInfo.deletedByInferenceIds">
<a class="uk-accordion-title" href="#">
Other Versions
({{publicationInfo.deletedByInferenceIds.length | number}})
</a>
<div *ngIf="activeTab=='Other Versions'" class="uk-accordion-content">
<deletedByInference [id]="articleId" [ids]="publicationInfo.deletedByInferenceIds" [type]="'publications'"></deletedByInference>
</div>
</li>
</ul>
</div>

View File

@ -152,7 +152,7 @@ export class PublicationComponent {
data => {
this.publicationInfo = data;
if((this.properties.environment == "beta") && (typeof document !== 'undefined')) {
if((this.properties.environment == "beta" || this.properties.environment == "development") && (typeof document !== 'undefined')) {
this.getOpenCitations(this.articleId);
}

View File

@ -22,12 +22,14 @@ import {PublicationComponent} from './publication.component';
import {Schema2jsonldModule} from '../../sharedComponents/schema2jsonld/schema2jsonld.module';
import { SEOServiceModule } from '../../sharedComponents/SEO/SEOService.module';
import {DeletedByInferenceModule} from '../landing-utils/deletedByInference/deletedByInference.module';
@NgModule({
imports: [
CommonModule, FormsModule, LandingModule, SharedModule, RouterModule,
CiteThisModule, PagingModule, ResultLandingModule, IFrameModule,
MetricsModule, AltMetricsModule, ConfigurationServiceModule, Schema2jsonldModule, SEOServiceModule
MetricsModule, AltMetricsModule, ConfigurationServiceModule, Schema2jsonldModule, SEOServiceModule,
DeletedByInferenceModule
],
declarations: [
PublicationComponent

View File

@ -3,6 +3,7 @@ import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import {PublicationInfo} from '../../utils/entities/publicationInfo';
import {DeletedByInferenceResult} from '../../utils/entities/deletedByInferenceResult';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
@ -29,22 +30,22 @@ export class PublicationService {
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'], res])
.map(res => [ res[1]['oaf:result'],
res[1]['oaf:result']['title'],
res[1]['oaf:result']['rels']['rel'],
res[1]['oaf:result']['children'],
res[1]['oaf:result']['pid'],
res[1]['oaf:result']['journal'],
res[1]['oaf:result']['language'],
res[1]['oaf:result']['subject'],
res[1]['oaf:result']['bestaccessright'],
res[1]['oaf:result']['collectedfrom'],
(res[1]['extraInfo']!= undefined && res[1]['extraInfo']['citations']!= undefined)? res[1]['extraInfo']['citations']['citation']:null,
res[1]['oaf:result']['context'],
res[0],
res[1]['oaf:result']['creator'],
res[2],
res[1]['oaf:result']['country'],
.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']['journal'], //5
res[1]['oaf:result']['language'], //6
res[1]['oaf:result']['subject'], //7
res[1]['oaf:result']['bestaccessright'], //8
res[1]['oaf:result']['collectedfrom'], //9
(res[1]['extraInfo']!= undefined && res[1]['extraInfo']['citations']!= undefined)? res[1]['extraInfo']['citations']['citation']:null, //10
res[1]['oaf:result']['context'], //11
res[0], //12
res[1]['oaf:result']['creator'], //13
res[2], //14
res[1]['oaf:result']['country'] //15
])
.map(res => this.parsePublicationInfo(res));
}
@ -125,6 +126,17 @@ export class PublicationService {
}
if(data[3] != null) {
if(data[3].hasOwnProperty("result")) {
this.publicationInfo.deletedByInferenceIds = [];
let length = Array.isArray(data[3]['result']) ? data[3]['result'].length : 1;
for(let i=0; i<length; i++) {
let result = Array.isArray(data[3]['result']) ? data[3]['result'][i] : data[3]['result'];
this.publicationInfo.deletedByInferenceIds.push(result.objidentifier);
}
}
if(data[3].hasOwnProperty("instance")) {
//this.publicationInfo.collectedFrom = new Array<{"name": string, "id": string}>();
//this.publicationInfo.downloadFrom = new Map<string, {"url": string[], "accessMode": string[], "bestAccessMode": string}>();

View File

@ -28,18 +28,6 @@
</p>
</h5>
<div>
<span *ngIf="result['authors'] != undefined">
<span *ngFor="let author of result['authors'].slice(0,15)">
{{author}};
</span>
<span *ngIf="result['authors'].length > 15">...</span>
</span>
<span *ngIf="result.year != undefined && result.year != ''">
({{result.year}})
</span>
</div>
<span *ngIf="result.types && result.types.length > 0" [class]="'uk-label custom-label label-blue label-'+result.entityType" title="Type">{{result.types.join(", ")}}</span>
<span *ngIf="result.programmingLanguages && result.programmingLanguages.length > 0" class="uk-label custom-label label-progrLanguage " title="Programming Language">{{result.programmingLanguages.join(", ")}}</span>
<span *ngIf="result.languages && result.languages.length > 0" class="uk-label custom-label label-language " title="Language">{{result.languages.join(", ")}}</span>
@ -57,6 +45,18 @@
<span *ngIf="result['compatibility'] != undefined && result['compatibility'] != ''" class="uk-label custom-label label-compatibility" title="Compatibility">{{result.compatibility}}</span>
<span *ngIf="result.country != undefined && result.country != ''" class="uk-label custom-label label-country" title="Country"> {{result.country}}</span>
<div class="uk-margin-small">
<span *ngIf="result['authors'] != undefined" class="resultsAuthors uk-margin-small-top" style="font-style: italic;">
<span *ngFor="let author of result['authors'].slice(0,15)">
{{author}};
</span>
<span *ngIf="result['authors'].length > 15">...</span>
</span>
<span *ngIf="result.year != undefined && result.year != ''">
({{result.year}})
</span>
</div>
<div *ngIf="result['projects'] != undefined">
<span> Project: </span>
<span *ngFor="let project of result['projects'].slice(0,15) let i=index">

View File

@ -0,0 +1,47 @@
/*title, authors, abstract, List of projects, PIDs,
collectedfrom (link pointing to the download url), access rights*/
export class DeletedByInferenceResult {
title: string;
accessMode: string;
authors: string[];
date: string;
dateofacceptance: string;
embargoEndDate: string;
types: string[];
hostedBy_collectedFrom: {"downloadName": string, "downloadUrl": string[], "collectedName": string, "collectedId": string, "accessMode": string[], "bestAccessMode": string, "type": string, "year":string}[];
//collectedFrom: {"downloadName": string, "downloadUrl": string[]};
identifiers: Map<string, string[]>; //key is the classname
//publisher: string;
//journal: {"journal": string, "issn": string, "lissn": string, "eissn": string, "issue": string, "volume": string, "start_page": string, "end_page": string};
languages: string[];
countries: string[];
description: string;
projectsProvenanceVocabulary: { "sysimport:crosswalk:repository": string,
"sysimport:crosswalk:entityregistry": string,
"sysimport:crosswalk:datasetarchive": string,
"iis": string,
"sysimport:mining:repository": string,
"user:claim:pid": string,
"user:claim:search": string,
"user:claim:datacite": string
} = {
"sysimport:crosswalk:repository": "Repository",
"sysimport:crosswalk:entityregistry": "Repository",
"sysimport:crosswalk:datasetarchive": "Repository",
"iis": "OpenAIRE",
"sysimport:mining:repository": "OpenAIRE",
"user:claim:pid": "User",
"user:claim:search": "User",
"user:claim:datacite": "User"
};
fundedByProjects: { "id": string, "acronym": string, "title": string,
"funderShortname": string, "funderName": string,
"funding": string, "code": string, "provenanceAction": string,
"inline": boolean}[];
}

View File

@ -62,4 +62,6 @@ export class PublicationInfo {
openCitations: {"url": string, "title": string, "year": string, "doi": string, "authors": string[]}[];
record;
deletedByInferenceIds: string[];
}