Project

General

Profile

1
import {Component, Input} from '@angular/core';
2
import {Observable}       from 'rxjs/Observable';
3
import {ActivatedRoute, Router} from '@angular/router';
4
import {EntitiesSearchService} from '../../utils/entitiesAutoComplete/entitySearch.service';
5
import {ClaimProject, ClaimResult} from '../claim-utils/claimEntities.class';
6
import {SearchPublicationsService} from '../../services/searchPublications.service';
7
import {SearchDatasetsService} from '../../services/searchDatasets.service';
8
import { Meta} from '../../sharedComponents/metaService';
9
import{EnvProperties} from '../../utils/properties/env-properties';
10

    
11
declare var UIkit:any;
12

    
13
@Component({
14
    selector: 'linking-generic',
15
    templateUrl: 'linkingGeneric.component.html'
16

    
17
})
18
export class LinkingGenericComponent {
19

    
20
  @Input() bulkMode: boolean = false;
21
  sourceType:string;
22
  targetType:string;
23
  step:number = 1;
24
  contexts=[];
25
  projects=[];
26
   results = [];
27
  show = "project";
28
  date='8-6-2016';
29
  keyword: string = "";
30
  linkType:string ="project"; // link type (selected in home page) : project, context, software, etc
31
  /* url Parameters for inline linking */
32
  id:string = null; //entity id
33
  type:string = null; // entity type (publication or research data)
34
  linkTo:string = null; // entity type (project or context or result)
35

    
36
  entityTypes=["dataset", "publication", "project","context"];
37
  inlineResult:ClaimResult =null;
38
  sub:any =null;
39
  properties:EnvProperties;
40

    
41
  constructor ( private _router: Router,  private route: ActivatedRoute, private entitySearch:EntitiesSearchService,
42
    private publicationsSearch:SearchPublicationsService, private datasetsSearch:SearchDatasetsService, private _meta: Meta) {
43
      this._meta.setTitle("OpenAIRE | Linking");
44
  }
45
  ngOnInit() {
46
    this.route.data
47
      .subscribe((data: { envSpecific: EnvProperties }) => {
48
         this.properties = data.envSpecific;
49

    
50
      });
51
      if( typeof localStorage !== 'undefined') {
52
        if(localStorage.getItem("projects")){
53
          this.projects  = JSON.parse(localStorage.getItem("projects"));
54

    
55
        }
56
        if(localStorage.getItem("contexts")){
57
          this.contexts  = JSON.parse(localStorage.getItem("contexts"));
58
        }
59
        if(localStorage.getItem("results")){
60
          this.results  = JSON.parse(localStorage.getItem("results"));
61

    
62
        }
63
        localStorage.removeItem("projects");
64
        localStorage.removeItem("contexts");
65
        localStorage.removeItem("results");
66
    }
67
  }
68

    
69
  next(){
70

    
71
    if((this.show == 'result' && this.keyword == '')||(this.show == 'dataset' || this.show == 'publication')){
72
        this.show='claim';
73

    
74
    }
75
  }
76
  prev(){
77
  if(this.show == 'claim'){
78
      this.show='result';
79
    }
80
  }
81

    
82

    
83
  resultsChange($event) {
84
    this.results=$event.value;
85
  }
86

    
87
  projectsChange($event) {
88
    this.projects=$event.value;
89
  }
90

    
91
  linkTypeChange($event) {
92

    
93
    this.linkType =$event.value;
94
    this.show="result";
95
    if(this.bulkMode){
96
      this.show="claim";
97
    }
98
  }
99

    
100
  showChange($event) {
101
    this.show=$event.value;
102
    this.showChangedType($event.value);
103
  }
104

    
105
  showChangedType(type:string) {
106
    this.show=type;
107
     if(this.show == 'project' || this.show == 'context' || this.show == 'software'){
108
        this.linkType = this.show;
109
    }
110
  }
111

    
112
  canProceedToMetadata(){
113
    if(this.results.length == 0){
114

    
115
      UIkit.notification({
116
          message : 'No research results selected!<br>Please select research results to link with projects and/ or ommunities.',
117
          status  : 'warning',
118
          timeout : 1000,
119
          pos     : 'top-center'
120
      });
121
    }else{
122
      this.show = 'claim';
123
      this.step = 3;
124
    }
125
  }
126
}
(3-3/4)