1
|
import {Component, Input} from '@angular/core';
|
2
|
import {JSONP_PROVIDERS} from '@angular/http';
|
3
|
import {Observable} from 'rxjs/Observable';
|
4
|
import { ROUTER_DIRECTIVES, Router } from '@angular/router';
|
5
|
import {ClaimContextComponent} from './claimContext/claimContext.component';
|
6
|
import {ClaimResultComponent} from './claimResult/claimResult.component';
|
7
|
import {ClaimSelectedProjectsComponent} from './selected/selectedProjects.component';
|
8
|
import {ClaimSelectedContextsComponent} from './selected/selectedContexts.component';
|
9
|
import {ClaimSelectedResultsComponent} from './selected/selectedResults.component';
|
10
|
|
11
|
import {ClaimInsertComponent} from './insertClaim/insertClaim.component';
|
12
|
import {ClaimProjectsComponent} from './claimProject/claimProject.component';
|
13
|
import {BulkClaimComponent} from './bulkClaim/bulkClaim.component';
|
14
|
import {LinkingHomeComponent} from './linkingHome.component';
|
15
|
|
16
|
@Component({
|
17
|
selector: 'linking-generic',
|
18
|
//providers: [MdRadioDispatcher],
|
19
|
directives: [...ROUTER_DIRECTIVES, ClaimContextComponent, ClaimSelectedProjectsComponent, ClaimSelectedContextsComponent,
|
20
|
ClaimSelectedResultsComponent, ClaimInsertComponent, ClaimProjectsComponent, LinkingHomeComponent, ClaimResultComponent, BulkClaimComponent],
|
21
|
template: `
|
22
|
<div class="container">
|
23
|
<div class="page-header">
|
24
|
<div *ngIf=" bulkMode " class="pull-right"><span class="badge"><h5>Bulk mode</h5></span></div>
|
25
|
<h1>Link research resutls</h1>
|
26
|
</div>
|
27
|
<linking-home *ngIf=" show == 'home' " [bulkMode]="bulkMode" (linkTypeChange)="linkTypeChange($event)" ></linking-home>
|
28
|
<div *ngIf=" show != 'home' && show != 'myclaims' " >
|
29
|
<ol *ngIf=" show != 'myclaims' " class="breadcrumb">
|
30
|
<li *ngIf="linkType == 'project'" [class]="(show == 'project' )?'active':''"><a *ngIf="show != 'project'" (click)="showChangedType('project')" >Project</a><span *ngIf="show == 'project'">Project</span></li>
|
31
|
<li *ngIf="linkType == 'context'" [class]="(show == 'context' )?'active':''"><a *ngIf="show != 'context'" (click)="showChangedType('context')" >Context</a><span *ngIf="show == 'context'">Context</span></li>
|
32
|
<li *ngIf="linkType == 'software'" [class]="(show == 'software' )?'active':''"><a *ngIf="show != 'software'" (click)="showChangedType('software')" >Software</a><span *ngIf="show == 'software'">Software</span> </li>
|
33
|
<li *ngIf="!bulkMode " [class]="(show == 'result' || show == 'publication' || show == 'dataset')?'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>
|
34
|
<li *ngIf="!bulkMode " [class]="(show == 'claim')?'active':''"><span *ngIf="show == 'claim'">Link</span><a *ngIf="show != 'claim'" (click)="showChangedType('claim')">Link</a> </li>
|
35
|
<li *ngIf="bulkMode " [class]="(show == 'claim' )?'active':''"><span *ngIf="show == 'claim'">Upload & Link</span><a *ngIf="show != 'claim'" (click)="showChangedType('claim')">Upload & Link</a> </li>
|
36
|
</ol>
|
37
|
|
38
|
<div *ngIf=" show != 'claim' && show != 'myclaims' " class="row" >
|
39
|
<div class="col-sm-6">
|
40
|
|
41
|
<div *ngIf=" show=='result' && !bulkMode " >
|
42
|
<claim-result [selectedDatasets]="datasets" [selectedPublications]="publications" (datasetsChange)="datasetsChange($event)" (publicationsChange)="publicationsChange($event)" > </claim-result>
|
43
|
|
44
|
|
45
|
</div>
|
46
|
|
47
|
<div *ngIf=" show=='project' " >
|
48
|
<claim-projects [selectedProjects]="projects" > </claim-projects>
|
49
|
</div>
|
50
|
<div *ngIf=" show=='software' " >
|
51
|
<p>TODO software</p>
|
52
|
</div>
|
53
|
<div *ngIf=" show == 'context'" >
|
54
|
<claim-contexts [selectedList]="contexts" > </claim-contexts>
|
55
|
</div>
|
56
|
<!-- <div *ngIf=" show == 'claim'" >
|
57
|
<claim-insert [contexts]="contexts" [publications]="publications" [datasets]="datasets" [projects]="projects" ></claim-insert>
|
58
|
</div>-->
|
59
|
</div>
|
60
|
<div class="col-sm-6">
|
61
|
<claim-selected-contexts [contexts]="contexts" [show]="show"
|
62
|
(showChange)="showChange($event)" > </claim-selected-contexts>
|
63
|
<claim-selected-projects [projects]="projects" [show]="show"
|
64
|
(showChange)="showChange($event)" > </claim-selected-projects>
|
65
|
<claim-selected-results [datasets]="datasets" [publications]="publications" [show]="show"
|
66
|
(showChange)="showChange($event)" [linkToResults]="(bulkMode)?false:true" > </claim-selected-results>
|
67
|
|
68
|
</div>
|
69
|
</div>
|
70
|
<div *ngIf=" show == 'claim' " >
|
71
|
<claim-selected [contexts]="contexts" [publications]="publications" [datasets]="datasets" [projects]="projects" [show]="show"
|
72
|
(showChange)="showChange($event)" (publicationsChange)="publicationsChange($event)" [showAccessRights]="'true'" [bulkMode]="bulkMode"
|
73
|
[linkToResults]="(bulkMode)?false:true" > </claim-selected>
|
74
|
|
75
|
<claim-selected-contexts [contexts]="contexts" [show]="show"
|
76
|
(showChange)="showChange($event)" > </claim-selected-contexts>
|
77
|
<claim-selected-projects [projects]="projects" [show]="show"
|
78
|
(showChange)="showChange($event)" > </claim-selected-projects>
|
79
|
<!-- Bulk Mode Results (publicationsChange)="publicationsChanged($event)" -->
|
80
|
<bulk-claim *ngIf=" bulkMode " [publications]="publications" > </bulk-claim>
|
81
|
<claim-selected-results [datasets]="datasets" [publications]="publications" [show]="show"
|
82
|
(showChange)="showChange($event)" [linkToResults]="(bulkMode)?false:true" [showAccessRights]=true [bulkMode]="bulkMode" >
|
83
|
</claim-selected-results>
|
84
|
<claim-insert [contexts]="contexts" [publications]="publications" [datasets]="datasets" [projects]="projects" [show] = "show"
|
85
|
(showChange)="showChange($event)" ></claim-insert>
|
86
|
</div>
|
87
|
<nav>
|
88
|
<ul *ngIf="show != 'home'" class="pager">
|
89
|
<li class="previous" (click)="prev()"><a ><span aria-hidden="true">←</span> Previous</a></li>
|
90
|
<li class="next" *ngIf="show != 'claim'" (click)="next()" ><a >Next <span aria-hidden="true">→</span></a></li>
|
91
|
</ul>
|
92
|
</nav>
|
93
|
|
94
|
</div>
|
95
|
</div>
|
96
|
|
97
|
|
98
|
`
|
99
|
|
100
|
})
|
101
|
//[(ngModel)]="date"
|
102
|
export class LinkingGenericComponent {
|
103
|
constructor ( private _router: Router) {
|
104
|
}
|
105
|
@Input() bulkMode: boolean = false;
|
106
|
sourceType:string;
|
107
|
targetType:string;
|
108
|
step:number = 1;
|
109
|
contexts=[];
|
110
|
projects=[];
|
111
|
publications=[];
|
112
|
datasets=[];
|
113
|
show = "home";
|
114
|
searchType="publication"; //publication or dataset
|
115
|
date='8-6-2016';
|
116
|
keyword: string = "";
|
117
|
linkType:string ="project"; // link type (selected in home page) : project, context, software, etc
|
118
|
ngOnInit() {
|
119
|
|
120
|
}
|
121
|
next(){
|
122
|
|
123
|
if((this.show == 'project' || this.show == 'context' || this.show == 'software')){
|
124
|
if(!this.bulkMode){
|
125
|
this.show='result';
|
126
|
}else{
|
127
|
this.show='claim';
|
128
|
}
|
129
|
}else if((this.show == 'result' && this.keyword == '')||(this.show == 'dataset' || this.show == 'publication')){
|
130
|
this.show='claim';
|
131
|
|
132
|
}
|
133
|
}
|
134
|
prev(){
|
135
|
if(this.show == 'result'){
|
136
|
this.show = this.linkType;
|
137
|
}else if(this.show == 'context' || this.show == 'project' || this.show == 'software' ){
|
138
|
this.show='home';
|
139
|
} else if(this.show == 'claim'){
|
140
|
// this.show='result';
|
141
|
if(!this.bulkMode){
|
142
|
this.show='result';
|
143
|
}else{
|
144
|
this.show = this.linkType;
|
145
|
}
|
146
|
}
|
147
|
}
|
148
|
goto(term: string) {
|
149
|
this._router.navigate( ['Search', { keyword: term }] );
|
150
|
}
|
151
|
|
152
|
search() {
|
153
|
if(this.searchType == 'publication' ){
|
154
|
this.show="publication";
|
155
|
}else{
|
156
|
this.show="dataset";
|
157
|
}
|
158
|
|
159
|
}
|
160
|
|
161
|
sourceTypeChange($event) {
|
162
|
this.sourceType=$event.value;
|
163
|
console.log($event.value);
|
164
|
}
|
165
|
targetTypeChange($event) {
|
166
|
this.targetType=$event.value;
|
167
|
console.log($event.value);
|
168
|
}
|
169
|
// contextsChange($event) {
|
170
|
// this.contexts=$event.value;
|
171
|
// console.log($event.value);
|
172
|
// }
|
173
|
publicationsChange($event) {
|
174
|
this.publications=$event.value;
|
175
|
}
|
176
|
datasetsChange($event) {
|
177
|
this.datasets=$event.value;
|
178
|
}
|
179
|
projectsChange($event) {
|
180
|
this.projects=$event.value;
|
181
|
}
|
182
|
typeChanged(type:string) {
|
183
|
this.searchType = type;
|
184
|
}
|
185
|
linkTypeChange($event) {
|
186
|
this.linkType =$event.value;
|
187
|
this.show=$event.value;
|
188
|
|
189
|
}
|
190
|
showChange($event) {
|
191
|
this.show=$event.value;
|
192
|
this.showChangedType($event.value);
|
193
|
|
194
|
|
195
|
}
|
196
|
showChangedType(type:string) {
|
197
|
this.show=type;
|
198
|
if(this.show == 'project' || this.show == 'context' || this.show == 'software'){
|
199
|
this.linkType = this.show;
|
200
|
}
|
201
|
|
202
|
|
203
|
}
|
204
|
}
|