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 {InlineClaimResultComponent} from '../../claimPages/inlineClaims/inlineClaimResult.component';
7

    
8
import { SearchPublicationsComponent } from '../../searchPages/simple/searchPublications.component';
9
import {SearchPublicationsService} from '../../services/searchPublications.service';
10
import { SearchDatasetsComponent } from '../../searchPages/simple/searchDatasets.component';
11
import { SearchDatasetsService } from '../../services/searchDatasets.service';
12
import {SearchResultComponent} from '../../searchPages/searchUtils/searchResult.component';
13

    
14
import {OpenaireProperties} from '../../utils/properties/openaireProperties';
15

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

    
22

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

    
33
  private project ;
34

    
35
   /*@ViewChild (InlineClaimResultComponent) inlineClaimResult : InlineClaimResultComponent ;*/
36

    
37

    
38
  public warningMessage = "";
39
  public errorMessage = "";
40

    
41
  sub: any;
42
  subPublications: any;
43
  subDatasets: any;
44
  subDatasetsCount: any;
45

    
46
  private searchPublicationsComponent : SearchPublicationsComponent;
47
  private linkToSearchPublications = "";
48
  private searchDatasetsComponent : SearchDatasetsComponent;
49
  private linkToSearchDatasets = "";
50

    
51
  constructor (private _projectService: ProjectService,
52
      private  route: ActivatedRoute,
53
      private _searchPublicationsService: SearchPublicationsService,
54
      private _searchDatasetsService: SearchDatasetsService) {
55
    console.info('project constructor.');
56

    
57
    this.searchPublicationsComponent = new SearchPublicationsComponent(this.route, this._searchPublicationsService);
58
    this.searchDatasetsComponent = new SearchDatasetsComponent(this.route, this._searchDatasetsService);
59
  }
60

    
61
  ngOnInit() {
62
      this.metricsClicked = false;
63
      this.statsClicked = false;
64

    
65
    this.sub =  this.route.queryParams.subscribe(params => {
66
      this.projectId = params['projectId'];
67
       console.info("Id is :"+this.projectId);
68
       if(this.projectId){
69
          this.getProjectInfo(this.projectId);
70
          //  this.subPublications =  this.route.queryParams.subscribe(params => {
71
          this.searchPublications();
72
          //  });
73

    
74
          this.subDatasetsCount = this._searchDatasetsService.numOfEntityDatasets(this.projectId, "projects/").subscribe(
75
            data => {
76
              this.searchDatasetsComponent.searchUtils.totalResults = data;
77
            },
78
            err => {
79
              console.log(err);
80
            });
81
      }else{
82
		      this.warningMessage="No valid project id";
83
      }
84

    
85
  });
86

    
87
}
88

    
89

    
90
  ngOnDestroy() {
91
    this.sub.unsubscribe();
92
    // if(this.subPublications != undefined) {
93
    //   this.subPublications.unsubscribe();
94
    // }
95
    // if(this.subDatasets != undefined) {
96
    //     this.subDatasets.unsubscribe();
97
    // }
98
    this.subDatasetsCount.unsubscribe();
99
  }
100

    
101
  private searchPublications() {
102
    this.searchPublicationsComponent.getResultsForEntity("project", this.projectId, 1, 10);
103
    this.linkToSearchPublications = OpenaireProperties.getLinkToAdvancedSearchPublications() + "?project=" + this.projectId+"&pr=and";
104
  }
105

    
106
  private searchDatasets() {
107
      this.searchDatasetsComponent.getResultsForEntity("project", this.projectId, 1, 10);
108
      this.linkToSearchDatasets = OpenaireProperties.getLinkToAdvancedSearchDatasets() + "?project=" + this.projectId+"&pr=and";
109
  }
110

    
111
  private searchDatasetsInit() {
112
      if(this.subDatasets == undefined && this.searchDatasetsComponent.searchUtils.totalResults > 0) {
113
          // this.subDatasets =  this.route.queryParams.subscribe(params => {
114
               this.searchDatasets();
115
          // });
116
      }
117
  }
118

    
119
  getProjectInfo (id:string)  {
120
    console.info("inside getProjectInfo of component");
121
	this.warningMessage = '';
122
    this.errorMessage=""
123
    this._projectService.getProjectInfo(id).subscribe(
124
      data => {
125
          this.projectInfo = data;
126
          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 };
127

    
128
          this.projectName = (this.projectInfo.acronym != undefined && this.projectInfo.acronym != '') ? this.projectInfo.acronym : this.projectInfo.title;
129
          this.viewsFrameUrl = ('http://vaggelas.athenarc.gr/stats/merge.php?com=query&data=[{"table":"project_stats_monthly","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":"Number of views for project '+this.projectName+'","yaxisheaders":["sum of views"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"id","values":["'+this.projectId+'"],"to":"-1"}]}]&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');
130
          //stats tab charts
131
          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';
132
          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';
133
          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';
134
      },
135
      err => {
136
		console.log(err);
137
		this.errorMessage = 'No project found';
138
		}
139
    );
140
   }
141

    
142
      /*
143
      ********* Methods for Inline Claim  of results *****
144
        */
145
    /*  toggleClaimResult(){
146
          this.inlineClaimResult.toggle();
147
      }
148
      publicationAdded($event){
149
       //TODO
150
       }
151

    
152
       datasetAdded($event){
153
         var contexts =$event.value;
154

    
155
 //TODO
156
        }*/
157

    
158
}
(2-2/2)