[CST-5668] Fixed orcid page

This commit is contained in:
Luca Giamminonni
2022-05-06 16:50:22 +02:00
parent bdad05b36f
commit da1fb5506b
5 changed files with 42 additions and 14 deletions

View File

@@ -162,7 +162,7 @@ export class ResearcherProfileService {
* @returns the check result * @returns the check result
*/ */
isLinkedToOrcid(item: Item): boolean { 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' 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)), switchMap((profile) => this.patch(profile, operations)),
getFinishedRemoteData() getFinishedRemoteData()
); );
@@ -227,7 +227,7 @@ export class ResearcherProfileService {
this.configurationService.findByPropertyName('orcid.scope').pipe(getFirstSucceededRemoteDataPayload())] this.configurationService.findByPropertyName('orcid.scope').pipe(getFirstSucceededRemoteDataPayload())]
).pipe( ).pipe(
map(([authorizeUrl, clientId, scopes]) => { 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=' return authorizeUrl.values[0] + '?client_id=' + clientId.values[0] + '&redirect_uri=' + redirectUri + '&response_type=code&scope='
+ scopes.values.join(' '); + scopes.values.join(' ');
})); }));

View File

@@ -33,7 +33,7 @@ export class OrcidAuthComponent implements OnInit {
private itemService: ItemDataService, private itemService: ItemDataService,
private route: ActivatedRoute, private route: ActivatedRoute,
@Inject(NativeWindowService) private _window: NativeWindowRef, @Inject(NativeWindowService) private _window: NativeWindowRef,
) { ) {
this.itemService.findById(this.route.snapshot.paramMap.get('id'), true, true).pipe(getFirstCompletedRemoteData()).subscribe((data: RemoteData<Item>) => { this.itemService.findById(this.route.snapshot.paramMap.get('id'), true, true).pipe(getFirstCompletedRemoteData()).subscribe((data: RemoteData<Item>) => {
this.item = data.payload; this.item = data.payload;
}); });
@@ -49,10 +49,10 @@ export class OrcidAuthComponent implements OnInit {
} }
getOrcidAuthorizations(): string[] { 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); return this.researcherProfileService.isLinkedToOrcid(this.item);
} }

View File

@@ -1,2 +1,2 @@
<ds-orcid-auth></ds-orcid-auth> <ds-orcid-auth></ds-orcid-auth>
<ds-orcid-setting></ds-orcid-setting> <ds-orcid-setting *ngIf="isLinkedToOrcid()"></ds-orcid-setting>

View File

@@ -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({ @Component({
selector: 'ds-orcid-page', selector: 'ds-orcid-page',
@@ -6,4 +16,22 @@ import { Component } from '@angular/core';
styleUrls: ['./orcid-page.component.scss'] styleUrls: ['./orcid-page.component.scss']
}) })
export class OrcidPageComponent { 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<Item>) => {
this.item = data.payload;
});
}
isLinkedToOrcid(): boolean {
return this.researcherProfileService.isLinkedToOrcid(this.item);
}
} }

View File

@@ -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) => { .map((value) => {
return { return {
label: this.messagePrefix + '.sync-profile.' + value.toLowerCase(), 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.currentSyncMode = this.getCurrentPreference('dspace.orcid.sync-mode', ['BATCH, MANUAL'], 'MANUAL');
this.currentSyncPublications = this.getCurrentPreference('cris.orcid.sync-publications', ['DISABLED', 'ALL'], 'DISABLED'); this.currentSyncPublications = this.getCurrentPreference('dspace.orcid.sync-publications', ['DISABLED', 'ALL'], 'DISABLED');
this.currentSyncFundings = this.getCurrentPreference('cris.orcid.sync-fundings', ['DISABLED', 'ALL'], 'DISABLED'); this.currentSyncFundings = this.getCurrentPreference('dspace.orcid.sync-fundings', ['DISABLED', 'ALL'], 'DISABLED');
} }
onSubmit(form: FormGroup) { onSubmit(form: FormGroup) {
@@ -110,7 +110,7 @@ export class OrcidSettingComponent implements OnInit {
return; 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)), switchMap((profile) => this.researcherProfileService.patch(profile, operations)),
getFinishedRemoteData() getFinishedRemoteData()
).subscribe((remoteData) => { ).subscribe((remoteData) => {