diff --git a/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.ts b/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.ts index 0f79504df..6e2d2d387 100644 --- a/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.ts +++ b/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.ts @@ -49,8 +49,7 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit { hasDOIToken = false; researchers: ResearcherModel[]; users: UserInfoListingModel[]; - lockStatus = false; - // lockStatus: Boolean; + lockStatus: Boolean; constructor( private route: ActivatedRoute, @@ -92,7 +91,7 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit { .subscribe(data => { this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data); }); - // this.checkLockStatus(this.dataset.id); + this.checkLockStatus(this.dataset.id); this.setIsUserOwner(); const breadCrumbs = []; breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.MY-DATASET-DESCRIPTIONS'), url: "/datasets" }); @@ -121,7 +120,7 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit { .subscribe(data => { this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data); }); - // this.checkLockStatus(this.dataset.id); + this.checkLockStatus(this.dataset.id); this.setIsUserOwner(); const breadCrumbs = []; breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.PUBLIC DATASETS'), url: "/explore" }); @@ -158,7 +157,7 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit { this.location.back(); } - reloadComponent(): void { + reloadPage(): void { this.router.navigateByUrl('/datasets', { skipLocationChange: true }).then(() => { this.router.navigate([`/datasets/overview/${this.dataset.id}`]); }); @@ -394,7 +393,7 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit { .subscribe( complete => { this.onCallbackSuccess(); - this.reloadComponent(); + this.reloadPage(); }, error => this.onDeleteCallbackError(error) ); 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 a150df65d..86202ab38 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 @@ -582,10 +582,19 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { this.location.back(); } + reloadPage(): void { + this.router.navigateByUrl('/plans', { skipLocationChange: true }).then(() => { + this.router.navigate([`/plans/overview/${this.dmp.id}`]); + }); + } + updateUsers() { return this.dmpService.updateUsers(this.dmp.id, this.dmp.users).pipe(takeUntil(this._destroyed)) .subscribe( - complete => { this.onCallbackSuccess() }, + complete => { + this.onCallbackSuccess(); + this.reloadPage(); + }, error => this.onDeleteCallbackError(error) ); } diff --git a/dmp-frontend/src/app/ui/dmp/start-new-dmp-dialogue/start-new-dmp-dialog.component.html b/dmp-frontend/src/app/ui/dmp/start-new-dmp-dialogue/start-new-dmp-dialog.component.html index 5b0c101a8..05749a473 100644 --- a/dmp-frontend/src/app/ui/dmp/start-new-dmp-dialogue/start-new-dmp-dialog.component.html +++ b/dmp-frontend/src/app/ui/dmp/start-new-dmp-dialogue/start-new-dmp-dialog.component.html @@ -8,7 +8,7 @@

{{'NAV-BAR.START-NEW-DMP' | translate}}

{{'NAV-BAR.START-NEW-DMP-TXT' | translate}}

- diff --git a/dmp-frontend/src/app/ui/dmp/start-new-dmp-dialogue/start-new-dmp-dialog.component.ts b/dmp-frontend/src/app/ui/dmp/start-new-dmp-dialogue/start-new-dmp-dialog.component.ts index d9a22912e..5ad72e5c3 100644 --- a/dmp-frontend/src/app/ui/dmp/start-new-dmp-dialogue/start-new-dmp-dialog.component.ts +++ b/dmp-frontend/src/app/ui/dmp/start-new-dmp-dialogue/start-new-dmp-dialog.component.ts @@ -1,21 +1,32 @@ import { Component, Inject } from '@angular/core'; -import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; +import { MatDialogRef, MAT_DIALOG_DATA, MatDialog } from '@angular/material/dialog'; import { Router } from '@angular/router'; +import { DmpUploadDialogue } from '../listing/upload-dialogue/dmp-upload-dialogue.component'; +import { UiNotificationService, SnackBarNotificationLevel } from '@app/core/services/notification/ui-notification-service'; +import { TranslateService } from '@ngx-translate/core'; +import { DmpService } from '@app/core/services/dmp/dmp.service'; +import { takeUntil } from 'rxjs/operators'; +import { BaseComponent } from '@common/base/base.component'; @Component({ selector: 'app-start-new-dmp', templateUrl: './start-new-dmp-dialog.component.html', styleUrls: ['./start-new-dmp-dialog.component.scss'] }) -export class StartNewDmpDialogComponent { +export class StartNewDmpDialogComponent extends BaseComponent { public isDialog: boolean = false; constructor( public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: any, - private router: Router + private router: Router, + public dialog: MatDialog, + private uiNotificationService: UiNotificationService, + private language: TranslateService, + private dmpService: DmpService ) { + super(); this.isDialog = data.isDialog; } @@ -36,4 +47,32 @@ export class StartNewDmpDialogComponent { this.close(); } + uploadFile(event) { + const dialogRef = this.dialog.open(DmpUploadDialogue, { + data: { + fileList: FileList, + success: Boolean, + dmpTitle: String + } + }); + dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { + if (result && result.success) { + this.dmpService.uploadXml(result.fileList, result.dmpTitle, result.dmpProfiles) + .pipe(takeUntil(this._destroyed)) + .subscribe((complete) => this.onCallbackImportComplete(), + (error) => this.onCallbackImportFail(error.error)); + } + }); + } + + private onCallbackImportComplete() { + this.uiNotificationService.snackBarNotification(this.language.instant('DMP-UPLOAD.UPLOAD-SUCCESS'), SnackBarNotificationLevel.Success); + this.router.navigate(['/reload']).then(() => this.router.navigate(['/plans'])); + // this.router.navigate(['/reload']).then(() => this.isPublic ? this.router.navigate(['/explore-plans']) : this.router.navigate(['/plans'])); + } + + private onCallbackImportFail(error: any) { + this.uiNotificationService.snackBarNotification(error.message, SnackBarNotificationLevel.Error); + } + }