diff --git a/backend/src/main/java/ervu/service/fileupload/EmployeeInfoFileUploadService.java b/backend/src/main/java/ervu/service/fileupload/EmployeeInfoFileUploadService.java index 18aff242..825cfcbd 100644 --- a/backend/src/main/java/ervu/service/fileupload/EmployeeInfoFileUploadService.java +++ b/backend/src/main/java/ervu/service/fileupload/EmployeeInfoFileUploadService.java @@ -15,19 +15,12 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.kafka.core.KafkaTemplate; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; -import ru.cg.webbpm.modules.standard_annotations.validation.NotNull; -import ru.cg.webbpm.modules.webkit.beans.Behavior; /** * @author Alexandr Shalaginov */ - @Service -public class EmployeeInfoFileUploadService extends Behavior { - - @NotNull - public int maxFileSize; - +public class EmployeeInfoFileUploadService { private static final Logger logger = LoggerFactory.getLogger(EmployeeInfoFileUploadService.class); private final FileUploadWebDavClient fileWebDavUploadClient; @@ -72,10 +65,6 @@ public class EmployeeInfoFileUploadService extends Behavior { } } - public int getMaxFileSize() { - return this.maxFileSize; - } - private boolean sendMessage(String message) { ProducerRecord record = new ProducerRecord<>(this.kafkaTopicName, message); try { @@ -114,5 +103,4 @@ public class EmployeeInfoFileUploadService extends Behavior { private String getDepartureDateTime() { return LocalDateTime.now().format(DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm")); } - } \ No newline at end of file diff --git a/backend/src/main/java/rpc/ErvuFileUploadRpcService.java b/backend/src/main/java/rpc/ErvuFileUploadRpcService.java deleted file mode 100644 index c78d0a28..00000000 --- a/backend/src/main/java/rpc/ErvuFileUploadRpcService.java +++ /dev/null @@ -1,30 +0,0 @@ -package rpc; - -import ervu.service.fileupload.EmployeeInfoFileUploadService; -import org.springframework.beans.factory.annotation.Autowired; -import ru.cg.webbpm.modules.standard_annotations.validation.NotNull; -import ru.cg.webbpm.modules.webkit.annotations.RpcCall; -import ru.cg.webbpm.modules.webkit.annotations.RpcService; -import ru.cg.webbpm.modules.webkit.beans.Behavior; - -/** - * @author Ivanov Denov - */ - -@RpcService - public class ErvuFileUploadRpcService extends Behavior { - - private EmployeeInfoFileUploadService service; - - @Override - protected void start() { - super.start(); - this.service = this.getScript(EmployeeInfoFileUploadService.class); - } - - @RpcCall - public int getMaxFileSize() { - return this.service.getMaxFileSize(); - } - -} diff --git a/frontend/src/ts/ervu/component/fileupload/ErvuFileUpload.ts b/frontend/src/ts/ervu/component/fileupload/ErvuFileUpload.ts index 4a94cf0c..d135739c 100644 --- a/frontend/src/ts/ervu/component/fileupload/ErvuFileUpload.ts +++ b/frontend/src/ts/ervu/component/fileupload/ErvuFileUpload.ts @@ -10,7 +10,6 @@ import {ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef} from import {FileItem, FileUploader} from "ng2-file-upload"; import {FileLikeObject} from "ng2-file-upload/file-upload/file-like-object.class"; import {EmployeeInfoFileFormType} from "./EmployeeInfoFileFormType"; -import {ErvuFileUploadRpcService} from "../../../generated/rpc/ErvuFileUploadRpcService"; @Component({ moduleId: module.id, @@ -19,13 +18,13 @@ import {ErvuFileUploadRpcService} from "../../../generated/rpc/ErvuFileUploadRpc changeDetection: ChangeDetectionStrategy.OnPush }) export class ErvuFileUpload extends InputControl { - @NotNull("true") public selectFileFieldText: string; @NotNull("true") public selectFileButtonName: string; @NotNull("true") public removeFileButtonName: string; + public maxFileSizeMb: number; public extensionFilter: string[] = []; public maxFilesToUpload: number; @NotNull("true") @@ -52,7 +51,6 @@ export class ErvuFileUpload extends InputControl { protected isFilesListVisible: boolean = true; protected isProgressBarVisible: boolean = false; - private rpcService: ErvuFileUploadRpcService; private fileInputEl: any; private url: string = '/backend/employee/document'; private messagesService: MessagesService; @@ -65,16 +63,34 @@ export class ErvuFileUpload extends InputControl { initialize() { super.initialize(); this.messagesService = this.injector.get(MessagesService); - this.rpcService = this.getScript(ErvuFileUploadRpcService); - if (!this.rpcService) { - this.setUploaderOptions(undefined); - this.setUploaderMethods(undefined); - return; - } - this.rpcService.getMaxFileSize().then(fileSize => { - this.setUploaderOptions(fileSize); - this.setUploaderMethods(fileSize); + + this.uploader.setOptions({ + url: this.url, + autoUpload: false, + filters: [{ + name: 'extension', + fn: (item: any): boolean => { + if (!this.extensionFilter.length) { + return true; + } + const fileExtension = item.name.substring(item.name.lastIndexOf('.') + 1, item.name.length); + for (let ext of this.extensionFilter) { + if (ext.toUpperCase() === fileExtension.toUpperCase()) { + return true; + } + } + return false; + } + }], + maxFileSize: this.maxFileSizeMb ? this.maxFileSizeMb * 1024 * 1024 : undefined, + queueLimit: this.maxFilesToUpload ? this.maxFilesToUpload : undefined, + headers: [{ + name: "X-Employee-Info-File-Form-Type", + value: EmployeeInfoFileFormType[this.formType] + }] }); + + this.setUploaderMethods(); } ngAfterViewInit() { @@ -96,35 +112,7 @@ export class ErvuFileUpload extends InputControl { this.fileDeletedEvent.trigger(); } - private setUploaderOptions(maxFileSize: number) { - this.uploader.setOptions({ - url: this.url, - autoUpload: false, - filters: [{ - name: 'extension', - fn: (item: any): boolean => { - if (!this.extensionFilter.length) { - return true; - } - const fileExtension = item.name.substring(item.name.lastIndexOf('.') + 1, item.name.length); - for (let ext of this.extensionFilter) { - if (ext.toUpperCase() === fileExtension.toUpperCase()) { - return true; - } - } - return false; - } - }], - maxFileSize: maxFileSize * 1024 * 1024, - queueLimit: this.maxFilesToUpload ? this.maxFilesToUpload : undefined, - headers: [{ - name: "X-Employee-Info-File-Form-Type", - value: EmployeeInfoFileFormType[this.formType] - }] - }); - } - - private setUploaderMethods(maxFileSize: number) { + private setUploaderMethods() { this.uploader.onBeforeUploadItem = (fileItem: FileItem) => { this.fileUploadStartEvent.trigger(); this.isDropZoneVisible = false; @@ -157,13 +145,12 @@ export class ErvuFileUpload extends InputControl { this.uploader.onAfterAddingFile = (fileItem: FileItem) => { this.fileAddedEvent.trigger(); - }; + } this.uploader.onWhenAddingFileFailed = (item: FileLikeObject, filter: any, options: any) => { switch (filter.name) { case "fileSize": - // при maxFileSize = undefined будет бред, но тогда и нет повода показывать сообщения когда-либо - this.messagesService.error(`Размер файла ${item.name} превышает предельно допустимый = ${maxFileSize} MB`); + this.messagesService.error(`Размер файла ${item.name} превышает предельно допустимый = ${this.maxFileSizeMb} MB`); break; case "queueLimit": this.messagesService.error(`Не удалось добавить файл ${item.name}. ` diff --git a/resources/src/main/resources/business-model/Личный кабинет юр лица.page b/resources/src/main/resources/business-model/Личный кабинет юр лица.page index 13f1aaac..c6eb6222 100644 --- a/resources/src/main/resources/business-model/Личный кабинет юр лица.page +++ b/resources/src/main/resources/business-model/Личный кабинет юр лица.page @@ -714,12 +714,6 @@ false - - formType - - "FORM_2" - - maxFilesToUpload @@ -4996,30 +4990,6 @@ - - - ErvuFileUploadRpcService - rpc - - true - true - - - - EmployeeInfoFileUploadService - ervu.service.fileupload - - true - true - - - maxFileSize - - 10 - - - - fd7e47b9-dce1-4d14-9f3a-580c79f59579