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
@Component({
29
    selector: 'statistics',
30
    templateUrl: 'statistics.component.html',
31
})
32

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

    
37
  public pageTitle = "OpenAIRE";
38

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

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

    
50
    statisticsSum: StatisticsSummary;
51
    statisticsDisplay: StatisticsDisplay;
52
    chartsUrlMap: {};
53

    
54
    displayedTimeline: string;
55
    displayedTimelineUrl: string;
56
    displayedGraph: string;
57
    displayedGraphUrl: string;
58
    displayedProjectChart: string;
59
    displayedProjectChartUrl: string;
60
    displayedEntity: string;
61

    
62
  constructor (
63
      private route: ActivatedRoute,
64
      private _router: Router,
65
      private location: Location,
66
      private _meta: Meta,
67
      private _title: Title,
68
      private _piwikService:PiwikService,
69
      private config: ConfigurationService,
70
      private _communityService:CommunityService,
71
      private _communitiesService:CommunitiesService,
72
      private _statisticsService: StatisticsService,
73
      private _configService: ConfigurationService,
74
      private titleCase: TitleCasePipe,
75
      private sanitizer: DomSanitizer) {
76

    
77
  }
78

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

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

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

    
109
  }
110

    
111

    
112
  public ngOnDestroy() {
113
    if(this.piwiksub){
114
      this.piwiksub.unsubscribe();
115
    }
116

    
117
  }
118

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

    
123
    createStatisticsObjects() {
124
        // console.log(" Stats! "+ this.properties.statisticsAPIURL);
125
        this._statisticsService.getCommunityStatistics(this.properties.statisticsAPIURL,this.communityId).subscribe (
126
            res => {
127
                console.log('statisticsSum is:');
128
                this.statisticsSum = res;
129
                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
130
                  this.statisticsSum["orp"]=res["other"];
131
                }
132
                console.log(this.statisticsSum);
133
            },
134
            error => {
135
                console.log(error);
136
            },
137
            () => {
138
                this.getDisplayOptions();
139
            });
140
    }
141

    
142
    getDisplayOptions() {
143
        this._statisticsService.getCommunityAdminStatisticsChoices(this.properties.adminToolsAPIURL,this.communityId)
144
            .subscribe(
145
                res => {
146
                    this.statisticsDisplay = res;
147
                },
148
                error => {
149
                    console.log(error);
150
                },
151
                () => {
152
                    this.createChartUrlMap();
153
                    this.getCommunityInfo();
154
                }
155
            );
156
    }
157

    
158

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

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

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

    
206
    createChartUrlMap() {
207
        this.chartsUrlMap = {
208
            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%`),
209
            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%`),
210
            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%`),
211
            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%`),
212
            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%`),
213
            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%`),
214
            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%`),
215
            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%`),
216
            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%`),
217
            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%`),
218
            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%`),
219
            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%`),
220
            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%`),
221
            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%`),
222
            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%`),
223

    
224
            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%`),
225
            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%`),
226
            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%`),
227
            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%`),
228
            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%`)
229
        };
230
    }
231

    
232

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

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

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

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

    
274
}
275

    
276

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

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

    
287
}
(4-4/5)