now the front-end updates the days the file is kept according to the settings

This commit is contained in:
Rostislav Raykov
2024-10-29 20:44:24 +02:00
parent ff5cd56179
commit df279d6bf9
3 changed files with 12 additions and 14 deletions

View File

@@ -1,7 +1,5 @@
package org.rostislav.quickdrop.controller;
import java.util.List;
import jakarta.servlet.http.HttpServletRequest;
import org.rostislav.quickdrop.model.FileEntity;
import org.rostislav.quickdrop.service.FileService;
@@ -16,6 +14,8 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody;
import java.util.List;
import static org.rostislav.quickdrop.util.FileUtils.populateModelAttributes;
@Controller
@@ -24,6 +24,8 @@ public class FileViewController {
private final FileService fileService;
@Value("${max-upload-file-size}")
private String maxFileSize;
@Value("${file.max.age}")
private String maxFileLifeTime;
public FileViewController(FileService fileService) {
this.fileService = fileService;
@@ -32,6 +34,7 @@ public class FileViewController {
@GetMapping("/upload")
public String showUploadFile(Model model) {
model.addAttribute("maxFileSize", maxFileSize);
model.addAttribute("maxFileLifeTime", maxFileLifeTime);
return "upload";
}
@@ -45,6 +48,7 @@ public class FileViewController {
@GetMapping("/{uuid}")
public String filePage(@PathVariable String uuid, Model model, HttpServletRequest request) {
FileEntity fileEntity = fileService.getFile(uuid);
model.addAttribute("maxFileLifeTime", maxFileLifeTime);
String password = (String) request.getSession().getAttribute("password");
if (fileEntity.passwordHash != null &&

View File

@@ -80,17 +80,10 @@
<p class="card-text mb-0"
th:text="${file.uploadDate}"></p>
</div>
<small class="text-muted">Files
are
kept
only
for
30
days
after
this
date.</small>
<small class="text-muted"
th:if="${file.keepIndefinitely == false}">
Files are kept only for <span th:text="${maxFileLifeTime}">30</span> days after this date.
</small>
<div class="d-flex justify-content-between align-items-center pt-3">
<h5 class="card-title">
Keep

View File

@@ -67,7 +67,8 @@
are
deleted
after
30
<span class="maxFileLifeTime"
th:text="${maxFileLifeTime}">30</span>
days
if
the