Project

General

Profile

1 58275 k.triantaf
import {ChangeDetectorRef, Component, Input, ViewChild} from '@angular/core';
2 56958 konstantin
import {ActivatedRoute, Router} from '@angular/router';
3
import {Meta, Title} from '@angular/platform-browser';
4
5
import {EnvProperties} from '../../utils/properties/env-properties';
6 58310 k.triantaf
import {Id, ResultLandingInfo} from '../../utils/entities/resultLandingInfo';
7 56958 konstantin
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 57536 konstantin
import {Location} from "@angular/common";
15 58275 k.triantaf
import {MetricsService} from "../../services/metrics.service";
16 58778 k.triantaf
import {RelationResult, ResultPreview} from "../../utils/result-preview/result-preview";
17 58723 k.triantaf
import {IndexInfoService} from "../../utils/indexInfo.service";
18 60221 konstantin
import {Identifier, StringUtils} from "../../utils/string-utils.class";
19 59007 k.triantaf
import {properties} from "../../../../environments/environment";
20 59072 konstantin
import {ISVocabulariesService} from "../../utils/staticAutoComplete/ISVocabularies.service";
21 59816 argiro.kok
import {Subscriber} from "rxjs";
22 60221 konstantin
import {Session} from "../../login/utils/helper.class";
23 60187 k.triantaf
import {AnnotationComponent} from "../annotation/annotation.component";
24 56958 konstantin
25
26
@Component({
27
  selector: 'result-landing',
28
  templateUrl: 'resultLanding.component.html',
29
})
30
export class ResultLandingComponent {
31
  @Input() type: string = "publication";
32 59007 k.triantaf
  @Input() piwikSiteId = properties.piwikSiteId;
33 56958 konstantin
  @Input() communityId = null;
34 58731 k.triantaf
  @ViewChild('linkModal') linkModal;
35
  @ViewChild('citeModal') citeModal;
36 56958 konstantin
  @ViewChild('AlertModalDeletedByInference') alertModalDeletedByInference;
37 58275 k.triantaf
  @ViewChild('relationModal') relationModal;
38
  @ViewChild('organizationModal') organizationModal;
39 57201 konstantin
  public deleteByInferenceOpened: boolean = false;
40 58745 k.triantaf
41 56958 konstantin
  public resultLandingInfo: ResultLandingInfo;
42 58748 k.triantaf
  public supplementaryResults: RelationResult[];
43 58275 k.triantaf
  public relation: string = 'trust';
44 56958 konstantin
  public id: string;
45
  public title: string;
46 58745 k.triantaf
47 58792 k.triantaf
  /*Show all organizations*/
48
  public showAll: boolean = false;
49
50 56958 konstantin
  // Links for SEO
51
  public linkToLandingPage: string = null;
52
  public linkToSearchPage: string = null;
53 58745 k.triantaf
54 58275 k.triantaf
  public thresholdDescription: number = 670;
55
  public showNumDescription: number = 670;
56 59007 k.triantaf
57 58951 konstantin
  public citeThisClicked: boolean;
58 59007 k.triantaf
59 56958 konstantin
  // Metrics tab variables
60
  public metricsClicked: boolean;
61 58275 k.triantaf
  public hasAltMetrics: boolean = false;
62 56958 konstantin
  public viewsFrameUrl: string;
63
  public downloadsFrameUrl: string;
64
  public totalViews: number;
65
  public totalDownloads: number;
66
  public pageViews: number;
67 58745 k.triantaf
68 56958 konstantin
  // Custom tab paging variables
69
  public referencesPage: number = 1;
70 58275 k.triantaf
  public bioentitiesPage: number = 1;
71 58748 k.triantaf
  public relatedPage: number = 1;
72
  public similarPage: number = 1;
73
  public supplementaryPage: number = 1;
74
  public supplementedByPage: number = 1;
75 56958 konstantin
  public organizationsPage: number = 1;
76
  public openCitationsPage: number = 1;
77
  public pageSize: number = 10;
78 58745 k.triantaf
79 56958 konstantin
  // Map counting variables
80
  public bioentitiesNum: number = 0;
81 58748 k.triantaf
  public relatedResultsNum: number = 0;
82 59816 argiro.kok
83 56958 konstantin
  // Message variables
84
  public warningMessage = "";
85
  public errorMessage = "";
86
  public showLoading: boolean = true;
87 59060 k.triantaf
  public dashboard = properties.isDashboard;
88 58745 k.triantaf
89 56958 konstantin
  public routerHelper: RouterHelper = new RouterHelper();
90 58778 k.triantaf
  public activeTab: string = null;
91 56958 konstantin
  private doi: string;
92 59816 argiro.kok
  subscriptions = [];
93 59007 k.triantaf
  properties: EnvProperties = properties;
94 58275 k.triantaf
  public indexUpdateDate: Date;
95 56958 konstantin
  public pageContents = null;
96
  public divContents = null;
97 58275 k.triantaf
  public showFeedback: boolean = false;
98
  public feedbackFields: string [] = [
99
    'Title', 'Authors', 'Access rights',
100
    'Publisher information', 'Funding Information',
101 58745 k.triantaf
    'Persistent identifiers', 'Other'];
102 60221 konstantin
  public loggedIn: boolean = false;
103
  public pidsArrayString: string = "";
104
  public identifier: Identifier;
105
106 60223 k.triantaf
  public isLoggedIn: boolean = Session.isLoggedIn();
107 60187 k.triantaf
  public pid: string;
108
  @ViewChild("annotation") annotation: AnnotationComponent;
109 60221 konstantin
110
  constructor(private _resultLandingService: ResultLandingService,
111 59072 konstantin
              private _vocabulariesService: ISVocabulariesService,
112 56958 konstantin
              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 57404 konstantin
              private seoService: SEOService,
120 58275 k.triantaf
              private metricsService: MetricsService,
121
              private cdr: ChangeDetectorRef,
122 58723 k.triantaf
              private _location: Location,
123 60187 k.triantaf
              private indexInfoService: IndexInfoService) {
124 56958 konstantin
  }
125 58745 k.triantaf
126 56958 konstantin
  ngOnInit() {
127 59007 k.triantaf
    if (typeof document !== 'undefined') {
128 59816 argiro.kok
      this.subscriptions.push(this.indexInfoService.getLastIndexDate(this.properties).subscribe(lastIndexUpdate => {
129 59007 k.triantaf
        if (lastIndexUpdate) {
130
          this.indexUpdateDate = new Date(lastIndexUpdate);
131 58874 konstantin
        }
132 59816 argiro.kok
      }));
133 59007 k.triantaf
    }
134
    //this.getDivContents();
135
    this.getPageContents();
136 59411 argiro.kok
    this.updateUrl(this.properties.domain +this.properties.baseLink +  this._router.url);
137 60221 konstantin
    this.subscriptions.push(this.route.queryParams.subscribe(async data => {
138
      if (Session.isLoggedIn()) {
139
        this.loggedIn = true;
140
      }
141 59007 k.triantaf
      this.resultLandingInfo = null;
142 59037 argiro.kok
      if (data['articleId']) {
143 59007 k.triantaf
        this.id = data['articleId'];
144 60221 konstantin
        this.initMetaAndLinks("publication");
145 59037 argiro.kok
      } else if (data['datasetId']) {
146 59007 k.triantaf
        this.id = data['datasetId'];
147 60221 konstantin
        this.initMetaAndLinks("dataset");
148 59037 argiro.kok
      } else if (data['softwareId']) {
149 59007 k.triantaf
        this.id = data['softwareId'];
150 60221 konstantin
        this.initMetaAndLinks("software");
151 59037 argiro.kok
      } else if (data['orpId']) {
152 59007 k.triantaf
        this.id = data['orpId'];
153 60221 konstantin
        this.initMetaAndLinks("orp");
154
      } else if (data["id"]) {
155 59007 k.triantaf
        this.id = data["id"];
156 60221 konstantin
        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 59007 k.triantaf
      }
166
      this.updateDescription("");
167 60221 konstantin
168 59007 k.triantaf
      this.metricsClicked = false;
169 59037 argiro.kok
170 60221 konstantin
      if ((this.id && StringUtils.isOpenAIREID(this.id)) || (this.identifier)) {
171 59007 k.triantaf
        this.getProvenanceVocabularyAndResultLandingInfo();
172
      } else {
173
        this.showLoading = false;
174 60221 konstantin
175 59007 k.triantaf
        this._router.navigate(['/error'], {
176
          queryParams: {
177
            "page": this._location.path(true),
178
            "page_type": this.type
179 56958 konstantin
          }
180
        });
181 59007 k.triantaf
      }
182 60221 konstantin
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 59007 k.triantaf
      this.scroll();
189 59816 argiro.kok
    }));
190 56958 konstantin
  }
191 60221 konstantin
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 56958 konstantin
  private getPageContents() {
227 59007 k.triantaf
    if (this.communityId) {
228 59816 argiro.kok
      this.subscriptions.push(this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
229 59007 k.triantaf
        this.pageContents = contents;
230 59816 argiro.kok
      }));
231 59007 k.triantaf
    }
232 56958 konstantin
  }
233 58745 k.triantaf
234 56958 konstantin
  private getDivContents() {
235 59007 k.triantaf
    if (this.communityId) {
236 59816 argiro.kok
      this.subscriptions.push(this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
237 59007 k.triantaf
        this.divContents = contents;
238 59816 argiro.kok
      }));
239 59007 k.triantaf
    }
240 56958 konstantin
  }
241 59816 argiro.kok
242 56958 konstantin
  ngOnDestroy() {
243 59816 argiro.kok
    this.subscriptions.forEach(subscription => {
244
      if (subscription instanceof Subscriber) {
245
        subscription.unsubscribe();
246
      }
247
    });
248
    this._vocabulariesService.clearSubscriptions();
249 56958 konstantin
  }
250 58275 k.triantaf
251 60187 k.triantaf
  public pidInit(event) {
252
    this.pid = event;
253
    this.cdr.detectChanges();
254
  }
255
256
257 58275 k.triantaf
  public getTypeName(): string {
258
    if (this.type === "dataset") {
259
      return "research data";
260
    } else if (this.type === "orp" || this.type === "other") {
261 58802 k.triantaf
      return "research product";
262 58275 k.triantaf
    } 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 58745 k.triantaf
280 58275 k.triantaf
  private getOpenCitations() {
281 60221 konstantin
    this.subscriptions.push(this._resultLandingService.getOpenCitations(this.id, this.properties).subscribe(
282 56958 konstantin
      data => {
283
        this.resultLandingInfo.openCitations = data[1];
284
      },
285
      err => {
286 58745 k.triantaf
        this.handleError("Error getting open citation for " + this.type + " with id: " + this.id, err);
287 56958 konstantin
      }
288 59816 argiro.kok
    ));
289 56958 konstantin
  }
290 58745 k.triantaf
291 57330 konstantin
  private getProvenanceVocabularyAndResultLandingInfo() {
292 56958 konstantin
    this.warningMessage = '';
293
    this.errorMessage = '';
294
    this.showLoading = true;
295 58745 k.triantaf
296 56958 konstantin
    this.resultLandingInfo = null;
297 59007 k.triantaf
298 58874 konstantin
    if (typeof document !== 'undefined') {
299 59816 argiro.kok
      this.subscriptions.push(this._vocabulariesService.getProvenanceActionVocabulary(this.properties).subscribe(
300 58874 konstantin
        provenanceActionVocabulary => {
301
          this.getResultLandingInfo(provenanceActionVocabulary);
302
        }, err => {
303
          this.getResultLandingInfo(null);
304 60221 konstantin
          this.handleError("Error getting provenance action vocabulary for " + this.type, err);
305 58874 konstantin
        }
306 59816 argiro.kok
      ));
307 58874 konstantin
    } else {
308
      this.getResultLandingInfo(null);
309
    }
310 58745 k.triantaf
311 57330 konstantin
  }
312 58745 k.triantaf
313 58778 k.triantaf
  private setActiveTab() {
314 59007 k.triantaf
    if (this.hasPrimaryInfo || this.hasSecondaryInfo) {
315 58778 k.triantaf
      this.activeTab = 'summary';
316 59007 k.triantaf
    } else if (this.resultLandingInfo.references && this.resultLandingInfo.references.length > 0) {
317 58778 k.triantaf
      this.activeTab = 'references';
318 59007 k.triantaf
    } else if ((this.resultLandingInfo.supplementaryResearchResults && this.resultLandingInfo.supplementaryResearchResults.length > 0) ||
319
      (this.resultLandingInfo.supplementedByResearchResults && this.resultLandingInfo.supplementedByResearchResults.length > 0)) {
320 58778 k.triantaf
      this.activeTab = 'supplementary';
321 59007 k.triantaf
    } else if ((this.resultLandingInfo.relatedResearchResults && this.resultLandingInfo.relatedResearchResults.length > 0) ||
322 58778 k.triantaf
      (this.resultLandingInfo.similarResearchResults && this.resultLandingInfo.similarResearchResults.length > 0)) {
323
      this.activeTab = 'related';
324 59007 k.triantaf
    } else if (this.resultLandingInfo.bioentities && this.bioentitiesNum > 0) {
325 58778 k.triantaf
      this.activeTab = 'bioentities';
326
    }
327
  }
328
329 58807 konstantin
  // 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 58790 k.triantaf
351 57330 konstantin
  private getResultLandingInfo(provenanceActionVocabulary: any) {
352 60221 konstantin
    this.subscriptions.push(this._resultLandingService.getResultLandingInfo(this.id, this.identifier, this.type, provenanceActionVocabulary, this.properties).subscribe(
353 56958 konstantin
      data => {
354
        this.resultLandingInfo = data;
355 60221 konstantin
        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 58745 k.triantaf
        if (this.type == "result") { // no type was specified - update URL based this.resultLandingInfo.resultType
361 58176 argiro.kok
          this.updateUrlWithType();
362
        }
363 59411 argiro.kok
        this.seoService.createLinkForCanonicalURL(this.properties.domain+ properties.baseLink  + this.linkToLandingPage + this.resultLandingInfo.relcanId);
364 56958 konstantin
        if ((this.type == "publication") && (this.properties.environment == "beta" || this.properties.environment == "development") && (typeof document !== 'undefined')) {
365 58275 k.triantaf
          this.getOpenCitations();
366 56958 konstantin
        }
367 60158 argiro.kok
        this.addNoIndexFilter();
368 56958 konstantin
        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 59816 argiro.kok
          this.subscriptions.push(this._piwikService.trackView(this.properties, this.resultLandingInfo.title/*.name*/, this.piwikSiteId).subscribe());
374 56958 konstantin
        }
375 58745 k.triantaf
376 56958 konstantin
        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 59007 k.triantaf
        if (typeof document !== 'undefined') {
384 60221 konstantin
          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 58874 konstantin
          }
399 56958 konstantin
        }
400
        this.showLoading = false;
401 58778 k.triantaf
        this.setActiveTab();
402 56958 konstantin
      },
403
      err => {
404 60221 konstantin
        this.handleError("Error getting " + this.type + " for " + (this.id ? ("id: " + this.id) : ("pid: " + this.identifier.id + " ("+this.identifier.class+")")), err);
405 58745 k.triantaf
        if (err.status == 404) {
406 57536 konstantin
          this._router.navigate(['/error'], {queryParams: {"page": this._location.path(true), "page_type": this.type}});
407 57494 konstantin
        }
408 58745 k.triantaf
409
        if (this.type == "publication" || this.type == "software") {
410
          this.errorMessage = 'No ' + this.type + ' found';
411
        } else if (this.type == "dataset") {
412 56958 konstantin
          this.errorMessage += "No research data found";
413 58745 k.triantaf
        } else if (this.type == "orp") {
414 56958 konstantin
          this.errorMessage += "No research product found";
415
        }
416
        this.showLoading = false;
417 59411 argiro.kok
        this.seoService.createLinkForCanonicalURL(this.properties.domain+ properties.baseLink  + this.linkToSearchPage);
418 56958 konstantin
      }
419 59816 argiro.kok
    ));
420 56958 konstantin
  }
421 58745 k.triantaf
422 56958 konstantin
  public metricsResults($event) {
423
    this.totalViews = $event.totalViews;
424
    this.totalDownloads = $event.totalDownloads;
425
    this.pageViews = $event.pageViews;
426
  }
427 58598 k.triantaf
428 58745 k.triantaf
  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 58598 k.triantaf
  public get hasMetrics(): boolean {
439 58745 k.triantaf
    return !(this.totalViews && this.totalDownloads && this.pageViews) || this.totalViews > 0 || this.totalDownloads > 0 || this.pageViews > 0;
440 58598 k.triantaf
  }
441 58745 k.triantaf
442 56958 konstantin
  private updateDescription(description: string) {
443 57820 argiro.kok
    this._meta.updateTag({content: description.substring(0, 160)}, "name='description'");
444
    this._meta.updateTag({content: description.substring(0, 160)}, "property='og:description'");
445 56958 konstantin
  }
446 58745 k.triantaf
447 56958 konstantin
  private updateTitle(title: string) {
448
    var _prefix = "";
449 57820 argiro.kok
    // 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 56958 konstantin
  }
456 58745 k.triantaf
457 56958 konstantin
  private updateUrl(url: string) {
458
    this._meta.updateTag({content: url}, "property='og:url'");
459
  }
460 58745 k.triantaf
461 56958 konstantin
  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 58745 k.triantaf
469 56958 konstantin
  public updateReferencesPage($event) {
470
    this.referencesPage = $event.value;
471
  }
472 58275 k.triantaf
473
  public updateBioentitiesPage($event) {
474
    this.bioentitiesPage = $event.value;
475
  }
476
477 58748 k.triantaf
  public updateRelatedPage($event) {
478
    this.relatedPage = $event.value;
479 58275 k.triantaf
  }
480 58745 k.triantaf
481 58748 k.triantaf
  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 56958 konstantin
  public updateOrganizationsPage($event) {
494
    this.organizationsPage = $event.value;
495
  }
496 58745 k.triantaf
497 56958 konstantin
  public updateOpenCitationsPage($event) {
498
    this.openCitationsPage = $event.value;
499
  }
500 58064 k.triantaf
501
  public accessClass(accessMode: string): string {
502 58745 k.triantaf
    if (accessMode.toLowerCase().indexOf('open') !== -1) {
503 58064 k.triantaf
      return 'open';
504 58745 k.triantaf
    } else if (accessMode.toLowerCase() === 'not available') {
505 58064 k.triantaf
      return 'unknown';
506
    } else {
507
      return 'closed';
508
    }
509
  }
510 58745 k.triantaf
511 56958 konstantin
  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 58745 k.triantaf
519 56958 konstantin
  public getKeys(map) {
520
    return Array.from(map.keys());
521
  }
522 58745 k.triantaf
523 56958 konstantin
  public scroll() {
524
    HelperFunctions.scroll();
525
  }
526 58745 k.triantaf
527 56958 konstantin
  private handleError(message: string, error) {
528 58745 k.triantaf
    if (this.type == "publication") {
529 56958 konstantin
      console.error("Publication Landing Page: " + message, error);
530 58745 k.triantaf
    } else if (this.type == "dataset") {
531 56958 konstantin
      console.error("Research Data Landing Page: " + message, error);
532 58745 k.triantaf
    } else if (this.type == "software") {
533 56958 konstantin
      console.error("Software Landing Page: " + message, error);
534 58745 k.triantaf
    } else if (this.type == "orp") {
535 56958 konstantin
      console.error("Other Research Product Landing Page: " + message, error);
536
    } else {
537
      console.error("Landing Page: " + message, error);
538
    }
539
  }
540 58745 k.triantaf
541 56958 konstantin
  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 58745 k.triantaf
551 56958 konstantin
  openDeletedByInference() {
552 57201 konstantin
    this.deleteByInferenceOpened = true;
553 56958 konstantin
    this.alertModalDeletedByInference.cancelButton = false;
554
    this.alertModalDeletedByInference.okButton = false;
555 58275 k.triantaf
    this.alertModalDeletedByInference.alertTitle = "Other versions of";
556 56958 konstantin
    this.alertModalDeletedByInference.open();
557
  }
558 58275 k.triantaf
559
  public getResultPreview(result: RelationResult): ResultPreview {
560
    return ResultPreview.relationResultConvert(result, this.relation);
561
  }
562 59007 k.triantaf
563 58745 k.triantaf
  updateUrlWithType() {
564 58176 argiro.kok
    this.type = this.resultLandingInfo.resultType;
565 60221 konstantin
566 58745 k.triantaf
    if (this.type == "publication") {
567 58176 argiro.kok
      this.linkToLandingPage = this.properties.searchLinkToPublication;
568
      this.linkToSearchPage = this.properties.searchLinkToPublications;
569 58745 k.triantaf
    } else if (this.type == "dataset") {
570 58176 argiro.kok
      this.linkToLandingPage = this.properties.searchLinkToDataset;
571
      this.linkToSearchPage = this.properties.searchLinkToDatasets;
572 58745 k.triantaf
    } else if (this.type == "software") {
573 58391 argiro.kok
      this.linkToLandingPage = this.properties.searchLinkToSoftwareLanding;
574
      this.linkToSearchPage = this.properties.searchLinkToSoftware;
575 58745 k.triantaf
    } else if (this.type == "other") {
576
      this.type = "orp";
577 58176 argiro.kok
      this.linkToLandingPage = this.properties.searchLinkToOrp;
578
      this.linkToSearchPage = this.properties.searchLinkToOrps;
579
    }
580 60221 konstantin
    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 58176 argiro.kok
  }
587 58310 k.triantaf
588
  public getReferenceUrl(id: Id): string {
589 58745 k.triantaf
    if (id.type === "doi") {
590 58310 k.triantaf
      return this.properties.doiURL + id.value;
591 58745 k.triantaf
    } else if (id.type === "pmc") {
592 58310 k.triantaf
      return this.properties.pmcURL + id.value;
593 58745 k.triantaf
    } else if (id.type === "pmid") {
594 58310 k.triantaf
      return this.properties.pmidURL + id.value;
595 58745 k.triantaf
    } else if (id.type === "handle") {
596 58310 k.triantaf
      return this.properties.handleURL + id.value;
597
    } else {
598 58745 k.triantaf
      return null;
599 58310 k.triantaf
    }
600
  }
601
602
  public getReferenceIdName(id: Id): string {
603 58745 k.triantaf
    if (id.type === "doi") {
604 58310 k.triantaf
      return 'DOI'
605 58745 k.triantaf
    } else if (id.type === "pmc") {
606 58310 k.triantaf
      return 'Europe PMC'
607 58745 k.triantaf
    } else if (id.type === "pmid") {
608 58310 k.triantaf
      return 'PubMed';
609 58745 k.triantaf
    } else if (id.type === "handle") {
610 58310 k.triantaf
      return 'Handle.NET';
611
    } else {
612 58745 k.triantaf
      return null;
613 58310 k.triantaf
    }
614
  }
615 58731 k.triantaf
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 58951 konstantin
    this.citeThisClicked = true;
625 58731 k.triantaf
    this.citeModal.cancelButton = false;
626
    this.citeModal.okButton = false;
627 60181 argiro.kok
    this.citeModal.alertTitle = "Cite this " + this.getTypeName();
628 58731 k.triantaf
    this.citeModal.open();
629
  }
630 60158 argiro.kok
  addNoIndexFilter() {
631
    try {
632 60181 argiro.kok
      if(!(this.properties.environment == "production" || this.properties.environment == "development") ) {
633 60158 argiro.kok
        return ;
634
      }else {
635 60181 argiro.kok
       let allow =  !!(!this.resultLandingInfo.underCurationMessage &&
636 60158 argiro.kok
          ((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 60181 argiro.kok
        if(!allow) {
647 60158 argiro.kok
          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 56958 konstantin
}