From 15b4c7fbc61013c8680966e2901724705baf5002 Mon Sep 17 00:00:00 2001 From: amentis Date: Thu, 11 Apr 2024 17:30:55 +0300 Subject: [PATCH] description template upload changes, dmp description tag field type fix --- .../java/eu/eudat/audit/AuditableAction.java | 1 + .../FieldBuilder.java | 17 ++-- .../description/DescriptionServiceImpl.java | 38 ++++++--- .../controllers/StorageFileController.java | 46 +++++++---- .../storage-file/storage-file.service.ts | 17 ++-- ...ption-template-editor-field.component.html | 4 +- .../form-field/form-field.component.html | 18 ++--- .../form-field/form-field.component.ts | 79 ++++++++----------- 8 files changed, 121 insertions(+), 99 deletions(-) diff --git a/dmp-backend/core/src/main/java/eu/eudat/audit/AuditableAction.java b/dmp-backend/core/src/main/java/eu/eudat/audit/AuditableAction.java index 49de636cb..d400b79c0 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/audit/AuditableAction.java +++ b/dmp-backend/core/src/main/java/eu/eudat/audit/AuditableAction.java @@ -114,6 +114,7 @@ public class AuditableAction { public static final EventId StorageFile_Download = new EventId(14000, "StorageFile_Download"); public static final EventId StorageFile_Upload = new EventId(14001, "StorageFile_Upload"); + public static final EventId StorageFile_Query = new EventId(14002, "StorageFile_Query"); public static final EventId Dashboard_MyRecentActivityItems = new EventId(15000, "Dashboard_MyRecentActivityItems"); public static final EventId Dashboard_MyDashboardStatistics = new EventId(15001, "Dashboard_MyDashboardStatistics"); diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/descriptionpropertiesdefinition/FieldBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/descriptionpropertiesdefinition/FieldBuilder.java index 50be8a7e7..1b98a3f69 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/descriptionpropertiesdefinition/FieldBuilder.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/descriptionpropertiesdefinition/FieldBuilder.java @@ -3,6 +3,7 @@ package eu.eudat.model.builder.descriptionpropertiesdefinition; import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.commons.enums.FieldType; import eu.eudat.commons.types.description.FieldEntity; +import eu.eudat.commons.types.descriptiontemplate.fielddata.LabelAndMultiplicityDataEntity; import eu.eudat.commons.types.descriptiontemplate.fielddata.SelectDataEntity; import eu.eudat.convention.ConventionService; import eu.eudat.model.Reference; @@ -72,12 +73,16 @@ public class FieldBuilder extends BaseBuilder { if (fields.hasField(this.asIndexer(Field._dateValue)) && FieldType.isDateType(fieldType)) m.setDateValue(d.getDateValue()); if (fields.hasField(this.asIndexer(Field._textValue)) && FieldType.isTextType(fieldType)) m.setTextValue(d.getTextValue()); if (fields.hasField(this.asIndexer(Field._textListValue)) && FieldType.isTextListType(fieldType)) { - boolean isSelectMultiSelect = true; - if(this.fieldEntity != null && this.fieldEntity.getData() != null && this.fieldEntity.getData().getFieldType().equals(FieldType.SELECT) && this.fieldEntity.getData() instanceof SelectDataEntity){ - isSelectMultiSelect = ((SelectDataEntity) this.fieldEntity.getData()).getMultipleSelect(); - } - if (fieldType.equals(FieldType.SELECT) && !isSelectMultiSelect && !this.conventionService.isListNullOrEmpty(d.getTextListValue())){ - m.setTextValue(d.getTextListValue().stream().findFirst().orElse(null)); + boolean isMultiSelect = true; + if(this.fieldEntity != null && this.fieldEntity.getData() != null && (this.fieldEntity.getData().getFieldType().equals(FieldType.SELECT) || this.fieldEntity.getData().getFieldType().equals(FieldType.INTERNAL_ENTRIES_DMPS) || this.fieldEntity.getData().getFieldType().equals(FieldType.INTERNAL_ENTRIES_DESCRIPTIONS))){ + if (this.fieldEntity.getData() instanceof SelectDataEntity) isMultiSelect = ((SelectDataEntity) this.fieldEntity.getData()).getMultipleSelect(); + else if (this.fieldEntity.getData() instanceof LabelAndMultiplicityDataEntity) isMultiSelect = ((LabelAndMultiplicityDataEntity) this.fieldEntity.getData()).getMultipleSelect(); + + if (!isMultiSelect && !this.conventionService.isListNullOrEmpty(d.getTextListValue())){ + m.setTextValue(d.getTextListValue().stream().findFirst().orElse(null)); + }else{ + m.setTextListValue(d.getTextListValue()); + } } else{ m.setTextListValue(d.getTextListValue()); } diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java index 39e4268d2..31d6c6dbf 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java @@ -516,22 +516,38 @@ public class DescriptionServiceImpl implements DescriptionService { } } else if (FieldType.isTextListType(fieldType)) { - if (FieldType.INTERNAL_ENTRIES_DMPS.equals(fieldType) && !this.conventionService.isListNullOrEmpty(persist.getTextListValue())){ - List ids = persist.getTextListValue().stream().map(UUID::fromString).toList(); - Set existingIds = this.queryFactory.query(DmpQuery.class).ids(ids).isActive(IsActive.Active).collectAs(new BaseFieldSet().ensure(Dmp._id)).stream().map(DmpEntity::getId).collect(Collectors.toSet()); - for (UUID id : ids){ - if (!existingIds.contains(id)) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale())); + List ids = new ArrayList<>(); + if (FieldType.INTERNAL_ENTRIES_DMPS.equals(fieldType)) { + if (!this.conventionService.isListNullOrEmpty(persist.getTextListValue())) persist.getTextListValue().stream().map(UUID::fromString).toList(); + else if (!this.conventionService.isNullOrEmpty(persist.getTextValue())) ids.add(UUID.fromString(persist.getTextValue())); + + if (ids.size() > 0){ + Set existingIds = this.queryFactory.query(DmpQuery.class).ids(ids).isActive(IsActive.Active).collectAs(new BaseFieldSet().ensure(Dmp._id)).stream().map(DmpEntity::getId).collect(Collectors.toSet()); + for (UUID id : ids){ + if (!existingIds.contains(id)) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale())); + } } - } if (FieldType.INTERNAL_ENTRIES_DESCRIPTIONS.equals(fieldType) && !this.conventionService.isListNullOrEmpty(persist.getTextListValue())){ - List ids = persist.getTextListValue().stream().map(UUID::fromString).toList(); - Set existingIds = this.queryFactory.query(DescriptionQuery.class).ids(ids).isActive(IsActive.Active).collectAs(new BaseFieldSet().ensure(Description._id)).stream().map(DescriptionEntity::getId).collect(Collectors.toSet()); - for (UUID id : ids){ - if (!existingIds.contains(id)) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Description.class.getSimpleName()}, LocaleContextHolder.getLocale())); + + } if (FieldType.INTERNAL_ENTRIES_DESCRIPTIONS.equals(fieldType)){ + if ( !this.conventionService.isListNullOrEmpty(persist.getTextListValue())) ids = persist.getTextListValue().stream().map(UUID::fromString).toList(); + else if (!this.conventionService.isNullOrEmpty(persist.getTextValue())) ids.add(UUID.fromString(persist.getTextValue())); + + if (ids.size() > 0) { + Set existingIds = this.queryFactory.query(DescriptionQuery.class).ids(ids).isActive(IsActive.Active).collectAs(new BaseFieldSet().ensure(Description._id)).stream().map(DescriptionEntity::getId).collect(Collectors.toSet()); + for (UUID id : ids){ + if (!existingIds.contains(id)) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Description.class.getSimpleName()}, LocaleContextHolder.getLocale())); + } } } + if (!ids.isEmpty()){ + if (ids.size() > 1) data.setTextListValue(persist.getTextListValue()); + else data.setTextListValue(List.of(persist.getTextValue())); + }else{ + data.setTextListValue(persist.getTextListValue()); + } if (fieldType.equals(FieldType.SELECT) && this.conventionService.isListNullOrEmpty(persist.getTextListValue()) && !this.conventionService.isNullOrEmpty(persist.getTextValue())){ data.setTextListValue(List.of(persist.getTextValue())); - } else{ + } else if (fieldType.equals(FieldType.SELECT) || fieldType.equals(FieldType.TAGS)){ data.setTextListValue(persist.getTextListValue()); } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/StorageFileController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/StorageFileController.java index d9e1d0fd9..ad608cee2 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/StorageFileController.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/StorageFileController.java @@ -1,23 +1,27 @@ package eu.eudat.controllers; import eu.eudat.audit.AuditableAction; +import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.Permission; import eu.eudat.commons.enums.StorageType; import eu.eudat.commons.scope.user.UserScope; import eu.eudat.convention.ConventionService; import eu.eudat.data.StorageFileEntity; import eu.eudat.model.StorageFile; +import eu.eudat.model.builder.StorageFileBuilder; import eu.eudat.model.persist.StorageFilePersist; import eu.eudat.query.StorageFileQuery; import eu.eudat.service.storage.StorageFileProperties; import eu.eudat.service.storage.StorageFileService; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.auditing.AuditService; +import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.exception.MyForbiddenException; import gr.cite.tools.exception.MyNotFoundException; import gr.cite.tools.fieldset.BaseFieldSet; +import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.validation.ValidatorFactory; @@ -25,8 +29,8 @@ import org.apache.commons.io.FilenameUtils; import org.slf4j.LoggerFactory; import org.springframework.context.MessageSource; import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.core.io.ByteArrayResource; import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.transaction.annotation.Transactional; @@ -45,6 +49,7 @@ public class StorageFileController { private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(StorageFileController.class)); private final AuditService auditService; private final QueryFactory queryFactory; + private final BuilderFactory builderFactory; private final MessageSource messageSource; private final StorageFileService storageFileService; private final StorageFileProperties config; @@ -55,13 +60,14 @@ public class StorageFileController { public StorageFileController( AuditService auditService, QueryFactory queryFactory, - MessageSource messageSource, + BuilderFactory builderFactory, MessageSource messageSource, StorageFileService storageFileService, StorageFileProperties config, UserScope userScope, AuthorizationService authorizationService, ConventionService conventionService, ValidatorFactory validatorFactory) { this.auditService = auditService; this.queryFactory = queryFactory; + this.builderFactory = builderFactory; this.messageSource = messageSource; this.storageFileService = storageFileService; this.config = config; @@ -71,21 +77,23 @@ public class StorageFileController { this.validatorFactory = validatorFactory; } - @GetMapping("/name/{id}") - public String getName(@PathVariable("id") UUID id) throws MyApplicationException, MyForbiddenException, MyNotFoundException { - logger.debug(new MapLogEntry("get name" ).And("id", id)); + @GetMapping("{id}") + public StorageFile get(@PathVariable("id") UUID id, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException { + logger.debug(new MapLogEntry("retrieving " + StorageFile.class.getSimpleName()).And("id", id).And("fields", fieldSet)); this.authorizationService.authorizeForce(Permission.BrowseStorageFile); - StorageFileEntity storageFile = this.queryFactory.query(StorageFileQuery.class).ids(id).firstAs(new BaseFieldSet().ensure(StorageFile._fullName)); - if (storageFile == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, StorageFile.class.getSimpleName()}, LocaleContextHolder.getLocale())); + StorageFileQuery query = this.queryFactory.query(StorageFileQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id); + StorageFile model = this.builderFactory.builder(StorageFileBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet)); + if (model == null) + throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, StorageFile.class.getSimpleName()}, LocaleContextHolder.getLocale())); - this.auditService.track(AuditableAction.StorageFile_Download, Map.ofEntries( - new AbstractMap.SimpleEntry("id", id) + this.auditService.track(AuditableAction.StorageFile_Query, Map.ofEntries( + new AbstractMap.SimpleEntry("id", id), + new AbstractMap.SimpleEntry("fields", fieldSet) )); - - return storageFile.getName(); + return model; } @@ -115,8 +123,8 @@ public class StorageFileController { return addedFiles; } - @GetMapping("{id}") - public ResponseEntity get(@PathVariable("id") UUID id) throws MyApplicationException, MyForbiddenException, MyNotFoundException { + @GetMapping("download/{id}") + public ResponseEntity get(@PathVariable("id") UUID id) throws MyApplicationException, MyForbiddenException, MyNotFoundException { logger.debug(new MapLogEntry("download" ).And("id", id)); this.authorizationService.authorizeForce(Permission.BrowseStorageFile); @@ -134,10 +142,14 @@ public class StorageFileController { String contentType = storageFile.getMimeType(); if (this.conventionService.isNullOrEmpty(contentType)) contentType = MediaType.APPLICATION_OCTET_STREAM_VALUE; - return ResponseEntity.ok() - .contentType(MediaType.valueOf(contentType)) - .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + storageFile.getName() + (storageFile.getExtension().startsWith(".") ? "" : ".") + storageFile.getExtension() + "\"") - .body(new ByteArrayResource(file)); + HttpHeaders responseHeaders = new HttpHeaders(); + responseHeaders.setContentLength(file.length); + responseHeaders.setContentType(MediaType.valueOf(contentType)); + responseHeaders.set("Content-Disposition", "attachment; filename=\"" + storageFile.getName() + (storageFile.getExtension().startsWith(".") ? "" : ".") + storageFile.getExtension() + "\""); + responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition"); + responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type"); + + return new ResponseEntity<>(file, responseHeaders, HttpStatus.OK); } } diff --git a/dmp-frontend/src/app/core/services/storage-file/storage-file.service.ts b/dmp-frontend/src/app/core/services/storage-file/storage-file.service.ts index b228e0091..ae1f33a4e 100644 --- a/dmp-frontend/src/app/core/services/storage-file/storage-file.service.ts +++ b/dmp-frontend/src/app/core/services/storage-file/storage-file.service.ts @@ -21,20 +21,25 @@ export class StorageFileService { private get apiBase(): string { return `${this.configurationService.server}storage-file`; } - getName(id: Guid ): Observable { - const url = `${this.apiBase}/name/${id}`; + getSingle(id: Guid, reqFields: string[] = []): Observable { + const url = `${this.apiBase}/${id}`; + const options = { params: { f: reqFields } }; return this.http - .get(url).pipe( + .get(url, options).pipe( catchError((error: any) => throwError(error))); } download(id: Guid ): Observable> { - const url = `${this.apiBase}/${id}`; + const url = `${this.apiBase}/download/${id}`; + + const params = new BaseHttpParams(); + params.interceptorContext = { + excludedInterceptors: [InterceptorType.JSONContentType, InterceptorType.ResponsePayload] + }; return this.http - .get>(url).pipe( - catchError((error: any) => throwError(error))); + .get(url, {params: params, responeType: 'blob', observe: 'response'}); } uploadTempFiles(item: File): Observable { diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.html index 8fed87433..1701b1b4b 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.html @@ -177,8 +177,8 @@ - - + + \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.html b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.html index e8fa69b76..a577c8820 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.html +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.html @@ -47,13 +47,13 @@
- + {{propertiesFormGroup?.get(field.id).get('textListValue').getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}} - + {{propertiesFormGroup?.get(field.id).get('textValue').getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}} @@ -62,17 +62,17 @@
-
+
- + {{propertiesFormGroup?.get(field.id).get('textListValue').getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}} - + {{propertiesFormGroup?.get(field.id).get('textValue').getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}} @@ -107,9 +107,9 @@
- - - {{ fileNameDisplay}} + + + {{ fileNameDisplay }}
@@ -157,7 +157,7 @@
- + {{'GENERAL.VALIDATION.REQUIRED' | translate}}
diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.ts b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.ts index 46991c269..db8bb346d 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.ts +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.ts @@ -6,10 +6,13 @@ import { MatDialog } from "@angular/material/dialog"; import { DescriptionTemplateFieldType } from '@app/core/common/enum/description-template-field-type'; import { DescriptionTemplateFieldValidationType } from '@app/core/common/enum/description-template-field-validation-type'; import { DescriptionTemplateField, DescriptionTemplateFieldSet, DescriptionTemplateLabelAndMultiplicityData, DescriptionTemplateUploadData } from '@app/core/model/description-template/description-template'; +import { StorageFile } from '@app/core/model/storage-file/storage-file'; +import { DescriptionService } from '@app/core/services/description/description.service'; import { DmpService } from '@app/core/services/dmp/dmp.service'; import { SnackBarNotificationLevel, UiNotificationService } from "@app/core/services/notification/ui-notification-service"; import { ReferenceService } from '@app/core/services/reference/reference.service'; import { StorageFileService } from '@app/core/services/storage-file/storage-file.service'; +import { TagService } from '@app/core/services/tag/tag.service'; import { FileUtils } from '@app/core/services/utilities/file-utils.service'; import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration'; @@ -21,6 +24,7 @@ import { TranslateService } from '@ngx-translate/core'; import * as FileSaver from 'file-saver'; import { Observable } from 'rxjs'; import { distinctUntilChanged, map, takeUntil } from 'rxjs/operators'; +import { nameof } from 'ts-simple-nameof'; @Component({ selector: 'app-description-form-field', @@ -70,11 +74,13 @@ export class DescriptionFormFieldComponent extends BaseComponent implements OnIn ]; filesToUpload: FileList; - fileNameDisplay: string; + fileNameDisplay: string = null; constructor( private language: TranslateService, - private dmpService: DmpService, + public dmpService: DmpService, + public descriptionService: DescriptionService, + public tagService: TagService, private cdr: ChangeDetectorRef, private uiNotificationService: UiNotificationService, public dialog: MatDialog, @@ -92,8 +98,24 @@ export class DescriptionFormFieldComponent extends BaseComponent implements OnIn ngOnInit() { - if(this.field?.data?.fieldType == DescriptionTemplateFieldType.UPLOAD && this.field && this.field.id && (this.propertiesFormGroup?.get(this.field.id).get('textValue').value != undefined)) this.getUploadFileName(); + if(this.field?.data?.fieldType == DescriptionTemplateFieldType.UPLOAD && this.field && this.field.id && (this.propertiesFormGroup?.get(this.field.id).get('textValue').value != undefined) && !this.fileNameDisplay) { + const id = Guid.parse((this.propertiesFormGroup?.get(this.field.id).get('textValue').value as string)); + const fields = [ + nameof(x => x.id), + nameof(x => x.name), + ] + + this.storageFileService.getSingle(id, fields).pipe(takeUntil(this._destroyed)).subscribe(storageFile => { + this.fileNameDisplay = storageFile.name; + this.applyFieldType(); + }); + } else { + this.applyFieldType(); + } + } + + private applyFieldType(){ this.isRequired = this.field.validations?.includes(DescriptionTemplateFieldValidationType.Required); switch (this.field?.data?.fieldType) { @@ -140,12 +162,6 @@ export class DescriptionFormFieldComponent extends BaseComponent implements OnIn // this.form.disable(); // } break; - case DescriptionTemplateFieldType.INTERNAL_ENTRIES_DESCRIPTIONS: - this.makeAutocompleteConfiguration(this.searchDatasets.bind(this), "label"); - break; - case DescriptionTemplateFieldType.INTERNAL_ENTRIES_DMPS: - this.makeAutocompleteConfiguration(this.searchDmps.bind(this), "label"); - break; } // this.form = this.visibilityRulesService.getFormGroup(this.field.id); @@ -161,28 +177,6 @@ export class DescriptionFormFieldComponent extends BaseComponent implements OnIn }); } - searchDatasets(query: string) { - //TODO refactor - return null; - // let fields: Array = new Array(); - // const datasetsAutocompleteRequestItem: DataTableRequest = new DataTableRequest(0, 25, { fields: fields }); - // datasetsAutocompleteRequestItem.criteria = new DatasetCriteria(); - // datasetsAutocompleteRequestItem.criteria.like = query; - // //TODO: refactor this - // // return this.datasetService.getPaged(datasetsAutocompleteRequestItem).pipe(map(item => item.data)); - // return null; - } - - searchDmps(query: string) { - //TODO refactor - return null; - // let fields: Array = new Array(); - // const dmpsAutocompleteRequestItem: DataTableRequest = new DataTableRequest(0, 25, { fields: fields }); - // dmpsAutocompleteRequestItem.criteria = new DmpCriteria(); - // dmpsAutocompleteRequestItem.criteria.like = query; - // return this.dmpService.getPaged(dmpsAutocompleteRequestItem).pipe(map(item => item.data)); - } - makeAutocompleteConfiguration(myfunc: Function, title: string, subtitle?: string): void { if (!((this.field.data as DescriptionTemplateLabelAndMultiplicityData).multipleSelect)) { this.singleAutoCompleteConfiguration = { @@ -275,16 +269,6 @@ export class DescriptionFormFieldComponent extends BaseComponent implements OnIn } - private getUploadFileName(){ - const id = Guid.parse((this.propertiesFormGroup?.get(this.field.id).get('textValue').value as string)); - - this.storageFileService.getName(id) - .pipe(takeUntil(this._destroyed)).subscribe((name) => { - this.fileNameDisplay = name; - }, error => { - this.fileNameDisplay = null; - }) - } public upload() { this.storageFileService.uploadTempFiles(this.filesToUpload[0]) @@ -364,13 +348,12 @@ export class DescriptionFormFieldComponent extends BaseComponent implements OnIn if (this.propertiesFormGroup?.get(this.field.id).get('textValue').value) { const id = Guid.parse((this.propertiesFormGroup?.get(this.field.id).get('textValue').value as string)); - this.storageFileService.download(id).subscribe((response) => { - const blob = new Blob([response.body]); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - FileSaver.saveAs(blob, filename); - }, error => { - this.onCallbackUploadFail(error.error); - }) + this.storageFileService.download(id).pipe(takeUntil(this._destroyed)) + .subscribe(response => { + const blob = new Blob([response.body]); + const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); + FileSaver.saveAs(blob, filename); + }); } }