1
|
import {Component, ViewChild, ElementRef} from '@angular/core';
|
2
|
import {Observable} from 'rxjs/Observable';
|
3
|
import {DatasetService} from './dataset.service';
|
4
|
import {DatasetInfo} from '../../utils/entities/datasetInfo';
|
5
|
import {ActivatedRoute, Router} from '@angular/router';
|
6
|
import {OpenaireProperties} from '../../utils/properties/openaireProperties'
|
7
|
import {RouterHelper} from '../../utils/routerHelper.class';
|
8
|
import { Meta} from '../../../angular2-meta';
|
9
|
|
10
|
@Component({
|
11
|
selector: 'dataset',
|
12
|
templateUrl: 'dataset.component.html',
|
13
|
})
|
14
|
|
15
|
export class DatasetComponent {
|
16
|
public datasetInfo: DatasetInfo;
|
17
|
|
18
|
public showAllCollectedFrom: boolean = false;
|
19
|
public showAllDownloadFrom: boolean = false;
|
20
|
public showAllPublishedIn: boolean = false;
|
21
|
public showAllFundedBy: boolean = false;
|
22
|
|
23
|
private showStyle: boolean = false;
|
24
|
private showAllReferences: boolean = false;
|
25
|
private showAllRelResData: boolean = false;
|
26
|
private showAllSimilPubl: boolean = false;
|
27
|
private showAllBioentities: boolean = false;
|
28
|
private datasetId : string ;
|
29
|
private result ;
|
30
|
sub: any;
|
31
|
|
32
|
private activeTab: string = "Related Research Results";
|
33
|
private metricsClicked: boolean;
|
34
|
private viewsFrameUrl: string;
|
35
|
private downloadsFrameUrl: string;
|
36
|
private totalViews: number;
|
37
|
private totalDownloads: number;
|
38
|
private pageViews: number;
|
39
|
|
40
|
public relatedResearchResultsNum: number = 0;
|
41
|
|
42
|
public warningMessage = "";
|
43
|
public errorMessage = "";
|
44
|
public showLoading: boolean = true;
|
45
|
|
46
|
public routerHelper:RouterHelper = new RouterHelper();
|
47
|
|
48
|
constructor (private element: ElementRef,
|
49
|
private _datasetService: DatasetService,
|
50
|
private route: ActivatedRoute,
|
51
|
private _meta: Meta,
|
52
|
private _router: Router) {
|
53
|
this.updateUrl(OpenaireProperties.getBaseLink()+this._router.url);
|
54
|
}
|
55
|
|
56
|
ngOnInit() {
|
57
|
this.sub = this.route.queryParams.subscribe(params => {
|
58
|
this.datasetInfo = null;
|
59
|
this.updateTitle("Dataset");
|
60
|
this.updateDescription("Dataset, search, open access");
|
61
|
|
62
|
this.datasetId = params['datasetId'];
|
63
|
console.info("Id is :"+this.datasetId);
|
64
|
|
65
|
if(this.datasetId){
|
66
|
this.getDatasetInfo(this.datasetId);
|
67
|
}else{
|
68
|
this.showLoading = false;
|
69
|
this.warningMessage="No valid dataset id";
|
70
|
}
|
71
|
|
72
|
this.metricsClicked = false;
|
73
|
|
74
|
this.viewsFrameUrl = OpenaireProperties.getFramesAPIURL()+'merge.php?com=query&data=[{"query":"resRepoViews", "resTitle":"'+this.datasetId+'", "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":["Monthly views"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["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(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';
|
75
|
/*this.viewsFrameUrl = OpenaireProperties.getFramesAPIURL()+'merge.php?com=query&data=[{"query":"resViewsTimeline", "resTitle":"'+this.datasetId+'", "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":["Monthly views"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["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&persistent=false';
|
76
|
*/
|
77
|
|
78
|
this.downloadsFrameUrl = OpenaireProperties.getFramesAPIURL()+'merge.php?com=query&data=[{"query":"resRepoDownloads", "resTitle":"'+this.datasetId+'", "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":["Monthly downloads"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["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(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';
|
79
|
/*this.downloadsFrameUrl = OpenaireProperties.getFramesAPIURL()+'merge.php?com=query&data=[{"query":"resRepoDownloadTimeline", "resTitle":"'+this.datasetId+'", "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":["Monthly downloads"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["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(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';
|
80
|
*/
|
81
|
if (typeof document !== 'undefined') {
|
82
|
this.element.nativeElement.scrollIntoView();
|
83
|
}
|
84
|
});
|
85
|
|
86
|
}
|
87
|
|
88
|
ngOnDestroy() {
|
89
|
this.sub.unsubscribe();
|
90
|
}
|
91
|
|
92
|
getDatasetInfo(id:string) {
|
93
|
this.warningMessage = '';
|
94
|
this.errorMessage=""
|
95
|
this.showLoading = true;
|
96
|
|
97
|
this._datasetService.getDatasetInfo(id).subscribe(
|
98
|
data => {
|
99
|
this.datasetInfo = data;
|
100
|
this.updateTitle(this.datasetInfo.title.name);
|
101
|
this.updateDescription("Dataset, search, repositories, open access,"+this.datasetInfo.title.name);
|
102
|
this.result = []
|
103
|
this.result = {id: id, type :"dataset", source : "openaire", title: this.datasetInfo.title,url: '', result: '', accessRights: this.datasetInfo.title.accessMode, embargoEndDate: ''};
|
104
|
|
105
|
let relatedResearchResultsNum = 0;
|
106
|
if(this.datasetInfo.relatedResearchResults != undefined) {
|
107
|
this.datasetInfo.relatedResearchResults.forEach(function (value, key, map) {
|
108
|
relatedResearchResultsNum += value.length;
|
109
|
});
|
110
|
}
|
111
|
this.relatedResearchResultsNum = relatedResearchResultsNum;
|
112
|
|
113
|
this.showLoading = false;
|
114
|
},
|
115
|
err => {
|
116
|
console.log(err)
|
117
|
console.info("error");
|
118
|
|
119
|
this.errorMessage = 'No dataset found';
|
120
|
this.showLoading = false;
|
121
|
}
|
122
|
);
|
123
|
}
|
124
|
|
125
|
showChange($event) {
|
126
|
this.showAllReferences=$event.value;
|
127
|
}
|
128
|
|
129
|
public metricsResults($event) {
|
130
|
this.totalViews = $event.totalViews;
|
131
|
this.totalDownloads = $event.totalDownloads;
|
132
|
this.pageViews = $event.pageViews;
|
133
|
}
|
134
|
updateDescription(description:string){
|
135
|
this._meta.updateMeta("description", description);
|
136
|
this._meta.updateProperty("og:description", description);
|
137
|
}
|
138
|
updateTitle(title:string){
|
139
|
var _suffix ="| OpenAIRE";
|
140
|
var _title = ((title.length> 50 ) ?title.substring(0,50):title) + _suffix;
|
141
|
this._meta.setTitle(_title );
|
142
|
this._meta.updateProperty("og:title",_title);
|
143
|
}
|
144
|
updateUrl(url:string){
|
145
|
this._meta.updateProperty("og:url", url);
|
146
|
}
|
147
|
|
148
|
public buildCurationTooltip() {
|
149
|
let tooltipContent: string = "<div class='uk-padding-small uk-light'>";
|
150
|
|
151
|
tooltipContent += "<h4>Record in preview</h4>";
|
152
|
tooltipContent += "<p>Bibliographic record accepted by the system, but not yet processed by <br> OpenAIRE tools for information quality improvement and de-duplication</p></di>";
|
153
|
|
154
|
return tooltipContent;
|
155
|
}
|
156
|
|
157
|
public buildFundingTooltip(item: { "id": string, "acronym": string, "title": string,
|
158
|
"funderShortname": string, "funderName": string,
|
159
|
"funding": string, "code": string, "provenanceAction":string, "inline": boolean}) {
|
160
|
let tooltipContent: string = "<div class='tooltip-custom-font-size uk-light uk-padding-small'>";
|
161
|
|
162
|
if(item.title) {
|
163
|
tooltipContent += "<h5>"+item.title+"</h5>";
|
164
|
}
|
165
|
|
166
|
if(item.code || item.funderName || item.funderShortname || item.funding) {
|
167
|
tooltipContent += "<p>";
|
168
|
}
|
169
|
|
170
|
if(item.code) {
|
171
|
tooltipContent += "<div>Project Code: "+item.code + "</div>";
|
172
|
}
|
173
|
|
174
|
if(item.funderName || item.funderShortname) {
|
175
|
tooltipContent += "<div>Funder: ";
|
176
|
if(item.funderName && item.funderShortname) {
|
177
|
tooltipContent += item.funderName + " ("+ item.funderShortname +")";
|
178
|
} else if(item.funderName) {
|
179
|
tooltipContent += item.funderName;
|
180
|
} else {
|
181
|
tooltipContent += item.funderShortname;
|
182
|
}
|
183
|
|
184
|
tooltipContent += "</div>";
|
185
|
}
|
186
|
|
187
|
if(item.funding) {
|
188
|
tooltipContent += "<div>Funding: "+ item.funding + "</div>";
|
189
|
}
|
190
|
|
191
|
if(item.code || item.funderName || item.funderShortname || item.funding) {
|
192
|
tooltipContent += "</p>";
|
193
|
}
|
194
|
|
195
|
if(item.provenanceAction == 'Repository') {
|
196
|
tooltipContent += "Provided by Repository";
|
197
|
} else if(item.provenanceAction == 'Algorithm') {
|
198
|
tooltipContent += "Inferred by Algorithm";
|
199
|
} else if(item.provenanceAction == 'USer') {
|
200
|
tooltipContent += "Claimed by User";
|
201
|
}
|
202
|
|
203
|
tooltipContent+="</div>"
|
204
|
return tooltipContent;
|
205
|
}
|
206
|
}
|