diff --git a/dmp-frontend/src/app/core/services/dataset-profile/dataset-profile.service.ts b/dmp-frontend/src/app/core/services/dataset-profile/dataset-profile.service.ts index a62b3beaa..1c30b086c 100644 --- a/dmp-frontend/src/app/core/services/dataset-profile/dataset-profile.service.ts +++ b/dmp-frontend/src/app/core/services/dataset-profile/dataset-profile.service.ts @@ -65,14 +65,17 @@ export class DatasetProfileService extends BaseService { return this.httpClient.get(this.actionUrl + 'getXml/' + id, { responseType: 'blob', observe: 'response', headers: headerXml }); } - uploadFile(file: FileList, labelSent: string): Observable> { + uploadFile(file: FileList, labelSent: string, datasetProfileId?: string): Observable> { const params = new BaseHttpParams(); params.interceptorContext = { excludedInterceptors: [InterceptorType.JSONContentType] }; const formData = new FormData(); formData.append('file', file[0], labelSent); - return this.http.post(this.actionUrl + "upload", formData, { params: params }); + return (datasetProfileId === undefined || datasetProfileId == null) + ? this.http.post(this.actionUrl + "upload", formData, { params: params }) + : this.http.post(this.actionUrl + "upload/" + datasetProfileId, formData, { params: params }); + } searchSchematics(like: string): Observable { diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.html index ca7500119..c1036626b 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.html +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.html @@ -60,6 +60,9 @@ + diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.ts index 4a9246688..cfb0315f6 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.ts @@ -123,6 +123,35 @@ export class DatasetProfileListingComponent extends BaseComponent implements OnI this.router.navigate(['dataset-profiles/newversion/' + id]); } + newVersionFromFile(id: string, label: string): void { + const dialogRef = this.dialog.open(DialogConfirmationUploadDatasetProfiles, { + width: '500px', + restoreFocus: false, + data: { + message: this.language.instant('DATASET-WIZARD.NEW-VERSION-FROM-FILE.NEW-VERSION-XML-FILE-TITLE', {datasetName: label}), + confirmButton: this.language.instant('DATASET-WIZARD.NEW-VERSION-FROM-FILE.NEW-VERSION-XML'), + cancelButton: this.language.instant('DATASET-WIZARD.NEW-VERSION-FROM-FILE.NEW-VERSION-XML-FILE-CANCEL'), + name: "", + file: FileList, + sucsess: false + } + }); + dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(data => { + if (data && data.sucsess && data.name != null && data.file != null) { + this.datasetService.uploadFile(data.file, data.name, id) + .pipe(takeUntil(this._destroyed)) + .subscribe(_=>{ + this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-WIZARD.NEW-VERSION-FROM-FILE.NEW-VERSION-XML-SUCCESSFUL'), SnackBarNotificationLevel.Success); + this.refresh(); + }, + error=>{ + this.uiNotificationService.snackBarNotification(error.message, SnackBarNotificationLevel.Error); + } + ); + } + }); + } + viewVersions(rowId, rowLabel) { this.router.navigate(['/dataset-profiles/versions/' + rowId], { queryParams: { groupLabel: rowLabel } }); } diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index e4d542f3f..afdd899e3 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -765,6 +765,12 @@ "UPLOAD-XML-IMPORT": "File", "UPLOAD-XML-FILE-CANCEL": "Cancel" }, + "NEW-VERSION-FROM-FILE": { + "NEW-VERSION-XML": "Import", + "NEW-VERSION-XML-FILE-TITLE": "New Version from File for {{datasetName}}", + "NEW-VERSION-XML-FILE-CANCEL": "Cancel", + "NEW-VERSION-XML-SUCCESSFUL": "New Version successfully uploaded" + }, "DIALOGUE": { "TITLE": "Copy Dataset to DMP", "DMP-SEARCH": { @@ -930,6 +936,7 @@ "VIEW": "View", "CLONE": "Clone", "NEW-VERSION": "New Version", + "NEW-VERSION-FROM-FILE": "New Version from File", "VIEW-VERSIONS": "All Dataset Template Versions", "DELETE": "Delete", "CREATE-DATASET-TEMPLATE": "Create Dataset Template"