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 class="uk-margin-top">
40
          <span *ngIf="authorNameParam">
41
            <a class="uk-button-text" [queryParams]="authorNameParam" 
42
                [routerLink]="properties.searchLinkToAdvancedResults" routerLinkActive="router-link-active">
43
              Discover research results related to you
44
            </a>
45
          </span>
46
          <span class="uk-align-right@m uk-margin-remove">
47
            Need help?
48
            <a href="https://www.openaire.eu/openaire-explore-integration-with-the-orcid-search-and-link-wizard" target="_blank">
49
              Read more  <span class="custom-external custom-icon space"></span>
50
            </a>
51
          </span>
52
        </div>
53
        <div *ngIf="showErrorMessage" class="uk-animation-fade uk-alert uk-alert-warning uk-margin-large-top" role="alert">
54
          An Error Occurred
55
        </div>
56
        <div *ngIf="!showLoading && !orcidQuery && !requestGrant && !showErrorMessage" 
57
              class="uk-animation-fade uk-alert uk-alert-primary uk-margin-large-top" role="alert">
58
          No ORCID links found
59
        </div>
60
        <div *ngIf="requestGrant" class="uk-margin-large-top">
61
          <div class="uk-text-center uk-padding-small">
62
            <div>
63
              This is a private page, only for users that have connected their ORCID iD with OpenAIRE.
64
              Please grant OpenAIRE to access and update your ORCID works.
65
            </div>
66

    
67
            <div class="uk-margin-medium-top uk-align-center">
68
              <button (click)="openGrantWindow()" type="submit"
69
                      class="uk-button uk-padding-small uk-padding-remove-vertical uk-margin-left uk-button-primary">
70
                <span>Grant OpenAIRE</span>
71
              </button>
72
            </div>
73
          </div>
74
        </div>
75
      </div>
76
      
77
<!--      <div *ngIf="orcidQuery" class="uk-container uk-container-large uk-margin-top">-->
78

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

    
115
    <div *ngIf="orcidQuery" class="tm-middle" id="tm-main">
116
      <div uk-grid="" class="uk-grid uk-grid-stack">
117
        <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">
118
          <div class="uk-container uk-container-large">
119
            <my-orcid-result [previewResults]="currentResults" 
120
                             [status]="searchUtils.status" 
121
                             [type]="resultType" 
122
                             [properties]=properties
123
                             [currentPage]="currentPage" 
124
                             [totalResults]="totalOrcidResults" 
125
                             [resultsPerPage]="resultsPerPage"
126
                             (pageChange)="pageChanged($event)">
127
            </my-orcid-result>        
128
            
129
            <div class="uk-text-center uk-margin-medium-top uk-margin-medium-bottom uk-animation-fade uk-alert" role="alert">
130
              Your ORCID links will be visible in the OpenAIRE research results as soon as we synchronize our data with ORCID.
131
            </div>
132
          </div>
133
        </div>
134
      </div>
135
    </div>
136
    `
137
})
138
export class MyOrcidLinksComponent {
139
  public resultType: string = "result";
140

    
141
  private errorCodes: ErrorCodes;
142
  private errorMessages: ErrorMessagesComponent;
143
  @Input() piwikSiteId = null;
144
  public results =[];
145
  public currentResults = [];
146
  public totalResults:number  = 0 ;
147
  public baseUrl:string;
148
  public searchUtils:SearchUtilsClass = new SearchUtilsClass();
149
  public subscriptions: any[] = [];
150
  public _location:Location;
151

    
152
  public disableForms: boolean = false;
153
  public loadPaging: boolean = true;
154
  public oldTotalResults: number = 0;
155
  pagingLimit = 0;
156

    
157
  properties:EnvProperties;
158

    
159
  @Input() public communityId: string = null;
160

    
161
  depositLearnHowPage: string = null;
162
  public routerHelper:RouterHelper = new RouterHelper();
163
  // breadcrumbs:Breadcrumb[] = [];
164
  parameters = {};
165
  keyword  = "";
166

    
167
  identifiers: string[] = [];
168
  works: any[] = [];
169

    
170
  orcidQuery: string = "";
171
  typeQuery: string = "";
172

    
173
  public showLoading: boolean = true;
174

    
175
  currentPage: number = 1;
176
  totalOrcidResults: number;
177
  resultsPerPage: number = 5;
178

    
179
  public requestGrant: boolean = false;
180
  public window: any;
181
  private tokenUrl: string;
182
  private clientId: string = "APP-A5M3KTX6NCN67L91";
183

    
184
  public authorNameParam: any = null;
185

    
186
  public showErrorMessage: boolean = false;
187

    
188
  constructor (private route: ActivatedRoute, private router: Router,
189
               private _orcidService: OrcidService,
190
               private _searchResearchResultsService: SearchResearchResultsService,
191
               private userManagementService: UserManagementService,
192
               private _meta: Meta, private _title: Title
193
               // ,private http: HttpClient/*ATHENA CODE*/
194
  ) {
195
    this.errorCodes = new ErrorCodes();
196
    this.errorMessages = new ErrorMessagesComponent();
197
    this.searchUtils.status = this.errorCodes.LOADING;
198
    this.searchUtils.page =1;
199

    
200
    if(typeof document !== 'undefined') {
201
      this.tokenUrl = properties.orcidTokenURL
202
        + "client_id="+properties.orcidClientId
203
        // + "&response_type=code&scope=/activities/update"
204
        // + "&response_type=code&scope=/authenticate /activities/update /person/update /read-limited"
205
        + "&response_type=code&scope=/activities/update /read-limited"
206
        + "&redirect_uri="+location.origin+"/orcid?source=openaire";
207
    }
208
  }
209

    
210
  public ngOnInit() {
211
    this.properties = properties;
212
    this.depositLearnHowPage = this.properties.depositLearnHowPage;
213
    this.baseUrl = this.properties.depositSearchPage;
214
    this.pagingLimit = this.properties.pagingLimit;
215
    // this.breadcrumbs.push({name: 'home', route: '/'}, {
216
    //   name: "Deposit",
217
    //   route: this.depositLearnHowPage
218
    // }, {name: "Browse repositories", route: null});
219

    
220
    // this.subscriptions.push(this.route.queryParams.subscribe(
221
    //   params => {
222
        // this.searchUtils.page = params['page'] ? params['page']-1 : 1;
223
        // this.searchUtils.size = params['size'] ? params['size'] : 5;
224

    
225
        // let page = (params['page'] === undefined) ? 1 : +params['page'];
226
        // this.searchUtils.page = (page <= 0) ? 1 : page;
227
        // let size = (params['size'] === undefined) ? 5 : +params['size'];
228
        // this.searchUtils.size = (size <= 0) ? 1 : size;
229
        //
230
        // if (params["type"]) {
231
        //   let types = params["type"];
232
        //   types = Array.isArray(types) ? types.join(',').split(","):types.split(",");
233
        //   types.map( function (t) {
234
        //     return StringUtils.unquote(StringUtils.URIDecode(t));
235
        //   } );
236
        //
237
        //   if(types.indexOf("publications")!=-1 && types.indexOf("datasets")!=-1 && types.indexOf("software")!=-1 && types.indexOf("other")!=-1 ){
238
        //     this.typeQuery += "&type=results";
239
        //   }else{
240
        //     for (let type of types) {
241
        //       this.typeQuery += "&type=" + StringUtils.unquote(StringUtils.URIDecode(type));
242
        //     }
243
        //   }
244
        // }else{
245
        //   this.typeQuery += "&type=results";
246
        // }
247

    
248
        // this.typeQuery = "&type=results";
249
        // this.getLocalWorks(this.currentPage, this.resultsPerPage);
250
    // }));
251
    var description = "Openaire, ORCID linking, publication, research data, software, other research product";
252
    this.updateTitle("My ORCID Links");
253
    this.updateDescription(description);
254
    this.updateUrl( properties.domain + properties.baseLink + this.route.url);
255

    
256
    this.typeQuery = "&type=results";
257
    this.getLocalWorks();
258
    this.getPersonalDetails();
259
  }
260

    
261
  public ngOnDestroy() {
262
    for(let sub of this.subscriptions){
263
      sub.unsubscribe();
264
    }
265
  }
266

    
267
  private getPersonalDetails() {
268
    //get author name
269
    this.subscriptions.push(this._orcidService.getPersonalDetails().subscribe(
270
      details => {
271
        let author: string = "";
272

    
273
        if(details && details['name']) {
274
          let name: string = details['name'];
275
          if(name['given-names'] && name['given-names']['value']) {
276
            author = name['given-names']['value'];
277
          }
278
          if(name['family-name'] && name['family-name']['value']) {
279
            author += (author ? " " : "") + name['family-name']['value'];
280
          }
281
          this.authorNameParam = this.routerHelper.createQueryParams(['f0', 'fv0'], ['resultauthor', author]);
282
        }
283
      },
284
      error => {
285
        console.error("Error getting personal details", error);
286
        this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
287
          if (user) {
288
            this.authorNameParam = this.routerHelper.createQueryParams(['f0', 'fv0'], ['resultauthor', user.fullname]);
289
          }
290
        }));
291
      }
292
    ));
293
  }
294

    
295
  openGrantWindow() {
296
    this.window = window.open(this.tokenUrl, '_blank',
297
      'location=yes,height=700,width=540,left=500,top=100,scrollbars=yes,status=yes');
298

    
299
    let self = this;
300
    window.onmessage = function (ev) {
301
      if (ev.isTrusted && ev.origin !== location.origin && ev.data !== 'success')
302
        return;
303
      self.requestGrant = false;
304
      UIkit.notification({
305
        message: 'Thank you for <strong>connecting your ORCID iD</strong> with OpenAIRE!',
306
        status: 'success',
307
        timeout: 6000,
308
        pos: 'bottom-right'
309
      });
310
      self.getLocalWorks();
311
    };
312
  }
313

    
314
  getLocalWorks() {
315
    this.showErrorMessage = false;
316

    
317
    this.showLoading = true;
318
    this.subscriptions.push(this._orcidService.getLocalWorks().subscribe(
319
      (response: any[]) => {
320

    
321
        this.works = response;//['results'];
322
        this.totalOrcidResults = this.works.length;//response['total'];
323

    
324
        this.prepareOrcidQuery();
325
      },
326
      error => {
327
        this.handleError(error, "Could not get locally stored user's ORCID works");
328
        this.showLoading = false;
329
      }
330
    ));
331
  }
332

    
333
  public prepareOrcidQuery() {
334

    
335
    if(this.results.length >= this.currentPage) {
336
      this.currentResults = this.results[this.currentPage-1];
337
      return;
338
    }
339

    
340
    this.showLoading = true;
341

    
342
    this.orcidQuery = "";
343

    
344
    let from: number = (this.currentPage-1)*this.resultsPerPage;
345
    if(from >= this.works.length) {
346
      this.searchUtils.status = this.errorCodes.OUT_OF_BOUND;
347
    }
348
    let to: number = this.currentPage*this.resultsPerPage;
349

    
350
    if(to > this.works.length) {
351
      to = this.works.length;
352
    }
353

    
354
    let works = this.works.slice(from, to);
355

    
356
    for(let work of works) {
357
      for(let pid of work['pids']) {
358
        let identifier: Identifier = Identifier.getIdentifierFromString(pid);
359
        this.orcidQuery += (this.orcidQuery ? " or " : "") + ('(pidclassid exact "'+identifier.class+'" and pid="'+StringUtils.URIEncode(identifier.id)+'")');
360
        //this.orcidQuery = '(pidclassid exact "doi" and pid="10.1007/978-3-030-55814-7_16")';
361
        // console.debug(this.orcidQuery);
362
      }
363
    }
364
    this.showLoading = false;
365
    this._getResults(works);
366
  }
367

    
368
  public _getResults(works: any) {
369
    this.searchUtils.status = this.errorCodes.LOADING;
370
    this.disableForms = true;
371
    this.currentResults = [];
372
    this.searchUtils.totalResults = 0;
373

    
374
    // let params: string = this.orcidQuery + this.typeQuery;
375
    //this.subs.push(this._searchResearchResultsService.advancedSearchResults(this.resultType, parameters, page, size, sortBy, this.properties, (refine) ? this.searchPage.getRefineFieldsQuery() : null, this.searchPage.getFields(), refineFieldsFilterQuery)
376
    this.subscriptions.push(this._searchResearchResultsService.searchForMyOrcidLinks(this.resultType, this.orcidQuery, this.typeQuery, 1, 50)
377
    //this.subs.push(this._searchResearchResultsService.advancedSearchResults(this.resultType, parameters, page, size, sortBy, this.properties, null, this.searchPage.getFields(), refineFieldsFilterQuery)
378
      .subscribe(
379
        data => {
380
          // this is for testing purposes only!
381
          // let newRes = JSON.parse(JSON.stringify(data[1][0]));
382
          // newRes.identifiers = new Map();
383
          // newRes.identifiers.set("doi", [data[1][0].identifiers.get("doi")[1]]);
384
          // data[1].push(newRes);
385
          // console.log(data[1][data[0]]);
386
          //
387
          // data[1][0].identifiers.set("doi", [data[1][0].identifiers.get("doi")[0]]);
388
          // console.log(data[1][0]);
389
          //
390
          // data[0] += 1;
391

    
392
          let totalResults = data[0];
393
          let results = data[1];
394

    
395
          this.resultsReturned(results, totalResults, works);
396
        },
397
        err => {
398
          // this.handleError("Error getting " + this.getEntityName(this.resultType, true, true), err);
399
          console.error("Error getting " + this.getEntityName(this.resultType, true, true));
400
          this.showLoading = false;
401
          this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
402
          this.disableForms = false;
403
        }
404
      )
405
    );
406
  }
407

    
408
  public resultsReturned(results: any, totalResults, works: any[]) {
409
    this.searchUtils.totalResults = totalResults;
410

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

    
413
    for(let work of works) {
414
      results.forEach(result => {
415
        let identifierValues: string[] = [].concat(...Array.from(result.identifiers.values()));
416
        if(work['pids'].some(pid => identifierValues.includes(pid))) {
417

    
418
          let index: number = resultsFound.get(identifierValues);
419
          if(!index) {
420
            this.currentResults.push(this.getResultPreview(result));
421
            index = this.currentResults.length - 1;
422

    
423
            this.currentResults[index].orcidPutCodes = [];
424
            this.currentResults[index].orcidCreationDates = [];
425
            this.currentResults[index].orcidUpdateDates = [];
426
          }
427

    
428
          if (work['putCode']) {
429
            this.currentResults[index].orcidPutCodes.push(work['putCode']);
430
          }
431
          if (work['creationDate']) {
432
            this.currentResults[index].orcidCreationDates.push(work['creationDate']);
433
          }
434
          if (work['updateDate']) {
435
            this.currentResults[index].orcidUpdateDates.push(work['updateDate']);
436
          }
437
        }
438
      })
439
    }
440

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

    
499

    
500
    this.results[this.currentPage-1] = this.currentResults;
501

    
502
    this.searchUtils.status = this.errorCodes.DONE;
503
    if (this.searchUtils.totalResults == 0) {
504
      this.searchUtils.status = this.errorCodes.NONE;
505
    }
506

    
507
    this.disableForms = false;
508
  }
509

    
510
  public resultsReturned2(results: any, totalResults, works: any[]) {
511
    this.searchUtils.totalResults = totalResults;
512

    
513
    for(let result of results) {
514
      let identifierValues: string[] = [].concat(...Array.from(result.identifiers.values()));
515

    
516
      this.currentResults.push(this.getResultPreview(result));
517

    
518
      let filteredWorks = works.filter(work => {
519
        return work['pids'].some(pid => identifierValues.includes(pid));
520
      })
521

    
522
      this.currentResults[this.currentResults.length - 1].orcidPutCodes = [];
523
      this.currentResults[this.currentResults.length - 1].orcidCreationDates = [];
524
      this.currentResults[this.currentResults.length - 1].orcidUpdateDates = [];
525

    
526
      filteredWorks.forEach(work => {
527
        if(work['putCode']) {
528
          this.currentResults[this.currentResults.length - 1].orcidPutCodes.push(work['putCode']);
529
        }
530
        if(work['creationDate']) {
531
          this.currentResults[this.currentResults.length - 1].orcidCreationDates.push(work['creationDate']);
532
        }
533
        if(work['updateDate']) {
534
          this.currentResults[this.currentResults.length - 1].orcidUpdateDates.push(work['updateDate']);
535
        }
536

    
537
        // this.currentResults[this.currentResults.length - 1].orcidPutCodes.push(work['putCode']);
538
        // this.currentResults[this.currentResults.length - 1].orcidCreationDates.push(work['creationDate']);
539
        // this.currentResults[this.currentResults.length - 1].orcidUpdateDates.push(work['creationDate']);
540
      });
541
    }
542

    
543
    this.results[this.currentPage-1] = this.currentResults;
544
    // if(!refine) {
545
      // this.searchPage.buildPageURLParameters(this.filters, this.rangeFilters, false);
546
    // }
547

    
548
    this.searchUtils.status = this.errorCodes.DONE;
549
    if (this.searchUtils.totalResults == 0) {
550
      this.searchUtils.status = this.errorCodes.NONE;
551
    }
552

    
553
    this.disableForms = false;
554
  }
555

    
556
  public getResultPreview(result: SearchResult): ResultPreview {
557
    return ResultPreview.searchResultConvert(result, (result.entityType)?result.entityType:this.resultType);
558
  }
559

    
560
  // private handleError(message: string, error) {
561
  //   if(error && error.status == "401") {
562
  //     this.requestGrant = true;
563
  //     this.requestGrantMessage = "Please grant OpenAIRE to access and update your ORCID record and works. ";
564
  //     // + "If you have already granted OpenAIRE, you just need to login again to ORCID!";
565
  //   } else if(error && error.status == "403") {
566
  //     this.requestGrant = true;
567
  //     this.requestGrantMessage = "Please login again to ORCID."
568
  //   }
569
  //   console.error("My ORCID links Page: "+message, error);
570
  // }
571

    
572
  public getEntityName(entityType: string, plural: boolean, full: boolean): string {
573
    if (entityType == "publication") {
574
      return "publication" + (plural ? "s" : "");
575
    } else if (entityType == "dataset") {
576
      return (full ? "research data" : ("dataset" + (plural ? "s" : "")));
577
    } else if (entityType == "software") {
578
      return "software";
579
    } else if (entityType == "other") {
580
      return (full ? ("other research product" + (plural ? "s" : "")) : "other");
581
    } else if (entityType == "result") {
582
      return (full ? ("research outcome" + (plural ? "s" : "")) : "result");
583
    }
584
  }
585

    
586
  public pageChanged($event) {
587
    this.currentPage = $event.value;
588
    this.prepareOrcidQuery();
589
    // this.getLocalWorks(this.currentPage, this.resultsPerPage);
590
  }
591

    
592
  handleError(error, errorMsg: string) {
593
    if(error && (error.status == "401" || error.status == "403")) {
594
      this.requestGrant = true;
595
    } else {
596
      this.showErrorMessage = true;
597

    
598
      // UIkit.notification({
599
      //   message: errorMsg,
600
      //   status: 'warning',
601
      //   timeout: 6000,
602
      //   pos: 'bottom-right'
603
      // });
604
    }
605
    this.showLoading = false;
606
  }
607

    
608
  private updateTitle(title: string) {
609
    var _prefix = "";
610
    // if(!this.communityId) {
611
    //   _prefix = "OpenAIRE | ";
612
    // }
613
    // var _title = _prefix + ((title.length > 50) ? title.substring(0, 50) : title);
614
    this._title.setTitle(title);
615
    this._meta.updateTag({content: title}, "property='og:title'");
616
  }
617

    
618
  private updateDescription(description: string) {
619
    this._meta.updateTag({content: description}, "name='description'");
620
    this._meta.updateTag({content: description}, "property='og:description'");
621
  }
622

    
623
  private updateUrl(url: string) {
624
    this._meta.updateTag({content: url}, "property='og:url'");
625
  }
626
}
(1-1/5)