1
|
import {Component, OnInit, ElementRef} from '@angular/core';
|
2
|
import {HelpContentService} from '../../services/help-content.service';
|
3
|
import {ActivatedRoute, Router} from '@angular/router';
|
4
|
import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';
|
5
|
import { Community } from '../../domain/community';
|
6
|
import { DomSanitizer } from '@angular/platform-browser';
|
7
|
import {TitleCasePipe} from '@angular/common';
|
8
|
import {availableEntitiesMap, StatisticsDisplay, StatisticsSummary} from '../../openaireLibrary/connect/statistics/statisticsEntities';
|
9
|
import {Observable} from 'rxjs/Observable';
|
10
|
import {ConfigurationService} from '../../openaireLibrary/utils/configuration/configuration.service';
|
11
|
|
12
|
import {Session} from '../../openaireLibrary/login/utils/helper.class';
|
13
|
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
|
14
|
|
15
|
@Component({
|
16
|
selector: 'stats',
|
17
|
templateUrl: 'stats.component.html'
|
18
|
})
|
19
|
|
20
|
export class StatsComponent implements OnInit {
|
21
|
// errorMessage: string;
|
22
|
// loadingMessage: string;
|
23
|
public showLoading: boolean = true;
|
24
|
public errorMessage: string = '';
|
25
|
public updateErrorMessage: string = '';
|
26
|
|
27
|
communities: Community[] = [];
|
28
|
communityId: string;
|
29
|
communityInfo = null;
|
30
|
deactivatedEntity: boolean;
|
31
|
|
32
|
displayedTimeline: string;
|
33
|
displayedGraph: string;
|
34
|
displayedProjectChart: string;
|
35
|
displayedEntity: string;
|
36
|
|
37
|
entitiesList: string[] = [];
|
38
|
entitiesMap: Map<string, string> = availableEntitiesMap;
|
39
|
|
40
|
statisticsSum: StatisticsSummary;
|
41
|
statisticsDisplay: StatisticsDisplay;
|
42
|
chartsUrlMap: {};
|
43
|
|
44
|
showAllInMonitor: boolean = false;
|
45
|
showAllInDashboard: boolean = false;
|
46
|
|
47
|
public properties: EnvProperties = null;
|
48
|
|
49
|
constructor(private element: ElementRef,
|
50
|
private contentService: HelpContentService,
|
51
|
private configService: ConfigurationService,
|
52
|
private route: ActivatedRoute,
|
53
|
private _router: Router,
|
54
|
private sanitizer: DomSanitizer,
|
55
|
private titleCase: TitleCasePipe) {}
|
56
|
|
57
|
ngOnInit() {
|
58
|
this.route.data
|
59
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
60
|
this.properties = data.envSpecific;
|
61
|
this.route.queryParams.subscribe(
|
62
|
params => {
|
63
|
this.scroll();
|
64
|
|
65
|
this.communityId = params['communityId'];
|
66
|
this.getStatistics();
|
67
|
});
|
68
|
},
|
69
|
error => console.log(`E R R O R!!`)
|
70
|
);
|
71
|
}
|
72
|
|
73
|
getStatistics() {
|
74
|
if(!Session.isLoggedIn()){
|
75
|
console.info(this._router.url);
|
76
|
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
77
|
} else {
|
78
|
// this.loadingMessage = 'Retrieving statistics';
|
79
|
// this.errorMessage = '';
|
80
|
this.showLoading = true;
|
81
|
this.updateErrorMessage = "";
|
82
|
this.errorMessage = "";
|
83
|
|
84
|
this.statisticsSum = null;
|
85
|
this.statisticsDisplay = null;
|
86
|
this.contentService.getCommunityStatistics(this.properties.statisticsAPIURL, this.communityId).subscribe(
|
87
|
stats => {
|
88
|
|
89
|
this.statisticsSum = stats;
|
90
|
if(stats["other"]){ //hack because in stats API the entity name is "other" while in admin API is "orp". This component uses also "orp" name
|
91
|
this.statisticsSum["orp"]=stats["other"];
|
92
|
}
|
93
|
},
|
94
|
error => {
|
95
|
//this.loadingMessage = '';
|
96
|
//this.errorMessage = 'Failed to retrieve statistics for the chosen community!';
|
97
|
//console.log(error);
|
98
|
this.handleError('Failed to retrieve statistics for the chosen community!', error);
|
99
|
},
|
100
|
() => {
|
101
|
console.log(`I have statistics!`);
|
102
|
//this.loadingMessage = '';
|
103
|
this.getDisplayOptions();
|
104
|
}
|
105
|
);
|
106
|
}
|
107
|
}
|
108
|
|
109
|
getDisplayOptions() {
|
110
|
if(!Session.isLoggedIn()){
|
111
|
console.info(this._router.url);
|
112
|
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
113
|
} else {
|
114
|
this.contentService.getCommunityAdminStatisticsChoices(this.properties.adminToolsAPIURL, this.communityId)
|
115
|
.subscribe(
|
116
|
res => {
|
117
|
this.statisticsDisplay = res;
|
118
|
},
|
119
|
error => {
|
120
|
//console.log(error);
|
121
|
this.handleError('Failed to retrieve statistics\' choices for the chosen community!', error);
|
122
|
},
|
123
|
() => {
|
124
|
this.getCommunityInfo();
|
125
|
}
|
126
|
);
|
127
|
}
|
128
|
}
|
129
|
|
130
|
getCommunityInfo() {
|
131
|
if(!Session.isLoggedIn()){
|
132
|
console.info(this._router.url);
|
133
|
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
134
|
} else {
|
135
|
console.log(`calling ${this.properties.adminToolsAPIURL}/communityFull/${this.communityId}`);
|
136
|
this.configService.getCommunityInformation(this.properties.adminToolsAPIURL, this.communityId).subscribe(
|
137
|
res => {
|
138
|
this.communityInfo = res;
|
139
|
},
|
140
|
error => this.handleError('Failed to retrieve information for the chosen community!', error),//console.log(error),
|
141
|
() => {
|
142
|
this.createChartUrlMap();
|
143
|
this.entitiesList = Array.from( this.entitiesMap.keys() );
|
144
|
this.onChangeEntity(this.entitiesList[0]);
|
145
|
}
|
146
|
);
|
147
|
}
|
148
|
}
|
149
|
|
150
|
onChangeEntity (entity: string) {
|
151
|
if(!Session.isLoggedIn()){
|
152
|
console.info(this._router.url);
|
153
|
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
154
|
} else {
|
155
|
this.showLoading = true;
|
156
|
|
157
|
this.deactivatedEntity = false;
|
158
|
this.displayedEntity = entity;
|
159
|
console.log(`displayed entity is ${entity}`);
|
160
|
console.log(`statisticsSum[${entity}].total is ${this.statisticsSum[entity].total}`);
|
161
|
|
162
|
console.log(`found ${entity} in allowedEntities`);
|
163
|
this.displayedTimeline = `${entity}Timeline`;
|
164
|
console.log(`displayed Timeline is: ${this.displayedTimeline}`);
|
165
|
this.displayedGraph = `${entity}Graph`;
|
166
|
console.log(`displayed Graph is: ${this.displayedGraph}`);
|
167
|
this.changeDisplayedProjectChart(`${entity}Projectcolumn`);
|
168
|
if (this.statisticsDisplay.entities[entity].charts.map['projectColumn'].showInMonitor &&
|
169
|
this.statisticsDisplay.entities[entity].charts.map['projectPie'].showInMonitor &&
|
170
|
this.statisticsDisplay.entities[entity].charts.map['projectTable'].showInMonitor) {
|
171
|
this.showAllInMonitor = true;
|
172
|
}
|
173
|
if (this.statisticsDisplay.entities[entity].charts.map['projectColumn'].showInDashboard &&
|
174
|
this.statisticsDisplay.entities[entity].charts.map['projectPie'].showInDashboard &&
|
175
|
this.statisticsDisplay.entities[entity].charts.map['projectTable'].showInDashboard) {
|
176
|
this.showAllInDashboard = true;
|
177
|
}
|
178
|
|
179
|
const activatedEntities = this.communityInfo['entities'];
|
180
|
if ( !activatedEntities.some(item => item.pid === entity) ) {
|
181
|
this.deactivatedEntity = true;
|
182
|
}
|
183
|
|
184
|
this.showLoading = false;
|
185
|
}
|
186
|
}
|
187
|
|
188
|
changeDisplayedProjectChart(chartName: string) {
|
189
|
this.displayedProjectChart = chartName;
|
190
|
console.log(`displayed ProjectChart is: ${this.displayedProjectChart}`);
|
191
|
}
|
192
|
|
193
|
createChartUrlMap() {
|
194
|
this.chartsUrlMap = {
|
195
|
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%`),
|
196
|
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%`),
|
197
|
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%`),
|
198
|
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%`),
|
199
|
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%`),
|
200
|
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%`),
|
201
|
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%`),
|
202
|
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%`),
|
203
|
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%`),
|
204
|
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%`),
|
205
|
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%`),
|
206
|
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%`),
|
207
|
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%`),
|
208
|
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%`),
|
209
|
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%`),
|
210
|
|
211
|
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%`),
|
212
|
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%`),
|
213
|
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%`),
|
214
|
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%`),
|
215
|
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%`)
|
216
|
};
|
217
|
}
|
218
|
|
219
|
toggleShowAllInMonitor(entity: string) {
|
220
|
if(!Session.isLoggedIn()){
|
221
|
console.info(this._router.url);
|
222
|
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
223
|
} else {
|
224
|
this.showLoading = true;
|
225
|
this.updateErrorMessage = "";
|
226
|
|
227
|
//this.loadingMessage = 'Saving changes';
|
228
|
this.showAllInMonitor = !this.showAllInMonitor;
|
229
|
|
230
|
this.contentService.postCommunityAdminStatisticsChoices(
|
231
|
this.properties.adminToolsAPIURL,
|
232
|
this.communityId,
|
233
|
entity,
|
234
|
'charts',
|
235
|
'projectColumn',
|
236
|
!this.showAllInMonitor,
|
237
|
true).subscribe(
|
238
|
response => console.log(JSON.stringify(response)),
|
239
|
error => {
|
240
|
console.log(error);
|
241
|
//this.loadingMessage = '';
|
242
|
//this.errorMessage = 'The changes could not be saved';
|
243
|
|
244
|
this.handleUpdateError('The changes could not be saved', error);
|
245
|
},
|
246
|
() => {
|
247
|
|
248
|
this.contentService.postCommunityAdminStatisticsChoices(
|
249
|
this.properties.adminToolsAPIURL,
|
250
|
this.communityId,
|
251
|
entity,
|
252
|
'charts',
|
253
|
'projectPie',
|
254
|
!this.showAllInMonitor,
|
255
|
true).subscribe(
|
256
|
response => console.log(JSON.stringify(response)),
|
257
|
error => {
|
258
|
console.log(error);
|
259
|
//this.loadingMessage = '';
|
260
|
//this.errorMessage = 'The changes could not be saved';
|
261
|
|
262
|
this.handleUpdateError('The changes could not be saved', error);
|
263
|
},
|
264
|
() => {
|
265
|
|
266
|
this.contentService.postCommunityAdminStatisticsChoices(
|
267
|
this.properties.adminToolsAPIURL,
|
268
|
this.communityId,
|
269
|
entity,
|
270
|
'charts',
|
271
|
'projectTable',
|
272
|
!this.showAllInMonitor,
|
273
|
true).subscribe(
|
274
|
response => console.log(JSON.stringify(response)),
|
275
|
error => {
|
276
|
console.log(error);
|
277
|
//this.loadingMessage = '';
|
278
|
//this.errorMessage = 'The changes could not be saved';
|
279
|
|
280
|
this.handleUpdateError('The changes could not be saved' ,error);
|
281
|
},
|
282
|
() => {
|
283
|
|
284
|
this.statisticsDisplay.entities[entity]['charts'].map['projectColumn'].showInMonitor = this.showAllInMonitor;
|
285
|
this.statisticsDisplay.entities[entity]['charts'].map['projectPie'].showInMonitor = this.showAllInMonitor;
|
286
|
this.statisticsDisplay.entities[entity]['charts'].map['projectTable'].showInMonitor = this.showAllInMonitor;
|
287
|
//this.loadingMessage = '';
|
288
|
|
289
|
this.showLoading = false;
|
290
|
}
|
291
|
);
|
292
|
}
|
293
|
);
|
294
|
}
|
295
|
);
|
296
|
|
297
|
/*forkJoin didn't work properly - maybe try another way*/
|
298
|
/*Observable.forkJoin(
|
299
|
this.contentService.postCommunityAdminStatisticsChoices(
|
300
|
this.properties.adminToolsAPIURL,
|
301
|
this.communityId,
|
302
|
entity,
|
303
|
'charts',
|
304
|
'projectColumn',
|
305
|
this.showAllInMonitor,
|
306
|
true),
|
307
|
this.contentService.postCommunityAdminStatisticsChoices(
|
308
|
this.properties.adminToolsAPIURL,
|
309
|
this.communityId,
|
310
|
entity,
|
311
|
'charts',
|
312
|
'projectPie',
|
313
|
this.showAllInMonitor,
|
314
|
true),
|
315
|
this.contentService.postCommunityAdminStatisticsChoices(
|
316
|
this.properties.adminToolsAPIURL,
|
317
|
this.communityId,
|
318
|
entity,
|
319
|
'charts',
|
320
|
'projectTable',
|
321
|
this.showAllInMonitor,
|
322
|
true)
|
323
|
|
324
|
).subscribe(
|
325
|
response => console.log('All went well in forkJoin!'),
|
326
|
error => {
|
327
|
console.log(error);
|
328
|
this.loadingMessage = '';
|
329
|
this.errorMessage = 'The changes could not be saved';
|
330
|
},
|
331
|
() => {
|
332
|
this.statisticsDisplay.entities[entity]['charts'].map['projectColumn'].showInMonitor = this.showAllInMonitor;
|
333
|
this.statisticsDisplay.entities[entity]['charts'].map['projectPie'].showInMonitor = this.showAllInMonitor;
|
334
|
this.statisticsDisplay.entities[entity]['charts'].map['projectTable'].showInMonitor = this.showAllInMonitor;
|
335
|
this.loadingMessage = '';
|
336
|
}
|
337
|
);*/
|
338
|
}
|
339
|
}
|
340
|
|
341
|
toggleShowAllInDashboard(entity: string) {
|
342
|
if(!Session.isLoggedIn()){
|
343
|
console.info(this._router.url);
|
344
|
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
345
|
} else {
|
346
|
this.showLoading = true;
|
347
|
this.updateErrorMessage = "";
|
348
|
|
349
|
//this.loadingMessage = 'Saving changes';
|
350
|
this.contentService.postCommunityAdminStatisticsChoices(
|
351
|
this.properties.adminToolsAPIURL,
|
352
|
this.communityId,
|
353
|
entity,
|
354
|
'charts',
|
355
|
'projectColumn',
|
356
|
!this.showAllInDashboard,
|
357
|
false).subscribe(
|
358
|
response => console.log(JSON.stringify(response)),
|
359
|
error => {
|
360
|
console.log(error);
|
361
|
//this.loadingMessage = '';
|
362
|
//this.errorMessage = 'The changes could not be saved';
|
363
|
this.handleUpdateError('The changed could not be saved', error);
|
364
|
},
|
365
|
() => {
|
366
|
|
367
|
this.contentService.postCommunityAdminStatisticsChoices(
|
368
|
this.properties.adminToolsAPIURL,
|
369
|
this.communityId,
|
370
|
entity,
|
371
|
'charts',
|
372
|
'projectPie',
|
373
|
!this.showAllInDashboard,
|
374
|
false).subscribe(
|
375
|
response => console.log(JSON.stringify(response)),
|
376
|
error => {
|
377
|
console.log(error);
|
378
|
//this.loadingMessage = '';
|
379
|
//this.errorMessage = 'The changes could not be saved';
|
380
|
this.handleUpdateError('The changes could not be saved', error);
|
381
|
},
|
382
|
() => {
|
383
|
|
384
|
this.contentService.postCommunityAdminStatisticsChoices(
|
385
|
this.properties.adminToolsAPIURL,
|
386
|
this.communityId,
|
387
|
entity,
|
388
|
'charts',
|
389
|
'projectTable',
|
390
|
!this.showAllInDashboard,
|
391
|
false).subscribe(
|
392
|
response => console.log(JSON.stringify(response)),
|
393
|
error => {
|
394
|
console.log(error);
|
395
|
//this.loadingMessage = '';
|
396
|
//this.errorMessage = 'The changes could not be saved';
|
397
|
this.handleUpdateError('The changes could not be saved', error);
|
398
|
},
|
399
|
() => {
|
400
|
|
401
|
this.showAllInDashboard = !this.showAllInDashboard;
|
402
|
this.statisticsDisplay.entities[entity]['charts'].map['projectColumn'].showInDashboard = this.showAllInDashboard;
|
403
|
this.statisticsDisplay.entities[entity]['charts'].map['projectPie'].showInDashboard = this.showAllInDashboard;
|
404
|
this.statisticsDisplay.entities[entity]['charts'].map['projectTable'].showInDashboard = this.showAllInDashboard;
|
405
|
//this.loadingMessage = '';
|
406
|
|
407
|
this.showLoading = false;
|
408
|
}
|
409
|
);
|
410
|
}
|
411
|
);
|
412
|
}
|
413
|
);
|
414
|
}
|
415
|
}
|
416
|
|
417
|
toggleShowInMonitor(entity: string, chartsOrNumbers: string, title: string) {
|
418
|
if(!Session.isLoggedIn()){
|
419
|
console.info(this._router.url);
|
420
|
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
421
|
} else {
|
422
|
this.showLoading = true;
|
423
|
this.updateErrorMessage = "";
|
424
|
|
425
|
this.contentService.postCommunityAdminStatisticsChoices(
|
426
|
this.properties.adminToolsAPIURL,
|
427
|
this.communityId,
|
428
|
entity,
|
429
|
chartsOrNumbers,
|
430
|
title,
|
431
|
!this.statisticsDisplay.entities[entity][chartsOrNumbers].map[title].showInMonitor,
|
432
|
true).subscribe(
|
433
|
response => console.log(JSON.stringify(response)),
|
434
|
error => this.handleUpdateError('The changes could not be saved', error),//console.log(error),
|
435
|
() => {
|
436
|
this.statisticsDisplay.entities[entity][chartsOrNumbers].map[title].showInMonitor = !this.statisticsDisplay.entities[entity][chartsOrNumbers].map[title].showInMonitor;
|
437
|
this.showLoading = false;
|
438
|
}
|
439
|
);
|
440
|
}
|
441
|
}
|
442
|
|
443
|
toggleShowInDashboard(entity: string, chartsOrNumbers: string, title: string) {
|
444
|
if(!Session.isLoggedIn()){
|
445
|
console.info(this._router.url);
|
446
|
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
447
|
} else {
|
448
|
this.showLoading = true;
|
449
|
this.updateErrorMessage = "";
|
450
|
|
451
|
this.contentService.postCommunityAdminStatisticsChoices(
|
452
|
this.properties.adminToolsAPIURL,
|
453
|
this.communityId,
|
454
|
entity,
|
455
|
chartsOrNumbers,
|
456
|
title,
|
457
|
!this.statisticsDisplay.entities[entity][chartsOrNumbers].map[title].showInDashboard,
|
458
|
false).subscribe(
|
459
|
response => console.log(JSON.stringify(response)),
|
460
|
error => this.handleUpdateError('The changes could not be saved', error),//console.log(error),
|
461
|
() => {
|
462
|
this.statisticsDisplay.entities[entity][chartsOrNumbers].map[title].showInDashboard = !this.statisticsDisplay.entities[entity][chartsOrNumbers].map[title].showInDashboard;
|
463
|
this.showLoading = false;
|
464
|
}
|
465
|
);
|
466
|
}
|
467
|
}
|
468
|
|
469
|
getCamelCaseString (inputString: string) {
|
470
|
return this.titleCase.transform(inputString);
|
471
|
}
|
472
|
|
473
|
|
474
|
handleUpdateError(message: string, error) {
|
475
|
this.updateErrorMessage = message;
|
476
|
console.log('Server responded: ' +error);
|
477
|
|
478
|
this.showLoading = false;
|
479
|
}
|
480
|
|
481
|
handleError(message: string, error) {
|
482
|
this.errorMessage = message;
|
483
|
console.log('Server responded: ' + error);
|
484
|
|
485
|
this.showLoading = false;
|
486
|
}
|
487
|
|
488
|
public scroll() {
|
489
|
console.info("scroll into view");
|
490
|
if (typeof document !== 'undefined') {
|
491
|
this.element.nativeElement.scrollIntoView();
|
492
|
}
|
493
|
}
|
494
|
}
|