Project

General

Profile

1
import {Component, Input, ViewChild} from '@angular/core';
2
import {ActivatedRoute, Router} from '@angular/router';
3
import {Location} from '@angular/common';
4
import {ErrorCodes} from "../../utils/properties/errorCodes";
5
import {ErrorMessagesComponent} from "../../utils/errorMessages.component";
6
import {SearchUtilsClass} from "../../searchPages/searchUtils/searchUtils.class";
7
import {RouterHelper} from "../../utils/routerHelper.class";
8
import {EnvProperties} from "../../utils/properties/env-properties";
9
import {properties} from "../../../../environments/environment";
10
import {OrcidService} from "../orcid.service";
11
import {Identifier, StringUtils} from "../../utils/string-utils.class";
12
import {SearchResearchResultsService} from "../../services/searchResearchResults.service";
13
import {Session} from "../../login/utils/helper.class";
14
import {LoginErrorCodes} from "../../login/utils/guardHelper.class";
15
import {SearchResult} from "../../utils/entities/searchResult";
16
import {ResultPreview} from "../../utils/result-preview/result-preview";
17
import {HttpClient} from "@angular/common/http";
18
import {Meta, Title} from "@angular/platform-browser";
19
import {UserManagementService} from "../../services/user-management.service";
20

    
21
declare var UIkit: any;
22

    
23
@Component({
24
  selector: 'my-orcid-links',
25
  template: `
26

    
27
<!--    <div class="uk-section uk-padding-remove-bottom uk-padding-remove-top">-->
28
<!--      <div class="explorePanelBackground communityPanelBackground uk-padding-small">-->
29
<!--        <div class="uk-container uk-container-large uk-margin-small-top uk-margin-small-bottom">-->
30
<!--          <breadcrumbs  [light]="!!(this.communityId)" [breadcrumbs]="breadcrumbs"></breadcrumbs>-->
31
<!--        </div>-->
32
<!--      </div>-->
33
<!--    </div>-->
34
    <div class="">
35
      <div class="uk-container uk-container-large uk-margin-top">
36
        <div class="uk-article-title custom-article-title">
37
          My ORCID links
38
        </div>
39
        <div *ngIf="authorNameParam" class="uk-margin-top">
40
          <a class="uk-button-text" [queryParams]="authorNameParam" [routerLink]="properties.searchLinkToAdvancedResults" routerLinkActive="router-link-active">
41
            Discover research results related to you
42
          </a>
43
        </div>
44
        <div *ngIf="showErrorMessage" class="uk-animation-fade uk-alert uk-alert-warning" role="alert">
45
          An Error Occurred
46
        </div>
47
        <div *ngIf="!showLoading && !orcidQuery && !requestGrant && !showErrorMessage" 
48
              class="uk-animation-fade uk-alert uk-alert-primary" role="alert">
49
          No ORCID links found
50
        </div>
51
        <div *ngIf="requestGrant" class="">
52
          <div class="uk-text-center uk-padding-small">
53
            <div>
54
              This is a private page, only for users that have connected their ORCID iD with OpenAIRE.
55
              Please grant OpenAIRE to access and update your ORCID works.
56
            </div>
57

    
58
            <div class="uk-margin-medium-top uk-align-center">
59
              <button (click)="openGrantWindow()" type="submit"
60
                      class="uk-button uk-padding-small uk-padding-remove-vertical uk-margin-left uk-button-primary">
61
                <span>Grant OpenAIRE</span>
62
              </button>
63
            </div>
64
          </div>
65
        </div>
66
      </div>
67
      
68
<!--      <div *ngIf="orcidQuery" class="uk-container uk-container-large uk-margin-top">-->
69

    
70
<!--        <form -->
71
<!--              class="uk-margin-top uk-grid uk-margin-small-left ng-untouched ng-pristine ng-valid uk-form-width-large uk-float-right">-->
72
<!-- -->
73
<!--          <div class=" uk-padding-remove-left uk-margin-small-top uk-inline uk-width-expand">-->
74
<!--            <a *ngIf="keyword.length > 0" class="uk-form-icon uk-form-icon-flip"-->
75
<!--               (click)="keyword = ''"-->
76
<!--               uk-icon="icon: close"></a>-->
77
<!--            <input type="text" class="uk-input text-input-box uk-width-expand"-->
78
<!--                   placeholder="Search by name, description, subject..." aria-describedby="sizing-addon2"-->
79
<!--                   [(ngModel)]="keyword" name="keyword">-->
80
<!--          </div>-->
81
<!--          <div class="uk-padding-remove-left">    -->
82
<!--          <button (click)="keywordChanged()" type="submit"-->
83
<!--                  class="portal-button uk-margin-small-left uk-margin-small-top uk-button">Search-->
84
<!--          </button>-->
85
<!--          </div>-->
86
<!-- -->
87
<!--        </form>-->
88
<!--      </div>-->
89
      
90
      
91
<!--      <div id="tm-main" class="   tm-middle" [class.uk-margin-top]="stickyForm">-->
92
<!--        <div uk-grid>-->
93
<!--          <div class="tm-main uk-width-1-1@s uk-width-1-1@m  uk-width-1-1@l uk-row-first ">-->
94
<!--            <div class="uk-container uk-container-large">-->
95
<!--              <my-orcid-result [results]="results"-->
96
<!--                            [status]="searchUtils.status"-->
97
<!--                            [type]="resultType"-->
98
<!--                            [properties]=properties>-->
99
<!--              </my-orcid-result>-->
100
<!--            </div>      -->
101
<!--          </div>-->
102
<!--        </div>-->
103
<!--      </div>-->
104
    </div>
105

    
106
    <div *ngIf="orcidQuery" class="tm-middle" id="tm-main">
107
      <div uk-grid="" class="uk-grid uk-grid-stack">
108
        <div class="tm-main uk-width-1-1@s uk-width-1-1@m uk-width-1-1@l uk-row-first uk-first-column">
109
          <div class="uk-container uk-container-large">
110
            <my-orcid-result [previewResults]="currentResults" 
111
                             [status]="searchUtils.status" 
112
                             [type]="resultType" 
113
                             [properties]=properties
114
                             [currentPage]="currentPage" 
115
                             [totalResults]="totalOrcidResults" 
116
                             [resultsPerPage]="resultsPerPage"
117
                             (pageChange)="pageChanged($event)">
118
            </my-orcid-result>        
119
            
120
            <div class="uk-text-center uk-margin-medium-top uk-margin-medium-bottom uk-animation-fade uk-alert" role="alert">
121
              Your ORCID links will be visible in the OpenAIRE research results as soon as we synchronize our data with ORCID.
122
            </div>
123
          </div>
124
        </div>
125
      </div>
126
    </div>
127
    `
128
})
129
export class MyOrcidLinksComponent {
130
  public resultType: string = "result";
131

    
132
  private errorCodes: ErrorCodes;
133
  private errorMessages: ErrorMessagesComponent;
134
  @Input() piwikSiteId = null;
135
  public results =[];
136
  public currentResults = [];
137
  public totalResults:number  = 0 ;
138
  public baseUrl:string;
139
  public searchUtils:SearchUtilsClass = new SearchUtilsClass();
140
  public subscriptions: any[] = [];
141
  public _location:Location;
142

    
143
  public disableForms: boolean = false;
144
  public loadPaging: boolean = true;
145
  public oldTotalResults: number = 0;
146
  pagingLimit = 0;
147

    
148
  properties:EnvProperties;
149

    
150
  @Input() public communityId: string = null;
151

    
152
  depositLearnHowPage: string = null;
153
  public routerHelper:RouterHelper = new RouterHelper();
154
  // breadcrumbs:Breadcrumb[] = [];
155
  parameters = {};
156
  keyword  = "";
157

    
158
  identifiers: string[] = [];
159
  works: any[] = [];
160

    
161
  orcidQuery: string = "";
162
  typeQuery: string = "";
163

    
164
  public showLoading: boolean = true;
165

    
166
  currentPage: number = 1;
167
  totalOrcidResults: number;
168
  resultsPerPage: number = 5;
169

    
170
  public requestGrant: boolean = false;
171
  public window: any;
172
  private tokenUrl: string;
173
  private clientId: string = "APP-A5M3KTX6NCN67L91";
174

    
175
  public authorNameParam: any = null;
176

    
177
  public showErrorMessage: boolean = false;
178

    
179
  constructor (private route: ActivatedRoute, private router: Router,
180
               private _orcidService: OrcidService,
181
               private _searchResearchResultsService: SearchResearchResultsService,
182
               private userManagementService: UserManagementService,
183
               private _meta: Meta, private _title: Title
184
               // ,private http: HttpClient/*ATHENA CODE*/
185
  ) {
186
    this.errorCodes = new ErrorCodes();
187
    this.errorMessages = new ErrorMessagesComponent();
188
    this.searchUtils.status = this.errorCodes.LOADING;
189
    this.searchUtils.page =1;
190

    
191
    if(typeof document !== 'undefined') {
192
      this.tokenUrl = properties.orcidTokenURL
193
        + "client_id="+properties.orcidClientId
194
        // + "&response_type=code&scope=/activities/update"
195
        // + "&response_type=code&scope=/authenticate /activities/update /person/update /read-limited"
196
        + "&response_type=code&scope=/activities/update /read-limited"
197
        + "&redirect_uri="+location.origin+"/orcid?source=openaire";
198
    }
199
  }
200

    
201
  public ngOnInit() {
202
    this.properties = properties;
203
    this.depositLearnHowPage = this.properties.depositLearnHowPage;
204
    this.baseUrl = this.properties.depositSearchPage;
205
    this.pagingLimit = this.properties.pagingLimit;
206
    // this.breadcrumbs.push({name: 'home', route: '/'}, {
207
    //   name: "Deposit",
208
    //   route: this.depositLearnHowPage
209
    // }, {name: "Browse repositories", route: null});
210

    
211
    // this.subscriptions.push(this.route.queryParams.subscribe(
212
    //   params => {
213
        // this.searchUtils.page = params['page'] ? params['page']-1 : 1;
214
        // this.searchUtils.size = params['size'] ? params['size'] : 5;
215

    
216
        // let page = (params['page'] === undefined) ? 1 : +params['page'];
217
        // this.searchUtils.page = (page <= 0) ? 1 : page;
218
        // let size = (params['size'] === undefined) ? 5 : +params['size'];
219
        // this.searchUtils.size = (size <= 0) ? 1 : size;
220
        //
221
        // if (params["type"]) {
222
        //   let types = params["type"];
223
        //   types = Array.isArray(types) ? types.join(',').split(","):types.split(",");
224
        //   types.map( function (t) {
225
        //     return StringUtils.unquote(StringUtils.URIDecode(t));
226
        //   } );
227
        //
228
        //   if(types.indexOf("publications")!=-1 && types.indexOf("datasets")!=-1 && types.indexOf("software")!=-1 && types.indexOf("other")!=-1 ){
229
        //     this.typeQuery += "&type=results";
230
        //   }else{
231
        //     for (let type of types) {
232
        //       this.typeQuery += "&type=" + StringUtils.unquote(StringUtils.URIDecode(type));
233
        //     }
234
        //   }
235
        // }else{
236
        //   this.typeQuery += "&type=results";
237
        // }
238

    
239
        // this.typeQuery = "&type=results";
240
        // this.getLocalWorks(this.currentPage, this.resultsPerPage);
241
    // }));
242
    var description = "Openaire, ORCID linking, publication, research data, software, other research product";
243
    this.updateTitle("My ORCID Links");
244
    this.updateDescription(description);
245
    this.updateUrl( properties.domain + properties.baseLink + this.route.url);
246

    
247
    this.typeQuery = "&type=results";
248
    this.getLocalWorks();
249
    this.getPersonalDetails();
250
  }
251

    
252
  public ngOnDestroy() {
253
    for(let sub of this.subscriptions){
254
      sub.unsubscribe();
255
    }
256
  }
257

    
258
  private getPersonalDetails() {
259
    //get author name
260
    this.subscriptions.push(this._orcidService.getPersonalDetails().subscribe(
261
      details => {
262
        let author: string = "";
263

    
264
        if(details && details['name']) {
265
          let name: string = details['name'];
266
          if(name['given-names'] && name['given-names']['value']) {
267
            author = name['given-names']['value'];
268
          }
269
          if(name['family-name'] && name['family-name']['value']) {
270
            author += (author ? " " : "") + name['family-name']['value'];
271
          }
272
          this.authorNameParam = this.routerHelper.createQueryParams(['f0', 'fv0'], ['resultauthor', author]);
273
        }
274
      },
275
      error => {
276
        console.error("Error getting personal details", error);
277
        this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
278
          if (user) {
279
            this.authorNameParam = this.routerHelper.createQueryParams(['f0', 'fv0'], ['resultauthor', user.fullname]);
280
          }
281
        }));
282
      }
283
    ));
284
  }
285

    
286
  openGrantWindow() {
287
    this.window = window.open(this.tokenUrl, '_blank',
288
      'location=yes,height=700,width=540,left=500,top=100,scrollbars=yes,status=yes');
289

    
290
    let self = this;
291
    window.onmessage = function (ev) {
292
      if (ev.isTrusted && ev.origin !== location.origin && ev.data !== 'success')
293
        return;
294
      self.requestGrant = false;
295
      UIkit.notification({
296
        message: 'Thank you for <strong>connecting your ORCID iD</strong> with OpenAIRE!',
297
        status: 'success',
298
        timeout: 6000,
299
        pos: 'bottom-right'
300
      });
301
      self.getLocalWorks();
302
    };
303
  }
304

    
305
  getLocalWorks() {
306
    this.showErrorMessage = false;
307

    
308
    this.showLoading = true;
309
    this.subscriptions.push(this._orcidService.getLocalWorks().subscribe(
310
      (response: any[]) => {
311

    
312
        this.works = response;//['results'];
313
        this.totalOrcidResults = this.works.length;//response['total'];
314

    
315
        this.prepareOrcidQuery();
316
      },
317
      error => {
318
        this.handleError(error, "Could not get locally stored user's ORCID works");
319
        this.showLoading = false;
320
      }
321
    ));
322
  }
323

    
324
  public prepareOrcidQuery() {
325

    
326
    if(this.results.length >= this.currentPage) {
327
      this.currentResults = this.results[this.currentPage-1];
328
      return;
329
    }
330

    
331
    this.showLoading = true;
332

    
333
    this.orcidQuery = "";
334

    
335
    let from: number = (this.currentPage-1)*this.resultsPerPage;
336
    if(from >= this.works.length) {
337
      this.searchUtils.status = this.errorCodes.OUT_OF_BOUND;
338
    }
339
    let to: number = this.currentPage*this.resultsPerPage;
340

    
341
    if(to > this.works.length) {
342
      to = this.works.length;
343
    }
344

    
345
    let works = this.works.slice(from, to);
346

    
347
    for(let work of works) {
348
      for(let pid of work['pids']) {
349
        let identifier: Identifier = Identifier.getIdentifierFromString(pid);
350
        this.orcidQuery += (this.orcidQuery ? " or " : "") + ('(pidclassid exact "'+identifier.class+'" and pid="'+StringUtils.URIEncode(identifier.id)+'")');
351
        //this.orcidQuery = '(pidclassid exact "doi" and pid="10.1007/978-3-030-55814-7_16")';
352
        // console.debug(this.orcidQuery);
353
      }
354
    }
355
    this.showLoading = false;
356
    this._getResults(works);
357
  }
358

    
359
  public _getResults(works: any) {
360
    this.searchUtils.status = this.errorCodes.LOADING;
361
    this.disableForms = true;
362
    this.currentResults = [];
363
    this.searchUtils.totalResults = 0;
364

    
365
    // let params: string = this.orcidQuery + this.typeQuery;
366
    //this.subs.push(this._searchResearchResultsService.advancedSearchResults(this.resultType, parameters, page, size, sortBy, this.properties, (refine) ? this.searchPage.getRefineFieldsQuery() : null, this.searchPage.getFields(), refineFieldsFilterQuery)
367
    this.subscriptions.push(this._searchResearchResultsService.searchForMyOrcidLinks(this.resultType, this.orcidQuery, this.typeQuery, 1, 50)
368
    //this.subs.push(this._searchResearchResultsService.advancedSearchResults(this.resultType, parameters, page, size, sortBy, this.properties, null, this.searchPage.getFields(), refineFieldsFilterQuery)
369
      .subscribe(
370
        data => {
371
          // this is for testing purposes only!
372
          // let newRes = JSON.parse(JSON.stringify(data[1][0]));
373
          // newRes.identifiers = new Map();
374
          // newRes.identifiers.set("doi", [data[1][0].identifiers.get("doi")[1]]);
375
          // data[1].push(newRes);
376
          // console.log(data[1][data[0]]);
377
          //
378
          // data[1][0].identifiers.set("doi", [data[1][0].identifiers.get("doi")[0]]);
379
          // console.log(data[1][0]);
380
          //
381
          // data[0] += 1;
382

    
383
          let totalResults = data[0];
384
          let results = data[1];
385

    
386
          this.resultsReturned(results, totalResults, works);
387
        },
388
        err => {
389
          // this.handleError("Error getting " + this.getEntityName(this.resultType, true, true), err);
390
          console.error("Error getting " + this.getEntityName(this.resultType, true, true));
391
          this.showLoading = false;
392
          this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
393
          this.disableForms = false;
394
        }
395
      )
396
    );
397
  }
398

    
399
  public resultsReturned(results: any, totalResults, works: any[]) {
400
    this.searchUtils.totalResults = totalResults;
401

    
402
    let resultsFound: Map<string[], number> = new Map<string[], number>();
403

    
404
    for(let work of works) {
405
      results.forEach(result => {
406
        let identifierValues: string[] = [].concat(...Array.from(result.identifiers.values()));
407
        if(work['pids'].some(pid => identifierValues.includes(pid))) {
408

    
409
          let index: number = resultsFound.get(identifierValues);
410
          if(!index) {
411
            this.currentResults.push(this.getResultPreview(result));
412
            index = this.currentResults.length - 1;
413

    
414
            this.currentResults[index].orcidPutCodes = [];
415
            this.currentResults[index].orcidCreationDates = [];
416
            this.currentResults[index].orcidUpdateDates = [];
417
          }
418

    
419
          if (work['putCode']) {
420
            this.currentResults[index].orcidPutCodes.push(work['putCode']);
421
          }
422
          if (work['creationDate']) {
423
            this.currentResults[index].orcidCreationDates.push(work['creationDate']);
424
          }
425
          if (work['updateDate']) {
426
            this.currentResults[index].orcidUpdateDates.push(work['updateDate']);
427
          }
428
        }
429
      })
430
    }
431

    
432
    // /////////////////////// ATHENA CODE ///////////////////////
433
    // // console.log(data[1]);
434
    // let dois = encodeURIComponent(results.map((result) => result.DOIs).join(","));
435
    // console.log(dois);
436
    // console.log(this.properties.impactFactorsAPIURL);
437
    // if(dois.length > 0 &&  (this.properties.impactFactorsAPIURL &&  this.properties.impactFactorsAPIURL.length > 0) ) {
438
    //   let url = this.properties.impactFactorsAPIURL + dois;
439
    //   this.http.get((this.properties.useCache?(this.properties.cacheUrl+(encodeURIComponent(url))):url)).subscribe((data_received:any[]) => {
440
    //     let impact =[];
441
    //     data_received.forEach(function (result) {
442
    //       if(result.doi && result.doi.length > 0 && result.pop_class!=null && result.inf_class!=null)
443
    //         impact[result.doi]=result;
444
    //     });
445
    //     this.currentResults.forEach(function (result) {
446
    //       if(result.identifiers) {
447
    //         result.identifiers.get("doi").forEach(function (doi) {
448
    //           if (impact[doi]) {
449
    //             result.DOI = doi;
450
    //           }
451
    //
452
    //         })
453
    //       }
454
    //     });
455
    //     for (let i = 0; i < this.currentResults.length; i++) {
456
    //       if (this.currentResults[i].DOI) {
457
    //         this.currentResults[i].pop_inf = new Array<string>();
458
    //         this.currentResults[i].pop_inf.push(impact[this.currentResults[i].DOI].pop_class, impact[this.currentResults[i].DOI].inf_class);
459
    //         if(this.currentResults[i].pop_inf[0]=="A"){
460
    //           // this.previewResults[i].pop_inf.push("High");
461
    //           this.currentResults[i].pop_inf.push("Exceptional");
462
    //         }else if(this.currentResults[i].pop_inf[0]=="B"){
463
    //           // this.previewResults[i].pop_inf.push("Average");
464
    //           this.currentResults[i].pop_inf.push("Substantial");
465
    //         }else{
466
    //           // this.previewResults[i].pop_inf.push("low");
467
    //           this.currentResults[i].pop_inf.push("Average");
468
    //         }
469
    //         if(this.currentResults[i].pop_inf[1]=="A"){
470
    //           // this.previewResults[i].pop_inf.push("Strong");
471
    //           this.currentResults[i].pop_inf.push("Exceptional");
472
    //         }else if(this.currentResults[i].pop_inf[1]=="B"){
473
    //           // this.previewResults[i].pop_inf.push("Average");
474
    //           this.currentResults[i].pop_inf.push("Substantial");
475
    //         }else{
476
    //           // this.previewResults[i].pop_inf.push("Weak");
477
    //           this.currentResults[i].pop_inf.push("Average");
478
    //         }
479
    //       }
480
    //     }
481
    //
482
    //   }, error1 => {
483
    //     console.error("Failed to get Impact factors for elixir-gr")
484
    //   });
485
    //   // console.log(researchResults[1]);
486
    //
487
    // }
488
    // /////////////////////// ATHENA CODE ///////////////////////
489

    
490

    
491
    this.results[this.currentPage-1] = this.currentResults;
492

    
493
    this.searchUtils.status = this.errorCodes.DONE;
494
    if (this.searchUtils.totalResults == 0) {
495
      this.searchUtils.status = this.errorCodes.NONE;
496
    }
497

    
498
    this.disableForms = false;
499
  }
500

    
501
  public resultsReturned2(results: any, totalResults, works: any[]) {
502
    this.searchUtils.totalResults = totalResults;
503

    
504
    for(let result of results) {
505
      let identifierValues: string[] = [].concat(...Array.from(result.identifiers.values()));
506

    
507
      this.currentResults.push(this.getResultPreview(result));
508

    
509
      let filteredWorks = works.filter(work => {
510
        return work['pids'].some(pid => identifierValues.includes(pid));
511
      })
512

    
513
      this.currentResults[this.currentResults.length - 1].orcidPutCodes = [];
514
      this.currentResults[this.currentResults.length - 1].orcidCreationDates = [];
515
      this.currentResults[this.currentResults.length - 1].orcidUpdateDates = [];
516

    
517
      filteredWorks.forEach(work => {
518
        if(work['putCode']) {
519
          this.currentResults[this.currentResults.length - 1].orcidPutCodes.push(work['putCode']);
520
        }
521
        if(work['creationDate']) {
522
          this.currentResults[this.currentResults.length - 1].orcidCreationDates.push(work['creationDate']);
523
        }
524
        if(work['updateDate']) {
525
          this.currentResults[this.currentResults.length - 1].orcidUpdateDates.push(work['updateDate']);
526
        }
527

    
528
        // this.currentResults[this.currentResults.length - 1].orcidPutCodes.push(work['putCode']);
529
        // this.currentResults[this.currentResults.length - 1].orcidCreationDates.push(work['creationDate']);
530
        // this.currentResults[this.currentResults.length - 1].orcidUpdateDates.push(work['creationDate']);
531
      });
532
    }
533

    
534
    this.results[this.currentPage-1] = this.currentResults;
535
    // if(!refine) {
536
      // this.searchPage.buildPageURLParameters(this.filters, this.rangeFilters, false);
537
    // }
538

    
539
    this.searchUtils.status = this.errorCodes.DONE;
540
    if (this.searchUtils.totalResults == 0) {
541
      this.searchUtils.status = this.errorCodes.NONE;
542
    }
543

    
544
    this.disableForms = false;
545
  }
546

    
547
  public getResultPreview(result: SearchResult): ResultPreview {
548
    return ResultPreview.searchResultConvert(result, (result.entityType)?result.entityType:this.resultType);
549
  }
550

    
551
  // private handleError(message: string, error) {
552
  //   if(error && error.status == "401") {
553
  //     this.requestGrant = true;
554
  //     this.requestGrantMessage = "Please grant OpenAIRE to access and update your ORCID record and works. ";
555
  //     // + "If you have already granted OpenAIRE, you just need to login again to ORCID!";
556
  //   } else if(error && error.status == "403") {
557
  //     this.requestGrant = true;
558
  //     this.requestGrantMessage = "Please login again to ORCID."
559
  //   }
560
  //   console.error("My ORCID links Page: "+message, error);
561
  // }
562

    
563
  public getEntityName(entityType: string, plural: boolean, full: boolean): string {
564
    if (entityType == "publication") {
565
      return "publication" + (plural ? "s" : "");
566
    } else if (entityType == "dataset") {
567
      return (full ? "research data" : ("dataset" + (plural ? "s" : "")));
568
    } else if (entityType == "software") {
569
      return "software";
570
    } else if (entityType == "other") {
571
      return (full ? ("other research product" + (plural ? "s" : "")) : "other");
572
    } else if (entityType == "result") {
573
      return (full ? ("research outcome" + (plural ? "s" : "")) : "result");
574
    }
575
  }
576

    
577
  public pageChanged($event) {
578
    this.currentPage = $event.value;
579
    this.prepareOrcidQuery();
580
    // this.getLocalWorks(this.currentPage, this.resultsPerPage);
581
  }
582

    
583
  handleError(error, errorMsg: string) {
584
    if(error && (error.status == "401" || error.status == "403")) {
585
      this.requestGrant = true;
586
    } else {
587
      this.showErrorMessage = true;
588

    
589
      // UIkit.notification({
590
      //   message: errorMsg,
591
      //   status: 'warning',
592
      //   timeout: 6000,
593
      //   pos: 'bottom-right'
594
      // });
595
    }
596
    this.showLoading = false;
597
  }
598

    
599
  private updateTitle(title: string) {
600
    var _prefix = "";
601
    // if(!this.communityId) {
602
    //   _prefix = "OpenAIRE | ";
603
    // }
604
    // var _title = _prefix + ((title.length > 50) ? title.substring(0, 50) : title);
605
    this._title.setTitle(title);
606
    this._meta.updateTag({content: title}, "property='og:title'");
607
  }
608

    
609
  private updateDescription(description: string) {
610
    this._meta.updateTag({content: description}, "name='description'");
611
    this._meta.updateTag({content: description}, "property='og:description'");
612
  }
613

    
614
  private updateUrl(url: string) {
615
    this._meta.updateTag({content: url}, "property='og:url'");
616
  }
617
}
(1-1/5)