From da1fb5506b4edec2fac0c04eff624ada4e86de0f Mon Sep 17 00:00:00 2001 From: Luca Giamminonni Date: Fri, 6 May 2022 16:50:22 +0200 Subject: [PATCH] [CST-5668] Fixed orcid page --- .../profile/researcher-profile.service.ts | 6 ++-- .../orcid-auth/orcid-auth.component.ts | 6 ++-- .../orcid-page/orcid-page.component.html | 2 +- .../orcid-page/orcid-page.component.ts | 30 ++++++++++++++++++- .../orcid-sync/orcid-setting.component.ts | 12 ++++---- 5 files changed, 42 insertions(+), 14 deletions(-) diff --git a/src/app/core/profile/researcher-profile.service.ts b/src/app/core/profile/researcher-profile.service.ts index 100fa459a1..b7035a921f 100644 --- a/src/app/core/profile/researcher-profile.service.ts +++ b/src/app/core/profile/researcher-profile.service.ts @@ -162,7 +162,7 @@ export class ResearcherProfileService { * @returns the check result */ isLinkedToOrcid(item: Item): boolean { - return item.hasMetadata('cris.orcid.authenticated'); + return item.hasMetadata('dspace.orcid.authenticated'); } /** @@ -214,7 +214,7 @@ export class ResearcherProfileService { op:'remove' }]; - return this.findById(item.firstMetadata('cris.owner').authority).pipe( + return this.findById(item.firstMetadata('dspace.object.owner').authority).pipe( switchMap((profile) => this.patch(profile, operations)), getFinishedRemoteData() ); @@ -227,7 +227,7 @@ export class ResearcherProfileService { this.configurationService.findByPropertyName('orcid.scope').pipe(getFirstSucceededRemoteDataPayload())] ).pipe( map(([authorizeUrl, clientId, scopes]) => { - const redirectUri = environment.rest.baseUrl + '/api/cris/orcid/' + profile.id + '/?url=' + encodeURIComponent(this.router.url); + const redirectUri = environment.rest.baseUrl + '/api/eperson/orcid/' + profile.id + '/?url=' + encodeURIComponent(this.router.url); return authorizeUrl.values[0] + '?client_id=' + clientId.values[0] + '&redirect_uri=' + redirectUri + '&response_type=code&scope=' + scopes.values.join(' '); })); diff --git a/src/app/item-page/orcid-page/orcid-auth/orcid-auth.component.ts b/src/app/item-page/orcid-page/orcid-auth/orcid-auth.component.ts index 9651215dc6..8594cba9f5 100644 --- a/src/app/item-page/orcid-page/orcid-auth/orcid-auth.component.ts +++ b/src/app/item-page/orcid-page/orcid-auth/orcid-auth.component.ts @@ -33,7 +33,7 @@ export class OrcidAuthComponent implements OnInit { private itemService: ItemDataService, private route: ActivatedRoute, @Inject(NativeWindowService) private _window: NativeWindowRef, - ) { + ) { this.itemService.findById(this.route.snapshot.paramMap.get('id'), true, true).pipe(getFirstCompletedRemoteData()).subscribe((data: RemoteData) => { this.item = data.payload; }); @@ -49,10 +49,10 @@ export class OrcidAuthComponent implements OnInit { } getOrcidAuthorizations(): string[] { - return this.item.allMetadataValues('cris.orcid.scope'); + return this.item.allMetadataValues('dspace.orcid.scope'); } - isLinkedToOrcid(): boolean { + isLinkedToOrcid(): boolean { return this.researcherProfileService.isLinkedToOrcid(this.item); } diff --git a/src/app/item-page/orcid-page/orcid-page.component.html b/src/app/item-page/orcid-page/orcid-page.component.html index 4e62a8d51c..e0cbfe95e2 100644 --- a/src/app/item-page/orcid-page/orcid-page.component.html +++ b/src/app/item-page/orcid-page/orcid-page.component.html @@ -1,2 +1,2 @@ - + diff --git a/src/app/item-page/orcid-page/orcid-page.component.ts b/src/app/item-page/orcid-page/orcid-page.component.ts index 32b47e069f..eed5ebc276 100644 --- a/src/app/item-page/orcid-page/orcid-page.component.ts +++ b/src/app/item-page/orcid-page/orcid-page.component.ts @@ -1,4 +1,14 @@ -import { Component } from '@angular/core'; +import {Component, Inject} from '@angular/core'; +import {ConfigurationDataService} from '../../core/data/configuration-data.service'; +import {ResearcherProfileService} from '../../core/profile/researcher-profile.service'; +import {TranslateService} from '@ngx-translate/core'; +import {NotificationsService} from '../../shared/notifications/notifications.service'; +import {ItemDataService} from '../../core/data/item-data.service'; +import {ActivatedRoute} from '@angular/router'; +import {NativeWindowRef, NativeWindowService} from '../../core/services/window.service'; +import {getFirstCompletedRemoteData} from '../../core/shared/operators'; +import {RemoteData} from '../../core/data/remote-data'; +import {Item} from '../../core/shared/item.model'; @Component({ selector: 'ds-orcid-page', @@ -6,4 +16,22 @@ import { Component } from '@angular/core'; styleUrls: ['./orcid-page.component.scss'] }) export class OrcidPageComponent { + + item: Item; + + constructor( + private itemService: ItemDataService, + private researcherProfileService: ResearcherProfileService, + private route: ActivatedRoute, + @Inject(NativeWindowService) private _window: NativeWindowRef, + ) { + this.itemService.findById(this.route.snapshot.paramMap.get('id'), true, true).pipe(getFirstCompletedRemoteData()).subscribe((data: RemoteData) => { + this.item = data.payload; + }); + } + + isLinkedToOrcid(): boolean { + return this.researcherProfileService.isLinkedToOrcid(this.item); + } + } diff --git a/src/app/item-page/orcid-page/orcid-sync/orcid-setting.component.ts b/src/app/item-page/orcid-page/orcid-sync/orcid-setting.component.ts index 87385f0780..45ec48e788 100644 --- a/src/app/item-page/orcid-page/orcid-sync/orcid-setting.component.ts +++ b/src/app/item-page/orcid-page/orcid-sync/orcid-setting.component.ts @@ -77,9 +77,9 @@ export class OrcidSettingComponent implements OnInit { }; }); - const syncProfilePreferences = this.item.allMetadataValues('cris.orcid.sync-profile'); + const syncProfilePreferences = this.item.allMetadataValues('dspace.orcid.sync-profile'); - this.syncProfileOptions = ['AFFILIATION', 'EDUCATION', 'BIOGRAPHICAL', 'IDENTIFIERS'] + this.syncProfileOptions = ['BIOGRAPHICAL', 'IDENTIFIERS'] .map((value) => { return { label: this.messagePrefix + '.sync-profile.' + value.toLowerCase(), @@ -88,9 +88,9 @@ export class OrcidSettingComponent implements OnInit { }; }); - this.currentSyncMode = this.getCurrentPreference('cris.orcid.sync-mode', ['BATCH, MANUAL'], 'MANUAL'); - this.currentSyncPublications = this.getCurrentPreference('cris.orcid.sync-publications', ['DISABLED', 'ALL'], 'DISABLED'); - this.currentSyncFundings = this.getCurrentPreference('cris.orcid.sync-fundings', ['DISABLED', 'ALL'], 'DISABLED'); + this.currentSyncMode = this.getCurrentPreference('dspace.orcid.sync-mode', ['BATCH, MANUAL'], 'MANUAL'); + this.currentSyncPublications = this.getCurrentPreference('dspace.orcid.sync-publications', ['DISABLED', 'ALL'], 'DISABLED'); + this.currentSyncFundings = this.getCurrentPreference('dspace.orcid.sync-fundings', ['DISABLED', 'ALL'], 'DISABLED'); } onSubmit(form: FormGroup) { @@ -110,7 +110,7 @@ export class OrcidSettingComponent implements OnInit { return; } - this.researcherProfileService.findById(this.item.firstMetadata('cris.owner').authority).pipe( + this.researcherProfileService.findById(this.item.firstMetadata('dspace.object.owner').authority).pipe( switchMap((profile) => this.researcherProfileService.patch(profile, operations)), getFinishedRemoteData() ).subscribe((remoteData) => {