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