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 {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

    
25

    
26
@Component({
27
  selector: 'result-landing',
28
  templateUrl: 'resultLanding.component.html',
29
})
30
export class ResultLandingComponent {
31
  @Input() type: string = "publication";
32
  @Input() piwikSiteId = properties.piwikSiteId;
33
  @Input() communityId = null;
34
  @ViewChild('linkModal') linkModal;
35
  @ViewChild('citeModal') citeModal;
36
  @ViewChild('AlertModalDeletedByInference') alertModalDeletedByInference;
37
  @ViewChild('relationModal') relationModal;
38
  @ViewChild('organizationModal') organizationModal;
39
  public deleteByInferenceOpened: boolean = false;
40
  
41
  public resultLandingInfo: ResultLandingInfo;
42
  public supplementaryResults: RelationResult[];
43
  public relation: string = 'trust';
44
  public id: string;
45
  public title: string;
46
  
47
  /*Show all organizations*/
48
  public showAll: boolean = false;
49
  
50
  // Links for SEO
51
  public linkToLandingPage: string = null;
52
  public linkToSearchPage: string = null;
53
  
54
  public thresholdDescription: number = 670;
55
  public showNumDescription: number = 670;
56
  
57
  public citeThisClicked: boolean;
58
  
59
  // Metrics tab variables
60
  public metricsClicked: boolean;
61
  public hasAltMetrics: boolean = false;
62
  public viewsFrameUrl: string;
63
  public downloadsFrameUrl: string;
64
  public totalViews: number;
65
  public totalDownloads: number;
66
  public pageViews: number;
67
  
68
  // Custom tab paging variables
69
  public referencesPage: number = 1;
70
  public bioentitiesPage: number = 1;
71
  public relatedPage: number = 1;
72
  public similarPage: number = 1;
73
  public supplementaryPage: number = 1;
74
  public supplementedByPage: number = 1;
75
  public organizationsPage: number = 1;
76
  public openCitationsPage: number = 1;
77
  public pageSize: number = 10;
78
  
79
  // Map counting variables
80
  public bioentitiesNum: number = 0;
81
  public relatedResultsNum: 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
  subscriptions = [];
93
  properties: EnvProperties = properties;
94
  public indexUpdateDate: Date;
95
  public pageContents = null;
96
  public divContents = null;
97
  public showFeedback: boolean = false;
98
  public feedbackFields: string [] = [
99
    'Title', 'Authors', 'Access rights',
100
    'Publisher information', 'Funding Information',
101
    'Persistent identifiers', 'Other'];
102
  public loggedIn: boolean = false;
103
  public pidsArrayString: string = "";
104
  public identifier: Identifier;
105

    
106
  public isLoggedIn: boolean = Session.isLoggedIn();
107
  public pid: string;
108
  @ViewChild("annotation") annotation: AnnotationComponent;
109

    
110
  constructor(private _resultLandingService: ResultLandingService,
111
              private _vocabulariesService: ISVocabulariesService,
112
              private _piwikService: PiwikService,
113
              private route: ActivatedRoute,
114
              private router: Router,
115
              private _meta: Meta,
116
              private _title: Title,
117
              private _router: Router,
118
              private helper: HelperService,
119
              private seoService: SEOService,
120
              private metricsService: MetricsService,
121
              private cdr: ChangeDetectorRef,
122
              private _location: Location,
123
              private indexInfoService: IndexInfoService) {
124
  }
125
  
126
  ngOnInit() {
127
    if (typeof document !== 'undefined') {
128
      this.subscriptions.push(this.indexInfoService.getLastIndexDate(this.properties).subscribe(lastIndexUpdate => {
129
        if (lastIndexUpdate) {
130
          this.indexUpdateDate = new Date(lastIndexUpdate);
131
        }
132
      }));
133
    }
134
    //this.getDivContents();
135
    this.getPageContents();
136
    this.updateUrl(this.properties.domain +this.properties.baseLink +  this._router.url);
137
    this.subscriptions.push(this.route.queryParams.subscribe(async data => {
138
      if (Session.isLoggedIn()) {
139
        this.loggedIn = true;
140
      }
141
      this.resultLandingInfo = null;
142
      if (data['articleId']) {
143
        this.id = data['articleId'];
144
        this.initMetaAndLinks("publication");
145
      } else if (data['datasetId']) {
146
        this.id = data['datasetId'];
147
        this.initMetaAndLinks("dataset");
148
      } else if (data['softwareId']) {
149
        this.id = data['softwareId'];
150
        this.initMetaAndLinks("software");
151
      } else if (data['orpId']) {
152
        this.id = data['orpId'];
153
        this.initMetaAndLinks("orp");
154
      } else if (data["id"]) {
155
        this.id = data["id"];
156
        this.initMetaAndLinks("result");
157
      } else if (data["pid"]) {
158
        this.identifier = Identifier.getIdentifierFromString(data["pid"]);
159
        console.debug(this.identifier);
160

    
161
        if(!this.type) {
162
          this.type = "result";
163
        }
164
        this.initMetaAndLinks(this.type);
165
      }
166
      this.updateDescription("");
167

    
168
      this.metricsClicked = false;
169

    
170
      if ((this.id && StringUtils.isOpenAIREID(this.id)) || (this.identifier)) {
171
        this.getProvenanceVocabularyAndResultLandingInfo();
172
      } else {
173
        this.showLoading = false;
174

    
175
        this._router.navigate(['/error'], {
176
          queryParams: {
177
            "page": this._location.path(true),
178
            "page_type": this.type
179
          }
180
        });
181
      }
182

    
183
      if(this.id) {
184
        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';
185
        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';
186
      }
187

    
188
      this.scroll();
189
    }));
190
  }
191

    
192
  private initMetaAndLinks(type: string) {
193
    if (type == "publication") {
194
      this.type = "publication";
195
      this.updateTitle("Publication");
196
      this.linkToLandingPage = this.properties.searchLinkToPublication;
197
      this.linkToSearchPage = this.properties.searchLinkToPublications;
198
      this.title = "Publication";
199
    } else if (type == "dataset") {
200
      this.updateTitle("Dataset");
201
      this.type = "dataset";
202
      this.linkToLandingPage = this.properties.searchLinkToDataset;
203
      this.linkToSearchPage = this.properties.searchLinkToDatasets;
204
      this.title = "Research Data";
205
    } else if (type == "software") {
206
      this.updateTitle("Software");
207
      this.type = "software";
208
      this.linkToLandingPage = this.properties.searchLinkToSoftwareLanding;
209
      this.linkToSearchPage = this.properties.searchLinkToSoftware;
210
      this.title = "Software";
211
    } else if (type == "orp") {
212
      this.type = "orp";
213
      this.updateTitle("Other Research Product");
214
      this.linkToLandingPage = this.properties.searchLinkToOrp;
215
      this.linkToSearchPage = this.properties.searchLinkToOrps;
216
      this.title = "Other Research Product";
217
    } else if (type == "result") {
218
      this.type = "result";
219
      this.updateTitle("Research Result");
220
      this.linkToLandingPage = this.properties.searchLinkToResult;
221
      this.linkToSearchPage = this.properties.searchLinkToResults;
222
      this.title = "Research Result";
223
    }
224
  }
225

    
226
  private getPageContents() {
227
    if (this.communityId) {
228
      this.subscriptions.push(this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
229
        this.pageContents = contents;
230
      }));
231
    }
232
  }
233
  
234
  private getDivContents() {
235
    if (this.communityId) {
236
      this.subscriptions.push(this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
237
        this.divContents = contents;
238
      }));
239
    }
240
  }
241

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

    
566
    if (this.type == "publication") {
567
      this.linkToLandingPage = this.properties.searchLinkToPublication;
568
      this.linkToSearchPage = this.properties.searchLinkToPublications;
569
    } else if (this.type == "dataset") {
570
      this.linkToLandingPage = this.properties.searchLinkToDataset;
571
      this.linkToSearchPage = this.properties.searchLinkToDatasets;
572
    } else if (this.type == "software") {
573
      this.linkToLandingPage = this.properties.searchLinkToSoftwareLanding;
574
      this.linkToSearchPage = this.properties.searchLinkToSoftware;
575
    } else if (this.type == "other") {
576
      this.type = "orp";
577
      this.linkToLandingPage = this.properties.searchLinkToOrp;
578
      this.linkToSearchPage = this.properties.searchLinkToOrps;
579
    }
580
    if(!this.identifier) {
581
      this._location.go(this.linkToLandingPage + this.id);
582
    }
583
    // else {
584
    //   this._location.go(this.linkToLandingPage.split("?")[0] + "?pid=" + this.identifier.id);
585
    // }
586
  }
587
  
588
  public getReferenceUrl(id: Id): string {
589
    if (id.type === "doi") {
590
      return this.properties.doiURL + id.value;
591
    } else if (id.type === "pmc") {
592
      return this.properties.pmcURL + id.value;
593
    } else if (id.type === "pmid") {
594
      return this.properties.pmidURL + id.value;
595
    } else if (id.type === "handle") {
596
      return this.properties.handleURL + id.value;
597
    } else {
598
      return null;
599
    }
600
  }
601
  
602
  public getReferenceIdName(id: Id): string {
603
    if (id.type === "doi") {
604
      return 'DOI'
605
    } else if (id.type === "pmc") {
606
      return 'Europe PMC'
607
    } else if (id.type === "pmid") {
608
      return 'PubMed';
609
    } else if (id.type === "handle") {
610
      return 'Handle.NET';
611
    } else {
612
      return null;
613
    }
614
  }
615
  
616
  public openLinkModal() {
617
    this.linkModal.cancelButton = false;
618
    this.linkModal.okButton = false;
619
    this.linkModal.alertTitle = "Link this " + this.getTypeName() + " to";
620
    this.linkModal.open();
621
  }
622
  
623
  public openCiteModal() {
624
    this.citeThisClicked = true;
625
    this.citeModal.cancelButton = false;
626
    this.citeModal.okButton = false;
627
    this.citeModal.alertTitle = "Cite this " + this.getTypeName();
628
    this.citeModal.open();
629
  }
630
  addNoIndexFilter() {
631
    try {
632
      if(!(this.properties.environment == "production" || this.properties.environment == "development") ) {
633
        return ;
634
      }else {
635
       let allow =  !!(!this.resultLandingInfo.underCurationMessage &&
636
          ((this.resultLandingInfo.fundedByProjects && this.resultLandingInfo.fundedByProjects.length > 0)
637
            || this.resultLandingInfo.journal
638
            || (this.resultLandingInfo.classifiedSubjects && this.resultLandingInfo.classifiedSubjects.size > 0)
639
            || (this.resultLandingInfo.organizations && this.resultLandingInfo.organizations.length > 0)
640
            || this.resultLandingInfo.bioentities || (this.resultLandingInfo.references && this.resultLandingInfo.references.length > 0)
641
            || (this.resultLandingInfo.relatedResearchResults && this.resultLandingInfo.relatedResearchResults.length > 0)
642
            || (this.resultLandingInfo.similarResearchResults && this.resultLandingInfo.similarResearchResults.length > 0)
643
            || (this.resultLandingInfo.supplementaryResearchResults && this.resultLandingInfo.supplementaryResearchResults.length > 0)
644
            || (this.resultLandingInfo.supplementedByResearchResults && this.resultLandingInfo.supplementedByResearchResults.length > 0)
645
          ));
646
        if(!allow) {
647
          this._meta.updateTag({content: 'noindex'}, "name='robots'");
648
        }
649
      }
650
    } catch (e) {
651
      console.error("Error in passNoIndexFilter()", this.resultLandingInfo.relcanId, e);
652
      return false;
653
    }
654
  }
655
}
(2-2/4)