Project

General

Profile

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

    
5
import {Observable}                   from 'rxjs/Observable';
6

    
7
import {EnvProperties}                from '../../utils/properties/env-properties';
8

    
9
import {ClaimProject, ClaimResult}    from '../claim-utils/claimEntities.class';
10

    
11
import {EntitiesSearchService}        from '../../utils/entitiesAutoComplete/entitySearch.service';
12
import {SearchPublicationsService}    from '../../services/searchPublications.service';
13
import {SearchDatasetsService}        from '../../services/searchDatasets.service';
14

    
15
declare var UIkit:any;
16

    
17
@Component({
18
    selector: 'linking-generic',
19
    templateUrl: 'linkingGeneric.component.html'
20

    
21
})
22
export class LinkingGenericComponent {
23

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

    
40
  entityTypes=["dataset", "publication", "project","context"];
41
  inlineResult:ClaimResult =null;
42
  sub:any =null;
43
  properties:EnvProperties;
44

    
45
  constructor (private _router: Router,  private route: ActivatedRoute, private entitySearch:EntitiesSearchService,
46
               private publicationsSearch:SearchPublicationsService, private datasetsSearch:SearchDatasetsService,
47
               private _meta: Meta, private _title: Title) {
48

    
49
                  var title = "OpenAIRE | Linking";
50
                  this._meta.updateTag({content:title},"property='og:title'");
51
                  this._title.setTitle(title);
52
  }
53
  ngOnInit() {
54
    this.route.data
55
      .subscribe((data: { envSpecific: EnvProperties }) => {
56
         this.properties = data.envSpecific;
57

    
58
      });
59
      if( typeof localStorage !== 'undefined') {
60
        if(localStorage.getItem("projects")){
61
          this.projects  = JSON.parse(localStorage.getItem("projects"));
62

    
63
        }
64
        if(localStorage.getItem("contexts")){
65
          this.contexts  = JSON.parse(localStorage.getItem("contexts"));
66
        }
67
        if(localStorage.getItem("results")){
68
          this.results  = JSON.parse(localStorage.getItem("results"));
69

    
70
        }
71
        localStorage.removeItem("projects");
72
        localStorage.removeItem("contexts");
73
        localStorage.removeItem("results");
74
    }
75
  }
76

    
77
  next(){
78

    
79
    if((this.show == 'result' && this.keyword == '')||(this.show == 'dataset' || this.show == 'publication')){
80
        this.show='claim';
81

    
82
    }
83
  }
84
  prev(){
85
  if(this.show == 'claim'){
86
      this.show='result';
87
    }
88
  }
89

    
90

    
91
  resultsChange($event) {
92
    this.results=$event.value;
93
  }
94

    
95
  projectsChange($event) {
96
    this.projects=$event.value;
97
  }
98

    
99
  linkTypeChange($event) {
100

    
101
    this.linkType =$event.value;
102
    this.show="result";
103
    if(this.bulkMode){
104
      this.show="claim";
105
    }
106
  }
107

    
108
  showChange($event) {
109
    this.show=$event.value;
110
    this.showChangedType($event.value);
111
  }
112

    
113
  showChangedType(type:string) {
114
    this.show=type;
115
     if(this.show == 'project' || this.show == 'context' || this.show == 'software'){
116
        this.linkType = this.show;
117
    }
118
  }
119

    
120
  canProceedToMetadata(){
121
    if(this.results.length == 0){
122

    
123
      UIkit.notification({
124
          message : 'No research results selected!<br>Please select research results to link with projects and/ or ommunities.',
125
          status  : 'warning',
126
          timeout : 1000,
127
          pos     : 'top-center'
128
      });
129
    }else{
130
      this.show = 'claim';
131
      this.step = 3;
132
    }
133
  }
134
}
(3-3/4)