2018-03-01 12:45:37 +01:00
import { Component } from '@angular/core' ;
import { Observable } from 'rxjs/Observable' ;
import { ActivatedRoute , Router } from '@angular/router' ;
import { Location } from '@angular/common' ;
import "rxjs/add/observable/zip" ;
import { EnvProperties } from '../openaireLibrary/utils/properties/env-properties' ;
import { ErrorCodes } from '../openaireLibrary/utils/properties/errorCodes' ;
import { Properties } from '../utils/properties' ;
2018-03-07 12:07:19 +01:00
import { CommunityService } from "../openaireLibrary/connect/community/community.service" ;
2018-03-01 12:45:37 +01:00
import { CommunitiesService } from "../communities/communities.service" ;
import { PiwikService } from '../openaireLibrary/utils/piwik/piwik.service' ;
import { Meta } from '../openaireLibrary/sharedComponents/metaService' ;
import { ConfigurationService } from '../openaireLibrary/utils/configuration/configuration.service' ;
import { StatisticsService } from '../utils/services/statistics.service' ;
2018-03-12 12:26:23 +01:00
import { StatisticsSummary } from "./statisticsEntities" ;
2018-03-01 12:45:37 +01:00
@Component ( {
selector : 'statistics' ,
templateUrl : 'statistics.component.html' ,
} )
export class StatisticsComponent {
public piwiksub : any ;
public subfunders : any ;
2018-03-12 12:26:23 +01:00
public pageTitle = "OpenAIRE" ;
2018-03-01 12:45:37 +01:00
properties :EnvProperties ;
public communityId = null ;
public communityInfo = null ;
2018-03-12 12:26:23 +01:00
public statistics : StatisticsSummary ;
2018-03-01 12:45:37 +01:00
charts = null ;
constructor (
private route : ActivatedRoute ,
private _router : Router ,
private location : Location , private _meta : Meta , private _piwikService :PiwikService ,
private config : ConfigurationService ,
private _communityService :CommunityService , private _communitiesService :CommunitiesService , private _statisticsService : StatisticsService
) {
var description = "open access, research, scientific publication, European Commission, EC, FP7, ERC, Horizon 2020, H2020, search, projects " ;
var title = "OpenAIRE" ;
this . _meta . setTitle ( title ) ;
this . _meta . updateMeta ( "description" , description ) ;
this . _meta . updateProperty ( "og:description" , description ) ;
this . _meta . updateProperty ( "og:title" , title ) ;
console . log ( "Heree " + document . location . hostname ) ;
}
public ngOnInit() {
this . route . data
. subscribe ( ( data : { envSpecific : EnvProperties } ) = > {
this . properties = data . envSpecific ;
var url = data . envSpecific . baseLink + this . _router . url
this . _meta . updateProperty ( "og:url" , url ) ;
if ( this . properties . enablePiwikTrack && ( typeof document !== 'undefined' ) ) {
this . piwiksub = this . _piwikService . trackView ( this . properties , "OpenAIRE" ) . subscribe ( ) ;
}
2018-03-01 17:11:31 +01:00
this . route . queryParams . subscribe (
communityId = > {
this . communityId = communityId [ 'communityId' ] ;
2018-03-12 12:26:23 +01:00
this . _statisticsService . getCommunityStatistics ( this . properties . statisticsAPIURL + "communities/" , this . communityId ) . subscribe (
2018-03-01 17:11:31 +01:00
res = > {
this . statistics = res ;
console . log ( this . statistics ) ;
} ) ;
this . createCharts ( ) ;
} ) ;
2018-03-12 17:16:40 +01:00
/* NOT NEEDED ??*/
/ * t h i s . _ c o m m u n i t y S e r v i c e . g e t C o m m u n i t y ( t h i s . p r o p e r t i e s . c o m m u n i t y A P I + t h i s . c o m m u n i t y I d ) . s u b s c r i b e (
2018-03-01 17:11:31 +01:00
communityInfo = > {
this . communityInfo = communityInfo ;
console . log ( communityInfo ) ;
2018-03-12 17:16:40 +01:00
} ) ; * /
2018-03-01 17:11:31 +01:00
} ) ;
2018-03-01 12:45:37 +01:00
}
public ngOnDestroy() {
if ( this . piwiksub ) {
this . piwiksub . unsubscribe ( ) ;
}
}
private createCharts ( ) {
this . charts = {
timelines : {
publications :
2018-03-12 17:16:40 +01:00
{ url : this.properties.statisticsFrameAPIURL + 'chart.php?com=query&persistent=false&data=com=query&data={"query":"comTimelinePubs","comId":"' + this . communityId + '","table":"result","fields":[{"fld":"number","agg":"count","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"year","agg":"avg"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":"-","s":"-","l":"-","ft":"-","wt":"-"},"yaxisheaders":["Publications"],"fieldsheaders":["publications"],"in":[{"f":0,"text":"Yearly"}],"filters":[{"name":"year","max":"2013","min":"2007","to":-1},{"name":"result_projects-project-funding_lvl0","values":["FP7"],"to":"-1"},{"name":"type","values":["publication"],"to":"-1"},{"name":"result_projects-project-funding_lvl2","values":["ERC"],"to":"-1"}],"having":[],"incfilters":[],"inchaving":[],"title":"Timeline of publications through the years","subtitle":"","xaxistitle":"Year"}&w=70%&h=83%' ,
2018-03-01 12:45:37 +01:00
load :true } ,
2018-03-12 22:39:36 +01:00
pubGraph :
{ utl : this.properties.statisticsFrameAPIURL + 'chart.php?com=query&data={"query":"comOAPubs","comId":"' + this . communityId + '","table":"result","fields":[{"fld":"number","agg":"count","type":"pie","yaxis":1,"c":false}],"xaxis":{"name":"bestlicense","agg":"avg"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":"-","s":"-","l":"-","ft":"-","wt":"-"},"order":"d","yaxisheaders":[""],"fieldsheaders":[""],"in":[],"filters":[],"having":[],"incfilters":[],"inchaving":[],"title":"' + this . communityId + ' publications by access mode","subtitle":"","xaxistitle":"","nulls":true}&w=500&h=600' ,
load :false } ,
2018-03-01 12:45:37 +01:00
datasets :
2018-03-01 17:11:31 +01:00
{ url : this.properties.statisticsFrameAPIURL + 'chart.php?com=query&data={"query":"comTimelineData","comId":"' + this . communityId + '","table":"result","fields":[{"fld":"number","agg":"count","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"year","agg":"avg"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":"-","s":"-","l":"-","ft":"-","wt":"-"},"yaxisheaders":["Datasets"],"fieldsheaders":["publications"],"in":[{"f":0,"text":"Yearly"}],"filters":[{"name":"year","max":"2013","min":"2007","to":-1},{"name":"result_projects-project-funding_lvl0","values":["FP7"],"to":"-1"},{"name":"type","values":["publication"],"to":"-1"},{"name":"result_projects-project-funding_lvl2","values":["ERC"],"to":"-1"}],"having":[],"incfilters":[],"inchaving":[],"title":"Research data through the years","subtitle":"","xaxistitle":"Year"}&w=90%&h=83%' ,
2018-03-01 12:45:37 +01:00
load :false } ,
2018-03-12 22:39:36 +01:00
dataGraph :
{ url : this.properties.statisticsFrameAPIURL + 'chart.php?com=query&data={"query":"comOAData","comId":"' + this . communityId + '","table":"result","fields":[{"fld":"number","agg":"count","type":"pie","yaxis":1,"c":false}],"xaxis":{"name":"bestlicense","agg":"avg"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":"-","s":"-","l":"-","ft":"-","wt":"-"},"order":"d","yaxisheaders":[""],"fieldsheaders":[""],"in":[],"filters":[],"having":[],"incfilters":[],"inchaving":[],"title":"' + this . communityId + ' datasets by access mode","subtitle":"","xaxistitle":"","nulls":true}&w=500&h=600' ,
load : false } ,
software :
{ url : this.properties.statisticsFrameAPIURL + 'chart.php?com=query&data={"query":"comTimelineSoft","comId":"' + this . communityId + '","table":"result","fields":[{"fld":"number","agg":"count","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"year","agg":"avg"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":"-","s":"-","l":"-","ft":"-","wt":"-"},"yaxisheaders":["Software"],"fieldsheaders":["publications"],"in":[{"f":0,"text":"Yearly"}],"filters":[{"name":"year","max":"2013","min":"2007","to":-1},{"name":"result_projects-project-funding_lvl0","values":["FP7"],"to":"-1"},{"name":"type","values":["publication"],"to":"-1"},{"name":"result_projects-project-funding_lvl2","values":["ERC"],"to":"-1"}],"having":[],"incfilters":[],"inchaving":[],"title":"Software through the years","subtitle":"","xaxistitle":"Year"}&w=90%&h=83%' ,
load :false } ,
softwareGraph :
{ url : this.properties.statisticsFrameAPIURL + 'chart.php?com=query&data={"query":"comOASoft","comId":"' + this . communityId + '","table":"result","fields":[{"fld":"number","agg":"count","type":"pie","yaxis":1,"c":false}],"xaxis":{"name":"bestlicense","agg":"avg"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":"-","s":"-","l":"-","ft":"-","wt":"-"},"order":"d","yaxisheaders":[""],"fieldsheaders":[""],"in":[],"filters":[],"having":[],"incfilters":[],"inchaving":[],"title":"' + this . communityId + ' software by access mode","subtitle":"","xaxistitle":"","nulls":true}&w=500&h=600' ,
2018-03-01 12:45:37 +01:00
load :false }
} ,
projectPublications : {
columns :
2018-03-12 17:16:40 +01:00
{ url : this.properties.statisticsFrameAPIURL + 'chart.php?com=query&data={"query":"comProjectPubs","comId":"' + this . communityId + '","table":"result","fields":[{"fld":"number","agg":"count","type":"bar","yaxis":1,"c":false}],"xaxis":{"name":"year","agg":"avg"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":"-","s":"-","l":"-","ft":"-","wt":"-"},"yaxisheaders":["Publications"],"fieldsheaders":["publications"],"in":[],"filters":[{"name":"year","max":"2013","min":"2007","to":-1},{"name":"result_projects-project-funding_lvl0","values":["FP7"],"to":"-1"},{"name":"type","values":["publication"],"to":"-1"},{"name":"result_projects-project-funding_lvl2","values":["ERC"],"to":"-1"}],"having":[],"incfilters":[],"inchaving":[],"title":"","subtitle":"","xaxistitle":"Project"}&w=70%&h=83%' ,
2018-03-01 12:45:37 +01:00
load :true } ,
pie :
2018-03-12 17:16:40 +01:00
{ url : this.properties.statisticsFrameAPIURL + 'chart.php?com=query&data={"query":"comProjectPubs","comId":"' + this . communityId + '","table":"result","fields":[{"fld":"number","agg":"count","type":"pie","yaxis":1,"c":false}],"xaxis":{"name":"year","agg":"avg"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":"-","s":"-","l":"-","ft":"-","wt":"-"},"yaxisheaders":["Publications"],"fieldsheaders":["publications"],"in":[],"filters":[{"name":"year","max":"2013","min":"2007","to":-1},{"name":"result_projects-project-funding_lvl0","values":["FP7"],"to":"-1"},{"name":"type","values":["publication"],"to":"-1"},{"name":"result_projects-project-funding_lvl2","values":["ERC"],"to":"-1"}],"having":[],"incfilters":[],"inchaving":[],"title":"","subtitle":"","xaxistitle":"Project"}&w=100%&h=83%' ,
2018-03-01 12:45:37 +01:00
display :false } ,
2018-03-12 17:16:40 +01:00
table : { url : this.properties.statisticsFrameAPIURL + 'gtable.php?com=query&data={"query":"comProjectPubs","comId":"' + this . communityId + '","table":"result","fields":[{"fld":"number","agg":"count","type":"bar","yaxis":1,"c":false}],"xaxis":{"name":"year","agg":"avg"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":"-","s":"-","l":"-","ft":"-","wt":"-"},"yaxisheaders":["Publications"],"fieldsheaders":["publications"],"in":[],"filters":[{"name":"year","max":"2013","min":"2007","to":-1},{"name":"result_projects-project-funding_lvl0","values":["FP7"],"to":"-1"},{"name":"type","values":["publication"],"to":"-1"},{"name":"result_projects-project-funding_lvl2","values":["ERC"],"to":"-1"}],"having":[],"incfilters":[],"inchaving":[],"title":"","subtitle":"","xaxistitle":"Project"}&w=90%&h=83%' ,
2018-03-01 12:45:37 +01:00
load :false }
} ,
projectDatasets : {
columns :
2018-03-12 22:39:36 +01:00
{ url : this.properties.statisticsFrameAPIURL + 'chart.php?com=query&data={"query":"comProjectData","comId":"' + this . communityId + '","table":"result","fields":[{"fld":"number","agg":"count","type":"bar","yaxis":1,"c":false}],"xaxis":{"name":"year","agg":"avg"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":"-","s":"-","l":"-","ft":"-","wt":"-"},"yaxisheaders":["Datasets"],"fieldsheaders":["publications"],"in":[],"filters":[{"name":"year","max":"2013","min":"2007","to":-1},{"name":"result_projects-project-funding_lvl0","values":["FP7"],"to":"-1"},{"name":"type","values":["publication"],"to":"-1"},{"name":"result_projects-project-funding_lvl2","values":["ERC"],"to":"-1"}],"having":[],"incfilters":[],"inchaving":[],"title":"","subtitle":"","xaxistitle":"Project"}&w=90%&h=83%' ,
2018-03-01 12:45:37 +01:00
load :true } ,
pie :
2018-03-12 22:39:36 +01:00
{ url : this.properties.statisticsFrameAPIURL + 'chart.php?com=query&data={"query":"comProjectData","comId":"' + this . communityId + '","table":"result","fields":[{"fld":"number","agg":"count","type":"pie","yaxis":1,"c":false}],"xaxis":{"name":"year","agg":"avg"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":"-","s":"-","l":"-","ft":"-","wt":"-"},"yaxisheaders":["Datasets"],"fieldsheaders":["publications"],"in":[],"filters":[{"name":"year","max":"2013","min":"2007","to":-1},{"name":"result_projects-project-funding_lvl0","values":["FP7"],"to":"-1"},{"name":"type","values":["publication"],"to":"-1"},{"name":"result_projects-project-funding_lvl2","values":["ERC"],"to":"-1"}],"having":[],"incfilters":[],"inchaving":[],"title":"","subtitle":"","xaxistitle":"Project"}&w=90%&h=83%' ,
2018-03-01 12:45:37 +01:00
load :false } ,
2018-03-12 22:39:36 +01:00
table : { url : this.properties.statisticsFrameAPIURL + 'gtable.php?com=query&data={"query":"comProjectData","comId":"' + this . communityId + '","table":"result","fields":[{"fld":"number","agg":"count","type":"bar","yaxis":1,"c":false}],"xaxis":{"name":"year","agg":"avg"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":"-","s":"-","l":"-","ft":"-","wt":"-"},"yaxisheaders":["Datasets"],"fieldsheaders":["publications"],"in":[],"filters":[{"name":"year","max":"2013","min":"2007","to":-1},{"name":"result_projects-project-funding_lvl0","values":["FP7"],"to":"-1"},{"name":"type","values":["publication"],"to":"-1"},{"name":"result_projects-project-funding_lvl2","values":["ERC"],"to":"-1"}],"having":[],"incfilters":[],"inchaving":[],"title":"","subtitle":"","xaxistitle":"Project"}&w=90%&h=83%' ,
2018-03-01 12:45:37 +01:00
load :false }
} ,
projectSoftware : {
columns :
2018-03-12 22:39:36 +01:00
{ url : this.properties.statisticsFrameAPIURL + 'chart.php?com=query&data={"query":"comProjectSoft","comId":"' + this . communityId + '","table":"result","fields":[{"fld":"number","agg":"count","type":"bar","yaxis":1,"c":false}],"xaxis":{"name":"year","agg":"avg"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":"-","s":"-","l":"-","ft":"-","wt":"-"},"yaxisheaders":["Software"],"fieldsheaders":["publications"],"in":[],"filters":[{"name":"year","max":"2013","min":"2007","to":-1},{"name":"result_projects-project-funding_lvl0","values":["FP7"],"to":"-1"},{"name":"type","values":["publication"],"to":"-1"},{"name":"result_projects-project-funding_lvl2","values":["ERC"],"to":"-1"}],"having":[],"incfilters":[],"inchaving":[],"title":"","subtitle":"","xaxistitle":"Project"}' ,
2018-03-01 12:45:37 +01:00
load :true } ,
pie :
2018-03-12 22:39:36 +01:00
{ url : this.properties.statisticsFrameAPIURL + 'chart.php?com=query&data={"query":"comProjectSoft","comId":"' + this . communityId + '","table":"result","fields":[{"fld":"number","agg":"count","type":"pie","yaxis":1,"c":false}],"xaxis":{"name":"year","agg":"avg"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":"-","s":"-","l":"-","ft":"-","wt":"-"},"yaxisheaders":["Software"],"fieldsheaders":["publications"],"in":[],"filters":[{"name":"year","max":"2013","min":"2007","to":-1},{"name":"result_projects-project-funding_lvl0","values":["FP7"],"to":"-1"},{"name":"type","values":["publication"],"to":"-1"},{"name":"result_projects-project-funding_lvl2","values":["ERC"],"to":"-1"}],"having":[],"incfilters":[],"inchaving":[],"title":"","subtitle":"","xaxistitle":"Project"}&w=90%&h=83%' ,
2018-03-01 12:45:37 +01:00
load :false } ,
2018-03-12 22:39:36 +01:00
table : { url : this.properties.statisticsFrameAPIURL + 'gtable.php?com=query&data={"query":"comProjectSoft","comId":"' + this . communityId + '","table":"result","fields":[{"fld":"number","agg":"count","type":"bar","yaxis":1,"c":false}],"xaxis":{"name":"year","agg":"avg"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":"-","s":"-","l":"-","ft":"-","wt":"-"},"yaxisheaders":["Software"],"fieldsheaders":["publications"],"in":[],"filters":[{"name":"year","max":"2013","min":"2007","to":-1},{"name":"result_projects-project-funding_lvl0","values":["FP7"],"to":"-1"},{"name":"type","values":["publication"],"to":"-1"},{"name":"result_projects-project-funding_lvl2","values":["ERC"],"to":"-1"}],"having":[],"incfilters":[],"inchaving":[],"title":"","subtitle":"","xaxistitle":"Project"}&w=90%&h=83%' ,
2018-03-01 12:45:37 +01:00
load :false }
}
}
}
}