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
|
|
9
|
@Component({
|
10
|
selector: 'linking-generic',
|
11
|
template: `
|
12
|
<div class="container uk-margin-top">
|
13
|
<div class="page-header">
|
14
|
<div *ngIf=" bulkMode " class="uk-float-right uk-badge uk-badge-notification">
|
15
|
<span class="uk-text-center uk-margin-top">Bulk mode</span>
|
16
|
</div>
|
17
|
<h1>Link research resutls</h1>
|
18
|
</div>
|
19
|
<linking-home *ngIf=" show == 'home' " [bulkMode]="bulkMode" (linkTypeChange)="linkTypeChange($event)" ></linking-home>
|
20
|
|
21
|
<div *ngIf=" show != 'home' && show != 'myclaims' " >
|
22
|
<ul *ngIf=" show != 'myclaims' " class="uk-breadcrumb">
|
23
|
<li *ngIf="linkType == 'project'" [class]="(show == 'project' )?'uk-active':''"><a *ngIf="show != 'project'" (click)="showChangedType('project')" >Project</a><span *ngIf="show == 'project'">Project</span></li>
|
24
|
<li *ngIf="linkType == 'context'" [class]="(show == 'context' )?'uk-active':''"><a *ngIf="show != 'context'" (click)="showChangedType('context')" >Context</a><span *ngIf="show == 'context'">Context</span></li>
|
25
|
<li *ngIf="linkType == 'software'" [class]="(show == 'software' )?'uk-active':''"><a *ngIf="show != 'software'" (click)="showChangedType('software')" >Software</a><span *ngIf="show == 'software'">Software</span> </li>
|
26
|
<li *ngIf="!bulkMode " [class]="(show == 'result' || show == 'publication' || show == 'dataset')?'uk-active':''"><a *ngIf="show != 'result' && show != 'publication' && show != 'dataset'" (click)="showChangedType('result')" >Research Result</a><span *ngIf="show == 'result' || show == 'publication' || show == 'dataset'">Research Result</span></li>
|
27
|
<li *ngIf="!bulkMode " [class]="(show == 'claim')?'uk-active':''"><span *ngIf="show == 'claim'">Link</span><a *ngIf="show != 'claim'" (click)="showChangedType('claim')">Link</a> </li>
|
28
|
<li *ngIf="bulkMode " [class]="(show == 'claim' )?'uk-active':''"><span *ngIf="show == 'claim'">Upload & Link</span><a *ngIf="show != 'claim'" (click)="showChangedType('claim')">Upload & Link</a> </li>
|
29
|
</ul>
|
30
|
|
31
|
<div *ngIf=" show != 'claim' && show != 'myclaims' " class="uk-grid" >
|
32
|
<div *ngIf=" show=='result' && !bulkMode " class="uk-width-small-1-1 uk-width-medium-1-2 uk-width-large-1-2">
|
33
|
<claim-result [selectedDatasets]="datasets" [selectedPublications]="publications" (datasetsChange)="datasetsChange($event)" (publicationsChange)="publicationsChange($event)" > </claim-result>
|
34
|
</div>
|
35
|
<div *ngIf=" show=='project' " class="uk-width-1-1" >
|
36
|
<claim-projects [selectedProjects]="projects" > </claim-projects>
|
37
|
</div>
|
38
|
<div *ngIf=" show=='software' " class="uk-width-1-1">
|
39
|
<p>TODO software</p>
|
40
|
</div>
|
41
|
<div *ngIf=" show == 'context'" class="uk-width-1-1" >
|
42
|
<claim-contexts [selectedList]="contexts" > </claim-contexts>
|
43
|
</div>
|
44
|
|
45
|
<div [class]="( show=='result' && !bulkMode)?'uk-width-small-1-1 uk-width-medium-1-2 uk-width-large-1-2 ':'uk-width-small-1-1 uk-width-medium-1-1 uk-width-large-1-1 uk-margin-top uk-grid'">
|
46
|
<div [class]="( show=='result' && !bulkMode)?'uk-width-small-1-1 uk-width-medium-1-1 uk-width-large-1-1 ':'uk-width-small-1-1 uk-width-medium-1-2 uk-width-large-1-2 uk-width-xlarge-1-2 '">
|
47
|
<claim-selected-contexts [contexts]="contexts" [show]="show"
|
48
|
(showChange)="showChange($event)" > </claim-selected-contexts>
|
49
|
</div>
|
50
|
<div [class]="( show=='result' && !bulkMode)?'uk-width-small-1-1 uk-width-medium-1-1 uk-width-large-1-1 ':'uk-width-small-1-1 uk-width-medium-1-2 uk-width-large-1-2 uk-width-xlarge-1-2 '">
|
51
|
<claim-selected-projects [projects]="projects" [show]="show"
|
52
|
(showChange)="showChange($event)" > </claim-selected-projects>
|
53
|
</div>
|
54
|
|
55
|
<div [class]="( show=='result' && !bulkMode)?'uk-width-small-1-1 uk-width-medium-1-1 uk-width-large-1-1 ':'uk-width-small-1-1 uk-width-medium-1-2 uk-width-large-1-2 uk-width-xlarge-1-2'">
|
56
|
<claim-selected-publications [publications]="publications" [linkToResults]="(bulkMode)?false:true" [bulkMode]="bulkMode">
|
57
|
</claim-selected-publications>
|
58
|
</div>
|
59
|
<div [class]="( show=='result' && !bulkMode)?'uk-width-small-1-1 uk-width-medium-1-1 uk-width-large-1-1 ':'uk-width-small-1-1 uk-width-medium-1-2 uk-width-large-1-2 uk-width-xlarge-1-2 '">
|
60
|
<claim-selected-datasets [datasets]="datasets" [linkToResults]="(bulkMode)?false:true" [bulkMode]="bulkMode"> </claim-selected-datasets>
|
61
|
</div>
|
62
|
|
63
|
</div>
|
64
|
</div>
|
65
|
<div *ngIf=" show == 'claim' " class="uk-width-small-1-1 uk-width-medium-1-1 uk-width-large-1-1 uk-grid">
|
66
|
|
67
|
<div class="uk-width-small-1-1 uk-width-medium-1-2 uk-width-large-1-2 uk-width-xlarge-1-2">
|
68
|
<claim-selected-contexts [contexts]="contexts" [show]="show" (showChange)="showChange($event)" > </claim-selected-contexts>
|
69
|
</div>
|
70
|
<div class="uk-width-small-1-1 uk-width-medium-1-2 uk-width-large-1-2 uk-width-xlarge-1-2">
|
71
|
<claim-selected-projects [projects]="projects" [show]="show"
|
72
|
(showChange)="showChange($event)" > </claim-selected-projects>
|
73
|
</div>
|
74
|
|
75
|
<bulk-claim *ngIf=" bulkMode " [publications]="publications" > </bulk-claim>
|
76
|
<div class="uk-width-small-1-1 uk-width-medium-1-2 uk-width-large-1-2 uk-width-xlarge-1-2">
|
77
|
<claim-selected-publications [publications]="publications" [showAccessRights]=true
|
78
|
[linkToResults]="(bulkMode)?false:true" [bulkMode]="bulkMode">
|
79
|
</claim-selected-publications>
|
80
|
</div>
|
81
|
<div class="uk-width-small-1-1 uk-width-medium-1-2 uk-width-large-1-2 uk-width-xlarge-1-2">
|
82
|
<claim-selected-datasets [datasets]="datasets" [showAccessRights]=true
|
83
|
[linkToResults]="(bulkMode)?false:true" [bulkMode]="bulkMode">
|
84
|
</claim-selected-datasets>
|
85
|
</div>
|
86
|
|
87
|
<div class="uk-width-1-1 ">
|
88
|
<claim-insert [contexts]="contexts" [publications]="publications" [datasets]="datasets" [projects]="projects" [show] = "show"
|
89
|
(showChange)="showChange($event)" ></claim-insert>
|
90
|
</div>
|
91
|
</div>
|
92
|
|
93
|
<ul *ngIf="show != 'home'" class="uk-pagination">
|
94
|
<li class="uk-pagination-previous" (click)="prev()"><a><i class="uk-icon-angle-left"></i> Previous</a></li>
|
95
|
<li class="uk-pagination-next" *ngIf="show != 'claim'" (click)="next()"><a>Next <i class="uk-icon-angle-right"></i></a></li>
|
96
|
</ul>
|
97
|
</div>
|
98
|
</div>
|
99
|
|
100
|
|
101
|
`
|
102
|
|
103
|
})
|
104
|
export class LinkingGenericComponent {
|
105
|
|
106
|
@Input() bulkMode: boolean = false;
|
107
|
sourceType:string;
|
108
|
targetType:string;
|
109
|
step:number = 1;
|
110
|
contexts=[];
|
111
|
projects=[];
|
112
|
publications=[];
|
113
|
datasets=[];
|
114
|
show = "home";
|
115
|
date='8-6-2016';
|
116
|
keyword: string = "";
|
117
|
linkType:string ="project"; // link type (selected in home page) : project, context, software, etc
|
118
|
/* Parameters for inline linking */
|
119
|
id:string = null; //entity id
|
120
|
type:string = null; // entity type (publication or dataset)
|
121
|
linkTo:string = null; // entity type (project or context)
|
122
|
entityTypes=["dataset", "publication", "project","context"];
|
123
|
inlineSearchResult:ClaimResult =null;
|
124
|
sub:any =null;
|
125
|
constructor ( private _router: Router, private route: ActivatedRoute, private entitySearch:EntitiesSearchService, private publicationsSearch:SearchPublicationsService, private datasetsSearch:SearchDatasetsService) {
|
126
|
|
127
|
}
|
128
|
ngOnInit() {
|
129
|
this.sub = this.route.queryParams.subscribe(params => {
|
130
|
this.id = params['id'];
|
131
|
this.type = params['type'];
|
132
|
this.linkTo = params['linkTo'];
|
133
|
if(this.type!=null && this.linkTo!=null){
|
134
|
this.type = (this.entityTypes.indexOf(this.type) != -1)? this.type:'publication';
|
135
|
this.linkTo = (this.entityTypes.indexOf(this.linkTo) != -1 || this.linkTo == "result")? this.linkTo:'project';
|
136
|
this.show = this.linkTo;
|
137
|
this.linkType = this.linkTo;
|
138
|
var isInlineSearchResult:boolean = false;
|
139
|
if((this.type == "publication" || this.type == "dataset") && (this.linkTo == "publication" || this.linkTo == "dataset")){
|
140
|
isInlineSearchResult = true;
|
141
|
}
|
142
|
if(this.type == "project"){
|
143
|
this.linkType = "project";
|
144
|
this.getProjectById(this.id);
|
145
|
}else if(this.type == "publication"){
|
146
|
this.getPublicationById(this.id,isInlineSearchResult);
|
147
|
}else if(this.type == "dataset"){
|
148
|
this.getDatasetById(this.id,isInlineSearchResult);
|
149
|
}
|
150
|
|
151
|
}
|
152
|
|
153
|
});
|
154
|
}
|
155
|
|
156
|
getProjectById(id:string){
|
157
|
this.sub = this.entitySearch.fetchByType(id,"project").subscribe(
|
158
|
data => {
|
159
|
console.log(data);
|
160
|
var item =data[0];
|
161
|
var project: ClaimProject = { funderId: item.funderId,funderName: item.funderName, projectId: id, projectName: item.projectName , projectAcronym: item.projectAcronym, startDate: item.startDate, endDate: item.endDate };
|
162
|
this.projects.push( project);
|
163
|
|
164
|
},
|
165
|
err => console.log("An error occured"));
|
166
|
}
|
167
|
getPublicationById(id:string, isInlineSearchResult:boolean){
|
168
|
|
169
|
this.sub = this.publicationsSearch.searchPublicationById(id).subscribe(
|
170
|
data => {
|
171
|
var item =data[0];
|
172
|
|
173
|
var result: ClaimResult = {id: id, type :"publication", source : "openaire", title: item['title'].name, url: item['title'].url, result: item, accessRights:item['title'].accessMode, embargoEndDate: null, date: item.year};
|
174
|
if(isInlineSearchResult){
|
175
|
this.inlineSearchResult = result;
|
176
|
}else{
|
177
|
this.publications.push( result);
|
178
|
}
|
179
|
},
|
180
|
err => console.log("An error occured"));
|
181
|
}
|
182
|
getDatasetById(id:string, isInlineSearchResult:boolean){
|
183
|
this.sub = this.datasetsSearch.searchDatasetById(id).subscribe(
|
184
|
data => {
|
185
|
var item =data[0];
|
186
|
console.log(item);
|
187
|
var result: ClaimResult = {id: id, type : "dataset", source : "openaire", title: item['title'].name, url: item['title'].url, result: item, accessRights:item['title'].accessMode, embargoEndDate: null, date: item.year};
|
188
|
if(isInlineSearchResult){
|
189
|
this.inlineSearchResult = result;
|
190
|
}else{
|
191
|
this.datasets.push( result);
|
192
|
}
|
193
|
},
|
194
|
err => console.log("An error occured"));
|
195
|
|
196
|
}
|
197
|
next(){
|
198
|
|
199
|
if((this.show == 'project' || this.show == 'context' || this.show == 'software')){
|
200
|
if(!this.bulkMode){
|
201
|
this.show='result';
|
202
|
}else{
|
203
|
this.show='claim';
|
204
|
}
|
205
|
}else if((this.show == 'result' && this.keyword == '')||(this.show == 'dataset' || this.show == 'publication')){
|
206
|
this.show='claim';
|
207
|
|
208
|
}
|
209
|
}
|
210
|
prev(){
|
211
|
if(this.show == 'result'){
|
212
|
this.show = this.linkType;
|
213
|
}else if(this.show == 'context' || this.show == 'project' || this.show == 'software' ){
|
214
|
this.show='home';
|
215
|
} else if(this.show == 'claim'){
|
216
|
if(!this.bulkMode){
|
217
|
this.show='result';
|
218
|
}else{
|
219
|
this.show = this.linkType;
|
220
|
}
|
221
|
}
|
222
|
}
|
223
|
goto(term: string) {
|
224
|
this._router.navigate( ['Search', { keyword: term }] );
|
225
|
}
|
226
|
|
227
|
|
228
|
sourceTypeChange($event) {
|
229
|
this.sourceType=$event.value;
|
230
|
console.log($event.value);
|
231
|
}
|
232
|
targetTypeChange($event) {
|
233
|
this.targetType=$event.value;
|
234
|
console.log($event.value);
|
235
|
}
|
236
|
|
237
|
publicationsChange($event) {
|
238
|
this.publications=$event.value;
|
239
|
}
|
240
|
datasetsChange($event) {
|
241
|
this.datasets=$event.value;
|
242
|
}
|
243
|
projectsChange($event) {
|
244
|
this.projects=$event.value;
|
245
|
}
|
246
|
|
247
|
linkTypeChange($event) {
|
248
|
this.linkType =$event.value;
|
249
|
this.show=$event.value;
|
250
|
}
|
251
|
|
252
|
showChange($event) {
|
253
|
this.show=$event.value;
|
254
|
this.showChangedType($event.value);
|
255
|
}
|
256
|
|
257
|
showChangedType(type:string) {
|
258
|
this.show=type;
|
259
|
if(this.show == 'project' || this.show == 'context' || this.show == 'software'){
|
260
|
this.linkType = this.show;
|
261
|
}
|
262
|
}
|
263
|
|
264
|
}
|