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