mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
[CST-5668] Retrieve item from route data
This commit is contained in:
@@ -28,26 +28,32 @@
|
|||||||
<div *ngIf="( missingAuthorizations$ | async ).length === 0" class="p-3 mb-2 alert alert-success rounded">
|
<div *ngIf="( missingAuthorizations$ | async ).length === 0" class="p-3 mb-2 alert alert-success rounded">
|
||||||
{{'person.page.orcid.no-missing-authorizations-message' | translate}}
|
{{'person.page.orcid.no-missing-authorizations-message' | translate}}
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="( missingAuthorizations$ | async ).length > 0" class="p-3 mb-2 alert alert-warning rounded" >
|
<div *ngIf="( missingAuthorizations$ | async ).length > 0" class="p-3 mb-2 alert alert-warning rounded">
|
||||||
{{'person.page.orcid.missing-authorizations-message' | translate}}
|
{{'person.page.orcid.missing-authorizations-message' | translate}}
|
||||||
<ul>
|
<ul>
|
||||||
<li *ngFor="let auth of ( ( missingAuthorizations$ | async ) )"> {{getAuthorizationDescription(auth) | translate }} </li>
|
<li
|
||||||
|
*ngFor="let auth of ( ( missingAuthorizations$ | async ) )"> {{getAuthorizationDescription(auth) | translate }} </li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="(onlyAdminCanDisconnectProfileFromOrcid() | async)" class="row mt-3 p-3 mb-2 bg-info text-white rounded d-flex justify-content-center">
|
<div *ngIf="(onlyAdminCanDisconnectProfileFromOrcid() | async)"
|
||||||
|
class="row mt-3 p-3 mb-2 bg-info text-white rounded d-flex justify-content-center">
|
||||||
{{ 'person.page.orcid.remove-orcid-message' | translate}}
|
{{ 'person.page.orcid.remove-orcid-message' | translate}}
|
||||||
</div>
|
</div>
|
||||||
<div class="row" *ngIf="(ownerCanDisconnectProfileFromOrcid() | async)">
|
<div class="row" *ngIf="(ownerCanDisconnectProfileFromOrcid() | async)">
|
||||||
<div class="col-md">
|
<div class="col-md">
|
||||||
<button type="submit" class="btn btn-danger float-right m-2" (click)="unlinkOrcid()" [disabled]=unlinkProcessing>
|
<button type="submit" class="btn btn-danger float-right m-2" (click)="unlinkOrcid()"
|
||||||
<span *ngIf="!unlinkProcessing"><i class="fas fa-unlink"></i> {{ 'person.page.orcid.unlink' | translate }}</span>
|
[disabled]=unlinkProcessing>
|
||||||
<span *ngIf="unlinkProcessing"><i class='fas fa-circle-notch fa-spin'></i> {{'person.page.orcid.unlink.processing' | translate}}</span>
|
<span *ngIf="!unlinkProcessing"><i
|
||||||
|
class="fas fa-unlink"></i> {{ 'person.page.orcid.unlink' | translate }}</span>
|
||||||
|
<span *ngIf="unlinkProcessing"><i
|
||||||
|
class='fas fa-circle-notch fa-spin'></i> {{'person.page.orcid.unlink.processing' | translate}}</span>
|
||||||
</button>
|
</button>
|
||||||
<button *ngIf="( missingAuthorizations$ | async ).length > 0" type="submit" class="btn btn-primary float-right m-2" (click)="linkOrcid()">
|
<button *ngIf="( missingAuthorizations$ | async ).length > 0" type="submit"
|
||||||
|
class="btn btn-primary float-right m-2" (click)="linkOrcid()">
|
||||||
<span><i class="fas fa-check"></i> {{ 'person.page.orcid.grant-authorizations' | translate }}</span>
|
<span><i class="fas fa-check"></i> {{ 'person.page.orcid.grant-authorizations' | translate }}</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -60,7 +66,7 @@
|
|||||||
<div class="alert alert-info col">{{ getOrcidNotLinkedMessage() | async }}</div>
|
<div class="alert alert-info col">{{ getOrcidNotLinkedMessage() | async }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md">
|
<div class="col p-0">
|
||||||
<button class="btn btn-primary float-right" (click)="linkOrcid()">
|
<button class="btn btn-primary float-right" (click)="linkOrcid()">
|
||||||
<i class="fas fa-link"></i>
|
<i class="fas fa-link"></i>
|
||||||
{{'person.page.orcid.link' | translate}}
|
{{'person.page.orcid.link' | translate}}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { Component, Inject, OnInit } from '@angular/core';
|
import { Component, Inject, Input, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { BehaviorSubject, Observable } from 'rxjs';
|
import { BehaviorSubject, Observable } from 'rxjs';
|
||||||
@@ -19,12 +19,15 @@ import { NotificationsService } from '../../../shared/notifications/notification
|
|||||||
})
|
})
|
||||||
export class OrcidAuthComponent implements OnInit {
|
export class OrcidAuthComponent implements OnInit {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The item for which showing the orcid settings
|
||||||
|
*/
|
||||||
|
@Input() item: Item;
|
||||||
|
|
||||||
missingAuthorizations$ = new BehaviorSubject<string[]>([]);
|
missingAuthorizations$ = new BehaviorSubject<string[]>([]);
|
||||||
|
|
||||||
unlinkProcessing = false;
|
unlinkProcessing = false;
|
||||||
|
|
||||||
item: Item;
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private configurationService: ConfigurationDataService,
|
private configurationService: ConfigurationDataService,
|
||||||
private researcherProfileService: ResearcherProfileService,
|
private researcherProfileService: ResearcherProfileService,
|
||||||
@@ -34,9 +37,6 @@ export class OrcidAuthComponent implements OnInit {
|
|||||||
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.item = data.payload;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
@@ -6,5 +6,5 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ds-orcid-auth></ds-orcid-auth>
|
<ds-orcid-auth *ngIf="item" [item]="item"></ds-orcid-auth>
|
||||||
<ds-orcid-setting *ngIf="isLinkedToOrcid()"></ds-orcid-setting>
|
<ds-orcid-setting *ngIf="item && isLinkedToOrcid()" [item]="item"></ds-orcid-setting>
|
||||||
|
@@ -1,37 +1,64 @@
|
|||||||
import {Component, Inject} from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import {ResearcherProfileService} from '../../core/profile/researcher-profile.service';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
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';
|
|
||||||
import {getItemPageRoute} from '../item-page-routing-paths';
|
|
||||||
|
|
||||||
|
import { map } from 'rxjs/operators';
|
||||||
|
|
||||||
|
import { ResearcherProfileService } from '../../core/profile/researcher-profile.service';
|
||||||
|
import { getFirstSucceededRemoteDataPayload } from '../../core/shared/operators';
|
||||||
|
import { RemoteData } from '../../core/data/remote-data';
|
||||||
|
import { Item } from '../../core/shared/item.model';
|
||||||
|
import { getItemPageRoute } from '../item-page-routing-paths';
|
||||||
|
import { AuthService } from '../../core/auth/auth.service';
|
||||||
|
import { redirectOn4xx } from '../../core/shared/authorized.operators';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A component that represents the orcid settings page
|
||||||
|
*/
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-orcid-page',
|
selector: 'ds-orcid-page',
|
||||||
templateUrl: './orcid-page.component.html',
|
templateUrl: './orcid-page.component.html',
|
||||||
styleUrls: ['./orcid-page.component.scss']
|
styleUrls: ['./orcid-page.component.scss']
|
||||||
})
|
})
|
||||||
export class OrcidPageComponent {
|
export class OrcidPageComponent implements OnInit {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The item for which showing the orcid settings
|
||||||
|
*/
|
||||||
item: Item;
|
item: Item;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private itemService: ItemDataService,
|
private authService: AuthService,
|
||||||
private researcherProfileService: ResearcherProfileService,
|
private researcherProfileService: ResearcherProfileService,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
@Inject(NativeWindowService) private _window: NativeWindowRef,
|
private router: Router
|
||||||
) {
|
) {
|
||||||
this.itemService.findById(this.route.snapshot.paramMap.get('id'), true, true).pipe(getFirstCompletedRemoteData()).subscribe((data: RemoteData<Item>) => {
|
}
|
||||||
this.item = data.payload;
|
|
||||||
|
/**
|
||||||
|
* Retrieve the item for which showing the orcid settings
|
||||||
|
*/
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.route.data.pipe(
|
||||||
|
map((data) => data.dso as RemoteData<Item>),
|
||||||
|
redirectOn4xx(this.router, this.authService),
|
||||||
|
getFirstSucceededRemoteDataPayload()
|
||||||
|
).subscribe((item) => {
|
||||||
|
this.item = item;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the current item is linked to an ORCID profile.
|
||||||
|
*
|
||||||
|
* @returns the check result
|
||||||
|
*/
|
||||||
isLinkedToOrcid(): boolean {
|
isLinkedToOrcid(): boolean {
|
||||||
return this.researcherProfileService.isLinkedToOrcid(this.item);
|
return this.researcherProfileService.isLinkedToOrcid(this.item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the route to an item's page
|
||||||
|
*/
|
||||||
getItemPage(): string {
|
getItemPage(): string {
|
||||||
return getItemPageRoute(this.item);
|
return getItemPageRoute(this.item);
|
||||||
}
|
}
|
||||||
|
@@ -1,16 +1,18 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, Input, OnInit } from '@angular/core';
|
||||||
import { FormGroup } from '@angular/forms';
|
import { FormGroup } from '@angular/forms';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { Operation } from 'fast-json-patch';
|
import { Operation } from 'fast-json-patch';
|
||||||
|
import { of } from 'rxjs';
|
||||||
import { switchMap } from 'rxjs/operators';
|
import { switchMap } from 'rxjs/operators';
|
||||||
|
|
||||||
import { AuthService } from '../../../core/auth/auth.service';
|
import { AuthService } from '../../../core/auth/auth.service';
|
||||||
import { ItemDataService } from '../../../core/data/item-data.service';
|
|
||||||
import { RemoteData } from '../../../core/data/remote-data';
|
import { RemoteData } from '../../../core/data/remote-data';
|
||||||
import { ResearcherProfileService } from '../../../core/profile/researcher-profile.service';
|
import { ResearcherProfileService } from '../../../core/profile/researcher-profile.service';
|
||||||
import { Item } from '../../../core/shared/item.model';
|
import { Item } from '../../../core/shared/item.model';
|
||||||
import { getFinishedRemoteData, getFirstCompletedRemoteData } from '../../../core/shared/operators';
|
import { getFirstCompletedRemoteData } from '../../../core/shared/operators';
|
||||||
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||||
|
import { ResearcherProfile } from '../../../core/profile/model/researcher-profile.model';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-orcid-setting',
|
selector: 'ds-orcid-setting',
|
||||||
@@ -19,6 +21,11 @@ import { NotificationsService } from '../../../shared/notifications/notification
|
|||||||
})
|
})
|
||||||
export class OrcidSettingComponent implements OnInit {
|
export class OrcidSettingComponent implements OnInit {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The item for which showing the orcid settings
|
||||||
|
*/
|
||||||
|
@Input() item: Item;
|
||||||
|
|
||||||
messagePrefix = 'person.page.orcid';
|
messagePrefix = 'person.page.orcid';
|
||||||
|
|
||||||
currentSyncMode: string;
|
currentSyncMode: string;
|
||||||
@@ -35,18 +42,12 @@ export class OrcidSettingComponent implements OnInit {
|
|||||||
|
|
||||||
syncProfileOptions: { value: string, label: string, checked: boolean }[];
|
syncProfileOptions: { value: string, label: string, checked: boolean }[];
|
||||||
|
|
||||||
item: Item;
|
|
||||||
|
|
||||||
constructor(private researcherProfileService: ResearcherProfileService,
|
constructor(private researcherProfileService: ResearcherProfileService,
|
||||||
protected translateService: TranslateService,
|
protected translateService: TranslateService,
|
||||||
private notificationsService: NotificationsService,
|
private notificationsService: NotificationsService,
|
||||||
public authService: AuthService,
|
public authService: AuthService
|
||||||
private route: ActivatedRoute,
|
|
||||||
private itemService: ItemDataService
|
|
||||||
) {
|
) {
|
||||||
this.itemService.findById(this.route.snapshot.paramMap.get('id'), true, true).pipe(getFirstCompletedRemoteData()).subscribe((data: RemoteData<Item>) => {
|
|
||||||
this.item = data.payload;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@@ -110,10 +111,18 @@ export class OrcidSettingComponent implements OnInit {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.researcherProfileService.findById(this.item.firstMetadata('dspace.object.owner').authority).pipe(
|
this.researcherProfileService.findByRelatedItem(this.item).pipe(
|
||||||
switchMap((profile) => this.researcherProfileService.patch(profile, operations)),
|
getFirstCompletedRemoteData(),
|
||||||
getFinishedRemoteData()
|
switchMap((profileRD: RemoteData<ResearcherProfile>) => {
|
||||||
).subscribe((remoteData) => {
|
if (profileRD.hasSucceeded) {
|
||||||
|
return this.researcherProfileService.updateByOrcidOperations(profileRD.payload, operations).pipe(
|
||||||
|
getFirstCompletedRemoteData()
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return of(profileRD);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
).subscribe((remoteData: RemoteData<ResearcherProfile>) => {
|
||||||
if (remoteData.isSuccess) {
|
if (remoteData.isSuccess) {
|
||||||
this.notificationsService.success(this.translateService.get(this.messagePrefix + '.synchronization-settings-update.success'));
|
this.notificationsService.success(this.translateService.get(this.messagePrefix + '.synchronization-settings-update.success'));
|
||||||
} else {
|
} else {
|
||||||
@@ -135,5 +144,4 @@ export class OrcidSettingComponent implements OnInit {
|
|||||||
return (currentPreference && allowedValues.includes(currentPreference)) ? currentPreference : defaultValue;
|
return (currentPreference && allowedValues.includes(currentPreference)) ? currentPreference : defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user