From 271fde37b6c2970cb8cde52fc2f103941dd4b975 Mon Sep 17 00:00:00 2001 From: amentis Date: Tue, 18 Jun 2024 15:41:39 +0300 Subject: [PATCH] import json rda ui changes --- .../dmp-upload-dialog.component.html | 10 ++++-- .../dmp-upload-dialog.component.ts | 33 ++++++++++++++----- dmp-frontend/src/assets/i18n/en.json | 1 + 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/dmp-frontend/src/app/ui/dmp/new/upload-dialogue/dmp-upload-dialog.component.html b/dmp-frontend/src/app/ui/dmp/new/upload-dialogue/dmp-upload-dialog.component.html index 78ba37074..8b59ee4ad 100644 --- a/dmp-frontend/src/app/ui/dmp/new/upload-dialogue/dmp-upload-dialog.component.html +++ b/dmp-frontend/src/app/ui/dmp/new/upload-dialogue/dmp-upload-dialog.component.html @@ -30,22 +30,26 @@ +
+ {{ 'DMP-UPLOAD.ANALYZING-FILE' | translate }} + +
- + -
+
{{ description.get('label').value }} {{'DMP-UPLOAD.FIELDS.DESCRIPTION-TEMPLATE' | translate}} - + {{description.get('templateId').getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}} diff --git a/dmp-frontend/src/app/ui/dmp/new/upload-dialogue/dmp-upload-dialog.component.ts b/dmp-frontend/src/app/ui/dmp/new/upload-dialogue/dmp-upload-dialog.component.ts index e7b79efe2..65c1bc5c0 100644 --- a/dmp-frontend/src/app/ui/dmp/new/upload-dialogue/dmp-upload-dialog.component.ts +++ b/dmp-frontend/src/app/ui/dmp/new/upload-dialogue/dmp-upload-dialog.component.ts @@ -6,9 +6,7 @@ import { DmpBlueprint, DmpBlueprintDefinitionSection } from '@app/core/model/dmp import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service'; import { DmpService } from '@app/core/services/dmp/dmp.service'; import { AnalyticsService } from '@app/core/services/matomo/analytics-service'; -import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; import { BaseComponent } from '@common/base/base.component'; -import { Observable } from 'rxjs'; import { map, takeUntil } from 'rxjs/operators'; import { DmpImportRdaConfigEditorModel } from './dmp-common-model-config.editor.model'; import { UntypedFormArray, UntypedFormGroup } from '@angular/forms'; @@ -18,6 +16,8 @@ import { DmpCommonModelConfig } from '@app/core/model/dmp/dmp-import'; import { StorageFileService } from '@app/core/services/storage-file/storage-file.service'; import { IsActive } from '@notification-service/core/enum/is-active.enum'; import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration'; +import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; +import { TranslateService } from '@ngx-translate/core'; @Component({ selector: 'dmp-upload-dialog', @@ -54,6 +54,8 @@ export class DmpUploadDialogComponent extends BaseComponent { public dmpBlueprintService: DmpBlueprintService, private dmpService: DmpService, private storageFileStorage: StorageFileService, + private uiNotificationService: UiNotificationService, + private language: TranslateService, @Inject(MAT_DIALOG_DATA) public data: any, ) { @@ -78,20 +80,27 @@ export class DmpUploadDialogComponent extends BaseComponent { this.data.dmpTitle = this.dmpTitle; this.data.dmpBlueprints = this.dmpBlueprints; - if (this.files.length > 0 && this.files[0].type.includes('/json') && this.formGroup && this.formGroup.valid){ - this.data.dmpCommonModelConfig = this.formService.getValue(this.formGroup.value) as DmpCommonModelConfig; - this.data.dmpCommonModelConfig.file = this.files[0]; + if (this.files.length > 0 && this.files[0].type.includes('/json') && this.formGroup){ + this.formService.removeAllBackEndErrors(this.formGroup); + this.formService.touchAllFormFields(this.formGroup); + if (this.formGroup.valid){ + this.data.dmpCommonModelConfig = this.formService.getValue(this.formGroup.value) as DmpCommonModelConfig; + this.data.dmpCommonModelConfig.file = this.files[0]; + } else { + return; + } } this.dialogRef.close(this.data); } disableConfirmButton(){ if (this.data.fileList.length === 0 || this.files.length === 0) return true; - if (this.files.length > 0 && this.files[0].type.includes('/json') && this.formGroup && this.formGroup.invalid) return true; + if (this.files.length > 0 && this.files[0].type.includes('/json') && this.formGroup == null) return true; return false; } uploadFile(event) { + this.formGroup = null; const fileList: FileList = event.target.files this.data.fileList = fileList; if (this.data.fileList.length > 0) { @@ -113,11 +122,13 @@ export class DmpUploadDialogComponent extends BaseComponent { .subscribe( (preprocessingData) => { this.formGroup = new DmpImportRdaConfigEditorModel().fromModel(preprocessingData, storageFile[0].id,).buildForm(); - } + }, + (error) => this.onCallbackEror(error.error) ); } - } + }, + (error) => this.onCallbackEror(error.error) ); } @@ -138,6 +149,7 @@ export class DmpUploadDialogComponent extends BaseComponent { onRemove(event) { this.files.splice(0, 1); this.dmpTitle = null; + this.formGroup = null; } selectedBlueprintChanged(item: DmpBlueprint): void{ @@ -153,4 +165,9 @@ export class DmpUploadDialogComponent extends BaseComponent { hasFile(): boolean { return this.files && this.files.length > 0; } + + private onCallbackEror(error: any) { + this.uiNotificationService.snackBarNotification(this.language.instant(error.error), SnackBarNotificationLevel.Error); + this.close(); + } } diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index c18948868..f7663581f 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -699,6 +699,7 @@ "DMP-UPLOAD": { "TITLE": "Import Plan", "UPLOAD-SUCCESS": "Import was Successful", + "ANALYZING-FILE": "Analyzing file", "FIELDS": { "BLUEPRINT-PLACEHOLDER": "Select Plan Blueprint", "DESCRIPTION-TEMPLATE": "Description Template",