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

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

    
167
      this.metricsClicked = false;
168

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

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

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

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

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

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

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

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