Revert "SUPPORT-8438 ready 2 roll"

This reverts commit 25ee603e
This commit is contained in:
ivanov.denis 2024-07-24 16:39:26 +03:00
parent f60e0fd9e4
commit f07e6a2310
4 changed files with 32 additions and 117 deletions

View file

@ -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<String, String> 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"));
}
}

View file

@ -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();
}
}

View file

@ -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}. `

View file

@ -714,12 +714,6 @@
<simple>false</simple>
</value>
</entry>
<entry>
<key>formType</key>
<value>
<simple>"FORM_2"</simple>
</value>
</entry>
<entry>
<key>maxFilesToUpload</key>
<value>
@ -4996,30 +4990,6 @@
</entry>
</properties>
</scripts>
<scripts id="87ab8176-752d-4cd1-8afb-bf2cbfb020c9">
<classRef type="JAVA">
<className>ErvuFileUploadRpcService</className>
<packageName>rpc</packageName>
</classRef>
<enabled>true</enabled>
<expanded>true</expanded>
</scripts>
<scripts id="8e45a506-eb23-426e-85bd-87f02aee6f6f">
<classRef type="JAVA">
<className>EmployeeInfoFileUploadService</className>
<packageName>ervu.service.fileupload</packageName>
</classRef>
<enabled>true</enabled>
<expanded>true</expanded>
<properties>
<entry>
<key>maxFileSize</key>
<value>
<simple>10</simple>
</value>
</entry>
</properties>
</scripts>
</rootObjects>
<rootObjects id="a0eb2a9a-94b5-4906-807b-eab28985625d">
<prototypeId>fd7e47b9-dce1-4d14-9f3a-580c79f59579</prototypeId>