1
|
import {Component, ViewChild} from '@angular/core';
|
2
|
import {Input} from '@angular/core';
|
3
|
import {ActivatedRoute, Router} from '@angular/router';
|
4
|
import {Title, Meta} from '@angular/platform-browser';
|
5
|
|
6
|
import {Observable} from 'rxjs';
|
7
|
|
8
|
import {DatasetInfo} from '../../utils/entities/datasetInfo';
|
9
|
import {EnvProperties} from '../../utils/properties/env-properties';
|
10
|
import {RouterHelper} from '../../utils/routerHelper.class';
|
11
|
|
12
|
import {DatasetService} from './dataset.service';
|
13
|
import {PiwikService} from '../../utils/piwik/piwik.service';
|
14
|
import { SEOService } from '../../sharedComponents/SEO/SEO.service';
|
15
|
import {HelperFunctions} from "../../utils/HelperFunctions.class";
|
16
|
|
17
|
|
18
|
@Component({
|
19
|
selector: 'dataset',
|
20
|
templateUrl: 'dataset.component.html',
|
21
|
})
|
22
|
|
23
|
export class DatasetComponent {
|
24
|
@Input() piwikSiteId = null;
|
25
|
public datasetInfo: DatasetInfo;
|
26
|
public datasetId : string ;
|
27
|
|
28
|
// APP BOX variables
|
29
|
public showAllCollectedFrom: boolean = false;
|
30
|
public showAllDownloadFrom: boolean = false;
|
31
|
public showAllPublishedIn: boolean = false;
|
32
|
|
33
|
public thresholdDescription: number = 270;
|
34
|
public showNumDescription: number = 270;
|
35
|
|
36
|
// Metrics tab variables
|
37
|
public metricsClicked: boolean;
|
38
|
public viewsFrameUrl: string;
|
39
|
public downloadsFrameUrl: string;
|
40
|
public totalViews: number;
|
41
|
public totalDownloads: number;
|
42
|
public pageViews: number;
|
43
|
|
44
|
// Custom tab paging variables
|
45
|
public referencesPage: number = 1;
|
46
|
public pageSize: number = 10;
|
47
|
|
48
|
// Active tab variable for responsiveness
|
49
|
public activeTab: string = "References";
|
50
|
|
51
|
// Map counting variable
|
52
|
public relatedResearchResultsNum: number = 0;
|
53
|
|
54
|
// Message variables
|
55
|
public warningMessage = "";
|
56
|
public errorMessage = "";
|
57
|
public showLoading: boolean = true;
|
58
|
|
59
|
public routerHelper:RouterHelper = new RouterHelper();
|
60
|
|
61
|
private result ;
|
62
|
sub: any; piwiksub: any; infoSub: any;
|
63
|
properties:EnvProperties;
|
64
|
|
65
|
constructor (private _datasetService: DatasetService,
|
66
|
private _piwikService:PiwikService,
|
67
|
private route: ActivatedRoute,
|
68
|
private _meta: Meta,
|
69
|
private _title: Title,
|
70
|
private _router: Router,
|
71
|
private seoService: SEOService) {
|
72
|
}
|
73
|
|
74
|
ngOnInit() {
|
75
|
this.route.data
|
76
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
77
|
this.properties = data.envSpecific;
|
78
|
this.updateUrl(data.envSpecific.baseLink+this._router.url);
|
79
|
|
80
|
});
|
81
|
this.sub = this.route.queryParams.subscribe(params => {
|
82
|
this.datasetInfo = null;
|
83
|
this.updateTitle("Dataset");
|
84
|
this.updateDescription("");
|
85
|
|
86
|
this.datasetId = params['datasetId'];
|
87
|
|
88
|
if(this.datasetId){
|
89
|
this.getDatasetInfo(this.datasetId);
|
90
|
}else{
|
91
|
this.showLoading = false;
|
92
|
this.warningMessage="No valid research data id";
|
93
|
}
|
94
|
|
95
|
this.metricsClicked = false;
|
96
|
|
97
|
this.viewsFrameUrl = this.properties.framesAPIURL+'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';
|
98
|
/*this.viewsFrameUrl = this.properties.framesAPIURL+'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';
|
99
|
*/
|
100
|
|
101
|
this.downloadsFrameUrl = this.properties.framesAPIURL+'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';
|
102
|
/*this.downloadsFrameUrl = this.properties.framesAPIURL+'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';
|
103
|
*/
|
104
|
this.scroll();
|
105
|
});
|
106
|
|
107
|
}
|
108
|
|
109
|
ngOnDestroy() {
|
110
|
if(this.sub){
|
111
|
this.sub.unsubscribe();
|
112
|
}
|
113
|
if(this.piwiksub){
|
114
|
this.piwiksub.unsubscribe();
|
115
|
}
|
116
|
if(this.infoSub) {
|
117
|
this.infoSub.unsubscribe();
|
118
|
}
|
119
|
}
|
120
|
|
121
|
private getDatasetInfo(id:string) {
|
122
|
this.warningMessage = '';
|
123
|
this.errorMessage=""
|
124
|
this.showLoading = true;
|
125
|
|
126
|
this.datasetInfo = null;
|
127
|
|
128
|
this.infoSub = this._datasetService.getDatasetInfo(id, this. properties).subscribe(
|
129
|
data => {
|
130
|
this.datasetInfo = data;
|
131
|
this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this.properties.searchLinkToDataset + this.datasetInfo.record["result"]["header"]["dri:objIdentifier"]);
|
132
|
/*
|
133
|
if(this.datasetInfo.title.name != undefined && this.datasetInfo.title.name!= ''){
|
134
|
this.updateTitle(this.datasetInfo.title.name);
|
135
|
this.updateDescription("Dataset, search, repositories, open access,"+this.datasetInfo.title.name);
|
136
|
}
|
137
|
*/
|
138
|
if(this.datasetInfo.title){
|
139
|
this.updateTitle(this.datasetInfo.title);
|
140
|
this.updateDescription((this.datasetInfo.description?(this.datasetInfo.description):(","+this.datasetInfo.title)));
|
141
|
}
|
142
|
if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
|
143
|
this.piwiksub = this._piwikService.trackView(this.properties, this.datasetInfo.title/*.name*/, this.piwikSiteId).subscribe();
|
144
|
}
|
145
|
|
146
|
this.result = []
|
147
|
this.result = {id: id, type :"dataset", source : "openaire", title: this.datasetInfo.title,url: '', result: '', accessRights: /*this.datasetInfo.title.accessMode*/ this.datasetInfo.accessMode, embargoEndDate: ''};
|
148
|
|
149
|
let relatedResearchResultsNum = 0;
|
150
|
if(this.datasetInfo.relatedResearchResults != undefined) {
|
151
|
this.datasetInfo.relatedResearchResults.forEach(function (value, key, map) {
|
152
|
relatedResearchResultsNum += value.length;
|
153
|
});
|
154
|
}
|
155
|
this.relatedResearchResultsNum = relatedResearchResultsNum;
|
156
|
|
157
|
this.showLoading = false;
|
158
|
},
|
159
|
err => {
|
160
|
//console.log(err)
|
161
|
this.handleError("Error getting research data for id: "+this.datasetId, err);
|
162
|
this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this.properties.searchLinkToDatasets);
|
163
|
this.errorMessage = 'No research data found';
|
164
|
this.showLoading = false;
|
165
|
}
|
166
|
);
|
167
|
}
|
168
|
|
169
|
// showChange($event) {
|
170
|
// this.showAllReferences=$event.value;
|
171
|
// }
|
172
|
|
173
|
public metricsResults($event) {
|
174
|
this.totalViews = $event.totalViews;
|
175
|
this.totalDownloads = $event.totalDownloads;
|
176
|
this.pageViews = $event.pageViews;
|
177
|
}
|
178
|
|
179
|
private updateDescription(description:string){
|
180
|
this._meta.updateTag({content:description},"name='description'");
|
181
|
this._meta.updateTag({content:description},"property='og:description'");
|
182
|
}
|
183
|
private updateTitle(title:string){
|
184
|
var _prefix ="OpenAIRE | ";
|
185
|
var _title = _prefix + ((title.length> 50 ) ?title.substring(0,50):title);
|
186
|
this._title.setTitle(_title);
|
187
|
this._meta.updateTag({content:_title},"property='og:title'");
|
188
|
}
|
189
|
private updateUrl(url:string){
|
190
|
this._meta.updateTag({content:url},"property='og:url'");
|
191
|
}
|
192
|
|
193
|
public buildCurationTooltip() {
|
194
|
let tooltipContent: string = "<div class='uk-padding-small uk-light'>";
|
195
|
|
196
|
tooltipContent += "<h4>Record in preview</h4>";
|
197
|
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>";
|
198
|
|
199
|
return tooltipContent;
|
200
|
}
|
201
|
public getKeys( map) {
|
202
|
return Array.from(map.keys());
|
203
|
}
|
204
|
|
205
|
private handleError(message: string, error) {
|
206
|
console.error("Research Data Landing Page: "+message, error);
|
207
|
}
|
208
|
|
209
|
public updateReferencesPage($event) {
|
210
|
this.referencesPage = $event.value;
|
211
|
}
|
212
|
|
213
|
public totalPages(totalResults: number): number {
|
214
|
let totalPages:any = totalResults/this.pageSize;
|
215
|
if(!(Number.isInteger(totalPages))) {
|
216
|
totalPages = (parseInt(totalPages, this.pageSize) + 1);
|
217
|
}
|
218
|
return totalPages;
|
219
|
}
|
220
|
|
221
|
public scroll() {
|
222
|
HelperFunctions.scroll();
|
223
|
}
|
224
|
}
|