From 195cea45c133b20d2a09a8be6b8bedfd660579ff Mon Sep 17 00:00:00 2001 From: gkolokythas Date: Fri, 5 Jul 2019 14:01:24 +0300 Subject: [PATCH] Adds button and service for DMP DOI creation. --- .../src/app/core/model/dmp/dmp-overview.ts | 1 + .../src/app/core/services/dmp/dmp.service.ts | 4 ++ .../dmp/overview/dmp-overview.component.html | 6 +++ .../ui/dmp/overview/dmp-overview.component.ts | 43 +++++++++++++++++-- dmp-frontend/src/assets/i18n/en.json | 11 ++++- 5 files changed, 60 insertions(+), 5 deletions(-) diff --git a/dmp-frontend/src/app/core/model/dmp/dmp-overview.ts b/dmp-frontend/src/app/core/model/dmp/dmp-overview.ts index d7c0efba4..644d85c7b 100644 --- a/dmp-frontend/src/app/core/model/dmp/dmp-overview.ts +++ b/dmp-frontend/src/app/core/model/dmp/dmp-overview.ts @@ -26,4 +26,5 @@ export interface DmpOverviewModel { researchers: ResearcherModel[]; finalizedAt: Date; publishedAt: Date; + doi: string; } diff --git a/dmp-frontend/src/app/core/services/dmp/dmp.service.ts b/dmp-frontend/src/app/core/services/dmp/dmp.service.ts index 80bfb13e6..289a824d8 100644 --- a/dmp-frontend/src/app/core/services/dmp/dmp.service.ts +++ b/dmp-frontend/src/app/core/services/dmp/dmp.service.ts @@ -92,6 +92,10 @@ export class DmpService { return this.http.post(this.actionUrl + 'finalize/' + id, datasetsToBeFinalized, { headers: this.headers }); } + getDoi(id: string): Observable { + return this.http.post(this.actionUrl + 'createZenodoDoi/' + id, {headers: this.headers}); + } + getDynamicField(requestItem: RequestItem): any { return this.http.post(this.actionUrl + 'dynamic', requestItem, { headers: this.headers }); } diff --git a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html index bcc1191aa..72675e34e 100644 --- a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html +++ b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html @@ -4,6 +4,9 @@

{{ dmp.label }}

+ + {{ 'DMP-EDITOR.TITLE.SUBTITLE' | translate }}: {{ dmp.doi }} +
+
diff --git a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts index ede704299..885145819 100644 --- a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts +++ b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts @@ -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() ); } }); diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index 12fadaa27..a235ac4ad 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -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": {