Project

General

Profile

1 51838 sofia.balt
import {Component, Input}            from '@angular/core';
2 51227 sofia.balt
import {ActivatedRoute, Router}      from '@angular/router';
3 51838 sofia.balt
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 50988 argiro.kok
8 51838 sofia.balt
import {Observable}                  from 'rxjs/Observable';
9
10 50988 argiro.kok
import "rxjs/add/observable/zip";
11
12 51227 sofia.balt
import {EnvProperties}               from '../openaireLibrary/utils/properties/env-properties';
13
import {ErrorCodes}                  from '../openaireLibrary/utils/properties/errorCodes';
14 50988 argiro.kok
15 51227 sofia.balt
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 51838 sofia.balt
22 51566 argiro.kok
import {ConnectHelper} from '../openaireLibrary/connect/connectHelper';
23 51838 sofia.balt
import {availableCharts, availableEntitiesMap, StatisticsDisplay,
24 51687 myrto.kouk
    StatisticsSummary
25
} from "../openaireLibrary/connect/statistics/statisticsEntities";
26 52386 argiro.kok
import {PiwikHelper} from '../utils/piwikHelper';
27 51227 sofia.balt
28 50988 argiro.kok
@Component({
29
    selector: 'statistics',
30
    templateUrl: 'statistics.component.html',
31
})
32 51227 sofia.balt
33 50988 argiro.kok
export class StatisticsComponent {
34
  public piwiksub: any;
35
  public subfunders: any;
36
37 51146 myrto.kouk
  public pageTitle = "OpenAIRE";
38 50988 argiro.kok
39
  properties:EnvProperties;
40 51407 argiro.kok
  @Input() communityId = null;
41 51227 sofia.balt
42 51332 myrto.kouk
    @Input() currentMode = 'showInMonitor';
43 51758 myrto.kouk
    communityInfo: any = null;
44 51627 myrto.kouk
    entitiesList: string[] = [];
45
    entitiesMap: Map<string,string> = availableEntitiesMap;
46 51322 myrto.kouk
    chartCatsList: string[] = availableCharts;
47 51332 myrto.kouk
    allowedCharts: Map<string,string[]> = new Map<string,string[]>();
48
    allowedEntities: string[] = [];
49 51322 myrto.kouk
50
    statisticsSum: StatisticsSummary;
51
    statisticsDisplay: StatisticsDisplay;
52
    chartsUrlMap: {};
53
54 51332 myrto.kouk
    displayedTimeline: string;
55
    displayedTimelineUrl: string;
56
    displayedGraph: string;
57
    displayedGraphUrl: string;
58
    displayedProjectChart: string;
59
    displayedProjectChartUrl: string;
60
    displayedEntity: string;
61 51322 myrto.kouk
62 50988 argiro.kok
  constructor (
63 51227 sofia.balt
      private route: ActivatedRoute,
64 50988 argiro.kok
      private _router: Router,
65 51322 myrto.kouk
      private location: Location,
66
      private _meta: Meta,
67 51838 sofia.balt
      private _title: Title,
68 51322 myrto.kouk
      private _piwikService:PiwikService,
69 50988 argiro.kok
      private config: ConfigurationService,
70 51322 myrto.kouk
      private _communityService:CommunityService,
71
      private _communitiesService:CommunitiesService,
72
      private _statisticsService: StatisticsService,
73 51758 myrto.kouk
      private _configService: ConfigurationService,
74 51322 myrto.kouk
      private titleCase: TitleCasePipe,
75 51838 sofia.balt
      private sanitizer: DomSanitizer) {
76 50988 argiro.kok
77
  }
78
79
  public ngOnInit() {
80 52051 argiro.kok
    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 50988 argiro.kok
    this.route.data
90
        .subscribe((data: { envSpecific: EnvProperties }) => {
91
           this.properties = data.envSpecific;
92 51322 myrto.kouk
           var url = data.envSpecific.baseLink+this._router.url;
93 51838 sofia.balt
           this._meta.updateTag({content:url},"property='og:url'");
94 50988 argiro.kok
95 50996 argiro.kok
          this.route.queryParams.subscribe(
96
            communityId => {
97
                  this.communityId = communityId['communityId'];
98 51407 argiro.kok
                  if(!this.communityId){
99
                    this.communityId  = ConnectHelper.getCommunityFromDomain(document.location.hostname);
100
                  }
101 52386 argiro.kok
                  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 51322 myrto.kouk
                  this.createStatisticsObjects();
106
            });
107 50996 argiro.kok
      });
108 50988 argiro.kok
109
  }
110
111 51758 myrto.kouk
112 50988 argiro.kok
  public ngOnDestroy() {
113
    if(this.piwiksub){
114
      this.piwiksub.unsubscribe();
115
    }
116
117
  }
118 51227 sofia.balt
119 51322 myrto.kouk
    getCamelCaseString(inputString: string) {
120
        return this.titleCase.transform(inputString);
121
    }
122 50988 argiro.kok
123 51322 myrto.kouk
    createStatisticsObjects() {
124 52386 argiro.kok
        // console.log(" Stats! "+ this.properties.statisticsAPIURL);
125 51322 myrto.kouk
        this._statisticsService.getCommunityStatistics(this.properties.statisticsAPIURL,this.communityId).subscribe (
126
            res => {
127 51514 myrto.kouk
                console.log('statisticsSum is:');
128 51322 myrto.kouk
                this.statisticsSum = res;
129 53562 argiro.kok
                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 51322 myrto.kouk
            },
134
            error => {
135 51383 myrto.kouk
                console.log(error);
136 51322 myrto.kouk
            },
137
            () => {
138
                this.getDisplayOptions();
139
            });
140 50988 argiro.kok
    }
141
142 51322 myrto.kouk
    getDisplayOptions() {
143
        this._statisticsService.getCommunityAdminStatisticsChoices(this.properties.adminToolsAPIURL,this.communityId)
144
            .subscribe(
145
                res => {
146
                    this.statisticsDisplay = res;
147
                },
148
                error => {
149 51383 myrto.kouk
                    console.log(error);
150 51322 myrto.kouk
                },
151
                () => {
152 51324 myrto.kouk
                    this.createChartUrlMap();
153 51758 myrto.kouk
                    this.getCommunityInfo();
154 51322 myrto.kouk
                }
155
            );
156
    }
157 51167 myrto.kouk
158 51322 myrto.kouk
159 51758 myrto.kouk
    getCommunityInfo() {
160 52386 argiro.kok
      // console.log(`calling ${this.properties.adminToolsAPIURL}/communityFull/${this.communityId}`);
161 51758 myrto.kouk
      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 51332 myrto.kouk
    initializeDisplayedCharts() {
178 51324 myrto.kouk
        let firstEntity: string;
179 51627 myrto.kouk
        this.entitiesList = Array.from( this.entitiesMap.keys() );
180 52386 argiro.kok
        // console.log('this.entitiesList is',this.entitiesList);
181
        // console.log(`my current mode is: ${this.currentMode}`);
182 51324 myrto.kouk
        for (let entity of this.entitiesList) {
183 51758 myrto.kouk
            if (this.statisticsDisplay.entities[entity] && this.statisticsSum[entity].total && this.communityInfo.entities.filter(x => x['pid'] == entity && x['isEnabled']===true).length ) {
184 51332 myrto.kouk
                this.allowedCharts[entity] = [];
185 51324 myrto.kouk
                for (let chart of this.chartCatsList){
186 51332 myrto.kouk
                    if (this.statisticsSum[entity].total &&
187
                        this.statisticsDisplay.entities[entity].charts.map[chart] &&
188
                        this.statisticsDisplay.entities[entity].charts.map[chart][this.currentMode] &&
189 51324 myrto.kouk
                        this.chartsUrlMap[entity + this.getCamelCaseString(chart)]) {
190 51332 myrto.kouk
                        this.allowedCharts[entity].push(entity + this.getCamelCaseString(chart));
191 53562 argiro.kok
                        // console.log(`added ${entity} - ${chart} to allowedCharts`);
192 51324 myrto.kouk
                    }
193
                }
194 51758 myrto.kouk
                if (this.allowedCharts[entity].length) {
195 52386 argiro.kok
                    // console.log(`added ${entity} to allowedEntities`);
196 51758 myrto.kouk
                    this.allowedEntities.push(entity);
197
                    if (!firstEntity){
198
                        firstEntity = entity;
199
                        this.onChangeEntity(entity);
200
                    }
201 51324 myrto.kouk
                }
202
            }
203
        }
204 51322 myrto.kouk
    }
205
206
    createChartUrlMap() {
207
        this.chartsUrlMap = {
208 51514 myrto.kouk
            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 51627 myrto.kouk
            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 51514 myrto.kouk
            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 51627 myrto.kouk
            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 51332 myrto.kouk
            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 51627 myrto.kouk
            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 51514 myrto.kouk
            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 51627 myrto.kouk
            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 53562 argiro.kok
            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 51322 myrto.kouk
        };
230
    }
231
232
233
    onChangeEntity (entity: string) {
234 51514 myrto.kouk
      this.displayedEntity = entity;
235 52386 argiro.kok
      // console.log(`displayed entity is ${entity}`);
236
      // console.log(`statisticsSum[${entity}].total is ${this.statisticsSum[entity].total}`);
237 51514 myrto.kouk
238
      if (this.statisticsSum[entity].total &&
239
          this.allowedEntities.filter(x => x == entity).length ) {
240
241 52386 argiro.kok
          // console.log(`found ${entity} in allowedEntities`);
242 51514 myrto.kouk
          this.displayedTimeline = `${entity}Timeline`;
243
          this.displayedTimelineUrl = this.chartsUrlMap[this.displayedTimeline];
244 52386 argiro.kok
          // console.log(`displayed Timeline is: ${this.displayedTimeline}`);
245 51514 myrto.kouk
          this.displayedGraph = `${entity}Graph`;
246
          this.displayedGraphUrl = this.chartsUrlMap[this.displayedGraph];
247 52386 argiro.kok
          // console.log(`displayed Graph is: ${this.displayedGraph}`);
248 51514 myrto.kouk
          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 52386 argiro.kok
                  // console.log(`displayed ProjectChart is: ${this.displayedProjectChart}`);
256 51514 myrto.kouk
              }
257
          }
258
      } else {
259
          this.displayedTimeline = '';
260
          this.displayedTimelineUrl = '';
261 52386 argiro.kok
          // console.log(`displayed Timeline is: ${this.displayedTimeline}`);
262 51514 myrto.kouk
          this.displayedGraph = '';
263
          this.displayedGraphUrl = '';
264 52386 argiro.kok
          // console.log(`displayed Graph is: ${this.displayedGraph}`);
265 51514 myrto.kouk
      }
266 51322 myrto.kouk
    }
267
268
    changeDisplayedProjectChart(chartName: string) {
269
        this.displayedProjectChart = chartName;
270
        this.displayedProjectChartUrl = this.chartsUrlMap[this.displayedProjectChart];
271 52386 argiro.kok
        // console.log(`displayed ProjectChart is: ${this.displayedProjectChart}`);
272 51322 myrto.kouk
    }
273
274 50988 argiro.kok
}
275 51332 myrto.kouk
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 51407 argiro.kok
}