Replace meta service import and use with meta and title from angular/platform-browser for user, publication, claimAdmin,claimsByToken, directLinking, linkingGeneric, myClaims, depositBySubject, depositBySubjectResult, deposit, depositResult, dataProvider, htmlProjectReport, organization, project, software, search, advancedSearchPage, searchPage and searchPageTableView component
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@51835 d315682c-612b-4755-9ff5-7f18f6832af3
2018-04-17 15:00:23 +02:00
import { Component , ViewChild } from '@angular/core' ;
import { ElementRef , Input } from '@angular/core' ;
import { ActivatedRoute , Router } from '@angular/router' ;
import { Title , Meta } from '@angular/platform-browser' ;
2017-12-19 13:53:46 +01:00
Replace meta service import and use with meta and title from angular/platform-browser for user, publication, claimAdmin,claimsByToken, directLinking, linkingGeneric, myClaims, depositBySubject, depositBySubjectResult, deposit, depositResult, dataProvider, htmlProjectReport, organization, project, software, search, advancedSearchPage, searchPage and searchPageTableView component
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@51835 d315682c-612b-4755-9ff5-7f18f6832af3
2018-04-17 15:00:23 +02:00
import { Observable } from 'rxjs/Observable' ;
2017-12-19 13:53:46 +01:00
Replace meta service import and use with meta and title from angular/platform-browser for user, publication, claimAdmin,claimsByToken, directLinking, linkingGeneric, myClaims, depositBySubject, depositBySubjectResult, deposit, depositResult, dataProvider, htmlProjectReport, organization, project, software, search, advancedSearchPage, searchPage and searchPageTableView component
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@51835 d315682c-612b-4755-9ff5-7f18f6832af3
2018-04-17 15:00:23 +02:00
import { EnvProperties } from '../../utils/properties/env-properties' ;
import { PublicationInfo } from '../../utils/entities/publicationInfo' ;
import { RouterHelper } from '../../utils/routerHelper.class' ;
import { PiwikService } from '../../utils/piwik/piwik.service' ;
import { PublicationService } from './publication.service' ;
2018-11-14 11:38:53 +01:00
import { SEOService } from '../../sharedComponents/SEO/SEO.service' ;
2017-12-19 13:53:46 +01:00
@Component ( {
selector : 'publication' ,
templateUrl : 'publication.component.html' ,
} )
export class PublicationComponent {
2018-04-11 10:59:01 +02:00
@Input ( ) piwikSiteId = null ;
2017-12-19 13:53:46 +01:00
public publicationInfo : PublicationInfo ;
public articleId : string ;
// APP BOX variables
public showAllCollectedFrom : boolean = false ;
public showAllDownloadFrom : boolean = false ;
// Metrics tab variables
public metricsClicked : boolean ;
public viewsFrameUrl : string ;
public downloadsFrameUrl : string ;
public totalViews : number ;
public totalDownloads : number ;
public pageViews : number ;
// Custom tab paging variables
public referencesPage : number = 1 ;
public organizationsPage : number = 1 ;
public softwarePage : number = 1 ;
public bioentitiesPage : number = 1 ;
2018-12-17 12:03:46 +01:00
public openCitationsPage : number = 1 ;
2017-12-19 13:53:46 +01:00
public pageSize : number = 10 ;
/ *
public startt : number = 0 ;
public stopp : number = 0 ;
* /
// Active tab variable for responsiveness
public activeTab : string = "References" ;
// Map counting variables
public bioentitiesNum : number = 0 ;
public relatedResearchResultsNum : number = 0 ;
// Message variables
public warningMessage = "" ;
public errorMessage = "" ;
public showLoading : boolean = true ;
public routerHelper :RouterHelper = new RouterHelper ( ) ;
private doi : string ;
2018-12-17 12:03:46 +01:00
public doiURL : string ;
2017-12-19 13:53:46 +01:00
private result ;
sub : any ; piwiksub : any ; infoSub : any ;
2018-02-05 14:14:59 +01:00
properties :EnvProperties ;
2017-12-19 13:53:46 +01:00
constructor ( private element : ElementRef ,
private _publicationService : PublicationService ,
private _piwikService :PiwikService ,
Replace meta service import and use with meta and title from angular/platform-browser for user, publication, claimAdmin,claimsByToken, directLinking, linkingGeneric, myClaims, depositBySubject, depositBySubjectResult, deposit, depositResult, dataProvider, htmlProjectReport, organization, project, software, search, advancedSearchPage, searchPage and searchPageTableView component
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@51835 d315682c-612b-4755-9ff5-7f18f6832af3
2018-04-17 15:00:23 +02:00
private route : ActivatedRoute ,
private _meta : Meta ,
private _title : Title ,
2018-11-14 11:38:53 +01:00
private _router : Router ,
private seoService : SEOService ) {
2017-12-19 13:53:46 +01:00
}
ngOnInit() {
2018-02-05 14:14:59 +01:00
this . route . data
. subscribe ( ( data : { envSpecific : EnvProperties } ) = > {
this . properties = data . envSpecific ;
2018-12-17 12:03:46 +01:00
this . doiURL = this . properties . doiURL ;
2018-02-05 14:14:59 +01:00
this . updateUrl ( data . envSpecific . baseLink + this . _router . url ) ;
} ) ;
2017-12-19 13:53:46 +01:00
this . sub = this . route . queryParams . subscribe ( data = > {
this . publicationInfo = null ;
this . updateTitle ( "Publication" ) ;
2019-02-08 13:19:26 +01:00
this . updateDescription ( "" ) ;
2019-02-11 16:03:38 +01:00
this . seoService . createLinkForCanonicalURL ( this . properties . baseLink + this . _router . url ) ;
2017-12-19 13:53:46 +01:00
this . articleId = data [ 'articleId' ] ;
this . metricsClicked = false ;
if ( this . articleId ) {
this . getPublicationInfo ( this . articleId ) ;
// if (typeof document !== 'undefined') {
// switcher(UIkit);
// }
} else {
this . showLoading = false ;
this . warningMessage = "No valid publication id" ;
}
2018-02-05 14:14:59 +01:00
this . viewsFrameUrl = this . properties . framesAPIURL + 'merge.php?com=query&data=[{"query":"resRepoViews", "resTitle":"' + this . articleId + '", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":["Monthly views"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column"]&stacking=normal&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false' ;
2017-12-19 13:53:46 +01:00
2018-02-05 14:14:59 +01:00
this . downloadsFrameUrl = this . properties . framesAPIURL + 'merge.php?com=query&data=[{"query":"resRepoDownloads", "resTitle":"' + this . articleId + '", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":["Monthly downloads"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column"]&stacking=normal&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false' ;
2017-12-19 13:53:46 +01:00
if ( typeof document !== 'undefined' ) {
this . element . nativeElement . scrollIntoView ( ) ;
}
} ) ;
}
ngOnDestroy() {
2018-09-05 14:37:47 +02:00
if ( this . sub ) {
this . sub . unsubscribe ( ) ;
}
2017-12-19 13:53:46 +01:00
if ( this . piwiksub ) {
this . piwiksub . unsubscribe ( ) ;
}
if ( this . infoSub ) {
this . infoSub . unsubscribe ( ) ;
}
}
2018-12-17 12:03:46 +01:00
private getOpenCitations ( id : string ) {
this . _publicationService . getOpenCitations ( this . articleId , this . properties ) . subscribe (
data = > {
this . publicationInfo . openCitations = data [ 1 ] ;
} ,
err = > {
2019-02-15 13:50:24 +01:00
//console.log(err);
this . handleError ( "Error getting open citation for publication with id: " + this . articleId , err ) ;
2018-12-17 12:03:46 +01:00
}
) ;
}
2017-12-19 13:53:46 +01:00
private getPublicationInfo ( id :string ) {
this . warningMessage = '' ;
this . errorMessage = ""
this . showLoading = true ;
2018-06-28 16:52:45 +02:00
this . publicationInfo = null ;
2018-07-25 15:18:58 +02:00
2018-02-05 14:14:59 +01:00
this . infoSub = this . _publicationService . getPublicationInfo ( this . articleId , this . properties ) . subscribe (
2017-12-19 13:53:46 +01:00
data = > {
this . publicationInfo = data ;
2019-03-05 10:45:42 +01:00
if ( ( this . properties . environment == "beta" || this . properties . environment == "development" ) && ( typeof document !== 'undefined' ) ) {
2018-12-17 12:03:46 +01:00
this . getOpenCitations ( this . articleId ) ;
}
2017-12-19 13:53:46 +01:00
// this.result = []
// this.result = {id: id, type :"dataset", source : "openaire", title: this.publicationInfo.title,url: '', result: '', accessRights: this.publicationInfo.bestaccessright, embargoEndDate: ''};
2018-06-28 16:52:45 +02:00
/ * i f ( t h i s . p u b l i c a t i o n I n f o . t i t l e . n a m e ! = u n d e f i n e d & & t h i s . p u b l i c a t i o n I n f o . t i t l e . n a m e ! = ' ' ) {
2018-06-01 14:28:49 +02:00
this . updateTitle ( this . publicationInfo . title . name ) ;
this . updateDescription ( "Dataset, search, repositories, open access," + this . publicationInfo . title . name ) ;
2018-06-28 16:52:45 +02:00
} * /
if ( this . publicationInfo . title ) {
this . updateTitle ( this . publicationInfo . title ) ;
2019-02-08 13:19:26 +01:00
this . updateDescription ( ( this . publicationInfo . description ? ( this . publicationInfo . description ) : ( "," + this . publicationInfo . title ) ) ) ;
2018-06-01 14:28:49 +02:00
}
2018-02-05 14:14:59 +01:00
if ( this . properties . enablePiwikTrack && ( typeof document !== 'undefined' ) ) {
2018-06-28 16:52:45 +02:00
this . piwiksub = this . _piwikService . trackView ( this . properties , this . publicationInfo . title /*.name*/ , this . piwikSiteId ) . subscribe ( ) ;
2017-12-19 13:53:46 +01:00
}
let bioentitiesNum = 0 ;
if ( this . publicationInfo . bioentities != undefined ) {
this . publicationInfo . bioentities . forEach ( function ( value , key , map ) {
bioentitiesNum += value . size ;
} ) ;
}
this . bioentitiesNum = bioentitiesNum ;
let relatedResearchResultsNum = 0 ;
if ( this . publicationInfo . relatedResearchResults != undefined ) {
this . publicationInfo . relatedResearchResults . forEach ( function ( value , key , map ) {
relatedResearchResultsNum += value . length ;
} ) ;
}
this . relatedResearchResultsNum = relatedResearchResultsNum ;
2018-06-28 16:52:45 +02:00
this . result = { id : this.articleId , type : "publication" , source : "openaire" , title : this.publicationInfo.title , url : '' , result : '' , accessRights : /*this.publicationInfo.title.accessMode*/ this . publicationInfo . accessMode , embargoEndDate : '' } ;
2017-12-19 13:53:46 +01:00
// this.result.push(result_);
if ( this . publicationInfo . identifiers != undefined && this . publicationInfo . identifiers . has ( 'doi' ) ) {
this . doi = this . publicationInfo . identifiers . get ( 'doi' ) [ 0 ] ;
}
this . showLoading = false ;
if ( this . publicationInfo . references ) {
this . activeTab = "References" ;
} else if ( this . publicationInfo . relatedResearchResults ) {
this . activeTab = "Related Research Results" ;
} else if ( this . publicationInfo . similarResearchResults ) {
this . activeTab = "Similar Research Results" ;
} else if ( this . publicationInfo . organizations ) {
this . activeTab = "Related Organizations" ;
} else if ( this . publicationInfo . bioentities ) {
this . activeTab = "bioentities" ;
} else if ( this . publicationInfo . software ) {
this . activeTab = "Software" ;
} else {
this . activeTab = "Metrics" ;
this . metricsClicked = true ;
}
} ,
err = > {
2019-02-15 13:50:24 +01:00
//console.log(err);
this . handleError ( "Error getting publication for id: " + this . articleId , err ) ;
2017-12-19 13:53:46 +01:00
this . errorMessage = 'No publication found' ;
this . showLoading = false ;
}
) ;
}
public metricsResults ( $event ) {
this . totalViews = $event . totalViews ;
this . totalDownloads = $event . totalDownloads ;
this . pageViews = $event . pageViews ;
}
public buildCurationTooltip() {
let tooltipContent : string = "<div class='uk-margin uk-padding-small'>" ;
tooltipContent += "<h4>Record in preview</h4>" ;
tooltipContent += "<p>Bibliographic record accepted by the system, but not yet processed by <br> OpenAIRE tools for information quality improvement and de-duplication</p>" ;
return tooltipContent += "</div>" ;
}
private updateDescription ( description :string ) {
Replace meta service import and use with meta and title from angular/platform-browser for user, publication, claimAdmin,claimsByToken, directLinking, linkingGeneric, myClaims, depositBySubject, depositBySubjectResult, deposit, depositResult, dataProvider, htmlProjectReport, organization, project, software, search, advancedSearchPage, searchPage and searchPageTableView component
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@51835 d315682c-612b-4755-9ff5-7f18f6832af3
2018-04-17 15:00:23 +02:00
this . _meta . updateTag ( { content :description } , "name='description'" ) ;
this . _meta . updateTag ( { content :description } , "property='og:description'" ) ;
2017-12-19 13:53:46 +01:00
}
private updateTitle ( title :string ) {
var _prefix = "OpenAIRE | " ;
var _title = _prefix + ( ( title . length > 50 ) ? title . substring ( 0 , 50 ) : title ) ;
Replace meta service import and use with meta and title from angular/platform-browser for user, publication, claimAdmin,claimsByToken, directLinking, linkingGeneric, myClaims, depositBySubject, depositBySubjectResult, deposit, depositResult, dataProvider, htmlProjectReport, organization, project, software, search, advancedSearchPage, searchPage and searchPageTableView component
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@51835 d315682c-612b-4755-9ff5-7f18f6832af3
2018-04-17 15:00:23 +02:00
this . _title . setTitle ( title ) ;
this . _meta . updateTag ( { content :title } , "property='og:title'" ) ;
2017-12-19 13:53:46 +01:00
}
private updateUrl ( url :string ) {
Replace meta service import and use with meta and title from angular/platform-browser for user, publication, claimAdmin,claimsByToken, directLinking, linkingGeneric, myClaims, depositBySubject, depositBySubjectResult, deposit, depositResult, dataProvider, htmlProjectReport, organization, project, software, search, advancedSearchPage, searchPage and searchPageTableView component
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@51835 d315682c-612b-4755-9ff5-7f18f6832af3
2018-04-17 15:00:23 +02:00
this . _meta . updateTag ( { content :url } , "property='og:url'" ) ;
2017-12-19 13:53:46 +01:00
}
public totalPages ( totalResults : number ) : number {
let totalPages :any = totalResults / this . pageSize ;
if ( ! ( Number . isInteger ( totalPages ) ) ) {
totalPages = ( parseInt ( totalPages , this . pageSize ) + 1 ) ;
}
return totalPages ;
}
public updateReferencesPage ( $event ) {
this . referencesPage = $event . value ;
}
public updateOrganizationsPage ( $event ) {
this . organizationsPage = $event . value ;
}
public updateSoftwarePage ( $event ) {
this . softwarePage = $event . value ;
}
public updateBioentitiesPage ( $event ) {
this . bioentitiesPage = $event . value ;
}
2018-12-17 12:03:46 +01:00
public updateOpenCitationsPage ( $event ) {
this . openCitationsPage = $event . value ;
}
2017-12-19 13:53:46 +01:00
public keysToArray ( bioentities : Map < string , string > ) : string [ ] {
let keys : string [ ] = [ ] ;
bioentities . forEach ( function ( value , key , map ) {
keys . push ( key ) ;
} ) ;
return keys ;
}
public getKeys ( map ) {
return Array . from ( map . keys ( ) ) ;
}
/ *
start ( i : number , bioentitiesPage : number ) {
let sum = 0 ;
let index = 0 ;
let retValue = 0 ;
let valuesToPage = this . pageSize * bioentitiesPage ;
let valuesToPreviousPage = valuesToPage - this . pageSize ;
if ( bioentitiesPage == 1 ) {
return 0 ;
}
this . publicationInfo . bioentities . forEach ( function ( value , key , map ) {
sum += map . get ( key ) . size ;
if ( index == i ) {
if ( sum <= valuesToPreviousPage ) {
retValue = 0 ;
} else if ( ( sum - map . get ( key ) . size ) >= valuesToPage ) {
retValue = 0 ;
} else {
if ( map . get ( key ) . size < ( sum - valuesToPreviousPage ) ) {
retValue = 0 ;
} else {
retValue = map . get ( key ) . size - ( sum - valuesToPreviousPage ) ;
}
}
}
index ++ ;
} ) ;
this . startt = retValue ;
return retValue ;
}
stop ( i : number , bioentitiesPage : number ) {
let sum = 0 ;
let index = 0 ;
let retValue = 0 ;
let valuesToPage = this . pageSize * bioentitiesPage ;
let valuesToPreviousPage = valuesToPage - this . pageSize ;
this . publicationInfo . bioentities . forEach ( function ( value , key , map ) {
sum += map . get ( key ) . size ;
if ( index == i ) {
if ( sum <= valuesToPreviousPage ) {
retValue = 0 ;
} else if ( ( sum - map . get ( key ) . size ) >= valuesToPage ) {
retValue = 0 ;
} else {
if ( sum < valuesToPage ) {
retValue = map . get ( key ) . size ;
} else {
retValue = map . get ( key ) . size - ( sum - valuesToPage ) ;
}
}
}
index ++ ;
} ) ;
this . stopp = retValue ;
return retValue ;
}
* /
2019-02-15 13:50:24 +01:00
private handleError ( message : string , error ) {
console . error ( "Publication Landing Page: " + message , error ) ;
}
2017-12-19 13:53:46 +01:00
}