Adds button and service for DMP DOI creation.

This commit is contained in:
gkolokythas 2019-07-05 14:01:24 +03:00
parent 41319ee320
commit 195cea45c1
5 changed files with 60 additions and 5 deletions

View File

@ -26,4 +26,5 @@ export interface DmpOverviewModel {
researchers: ResearcherModel[];
finalizedAt: Date;
publishedAt: Date;
doi: string;
}

View File

@ -92,6 +92,10 @@ export class DmpService {
return this.http.post<DmpModel>(this.actionUrl + 'finalize/' + id, datasetsToBeFinalized, { headers: this.headers });
}
getDoi(id: string): Observable<string> {
return this.http.post<string>(this.actionUrl + 'createZenodoDoi/' + id, {headers: this.headers});
}
getDynamicField(requestItem: RequestItem<DynamicFieldProjectCriteria>): any {
return this.http.post<any>(this.actionUrl + 'dynamic', requestItem, { headers: this.headers });
}

View File

@ -4,6 +4,9 @@
<div class="card-header card-header-plain d-flex">
<div class="card-desc d-flex flex-column justify-content-center">
<h4 class="card-title">{{ dmp.label }}</h4>
<mat-card-subtitle *ngIf="!hasDoi(dmp)">
{{ 'DMP-EDITOR.TITLE.SUBTITLE' | translate }}: {{ dmp.doi }}
</mat-card-subtitle>
</div>
<div class="d-flex ml-auto p-2">
<button *ngIf="isDraftDmp(dmp)" mat-icon-button [matMenuTriggerFor]="actionsMenu" class="ml-auto more-icon"
@ -42,6 +45,9 @@
<button *ngIf="isDraftDmp(dmp)" mat-raised-button color="primary" (click)="finalize(dmp)" class="lightblue-btn ml-2">
<mat-icon>done_all</mat-icon> {{ 'DMP-LISTING.ACTIONS.FINALIZE' | translate }}
</button>
<button *ngIf="hasDoi(dmp) && isFinalizedDmp(dmp)" mat-raised-button color="primary" (click)="getDoi(dmp)" class="lightblue-btn ml-2">
<mat-icon>archive</mat-icon> {{ 'DMP-LISTING.ACTIONS.GETDOI' | translate }}
</button>
</div>
</div>
<div class="row ml-2">

View File

@ -126,8 +126,8 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
this.dmpService.delete(this.dmp.id)
.pipe(takeUntil(this._destroyed))
.subscribe(
complete => { this.onCallbackSuccess() },
error => this.onDeleteCallbackError(error)
complete => { this.onCallbackSuccess() },
error => this.onDeleteCallbackError(error)
);
}
});
@ -279,6 +279,43 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
return dmp.status == DmpStatus.Finalized;
}
hasDoi(dmp: DmpOverviewModel) {
return dmp.doi == null ? true : false;
}
getDoi(dmp: DmpOverviewModel) {
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
maxWidth: '600px',
data: {
message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ZENODO-DOI'),
confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'),
cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'),
}
});
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
console.log(result);
if (result) {
this.dmpService.getDoi(dmp.id)
.pipe(takeUntil(this._destroyed))
.subscribe(
complete => {
this.onDOICallbackSuccess();
this.dmp.doi = complete;
},
error => this.onDeleteCallbackError(error)
);
}
});
}
onDOICallbackSuccess(): void {
this.uiNotificationService.snackBarNotification(this.language.instant('DMP-EDITOR.SNACK-BAR.SUCCESSFUL-DOI'), SnackBarNotificationLevel.Success);
}
onDOICallbackError(error) {
this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('DMP-EDITOR.SNACK-BAR.UNSUCCESSFUL-DOI'), SnackBarNotificationLevel.Error);
}
showPublishButton(dmp: DmpOverviewModel) {
return this.isFinalizedDmp(dmp) && !dmp.isPublic && this.hasPublishButton;
}
@ -317,7 +354,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
this.dmpService.finalize(datasetsToBeFinalized, this.dmp.id)
.pipe(takeUntil(this._destroyed))
.subscribe(
complete => this.onCallbackSuccess()
complete => this.onCallbackSuccess()
);
}
});

View File

@ -37,6 +37,7 @@
"DELETE-USER": "Remove this collaborator?",
"FINALIZE-ITEM": "Finalize this item?",
"ADD-DATASET": "Proceed on adding new Dataset?",
"ZENODO-DOI": "Would you like to create digital object identifier (DOI) for the DMP?",
"ACTIONS": {
"CONFIRM": "Yes",
"No": "No",
@ -282,7 +283,8 @@
"DOWNLOAD-XML": "Download XML",
"DOWNLOAD-DOCX": "Download Document",
"DOWNLOAD-PDF": "Download PDF",
"SETTINGS": "Settings"
"SETTINGS": "Settings",
"GETDOI": "Get DOI"
}
},
"DMP-PUBLIC-LISTING": {
@ -478,7 +480,8 @@
"DMP-EDITOR": {
"TITLE": {
"NEW": "New Data Management Plan",
"EDIT": "Edit"
"EDIT": "Edit",
"SUBTITLE": "DOI"
},
"FIELDS": {
"NAME": "Title",
@ -503,6 +506,10 @@
"CANCEL": "Cancel",
"DELETE": "Delete",
"FINALISE": "Finalize"
},
"SNACK-BAR": {
"UNSUCCESSFUL-DOI": "Unsuccessful DOI creation",
"SUCCESSFUL-DOI": "Successful DOI creation"
}
},
"DMP-PROFILE-LISTING": {