1
|
import {Component, Input} from '@angular/core';
|
2
|
import {ActivatedRoute, Params} from '@angular/router';
|
3
|
|
4
|
import { SearchPublicationsComponent } from '../../searchPages/simple/searchPublications.component';
|
5
|
import { SearchPublicationsService } from '../../services/searchPublications.service';
|
6
|
import { SearchDatasetsComponent } from '../../searchPages/simple/searchDatasets.component';
|
7
|
import { SearchDatasetsService } from '../../services/searchDatasets.service';
|
8
|
import { SearchProjectsComponent } from '../../searchPages/simple/searchProjects.component';
|
9
|
import { SearchProjectsService } from '../../services/searchProjects.service';
|
10
|
import { SearchDataprovidersComponent } from '../../searchPages/simple/searchDataproviders.component';
|
11
|
import { SearchDataprovidersService } from '../../services/searchDataproviders.service';
|
12
|
|
13
|
@Component({
|
14
|
selector: 'tabs',
|
15
|
template: `
|
16
|
<ul *ngIf="tabs != undefined" class="nav nav-tabs">
|
17
|
<li *ngIf="tabs.length>0" class="active">
|
18
|
<a data-toggle="tab" href="#{{tabs[0].content}}">
|
19
|
{{tabs[0].name}}
|
20
|
<span class="badge" *ngIf="tabs[0].content=='publicationsTab'">
|
21
|
{{searchPublicationsComponent.searchUtils.totalResults}}
|
22
|
</span>
|
23
|
<span class="badge" *ngIf="tabs[0].content=='datasetsTab'">
|
24
|
{{searchDatasetsComponent.searchUtils.totalResults}}
|
25
|
</span>
|
26
|
<span class="badge" *ngIf="tabs[0].content=='projectsTab'">
|
27
|
{{searchProjectsComponent.searchUtils.totalResults}}
|
28
|
</span>
|
29
|
<span class="badge" *ngIf="tabs[0].content=='datasourcesTab'">
|
30
|
{{searchDataprovidersComponent.searchUtils.totalResults}}
|
31
|
</span>
|
32
|
<span class="badge" *ngIf="tabs[0].content=='organizationsTab'">
|
33
|
{{organizations.length}}
|
34
|
</span>
|
35
|
</a>
|
36
|
</li>
|
37
|
|
38
|
<li *ngFor="let tab of tabs; let i=index" role="presentation">
|
39
|
<a *ngIf="i>0"
|
40
|
(click)="search(tab.content, 1, 10)" data-toggle="tab" href="#{{tab.content}}">
|
41
|
{{tab.name}}
|
42
|
<span class="badge" *ngIf="tab.content=='publicationsTab'">
|
43
|
{{searchPublicationsComponent.searchUtils.totalResults}}
|
44
|
</span>
|
45
|
<span class="badge" *ngIf="tab.content=='datasetsTab'">
|
46
|
{{searchDatasetsComponent.searchUtils.totalResults}}
|
47
|
</span>
|
48
|
<span class="badge" *ngIf="tab.content=='projectsTab'">
|
49
|
{{searchProjectsComponent.searchUtils.totalResults}}
|
50
|
</span>
|
51
|
<span class="badge" *ngIf="tab.content=='datasourcesTab'">
|
52
|
{{searchDataprovidersComponent.searchUtils.totalResults}}
|
53
|
</span>
|
54
|
<span class="badge" *ngIf="tab.content=='organizationsTab'">
|
55
|
{{organizations.length}}
|
56
|
</span>
|
57
|
</a>
|
58
|
</li>
|
59
|
</ul>
|
60
|
|
61
|
<div *ngIf="tabs != undefined" class="tab-content">
|
62
|
<div *ngIf="tabs.length>0" id="{{tabs[0].content}}" class="tab-pane fade in active panel-body">
|
63
|
<publicationsTab *ngIf="tabs[0].content=='publicationsTab'"
|
64
|
[paramsForSearchLink]="paramsForSearchLink"
|
65
|
[searchPublicationsComponent]="searchPublicationsComponent">
|
66
|
</publicationsTab>
|
67
|
<datasetsTab *ngIf="tabs[0].content=='datasetsTab'"
|
68
|
[paramsForSearchLink]="paramsForSearchLink"
|
69
|
[searchDatasetsComponent]="searchDatasetsComponent">
|
70
|
</datasetsTab>
|
71
|
<statisticsTab *ngIf="tabs[0].content=='statisticsTab'"
|
72
|
[statistics]="statistics">
|
73
|
</statisticsTab>
|
74
|
<projectsTab *ngIf="tabs[0].content=='projectsTab'"
|
75
|
[paramsForSearchLink]="paramsForSearchLink"
|
76
|
[searchProjectsComponent]="searchProjectsComponent">
|
77
|
</projectsTab>
|
78
|
<datasourcesTab *ngIf="tabs[0].content=='datasourcesTab'"
|
79
|
[paramsForSearchLink]="paramsForSearchLink"
|
80
|
[searchDataprovidersComponent]="searchDataprovidersComponent">
|
81
|
</datasourcesTab>
|
82
|
<organizationsTab *ngIf="tabs[0].content=='organizationsTab'">
|
83
|
[organizations]="organizations"
|
84
|
</organizationsTab>
|
85
|
</div>
|
86
|
|
87
|
<div *ngFor="let tab of tabs; let i=index" id="{{tab.content}}" class="tab-pane fade panel-body">
|
88
|
<publicationsTab *ngIf="i>0 && tab.content=='publicationsTab'"
|
89
|
[paramsForSearchLink]="paramsForSearchLink"
|
90
|
[searchPublicationsComponent] = "searchPublicationsComponent">
|
91
|
</publicationsTab>
|
92
|
<datasetsTab *ngIf="i>0 && tab.content=='datasetsTab'"
|
93
|
[paramsForSearchLink]="paramsForSearchLink"
|
94
|
[searchDatasetsComponent]="searchDatasetsComponent">
|
95
|
</datasetsTab>
|
96
|
<statisticsTab *ngIf="i>0 && tab.content=='statisticsTab'"></statisticsTab>
|
97
|
<projectsTab *ngIf="i>0 && tab.content=='projectsTab'"
|
98
|
[paramsForSearchLink]="paramsForSearchLink"
|
99
|
[searchProjectsComponent]="searchProjectsComponent">
|
100
|
</projectsTab>
|
101
|
<datasourcesTab *ngIf="i>0 && tab.content=='datasourcesTab'"
|
102
|
[paramsForSearchLink]="paramsForSearchLink"
|
103
|
[searchDataprovidersComponent]="searchDataprovidersComponent">
|
104
|
</datasourcesTab>
|
105
|
<organizationsTab *ngIf="i>0 && tab.content=='organizationsTab'"
|
106
|
[organizations]="organizations">
|
107
|
</organizationsTab>
|
108
|
</div>
|
109
|
</div>
|
110
|
`
|
111
|
})
|
112
|
|
113
|
export class TabsComponent {
|
114
|
|
115
|
@Input() id: string;
|
116
|
@Input() resultsBy: string;
|
117
|
@Input() tabs: {"name": string, "content": string}[];
|
118
|
//@Input() publications;
|
119
|
//@Input() datasets;
|
120
|
@Input() statistics;
|
121
|
//@Input() projects;
|
122
|
//@Input() datasources;
|
123
|
@Input() organizations: {"name": string, "url": string}[];
|
124
|
|
125
|
public paramsForSearchLink: string = "";
|
126
|
|
127
|
public reloadPublications: boolean = true;
|
128
|
public reloadDatasets: boolean = true;
|
129
|
public reloadProjects: boolean = true;
|
130
|
public reloadDataproviders: boolean = true;
|
131
|
|
132
|
public searchPublicationsComponent : SearchPublicationsComponent;
|
133
|
public searchDatasetsComponent: SearchDatasetsComponent;
|
134
|
public searchProjectsComponent: SearchProjectsComponent;
|
135
|
public searchDataprovidersComponent: SearchDataprovidersComponent;
|
136
|
|
137
|
constructor (private route: ActivatedRoute,
|
138
|
private _searchPublicationsService: SearchPublicationsService,
|
139
|
private _searchDatasetsService: SearchDatasetsService,
|
140
|
private _searchProjectsService: SearchProjectsService,
|
141
|
private _searchDataprovidersService: SearchDataprovidersService) {
|
142
|
this.searchPublicationsComponent = new SearchPublicationsComponent(this.route, this._searchPublicationsService);
|
143
|
this.searchDatasetsComponent = new SearchDatasetsComponent(this.route, this._searchDatasetsService);
|
144
|
this.searchProjectsComponent = new SearchProjectsComponent(this.route, this._searchProjectsService);
|
145
|
this.searchDataprovidersComponent = new SearchDataprovidersComponent(this.route, this._searchDataprovidersService);
|
146
|
}
|
147
|
|
148
|
ngOnInit() {
|
149
|
if(this.tabs != undefined && this.tabs.length > 0) {
|
150
|
this.search(this.tabs[0].content, 1, 10);
|
151
|
this.count(1, 0);
|
152
|
}
|
153
|
|
154
|
if(this.resultsBy == "collectedFrom") {
|
155
|
this.paramsForSearchLink = "?collectedfromdatasourceid="+this.id;
|
156
|
} else if (this.resultsBy == "hostedBy") {
|
157
|
this.paramsForSearchLink = "?resulthostingdatasourceid="+this.id;
|
158
|
}
|
159
|
}
|
160
|
|
161
|
private count(page: number, size: number) {
|
162
|
console.info("number of tabs: "+this.tabs.length);
|
163
|
|
164
|
for(let i=1; i<this.tabs.length; i++) {
|
165
|
let content: string = this.tabs[i].content;
|
166
|
if(content=='publicationsTab') {
|
167
|
this.countPublications(page, size);
|
168
|
} else if(content=='datasetsTab') {
|
169
|
this.countDatasets(page, size);
|
170
|
} else if(content=='projectsTab') {
|
171
|
this.countProjects(page, size);
|
172
|
} else if(content=='datasourcesTab') {
|
173
|
this.countDataproviders(page, size);
|
174
|
}
|
175
|
}
|
176
|
}
|
177
|
|
178
|
private search(content: string, page: number, size: number) {
|
179
|
if(content=='publicationsTab') {
|
180
|
this.searchPublications(page, size);
|
181
|
} else if(content=='datasetsTab') {
|
182
|
this.searchDatasets(page, size);
|
183
|
} else if(content=='projectsTab') {
|
184
|
this.searchProjects(page, size);
|
185
|
} else if(content=='datasourcesTab') {
|
186
|
this.searchDataproviders(page, size);
|
187
|
}
|
188
|
}
|
189
|
|
190
|
private searchPublications(page: number, size: number) {
|
191
|
if(this.reloadPublications) {
|
192
|
this.searchPublicationsComponent.getResultsForDataproviders(this.id, this.resultsBy, page, size);
|
193
|
}
|
194
|
this.reloadPublications = false;
|
195
|
}
|
196
|
|
197
|
private countPublications(page: number, size: number) {
|
198
|
this.searchPublicationsComponent.getResultsForDataproviders(this.id, this.resultsBy, page, size);
|
199
|
}
|
200
|
|
201
|
private searchDatasets(page: number, size: number) {
|
202
|
if(this.reloadDatasets) {
|
203
|
this.searchDatasetsComponent.getResultsForDataproviders(this.id, this.resultsBy, page, size);
|
204
|
}
|
205
|
this.reloadDatasets = false;
|
206
|
}
|
207
|
|
208
|
private countDatasets(page: number, size: number) {
|
209
|
this.searchDatasetsComponent.getResultsForDataproviders(this.id, this.resultsBy, page, size);
|
210
|
}
|
211
|
|
212
|
private searchProjects(page: number, size: number) {
|
213
|
if(this.reloadProjects) {
|
214
|
this.searchProjectsComponent.getResultsForDataproviders(this.id, page, size);
|
215
|
}
|
216
|
this.reloadProjects = false;
|
217
|
}
|
218
|
|
219
|
private countProjects(page: number, size: number) {
|
220
|
this.searchProjectsComponent.getResultsForDataproviders(this.id, page, size);
|
221
|
}
|
222
|
|
223
|
private searchDataproviders(page: number, size: number) {
|
224
|
if(this.reloadDataproviders) {
|
225
|
this.searchDataprovidersComponent.getResultsForDataproviders(this.id, page, size);
|
226
|
}
|
227
|
this.reloadDataproviders = false;
|
228
|
}
|
229
|
|
230
|
private countDataproviders(page: number, size: number) {
|
231
|
this.searchDataprovidersComponent.getResultsForDataproviders(this.id, page, size);
|
232
|
}
|
233
|
}
|