diff --git a/src/main/java/ru/ulstu/file/FileController.java b/src/main/java/ru/ulstu/file/FileController.java
index e60626b..f68b820 100644
--- a/src/main/java/ru/ulstu/file/FileController.java
+++ b/src/main/java/ru/ulstu/file/FileController.java
@@ -3,12 +3,7 @@ package ru.ulstu.file;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import ru.ulstu.configuration.Constants;
import ru.ulstu.core.model.response.Response;
@@ -51,7 +46,7 @@ public class FileController {
}
@PostMapping("/uploadTmpFile")
- public Response upload(@RequestParam("file") MultipartFile multipartFile) throws IOException {
- return new Response(fileService.uploadToTmpDir(multipartFile));
+ public Response
-
@@ -189,15 +191,72 @@
div: "loader",
url: urlFileUpload,
maxSize: 1.5,
- extensions: ["doc", "docx", "xls", "jpg", "pdf", "txt", "png"],
+ extensions: [],
callback: function (response) {
showFeedbackMessage("Файл успешно загружен");
console.debug(response);
+
+ addNewFile(response);
}
});
$('.selectpicker').selectpicker();
});
/*]]>*/
+ function addNewFile(fileNames) {
+ var filesList = $("#files-list");
+ var fileNumber = $("#files-list div.row").length;
+
+ var newFileRow = $("
")
+ .attr("id", 'files' + fileNumber)
+ .addClass("row");
+
+ var idInput = $("
")
+ .attr("type", "hidden")
+ .attr("id", "files" + fileNumber + ".id")
+ .attr("value", '')
+ .attr("name", "files[" + fileNumber + "].id");
+ newFileRow.append(idInput);
+
+ var flagInput = $("
")
+ .attr("type", "hidden")
+ .attr("id", "files" + fileNumber + ".deleteFlag")
+ .attr("value", "false")
+ .attr("name", "files[" + fileNumber + "].deleteFlag");
+ newFileRow.append(flagInput);
+
+ var nameInput = $("
")
+ .attr("type", "hidden")
+ .attr("id", "files" + fileNumber + ".name")
+ .attr("value", tmpFileName[1])
+ .attr("name", "files[" + fileNumber + "].name");
+ newFileRow.append(nameInput);
+
+ var tmpFileNameInput = $("
")
+ .attr("type", "hidden")
+ .attr("id", "files" + fileNumber + ".tmpFileName")
+ .attr("value", tmpFileName[0])
+ .attr("name", "files[" + fileNumber + "].tmpFileName");
+ newFileRow.append(tmpFileNameInput);
+
+ var nextDiv = $("
")
+ .addClass("col-2");
+
+ var nextA = $("
")
+ .addClass("btn btn-danger float-right")
+ .attr("onclick", "$('#files" + fileNumber + "\\\\.deleteFlag').val('true'); $('#files" + fileNumber + "').hide();")
+ .append(($("
").attr("aria-hidden", "true")).append($("
").addClass("fa fa-times")))
+ ;
+ nextDiv.append(nextA)
+ newFileRow.append(nextDiv);
+
+ var nameDiv = $("
")
+ .addClass("col-10")
+ .append($("
").text(tmpFileName[1]));
+ newFileRow.append(nameDiv);
+
+ $("#files-list").append(newFileRow);
+
+ }