1
|
import {Component, Input} from '@angular/core';
|
2
|
import {ActivatedRoute, Router} from '@angular/router';
|
3
|
import {Title, Meta} from '@angular/platform-browser';
|
4
|
import {Observable} from 'rxjs';
|
5
|
|
6
|
import {EnvProperties} from '../../utils/properties/env-properties';
|
7
|
|
8
|
import {ClaimProject, ClaimResult} from '../claim-utils/claimEntities.class';
|
9
|
|
10
|
import {EntitiesSearchService} from '../../utils/entitiesAutoComplete/entitySearch.service';
|
11
|
import {SearchPublicationsService} from '../../services/searchPublications.service';
|
12
|
import {SearchDatasetsService} from '../../services/searchDatasets.service';
|
13
|
import { SEOService } from '../../sharedComponents/SEO/SEO.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
|
@Input() communityId:string= null;
|
26
|
sourceType:string;
|
27
|
targetType:string;
|
28
|
step:number = 1;
|
29
|
contexts=[];
|
30
|
projects=[];
|
31
|
results = [];
|
32
|
show = "project";
|
33
|
date='8-6-2016';
|
34
|
keyword: string = "";
|
35
|
linkType:string ="project"; // link type (selected in home page) : project, context, software, etc
|
36
|
/* url Parameters for inline linking */
|
37
|
id:string = null; //entity id
|
38
|
type:string = null; // entity type (publication or research data)
|
39
|
linkTo:string = null; // entity type (project or context or result)
|
40
|
|
41
|
entityTypes=["dataset", "publication", "project","context"];
|
42
|
inlineResult:ClaimResult =null;
|
43
|
sub:any =null;
|
44
|
properties:EnvProperties;
|
45
|
localStoragePrefix:string = "linking_";
|
46
|
url=null;
|
47
|
|
48
|
constructor (private _router: Router, private route: ActivatedRoute, private entitySearch:EntitiesSearchService,
|
49
|
private publicationsSearch:SearchPublicationsService, private datasetsSearch:SearchDatasetsService,
|
50
|
private _meta: Meta, private _title: Title,
|
51
|
private seoService: SEOService ) {
|
52
|
|
53
|
var title = "OpenAIRE | Linking";
|
54
|
this._meta.updateTag({content:title},"property='og:title'");
|
55
|
this._title.setTitle(title);
|
56
|
|
57
|
|
58
|
}
|
59
|
ngOnInit() {
|
60
|
this.route.data
|
61
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
62
|
this.properties = data.envSpecific;
|
63
|
this.url = data.envSpecific.baseLink+this._router.url;
|
64
|
this.seoService.createLinkForCanonicalURL(this.properties.baseLink+this._router.url, false);
|
65
|
|
66
|
});
|
67
|
if( typeof localStorage !== 'undefined') {
|
68
|
if(localStorage.getItem(this.localStoragePrefix + "projects")){
|
69
|
this.projects = JSON.parse(localStorage.getItem(this.localStoragePrefix + "projects"));
|
70
|
|
71
|
}
|
72
|
if(localStorage.getItem(this.localStoragePrefix + "contexts")){
|
73
|
this.contexts = JSON.parse(localStorage.getItem(this.localStoragePrefix + "contexts"));
|
74
|
}
|
75
|
if(localStorage.getItem(this.localStoragePrefix + "results")){
|
76
|
this.results = JSON.parse(localStorage.getItem(this.localStoragePrefix + "results"));
|
77
|
|
78
|
}
|
79
|
}
|
80
|
}
|
81
|
|
82
|
next(){
|
83
|
|
84
|
if((this.show == 'result' && this.keyword == '')||(this.show == 'dataset' || this.show == 'publication')){
|
85
|
this.show='claim';
|
86
|
|
87
|
}
|
88
|
}
|
89
|
prev(){
|
90
|
if(this.show == 'claim'){
|
91
|
this.show='result';
|
92
|
}
|
93
|
}
|
94
|
|
95
|
|
96
|
resultsChange($event) {
|
97
|
this.results=$event.value;
|
98
|
}
|
99
|
|
100
|
projectsChange($event) {
|
101
|
this.projects=$event.value;
|
102
|
}
|
103
|
|
104
|
linkTypeChange($event) {
|
105
|
|
106
|
this.linkType =$event.value;
|
107
|
this.show="result";
|
108
|
if(this.bulkMode){
|
109
|
this.show="claim";
|
110
|
}
|
111
|
}
|
112
|
|
113
|
showChange($event) {
|
114
|
this.show=$event.value;
|
115
|
this.showChangedType($event.value);
|
116
|
}
|
117
|
|
118
|
showChangedType(type:string) {
|
119
|
this.show=type;
|
120
|
if(this.show == 'project' || this.show == 'context' || this.show == 'software'){
|
121
|
this.linkType = this.show;
|
122
|
}
|
123
|
}
|
124
|
|
125
|
canProceedToMetadata(){
|
126
|
if(this.results.length == 0){
|
127
|
|
128
|
UIkit.notification({
|
129
|
message : 'No research results selected!<br>Please select research results to link with projects and/ or ommunities.',
|
130
|
status : 'warning',
|
131
|
timeout : 1000,
|
132
|
pos : 'top-center'
|
133
|
});
|
134
|
}else{
|
135
|
this.show = 'claim';
|
136
|
this.step = 3;
|
137
|
}
|
138
|
}
|
139
|
}
|