Project

General

Profile

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

    
7
import {Observable}                   from 'rxjs';
8

    
9
import {ProjectService}               from './project.service';
10
import {ProjectInfo}                  from '../../utils/entities/projectInfo';
11
import {RouterHelper}                 from '../../utils/routerHelper.class';
12

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

    
22
import {ModalLoading}                 from '../../utils/modal/loading.component';
23

    
24
import {ReportsService}               from '../../services/reports.service';
25
import {ErrorCodes}                   from '../../utils/properties/errorCodes'
26

    
27
import {PiwikService}                 from '../../utils/piwik/piwik.service';
28
import {EnvProperties}                from '../../utils/properties/env-properties';
29
import { SEOService } from '../../sharedComponents/SEO/SEO.service';
30
import {HelperFunctions} from "../../utils/HelperFunctions.class";
31

    
32
@Component({
33
    selector: 'project',
34
    templateUrl: 'project.component.html',
35
 })
36

    
37
export class ProjectComponent{
38
  @Input() piwikSiteId = null;
39
  public projectInfo: ProjectInfo;
40
  public projectId : string ;
41
  public projectName: string;
42

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

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

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

    
63
  public project ;
64

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

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

    
77
  // Active tab variable for responsiveness
78
  public activeTab: string = "Publications";
79

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

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

    
96
  public routerHelper:RouterHelper = new RouterHelper();
97
  public errorCodes:ErrorCodes = new ErrorCodes();
98

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

    
103
  sub: any; piwiksub: any; infoSub: any; downloadFilePiwikSub: any;
104
properties:EnvProperties;
105
  constructor ( private _projectService: ProjectService,
106
                private _piwikService:PiwikService,
107
                private  route: ActivatedRoute,
108
                private router: Router,
109
                private _searchPublicationsService: SearchPublicationsService,
110
                private _searchDatasetsService: SearchDatasetsService,
111
                private _searchSoftwareService: SearchSoftwareService,
112
                private _searchOrpsService: SearchOrpsService,
113
                private _reportsService: ReportsService,
114
                private _meta: Meta,
115
                private _title: Title,
116
                private _router: Router,
117
              private seoService: SEOService) {
118
  }
119

    
120
  ngOnInit() {
121
    this.route.data
122
      .subscribe((data: { envSpecific: EnvProperties }) => {
123
         this.properties = data.envSpecific;
124
         this.updateUrl(data.envSpecific.baseLink+this._router.url);
125

    
126
      });
127
    this.sub =  this.route.queryParams.subscribe(params => {
128
        this.metricsClicked = false;
129
        this.statsClicked = false;
130
        this.fetchPublications = new FetchPublications( this._searchPublicationsService);
131
        this.fetchDatasets = new FetchDatasets(this._searchDatasetsService);
132
        this.fetchSoftware = new FetchSoftware(this._searchSoftwareService);
133
        this.fetchOrps = new FetchOrps(this._searchOrpsService);
134

    
135
        var title = "Project";
136
        var description = "";
137

    
138
        this.updateTitle(title);
139
        this.updateDescription(description);
140
      this.projectId = params['projectId'];
141
      var grantId = params['grantId'];
142
      var funder = params['funder'];
143

    
144

    
145
       if(this.projectId){
146
         this.getProjectInfo(this.projectId);
147
         this.actionsAfterLoadId();
148
      }else if(grantId && funder){
149
        this.getProjectInfoByGrantId(grantId,funder);
150
      }else{
151

    
152
          this.showLoading = false;
153
		      this.warningMessage="No valid project id";
154
      }
155

    
156
      this.downloadURLAPI = this.properties.csvAPIURL;
157

    
158
      this.createClipboard();
159
      this.csvParams = "?format=csv-special&type=publications&fq=(((oaftype exact result) and (resulttypeid exact publication)) and (relprojectid exact \""+this.projectId+"\"))";
160
      this.csvParamsDatasets = "?format=csv-special&type=datasets&fq=(((oaftype exact result) and (resulttypeid exact dataset)) and (relprojectid exact \""+this.projectId+"\"))";
161
      this.csvParamsSoftware = "?format=csv-special&type=software&fq=(((oaftype exact result) and (resulttypeid exact software)) and (relprojectid exact \""+this.projectId+"\"))";
162
      this.csvParamsOrps = "?format=csv-special&type=other&fq=(((oaftype exact result) and (resulttypeid exact other)) and (relprojectid exact \""+this.projectId+"\"))";
163

    
164
      HelperFunctions.scroll();
165
  });
166
}
167

    
168
actionsAfterLoadId(){
169
  this.publications_dynamic =
170
       "<script type=\"text/javascript\">"
171
       + "\n<!--"
172
       + "\ndocument.write('<div id=\"oa_widget\"></div>');"
173
       + "\ndocument.write('<script type=\"text/javascript\""
174
       + " src=\""+this.properties.widgetLink
175
       + this.projectId + "&type=publication\"></script>');"
176
       + "\n-->"
177
       + "\n</script>";
178

    
179
   this.datasets_dynamic =
180
       "<script type=\"text/javascript\">"
181
       + "\n<!--"
182
       + "\ndocument.write('<div id=\"oa_widget\"></div>');"
183
       + "\ndocument.write('<script type=\"text/javascript\""
184
       + " src=\""+this.properties.widgetLink
185
       + this.projectId + "&type=dataset\"></script>');"
186
       + "\n-->"
187
       + "\n</script>";
188

    
189
   this.software_dynamic =
190
       "<script type=\"text/javascript\">"
191
       + "\n<!--"
192
       + "\ndocument.write('<div id=\"oa_widget\"></div>');"
193
       + "\ndocument.write('<script type=\"text/javascript\""
194
       + "\nsrc=\""+this.properties.widgetLink
195
       + this.projectId + "&type=software\"></script>');"
196
       + "\n-->"
197
       + "\n</script>";
198

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

    
209
 this.getProjectInfo(this.projectId);
210
 //this.searchPublications();
211
 this.fetchPublications.getNumForEntity("project", this.projectId, this.properties);
212
 this.fetchDatasets.getNumForEntity("project", this.projectId, this.properties);
213
 this.fetchSoftware.getNumForEntity("project", this.projectId, this.properties);
214
 this.fetchOrps.getNumForEntity("project", this.projectId, this.properties);
215
}
216
  ngOnDestroy() {
217
    if(this.sub){
218
      this.sub.unsubscribe();
219
    }
220
    if(this.piwiksub){
221
      this.piwiksub.unsubscribe();
222
    }
223
    if(this.infoSub) {
224
      this.infoSub.unsubscribe();
225
    }
226
    if(this.downloadFilePiwikSub) {
227
      this.downloadFilePiwikSub.unsubscribe();
228
    }
229
  }
230

    
231
  private createClipboard() {
232
      if(typeof window !== 'undefined') {
233

    
234
          let publ_clipboard, datasets_clipboard, software_clipboard, orps_clipboard;
235
          let Clipboard;
236
          Clipboard = require('clipboard');
237
          publ_clipboard = new Clipboard('.publ_clipboard_btn');
238
          datasets_clipboard = new Clipboard('.datasets_clipboard_btn');
239
          software_clipboard = new Clipboard('.software_clipboard_btn');
240
          orps_clipboard = new Clipboard('.orps_clipboard_btn');
241
      }
242
  }
243

    
244
  private searchPublications() {
245
    this.fetchPublications.getResultsForEntity("project", this.projectId, 1, 10, this.properties);
246
    this.linkToSearchPublications = this.properties.searchLinkToAdvancedPublications;// + "?project=" + this.projectId+"&pr=and";
247
    //if(this.fetchPublications.searchUtils.totalResults > 0) {
248
      //this.activeTab = "Publications";
249
    //} else {
250
      //this.searchDatasetsInit();
251
    //}
252
    this.reloadPublications = false;
253
  }
254

    
255
  private searchDatasets() {
256
      this.fetchDatasets.getResultsForEntity("project", this.projectId, 1, 10, this.properties);
257
      this.linkToSearchDatasets = this.properties.searchLinkToAdvancedDatasets;// + "?project=" + this.projectId+"&pr=and";
258

    
259
      this.reloadDatasets = false;
260
      //this.activeTab = "Research Data";
261
  }
262

    
263
  private searchSoftware() {
264
      this.fetchSoftware.getResultsForEntity("project", this.projectId, 1, 10, this.properties);
265
      this.linkToSearchSoftware = this.properties.searchLinkToAdvancedSoftware;
266
      this.reloadSoftware = false;
267
  }
268

    
269
  private searchOrps() {
270
      this.fetchOrps.getResultsForEntity("project", this.projectId, 1, 10, this.properties);
271
      this.linkToSearchOrps = this.properties.searchLinkToAdvancedOrps;
272
      this.reloadOrps = false;
273
  }
274

    
275
  public searchPublicationsInit() {
276
      if(this.reloadPublications && this.fetchPublications.searchUtils.totalResults > 0) {
277
        this.searchPublications();
278
      } else if(this.fetchPublications.searchUtils.totalResults == 0) {
279
        //this.statsClicked=true;
280
        //this.activeTab = "Statistics";
281
      }
282
  }
283

    
284
  public searchDatasetsInit() {
285
      if(this.reloadDatasets && this.fetchDatasets.searchUtils.totalResults > 0) {
286
	      this.searchDatasets();
287
      } else if(this.fetchDatasets.searchUtils.totalResults == 0) {
288
        //this.statsClicked=true;
289
        //this.activeTab = "Statistics";
290
      }
291
  }
292

    
293
  public searchSoftwareInit() {
294
      if(this.reloadSoftware && this.fetchSoftware.searchUtils.totalResults > 0) {
295
	      this.searchSoftware();
296
      }
297
  }
298

    
299
  public searchOrpsInit() {
300
      if(this.reloadOrps && this.fetchOrps.searchUtils.totalResults > 0) {
301
	      this.searchOrps();
302
      }
303
  }
304

    
305
  private getProjectInfo (id:string)  {
306
	  this.warningMessage = '';
307
    this.errorMessage=""
308
    this.showLoading = true;
309

    
310
    this.projectInfo = null;
311

    
312
    this.infoSub = this._projectService.getProjectInfo(id, this.properties).subscribe(
313
      data => {
314
          this.projectInfo = data;
315

    
316
          this.actionsAfterGettingProjectInfo();
317
      },
318
      err => {
319
		      //console.log(err);
320
          this.handleError("Error getting project for id: "+this.projectId, err);
321
        this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this.properties.searchLinkToProjects);
322
		      this.errorMessage = 'No project found';
323
          this.showLoading = false;
324
		  }
325
    );
326
   }
327
   private getProjectInfoByGrantId (grantId:string,  funder:string)  {
328
 	   this.warningMessage = '';
329
     this.errorMessage=""
330
     this.showLoading = true;
331

    
332
     this.projectInfo = null;
333

    
334
     this._projectService.getProjectInfoByGrantId(grantId,funder,this.properties).subscribe(
335
       data =>{
336

    
337
           this.projectInfo = data;
338

    
339
           this.actionsAfterGettingProjectInfo();
340
           this.projectId = this.projectInfo.id;
341
           this.actionsAfterLoadId();
342
       },
343
       err => {
344
 		      //console.log(err);
345
          this.handleError("Error getting project for grant id: "+grantId+" and funder: "+funder, err);
346
         this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this.properties.searchLinkToProjects);
347
 		      this.errorMessage = 'No project found';
348
          this.showLoading = false;
349
 		  }
350
     );
351
    }
352
actionsAfterGettingProjectInfo(){
353
  this.projectName = this.projectInfo.acronym;
354
  if(this.projectName == undefined || this.projectName == '') {
355
      this.projectName = this.projectInfo.title;
356
  }
357
  this.seoService.createLinkForCanonicalURL(this.properties.baseLink+this._router.url);
358
  this.updateTitle(this.projectName);
359
  this.updateDescription("project, "+this.projectName+ ","+this.projectInfo.funder+","+this.projectInfo.acronym);
360
  if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
361
    this.piwiksub = this._piwikService.trackView(this.properties, this.projectName, this.piwikSiteId).subscribe();
362
  }
363

    
364
  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 };
365

    
366
  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';
367

    
368
  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';
369

    
370
  //stats tab charts
371
  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=100%&h=250';
372
  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=100%&h=250';
373
  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=100%&h=250';
374

    
375
  this.showLoading = false;
376
}
377
   public downloadfile(url:string, filename: string){
378
       this.openLoading();
379
       this.setMessageLoading("Downloading CSV file");
380

    
381
       this._reportsService.downloadCSVFile(url).subscribe(
382
            data => {
383
                this.closeLoading();
384

    
385
                var url = window.URL.createObjectURL(data);
386
                var a = window.document.createElement('a');
387
                window.document.body.appendChild(a);
388
                a.setAttribute('style', 'display: none');
389
                a.href = url;
390
                a.download = filename+".csv";
391
                a.click();
392
                window.URL.revokeObjectURL(url);
393
                a.remove(); // remove the element
394

    
395
                //window.open(window.URL.createObjectURL(data));
396
                if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
397
                  this.downloadFilePiwikSub = this._piwikService.trackDownload(this.properties, url).subscribe();
398
                }
399
            },
400
            error => {
401
              //console.log("Error downloading the file.");
402
              this.handleError("Error downloading file: "+filename, error);
403

    
404
              this.closeLoading();
405
              this.confirmOpenCsvError();
406
            }/*,
407
            () => console.log('Completed file download.')*/
408
        );
409
    }
410

    
411
/*
412
    showHTML(){
413
      let info:string = "<h1>Publications of Project ";
414

    
415
      if(this.projectInfo.title != undefined && this.projectInfo.title != "") {
416
          info += this.projectInfo.title;
417
      }
418
      if((this.projectInfo.title != undefined && this.projectInfo.title != "") &&
419
         ((this.projectInfo.acronym != undefined && this.projectInfo.acronym != "") ||
420
          (this.projectInfo.callIdentifier != undefined && this.projectInfo.callIdentifier != ""))) {
421
                info += "(";
422
      }
423
      if(this.projectInfo.acronym != undefined && this.projectInfo.acronym != "") {
424
          info += this.projectInfo.acronym + " - ";
425
      }
426
      if(this.projectInfo.callIdentifier != undefined && this.projectInfo.callIdentifier != "") {
427
          info += this.projectInfo.callIdentifier;
428
      }
429
      if((this.projectInfo.title != undefined && this.projectInfo.title != "") &&
430
         ((this.projectInfo.acronym != undefined && this.projectInfo.acronym != "") ||
431
          (this.projectInfo.callIdentifier != undefined && this.projectInfo.callIdentifier != ""))) {
432
                info += ")";
433
      }
434
      info +="</h1>";
435
      info += "<h3>"+this.fetchPublications.searchUtils.totalResults+" publications</h3>";
436

    
437
      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+'"))';
438
      this._reportsService.downloadHTMLFile(this.downloadURLAPI+htmlParams, info)
439
          .subscribe(data => this.funct(data),
440
                      error => console.log("Error downloading the file."),
441
                      () => console.log('Completed file download.'));
442
     }
443

    
444
     funct(data) {
445
         var win = window.open(window.URL.createObjectURL(data));
446
     }
447
*/
448
    public metricsResults($event) {
449
      this.totalViews = $event.totalViews;
450
      this.totalDownloads = $event.totalDownloads;
451
      this.pageViews = $event.pageViews;
452
    }
453

    
454
    private updateDescription(description:string) {
455
      this._meta.updateTag({content:description},"name='description'");
456
      this._meta.updateTag({content:description},"property='og:description'");
457
    }
458
    private updateTitle(title:string) {
459
      var _prefix ="OpenAIRE | ";
460
      var _title = _prefix + ((title.length> 50 ) ?title.substring(0,50):title);
461
      this._title.setTitle(_title);
462
      this._meta.updateTag({content:_title},"property='og:title'");
463
    }
464
    private updateUrl(url:string) {
465
      this._meta.updateTag({content:url},"property='og:url'");
466
    }
467

    
468
    private openLoading(){
469
      if(this.loading){
470
        this.loading.open();
471
      }
472
    }
473
    private closeLoading(){
474
      if(this.loading){
475
        this.loading.close();
476
      }
477
    }
478
    private setMessageLoading(message: string){
479
      if(this.loading){
480
        this.loading.message = message;
481
      }
482
    }
483

    
484
    public confirmOpenCsvError(){
485
      this.alertCsvError.cancelButton = false;
486
      this.alertCsvError.okButton = true;
487
      this.alertCsvError.alertTitle = "ERROR DOWNLOADING CSV FILE";
488
      this.alertCsvError.message = "There was an error in csv downloading. Please try again later.";
489
      this.alertCsvError.okButtonText = "OK";
490
      this.alertCsvError.open();
491
    }
492

    
493
    private handleError(message: string, error) {
494
        console.error("Project Landing Page: "+message, error);
495
    }
496
  isRouteAvailable(routeToCheck:string){
497
    for (let i = 0; i < this.router.config.length; i++) {
498
      let routePath:string = this.router.config[i].path;
499
      if(routePath == routeToCheck){
500
        return true;
501
      }
502
    }
503
    return false;
504
  }
505
}
(2-2/5)