1 |
51746
|
argiro.kok
|
import {Component, ViewChild, ElementRef, Input} from '@angular/core';
|
2 |
50169
|
argiro.kok
|
import {Observable} from 'rxjs/Observable';
|
3 |
|
|
import {ActivatedRoute, Params, Router} from '@angular/router';
|
4 |
|
|
import {ProjectService} from './project.service';
|
5 |
|
|
import {ProjectInfo} from '../../utils/entities/projectInfo';
|
6 |
|
|
import {RouterHelper} from '../../utils/routerHelper.class';
|
7 |
|
|
|
8 |
|
|
import { FetchPublications } from '../../utils/fetchEntitiesClasses/fetchPublications.class';
|
9 |
|
|
import { SearchPublicationsService } from '../../services/searchPublications.service';
|
10 |
|
|
import { FetchDatasets } from '../../utils/fetchEntitiesClasses/fetchDatasets.class';
|
11 |
|
|
import { SearchDatasetsService } from '../../services/searchDatasets.service';
|
12 |
|
|
import { FetchSoftware } from '../../utils/fetchEntitiesClasses/fetchSoftware.class';
|
13 |
|
|
import { SearchSoftwareService } from '../../services/searchSoftware.service';
|
14 |
|
|
|
15 |
|
|
import {ModalLoading} from '../../utils/modal/loading.component';
|
16 |
|
|
|
17 |
|
|
import {ReportsService} from '../../services/reports.service';
|
18 |
50761
|
argiro.kok
|
import { ErrorCodes} from '../../utils/properties/errorCodes';
|
19 |
50684
|
argiro.kok
|
import { Meta} from '../../sharedComponents/metaService';
|
20 |
50169
|
argiro.kok
|
|
21 |
|
|
import {PiwikService} from '../../utils/piwik/piwik.service';
|
22 |
50586
|
argiro.kok
|
import{EnvProperties} from '../../utils/properties/env-properties';
|
23 |
50169
|
argiro.kok
|
|
24 |
|
|
@Component({
|
25 |
|
|
selector: 'project',
|
26 |
|
|
templateUrl: 'project.component.html',
|
27 |
|
|
})
|
28 |
|
|
export class ProjectComponent{
|
29 |
51746
|
argiro.kok
|
@Input() piwikSiteId = null;
|
30 |
50169
|
argiro.kok
|
public projectInfo: ProjectInfo;
|
31 |
|
|
public projectId : string ;
|
32 |
|
|
public projectName: string;
|
33 |
|
|
|
34 |
|
|
// Metrics tab variables
|
35 |
|
|
public metricsClicked: boolean;
|
36 |
|
|
public viewsFrameUrl: string;
|
37 |
|
|
public downloadsFrameUrl: string;
|
38 |
|
|
private totalViews: number;
|
39 |
|
|
private totalDownloads: number;
|
40 |
|
|
private pageViews: number;
|
41 |
|
|
|
42 |
|
|
// Statistics tab variables
|
43 |
|
|
public statsClicked: boolean;
|
44 |
|
|
public chartScientificResultsUrl: string;
|
45 |
|
|
public chartAccessModeUrl: string;
|
46 |
|
|
public chartDatasourcesUrl: string;
|
47 |
|
|
|
48 |
|
|
// HTML variables in APP BOX
|
49 |
|
|
public publications_dynamic: string;
|
50 |
|
|
public datasets_dynamic: string;
|
51 |
|
|
public software_dynamic: string;
|
52 |
|
|
|
53 |
|
|
public project ;
|
54 |
|
|
|
55 |
|
|
// CSV variables
|
56 |
|
|
public downloadURLAPI: string;
|
57 |
|
|
public csvParams: string;
|
58 |
|
|
public csvParamsDatasets: string;
|
59 |
|
|
public csvParamsSoftware: string;
|
60 |
|
|
|
61 |
|
|
// Message variables
|
62 |
|
|
public warningMessage = "";
|
63 |
|
|
public errorMessage = "";
|
64 |
|
|
public showLoading: boolean = true;
|
65 |
|
|
|
66 |
|
|
// Active tab variable for responsiveness
|
67 |
|
|
public activeTab: string = "Publications";
|
68 |
|
|
|
69 |
|
|
// Request results for research data and software only the one time (first time tab is clicked)
|
70 |
|
|
private reloadDatasets: boolean = true;
|
71 |
|
|
private reloadSoftware: boolean = true;
|
72 |
|
|
|
73 |
|
|
// Variables for publications, research data, software tabs
|
74 |
|
|
public fetchPublications : FetchPublications;
|
75 |
|
|
public linkToSearchPublications = "";
|
76 |
|
|
public fetchDatasets : FetchDatasets;
|
77 |
|
|
public linkToSearchDatasets = "";
|
78 |
|
|
public fetchSoftware: FetchSoftware;
|
79 |
|
|
public linkToSearchSoftware = "";
|
80 |
|
|
|
81 |
|
|
public routerHelper:RouterHelper = new RouterHelper();
|
82 |
|
|
public errorCodes:ErrorCodes = new ErrorCodes();
|
83 |
|
|
|
84 |
|
|
@ViewChild (ModalLoading) loading : ModalLoading ;
|
85 |
|
|
// Alert box when something is wrong with CSV requests
|
86 |
|
|
@ViewChild('AlertModalCsvError') alertCsvError;
|
87 |
|
|
|
88 |
|
|
sub: any; piwiksub: any; infoSub: any; downloadFilePiwikSub: any;
|
89 |
50586
|
argiro.kok
|
properties:EnvProperties;
|
90 |
50169
|
argiro.kok
|
constructor ( private element: ElementRef,
|
91 |
|
|
private _projectService: ProjectService,
|
92 |
|
|
private _piwikService:PiwikService,
|
93 |
|
|
private route: ActivatedRoute,
|
94 |
|
|
private _searchPublicationsService: SearchPublicationsService,
|
95 |
|
|
private _searchDatasetsService: SearchDatasetsService,
|
96 |
|
|
private _searchSoftwareService: SearchSoftwareService,
|
97 |
|
|
private _reportsService: ReportsService, private _meta: Meta,
|
98 |
|
|
private _router: Router) {
|
99 |
|
|
}
|
100 |
|
|
|
101 |
|
|
ngOnInit() {
|
102 |
50586
|
argiro.kok
|
this.route.data
|
103 |
|
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
104 |
|
|
this.properties = data.envSpecific;
|
105 |
|
|
this.updateUrl(data.envSpecific.baseLink+this._router.url);
|
106 |
|
|
|
107 |
|
|
});
|
108 |
50169
|
argiro.kok
|
this.sub = this.route.queryParams.subscribe(params => {
|
109 |
|
|
this.metricsClicked = false;
|
110 |
|
|
this.statsClicked = false;
|
111 |
|
|
this.fetchPublications = new FetchPublications( this._searchPublicationsService);
|
112 |
|
|
this.fetchDatasets = new FetchDatasets(this._searchDatasetsService);
|
113 |
|
|
this.fetchSoftware = new FetchSoftware(this._searchSoftwareService);
|
114 |
|
|
|
115 |
|
|
this.updateTitle("Project");
|
116 |
|
|
this.updateDescription("project, funding, open access, publications, research data, software");
|
117 |
|
|
|
118 |
|
|
this.projectId = params['projectId'];
|
119 |
51318
|
argiro.kok
|
var grantId = params['grantId'];
|
120 |
|
|
var funder = params['funder'];
|
121 |
50169
|
argiro.kok
|
|
122 |
|
|
|
123 |
51318
|
argiro.kok
|
if(this.projectId){
|
124 |
|
|
this.getProjectInfo(this.projectId);
|
125 |
|
|
this.actionsAfterLoadId();
|
126 |
|
|
}else if(grantId && funder){
|
127 |
|
|
this.getProjectInfoByGrantId(grantId,funder);
|
128 |
|
|
}else{
|
129 |
50169
|
argiro.kok
|
|
130 |
|
|
this.showLoading = false;
|
131 |
|
|
this.warningMessage="No valid project id";
|
132 |
|
|
}
|
133 |
|
|
|
134 |
50586
|
argiro.kok
|
this.downloadURLAPI = this.properties.csvAPIURL;
|
135 |
50169
|
argiro.kok
|
|
136 |
|
|
this.createClipboard();
|
137 |
50586
|
argiro.kok
|
this.csvParams = "?format=csv-special&type=publications&fq=(((oaftype exact result) and (resulttypeid exact publication)) and (relprojectid exact "+this.projectId+"))";
|
138 |
|
|
this.csvParamsDatasets = "?format=csv-special&type=datasets&fq=(((oaftype exact result) and (resulttypeid exact dataset)) and (relprojectid exact "+this.projectId+"))";
|
139 |
|
|
this.csvParamsSoftware = "?format=csv-special&type=software&fq=(((oaftype exact result) and (resulttypeid exact software)) and (relprojectid exact "+this.projectId+"))";
|
140 |
50169
|
argiro.kok
|
|
141 |
|
|
if (typeof document !== 'undefined') {
|
142 |
|
|
this.element.nativeElement.scrollIntoView();
|
143 |
|
|
}
|
144 |
|
|
});
|
145 |
|
|
}
|
146 |
|
|
|
147 |
51318
|
argiro.kok
|
actionsAfterLoadId(){
|
148 |
|
|
this.publications_dynamic =
|
149 |
|
|
"<script type=\"text/javascript\">"
|
150 |
|
|
+ "\n<!--"
|
151 |
|
|
+ "\ndocument.write('<div id=\"oa_widget\"></div>');"
|
152 |
|
|
+ "\ndocument.write('<script type=\"text/javascript\""
|
153 |
|
|
+ "\nsrc=\"https://beta.openaire.eu/index.php?option=com_openaire&view=widget&format=raw&projectId="
|
154 |
|
|
+ this.projectId + "&type=publication\"></script>');"
|
155 |
|
|
+ "\n-->"
|
156 |
|
|
+ "\n</script>";
|
157 |
50169
|
argiro.kok
|
|
158 |
51318
|
argiro.kok
|
this.datasets_dynamic =
|
159 |
|
|
"<script type=\"text/javascript\">"
|
160 |
|
|
+ "\n<!--"
|
161 |
|
|
+ "\ndocument.write('<div id=\"oa_widget\"></div>');"
|
162 |
|
|
+ "\ndocument.write('<script type=\"text/javascript\""
|
163 |
|
|
+ "\nsrc=\"https://beta.openaire.eu/index.php?option=com_openaire&view=widget&format=raw&projectId="
|
164 |
|
|
+ this.projectId + "&type=dataset\"></script>');"
|
165 |
|
|
+ "\n-->"
|
166 |
|
|
+ "\n</script>";
|
167 |
|
|
|
168 |
|
|
this.software_dynamic =
|
169 |
|
|
"<script type=\"text/javascript\">"
|
170 |
|
|
+ "\n<!--"
|
171 |
|
|
+ "\ndocument.write('<div id=\"oa_widget\"></div>');"
|
172 |
|
|
+ "\ndocument.write('<script type=\"text/javascript\""
|
173 |
|
|
+ "\nsrc=\"https://beta.openaire.eu/index.php?option=com_openaire&view=widget&format=raw&projectId="
|
174 |
|
|
+ this.projectId + "&type=software\"></script>');"
|
175 |
|
|
+ "\n-->"
|
176 |
|
|
+ "\n</script>";
|
177 |
|
|
|
178 |
|
|
this.getProjectInfo(this.projectId);
|
179 |
|
|
this.searchPublications();
|
180 |
|
|
this.fetchDatasets.getNumForEntity("project", this.projectId, this.properties);
|
181 |
|
|
this.fetchSoftware.getNumForEntity("project", this.projectId, this.properties);
|
182 |
|
|
}
|
183 |
50169
|
argiro.kok
|
ngOnDestroy() {
|
184 |
|
|
this.sub.unsubscribe();
|
185 |
|
|
if(this.piwiksub){
|
186 |
|
|
this.piwiksub.unsubscribe();
|
187 |
|
|
}
|
188 |
|
|
if(this.infoSub) {
|
189 |
|
|
this.infoSub.unsubscribe();
|
190 |
|
|
}
|
191 |
|
|
if(this.downloadFilePiwikSub) {
|
192 |
|
|
this.downloadFilePiwikSub.unsubscribe();
|
193 |
|
|
}
|
194 |
|
|
}
|
195 |
|
|
|
196 |
|
|
private createClipboard() {
|
197 |
|
|
if(typeof window !== 'undefined') {
|
198 |
|
|
|
199 |
|
|
let publ_clipboard, datasets_clipboard, software_clipboard;
|
200 |
|
|
let Clipboard;
|
201 |
|
|
Clipboard = require('clipboard');
|
202 |
|
|
publ_clipboard = new Clipboard('.publ_clipboard_btn');
|
203 |
|
|
datasets_clipboard = new Clipboard('.datasets_clipboard_btn');
|
204 |
|
|
software_clipboard = new Clipboard('.software_clipboard_btn');
|
205 |
|
|
}
|
206 |
|
|
}
|
207 |
|
|
|
208 |
|
|
private searchPublications() {
|
209 |
50586
|
argiro.kok
|
this.fetchPublications.getResultsForEntity("project", this.projectId, 1, 10, this.properties);
|
210 |
|
|
this.linkToSearchPublications = this.properties.searchLinkToAdvancedPublications;// + "?project=" + this.projectId+"&pr=and";
|
211 |
50169
|
argiro.kok
|
if(this.fetchPublications.searchUtils.totalResults > 0) {
|
212 |
|
|
//this.activeTab = "Publications";
|
213 |
|
|
} else {
|
214 |
|
|
//this.searchDatasetsInit();
|
215 |
|
|
}
|
216 |
|
|
}
|
217 |
|
|
|
218 |
|
|
private searchDatasets() {
|
219 |
50586
|
argiro.kok
|
this.fetchDatasets.getResultsForEntity("project", this.projectId, 1, 10, this.properties);
|
220 |
|
|
this.linkToSearchDatasets = this.properties.searchLinkToAdvancedDatasets;// + "?project=" + this.projectId+"&pr=and";
|
221 |
50169
|
argiro.kok
|
|
222 |
|
|
this.reloadDatasets = false;
|
223 |
|
|
//this.activeTab = "Research Data";
|
224 |
|
|
}
|
225 |
|
|
|
226 |
|
|
private searchSoftware() {
|
227 |
50586
|
argiro.kok
|
this.fetchSoftware.getResultsForEntity("project", this.projectId, 1, 10, this.properties);
|
228 |
|
|
this.linkToSearchSoftware = this.properties.searchLinkToAdvancedSoftware;
|
229 |
50169
|
argiro.kok
|
this.reloadSoftware = false;
|
230 |
|
|
}
|
231 |
|
|
|
232 |
|
|
public searchDatasetsInit() {
|
233 |
|
|
console.info("searchDatasetsInit");
|
234 |
|
|
if(this.reloadDatasets && this.fetchDatasets.searchUtils.totalResults > 0) {
|
235 |
|
|
this.searchDatasets();
|
236 |
|
|
} else if(this.fetchDatasets.searchUtils.totalResults == 0) {
|
237 |
|
|
//this.statsClicked=true;
|
238 |
|
|
//this.activeTab = "Statistics";
|
239 |
|
|
}
|
240 |
|
|
}
|
241 |
|
|
|
242 |
|
|
public searchSoftwareInit() {
|
243 |
|
|
console.info("searchSoftwareInit");
|
244 |
|
|
if(this.reloadSoftware && this.fetchSoftware.searchUtils.totalResults > 0) {
|
245 |
|
|
this.searchSoftware();
|
246 |
|
|
}
|
247 |
|
|
}
|
248 |
|
|
|
249 |
|
|
private getProjectInfo (id:string) {
|
250 |
|
|
this.warningMessage = '';
|
251 |
|
|
this.errorMessage=""
|
252 |
|
|
this.showLoading = true;
|
253 |
51318
|
argiro.kok
|
var funder = "EC";
|
254 |
|
|
var grantId ="654142";
|
255 |
50169
|
argiro.kok
|
|
256 |
50586
|
argiro.kok
|
this.infoSub = this._projectService.getProjectInfo(id, this.properties).subscribe(
|
257 |
50169
|
argiro.kok
|
data => {
|
258 |
|
|
this.projectInfo = data;
|
259 |
|
|
|
260 |
51318
|
argiro.kok
|
this.actionsAfterGettingProjectInfo();
|
261 |
50169
|
argiro.kok
|
},
|
262 |
|
|
err => {
|
263 |
|
|
console.log(err);
|
264 |
|
|
this.errorMessage = 'No project found';
|
265 |
|
|
this.showLoading = false;
|
266 |
|
|
}
|
267 |
|
|
);
|
268 |
|
|
}
|
269 |
51318
|
argiro.kok
|
private getProjectInfoByGrantId (grantId:string, funder:string) {
|
270 |
|
|
this.warningMessage = '';
|
271 |
|
|
this.errorMessage=""
|
272 |
|
|
this.showLoading = true;
|
273 |
50169
|
argiro.kok
|
|
274 |
51318
|
argiro.kok
|
this._projectService.getProjectInfoByGrantId(grantId,funder,this.properties).subscribe(
|
275 |
|
|
data =>{
|
276 |
|
|
|
277 |
|
|
this.projectInfo = data;
|
278 |
|
|
|
279 |
|
|
this.actionsAfterGettingProjectInfo();
|
280 |
|
|
this.projectId = this.projectInfo.id;
|
281 |
|
|
this.actionsAfterLoadId();
|
282 |
|
|
},
|
283 |
|
|
err => {
|
284 |
|
|
console.log(err);
|
285 |
|
|
this.errorMessage = 'No project found';
|
286 |
|
|
this.showLoading = false;
|
287 |
|
|
}
|
288 |
|
|
);
|
289 |
|
|
}
|
290 |
|
|
actionsAfterGettingProjectInfo(){
|
291 |
|
|
this.projectName = this.projectInfo.acronym;
|
292 |
|
|
if(this.projectName == undefined || this.projectName == '') {
|
293 |
|
|
this.projectName = this.projectInfo.title;
|
294 |
|
|
}
|
295 |
|
|
this.updateTitle(this.projectName);
|
296 |
|
|
this.updateDescription("project, funding, open access, publications, research data, "+this.projectName+ ","+this.projectInfo.funder);
|
297 |
|
|
if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
|
298 |
51746
|
argiro.kok
|
this.piwiksub = this._piwikService.trackView(this.properties, this.projectName, this.piwikSiteId).subscribe();
|
299 |
51318
|
argiro.kok
|
}
|
300 |
|
|
|
301 |
|
|
this.project= { funderId: "", funderName: this.projectInfo.funder, projectId: this.projectId, projectName: this.projectInfo.title, projectAcronym: this.projectInfo.acronym, startDate: this.projectInfo.startDate, endDate: this.projectInfo.endDate };
|
302 |
|
|
|
303 |
|
|
this.viewsFrameUrl = this.properties.framesAPIURL+'merge.php?com=query&data=[{"query":"projRepoViews","projTitle":"'+this.projectId+'","table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"","yaxisheaders":["Monthly views"],"generalxaxis":"","theme":0,"in":[]}]&info_types=["column"]&stacking=&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(124, 181, 236, 1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false';
|
304 |
|
|
|
305 |
|
|
this.downloadsFrameUrl = this.properties.framesAPIURL+'merge.php?com=query&data=[{"query":"projRepoDownloads","projTitle":"'+this.projectId+'","table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"","yaxisheaders":["Monthly downloads"],"generalxaxis":"","theme":0,"in":[]}]&info_types=["column"]&stacking=&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(124, 181, 236, 1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false';
|
306 |
|
|
|
307 |
|
|
//stats tab charts
|
308 |
|
|
this.chartScientificResultsUrl='https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"projScient","projTitle":"'+this.projectId+'", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "spline", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Research Results"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [" "], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=600&h=250';
|
309 |
|
|
this.chartAccessModeUrl='https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"projOA","projTitle":"'+this.projectId+'", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "pie", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Research Results"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [" "], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=600&h=250';
|
310 |
|
|
this.chartDatasourcesUrl= 'https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"projPubsRepos","projTitle":"'+this.projectId+'", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "bar", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Research Results"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [" "], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=600&h=250';
|
311 |
|
|
|
312 |
|
|
this.showLoading = false;
|
313 |
|
|
}
|
314 |
50169
|
argiro.kok
|
public downloadfile(url:string){
|
315 |
|
|
this.openLoading();
|
316 |
|
|
this.setMessageLoading("Downloading CSV file");
|
317 |
|
|
|
318 |
|
|
this._reportsService.downloadCSVFile(url).subscribe(
|
319 |
|
|
data => {
|
320 |
|
|
this.closeLoading();
|
321 |
|
|
window.open(window.URL.createObjectURL(data));
|
322 |
50586
|
argiro.kok
|
if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
|
323 |
50761
|
argiro.kok
|
this.downloadFilePiwikSub = this._piwikService.trackDownload(this.properties, url).subscribe();
|
324 |
50169
|
argiro.kok
|
}
|
325 |
|
|
},
|
326 |
|
|
error => {
|
327 |
|
|
console.log("Error downloading the file.");
|
328 |
|
|
this.closeLoading();
|
329 |
|
|
this.confirmOpenCsvError();
|
330 |
|
|
},
|
331 |
|
|
() => console.log('Completed file download.')
|
332 |
|
|
);
|
333 |
|
|
}
|
334 |
|
|
|
335 |
|
|
/*
|
336 |
|
|
showHTML(){
|
337 |
|
|
let info:string = "<h1>Publications of Project ";
|
338 |
|
|
|
339 |
|
|
if(this.projectInfo.title != undefined && this.projectInfo.title != "") {
|
340 |
|
|
info += this.projectInfo.title;
|
341 |
|
|
}
|
342 |
|
|
if((this.projectInfo.title != undefined && this.projectInfo.title != "") &&
|
343 |
|
|
((this.projectInfo.acronym != undefined && this.projectInfo.acronym != "") ||
|
344 |
|
|
(this.projectInfo.callIdentifier != undefined && this.projectInfo.callIdentifier != ""))) {
|
345 |
|
|
info += "(";
|
346 |
|
|
}
|
347 |
|
|
if(this.projectInfo.acronym != undefined && this.projectInfo.acronym != "") {
|
348 |
|
|
info += this.projectInfo.acronym + " - ";
|
349 |
|
|
}
|
350 |
|
|
if(this.projectInfo.callIdentifier != undefined && this.projectInfo.callIdentifier != "") {
|
351 |
|
|
info += this.projectInfo.callIdentifier;
|
352 |
|
|
}
|
353 |
|
|
if((this.projectInfo.title != undefined && this.projectInfo.title != "") &&
|
354 |
|
|
((this.projectInfo.acronym != undefined && this.projectInfo.acronym != "") ||
|
355 |
|
|
(this.projectInfo.callIdentifier != undefined && this.projectInfo.callIdentifier != ""))) {
|
356 |
|
|
info += ")";
|
357 |
|
|
}
|
358 |
|
|
info +="</h1>";
|
359 |
|
|
info += "<h3>"+this.fetchPublications.searchUtils.totalResults+" publications</h3>";
|
360 |
|
|
|
361 |
|
|
let htmlParams = 'resources?format=html&page=0&size='+this.fetchPublications.searchUtils.totalResults+'&type=publications&query=(((oaftype exact result) and (resulttypeid exact publication)) and (relprojectid exact "'+this.projectId+'"))';
|
362 |
|
|
this._reportsService.downloadHTMLFile(this.downloadURLAPI+htmlParams, info)
|
363 |
|
|
.subscribe(data => this.funct(data),
|
364 |
|
|
error => console.log("Error downloading the file."),
|
365 |
|
|
() => console.log('Completed file download.'));
|
366 |
|
|
}
|
367 |
|
|
|
368 |
|
|
funct(data) {
|
369 |
|
|
var win = window.open(window.URL.createObjectURL(data));
|
370 |
|
|
}
|
371 |
|
|
*/
|
372 |
|
|
public metricsResults($event) {
|
373 |
|
|
this.totalViews = $event.totalViews;
|
374 |
|
|
this.totalDownloads = $event.totalDownloads;
|
375 |
|
|
this.pageViews = $event.pageViews;
|
376 |
|
|
}
|
377 |
|
|
|
378 |
|
|
private updateDescription(description:string){
|
379 |
|
|
this._meta.updateMeta("description", description);
|
380 |
|
|
this._meta.updateProperty("og:description", description);
|
381 |
|
|
}
|
382 |
|
|
private updateTitle(title:string){
|
383 |
|
|
var _prefix ="OpenAIRE | ";
|
384 |
|
|
var _title = _prefix + ((title.length> 50 ) ?title.substring(0,50):title);
|
385 |
|
|
this._meta.setTitle(_title );
|
386 |
|
|
this._meta.updateProperty("og:title",_title);
|
387 |
|
|
}
|
388 |
|
|
private updateUrl(url:string){
|
389 |
|
|
this._meta.updateProperty("og:url", url);
|
390 |
|
|
}
|
391 |
|
|
|
392 |
|
|
private openLoading(){
|
393 |
|
|
if(this.loading){
|
394 |
|
|
this.loading.open();
|
395 |
|
|
}
|
396 |
|
|
}
|
397 |
|
|
private closeLoading(){
|
398 |
|
|
if(this.loading){
|
399 |
|
|
this.loading.close();
|
400 |
|
|
}
|
401 |
|
|
}
|
402 |
|
|
private setMessageLoading(message: string){
|
403 |
|
|
if(this.loading){
|
404 |
|
|
this.loading.message = message;
|
405 |
|
|
}
|
406 |
|
|
}
|
407 |
|
|
|
408 |
|
|
public confirmOpenCsvError(){
|
409 |
|
|
this.alertCsvError.cancelButton = false;
|
410 |
|
|
this.alertCsvError.okButton = true;
|
411 |
|
|
this.alertCsvError.alertTitle = "ERROR DOWNLOADING CSV FILE";
|
412 |
|
|
this.alertCsvError.message = "There was an error in csv downloading. Please try again later.";
|
413 |
|
|
this.alertCsvError.okButtonText = "OK";
|
414 |
|
|
this.alertCsvError.open();
|
415 |
|
|
}
|
416 |
|
|
}
|