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

    
23

    
24
@Component({
25
  selector: 'result-landing',
26
  templateUrl: 'resultLanding.component.html',
27
})
28
export class ResultLandingComponent {
29
  @Input() type: string = "publication";
30
  @Input() piwikSiteId = properties.piwikSiteId;
31
  @Input() communityId = null;
32
  @ViewChild('linkModal') linkModal;
33
  @ViewChild('citeModal') citeModal;
34
  @ViewChild('AlertModalDeletedByInference') alertModalDeletedByInference;
35
  @ViewChild('relationModal') relationModal;
36
  @ViewChild('organizationModal') organizationModal;
37
  public deleteByInferenceOpened: boolean = false;
38
  
39
  public resultLandingInfo: ResultLandingInfo;
40
  public relatedResults: RelationResult[];
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
  public supplementaryResultsNum: number = 0;
82
  
83
  // Message variables
84
  public warningMessage = "";
85
  public errorMessage = "";
86
  public showLoading: boolean = true;
87
  public dashboard = properties.isDashboard;
88
  
89
  public routerHelper: RouterHelper = new RouterHelper();
90
  public activeTab: string = null;
91
  private doi: string;
92
  sub: any;
93
  piwiksub: any;
94
  infoSub: any;
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
  
105
  constructor(private _resultLaningService: ResultLandingService,
106
              private _vocabulariesService: ISVocabulariesService,
107
              private _piwikService: PiwikService,
108
              private route: ActivatedRoute,
109
              private router: Router,
110
              private _meta: Meta,
111
              private _title: Title,
112
              private _router: Router,
113
              private helper: HelperService,
114
              private seoService: SEOService,
115
              private metricsService: MetricsService,
116
              private cdr: ChangeDetectorRef,
117
              private _location: Location,
118
              private indexInfoService: IndexInfoService,
119
              private fb: FormBuilder) {
120
  }
121
  
122
  ngOnInit() {
123
    if (typeof document !== 'undefined') {
124
      this.indexInfoService.getLastIndexDate(this.properties).subscribe(lastIndexUpdate => {
125
        if (lastIndexUpdate) {
126
          this.indexUpdateDate = new Date(lastIndexUpdate);
127
        }
128
      });
129
    }
130
    //this.getDivContents();
131
    this.getPageContents();
132
    this.updateUrl(this.properties.domain +this.properties.baseLink +  this._router.url);
133
    this.sub = this.route.queryParams.subscribe(data => {
134
      this.resultLandingInfo = null;
135
      if (data['articleId']) {
136
        this.type = "publication";
137
        this.updateTitle("Publication");
138
        this.linkToLandingPage = this.properties.searchLinkToPublication;
139
        this.linkToSearchPage = this.properties.searchLinkToPublications;
140
        this.id = data['articleId'];
141
        this.title = "Publication";
142
      } else if (data['datasetId']) {
143
        this.updateTitle("Dataset");
144
        this.type = "dataset";
145
        this.linkToLandingPage = this.properties.searchLinkToDataset;
146
        this.linkToSearchPage = this.properties.searchLinkToDatasets;
147
        this.id = data['datasetId'];
148
        this.title = "Research Data";
149
      } else if (data['softwareId']) {
150
        this.updateTitle("Software");
151
        this.type = "software";
152
        this.linkToLandingPage = this.properties.searchLinkToSoftwareLanding;
153
        this.linkToSearchPage = this.properties.searchLinkToSoftware;
154
        this.id = data['softwareId'];
155
        this.title = "Software";
156
      } else if (data['orpId']) {
157
        this.type = "orp";
158
        this.updateTitle("Other Research Product");
159
        this.linkToLandingPage = this.properties.searchLinkToOrp;
160
        this.linkToSearchPage = this.properties.searchLinkToOrps;
161
        this.id = data['orpId'];
162
        this.title = "Other Research Product";
163
      } else if (data["id"]){
164
        this.type = "result";
165
        this.id = data["id"];
166
        this.updateTitle("Research Result");
167
        this.linkToLandingPage = this.properties.searchLinkToResult;
168
        this.linkToSearchPage = this.properties.searchLinkToResults;
169
        this.title = "Research Result";
170
      }
171
      this.updateDescription("");
172
      
173
      this.metricsClicked = false;
174

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