Project

General

Profile

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
import {AnnotationComponent} from "../annotation/annotation.component";
24
import {User} from "../../login/utils/helper.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
  @ViewChild('linkModal') linkModal;
36
  @ViewChild('citeModal') citeModal;
37
  @ViewChild('AlertModalDeletedByInference') alertModalDeletedByInference;
38
  @ViewChild('relationModal') relationModal;
39
  @ViewChild('organizationModal') organizationModal;
40
  public deleteByInferenceOpened: boolean = false;
41
  
42
  public resultLandingInfo: ResultLandingInfo;
43
  public supplementaryResults: RelationResult[];
44
  public relation: string = 'trust';
45
  public id: string;
46
  public title: string;
47
  
48
  /*Show all organizations*/
49
  public showAll: boolean = false;
50
  
51
  // Links for SEO
52
  public linkToLandingPage: string = null;
53
  public linkToSearchPage: string = null;
54
  
55
  public thresholdDescription: number = 670;
56
  public showNumDescription: number = 670;
57
  
58
  public citeThisClicked: boolean;
59
  
60
  // Metrics tab variables
61
  public metricsClicked: boolean;
62
  public hasAltMetrics: boolean = false;
63
  public viewsFrameUrl: string;
64
  public downloadsFrameUrl: string;
65
  public totalViews: number;
66
  public totalDownloads: number;
67
  public pageViews: number;
68
  
69
  // Custom tab paging variables
70
  public referencesPage: number = 1;
71
  public bioentitiesPage: number = 1;
72
  public relatedPage: number = 1;
73
  public similarPage: number = 1;
74
  public supplementaryPage: number = 1;
75
  public supplementedByPage: number = 1;
76
  public organizationsPage: number = 1;
77
  public openCitationsPage: number = 1;
78
  public pageSize: number = 10;
79
  
80
  // Map counting variables
81
  public bioentitiesNum: number = 0;
82
  public relatedResultsNum: number = 0;
83

    
84
  // Message variables
85
  public warningMessage = "";
86
  public errorMessage = "";
87
  public showLoading: boolean = true;
88
  public dashboard = properties.isDashboard;
89
  
90
  public routerHelper: RouterHelper = new RouterHelper();
91
  public activeTab: string = null;
92
  private doi: string;
93
  subscriptions = [];
94
  properties: EnvProperties = properties;
95
  public indexUpdateDate: Date;
96
  public pageContents = null;
97
  public divContents = null;
98
  public showFeedback: boolean = false;
99
  public feedbackFields: string [] = [
100
    'Title', 'Authors', 'Access rights',
101
    'Publisher information', 'Funding Information',
102
    'Persistent identifiers', 'Other'];
103
  public user: User;
104
  public pid: string;
105
  @ViewChild("annotation") annotation: AnnotationComponent;
106
  
107
  constructor(private _resultLaningService: ResultLandingService,
108
              private _vocabulariesService: ISVocabulariesService,
109
              private _piwikService: PiwikService,
110
              private route: ActivatedRoute,
111
              private router: Router,
112
              private _meta: Meta,
113
              private _title: Title,
114
              private _router: Router,
115
              private helper: HelperService,
116
              private seoService: SEOService,
117
              private metricsService: MetricsService,
118
              private cdr: ChangeDetectorRef,
119
              private _location: Location,
120
              private indexInfoService: IndexInfoService) {
121
  }
122
  
123
  ngOnInit() {
124
    if (typeof document !== 'undefined') {
125
      this.subscriptions.push(this.indexInfoService.getLastIndexDate(this.properties).subscribe(lastIndexUpdate => {
126
        if (lastIndexUpdate) {
127
          this.indexUpdateDate = new Date(lastIndexUpdate);
128
        }
129
      }));
130
    }
131
    //this.getDivContents();
132
    this.getPageContents();
133
    this.updateUrl(this.properties.domain +this.properties.baseLink +  this._router.url);
134
    this.subscriptions.push(this.route.queryParams.subscribe(data => {
135
      this.resultLandingInfo = null;
136
      if (data['articleId']) {
137
        this.type = "publication";
138
        this.updateTitle("Publication");
139
        this.linkToLandingPage = this.properties.searchLinkToPublication;
140
        this.linkToSearchPage = this.properties.searchLinkToPublications;
141
        this.id = data['articleId'];
142
        this.title = "Publication";
143
      } else if (data['datasetId']) {
144
        this.updateTitle("Dataset");
145
        this.type = "dataset";
146
        this.linkToLandingPage = this.properties.searchLinkToDataset;
147
        this.linkToSearchPage = this.properties.searchLinkToDatasets;
148
        this.id = data['datasetId'];
149
        this.title = "Research Data";
150
      } else if (data['softwareId']) {
151
        this.updateTitle("Software");
152
        this.type = "software";
153
        this.linkToLandingPage = this.properties.searchLinkToSoftwareLanding;
154
        this.linkToSearchPage = this.properties.searchLinkToSoftware;
155
        this.id = data['softwareId'];
156
        this.title = "Software";
157
      } else if (data['orpId']) {
158
        this.type = "orp";
159
        this.updateTitle("Other Research Product");
160
        this.linkToLandingPage = this.properties.searchLinkToOrp;
161
        this.linkToSearchPage = this.properties.searchLinkToOrps;
162
        this.id = data['orpId'];
163
        this.title = "Other Research Product";
164
      } else if (data["id"]){
165
        this.type = "result";
166
        this.id = data["id"];
167
        this.updateTitle("Research Result");
168
        this.linkToLandingPage = this.properties.searchLinkToResult;
169
        this.linkToSearchPage = this.properties.searchLinkToResults;
170
        this.title = "Research Result";
171
      }
172
      this.updateDescription("");
173
      
174
      this.metricsClicked = false;
175

    
176
      if (this.id && StringUtils.isOpenAIREID(this.id)) {
177
        this.getProvenanceVocabularyAndResultLandingInfo();
178
      } else {
179
        this.showLoading = false;
180
        
181
        this._router.navigate(['/error'], {
182
          queryParams: {
183
            "page": this._location.path(true),
184
            "page_type": this.type
185
          }
186
        });
187
      }
188
      
189
      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';
190
      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';
191
      
192
      this.scroll();
193
    }));
194
  }
195
  
196
  private getPageContents() {
197
    if (this.communityId) {
198
      this.subscriptions.push(this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
199
        this.pageContents = contents;
200
      }));
201
    }
202
  }
203
  
204
  private getDivContents() {
205
    if (this.communityId) {
206
      this.subscriptions.push(this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
207
        this.divContents = contents;
208
      }));
209
    }
210
  }
211

    
212
  ngOnDestroy() {
213
    this.subscriptions.forEach(subscription => {
214
      if (subscription instanceof Subscriber) {
215
        subscription.unsubscribe();
216
      }
217
    });
218
    this._vocabulariesService.clearSubscriptions();
219
  }
220
  
221
  public userInit(event) {
222
    this.user = event;
223
    this.cdr.detectChanges();
224
  }
225
  
226
  public pidInit(event) {
227
    this.pid = event;
228
    this.cdr.detectChanges();
229
  }
230
  
231
  
232
  public getTypeName(): string {
233
    if (this.type === "dataset") {
234
      return "research data";
235
    } else if (this.type === "orp" || this.type === "other") {
236
      return "research product";
237
    } else {
238
      return this.type;
239
    }
240
  }
241
  
242
  public removeUnknown(array: string[], type: boolean = false): string[] {
243
    if (type) {
244
      return this.removeDuplicates(array).filter(value => value.toLowerCase() !== 'unknown');
245
    } else {
246
      return array.filter(value => value.toLowerCase() !== 'unknown');
247
    }
248
  }
249
  
250
  public removeDuplicates(array: string[]): string[] {
251
    let type = this.getTypeName();
252
    return array.filter(value => value.toLowerCase() !== type);
253
  }
254
  
255
  private getOpenCitations() {
256
    this.subscriptions.push(this._resultLaningService.getOpenCitations(this.id, this.properties).subscribe(
257
      data => {
258
        this.resultLandingInfo.openCitations = data[1];
259
      },
260
      err => {
261
        this.handleError("Error getting open citation for " + this.type + " with id: " + this.id, err);
262
      }
263
    ));
264
  }
265
  
266
  private getProvenanceVocabularyAndResultLandingInfo() {
267
    this.warningMessage = '';
268
    this.errorMessage = '';
269
    this.showLoading = true;
270
    
271
    this.resultLandingInfo = null;
272
    
273
    if (typeof document !== 'undefined') {
274
      this.subscriptions.push(this._vocabulariesService.getProvenanceActionVocabulary(this.properties).subscribe(
275
        provenanceActionVocabulary => {
276
          this.getResultLandingInfo(provenanceActionVocabulary);
277
        }, err => {
278
          this.getResultLandingInfo(null);
279
          this.handleError("Error getting provenance action vocabulary for " + this.type + " with id: " + this.id, err);
280
        }
281
      ));
282
    } else {
283
      this.getResultLandingInfo(null);
284
    }
285
    
286
  }
287
  
288
  private setActiveTab() {
289
    if (this.hasPrimaryInfo || this.hasSecondaryInfo) {
290
      this.activeTab = 'summary';
291
    } else if (this.resultLandingInfo.references && this.resultLandingInfo.references.length > 0) {
292
      this.activeTab = 'references';
293
    } else if ((this.resultLandingInfo.supplementaryResearchResults && this.resultLandingInfo.supplementaryResearchResults.length > 0) ||
294
      (this.resultLandingInfo.supplementedByResearchResults && this.resultLandingInfo.supplementedByResearchResults.length > 0)) {
295
      this.activeTab = 'supplementary';
296
    } else if ((this.resultLandingInfo.relatedResearchResults && this.resultLandingInfo.relatedResearchResults.length > 0) ||
297
      (this.resultLandingInfo.similarResearchResults && this.resultLandingInfo.similarResearchResults.length > 0)) {
298
      this.activeTab = 'related';
299
    } else if (this.resultLandingInfo.bioentities && this.bioentitiesNum > 0) {
300
      this.activeTab = 'bioentities';
301
    }
302
  }
303
  
304
  // private get numberOfTabs(): number {
305
  //   let numberOfTabs = 0;
306
  //   if(this.hasPrimaryInfo || this.hasSecondaryInfo) {
307
  //     numberOfTabs++;
308
  //   }
309
  //   if(this.resultLandingInfo.references && this.resultLandingInfo.references.length > 0) {
310
  //     numberOfTabs++;
311
  //   }
312
  //   if((this.resultLandingInfo.supplementaryResearchResults && this.resultLandingInfo.supplementaryResearchResults.length > 0) ||
313
  //     (this.resultLandingInfo.supplementedByResearchResults && this.resultLandingInfo.supplementedByResearchResults.length > 0)) {
314
  //     numberOfTabs++;
315
  //   }
316
  //   if((this.resultLandingInfo.relatedResearchResults && this.resultLandingInfo.relatedResearchResults.length > 0) ||
317
  //     (this.resultLandingInfo.similarResearchResults && this.resultLandingInfo.similarResearchResults.length > 0)) {
318
  //     numberOfTabs++;
319
  //   }
320
  //   if(this.resultLandingInfo.bioentities && this.bioentitiesNum > 0) {
321
  //     numberOfTabs++;
322
  //   }
323
  //   return numberOfTabs;
324
  // }
325
  
326
  private getResultLandingInfo(provenanceActionVocabulary: any) {
327
    this.subscriptions.push(this._resultLaningService.getResultLandingInfo(this.id, this.type, provenanceActionVocabulary, this.properties).subscribe(
328
      data => {
329
        this.resultLandingInfo = data;
330
        if (this.type == "result") { // no type was specified - update URL based this.resultLandingInfo.resultType
331
          this.updateUrlWithType();
332
        }
333
        this.seoService.createLinkForCanonicalURL(this.properties.domain+ properties.baseLink  + this.linkToLandingPage + this.resultLandingInfo.relcanId);
334
        if ((this.type == "publication") && (this.properties.environment == "beta" || this.properties.environment == "development") && (typeof document !== 'undefined')) {
335
          this.getOpenCitations();
336
        }
337
        this.addNoIndexFilter();
338
        if (this.resultLandingInfo.title) {
339
          this.updateTitle(this.resultLandingInfo.title);
340
          this.updateDescription((this.resultLandingInfo.description ? (this.resultLandingInfo.description) : ("," + this.resultLandingInfo.title)));
341
        }
342
        if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
343
          this.subscriptions.push(this._piwikService.trackView(this.properties, this.resultLandingInfo.title/*.name*/, this.piwikSiteId).subscribe());
344
        }
345
        
346
        let bioentitiesNum = 0;
347
        if (this.resultLandingInfo.bioentities != undefined) {
348
          this.resultLandingInfo.bioentities.forEach(function (value, key, map) {
349
            bioentitiesNum += value.size;
350
          });
351
        }
352
        this.bioentitiesNum = bioentitiesNum;
353
        if (typeof document !== 'undefined') {
354
          if (this.resultLandingInfo.identifiers != undefined && this.resultLandingInfo.identifiers.has('doi')) {
355
            this.doi = this.resultLandingInfo.identifiers.get('doi')[0];
356
            this.subscriptions.push(this.metricsService.hasAltMetrics(this.properties.altMetricsAPIURL, this.doi).subscribe(hasAltMetrics => {
357
              this.hasAltMetrics = hasAltMetrics;
358
            }, error => {
359
              this.hasAltMetrics = false;
360
            }));
361
          }
362
        }
363
        this.showLoading = false;
364
        this.setActiveTab();
365
      },
366
      err => {
367
        this.handleError("Error getting " + this.type + " for id: " + this.id, err);
368
        
369
        if (err.status == 404) {
370
          this._router.navigate(['/error'], {queryParams: {"page": this._location.path(true), "page_type": this.type}});
371
        }
372
        
373
        if (this.type == "publication" || this.type == "software") {
374
          this.errorMessage = 'No ' + this.type + ' found';
375
        } else if (this.type == "dataset") {
376
          this.errorMessage += "No research data found";
377
        } else if (this.type == "orp") {
378
          this.errorMessage += "No research product found";
379
        }
380
        this.showLoading = false;
381
        this.seoService.createLinkForCanonicalURL(this.properties.domain+ properties.baseLink  + this.linkToSearchPage);
382
      }
383
    ));
384
  }
385
  
386
  public metricsResults($event) {
387
    this.totalViews = $event.totalViews;
388
    this.totalDownloads = $event.totalDownloads;
389
    this.pageViews = $event.pageViews;
390
  }
391
  
392
  public get hasPrimaryInfo(): boolean {
393
    return !!this.resultLandingInfo && (!!this.resultLandingInfo.description || !!this.resultLandingInfo.identifiers || !!this.resultLandingInfo.subjects);
394
  }
395
  
396
  public get hasSecondaryInfo(): boolean {
397
    return (this.resultLandingInfo.fundedByProjects && this.resultLandingInfo.fundedByProjects.length > 0) ||
398
      (this.resultLandingInfo.contexts && this.resultLandingInfo.contexts.length > 0) ||
399
      (this.resultLandingInfo.hostedBy_collectedFrom && this.resultLandingInfo.hostedBy_collectedFrom.length > 0);
400
  }
401
  
402
  public get hasMetrics(): boolean {
403
    return !(this.totalViews && this.totalDownloads && this.pageViews) || this.totalViews > 0 || this.totalDownloads > 0 || this.pageViews > 0;
404
  }
405
  
406
  private updateDescription(description: string) {
407
    this._meta.updateTag({content: description.substring(0, 160)}, "name='description'");
408
    this._meta.updateTag({content: description.substring(0, 160)}, "property='og:description'");
409
  }
410
  
411
  private updateTitle(title: string) {
412
    var _prefix = "";
413
    // if(!this.communityId) {
414
    //   _prefix = "OpenAIRE | ";
415
    // }
416
    // var _title = _prefix + ((title.length > 50) ? title.substring(0, 50) : title);
417
    this._title.setTitle(title);
418
    this._meta.updateTag({content: title}, "property='og:title'");
419
  }
420
  
421
  private updateUrl(url: string) {
422
    this._meta.updateTag({content: url}, "property='og:url'");
423
  }
424
  
425
  public totalPages(totalResults: number): number {
426
    let totalPages: any = totalResults / this.pageSize;
427
    if (!(Number.isInteger(totalPages))) {
428
      totalPages = (parseInt(totalPages, this.pageSize) + 1);
429
    }
430
    return totalPages;
431
  }
432
  
433
  public updateReferencesPage($event) {
434
    this.referencesPage = $event.value;
435
  }
436
  
437
  public updateBioentitiesPage($event) {
438
    this.bioentitiesPage = $event.value;
439
  }
440
  
441
  public updateRelatedPage($event) {
442
    this.relatedPage = $event.value;
443
  }
444
  
445
  public updateSimilarPage($event) {
446
    this.similarPage = $event.value;
447
  }
448
  
449
  public updateSupplementaryPage($event) {
450
    this.supplementaryPage = $event.value;
451
  }
452
  
453
  public updateSupplementedByPage($event) {
454
    this.supplementedByPage = $event.value;
455
  }
456
  
457
  public updateOrganizationsPage($event) {
458
    this.organizationsPage = $event.value;
459
  }
460
  
461
  public updateOpenCitationsPage($event) {
462
    this.openCitationsPage = $event.value;
463
  }
464
  
465
  public accessClass(accessMode: string): string {
466
    if (accessMode.toLowerCase().indexOf('open') !== -1) {
467
      return 'open';
468
    } else if (accessMode.toLowerCase() === 'not available') {
469
      return 'unknown';
470
    } else {
471
      return 'closed';
472
    }
473
  }
474
  
475
  public keysToArray(bioentities: Map<string, string>): string[] {
476
    let keys: string[] = [];
477
    bioentities.forEach(function (value, key, map) {
478
      keys.push(key);
479
    });
480
    return keys;
481
  }
482
  
483
  public getKeys(map) {
484
    return Array.from(map.keys());
485
  }
486
  
487
  public scroll() {
488
    HelperFunctions.scroll();
489
  }
490
  
491
  private handleError(message: string, error) {
492
    if (this.type == "publication") {
493
      console.error("Publication Landing Page: " + message, error);
494
    } else if (this.type == "dataset") {
495
      console.error("Research Data Landing Page: " + message, error);
496
    } else if (this.type == "software") {
497
      console.error("Software Landing Page: " + message, error);
498
    } else if (this.type == "orp") {
499
      console.error("Other Research Product Landing Page: " + message, error);
500
    } else {
501
      console.error("Landing Page: " + message, error);
502
    }
503
  }
504
  
505
  isRouteAvailable(routeToCheck: string) {
506
    for (let i = 0; i < this.router.config.length; i++) {
507
      let routePath: string = this.router.config[i].path;
508
      if (routePath == routeToCheck) {
509
        return true;
510
      }
511
    }
512
    return false;
513
  }
514
  
515
  openDeletedByInference() {
516
    this.deleteByInferenceOpened = true;
517
    this.alertModalDeletedByInference.cancelButton = false;
518
    this.alertModalDeletedByInference.okButton = false;
519
    this.alertModalDeletedByInference.alertTitle = "Other versions of";
520
    this.alertModalDeletedByInference.open();
521
  }
522
  
523
  public getResultPreview(result: RelationResult): ResultPreview {
524
    return ResultPreview.relationResultConvert(result, this.relation);
525
  }
526
  
527
  updateUrlWithType() {
528
    this.type = this.resultLandingInfo.resultType;
529
    if (this.type == "publication") {
530
      this.linkToLandingPage = this.properties.searchLinkToPublication;
531
      this.linkToSearchPage = this.properties.searchLinkToPublications;
532
    } else if (this.type == "dataset") {
533
      this.linkToLandingPage = this.properties.searchLinkToDataset;
534
      this.linkToSearchPage = this.properties.searchLinkToDatasets;
535
    } else if (this.type == "software") {
536
      this.linkToLandingPage = this.properties.searchLinkToSoftwareLanding;
537
      this.linkToSearchPage = this.properties.searchLinkToSoftware;
538
    } else if (this.type == "other") {
539
      this.type = "orp";
540
      this.linkToLandingPage = this.properties.searchLinkToOrp;
541
      this.linkToSearchPage = this.properties.searchLinkToOrps;
542
    }
543
    this._location.go(this.linkToLandingPage + this.id);
544
  }
545
  
546
  public getReferenceUrl(id: Id): string {
547
    if (id.type === "doi") {
548
      return this.properties.doiURL + id.value;
549
    } else if (id.type === "pmc") {
550
      return this.properties.pmcURL + id.value;
551
    } else if (id.type === "pmid") {
552
      return this.properties.pmidURL + id.value;
553
    } else if (id.type === "handle") {
554
      return this.properties.handleURL + id.value;
555
    } else {
556
      return null;
557
    }
558
  }
559
  
560
  public getReferenceIdName(id: Id): string {
561
    if (id.type === "doi") {
562
      return 'DOI'
563
    } else if (id.type === "pmc") {
564
      return 'Europe PMC'
565
    } else if (id.type === "pmid") {
566
      return 'PubMed';
567
    } else if (id.type === "handle") {
568
      return 'Handle.NET';
569
    } else {
570
      return null;
571
    }
572
  }
573
  
574
  public openLinkModal() {
575
    this.linkModal.cancelButton = false;
576
    this.linkModal.okButton = false;
577
    this.linkModal.alertTitle = "Link this " + this.getTypeName() + " to";
578
    this.linkModal.open();
579
  }
580
  
581
  public openCiteModal() {
582
    this.citeThisClicked = true;
583
    this.citeModal.cancelButton = false;
584
    this.citeModal.okButton = false;
585
    this.citeModal.alertTitle = "Cite this " + this.getTypeName();
586
    this.citeModal.open();
587
  }
588
  addNoIndexFilter() {
589
    try {
590
      if(!(this.properties.environment == "production" || this.properties.environment == "development") ) {
591
        return ;
592
      }else {
593
       let allow =  !!(!this.resultLandingInfo.underCurationMessage &&
594
          ((this.resultLandingInfo.fundedByProjects && this.resultLandingInfo.fundedByProjects.length > 0)
595
            || this.resultLandingInfo.journal
596
            || (this.resultLandingInfo.classifiedSubjects && this.resultLandingInfo.classifiedSubjects.size > 0)
597
            || (this.resultLandingInfo.organizations && this.resultLandingInfo.organizations.length > 0)
598
            || this.resultLandingInfo.bioentities || (this.resultLandingInfo.references && this.resultLandingInfo.references.length > 0)
599
            || (this.resultLandingInfo.relatedResearchResults && this.resultLandingInfo.relatedResearchResults.length > 0)
600
            || (this.resultLandingInfo.similarResearchResults && this.resultLandingInfo.similarResearchResults.length > 0)
601
            || (this.resultLandingInfo.supplementaryResearchResults && this.resultLandingInfo.supplementaryResearchResults.length > 0)
602
            || (this.resultLandingInfo.supplementedByResearchResults && this.resultLandingInfo.supplementedByResearchResults.length > 0)
603
          ));
604
        if(!allow) {
605
          this._meta.updateTag({content: 'noindex'}, "name='robots'");
606
        }
607
      }
608
    } catch (e) {
609
      console.error("Error in passNoIndexFilter()", this.resultLandingInfo.relcanId, e);
610
      return false;
611
    }
612
  }
613
}
(2-2/4)