1
|
import {Component, Input, ViewChild} from '@angular/core';
|
2
|
import {ActivatedRoute, Router} from '@angular/router';
|
3
|
import {Meta, Title} from '@angular/platform-browser';
|
4
|
|
5
|
|
6
|
import {EnvProperties} from '../../utils/properties/env-properties';
|
7
|
|
8
|
import {DataProviderInfo} from '../../utils/entities/dataProviderInfo';
|
9
|
import {DataProviderService} from './dataProvider.service';
|
10
|
import {FetchResearchResults} from '../../utils/fetchEntitiesClasses/fetchResearchResults.class';
|
11
|
import {SearchResearchResultsService} from '../../services/searchResearchResults.service';
|
12
|
import {FetchProjects} from '../../utils/fetchEntitiesClasses/fetchProjects.class';
|
13
|
import {SearchProjectsService} from '../../services/searchProjects.service';
|
14
|
import {FetchDataproviders} from '../../utils/fetchEntitiesClasses/fetchDataproviders.class';
|
15
|
import {SearchDataprovidersService} from '../../services/searchDataproviders.service';
|
16
|
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
17
|
import {RouterHelper} from '../../utils/routerHelper.class';
|
18
|
import {PiwikService} from '../../utils/piwik/piwik.service';
|
19
|
import {SEOService} from '../../sharedComponents/SEO/SEO.service';
|
20
|
import {HelperFunctions} from "../../utils/HelperFunctions.class";
|
21
|
import {HelperService} from "../../utils/helper/helper.service";
|
22
|
import {Location} from "@angular/common";
|
23
|
import {StringUtils} from "../../utils/string-utils.class";
|
24
|
import {SearchResult} from "../../utils/entities/searchResult";
|
25
|
import {ResultPreview} from "../../utils/result-preview/result-preview";
|
26
|
import {IndexInfoService} from "../../utils/indexInfo.service";
|
27
|
import {properties} from "../../../../environments/environment";
|
28
|
import {Subscriber} from "rxjs";
|
29
|
|
30
|
|
31
|
@Component({
|
32
|
selector: 'dataprovider',
|
33
|
templateUrl: 'dataProvider.component.html',
|
34
|
})
|
35
|
|
36
|
export class DataProviderComponent {
|
37
|
@Input() piwikSiteId = null;
|
38
|
@Input() communityId = null;
|
39
|
public dataProviderInfo: DataProviderInfo;
|
40
|
public datasourceId: string;
|
41
|
|
42
|
// Message variables
|
43
|
public warningMessage = "";
|
44
|
public errorMessage = "";
|
45
|
public showLoading: boolean = true;
|
46
|
|
47
|
// Metrics tab variables
|
48
|
public metricsClicked: boolean;
|
49
|
public viewsFrameUrl: string;
|
50
|
public downloadsFrameUrl: string;
|
51
|
public totalViews: number;
|
52
|
public totalDownloads: number;
|
53
|
public pageViews: number;
|
54
|
|
55
|
// Statistics tab variables
|
56
|
public statsClicked: boolean = false;
|
57
|
|
58
|
@ViewChild('statisticsModal') statisticsModal;
|
59
|
@ViewChild('relatedDatasourcesModal') relatedDatasourcesModal;
|
60
|
|
61
|
// Variables for publications, research data, projects, content providers, related content providers tabs
|
62
|
public fetchPublications: FetchResearchResults;
|
63
|
public fetchDatasets: FetchResearchResults;
|
64
|
public fetchSoftware: FetchResearchResults;
|
65
|
public fetchOrps: FetchResearchResults;
|
66
|
public fetchProjects: FetchProjects;
|
67
|
public fetchDataproviders: FetchDataproviders;
|
68
|
public fetchAggregatorsResults: FetchResearchResults;
|
69
|
public searchNumber: number = 5;
|
70
|
|
71
|
public aggregationStatusIsInitialized: boolean = false;
|
72
|
|
73
|
public loadingRelatedDatasources: boolean = true;
|
74
|
|
75
|
// Active tab variable for responsiveness - show tabs only if main request is completed
|
76
|
public activeTab: string = "";
|
77
|
public showTabs: boolean = false;
|
78
|
|
79
|
public _numberOfTabs: number = 0;
|
80
|
public tabsAreInitialized: boolean = false;
|
81
|
|
82
|
public routerHelper: RouterHelper = new RouterHelper();
|
83
|
public errorCodes: ErrorCodes = new ErrorCodes();
|
84
|
public pageContents = null;
|
85
|
public divContents = null;
|
86
|
|
87
|
// Request results of each tab only the one time (first time tab is clicked)
|
88
|
private reloadPublications: boolean = true;
|
89
|
private reloadDatasets: boolean = true;
|
90
|
private reloadSoftware: boolean = true;
|
91
|
private reloadOrps: boolean = true;
|
92
|
private reloadProjects: boolean = true;
|
93
|
private reloadDataproviders: boolean = true;
|
94
|
private reloadRelatedDatasources: boolean = true;
|
95
|
|
96
|
// Organizations variables for view more/less functionality
|
97
|
public thresholdOrganizations: number = 20;
|
98
|
public showNumOrganizations: number = 20;
|
99
|
|
100
|
// Subjects variables for view more/less functionality
|
101
|
public thresholdSubjects: number = 20;
|
102
|
public showNumSubjects: number = 20;
|
103
|
|
104
|
// Description variables for view more/less functionality
|
105
|
public thresholdDescription: number = 670;
|
106
|
public showNumDescription: number = 670;
|
107
|
|
108
|
public indexUpdateDate: Date;
|
109
|
public showFeedback: boolean = false;
|
110
|
public feedbackFields: string [] = ['Name', 'Organizations', 'Country', 'Other'];
|
111
|
|
112
|
subscriptions = [];
|
113
|
properties: EnvProperties = properties;
|
114
|
|
115
|
constructor(private _dataproviderService: DataProviderService,
|
116
|
private _piwikService: PiwikService,
|
117
|
private route: ActivatedRoute,
|
118
|
private _meta: Meta,
|
119
|
private _title: Title,
|
120
|
private _router: Router,
|
121
|
private _searchResearchResultsService: SearchResearchResultsService,
|
122
|
private _searchProjectsService: SearchProjectsService,
|
123
|
private _searchDataprovidersService: SearchDataprovidersService,
|
124
|
private seoService: SEOService,
|
125
|
private helper: HelperService,
|
126
|
private _location: Location,
|
127
|
private indexInfoService: IndexInfoService) {
|
128
|
this.fetchPublications = new FetchResearchResults(this._searchResearchResultsService);
|
129
|
this.fetchDatasets = new FetchResearchResults(this._searchResearchResultsService);
|
130
|
this.fetchSoftware = new FetchResearchResults(this._searchResearchResultsService);
|
131
|
this.fetchOrps = new FetchResearchResults(this._searchResearchResultsService);
|
132
|
this.fetchProjects = new FetchProjects(this._searchProjectsService);
|
133
|
this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService);
|
134
|
|
135
|
}
|
136
|
|
137
|
ngOnInit() {
|
138
|
if (typeof document !== 'undefined') {
|
139
|
this.subscriptions.push(this.indexInfoService.getLastIndexDate(this.properties).subscribe(lastIndexUpdate => {
|
140
|
if (lastIndexUpdate) {
|
141
|
this.indexUpdateDate = new Date(lastIndexUpdate);
|
142
|
}
|
143
|
}));
|
144
|
}
|
145
|
//this.getDivContents();
|
146
|
this.getPageContents();
|
147
|
this.updateUrl(this.properties.domain + this.properties.baseLink + this._router.url);
|
148
|
this.subscriptions.push(this.route.queryParams.subscribe(data => {
|
149
|
this.updateTitle("Content provider");
|
150
|
this.updateDescription("");
|
151
|
this.datasourceId = data['datasourceId'];
|
152
|
if (this.datasourceId && StringUtils.isOpenAIREID(this.datasourceId)) {
|
153
|
this.initializeValues();
|
154
|
this.getDataProviderInfo(this.datasourceId);
|
155
|
} else {
|
156
|
this.showLoading = false;
|
157
|
this._router.navigate(['/error'], {
|
158
|
queryParams: {
|
159
|
"page": this._location.path(true),
|
160
|
"page_type": "dataprovider"
|
161
|
}
|
162
|
});
|
163
|
}
|
164
|
|
165
|
HelperFunctions.scroll();
|
166
|
}));
|
167
|
}
|
168
|
|
169
|
public initializeValues() {
|
170
|
this._numberOfTabs = 0;
|
171
|
this.tabsAreInitialized = false;
|
172
|
this.dataProviderInfo = null;
|
173
|
this.aggregationStatusIsInitialized = false;
|
174
|
this.fetchProjects.searchUtils.status = this.errorCodes.LOADING;
|
175
|
this.fetchProjects.searchUtils.totalResults = 0;
|
176
|
this.fetchDataproviders.searchUtils.status = this.errorCodes.LOADING;
|
177
|
this.fetchDataproviders.searchUtils.totalResults = 0;
|
178
|
this.fetchPublications.searchUtils.status = this.errorCodes.LOADING;
|
179
|
this.fetchPublications.searchUtils.totalResults = 0;
|
180
|
this.fetchDatasets.searchUtils.status = this.errorCodes.LOADING;
|
181
|
this.fetchDatasets.searchUtils.totalResults = 0;
|
182
|
this.fetchSoftware.searchUtils.status = this.errorCodes.LOADING;
|
183
|
this.fetchSoftware.searchUtils.totalResults = 0;
|
184
|
this.fetchOrps.searchUtils.status = this.errorCodes.LOADING;
|
185
|
this.fetchOrps.searchUtils.totalResults = 0;
|
186
|
this.statsClicked = false;
|
187
|
this.metricsClicked = false;
|
188
|
}
|
189
|
|
190
|
private getPageContents() {
|
191
|
this.subscriptions.push(this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
|
192
|
this.pageContents = contents;
|
193
|
}));
|
194
|
}
|
195
|
|
196
|
private getDivContents() {
|
197
|
this.subscriptions.push(this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
|
198
|
this.divContents = contents;
|
199
|
}));
|
200
|
}
|
201
|
|
202
|
ngOnDestroy() {
|
203
|
this.subscriptions.forEach(subscription => {
|
204
|
if (subscription instanceof Subscriber) {
|
205
|
subscription.unsubscribe();
|
206
|
}
|
207
|
});
|
208
|
this.fetchDatasets.clearSubscriptions();
|
209
|
this.fetchPublications.clearSubscriptions();
|
210
|
this.fetchSoftware.clearSubscriptions();
|
211
|
this.fetchPublications.clearSubscriptions();
|
212
|
this.fetchDataproviders.clearSubscriptions();
|
213
|
this.fetchProjects.clearSubscriptions();
|
214
|
}
|
215
|
|
216
|
private getDataProviderInfo(id: string) {
|
217
|
this.warningMessage = '';
|
218
|
this.errorMessage = "";
|
219
|
this.showLoading = true;
|
220
|
|
221
|
this.dataProviderInfo = null;
|
222
|
|
223
|
this.showTabs = false;
|
224
|
if (this.datasourceId == null || this.datasourceId == '') {
|
225
|
this.showLoading = false;
|
226
|
this.warningMessage = "No valid datasource id";
|
227
|
} else {
|
228
|
this.subscriptions.push(this._dataproviderService.getDataproviderInfo(this.datasourceId, this.properties).subscribe(
|
229
|
data => {
|
230
|
this.dataProviderInfo = data;
|
231
|
this.seoService.createLinkForCanonicalURL(this.properties.domain +this.properties.baseLink + this._router.url);
|
232
|
if (typeof document !== 'undefined') {
|
233
|
this.getDataProviderAggregationStatus(this.dataProviderInfo.originalId);
|
234
|
} else {
|
235
|
this.aggregationStatusIsInitialized = true;
|
236
|
}
|
237
|
if (typeof document !== 'undefined') {
|
238
|
this.initTabs();
|
239
|
}
|
240
|
this.showTabs = true;
|
241
|
this.updateTitle(this.dataProviderInfo.title.name?this.dataProviderInfo.title.name:this.dataProviderInfo.officialName);
|
242
|
this.updateDescription(this.dataProviderInfo.description?this.dataProviderInfo.description: "Content provider, " + (this.dataProviderInfo.title.name?this.dataProviderInfo.title.name:this.dataProviderInfo.officialName));
|
243
|
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
244
|
this.subscriptions.push(this._piwikService.trackView(this.properties, this.dataProviderInfo.title.name, this.piwikSiteId).subscribe());
|
245
|
}
|
246
|
|
247
|
this.showLoading = false;
|
248
|
|
249
|
// if (this.dataProviderInfo.tabs != undefined && this.dataProviderInfo.tabs.length > 0) {
|
250
|
// this.activeTab = this.dataProviderInfo.tabs[0].name;
|
251
|
// }
|
252
|
},
|
253
|
err => {
|
254
|
//console.log(err);
|
255
|
this.handleError("Error getting content provider for id: " + this.datasourceId, err);
|
256
|
if (err.status == 404) {
|
257
|
this._router.navigate(['/error'], {
|
258
|
queryParams: {
|
259
|
"page": this._location.path(true),
|
260
|
"page_type": "dataprovider"
|
261
|
}
|
262
|
});
|
263
|
}
|
264
|
this.errorMessage = 'No dataProvider found';
|
265
|
this.showLoading = false;
|
266
|
this.seoService.createLinkForCanonicalURL(this.properties.domain + this.properties.baseLink + this.properties.searchLinkToDataProviders);
|
267
|
}
|
268
|
));
|
269
|
}
|
270
|
}
|
271
|
|
272
|
private getDataProviderAggregationStatus(originalId: string) {
|
273
|
this.subscriptions.push(this._dataproviderService.getDataproviderAggregationStatus(originalId, this.properties).subscribe(
|
274
|
data => {
|
275
|
this.dataProviderInfo.aggregationStatus = data;
|
276
|
},
|
277
|
err => {
|
278
|
//console.log(err);
|
279
|
this.handleError("Error getting content provider aggregation status for id: " + this.datasourceId, err);
|
280
|
},
|
281
|
() => {
|
282
|
this.aggregationStatusIsInitialized = true;
|
283
|
}
|
284
|
));
|
285
|
}
|
286
|
|
287
|
private updateDescription(description: string) {
|
288
|
this._meta.updateTag({content: description.substring(0, 160)}, "name='description'");
|
289
|
this._meta.updateTag({content: description.substring(0, 160)}, "property='og:description'");
|
290
|
}
|
291
|
|
292
|
private updateTitle(title: string) {
|
293
|
var _prefix = "";
|
294
|
// if(this.communityId) {
|
295
|
// _prefix = "OpenAIRE | ";
|
296
|
// }
|
297
|
// var _title = _prefix + ((title.length > 50) ? title.substring(0, 50) : title);
|
298
|
this._title.setTitle(title);
|
299
|
this._meta.updateTag({content: title}, "property='og:title'");
|
300
|
}
|
301
|
|
302
|
private updateUrl(url: string) {
|
303
|
this._meta.updateTag({content: url}, "property='og:url'");
|
304
|
}
|
305
|
|
306
|
private initTabs() {
|
307
|
|
308
|
//if (this.dataProviderInfo.tabs != undefined && this.dataProviderInfo.tabs.length > 0) {
|
309
|
this.reloadPublications = true;
|
310
|
this.reloadDatasets = true;
|
311
|
this.reloadSoftware = true;
|
312
|
this.reloadOrps = true;
|
313
|
this.reloadProjects = true;
|
314
|
this.reloadDataproviders = true;
|
315
|
this.reloadRelatedDatasources = true;
|
316
|
this.statsClicked = false;
|
317
|
|
318
|
//this.search(this.dataProviderInfo.tabs[0].content, 1, 10);
|
319
|
this.count(1, 0);
|
320
|
|
321
|
this.metricsClicked = false;
|
322
|
|
323
|
this.viewsFrameUrl = this.properties.framesAPIURL + 'merge.php?com=query&data=[{"query":"dtsrcRepoViews","dtsrcName":"' + this.datasourceId + '","table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":"","color":"","type":"chart","size":200,"sort":"xaxis","xStyle":{"r":-30,"s":"6","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"","yaxisheaders":["Monthly views"],"generalxaxis":"","theme":0,"in":[]}]&info_types=["column"]&stacking=&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(124, 181, 236, 1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false';
|
324
|
this.downloadsFrameUrl = this.properties.framesAPIURL + 'merge.php?com=query&data=[{"query":"dtsrcRepoDownloads","dtsrcName":"' + this.datasourceId + '","table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":"","color":"","type":"chart","size":200,"sort":"xaxis","xStyle":{"r":-30,"s":"6","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"","yaxisheaders":["Monthly downloads"],"generalxaxis":"","theme":0,"in":[]}]&info_types=["column"]&stacking=&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(124, 181, 236, 1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false';
|
325
|
this.fetchAggregatorsResults = new FetchResearchResults(this._searchResearchResultsService);
|
326
|
|
327
|
}
|
328
|
|
329
|
public getParamsForSearchLink(type: string = "") {
|
330
|
|
331
|
if (type) {
|
332
|
return this.routerHelper.createQueryParams(['f0', 'fv0', 'f1', 'fv1', 'type', 'qf', 'sortBy'], ["collectedfromdatasourceid", this.datasourceId, "resulthostingdatasourceid,or", this.datasourceId, type, "false", 'resultdateofacceptance,descending']);
|
333
|
} else {
|
334
|
return this.routerHelper.createQueryParams(['f0', 'fv0', 'f1', 'fv1'], ["collectedfromdatasourceid", this.datasourceId, "resulthostingdatasourceid,or", this.datasourceId]);
|
335
|
}
|
336
|
}
|
337
|
|
338
|
private count(page: number, size: number) {
|
339
|
|
340
|
this.countPublications(page, size);
|
341
|
this.countDatasets(page, size);
|
342
|
this.countSoftware(page, size);
|
343
|
this.countOrps(page, size);
|
344
|
this.countProjects(page, size);
|
345
|
this.countDatasources(page, size);
|
346
|
|
347
|
}
|
348
|
|
349
|
public search(content: string, page: number, size: number) {
|
350
|
if (content == 'publicationsTab') {
|
351
|
this.searchPublications(page, size);
|
352
|
} else if (content == 'datasetsTab') {
|
353
|
this.searchDatasets(page, size);
|
354
|
} else if (content == 'softwareTab') {
|
355
|
this.searchSoftware(page, size);
|
356
|
} else if (content == 'orpsTab') {
|
357
|
this.searchOrps(page, size);
|
358
|
} else if (content == 'projectsTab') {
|
359
|
this.searchProjects(page, size);
|
360
|
} else if (content == 'datasourcesTab') {
|
361
|
this.searchDatasources(page, size);
|
362
|
} else if (content == 'relatedDatasourcesTab') {
|
363
|
this.searchRelatedDatasources(1, 0);
|
364
|
} else if (content == 'metricsTab') {
|
365
|
this.metricsClicked = true;
|
366
|
} else if (content == 'statisticsTab') {
|
367
|
this.statsClicked = !this.statsClicked;
|
368
|
}
|
369
|
}
|
370
|
|
371
|
private searchPublications(page: number, size: number) {
|
372
|
if (this.reloadPublications &&
|
373
|
(this.fetchPublications.searchUtils.status == this.errorCodes.LOADING ||
|
374
|
(this.fetchPublications.searchUtils.status == this.errorCodes.DONE && this.fetchPublications.searchUtils.totalResults > 0)
|
375
|
)
|
376
|
) {
|
377
|
this.fetchPublications.getResultsForDataproviders("publication", this.datasourceId, this.dataProviderInfo.resultsBy, page, size, this.properties);
|
378
|
}
|
379
|
this.reloadPublications = false;
|
380
|
}
|
381
|
|
382
|
private countPublications(page: number, size: number) {
|
383
|
this.fetchPublications.getResultsForDataproviders("publication", this.datasourceId, this.dataProviderInfo.resultsBy, page, size, this.properties);
|
384
|
}
|
385
|
|
386
|
private searchDatasets(page: number, size: number) {
|
387
|
if (this.reloadDatasets &&
|
388
|
(this.fetchDatasets.searchUtils.status == this.errorCodes.LOADING ||
|
389
|
(this.fetchDatasets.searchUtils.status == this.errorCodes.DONE && this.fetchDatasets.searchUtils.totalResults > 0)
|
390
|
)
|
391
|
) {
|
392
|
this.fetchDatasets.getResultsForDataproviders("dataset", this.datasourceId, this.dataProviderInfo.resultsBy, page, size, this.properties);
|
393
|
}
|
394
|
this.reloadDatasets = false;
|
395
|
}
|
396
|
|
397
|
private countDatasets(page: number, size: number) {
|
398
|
this.fetchDatasets.getResultsForDataproviders("dataset", this.datasourceId, this.dataProviderInfo.resultsBy, page, size, this.properties);
|
399
|
}
|
400
|
|
401
|
private searchSoftware(page: number, size: number) {
|
402
|
if (this.reloadSoftware &&
|
403
|
(this.fetchSoftware.searchUtils.status == this.errorCodes.LOADING ||
|
404
|
(this.fetchSoftware.searchUtils.status == this.errorCodes.DONE && this.fetchSoftware.searchUtils.totalResults > 0)
|
405
|
)
|
406
|
) {
|
407
|
this.fetchSoftware.getResultsForDataproviders("software", this.datasourceId, this.dataProviderInfo.resultsBy, page, size, this.properties);
|
408
|
}
|
409
|
this.reloadSoftware = false;
|
410
|
}
|
411
|
|
412
|
private countSoftware(page: number, size: number) {
|
413
|
this.fetchSoftware.getResultsForDataproviders("software", this.datasourceId, this.dataProviderInfo.resultsBy, page, size, this.properties);
|
414
|
}
|
415
|
|
416
|
private searchOrps(page: number, size: number) {
|
417
|
if (this.reloadOrps &&
|
418
|
(this.fetchOrps.searchUtils.status == this.errorCodes.LOADING ||
|
419
|
(this.fetchOrps.searchUtils.status == this.errorCodes.DONE && this.fetchOrps.searchUtils.totalResults > 0)
|
420
|
)
|
421
|
) {
|
422
|
this.fetchOrps.getResultsForDataproviders("other", this.datasourceId, this.dataProviderInfo.resultsBy, page, size, this.properties);
|
423
|
}
|
424
|
this.reloadOrps = false;
|
425
|
}
|
426
|
|
427
|
private countOrps(page: number, size: number) {
|
428
|
this.fetchOrps.getResultsForDataproviders("other", this.datasourceId, this.dataProviderInfo.resultsBy, page, size, this.properties);
|
429
|
}
|
430
|
|
431
|
private searchProjects(page: number, size: number) {
|
432
|
if (this.reloadProjects &&
|
433
|
(this.fetchProjects.searchUtils.status == this.errorCodes.LOADING ||
|
434
|
(this.fetchProjects.searchUtils.status == this.errorCodes.DONE && this.fetchProjects.searchUtils.totalResults > 0)
|
435
|
)
|
436
|
) {
|
437
|
this.fetchProjects.getResultsForDataproviders(this.datasourceId, page, size, this.properties);
|
438
|
}
|
439
|
this.reloadProjects = false;
|
440
|
}
|
441
|
|
442
|
private countProjects(page: number, size: number) {
|
443
|
this.fetchProjects.getResultsForDataproviders(this.datasourceId, page, size, this.properties);
|
444
|
}
|
445
|
|
446
|
private searchDatasources(page: number, size: number) {
|
447
|
if (this.reloadDataproviders &&
|
448
|
(this.fetchDataproviders.searchUtils.status == this.errorCodes.LOADING ||
|
449
|
(this.fetchDataproviders.searchUtils.status == this.errorCodes.DONE && this.fetchDataproviders.searchUtils.totalResults > 0)
|
450
|
)
|
451
|
) {
|
452
|
this.fetchDataproviders.getResultsForDataproviders(this.datasourceId, page, size, this.properties);
|
453
|
}
|
454
|
this.reloadDataproviders = false;
|
455
|
}
|
456
|
|
457
|
private countDatasources(page: number, size: number) {
|
458
|
this.fetchDataproviders.getResultsForDataproviders(this.datasourceId, page, size, this.properties);
|
459
|
}
|
460
|
|
461
|
private searchRelatedDatasources(page: number, size: number) {
|
462
|
// Currently no counting is done for this tab. Following condition is always false
|
463
|
|
464
|
// if (this.reloadRelatedDatasources &&
|
465
|
// (this.fetchAggregatorsPublications.searchUtils.status == this.errorCodes.LOADING ||
|
466
|
// this.fetchAggregatorsPublications.searchUtils.status == this.errorCodes.DONE)
|
467
|
// &&
|
468
|
// (this.fetchAggregatorsDatasets.searchUtils.status == this.errorCodes.LOADING ||
|
469
|
// this.fetchAggregatorsDatasets.searchUtils.status == this.errorCodes.DONE)
|
470
|
// &&
|
471
|
// (this.fetchAggregatorsSoftware.searchUtils.status == this.errorCodes.LOADING ||
|
472
|
// this.fetchAggregatorsSoftware.searchUtils.status == this.errorCodes.DONE)
|
473
|
// &&
|
474
|
// (this.fetchAggregatorsOrps.searchUtils.status == this.errorCodes.LOADING ||
|
475
|
// this.fetchAggregatorsOrps.searchUtils.status == this.errorCodes.DONE)
|
476
|
// ) {
|
477
|
// this.relatedDatasourcesSub = observableMerge(this.fetchAggregatorsPublications.requestComplete, this.fetchAggregatorsDatasets.requestComplete, this.fetchAggregatorsSoftware.requestComplete, this.fetchAggregatorsOrps.requestComplete)
|
478
|
// .subscribe(
|
479
|
// data => {
|
480
|
// },
|
481
|
// err => {
|
482
|
// },
|
483
|
// () => {
|
484
|
// this.preprocessRelatedDatasources();
|
485
|
// }
|
486
|
// );
|
487
|
//
|
488
|
// this.fetchAggregatorsPublications.getAggregatorResults("publication", this.datasourceId, page, size, this.properties);
|
489
|
// this.fetchAggregatorsDatasets.getAggregatorResults("dataset", this.datasourceId, page, size, this.properties);
|
490
|
// this.fetchAggregatorsSoftware.getAggregatorResults("software", this.datasourceId, page, size, this.properties);
|
491
|
// this.fetchAggregatorsOrps.getAggregatorResults("other", this.datasourceId, page, size, this.properties);
|
492
|
if (this.reloadRelatedDatasources &&
|
493
|
(this.fetchAggregatorsResults.searchUtils.status == this.errorCodes.LOADING ||
|
494
|
(this.fetchAggregatorsResults.searchUtils.status == this.errorCodes.DONE && this.fetchAggregatorsResults.searchUtils.totalResults > 0)
|
495
|
)
|
496
|
) {
|
497
|
this.subscriptions.push(this.fetchAggregatorsResults.requestComplete.subscribe(
|
498
|
data => {
|
499
|
},
|
500
|
err => {
|
501
|
},
|
502
|
() => {
|
503
|
//this.preprocessRelatedDatasources();
|
504
|
this.dataProviderInfo.relatedDatasources = this.fetchAggregatorsResults.results;
|
505
|
this.loadingRelatedDatasources = false;
|
506
|
}
|
507
|
));
|
508
|
|
509
|
this.fetchAggregatorsResults.getAggregatorResults("results", this.datasourceId, page, size, this.properties);
|
510
|
} else {
|
511
|
this.loadingRelatedDatasources = false;
|
512
|
}
|
513
|
|
514
|
|
515
|
this.reloadRelatedDatasources = false;
|
516
|
}
|
517
|
|
518
|
private countRelatedDatasources(page: number, size: number) {
|
519
|
this.fetchAggregatorsResults.getAggregatorResults("results", this.datasourceId, page, size, this.properties);
|
520
|
}
|
521
|
|
522
|
public metricsResults($event) {
|
523
|
this.totalViews = $event.totalViews;
|
524
|
this.totalDownloads = $event.totalDownloads;
|
525
|
this.pageViews = $event.pageViews;
|
526
|
}
|
527
|
|
528
|
public get hasMetrics(): boolean {
|
529
|
return !(this.totalViews && this.totalDownloads && this.pageViews) || this.totalViews > 0 || this.totalDownloads > 0 || this.pageViews > 0;
|
530
|
}
|
531
|
|
532
|
public openStatistics() {
|
533
|
this.statsClicked = true;
|
534
|
this.statisticsModal.cancelButton = false;
|
535
|
this.statisticsModal.okButton = false;
|
536
|
this.statisticsModal.alertTitle = "Statistics of";
|
537
|
this.statisticsModal.open();
|
538
|
}
|
539
|
|
540
|
public openRelatedDatasources() {
|
541
|
this.searchRelatedDatasources(1, 0);
|
542
|
this.relatedDatasourcesModal.cancelButton = false;
|
543
|
this.relatedDatasourcesModal.okButton = false;
|
544
|
this.relatedDatasourcesModal.alertTitle = "Related content providers of";
|
545
|
this.relatedDatasourcesModal.open();
|
546
|
}
|
547
|
|
548
|
public scroll() {
|
549
|
HelperFunctions.scroll();
|
550
|
}
|
551
|
|
552
|
public removeUnknown(array: string[]): string[] {
|
553
|
return array.filter(value => value.toLowerCase() !== 'unknown');
|
554
|
}
|
555
|
|
556
|
private handleError(message: string, error) {
|
557
|
console.error("Content Provider Landing Page: " + message, error);
|
558
|
}
|
559
|
|
560
|
private getEntityName(entityType: string, plural: boolean, full: boolean): string {
|
561
|
if (entityType == "publication") {
|
562
|
return "publication" + (plural ? "s" : "");
|
563
|
} else if (entityType == "dataset") {
|
564
|
return (full ? "research data" : ("dataset" + (plural ? "s" : "")));
|
565
|
} else if (entityType == "software") {
|
566
|
return "software";
|
567
|
} else if (entityType == "other") {
|
568
|
return (full ? ("other research product" + (plural ? "s" : "")) : "other");
|
569
|
} else if (entityType == "dataprovider") {
|
570
|
return (full ? ("content provider" + (plural ? "s" : "")) : "dataprovider" + (plural ? "s" : ""));
|
571
|
} else {
|
572
|
return entityType + (plural ? "s" : "");
|
573
|
}
|
574
|
}
|
575
|
|
576
|
public getResultPreview(result: SearchResult, type: string): ResultPreview {
|
577
|
return ResultPreview.searchResultConvert(result, type);
|
578
|
}
|
579
|
|
580
|
public onSelectActiveTab(activeTabId) {
|
581
|
if (this.activeTab != "activaTabId") { // tab really changed
|
582
|
if (activeTabId == 'summary') {
|
583
|
this.activeTab = 'summary';
|
584
|
} else if (activeTabId == 'publications') {
|
585
|
this.activeTab = 'publications';
|
586
|
this.searchPublications(1, this.searchNumber);
|
587
|
} else if (activeTabId == 'datasets') {
|
588
|
this.activeTab = 'datasets';
|
589
|
this.searchDatasets(1, this.searchNumber);
|
590
|
} else if (activeTabId == 'software') {
|
591
|
this.activeTab = 'software';
|
592
|
this.searchSoftware(1, this.searchNumber);
|
593
|
} else if (activeTabId == 'other') {
|
594
|
this.activeTab = "other";
|
595
|
this.searchOrps(1, this.searchNumber);
|
596
|
} else if (activeTabId == 'projects') {
|
597
|
this.activeTab = "projects";
|
598
|
this.searchProjects(1, this.searchNumber);
|
599
|
} else if (activeTabId == 'datasources') {
|
600
|
this.activeTab = "datasources";
|
601
|
this.searchDatasources(1, this.searchNumber);
|
602
|
} else if (activeTabId == 'relatedDatasources') {
|
603
|
this.activeTab = "relatedDatasources";
|
604
|
this.searchRelatedDatasources(1, this.searchNumber);
|
605
|
} else if (activeTabId == 'statistics') {
|
606
|
this.activeTab = 'statistics';
|
607
|
this.statsClicked = true;
|
608
|
}
|
609
|
}
|
610
|
}
|
611
|
|
612
|
public get hasAggregationStatusInfo(): boolean {
|
613
|
return (!!this.dataProviderInfo.aggregationStatus &&
|
614
|
((!!this.dataProviderInfo.aggregationStatus.fulltexts && parseInt(this.dataProviderInfo.aggregationStatus.fulltexts) != -1)
|
615
|
|| (!!this.dataProviderInfo.aggregationStatus.fundedContent && parseInt(this.dataProviderInfo.aggregationStatus.fundedContent) != -1)
|
616
|
|| !!this.dataProviderInfo.aggregationStatus.lastUpdateDate));
|
617
|
}
|
618
|
|
619
|
public get hasJournalInfo(): boolean {
|
620
|
return (!!this.dataProviderInfo.journal && (
|
621
|
!!this.dataProviderInfo.journal['journal'] || !!this.dataProviderInfo.journal['issn'] ||
|
622
|
!!this.dataProviderInfo.journal['lissn'] || !!this.dataProviderInfo.journal['eissn'] ||
|
623
|
!!this.dataProviderInfo.journal['volume'] || !!this.dataProviderInfo.journal['issue'] ||
|
624
|
!!this.dataProviderInfo.journal['start_page'] || !!this.dataProviderInfo.journal['end_page']));
|
625
|
//return true;
|
626
|
}
|
627
|
|
628
|
public get hasPrimaryInfo(): boolean {
|
629
|
return !!this.dataProviderInfo && (
|
630
|
!!this.dataProviderInfo.description ||
|
631
|
this.hasJournalInfo ||
|
632
|
//this.hasAggregationStatusInfo ||
|
633
|
!!this.dataProviderInfo.countries ||
|
634
|
(!!this.dataProviderInfo.subjects && this.dataProviderInfo.subjects.length > 0));
|
635
|
}
|
636
|
|
637
|
public get hasSecondaryInfo(): boolean {
|
638
|
return !!this.dataProviderInfo && (
|
639
|
(!!this.dataProviderInfo.organizations && this.dataProviderInfo.organizations.length > 0)
|
640
|
|| !!this.dataProviderInfo.oaiPmhURL || !!this.dataProviderInfo.openDoarId || !!this.dataProviderInfo.r3DataId
|
641
|
);
|
642
|
}
|
643
|
|
644
|
}
|