Project

General

Profile

1
import {Component, ViewChild} from '@angular/core';
2
import {Observable} from 'rxjs/Observable';
3
import {ActivatedRoute, Params} from '@angular/router';
4
import {ProjectService} from '../../services/project.service';
5
import {ProjectInfo} from '../../utils/entities/projectInfo';
6
import { SearchPublicationsComponent } from '../../searchPages/simple/searchPublications.component';
7
import {SearchPublicationsService} from '../../services/searchPublications.service';
8
import { SearchDatasetsComponent } from '../../searchPages/simple/searchDatasets.component';
9
import { SearchDatasetsService } from '../../services/searchDatasets.service';
10
import {SearchResultComponent} from '../../searchPages/searchUtils/searchResult.component';
11

    
12
import {OpenaireProperties} from '../../utils/properties/openaireProperties';
13

    
14
@Component({
15
    selector: 'project',
16
    templateUrl: 'project.component.html',
17
 })
18
export class ProjectComponent{
19

    
20

    
21
  private projectId : string ;
22
  public projectInfo: ProjectInfo;
23
  private projectName: string;
24
  private metricsClicked: boolean;
25
  private viewsFrameUrl: string;
26
  private downloadsFrameUrl: string;
27
  private statsClicked: boolean;
28
  private chartScientificResultsUrl: string;
29
  private chartAccessModeUrl: string;
30
  private chartDatasourcesUrl: string;
31

    
32
  private project ;
33
  public warningMessage = "";
34
  public errorMessage = "";
35

    
36
  sub: any;
37
  subPublications: any;
38
  subDatasets: any;
39
  subDatasetsCount: any;
40

    
41
  private searchPublicationsComponent : SearchPublicationsComponent;
42
  private linkToSearchPublications = "";
43
  private searchDatasetsComponent : SearchDatasetsComponent;
44
  private linkToSearchDatasets = "";
45

    
46
  constructor (private _projectService: ProjectService,
47
      private  route: ActivatedRoute,
48
      private _searchPublicationsService: SearchPublicationsService,
49
      private _searchDatasetsService: SearchDatasetsService) {
50
    console.info('project constructor.');
51

    
52
    this.searchPublicationsComponent = new SearchPublicationsComponent(this.route, this._searchPublicationsService);
53
    this.searchDatasetsComponent = new SearchDatasetsComponent(this.route, this._searchDatasetsService);
54
  }
55

    
56
  ngOnInit() {
57
      this.metricsClicked = false;
58
      this.statsClicked = false;
59

    
60
    this.sub =  this.route.queryParams.subscribe(params => {
61
      this.projectId = params['projectId'];
62
       console.info("Id is :"+this.projectId);
63
       if(this.projectId){
64
          this.getProjectInfo(this.projectId);
65
          //  this.subPublications =  this.route.queryParams.subscribe(params => {
66
          this.searchPublications();
67
          //  });
68

    
69
          this.subDatasetsCount = this._searchDatasetsService.numOfEntityDatasets(this.projectId, "projects/").subscribe(
70
            data => {
71
              this.searchDatasetsComponent.searchUtils.totalResults = data;
72
            },
73
            err => {
74
              console.log(err);
75
            });
76
      }else{
77
		      this.warningMessage="No valid project id";
78
      }
79

    
80
  });
81

    
82
}
83

    
84

    
85
  ngOnDestroy() {
86
    this.sub.unsubscribe();
87
    this.subDatasetsCount.unsubscribe();
88
  }
89

    
90
  private searchPublications() {
91
    this.searchPublicationsComponent.getResultsForEntity("project", this.projectId, 1, 10);
92
    this.linkToSearchPublications = OpenaireProperties.getLinkToAdvancedSearchPublications() + "?project=" + this.projectId+"&pr=and";
93
  }
94

    
95
  private searchDatasets() {
96
      this.searchDatasetsComponent.getResultsForEntity("project", this.projectId, 1, 10);
97
      this.linkToSearchDatasets = OpenaireProperties.getLinkToAdvancedSearchDatasets() + "?project=" + this.projectId+"&pr=and";
98
  }
99

    
100
  private searchDatasetsInit() {
101
      if(this.subDatasets == undefined && this.searchDatasetsComponent.searchUtils.totalResults > 0) {
102
               this.searchDatasets();
103
      }
104
  }
105

    
106
  getProjectInfo (id:string)  {
107
    console.info("inside getProjectInfo of component");
108
	this.warningMessage = '';
109
    this.errorMessage=""
110
    this._projectService.getProjectInfo(id).subscribe(
111
      data => {
112
          this.projectInfo = data;
113
          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 };
114

    
115
          this.viewsFrameUrl = OpenaireProperties.getFramesAPIURL()+'merge.php?com=query&data=[{"query":"projViewsTimeline","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=["spline"]&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';
116
          this.downloadsFrameUrl = OpenaireProperties.getFramesAPIURL()+'merge.php?com=query&data=[{"query":"projDownloadsTimeline","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=["spline"]&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';
117
          //stats tab charts
118
          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": ["Publications"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [" "], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=600&h=250';
119
          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": ["Publications"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [" "], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=600&h=250';
120
          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": "column", "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": ["Publications"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [" "], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=600&h=250';
121
      },
122
      err => {
123
		console.log(err);
124
		this.errorMessage = 'No project found';
125
		}
126
    );
127
   }
128

    
129

    
130
}
(2-2/2)