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 '../../../angular2-meta';
|
9
|
declare var UIkit:any;
|
10
|
|
11
|
@Component({
|
12
|
selector: 'linking-generic',
|
13
|
template: `
|
14
|
<div class="container uk-margin-top">
|
15
|
<div class="page-header">
|
16
|
<h1>Linking</h1>
|
17
|
</div>
|
18
|
|
19
|
<ul class="uk-breadcrumb">
|
20
|
<li [class]="(show=='project')?'uk-active':''" ><a (click)="show='project';"> Select Projects <span >({{projects.length}})</span></a></li>
|
21
|
<li [class]="(show=='context')?'uk-active':''" ><a (click)="show='context';"> Select Communities <span >({{contexts.length}})</span></a></li>
|
22
|
<li [class]="(show=='result')?'uk-active':''" ><a (click)="show='result';"> Select Research Results <span >({{results.length}})</span></a></li>
|
23
|
<li [class]="(show=='claim')?'uk-active':''" (click)="canProceedToMetadata();"><a [class]="(results.length == 0)?'uk-disabled':''" (click)="show='claim';" > Complete metadata</a></li>
|
24
|
</ul>
|
25
|
<start-over [results]="results" [contexts]="contexts" [projects]="projects" ></start-over>
|
26
|
|
27
|
<div class="uk-clearfix">
|
28
|
<a class="uk-float-right" uk-toggle="target: #linkingInfo; animation: uk-animation-fade"><span uk-icon="icon: info"></span> What is linking about? </a>
|
29
|
</div>
|
30
|
<div id="linkingInfo" class="uk-card uk-card-default uk-card-body uk-margin-small" hidden>
|
31
|
<a uk-toggle="target: #uploadInfo; animation: uk-animation-fade" class="uk-float-right"><span uk-icon="icon: close"></span></a>
|
32
|
<div class="uk-text-bold"><span uk-icon="icon: info"></span> Linking Functioanlity:</div>
|
33
|
<p>TODO: Put some useful information here... </p>
|
34
|
|
35
|
|
36
|
</div>
|
37
|
|
38
|
|
39
|
<!--ul class="uk-pagination uk-margin-remove-bottom">
|
40
|
<li *ngIf="show != 'result' " (click)="prev()"><a><span class="uk-margin-small-right" uk-pagination-previous></span> Previous</a></li>
|
41
|
<li *ngIf="show != 'claim' " (click)="next()" class="uk-margin-auto-left"><a>Next <span class="uk-margin-small-left" uk-pagination-next></span></a></li>
|
42
|
<li *ngIf="show == 'claim' " (click)="next()" class="uk-margin-auto-left">
|
43
|
<claim-insert [contexts]="contexts" [results]="results" [projects]="projects" [show] = "show"
|
44
|
(showChange)="showChange($event)" ></claim-insert>
|
45
|
|
46
|
</li>
|
47
|
</ul-->
|
48
|
|
49
|
<!-- link with Projects & Contexts -->
|
50
|
<!--div class="uk-width-1-1@s uk-width-1-1@m uk-width-1-1@l uk-grid">
|
51
|
<div class="uk-width-1-1@s uk-width-1-2@m uk-width-1-2@l uk-width-1-2@xl "-->
|
52
|
<!--ul class=" uk-tab " uk-tab="connect: #tabs; animation: uk-animation-fade">
|
53
|
<li>
|
54
|
<a>Projects ({{projects.length}})</a>
|
55
|
</li>
|
56
|
<li>
|
57
|
<a>Communities ({{contexts.length}})</a>
|
58
|
</li>
|
59
|
</ul>
|
60
|
<ul id="tabs" class="uk-switcher uk-margin-left uk-width-1-1">
|
61
|
<li-->
|
62
|
<claim-selected-projects *ngIf="show=='project'" title="link Projects" [projects]="projects" [show]="show" [linkType]=linkType
|
63
|
(showChange)="showChange($event)" > </claim-selected-projects>
|
64
|
<!--/li>
|
65
|
<li-->
|
66
|
<claim-selected-contexts *ngIf="show=='context'" title="link Communities" [contexts]="contexts" [projects]="projects" [results]="results" [inlineEntity] = "inlineResult" [show]="show" [linkType]=linkType
|
67
|
(showChange)="showChange($event)" > </claim-selected-contexts>
|
68
|
<!--/li-->
|
69
|
<!--/div>
|
70
|
<div class="uk-width-1-1@s uk-width-1-2@m uk-width-1-2@l uk-width-1-2@xl "-->
|
71
|
|
72
|
<!--/ul>
|
73
|
<!--/div-->
|
74
|
<!--/div-->
|
75
|
<!--hr-->
|
76
|
<!-- Research Results -->
|
77
|
<div *ngIf="show=='result' || show=='claim'" class="uk-width-1-1@s uk-width-1-1@m uk-width-1-1@l">
|
78
|
<claim-selected-results title= "Selected Research Results" [results]="results" [bulkMode]="bulkMode" [showSearch]="show=='claim'|| bulkMode? false: true" [showAccessRights]="show=='claim' || bulkMode? true: false">
|
79
|
</claim-selected-results>
|
80
|
</div>
|
81
|
|
82
|
|
83
|
|
84
|
|
85
|
<ul class="uk-pagination">
|
86
|
<!--li *ngIf="show != 'result' " (click)="prev()"><a><span class="uk-margin-small-right" uk-pagination-previous></span> Previous</a></li-->
|
87
|
<li *ngIf="show != 'claim' " (click)="canProceedToMetadata()" class="uk-margin-auto-left"><a> Review Metadata <span class="uk-margin-small-left" uk-pagination-next></span></a></li>
|
88
|
<li *ngIf="show == 'claim' " (click)="next()" class="uk-margin-auto-left">
|
89
|
<claim-insert [contexts]="contexts" [results]="results" [projects]="projects" [show] = "show"
|
90
|
(showChange)="showChange($event)" ></claim-insert>
|
91
|
|
92
|
</li>
|
93
|
</ul>
|
94
|
</div>
|
95
|
|
96
|
|
97
|
`
|
98
|
|
99
|
})
|
100
|
export class LinkingGenericComponent {
|
101
|
|
102
|
@Input() bulkMode: boolean = false;
|
103
|
sourceType:string;
|
104
|
targetType:string;
|
105
|
step:number = 1;
|
106
|
contexts=[];
|
107
|
projects=[];
|
108
|
results = [];
|
109
|
show = "project";
|
110
|
date='8-6-2016';
|
111
|
keyword: string = "";
|
112
|
linkType:string ="project"; // link type (selected in home page) : project, context, software, etc
|
113
|
/* url Parameters for inline linking */
|
114
|
id:string = null; //entity id
|
115
|
type:string = null; // entity type (publication or dataset)
|
116
|
linkTo:string = null; // entity type (project or context or result)
|
117
|
|
118
|
entityTypes=["dataset", "publication", "project","context"];
|
119
|
inlineResult:ClaimResult =null;
|
120
|
sub:any =null;
|
121
|
constructor ( private _router: Router, private route: ActivatedRoute, private entitySearch:EntitiesSearchService,
|
122
|
private publicationsSearch:SearchPublicationsService, private datasetsSearch:SearchDatasetsService, private _meta: Meta) {
|
123
|
this._meta.setTitle("Linking | OpenAIRE");
|
124
|
}
|
125
|
ngOnInit() {
|
126
|
if( typeof localStorage !== 'undefined') {
|
127
|
if(localStorage.getItem("projects")){
|
128
|
this.projects = JSON.parse(localStorage.getItem("projects"));
|
129
|
|
130
|
}
|
131
|
if(localStorage.getItem("contexts")){
|
132
|
this.contexts = JSON.parse(localStorage.getItem("contexts"));
|
133
|
}
|
134
|
if(localStorage.getItem("results")){
|
135
|
this.results = JSON.parse(localStorage.getItem("results"));
|
136
|
|
137
|
}
|
138
|
localStorage.removeItem("projects");
|
139
|
localStorage.removeItem("contexts");
|
140
|
localStorage.removeItem("results");
|
141
|
}
|
142
|
}
|
143
|
|
144
|
next(){
|
145
|
|
146
|
if((this.show == 'result' && this.keyword == '')||(this.show == 'dataset' || this.show == 'publication')){
|
147
|
this.show='claim';
|
148
|
|
149
|
}
|
150
|
}
|
151
|
prev(){
|
152
|
if(this.show == 'claim'){
|
153
|
this.show='result';
|
154
|
}
|
155
|
}
|
156
|
|
157
|
|
158
|
resultsChange($event) {
|
159
|
this.results=$event.value;
|
160
|
}
|
161
|
|
162
|
projectsChange($event) {
|
163
|
this.projects=$event.value;
|
164
|
}
|
165
|
|
166
|
linkTypeChange($event) {
|
167
|
|
168
|
this.linkType =$event.value;
|
169
|
this.show="result";
|
170
|
if(this.bulkMode){
|
171
|
this.show="claim";
|
172
|
}
|
173
|
}
|
174
|
|
175
|
showChange($event) {
|
176
|
this.show=$event.value;
|
177
|
this.showChangedType($event.value);
|
178
|
}
|
179
|
|
180
|
showChangedType(type:string) {
|
181
|
this.show=type;
|
182
|
if(this.show == 'project' || this.show == 'context' || this.show == 'software'){
|
183
|
this.linkType = this.show;
|
184
|
}
|
185
|
}
|
186
|
|
187
|
canProceedToMetadata(){
|
188
|
if(this.results.length == 0){
|
189
|
|
190
|
UIkit.notification({
|
191
|
message : 'No research results selected!<br>Please select research results to link with projects and/ or ommunities.',
|
192
|
status : 'warning',
|
193
|
timeout : 1000,
|
194
|
pos : 'top-center'
|
195
|
});
|
196
|
}else{
|
197
|
this.show = 'claim';
|
198
|
}
|
199
|
}
|
200
|
}
|