Project

General

Profile

1
import {Component, Input}            from '@angular/core';
2
import {ActivatedRoute, Router}      from '@angular/router';
3
import {Location, TitleCasePipe}     from '@angular/common';
4
import {Title, Meta}                 from '@angular/platform-browser';
5
import {DomSanitizer}                from '@angular/platform-browser';
6
import {SafeResourceUrl, SafeUrl}    from '@angular/platform-browser';
7

    
8
import {Observable}                  from 'rxjs/Observable';
9

    
10
import "rxjs/add/observable/zip";
11

    
12
import {EnvProperties}               from '../openaireLibrary/utils/properties/env-properties';
13
import {ErrorCodes}                  from '../openaireLibrary/utils/properties/errorCodes';
14

    
15
import {StatisticsService}           from '../utils/services/statistics.service';
16

    
17
import {CommunityService}            from "../openaireLibrary/connect/community/community.service";
18
import {CommunitiesService}          from "../openaireLibrary/connect/communities/communities.service";
19
import {ConfigurationService}        from '../openaireLibrary/utils/configuration/configuration.service';
20
import {PiwikService}                from '../openaireLibrary/utils/piwik/piwik.service';
21

    
22
import {ConnectHelper} from '../openaireLibrary/connect/connectHelper';
23
import {availableCharts, availableEntitiesMap, StatisticsDisplay,
24
    StatisticsSummary
25
} from "../openaireLibrary/connect/statistics/statisticsEntities";
26
import {PiwikHelper} from '../utils/piwikHelper';
27

    
28

    
29
@Component({
30
    selector: 'statistics',
31
    templateUrl: 'statistics.component.html',
32
})
33

    
34
export class StatisticsComponent {
35
  public piwiksub: any;
36
  public subfunders: any;
37

    
38
  public pageTitle = "OpenAIRE";
39

    
40
  properties:EnvProperties;
41
  @Input() communityId = null;
42

    
43
    @Input() currentMode = 'showInMonitor';
44
    communityInfo: any = null;
45
    entitiesList: string[] = [];
46
    entitiesMap: Map<string,string> = availableEntitiesMap;
47
    chartCatsList: string[] = availableCharts;
48
    allowedCharts: Map<string,string[]> = new Map<string,string[]>();
49
    allowedEntities: string[] = [];
50

    
51
    statisticsSum: StatisticsSummary =null;
52
    statisticsDisplay: StatisticsDisplay = null;
53
    chartsUrlMap: {};
54

    
55
    displayedTimeline: string;
56
    displayedTimelineUrl: string;
57
    displayedGraph: string;
58
    displayedGraphUrl: string;
59
    displayedProjectChart: string;
60
    displayedProjectChartUrl: string;
61
    displayedEntity: string;
62
    public errorCodes:ErrorCodes = new ErrorCodes();
63
    status = null;
64
  constructor (
65
      private route: ActivatedRoute,
66
      private _router: Router,
67
      private location: Location,
68
      private _meta: Meta,
69
      private _title: Title,
70
      private _piwikService:PiwikService,
71
      private config: ConfigurationService,
72
      private _communityService:CommunityService,
73
      private _communitiesService:CommunitiesService,
74
      private _statisticsService: StatisticsService,
75
      private _configService: ConfigurationService,
76
      private titleCase: TitleCasePipe,
77
      private sanitizer: DomSanitizer) {
78

    
79
  }
80

    
81
  public ngOnInit() {
82
    if(this.currentMode == "showInMonitor"){
83
      var description = "open access, research, scientific publication, European Commission, EC, FP7, ERC, Horizon 2020, H2020, search, projects ";
84
      var title = "Monitor";
85

    
86
      this._title.setTitle(title);
87
      this._meta.updateTag({content:description},"name='description'");
88
      this._meta.updateTag({content:description},"property='og:description'");
89
      this._meta.updateTag({content:title},"property='og:title'");
90
    }
91
    this.route.data
92
        .subscribe((data: { envSpecific: EnvProperties }) => {
93
           this.properties = data.envSpecific;
94
           var url = data.envSpecific.baseLink+this._router.url;
95
           this._meta.updateTag({content:url},"property='og:url'");
96

    
97
          this.route.queryParams.subscribe(
98
            communityId => {
99
                  this.communityId = communityId['communityId'];
100
                  if(!this.communityId && typeof document !== 'undefined'){
101
                    this.communityId  = ConnectHelper.getCommunityFromDomain(document.location.hostname);
102
                  }
103
                  if(this.currentMode == "showInMonitor" && this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
104
                    this.piwiksub = this._piwikService.trackView(this.properties, "Monitor "+ this.communityId, PiwikHelper.siteIDs[this.communityId]).subscribe();
105
                  }
106
                  // console.log(" Stats! "+ this.properties.statisticsAPIURL);
107
                  this.createStatisticsObjects();
108
            });
109
      });
110

    
111
  }
112

    
113

    
114
  public ngOnDestroy() {
115
    if(this.piwiksub){
116
      this.piwiksub.unsubscribe();
117
    }
118

    
119
  }
120

    
121
    getCamelCaseString(inputString: string) {
122
        return this.titleCase.transform(inputString);
123
    }
124

    
125
    createStatisticsObjects() {
126
        // console.log(" Stats! "+ this.properties.statisticsAPIURL);
127
        this.status = this.errorCodes.LOADING;
128
        this._statisticsService.getCommunityStatistics(this.properties.statisticsAPIURL,this.communityId).subscribe (
129
            res => {
130
                this.statisticsSum = res;
131
                if(res["other"]){ //hack because in stats API the entity name is "other" while in admin API is "orp". This component uses also "orp" name
132
                  this.statisticsSum["orp"]=res["other"];
133
                }
134
                this.getDisplayOptions();
135
            },
136
            error => {
137
                console.log(error);
138
                this.status = this.errorCodes.ERROR;
139
            });
140
    }
141

    
142
    getDisplayOptions() {
143
        this._statisticsService.getCommunityAdminStatisticsChoices(this.properties.adminToolsAPIURL,this.communityId)
144
            .subscribe(
145
                res => {
146
                    this.statisticsDisplay = res;
147
                    this.createChartUrlMap();
148
                    this.getCommunityInfo();
149
                    this.status = this.errorCodes.DONE;
150

    
151
                },
152
                error => {
153
                    console.log(error);
154
                    this.status = this.errorCodes.ERROR;
155
                }
156
            );
157
    }
158

    
159

    
160
    getCommunityInfo() {
161
      // console.log(`calling ${this.properties.adminToolsAPIURL}/communityFull/${this.communityId}`);
162
      this._configService.getCommunityInformation(this.properties.adminToolsAPIURL, this.communityId).subscribe(
163
          res => {
164
              this.communityInfo = res;
165
              /*for(let i=0; i<this.communityInfo.entities.length; i++){
166

    
167
                  if (this.communityInfo.entities[i]["isEnabled"] ) {
168
                      this.entitiesList.push(this.communityInfo.entities[i]['pid']);
169
                  }
170
              }
171
              console.log(this.entitiesList);*/
172
          },
173
          error => console.log(error),
174
          () => this.initializeDisplayedCharts()
175
      );
176
    }
177

    
178
    initializeDisplayedCharts() {
179
        let firstEntity: string;
180
        this.entitiesList = Array.from( this.entitiesMap.keys() );
181
        // console.log('this.entitiesList is',this.entitiesList);
182
        // console.log(`my current mode is: ${this.currentMode}`);
183
        for (let entity of this.entitiesList) {
184
            if (this.statisticsDisplay.entities[entity] && this.statisticsSum[entity].total && this.communityInfo.entities.filter(x => x['pid'] == entity && x['isEnabled']===true).length ) {
185
                this.allowedCharts[entity] = [];
186
                for (let chart of this.chartCatsList){
187
                    if (this.statisticsSum[entity].total &&
188
                        this.statisticsDisplay.entities[entity].charts.map[chart] &&
189
                        this.statisticsDisplay.entities[entity].charts.map[chart][this.currentMode] &&
190
                        this.chartsUrlMap[entity + this.getCamelCaseString(chart)]) {
191
                        this.allowedCharts[entity].push(entity + this.getCamelCaseString(chart));
192
                        // console.log(`added ${entity} - ${chart} to allowedCharts`);
193
                    }
194
                }
195
                if (this.allowedCharts[entity].length) {
196
                    // console.log(`added ${entity} to allowedEntities`);
197
                    this.allowedEntities.push(entity);
198
                    if (!firstEntity){
199
                        firstEntity = entity;
200
                        this.onChangeEntity(entity);
201
                    }
202
                }
203
            }
204
        }
205
    }
206

    
207
    createChartUrlMap() {
208
        this.chartsUrlMap = {
209
            publicationTimeline : this.sanitizer.bypassSecurityTrustResourceUrl(`${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=70%&h=83%`),
210
            publicationGraph: this.sanitizer.bypassSecurityTrustResourceUrl(`${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":"Publications by access mode","subtitle":"","xaxistitle":"","nulls":true}&w=70%&h=70%`),
211
            publicationProjectcolumn: this.sanitizer.bypassSecurityTrustResourceUrl(`${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=70%&h=90%`),
212
            publicationProjectpie: this.sanitizer.bypassSecurityTrustResourceUrl(`${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":[""],"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=91%&h=90%`),
213
            publicationProjecttable: this.sanitizer.bypassSecurityTrustResourceUrl(`${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%`),
214
            datasetTimeline: this.sanitizer.bypassSecurityTrustResourceUrl(`${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":["datasets"],"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=70%&h=83%`),
215
            datasetGraph: this.sanitizer.bypassSecurityTrustResourceUrl(`${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":"Research data by access mode","subtitle":"","xaxistitle":"","nulls":true}&w=70%&h=70%`),
216
            datasetProjectcolumn: this.sanitizer.bypassSecurityTrustResourceUrl(`${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":["datasets"],"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=70%&h=90%`),
217
            datasetProjectpie: this.sanitizer.bypassSecurityTrustResourceUrl(`${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":[""],"fieldsheaders":["datasets"],"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=91%&h=90%`),
218
            datasetProjecttable: this.sanitizer.bypassSecurityTrustResourceUrl(`${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":["Datasets"],"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%`),
219
            softwareTimeline: this.sanitizer.bypassSecurityTrustResourceUrl(`${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":["software"],"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=70%&h=83%`),
220
            softwareGraph: this.sanitizer.bypassSecurityTrustResourceUrl(`${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":"Software by access mode","subtitle":"","xaxistitle":"","nulls":true}&w=70%&h=70%`),
221
            softwareProjectcolumn: this.sanitizer.bypassSecurityTrustResourceUrl(`${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":["software"],"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=70%&h=90%`),
222
            softwareProjectpie: this.sanitizer.bypassSecurityTrustResourceUrl(`${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":[""],"fieldsheaders":["software"],"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=91%&h=90%`),
223
            softwareProjecttable: this.sanitizer.bypassSecurityTrustResourceUrl(`${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":["Software"],"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%`),
224

    
225
            orpTimeline: this.sanitizer.bypassSecurityTrustResourceUrl(`${this.properties.statisticsFrameAPIURL}chart.php?com=query&data={"query":"comTimelineOther","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":["Other Research products"],"fieldsheaders":["Other Research products"],"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":"Other Research products through the years","subtitle":"","xaxistitle":"Year"}&w=70%&h=83%`),
226
            orpGraph: this.sanitizer.bypassSecurityTrustResourceUrl(`${this.properties.statisticsFrameAPIURL}chart.php?com=query&data={"query":"comOAOther","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":"Other Research products by access mode","subtitle":"","xaxistitle":"","nulls":true}&w=70%&h=70%`),
227
            orpProjectcolumn: this.sanitizer.bypassSecurityTrustResourceUrl(`${this.properties.statisticsFrameAPIURL}chart.php?com=query&data={"query":"comProjectOther","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":["Other Research products"],"fieldsheaders":["Other Research products"],"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":"Other Research products per project","subtitle":"","xaxistitle":"Project"}&w=70%&h=90%`),
228
            orpProjectpie: this.sanitizer.bypassSecurityTrustResourceUrl(`${this.properties.statisticsFrameAPIURL}chart.php?com=query&data={"query":"comProjectOther","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":[""],"fieldsheaders":["Other Research products"],"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":"Other Research products per project","subtitle":"","xaxistitle":"Project"}&w=91%&h=90%`),
229
            orpProjecttable: this.sanitizer.bypassSecurityTrustResourceUrl(`${this.properties.statisticsFrameAPIURL}gtable.php?com=query&data={"query":"comProjectOther","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":["Other Research products"],"fieldsheaders":["Other Research products"],"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%`)
230
        };
231
    }
232

    
233

    
234
    onChangeEntity (entity: string) {
235
      this.displayedEntity = entity;
236
      // console.log(`displayed entity is ${entity}`);
237
      // console.log(`statisticsSum[${entity}].total is ${this.statisticsSum[entity].total}`);
238

    
239
      if (this.statisticsSum[entity].total &&
240
          this.allowedEntities.filter(x => x == entity).length ) {
241

    
242
          // console.log(`found ${entity} in allowedEntities`);
243
          this.displayedTimeline = `${entity}Timeline`;
244
          this.displayedTimelineUrl = this.chartsUrlMap[this.displayedTimeline];
245
          // console.log(`displayed Timeline is: ${this.displayedTimeline}`);
246
          this.displayedGraph = `${entity}Graph`;
247
          this.displayedGraphUrl = this.chartsUrlMap[this.displayedGraph];
248
          // console.log(`displayed Graph is: ${this.displayedGraph}`);
249
          if (this.allowedCharts[entity]) {
250
              let firstProjectChart = this.allowedCharts[entity].filter( x => x.includes(entity+'Project') );
251
              if (firstProjectChart[0]) {
252
                  this.changeDisplayedProjectChart(firstProjectChart[0]);
253
              } else {
254
                  this.displayedProjectChart = '';
255
                  this.displayedProjectChartUrl = '';
256
                  // console.log(`displayed ProjectChart is: ${this.displayedProjectChart}`);
257
              }
258
          }
259
      } else {
260
          this.displayedTimeline = '';
261
          this.displayedTimelineUrl = '';
262
          // console.log(`displayed Timeline is: ${this.displayedTimeline}`);
263
          this.displayedGraph = '';
264
          this.displayedGraphUrl = '';
265
          // console.log(`displayed Graph is: ${this.displayedGraph}`);
266
      }
267
    }
268

    
269
    changeDisplayedProjectChart(chartName: string) {
270
        this.displayedProjectChart = chartName;
271
        this.displayedProjectChartUrl = this.chartsUrlMap[this.displayedProjectChart];
272
        // console.log(`displayed ProjectChart is: ${this.displayedProjectChart}`);
273
    }
274

    
275
}
276

    
277

    
278
@Component({
279
    selector: 'statistics-for-dashboard',
280
    templateUrl: 'statistics-for-dashboard.component.html',
281
})
282

    
283
export class StatisticsForDashboardComponent extends StatisticsComponent {
284
    ngOnInit() {
285
        super.ngOnInit();
286
    }
287

    
288
}
(4-4/5)