164 lines
5.9 KiB
TypeScript
164 lines
5.9 KiB
TypeScript
import {Component, ViewChild} from '@angular/core';
|
|
import {Observable} from 'rxjs/Observable';
|
|
import {PublicationService} from '../../services/publication.service';
|
|
import {PublicationInfo} from '../../utils/entities/publicationInfo';
|
|
import {ActivatedRoute} from '@angular/router';
|
|
import {OpenaireProperties} from '../../utils/properties/openaireProperties';
|
|
import {InlineClaimContextComponent} from '../../claimPages/inlineClaimContext/inlineClaimContext.component';
|
|
import {InlineClaimProjectComponent} from '../../claimPages/inlineClaimProject/inlineClaimProject.component';
|
|
import {InlineClaimResultComponent} from '../../claimPages/inlineClaimResult/inlineClaimResult.component';
|
|
@Component({
|
|
selector: 'publication',
|
|
templateUrl: 'publication.component.html',
|
|
|
|
})
|
|
|
|
export class PublicationComponent {
|
|
constructor (private _publicationService: PublicationService, private route: ActivatedRoute) {
|
|
}
|
|
ngOnInit() {
|
|
this.sub = this.route.queryParams.subscribe(data => {
|
|
this.articleId = data['articleId'];
|
|
console.info("Article id is :"+this.articleId);
|
|
if(this.articleId){
|
|
this.getPublicationInfo(this.articleId);
|
|
}else{
|
|
console.info("Article id not found");
|
|
}
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
ngOnDestroy() {
|
|
this.sub.unsubscribe();
|
|
}
|
|
sub: any;
|
|
articleId: string;
|
|
private publicationInfo: PublicationInfo;
|
|
|
|
private showAllReferences: boolean = false;
|
|
private showAllRelResData: boolean = false;
|
|
private showAllSimilPubl: boolean = false;
|
|
private showAllBioentities: boolean = false;
|
|
private showFundingDetails: boolean = false;
|
|
|
|
private bioentitiesNum: number = 0;
|
|
|
|
private result ;
|
|
|
|
@ViewChild (InlineClaimProjectComponent) inlineClaimProject : InlineClaimProjectComponent ;
|
|
@ViewChild (InlineClaimContextComponent) inlineClaimContext : InlineClaimContextComponent ;
|
|
@ViewChild (InlineClaimResultComponent) inlineClaimResult : InlineClaimResultComponent ;
|
|
|
|
public warningMessage = "";
|
|
public errorMessage = "";
|
|
|
|
getPublicationInfo(id:string) {
|
|
this.warningMessage = '';
|
|
this.errorMessage=""
|
|
if(this.articleId==null || this.articleId==''){
|
|
this.warningMessage="No valid publication id";
|
|
console.info("novalid");
|
|
}else{
|
|
console.info("do request");
|
|
this._publicationService.getPublicationInfo(this.articleId).subscribe(
|
|
data => {
|
|
this.publicationInfo = data;
|
|
|
|
let bioentitiesNum = 0;
|
|
if(this.publicationInfo.bioentities != undefined) {
|
|
this.publicationInfo.bioentities.forEach(function (value, key, map) {
|
|
bioentitiesNum += value.size;
|
|
});
|
|
}
|
|
this.bioentitiesNum = bioentitiesNum;
|
|
|
|
this.result = {id: this.articleId, type :"publication", source : "openaire", title: this.publicationInfo.title,url: '', result: '', accessRights: this.publicationInfo.bestlicense, embargoEndDate: ''};
|
|
// this.result.push(result_);
|
|
},
|
|
err => {
|
|
console.error(err)
|
|
console.info("error");
|
|
|
|
this.errorMessage = 'No publication found';
|
|
}
|
|
);
|
|
}
|
|
}
|
|
|
|
/*
|
|
********* Methods for Inline Claim of project / publication *****
|
|
*/
|
|
toggleClaimProject(){
|
|
this.inlineClaimProject.toggle();
|
|
}
|
|
projectAdded($event){
|
|
var projects =$event.value;
|
|
if(projects){
|
|
for(var i=0; i < projects.length; i++){
|
|
|
|
if(this.publicationInfo.fundedByProjects == undefined) {
|
|
this.publicationInfo.fundedByProjects = new Array<
|
|
{ "url": string, "acronym": string, "title": string,
|
|
"funderShortname": string, "funderName": string,
|
|
"funding": string, "inline": boolean
|
|
}>();
|
|
}
|
|
var project =projects[i];
|
|
|
|
let counter = this.publicationInfo.fundedByProjects.length;
|
|
this.publicationInfo.fundedByProjects[counter] = {
|
|
"url": "", "acronym": "", "title": "",
|
|
"funderShortname": "", "funderName": "",
|
|
"funding": "", "inline": true
|
|
}
|
|
this.publicationInfo.fundedByProjects[counter]['url'] =
|
|
OpenaireProperties.getsearchLinkToProject() + project.projectId;
|
|
this.publicationInfo.fundedByProjects[counter]['acronym'] = project.projectAcronym;
|
|
this.publicationInfo.fundedByProjects[counter]['title'] = project.projectName;
|
|
this.publicationInfo.fundedByProjects[counter]['funderShortname'] = project.funderName;
|
|
}
|
|
}
|
|
}
|
|
toggleClaimContext(){
|
|
this.inlineClaimContext.toggle();
|
|
}
|
|
contextAdded($event){
|
|
var contexts =$event.value;
|
|
if(contexts){
|
|
for(var i=0; i < contexts.length; i++){
|
|
var context = contexts[i];
|
|
if(!this.publicationInfo.contexts){
|
|
this.publicationInfo.contexts = new Array<
|
|
{ "labelContext": string, "labelCategory": string, "labelConcept": string, "inline": boolean}>();
|
|
|
|
}
|
|
var position:number = this.publicationInfo.contexts.length;
|
|
|
|
this.publicationInfo.contexts[ position] = {"labelContext": "", "labelCategory": "", "labelConcept": "", inline: true };
|
|
this.publicationInfo.contexts[position]['labelContext'] = context.community;
|
|
this.publicationInfo.contexts[position]['labelCategory'] = context.category;
|
|
this.publicationInfo.contexts[position]['labelConcept'] = context.concept.label;
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
toggleClaimResult(){
|
|
this.inlineClaimResult.toggle();
|
|
}
|
|
resultsAdded($event, isPublication:boolean){
|
|
var results =$event.value;
|
|
|
|
//TODO
|
|
}
|
|
|
|
showChange($event) {
|
|
this.showAllReferences=$event.value;
|
|
}
|
|
|
|
|
|
}
|