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