-
+
\ No newline at end of file
diff --git a/dmp-frontend/src/app/ui/dmp/editor/dmp-deposit-dialog/dmp-deposit-dialog.component.ts b/dmp-frontend/src/app/ui/dmp/editor/dmp-deposit-dialog/dmp-deposit-dialog.component.ts
index 04247b533..2fb0eac2d 100644
--- a/dmp-frontend/src/app/ui/dmp/editor/dmp-deposit-dialog/dmp-deposit-dialog.component.ts
+++ b/dmp-frontend/src/app/ui/dmp/editor/dmp-deposit-dialog/dmp-deposit-dialog.component.ts
@@ -1,6 +1,17 @@
import { Component, Inject, OnInit } from '@angular/core';
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
+import { DepositConfigurationStatus } from '@app/core/common/enum/deposit-configuration-status';
+import { DepositConfigurationModel } from '@app/core/model/deposit/deposit-configuration';
+import { DmpOverviewModel } from '@app/core/model/dmp/dmp-overview';
+import { DepositRepositoriesService } from '@app/core/services/deposit-repositories/deposit-repositories.service';
+import { DmpService } from '@app/core/services/dmp/dmp.service';
+import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service';
+import { Oauth2DialogService } from '@app/ui/misc/oauth2-dialog/service/oauth2-dialog.service';
import { BaseComponent } from '@common/base/base.component';
+import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component';
+import { MultipleChoiceDialogComponent } from '@common/modules/multiple-choice-dialog/multiple-choice-dialog.component';
+import { TranslateService } from '@ngx-translate/core';
+import { takeUntil } from 'rxjs/operators';
@Component({
selector: 'app-dmp-deposit-dialog',
@@ -9,15 +20,23 @@ import { BaseComponent } from '@common/base/base.component';
})
export class DmpDepositDialogComponent extends BaseComponent implements OnInit {
- inputRepos: string[];
+ inputRepos: DepositConfigurationModel[];
outputRepos: string[];
+ dmp: DmpOverviewModel;
constructor(
+ private dmpService: DmpService,
+ private depositRepositoriesService: DepositRepositoriesService,
public dialogRef: MatDialogRef
,
+ private dialog: MatDialog,
+ private language: TranslateService,
+ private uiNotificationService: UiNotificationService,
+ private oauth2DialogService: Oauth2DialogService,
@Inject(MAT_DIALOG_DATA) public data: any
) {
super();
- this.inputRepos = data['depositRepos'];
+ this.inputRepos = data['depositRepos'][0];
+ this.dmp = data['depositRepos'][1];
this.outputRepos = [];
}
@@ -32,4 +51,75 @@ export class DmpDepositDialogComponent extends BaseComponent implements OnInit {
this.dialogRef.close(this.outputRepos);
}
+ deposit(repo: DepositConfigurationModel) {
+
+ if(repo.depositAccountStatus == DepositConfigurationStatus.BothSystemAndUser){
+
+ const dialogRef = this.dialog.open(MultipleChoiceDialogComponent, {
+ maxWidth: '600px',
+ restoreFocus: false,
+ data: {
+ message: 'Which account would you like to use?',//this.language.instant('GENERAL.ERRORS.HTTP-REQUEST-ERROR'),
+ titles: ['Login with ' + repo.repositoryId/*this.language.instant('DMP-OVERVIEW.MULTIPLE-DIALOG.ZENODO-LOGIN')*/, this.language.instant('DMP-OVERVIEW.MULTIPLE-DIALOG.USE-DEFAULT')]
+ }
+ });
+ dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
+ switch (result) {
+ case 0:
+ this.showOauth2Dialog('https://sandbox.zenodo.org/oauth/authorize'+ '?client_id=' + repo.repositoryLoginClientId
+ + '&response_type=code&scope=deposit:write+deposit:actions+user:email&state=astate&redirect_uri='
+ + 'http://localhost:4200/login/external/zenodo', repo, this.dmp);
+ break;
+ case 1:
+ // this.dmpService.getDoi(dmp.id)
+ // .pipe(takeUntil(this._destroyed))
+ // .subscribe(
+ // complete => {
+ // this.onDOICallbackSuccess();
+ // this.dmp.doi = complete;
+ // },
+ // error => this.onDeleteCallbackError(error)
+ // );
+ break;
+ }
+ });
+
+ }
+ }
+
+ onDOICallbackSuccess(): void {
+ this.uiNotificationService.snackBarNotification(this.language.instant('DMP-EDITOR.SNACK-BAR.SUCCESSFUL-DOI'), SnackBarNotificationLevel.Success);
+ }
+
+ onDeleteCallbackError(error) {
+ this.uiNotificationService.snackBarNotification(error.error.message ? this.language.instant(error.error.message) : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DELETE'), SnackBarNotificationLevel.Error);
+ }
+
+ showOauth2Dialog(url: string, repo: DepositConfigurationModel, dmp: DmpOverviewModel) {
+ this.oauth2DialogService.login(url)
+ .pipe(takeUntil(this._destroyed))
+ .subscribe(result => {
+ if (result !== undefined) {
+ if (result.oauthCode !== undefined && result.oauthCode !== null) {
+ this.depositRepositoriesService.getAccessToken(repo.repositoryId, result.oauthCode)
+ .pipe(takeUntil(this._destroyed))
+ .subscribe(token => {
+ console.log(token);
+ this.depositRepositoriesService.createDoi(repo.repositoryId, dmp.id, token)
+ .pipe(takeUntil(this._destroyed))
+ .subscribe(doi =>{
+ console.log(doi);
+ });
+ });
+ // this.userService.registerDOIToken(result.oauthCode, this.configurationService.app + 'oauth2')
+ // .pipe(takeUntil(this._destroyed))
+ // .subscribe(() => {
+ // this.hasDOIToken = true;
+ // this.showConfirmationDOIDialog(dmp);
+ // });
+ }
+ }
+ });
+ }
+
}
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 63c3a8231..bf561abbc 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
@@ -43,6 +43,7 @@ import { MatomoService } from '@app/core/services/matomo/matomo-service';
import { PopupNotificationDialogComponent } from '@app/library/notification/popup/popup-notification.component';
import { DepositRepositoriesService } from '@app/core/services/deposit-repositories/deposit-repositories.service';
import { DmpDepositDialogComponent } from '../editor/dmp-deposit-dialog/dmp-deposit-dialog.component';
+import { DepositConfigurationModel } from '@app/core/model/deposit/deposit-configuration';
@Component({
selector: 'app-dmp-overview',
@@ -70,7 +71,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
@ViewChild('doi')
doi: ElementRef;
- depositRepos: String[];
+ depositRepos: DepositConfigurationModel[];
formGroup: FormGroup;
@@ -589,18 +590,24 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
.subscribe(
repos => {
this.depositRepos = repos;
+ const dialogRef = this.dialog.open(DmpDepositDialogComponent, {
+ maxWidth: '600px',
+ restoreFocus: false,
+ autoFocus: false,
+ data: {
+ depositRepos: [this.depositRepos, this.dmp],
+ message: "Select repositories to deposit",//this.language.instant('GENERAL.CONFIRMATION-DIALOG.FINALIZE-ITEM'),
+ confirmButton: "Proceed to authentication",//this.language.instant('DMP-FINALISE-DIALOG.SUBMIT'),
+ cancelButton: "Cancel",//this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'),
+ }
+ });
+ dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe((result: string[]) => {
+ if (result) {
+ this.dmp.doi = result[0];
+ }
+ });
}
);
- const dialogRef = this.dialog.open(DmpDepositDialogComponent, {
- restoreFocus: false,
- autoFocus: false,
- data: {
- depositRepos: this.depositRepos,
- message: "Select repositories to deposit",//this.language.instant('GENERAL.CONFIRMATION-DIALOG.FINALIZE-ITEM'),
- confirmButton: "Proceed to authentication",//this.language.instant('DMP-FINALISE-DIALOG.SUBMIT'),
- cancelButton: "Cancel",//this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'),
- }
- });
}
finalize(dmp: DmpOverviewModel) {