mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Merge branch 'CST-5668' into CST-5339
This commit is contained in:
@@ -28,7 +28,6 @@ export enum FeatureID {
|
|||||||
CanCreateVersion = 'canCreateVersion',
|
CanCreateVersion = 'canCreateVersion',
|
||||||
CanViewUsageStatistics = 'canViewUsageStatistics',
|
CanViewUsageStatistics = 'canViewUsageStatistics',
|
||||||
CanSendFeedback = 'canSendFeedback',
|
CanSendFeedback = 'canSendFeedback',
|
||||||
ShowClaimItem = 'showClaimItem',
|
|
||||||
CanClaimItem = 'canClaimItem',
|
CanClaimItem = 'canClaimItem',
|
||||||
CanSynchronizeWithORCID = 'canSynchronizeWithORCID'
|
CanSynchronizeWithORCID = 'canSynchronizeWithORCID'
|
||||||
}
|
}
|
||||||
|
@@ -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(' ');
|
||||||
}));
|
}));
|
||||||
|
@@ -40,7 +40,7 @@ export class PersonComponent extends ItemComponent implements OnInit {
|
|||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
super.ngOnInit();
|
super.ngOnInit();
|
||||||
|
|
||||||
this.authorizationService.isAuthorized(FeatureID.ShowClaimItem, this.object._links.self.href).pipe(
|
this.authorizationService.isAuthorized(FeatureID.CanClaimItem, this.object._links.self.href).pipe(
|
||||||
take(1)
|
take(1)
|
||||||
).subscribe((isAuthorized: boolean) => {
|
).subscribe((isAuthorized: boolean) => {
|
||||||
this.claimable$.next(isAuthorized);
|
this.claimable$.next(isAuthorized);
|
||||||
@@ -48,21 +48,10 @@ export class PersonComponent extends ItemComponent implements OnInit {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new researcher profile claiming the current item.
|
||||||
|
*/
|
||||||
claim() {
|
claim() {
|
||||||
|
|
||||||
this.authorizationService.isAuthorized(FeatureID.CanClaimItem, this.object._links.self.href).pipe(
|
|
||||||
take(1)
|
|
||||||
).subscribe((isAuthorized: boolean) => {
|
|
||||||
if (!isAuthorized) {
|
|
||||||
this.notificationsService.warning(this.translate.get('researcherprofile.claim.not-authorized'));
|
|
||||||
} else {
|
|
||||||
this.createFromExternalSource();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
createFromExternalSource() {
|
|
||||||
this.researcherProfileService.createFromExternalSource(this.object._links.self.href).pipe(
|
this.researcherProfileService.createFromExternalSource(this.object._links.self.href).pipe(
|
||||||
getFirstSucceededRemoteData(),
|
getFirstSucceededRemoteData(),
|
||||||
mergeMap((rd: RemoteData<ResearcherProfile>) => {
|
mergeMap((rd: RemoteData<ResearcherProfile>) => {
|
||||||
@@ -81,10 +70,16 @@ export class PersonComponent extends ItemComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the item is claimable, false otherwise.
|
||||||
|
*/
|
||||||
isClaimable(): Observable<boolean> {
|
isClaimable(): Observable<boolean> {
|
||||||
return this.claimable$;
|
return this.claimable$;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the metadata values to be used for the page title.
|
||||||
|
*/
|
||||||
getTitleMetadataValues(): MetadataValue[]{
|
getTitleMetadataValues(): MetadataValue[]{
|
||||||
const metadataValues = [];
|
const metadataValues = [];
|
||||||
const familyName = this.object?.firstMetadata('person.familyName');
|
const familyName = this.object?.firstMetadata('person.familyName');
|
||||||
|
@@ -49,7 +49,7 @@ 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 {
|
||||||
|
@@ -1,3 +1,3 @@
|
|||||||
<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>
|
||||||
<ds-orcid-queue></ds-orcid-queue>
|
<ds-orcid-queue *ngIf="isLinkedToOrcid()"></ds-orcid-queue>
|
||||||
|
@@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -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) => {
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Observable, of } from 'rxjs';
|
import { Observable, of } from 'rxjs';
|
||||||
import { mergeMap, switchMap, take } from 'rxjs/operators';
|
import { mergeMap, take } from 'rxjs/operators';
|
||||||
import { ConfigurationDataService } from '../../core/data/configuration-data.service';
|
import { ConfigurationDataService } from '../../core/data/configuration-data.service';
|
||||||
import { PaginatedList } from '../../core/data/paginated-list.model';
|
import { PaginatedList } from '../../core/data/paginated-list.model';
|
||||||
import { RemoteData } from '../../core/data/remote-data';
|
import { RemoteData } from '../../core/data/remote-data';
|
||||||
@@ -12,6 +12,9 @@ import { PaginatedSearchOptions } from '../../shared/search/models/paginated-sea
|
|||||||
import { SearchResult } from '../../shared/search/models/search-result.model';
|
import { SearchResult } from '../../shared/search/models/search-result.model';
|
||||||
import { getFirstSucceededRemoteData } from './../../core/shared/operators';
|
import { getFirstSucceededRemoteData } from './../../core/shared/operators';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Service that handle profiles claim.
|
||||||
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ProfileClaimService {
|
export class ProfileClaimService {
|
||||||
|
|
||||||
@@ -19,6 +22,11 @@ export class ProfileClaimService {
|
|||||||
private configurationService: ConfigurationDataService) {
|
private configurationService: ConfigurationDataService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if it is possible to suggest profiles to be claimed to the given eperson.
|
||||||
|
*
|
||||||
|
* @param eperson the eperson
|
||||||
|
*/
|
||||||
canClaimProfiles(eperson: EPerson): Observable<boolean> {
|
canClaimProfiles(eperson: EPerson): Observable<boolean> {
|
||||||
|
|
||||||
const query = this.personQueryData(eperson);
|
const query = this.personQueryData(eperson);
|
||||||
@@ -33,6 +41,10 @@ export class ProfileClaimService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns profiles that could be associated with the given user.
|
||||||
|
* @param eperson the user
|
||||||
|
*/
|
||||||
search(eperson: EPerson): Observable<RemoteData<PaginatedList<SearchResult<DSpaceObject>>>> {
|
search(eperson: EPerson): Observable<RemoteData<PaginatedList<SearchResult<DSpaceObject>>>> {
|
||||||
const query = this.personQueryData(eperson);
|
const query = this.personQueryData(eperson);
|
||||||
if (!hasValue(query) || query.length === 0) {
|
if (!hasValue(query) || query.length === 0) {
|
||||||
@@ -41,6 +53,10 @@ export class ProfileClaimService {
|
|||||||
return this.lookup(query);
|
return this.lookup(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search object by the given query.
|
||||||
|
* @param query the query for the search
|
||||||
|
*/
|
||||||
private lookup(query: string): Observable<RemoteData<PaginatedList<SearchResult<DSpaceObject>>>> {
|
private lookup(query: string): Observable<RemoteData<PaginatedList<SearchResult<DSpaceObject>>>> {
|
||||||
if (!hasValue(query)) {
|
if (!hasValue(query)) {
|
||||||
return of(null);
|
return of(null);
|
||||||
@@ -55,16 +71,7 @@ export class ProfileClaimService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private personQueryData(eperson: EPerson): string {
|
private personQueryData(eperson: EPerson): string {
|
||||||
const querySections = [];
|
return 'dc.title:' + eperson.name;
|
||||||
this.queryParam(querySections, 'dc.title', eperson.name);
|
|
||||||
this.queryParam(querySections, 'crisrp.name', eperson.name);
|
|
||||||
return querySections.join(' OR ');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private queryParam(query: string[], metadata: string, value: string) {
|
|
||||||
if (!hasValue(value)) {return;}
|
|
||||||
query.push(metadata + ':' + value);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -152,6 +152,9 @@ export class ProfilePageResearcherFormComponent implements OnInit {
|
|||||||
return this.processingCreate$.asObservable();
|
return this.processingCreate$.asObservable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new profile related to the current user from scratch.
|
||||||
|
*/
|
||||||
createProfileFromScratch() {
|
createProfileFromScratch() {
|
||||||
this.processingCreate$.next(true);
|
this.processingCreate$.next(true);
|
||||||
this.researcherProfileService.create().pipe(
|
this.researcherProfileService.create().pipe(
|
||||||
@@ -167,6 +170,9 @@ export class ProfilePageResearcherFormComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the researcherProfile and researcherProfileItemId attributes using the profile of the current user.
|
||||||
|
*/
|
||||||
private initResearchProfile(): void {
|
private initResearchProfile(): void {
|
||||||
this.researcherProfileService.findById(this.user.id).pipe(
|
this.researcherProfileService.findById(this.user.id).pipe(
|
||||||
take(1),
|
take(1),
|
||||||
|
@@ -172,6 +172,9 @@ export class ProfilePageComponent implements OnInit {
|
|||||||
this.updateProfile();
|
this.updateProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the researcher profile feature is enabled, false otherwise.
|
||||||
|
*/
|
||||||
isResearcherProfileEnabled(){
|
isResearcherProfileEnabled(){
|
||||||
return this.isResearcherProfileEnabled$;
|
return this.isResearcherProfileEnabled$;
|
||||||
}
|
}
|
||||||
|
@@ -14,8 +14,9 @@ import { ViewMode } from '../../../../core/shared/view-mode.model';
|
|||||||
import { ProfileClaimService } from '../../../../profile-page/profile-claim/profile-claim.service';
|
import { ProfileClaimService } from '../../../../profile-page/profile-claim/profile-claim.service';
|
||||||
import { CollectionElementLinkType } from '../../../object-collection/collection-element-link.type';
|
import { CollectionElementLinkType } from '../../../object-collection/collection-element-link.type';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Component
|
||||||
|
*/
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-claim-item-selector',
|
selector: 'ds-claim-item-selector',
|
||||||
templateUrl: './claim-item-selector.component.html'
|
templateUrl: './claim-item-selector.component.html'
|
||||||
|
Reference in New Issue
Block a user