Project

General

Profile

1

    
2
import {Component} from '@angular/core';
3
import {Observable}       from 'rxjs/Observable';
4
import {ActivatedRoute, Router} from '@angular/router';
5
import {Location} from '@angular/common';
6
import "rxjs/add/observable/zip";
7
import { EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
8
import { ErrorCodes} from '../openaireLibrary/utils/properties/errorCodes';
9

    
10
import {Properties} from '../utils/properties';
11
import {CommunityService} from "../openaireLibrary/connect/community/community.service";
12
import {CommunitiesService} from "../communities/communities.service";
13
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
14
import {Meta} from '../openaireLibrary/sharedComponents/metaService';
15
import {ConfigurationService} from '../openaireLibrary/utils/configuration/configuration.service';
16
import{ StatisticsService} from '../utils/services/statistics.service';
17
import {StatisticsSummary} from "./statisticsEntities";
18

    
19
@Component({
20
    selector: 'statistics',
21
    templateUrl: 'statistics.component.html',
22
})
23
export class StatisticsComponent {
24
  public piwiksub: any;
25
  public subfunders: any;
26

    
27
  public pageTitle = "OpenAIRE";
28

    
29
  properties:EnvProperties;
30
  public communityId = null;
31
  public communityInfo = null;
32
  public statistics: StatisticsSummary;
33
  charts = null;
34
  constructor (
35
    private route: ActivatedRoute,
36
      private _router: Router,
37
      private location: Location, private _meta: Meta, private _piwikService:PiwikService,
38
      private config: ConfigurationService,
39
      private _communityService:CommunityService, private _communitiesService:CommunitiesService, private _statisticsService: StatisticsService
40
    ) {
41

    
42
          var description = "open access, research, scientific publication, European Commission, EC, FP7, ERC, Horizon 2020, H2020, search, projects ";
43

    
44
          var title = "OpenAIRE";
45

    
46
          this._meta.setTitle(title);
47
          this._meta.updateMeta("description", description);
48
          this._meta.updateProperty("og:description", description);
49
          this._meta.updateProperty("og:title", title);
50
          console.log("Heree " +document.location.hostname);
51

    
52

    
53
  }
54

    
55
  public ngOnInit() {
56
    this.route.data
57
        .subscribe((data: { envSpecific: EnvProperties }) => {
58
           this.properties = data.envSpecific;
59
           var url = data.envSpecific.baseLink+this._router.url
60
           this._meta.updateProperty("og:url", url);
61
           if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
62
             this.piwiksub = this._piwikService.trackView(this.properties, "OpenAIRE").subscribe();
63
           }
64

    
65
          this.route.queryParams.subscribe(
66
            communityId => {
67
                  this.communityId = communityId['communityId'];
68
                  this._statisticsService.getCommunityStatistics(this.properties.statisticsAPIURL+"communities/",this.communityId).subscribe (
69
                    res => {
70
                          this.statistics = res;
71
                          console.log(this.statistics);
72
                    });
73
                    this.createCharts();
74
                });
75
                this._communityService.getCommunity(this.properties.communityAPI+this.communityId).subscribe (
76
                  communityInfo => {
77
                        this.communityInfo = communityInfo;
78
                        console.log(communityInfo);
79
                  });
80
      });
81

    
82
  }
83

    
84

    
85
  public ngOnDestroy() {
86
    if(this.piwiksub){
87
      this.piwiksub.unsubscribe();
88
    }
89

    
90
  }
91
  private createCharts(){
92
     this.charts = {
93
       timelines: {
94
         publications:
95
         {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":"Publications through the years","subtitle":"","xaxistitle":"Year"}&w=90%&h=83%',
96
         load:true},
97
         datasets:
98
         {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%',
99
         load:false},
100
         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%',
101
         load:false}
102
       },
103
       projectPublications: {
104
         columns:
105
         {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":"Publications per project","subtitle":"","xaxistitle":"Project"}&w=90%&h=83%',
106
         load:true},
107
         pie:
108
         {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":"Publications per project","subtitle":"","xaxistitle":"Project"}&w=90%&h=83%',
109
         display:false},
110
         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":"Publications per project","subtitle":"","xaxistitle":"Project"}&w=90%&h=83%',
111
         load:false}
112
       },
113
       projectDatasets: {
114
         columns:
115
         {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":"Research Data per project","subtitle":"","xaxistitle":"Project"}&w=90%&h=83%',
116
         load:true},
117
         pie:
118
         {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":"Research Data project","subtitle":"","xaxistitle":"Project"}&w=90%&h=83%',
119
         load:false},
120
         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":"Research Data per project","subtitle":"","xaxistitle":"Project"}&w=90%&h=83%',
121
         load:false}
122
       },
123
       projectSoftware: {
124
         columns:
125
         {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":"Software per project","subtitle":"","xaxistitle":"Project"}&w=90%&h=83%',
126
         load:true},
127
         pie:
128
         {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":"Software per project","subtitle":"","xaxistitle":"Project"}&w=90%&h=83%',
129
         load:false},
130
         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":"Software per project","subtitle":"","xaxistitle":"Project"}&w=90%&h=83%',
131
         load:false}
132
       }
133

    
134

    
135
    }
136
  }
137

    
138
}
(3-3/5)