1
|
import {ChangeDetectorRef, Component, Input, ViewChild} from '@angular/core';
|
2
|
import {ActivatedRoute, Router} from '@angular/router';
|
3
|
import {Meta, Title} from '@angular/platform-browser';
|
4
|
|
5
|
import {EnvProperties} from '../../utils/properties/env-properties';
|
6
|
import {Id, ResultLandingInfo} from '../../utils/entities/resultLandingInfo';
|
7
|
import {RouterHelper} from '../../utils/routerHelper.class';
|
8
|
|
9
|
import {PiwikService} from '../../utils/piwik/piwik.service';
|
10
|
import {ResultLandingService} from './resultLanding.service';
|
11
|
import {SEOService} from '../../sharedComponents/SEO/SEO.service';
|
12
|
import {HelperFunctions} from '../../utils/HelperFunctions.class';
|
13
|
import {HelperService} from '../../utils/helper/helper.service';
|
14
|
import {Location} from "@angular/common";
|
15
|
import {MetricsService} from "../../services/metrics.service";
|
16
|
import {RelationResult, ResultPreview} from "../../utils/result-preview/result-preview";
|
17
|
import {IndexInfoService} from "../../utils/indexInfo.service";
|
18
|
import {FormBuilder} from "@angular/forms";
|
19
|
import {Identifier, StringUtils} from "../../utils/string-utils.class";
|
20
|
import {properties} from "../../../../environments/environment";
|
21
|
import {ISVocabulariesService} from "../../utils/staticAutoComplete/ISVocabularies.service";
|
22
|
import {Subscriber} from "rxjs";
|
23
|
import {Session} from "../../login/utils/helper.class";
|
24
|
import {AnnotationComponent} from "../annotation/annotation.component";
|
25
|
import {Session, User} from "../../login/utils/helper.class";
|
26
|
|
27
|
|
28
|
@Component({
|
29
|
selector: 'result-landing',
|
30
|
templateUrl: 'resultLanding.component.html',
|
31
|
})
|
32
|
export class ResultLandingComponent {
|
33
|
@Input() type: string = "publication";
|
34
|
@Input() piwikSiteId = properties.piwikSiteId;
|
35
|
@Input() communityId = null;
|
36
|
@ViewChild('linkModal') linkModal;
|
37
|
@ViewChild('citeModal') citeModal;
|
38
|
@ViewChild('AlertModalDeletedByInference') alertModalDeletedByInference;
|
39
|
@ViewChild('relationModal') relationModal;
|
40
|
@ViewChild('organizationModal') organizationModal;
|
41
|
public deleteByInferenceOpened: boolean = false;
|
42
|
|
43
|
public resultLandingInfo: ResultLandingInfo;
|
44
|
public supplementaryResults: RelationResult[];
|
45
|
public relation: string = 'trust';
|
46
|
public id: string;
|
47
|
public title: string;
|
48
|
|
49
|
/*Show all organizations*/
|
50
|
public showAll: boolean = false;
|
51
|
|
52
|
// Links for SEO
|
53
|
public linkToLandingPage: string = null;
|
54
|
public linkToSearchPage: string = null;
|
55
|
|
56
|
public thresholdDescription: number = 670;
|
57
|
public showNumDescription: number = 670;
|
58
|
|
59
|
public citeThisClicked: boolean;
|
60
|
|
61
|
// Metrics tab variables
|
62
|
public metricsClicked: boolean;
|
63
|
public hasAltMetrics: boolean = false;
|
64
|
public viewsFrameUrl: string;
|
65
|
public downloadsFrameUrl: string;
|
66
|
public totalViews: number;
|
67
|
public totalDownloads: number;
|
68
|
public pageViews: number;
|
69
|
|
70
|
// Custom tab paging variables
|
71
|
public referencesPage: number = 1;
|
72
|
public bioentitiesPage: number = 1;
|
73
|
public relatedPage: number = 1;
|
74
|
public similarPage: number = 1;
|
75
|
public supplementaryPage: number = 1;
|
76
|
public supplementedByPage: number = 1;
|
77
|
public organizationsPage: number = 1;
|
78
|
public openCitationsPage: number = 1;
|
79
|
public pageSize: number = 10;
|
80
|
|
81
|
// Map counting variables
|
82
|
public bioentitiesNum: number = 0;
|
83
|
public relatedResultsNum: number = 0;
|
84
|
|
85
|
// Message variables
|
86
|
public warningMessage = "";
|
87
|
public errorMessage = "";
|
88
|
public showLoading: boolean = true;
|
89
|
public dashboard = properties.isDashboard;
|
90
|
|
91
|
public routerHelper: RouterHelper = new RouterHelper();
|
92
|
public activeTab: string = null;
|
93
|
private doi: string;
|
94
|
subscriptions = [];
|
95
|
properties: EnvProperties = properties;
|
96
|
public indexUpdateDate: Date;
|
97
|
public pageContents = null;
|
98
|
public divContents = null;
|
99
|
public showFeedback: boolean = false;
|
100
|
public feedbackFields: string [] = [
|
101
|
'Title', 'Authors', 'Access rights',
|
102
|
'Publisher information', 'Funding Information',
|
103
|
'Persistent identifiers', 'Other'];
|
104
|
public loggedIn: boolean = false;
|
105
|
public pidsArrayString: string = "";
|
106
|
public identifier: Identifier;
|
107
|
|
108
|
public user: User;
|
109
|
public pid: string;
|
110
|
@ViewChild("annotation") annotation: AnnotationComponent;
|
111
|
|
112
|
constructor(private _resultLandingService: ResultLandingService,
|
113
|
private _vocabulariesService: ISVocabulariesService,
|
114
|
private _piwikService: PiwikService,
|
115
|
private route: ActivatedRoute,
|
116
|
private router: Router,
|
117
|
private _meta: Meta,
|
118
|
private _title: Title,
|
119
|
private _router: Router,
|
120
|
private helper: HelperService,
|
121
|
private seoService: SEOService,
|
122
|
private metricsService: MetricsService,
|
123
|
private cdr: ChangeDetectorRef,
|
124
|
private _location: Location,
|
125
|
private indexInfoService: IndexInfoService) {
|
126
|
}
|
127
|
|
128
|
ngOnInit() {
|
129
|
if (typeof document !== 'undefined') {
|
130
|
this.subscriptions.push(this.indexInfoService.getLastIndexDate(this.properties).subscribe(lastIndexUpdate => {
|
131
|
if (lastIndexUpdate) {
|
132
|
this.indexUpdateDate = new Date(lastIndexUpdate);
|
133
|
}
|
134
|
}));
|
135
|
}
|
136
|
//this.getDivContents();
|
137
|
this.getPageContents();
|
138
|
this.updateUrl(this.properties.domain +this.properties.baseLink + this._router.url);
|
139
|
this.subscriptions.push(this.route.queryParams.subscribe(async data => {
|
140
|
if (Session.isLoggedIn()) {
|
141
|
this.loggedIn = true;
|
142
|
}
|
143
|
this.resultLandingInfo = null;
|
144
|
if (data['articleId']) {
|
145
|
this.id = data['articleId'];
|
146
|
this.initMetaAndLinks("publication");
|
147
|
} else if (data['datasetId']) {
|
148
|
this.id = data['datasetId'];
|
149
|
this.initMetaAndLinks("dataset");
|
150
|
} else if (data['softwareId']) {
|
151
|
this.id = data['softwareId'];
|
152
|
this.initMetaAndLinks("software");
|
153
|
} else if (data['orpId']) {
|
154
|
this.id = data['orpId'];
|
155
|
this.initMetaAndLinks("orp");
|
156
|
} else if (data["id"]) {
|
157
|
this.id = data["id"];
|
158
|
this.initMetaAndLinks("result");
|
159
|
} else if (data["pid"]) {
|
160
|
this.identifier = Identifier.getIdentifierFromString(data["pid"]);
|
161
|
console.debug(this.identifier);
|
162
|
|
163
|
if(!this.type) {
|
164
|
this.type = "result";
|
165
|
}
|
166
|
this.initMetaAndLinks(this.type);
|
167
|
}
|
168
|
this.updateDescription("");
|
169
|
|
170
|
this.metricsClicked = false;
|
171
|
|
172
|
if ((this.id && StringUtils.isOpenAIREID(this.id)) || (this.identifier)) {
|
173
|
this.getProvenanceVocabularyAndResultLandingInfo();
|
174
|
} else {
|
175
|
this.showLoading = false;
|
176
|
|
177
|
this._router.navigate(['/error'], {
|
178
|
queryParams: {
|
179
|
"page": this._location.path(true),
|
180
|
"page_type": this.type
|
181
|
}
|
182
|
});
|
183
|
}
|
184
|
|
185
|
if(this.id) {
|
186
|
this.viewsFrameUrl = this.properties.framesAPIURL + 'merge.php?com=query&data=[{"query":"resRepoViews", "resTitle":"' + this.id + '", "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":"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';
|
187
|
this.downloadsFrameUrl = this.properties.framesAPIURL + 'merge.php?com=query&data=[{"query":"resRepoDownloads", "resTitle":"' + this.id + '", "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":"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';
|
188
|
}
|
189
|
|
190
|
this.scroll();
|
191
|
}));
|
192
|
}
|
193
|
|
194
|
private initMetaAndLinks(type: string) {
|
195
|
if (type == "publication") {
|
196
|
this.type = "publication";
|
197
|
this.updateTitle("Publication");
|
198
|
this.linkToLandingPage = this.properties.searchLinkToPublication;
|
199
|
this.linkToSearchPage = this.properties.searchLinkToPublications;
|
200
|
this.title = "Publication";
|
201
|
} else if (type == "dataset") {
|
202
|
this.updateTitle("Dataset");
|
203
|
this.type = "dataset";
|
204
|
this.linkToLandingPage = this.properties.searchLinkToDataset;
|
205
|
this.linkToSearchPage = this.properties.searchLinkToDatasets;
|
206
|
this.title = "Research Data";
|
207
|
} else if (type == "software") {
|
208
|
this.updateTitle("Software");
|
209
|
this.type = "software";
|
210
|
this.linkToLandingPage = this.properties.searchLinkToSoftwareLanding;
|
211
|
this.linkToSearchPage = this.properties.searchLinkToSoftware;
|
212
|
this.title = "Software";
|
213
|
} else if (type == "orp") {
|
214
|
this.type = "orp";
|
215
|
this.updateTitle("Other Research Product");
|
216
|
this.linkToLandingPage = this.properties.searchLinkToOrp;
|
217
|
this.linkToSearchPage = this.properties.searchLinkToOrps;
|
218
|
this.title = "Other Research Product";
|
219
|
} else if (type == "result") {
|
220
|
this.type = "result";
|
221
|
this.updateTitle("Research Result");
|
222
|
this.linkToLandingPage = this.properties.searchLinkToResult;
|
223
|
this.linkToSearchPage = this.properties.searchLinkToResults;
|
224
|
this.title = "Research Result";
|
225
|
}
|
226
|
}
|
227
|
|
228
|
private getPageContents() {
|
229
|
if (this.communityId) {
|
230
|
this.subscriptions.push(this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
|
231
|
this.pageContents = contents;
|
232
|
}));
|
233
|
}
|
234
|
}
|
235
|
|
236
|
private getDivContents() {
|
237
|
if (this.communityId) {
|
238
|
this.subscriptions.push(this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
|
239
|
this.divContents = contents;
|
240
|
}));
|
241
|
}
|
242
|
}
|
243
|
|
244
|
ngOnDestroy() {
|
245
|
this.subscriptions.forEach(subscription => {
|
246
|
if (subscription instanceof Subscriber) {
|
247
|
subscription.unsubscribe();
|
248
|
}
|
249
|
});
|
250
|
this._vocabulariesService.clearSubscriptions();
|
251
|
}
|
252
|
|
253
|
public pidInit(event) {
|
254
|
this.pid = event;
|
255
|
this.cdr.detectChanges();
|
256
|
}
|
257
|
|
258
|
|
259
|
public getTypeName(): string {
|
260
|
if (this.type === "dataset") {
|
261
|
return "research data";
|
262
|
} else if (this.type === "orp" || this.type === "other") {
|
263
|
return "research product";
|
264
|
} else {
|
265
|
return this.type;
|
266
|
}
|
267
|
}
|
268
|
|
269
|
public removeUnknown(array: string[], type: boolean = false): string[] {
|
270
|
if (type) {
|
271
|
return this.removeDuplicates(array).filter(value => value.toLowerCase() !== 'unknown');
|
272
|
} else {
|
273
|
return array.filter(value => value.toLowerCase() !== 'unknown');
|
274
|
}
|
275
|
}
|
276
|
|
277
|
public removeDuplicates(array: string[]): string[] {
|
278
|
let type = this.getTypeName();
|
279
|
return array.filter(value => value.toLowerCase() !== type);
|
280
|
}
|
281
|
|
282
|
private getOpenCitations() {
|
283
|
this.subscriptions.push(this._resultLandingService.getOpenCitations(this.id, this.properties).subscribe(
|
284
|
data => {
|
285
|
this.resultLandingInfo.openCitations = data[1];
|
286
|
},
|
287
|
err => {
|
288
|
this.handleError("Error getting open citation for " + this.type + " with id: " + this.id, err);
|
289
|
}
|
290
|
));
|
291
|
}
|
292
|
|
293
|
private getProvenanceVocabularyAndResultLandingInfo() {
|
294
|
this.warningMessage = '';
|
295
|
this.errorMessage = '';
|
296
|
this.showLoading = true;
|
297
|
|
298
|
this.resultLandingInfo = null;
|
299
|
|
300
|
if (typeof document !== 'undefined') {
|
301
|
this.subscriptions.push(this._vocabulariesService.getProvenanceActionVocabulary(this.properties).subscribe(
|
302
|
provenanceActionVocabulary => {
|
303
|
this.getResultLandingInfo(provenanceActionVocabulary);
|
304
|
}, err => {
|
305
|
this.getResultLandingInfo(null);
|
306
|
this.handleError("Error getting provenance action vocabulary for " + this.type, err);
|
307
|
}
|
308
|
));
|
309
|
} else {
|
310
|
this.getResultLandingInfo(null);
|
311
|
}
|
312
|
|
313
|
}
|
314
|
|
315
|
private setActiveTab() {
|
316
|
if (this.hasPrimaryInfo || this.hasSecondaryInfo) {
|
317
|
this.activeTab = 'summary';
|
318
|
} else if (this.resultLandingInfo.references && this.resultLandingInfo.references.length > 0) {
|
319
|
this.activeTab = 'references';
|
320
|
} else if ((this.resultLandingInfo.supplementaryResearchResults && this.resultLandingInfo.supplementaryResearchResults.length > 0) ||
|
321
|
(this.resultLandingInfo.supplementedByResearchResults && this.resultLandingInfo.supplementedByResearchResults.length > 0)) {
|
322
|
this.activeTab = 'supplementary';
|
323
|
} else if ((this.resultLandingInfo.relatedResearchResults && this.resultLandingInfo.relatedResearchResults.length > 0) ||
|
324
|
(this.resultLandingInfo.similarResearchResults && this.resultLandingInfo.similarResearchResults.length > 0)) {
|
325
|
this.activeTab = 'related';
|
326
|
} else if (this.resultLandingInfo.bioentities && this.bioentitiesNum > 0) {
|
327
|
this.activeTab = 'bioentities';
|
328
|
}
|
329
|
}
|
330
|
|
331
|
// private get numberOfTabs(): number {
|
332
|
// let numberOfTabs = 0;
|
333
|
// if(this.hasPrimaryInfo || this.hasSecondaryInfo) {
|
334
|
// numberOfTabs++;
|
335
|
// }
|
336
|
// if(this.resultLandingInfo.references && this.resultLandingInfo.references.length > 0) {
|
337
|
// numberOfTabs++;
|
338
|
// }
|
339
|
// if((this.resultLandingInfo.supplementaryResearchResults && this.resultLandingInfo.supplementaryResearchResults.length > 0) ||
|
340
|
// (this.resultLandingInfo.supplementedByResearchResults && this.resultLandingInfo.supplementedByResearchResults.length > 0)) {
|
341
|
// numberOfTabs++;
|
342
|
// }
|
343
|
// if((this.resultLandingInfo.relatedResearchResults && this.resultLandingInfo.relatedResearchResults.length > 0) ||
|
344
|
// (this.resultLandingInfo.similarResearchResults && this.resultLandingInfo.similarResearchResults.length > 0)) {
|
345
|
// numberOfTabs++;
|
346
|
// }
|
347
|
// if(this.resultLandingInfo.bioentities && this.bioentitiesNum > 0) {
|
348
|
// numberOfTabs++;
|
349
|
// }
|
350
|
// return numberOfTabs;
|
351
|
// }
|
352
|
|
353
|
private getResultLandingInfo(provenanceActionVocabulary: any) {
|
354
|
this.subscriptions.push(this._resultLandingService.getResultLandingInfo(this.id, this.identifier, this.type, provenanceActionVocabulary, this.properties).subscribe(
|
355
|
data => {
|
356
|
this.resultLandingInfo = data;
|
357
|
if(!this.id) {
|
358
|
this.id = this.resultLandingInfo.relcanId;
|
359
|
this.viewsFrameUrl = this.properties.framesAPIURL + 'merge.php?com=query&data=[{"query":"resRepoViews", "resTitle":"' + this.id + '", "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":"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';
|
360
|
this.downloadsFrameUrl = this.properties.framesAPIURL + 'merge.php?com=query&data=[{"query":"resRepoDownloads", "resTitle":"' + this.id + '", "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":"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';
|
361
|
}
|
362
|
if (this.type == "result") { // no type was specified - update URL based this.resultLandingInfo.resultType
|
363
|
this.updateUrlWithType();
|
364
|
}
|
365
|
this.seoService.createLinkForCanonicalURL(this.properties.domain+ properties.baseLink + this.linkToLandingPage + this.resultLandingInfo.relcanId);
|
366
|
if ((this.type == "publication") && (this.properties.environment == "beta" || this.properties.environment == "development") && (typeof document !== 'undefined')) {
|
367
|
this.getOpenCitations();
|
368
|
}
|
369
|
this.addNoIndexFilter();
|
370
|
if (this.resultLandingInfo.title) {
|
371
|
this.updateTitle(this.resultLandingInfo.title);
|
372
|
this.updateDescription((this.resultLandingInfo.description ? (this.resultLandingInfo.description) : ("," + this.resultLandingInfo.title)));
|
373
|
}
|
374
|
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
375
|
this.subscriptions.push(this._piwikService.trackView(this.properties, this.resultLandingInfo.title/*.name*/, this.piwikSiteId).subscribe());
|
376
|
}
|
377
|
|
378
|
let bioentitiesNum = 0;
|
379
|
if (this.resultLandingInfo.bioentities != undefined) {
|
380
|
this.resultLandingInfo.bioentities.forEach(function (value, key, map) {
|
381
|
bioentitiesNum += value.size;
|
382
|
});
|
383
|
}
|
384
|
this.bioentitiesNum = bioentitiesNum;
|
385
|
if (typeof document !== 'undefined') {
|
386
|
if(this.resultLandingInfo.identifiers) {
|
387
|
let pidsArray: string[] = [];
|
388
|
for(let key of Array.from(this.resultLandingInfo.identifiers.keys())) {
|
389
|
pidsArray = pidsArray.concat(this.resultLandingInfo.identifiers.get(key));
|
390
|
this.pidsArrayString = pidsArray.join();
|
391
|
}
|
392
|
if (this.resultLandingInfo.identifiers.has('doi')) {
|
393
|
this.doi = this.resultLandingInfo.identifiers.get('doi')[0];
|
394
|
this.subscriptions.push(this.metricsService.hasAltMetrics(this.properties.altMetricsAPIURL, this.doi).subscribe(hasAltMetrics => {
|
395
|
this.hasAltMetrics = hasAltMetrics;
|
396
|
}, error => {
|
397
|
this.hasAltMetrics = false;
|
398
|
}));
|
399
|
}
|
400
|
}
|
401
|
}
|
402
|
this.showLoading = false;
|
403
|
this.setActiveTab();
|
404
|
},
|
405
|
err => {
|
406
|
this.handleError("Error getting " + this.type + " for " + (this.id ? ("id: " + this.id) : ("pid: " + this.identifier.id + " ("+this.identifier.class+")")), err);
|
407
|
if (err.status == 404) {
|
408
|
this._router.navigate(['/error'], {queryParams: {"page": this._location.path(true), "page_type": this.type}});
|
409
|
}
|
410
|
|
411
|
if (this.type == "publication" || this.type == "software") {
|
412
|
this.errorMessage = 'No ' + this.type + ' found';
|
413
|
} else if (this.type == "dataset") {
|
414
|
this.errorMessage += "No research data found";
|
415
|
} else if (this.type == "orp") {
|
416
|
this.errorMessage += "No research product found";
|
417
|
}
|
418
|
this.showLoading = false;
|
419
|
this.seoService.createLinkForCanonicalURL(this.properties.domain+ properties.baseLink + this.linkToSearchPage);
|
420
|
}
|
421
|
));
|
422
|
}
|
423
|
|
424
|
public metricsResults($event) {
|
425
|
this.totalViews = $event.totalViews;
|
426
|
this.totalDownloads = $event.totalDownloads;
|
427
|
this.pageViews = $event.pageViews;
|
428
|
}
|
429
|
|
430
|
public get hasPrimaryInfo(): boolean {
|
431
|
return !!this.resultLandingInfo && (!!this.resultLandingInfo.description || !!this.resultLandingInfo.identifiers || !!this.resultLandingInfo.subjects);
|
432
|
}
|
433
|
|
434
|
public get hasSecondaryInfo(): boolean {
|
435
|
return (this.resultLandingInfo.fundedByProjects && this.resultLandingInfo.fundedByProjects.length > 0) ||
|
436
|
(this.resultLandingInfo.contexts && this.resultLandingInfo.contexts.length > 0) ||
|
437
|
(this.resultLandingInfo.hostedBy_collectedFrom && this.resultLandingInfo.hostedBy_collectedFrom.length > 0);
|
438
|
}
|
439
|
|
440
|
public get hasMetrics(): boolean {
|
441
|
return !(this.totalViews && this.totalDownloads && this.pageViews) || this.totalViews > 0 || this.totalDownloads > 0 || this.pageViews > 0;
|
442
|
}
|
443
|
|
444
|
private updateDescription(description: string) {
|
445
|
this._meta.updateTag({content: description.substring(0, 160)}, "name='description'");
|
446
|
this._meta.updateTag({content: description.substring(0, 160)}, "property='og:description'");
|
447
|
}
|
448
|
|
449
|
private updateTitle(title: string) {
|
450
|
var _prefix = "";
|
451
|
// if(!this.communityId) {
|
452
|
// _prefix = "OpenAIRE | ";
|
453
|
// }
|
454
|
// var _title = _prefix + ((title.length > 50) ? title.substring(0, 50) : title);
|
455
|
this._title.setTitle(title);
|
456
|
this._meta.updateTag({content: title}, "property='og:title'");
|
457
|
}
|
458
|
|
459
|
private updateUrl(url: string) {
|
460
|
this._meta.updateTag({content: url}, "property='og:url'");
|
461
|
}
|
462
|
|
463
|
public totalPages(totalResults: number): number {
|
464
|
let totalPages: any = totalResults / this.pageSize;
|
465
|
if (!(Number.isInteger(totalPages))) {
|
466
|
totalPages = (parseInt(totalPages, this.pageSize) + 1);
|
467
|
}
|
468
|
return totalPages;
|
469
|
}
|
470
|
|
471
|
public updateReferencesPage($event) {
|
472
|
this.referencesPage = $event.value;
|
473
|
}
|
474
|
|
475
|
public updateBioentitiesPage($event) {
|
476
|
this.bioentitiesPage = $event.value;
|
477
|
}
|
478
|
|
479
|
public updateRelatedPage($event) {
|
480
|
this.relatedPage = $event.value;
|
481
|
}
|
482
|
|
483
|
public updateSimilarPage($event) {
|
484
|
this.similarPage = $event.value;
|
485
|
}
|
486
|
|
487
|
public updateSupplementaryPage($event) {
|
488
|
this.supplementaryPage = $event.value;
|
489
|
}
|
490
|
|
491
|
public updateSupplementedByPage($event) {
|
492
|
this.supplementedByPage = $event.value;
|
493
|
}
|
494
|
|
495
|
public updateOrganizationsPage($event) {
|
496
|
this.organizationsPage = $event.value;
|
497
|
}
|
498
|
|
499
|
public updateOpenCitationsPage($event) {
|
500
|
this.openCitationsPage = $event.value;
|
501
|
}
|
502
|
|
503
|
public accessClass(accessMode: string): string {
|
504
|
if (accessMode.toLowerCase().indexOf('open') !== -1) {
|
505
|
return 'open';
|
506
|
} else if (accessMode.toLowerCase() === 'not available') {
|
507
|
return 'unknown';
|
508
|
} else {
|
509
|
return 'closed';
|
510
|
}
|
511
|
}
|
512
|
|
513
|
public keysToArray(bioentities: Map<string, string>): string[] {
|
514
|
let keys: string[] = [];
|
515
|
bioentities.forEach(function (value, key, map) {
|
516
|
keys.push(key);
|
517
|
});
|
518
|
return keys;
|
519
|
}
|
520
|
|
521
|
public getKeys(map) {
|
522
|
return Array.from(map.keys());
|
523
|
}
|
524
|
|
525
|
public scroll() {
|
526
|
HelperFunctions.scroll();
|
527
|
}
|
528
|
|
529
|
private handleError(message: string, error) {
|
530
|
if (this.type == "publication") {
|
531
|
console.error("Publication Landing Page: " + message, error);
|
532
|
} else if (this.type == "dataset") {
|
533
|
console.error("Research Data Landing Page: " + message, error);
|
534
|
} else if (this.type == "software") {
|
535
|
console.error("Software Landing Page: " + message, error);
|
536
|
} else if (this.type == "orp") {
|
537
|
console.error("Other Research Product Landing Page: " + message, error);
|
538
|
} else {
|
539
|
console.error("Landing Page: " + message, error);
|
540
|
}
|
541
|
}
|
542
|
|
543
|
isRouteAvailable(routeToCheck: string) {
|
544
|
for (let i = 0; i < this.router.config.length; i++) {
|
545
|
let routePath: string = this.router.config[i].path;
|
546
|
if (routePath == routeToCheck) {
|
547
|
return true;
|
548
|
}
|
549
|
}
|
550
|
return false;
|
551
|
}
|
552
|
|
553
|
openDeletedByInference() {
|
554
|
this.deleteByInferenceOpened = true;
|
555
|
this.alertModalDeletedByInference.cancelButton = false;
|
556
|
this.alertModalDeletedByInference.okButton = false;
|
557
|
this.alertModalDeletedByInference.alertTitle = "Other versions of";
|
558
|
this.alertModalDeletedByInference.open();
|
559
|
}
|
560
|
|
561
|
public getResultPreview(result: RelationResult): ResultPreview {
|
562
|
return ResultPreview.relationResultConvert(result, this.relation);
|
563
|
}
|
564
|
|
565
|
updateUrlWithType() {
|
566
|
this.type = this.resultLandingInfo.resultType;
|
567
|
|
568
|
if (this.type == "publication") {
|
569
|
this.linkToLandingPage = this.properties.searchLinkToPublication;
|
570
|
this.linkToSearchPage = this.properties.searchLinkToPublications;
|
571
|
} else if (this.type == "dataset") {
|
572
|
this.linkToLandingPage = this.properties.searchLinkToDataset;
|
573
|
this.linkToSearchPage = this.properties.searchLinkToDatasets;
|
574
|
} else if (this.type == "software") {
|
575
|
this.linkToLandingPage = this.properties.searchLinkToSoftwareLanding;
|
576
|
this.linkToSearchPage = this.properties.searchLinkToSoftware;
|
577
|
} else if (this.type == "other") {
|
578
|
this.type = "orp";
|
579
|
this.linkToLandingPage = this.properties.searchLinkToOrp;
|
580
|
this.linkToSearchPage = this.properties.searchLinkToOrps;
|
581
|
}
|
582
|
if(!this.identifier) {
|
583
|
this._location.go(this.linkToLandingPage + this.id);
|
584
|
}
|
585
|
// else {
|
586
|
// this._location.go(this.linkToLandingPage.split("?")[0] + "?pid=" + this.identifier.id);
|
587
|
// }
|
588
|
}
|
589
|
|
590
|
public getReferenceUrl(id: Id): string {
|
591
|
if (id.type === "doi") {
|
592
|
return this.properties.doiURL + id.value;
|
593
|
} else if (id.type === "pmc") {
|
594
|
return this.properties.pmcURL + id.value;
|
595
|
} else if (id.type === "pmid") {
|
596
|
return this.properties.pmidURL + id.value;
|
597
|
} else if (id.type === "handle") {
|
598
|
return this.properties.handleURL + id.value;
|
599
|
} else {
|
600
|
return null;
|
601
|
}
|
602
|
}
|
603
|
|
604
|
public getReferenceIdName(id: Id): string {
|
605
|
if (id.type === "doi") {
|
606
|
return 'DOI'
|
607
|
} else if (id.type === "pmc") {
|
608
|
return 'Europe PMC'
|
609
|
} else if (id.type === "pmid") {
|
610
|
return 'PubMed';
|
611
|
} else if (id.type === "handle") {
|
612
|
return 'Handle.NET';
|
613
|
} else {
|
614
|
return null;
|
615
|
}
|
616
|
}
|
617
|
|
618
|
public openLinkModal() {
|
619
|
this.linkModal.cancelButton = false;
|
620
|
this.linkModal.okButton = false;
|
621
|
this.linkModal.alertTitle = "Link this " + this.getTypeName() + " to";
|
622
|
this.linkModal.open();
|
623
|
}
|
624
|
|
625
|
public openCiteModal() {
|
626
|
this.citeThisClicked = true;
|
627
|
this.citeModal.cancelButton = false;
|
628
|
this.citeModal.okButton = false;
|
629
|
this.citeModal.alertTitle = "Cite this " + this.getTypeName();
|
630
|
this.citeModal.open();
|
631
|
}
|
632
|
addNoIndexFilter() {
|
633
|
try {
|
634
|
if(!(this.properties.environment == "production" || this.properties.environment == "development") ) {
|
635
|
return ;
|
636
|
}else {
|
637
|
let allow = !!(!this.resultLandingInfo.underCurationMessage &&
|
638
|
((this.resultLandingInfo.fundedByProjects && this.resultLandingInfo.fundedByProjects.length > 0)
|
639
|
|| this.resultLandingInfo.journal
|
640
|
|| (this.resultLandingInfo.classifiedSubjects && this.resultLandingInfo.classifiedSubjects.size > 0)
|
641
|
|| (this.resultLandingInfo.organizations && this.resultLandingInfo.organizations.length > 0)
|
642
|
|| this.resultLandingInfo.bioentities || (this.resultLandingInfo.references && this.resultLandingInfo.references.length > 0)
|
643
|
|| (this.resultLandingInfo.relatedResearchResults && this.resultLandingInfo.relatedResearchResults.length > 0)
|
644
|
|| (this.resultLandingInfo.similarResearchResults && this.resultLandingInfo.similarResearchResults.length > 0)
|
645
|
|| (this.resultLandingInfo.supplementaryResearchResults && this.resultLandingInfo.supplementaryResearchResults.length > 0)
|
646
|
|| (this.resultLandingInfo.supplementedByResearchResults && this.resultLandingInfo.supplementedByResearchResults.length > 0)
|
647
|
));
|
648
|
if(!allow) {
|
649
|
this._meta.updateTag({content: 'noindex'}, "name='robots'");
|
650
|
}
|
651
|
}
|
652
|
} catch (e) {
|
653
|
console.error("Error in passNoIndexFilter()", this.resultLandingInfo.relcanId, e);
|
654
|
return false;
|
655
|
}
|
656
|
}
|
657
|
}
|