Project

General

Profile

1
import {Component, Input, ViewChild} from '@angular/core';
2
import {ActivatedRoute, Router} from '@angular/router';
3
import {Meta, Title} from '@angular/platform-browser';
4

    
5
import {ProjectService} from './project.service';
6
import {ProjectInfo} from '../../utils/entities/projectInfo';
7
import {RouterHelper} from '../../utils/routerHelper.class';
8

    
9
import {FetchPublications} from '../../utils/fetchEntitiesClasses/fetchPublications.class';
10
import {SearchPublicationsService} from '../../services/searchPublications.service';
11
import {FetchDatasets} from '../../utils/fetchEntitiesClasses/fetchDatasets.class';
12
import {SearchDatasetsService} from '../../services/searchDatasets.service';
13
import {FetchSoftware} from '../../utils/fetchEntitiesClasses/fetchSoftware.class';
14
import {SearchSoftwareService} from '../../services/searchSoftware.service';
15
import {FetchOrps} from '../../utils/fetchEntitiesClasses/fetchOrps.class';
16
import {SearchOrpsService} from '../../services/searchOrps.service';
17

    
18
import {ModalLoading} from '../../utils/modal/loading.component';
19

    
20
import {ReportsService} from '../../services/reports.service';
21
import {ErrorCodes} from '../../utils/properties/errorCodes'
22

    
23
import {PiwikService} from '../../utils/piwik/piwik.service';
24
import {EnvProperties} from '../../utils/properties/env-properties';
25
import {SEOService} from '../../sharedComponents/SEO/SEO.service';
26
import {HelperFunctions} from "../../utils/HelperFunctions.class";
27
import {HelperService} from "../../utils/helper/helper.service";
28

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

    
34
export class ProjectComponent {
35
  @Input() piwikSiteId = null;
36
  @Input() communityId = null;
37
  public projectInfo: ProjectInfo;
38
  public projectId: string;
39
  public projectName: string;
40

    
41
  // Metrics tab variables
42
  public metricsClicked: boolean;
43
  public viewsFrameUrl: string;
44
  public downloadsFrameUrl: string;
45
  private totalViews: number;
46
  private totalDownloads: number;
47
  private pageViews: number;
48

    
49
  // Statistics tab variables
50
  public statsClicked: boolean;
51
  public chartScientificResultsUrl: string;
52
  public chartAccessModeUrl: string;
53
  public chartDatasourcesUrl: string;
54

    
55
  // HTML variables in APP BOX
56
  public publications_dynamic: string;
57
  public datasets_dynamic: string;
58
  public software_dynamic: string;
59
  public orps_dynamic: string;
60

    
61
  public project;
62

    
63
  // CSV variables
64
  public downloadURLAPI: string;
65
  public csvParams: string;
66
  public csvParamsDatasets: string;
67
  public csvParamsSoftware: string;
68
  public csvParamsOrps: string;
69

    
70
  // Message variables
71
  public warningMessage = "";
72
  public errorMessage = "";
73
  public showLoading: boolean = true;
74

    
75
  // Active tab variable for responsiveness
76
  public activeTab: string = "Publications";
77

    
78
  // Request results for publications, research data and software only the one time (first time tab is clicked)
79
  private reloadPublications: boolean = true;
80
  private reloadDatasets: boolean = true;
81
  private reloadSoftware: boolean = true;
82
  private reloadOrps: boolean = true;
83

    
84
  // Variables for publications, research data, software tabs
85
  public fetchPublications: FetchPublications;
86
  public linkToSearchPublications = "";
87
  public fetchDatasets: FetchDatasets;
88
  public linkToSearchDatasets = "";
89
  public fetchSoftware: FetchSoftware;
90
  public linkToSearchSoftware = "";
91
  public fetchOrps: FetchOrps;
92
  public linkToSearchOrps = "";
93

    
94
  public routerHelper: RouterHelper = new RouterHelper();
95
  public errorCodes: ErrorCodes = new ErrorCodes();
96
  public pageContents = null;
97
  public divContents = null;
98

    
99
  @ViewChild(ModalLoading) loading: ModalLoading;
100
  // Alert box when something is wrong with CSV requests
101
  @ViewChild('AlertModalCsvError') alertCsvError;
102

    
103
  sub: any;
104
  piwiksub: any;
105
  infoSub: any;
106
  downloadFilePiwikSub: any;
107
  properties: EnvProperties;
108

    
109
  constructor(private _projectService: ProjectService,
110
              private _piwikService: PiwikService,
111
              private  route: ActivatedRoute,
112
              private router: Router,
113
              private _searchPublicationsService: SearchPublicationsService,
114
              private _searchDatasetsService: SearchDatasetsService,
115
              private _searchSoftwareService: SearchSoftwareService,
116
              private _searchOrpsService: SearchOrpsService,
117
              private _reportsService: ReportsService,
118
              private _meta: Meta,
119
              private _title: Title,
120
              private _router: Router,
121
              private helper: HelperService,
122
              private seoService: SEOService) {
123
  }
124

    
125
  ngOnInit() {
126
    this.route.data
127
      .subscribe((data: { envSpecific: EnvProperties }) => {
128
        this.properties = data.envSpecific;
129
        //this.getDivContents();
130
        this.getPageContents();
131
        this.updateUrl(data.envSpecific.baseLink + this._router.url);
132

    
133
      });
134
    this.sub = this.route.queryParams.subscribe(params => {
135
      this.metricsClicked = false;
136
      this.statsClicked = false;
137
      this.fetchPublications = new FetchPublications(this._searchPublicationsService);
138
      this.fetchDatasets = new FetchDatasets(this._searchDatasetsService);
139
      this.fetchSoftware = new FetchSoftware(this._searchSoftwareService);
140
      this.fetchOrps = new FetchOrps(this._searchOrpsService);
141

    
142
      var title = "Project";
143
      var description = "";
144

    
145
      this.updateTitle(title);
146
      this.updateDescription(description);
147
      this.projectId = params['projectId'];
148
      var grantId = params['grantId'];
149
      var funder = params['funder'];
150

    
151

    
152
      if (this.projectId) {
153
        this.getProjectInfo(this.projectId);
154
        this.actionsAfterLoadId();
155
      } else if (grantId && funder) {
156
        this.getProjectInfoByGrantId(grantId, funder);
157
      } else {
158

    
159
        this.showLoading = false;
160
        this.warningMessage = "No valid project id";
161
      }
162

    
163
      this.downloadURLAPI = this.properties.csvAPIURL;
164

    
165
      this.createClipboard();
166
      this.csvParams = "?format=csv-special&type=publications&fq=(((oaftype exact result) and (resulttypeid exact publication)) and (relprojectid exact \"" + this.projectId + "\"))";
167
      this.csvParamsDatasets = "?format=csv-special&type=datasets&fq=(((oaftype exact result) and (resulttypeid exact dataset)) and (relprojectid exact \"" + this.projectId + "\"))";
168
      this.csvParamsSoftware = "?format=csv-special&type=software&fq=(((oaftype exact result) and (resulttypeid exact software)) and (relprojectid exact \"" + this.projectId + "\"))";
169
      this.csvParamsOrps = "?format=csv-special&type=other&fq=(((oaftype exact result) and (resulttypeid exact other)) and (relprojectid exact \"" + this.projectId + "\"))";
170

    
171
      HelperFunctions.scroll();
172
    });
173
  }
174

    
175
  private getPageContents() {
176
    this.helper.getPageHelpContents(this._router.url, this.properties, this.communityId).subscribe(contents => {
177
      this.pageContents = contents;
178
    })
179
  }
180

    
181
  private getDivContents() {
182
    this.helper.getDivHelpContents(this._router.url, this.properties, this.communityId).subscribe(contents => {
183
      this.divContents = contents;
184
    })
185
  }
186

    
187
  actionsAfterLoadId() {
188
    this.publications_dynamic =
189
      "<script type=\"text/javascript\">"
190
      + "\n<!--"
191
      + "\ndocument.write('<div id=\"oa_widget\"></div>');"
192
      + "\ndocument.write('<script type=\"text/javascript\""
193
      + " src=\"" + this.properties.widgetLink
194
      + this.projectId + "&type=publication\"></script>');"
195
      + "\n-->"
196
      + "\n</script>";
197

    
198
    this.datasets_dynamic =
199
      "<script type=\"text/javascript\">"
200
      + "\n<!--"
201
      + "\ndocument.write('<div id=\"oa_widget\"></div>');"
202
      + "\ndocument.write('<script type=\"text/javascript\""
203
      + " src=\"" + this.properties.widgetLink
204
      + this.projectId + "&type=dataset\"></script>');"
205
      + "\n-->"
206
      + "\n</script>";
207

    
208
    this.software_dynamic =
209
      "<script type=\"text/javascript\">"
210
      + "\n<!--"
211
      + "\ndocument.write('<div id=\"oa_widget\"></div>');"
212
      + "\ndocument.write('<script type=\"text/javascript\""
213
      + "\nsrc=\"" + this.properties.widgetLink
214
      + this.projectId + "&type=software\"></script>');"
215
      + "\n-->"
216
      + "\n</script>";
217

    
218
    this.orps_dynamic =
219
      "<script type=\"text/javascript\">"
220
      + "\n<!--"
221
      + "\ndocument.write('<div id=\"oa_widget\"></div>');"
222
      + "\ndocument.write('<script type=\"text/javascript\""
223
      + "\nsrc=\"" + this.properties.widgetLink
224
      + this.projectId + "&type=other\"></script>');"
225
      + "\n-->"
226
      + "\n</script>";
227

    
228
    this.getProjectInfo(this.projectId);
229
    //this.searchPublications();
230
    this.fetchPublications.getNumForEntity("project", this.projectId, this.properties);
231
    this.fetchDatasets.getNumForEntity("project", this.projectId, this.properties);
232
    this.fetchSoftware.getNumForEntity("project", this.projectId, this.properties);
233
    this.fetchOrps.getNumForEntity("project", this.projectId, this.properties);
234
  }
235

    
236
  ngOnDestroy() {
237
    if (this.sub) {
238
      this.sub.unsubscribe();
239
    }
240
    if (this.piwiksub) {
241
      this.piwiksub.unsubscribe();
242
    }
243
    if (this.infoSub) {
244
      this.infoSub.unsubscribe();
245
    }
246
    if (this.downloadFilePiwikSub) {
247
      this.downloadFilePiwikSub.unsubscribe();
248
    }
249
  }
250

    
251
  private createClipboard() {
252
    if (typeof window !== 'undefined') {
253

    
254
      let publ_clipboard, datasets_clipboard, software_clipboard, orps_clipboard;
255
      let Clipboard;
256
      Clipboard = require('clipboard');
257
      publ_clipboard = new Clipboard('.publ_clipboard_btn');
258
      datasets_clipboard = new Clipboard('.datasets_clipboard_btn');
259
      software_clipboard = new Clipboard('.software_clipboard_btn');
260
      orps_clipboard = new Clipboard('.orps_clipboard_btn');
261
    }
262
  }
263

    
264
  private searchPublications() {
265
    this.fetchPublications.getResultsForEntity("project", this.projectId, 1, 10, this.properties);
266
    this.linkToSearchPublications = this.properties.searchLinkToAdvancedPublications;// + "?project=" + this.projectId+"&pr=and";
267
    //if(this.fetchPublications.searchUtils.totalResults > 0) {
268
    //this.activeTab = "Publications";
269
    //} else {
270
    //this.searchDatasetsInit();
271
    //}
272
    this.reloadPublications = false;
273
  }
274

    
275
  private searchDatasets() {
276
    this.fetchDatasets.getResultsForEntity("project", this.projectId, 1, 10, this.properties);
277
    this.linkToSearchDatasets = this.properties.searchLinkToAdvancedDatasets;// + "?project=" + this.projectId+"&pr=and";
278

    
279
    this.reloadDatasets = false;
280
    //this.activeTab = "Research Data";
281
  }
282

    
283
  private searchSoftware() {
284
    this.fetchSoftware.getResultsForEntity("project", this.projectId, 1, 10, this.properties);
285
    this.linkToSearchSoftware = this.properties.searchLinkToAdvancedSoftware;
286
    this.reloadSoftware = false;
287
  }
288

    
289
  private searchOrps() {
290
    this.fetchOrps.getResultsForEntity("project", this.projectId, 1, 10, this.properties);
291
    this.linkToSearchOrps = this.properties.searchLinkToAdvancedOrps;
292
    this.reloadOrps = false;
293
  }
294

    
295
  public searchPublicationsInit() {
296
    if (this.reloadPublications && this.fetchPublications.searchUtils.totalResults > 0) {
297
      this.searchPublications();
298
    } else if (this.fetchPublications.searchUtils.totalResults == 0) {
299
      //this.statsClicked=true;
300
      //this.activeTab = "Statistics";
301
    }
302
  }
303

    
304
  public searchDatasetsInit() {
305
    if (this.reloadDatasets && this.fetchDatasets.searchUtils.totalResults > 0) {
306
      this.searchDatasets();
307
    } else if (this.fetchDatasets.searchUtils.totalResults == 0) {
308
      //this.statsClicked=true;
309
      //this.activeTab = "Statistics";
310
    }
311
  }
312

    
313
  public searchSoftwareInit() {
314
    if (this.reloadSoftware && this.fetchSoftware.searchUtils.totalResults > 0) {
315
      this.searchSoftware();
316
    }
317
  }
318

    
319
  public searchOrpsInit() {
320
    if (this.reloadOrps && this.fetchOrps.searchUtils.totalResults > 0) {
321
      this.searchOrps();
322
    }
323
  }
324

    
325
  private getProjectInfo(id: string) {
326
    this.warningMessage = '';
327
    this.errorMessage = ""
328
    this.showLoading = true;
329

    
330
    this.projectInfo = null;
331

    
332
    this.infoSub = this._projectService.getProjectInfo(id, this.properties).subscribe(
333
      data => {
334
        this.projectInfo = data;
335

    
336
        this.actionsAfterGettingProjectInfo();
337
      },
338
      err => {
339
        //console.log(err);
340
        this.handleError("Error getting project for id: " + this.projectId, err);
341
        this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this.properties.searchLinkToProjects);
342
        this.errorMessage = 'No project found';
343
        this.showLoading = false;
344
      }
345
    );
346
  }
347

    
348
  private getProjectInfoByGrantId(grantId: string, funder: string) {
349
    this.warningMessage = '';
350
    this.errorMessage = ""
351
    this.showLoading = true;
352

    
353
    this.projectInfo = null;
354

    
355
    this._projectService.getProjectInfoByGrantId(grantId, funder, this.properties).subscribe(
356
      data => {
357

    
358
        this.projectInfo = data;
359

    
360
        this.actionsAfterGettingProjectInfo();
361
        this.projectId = this.projectInfo.id;
362
        this.actionsAfterLoadId();
363
      },
364
      err => {
365
        //console.log(err);
366
        this.handleError("Error getting project for grant id: " + grantId + " and funder: " + funder, err);
367
        this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this.properties.searchLinkToProjects);
368
        this.errorMessage = 'No project found';
369
        this.showLoading = false;
370
      }
371
    );
372
  }
373

    
374
  actionsAfterGettingProjectInfo() {
375
    this.projectName = this.projectInfo.acronym;
376
    if (this.projectName == undefined || this.projectName == '') {
377
      this.projectName = this.projectInfo.title;
378
    }
379
    this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this._router.url);
380
    this.updateTitle(this.projectName);
381
    this.updateDescription("project, " + this.projectName + "," + this.projectInfo.funder + "," + this.projectInfo.acronym);
382
    if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
383
      this.piwiksub = this._piwikService.trackView(this.properties, this.projectName, this.piwikSiteId).subscribe();
384
    }
385

    
386
    this.project = {
387
      funderId: "",
388
      funderName: this.projectInfo.funder,
389
      projectId: this.projectId,
390
      projectName: this.projectInfo.title,
391
      projectAcronym: this.projectInfo.acronym,
392
      startDate: this.projectInfo.startDate,
393
      endDate: this.projectInfo.endDate
394
    };
395

    
396
    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';
397

    
398
    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';
399

    
400
    //stats tab charts
401
    this.chartScientificResultsUrl = this.properties.statisticsFrameAPIURL + '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=90%&h=90%';
402
    this.chartAccessModeUrl = this.properties.statisticsFrameAPIURL + '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=90%&h=90%';
403
    this.chartDatasourcesUrl = this.properties.statisticsFrameAPIURL + '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=90%&h=90%';
404

    
405
    this.showLoading = false;
406
  }
407

    
408
  public downloadfile(url: string, filename: string) {
409
    this.openLoading();
410
    this.setMessageLoading("Downloading CSV file");
411

    
412
    this._reportsService.downloadCSVFile(url).subscribe(
413
      data => {
414
        this.closeLoading();
415

    
416
        var url = window.URL.createObjectURL(data);
417
        var a = window.document.createElement('a');
418
        window.document.body.appendChild(a);
419
        a.setAttribute('style', 'display: none');
420
        a.href = url;
421
        a.download = filename + ".csv";
422
        a.click();
423
        window.URL.revokeObjectURL(url);
424
        a.remove(); // remove the element
425

    
426
        //window.open(window.URL.createObjectURL(data));
427
        if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
428
          this.downloadFilePiwikSub = this._piwikService.trackDownload(this.properties, url).subscribe();
429
        }
430
      },
431
      error => {
432
        //console.log("Error downloading the file.");
433
        this.handleError("Error downloading file: " + filename, error);
434

    
435
        this.closeLoading();
436
        this.confirmOpenCsvError();
437
      }/*,
438
            () => console.log('Completed file download.')*/
439
    );
440
  }
441

    
442
  /*
443
      showHTML(){
444
        let info:string = "<h1>Publications of Project ";
445

    
446
        if(this.projectInfo.title != undefined && this.projectInfo.title != "") {
447
            info += this.projectInfo.title;
448
        }
449
        if((this.projectInfo.title != undefined && this.projectInfo.title != "") &&
450
           ((this.projectInfo.acronym != undefined && this.projectInfo.acronym != "") ||
451
            (this.projectInfo.callIdentifier != undefined && this.projectInfo.callIdentifier != ""))) {
452
                  info += "(";
453
        }
454
        if(this.projectInfo.acronym != undefined && this.projectInfo.acronym != "") {
455
            info += this.projectInfo.acronym + " - ";
456
        }
457
        if(this.projectInfo.callIdentifier != undefined && this.projectInfo.callIdentifier != "") {
458
            info += this.projectInfo.callIdentifier;
459
        }
460
        if((this.projectInfo.title != undefined && this.projectInfo.title != "") &&
461
           ((this.projectInfo.acronym != undefined && this.projectInfo.acronym != "") ||
462
            (this.projectInfo.callIdentifier != undefined && this.projectInfo.callIdentifier != ""))) {
463
                  info += ")";
464
        }
465
        info +="</h1>";
466
        info += "<h3>"+this.fetchPublications.searchUtils.totalResults+" publications</h3>";
467

    
468
        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+'"))';
469
        this._reportsService.downloadHTMLFile(this.downloadURLAPI+htmlParams, info)
470
            .subscribe(data => this.funct(data),
471
                        error => console.log("Error downloading the file."),
472
                        () => console.log('Completed file download.'));
473
       }
474

    
475
       funct(data) {
476
           var win = window.open(window.URL.createObjectURL(data));
477
       }
478
  */
479
  public metricsResults($event) {
480
    this.totalViews = $event.totalViews;
481
    this.totalDownloads = $event.totalDownloads;
482
    this.pageViews = $event.pageViews;
483
  }
484

    
485
  private updateDescription(description: string) {
486
    this._meta.updateTag({content: description}, "name='description'");
487
    this._meta.updateTag({content: description}, "property='og:description'");
488
  }
489

    
490
  private updateTitle(title: string) {
491
    var _prefix = "";
492
    if(!this.communityId) {
493
      _prefix = "OpenAIRE | ";
494
    }
495
    var _title = _prefix + ((title.length > 50) ? title.substring(0, 50) : title);
496
    this._title.setTitle(_title);
497
    this._meta.updateTag({content: _title}, "property='og:title'");
498
  }
499

    
500
  private updateUrl(url: string) {
501
    this._meta.updateTag({content: url}, "property='og:url'");
502
  }
503

    
504
  private openLoading() {
505
    if (this.loading) {
506
      this.loading.open();
507
    }
508
  }
509

    
510
  private closeLoading() {
511
    if (this.loading) {
512
      this.loading.close();
513
    }
514
  }
515

    
516
  private setMessageLoading(message: string) {
517
    if (this.loading) {
518
      this.loading.message = message;
519
    }
520
  }
521

    
522
  public confirmOpenCsvError() {
523
    this.alertCsvError.cancelButton = false;
524
    this.alertCsvError.okButton = true;
525
    this.alertCsvError.alertTitle = "ERROR DOWNLOADING CSV FILE";
526
    this.alertCsvError.message = "There was an error in csv downloading. Please try again later.";
527
    this.alertCsvError.okButtonText = "OK";
528
    this.alertCsvError.open();
529
  }
530

    
531
  private handleError(message: string, error) {
532
    console.error("Project Landing Page: " + message, error);
533
  }
534

    
535
  isRouteAvailable(routeToCheck: string) {
536
    for (let i = 0; i < this.router.config.length; i++) {
537
      let routePath: string = this.router.config[i].path;
538
      if (routePath == routeToCheck) {
539
        return true;
540
      }
541
    }
542
    return false;
543
  }
544
}
(2-2/5)