From 1cac696ddef27a8edd963870a3bd01e43cd4d6c1 Mon Sep 17 00:00:00 2001 From: MK13 Date: Mon, 23 Jan 2023 23:13:22 +0100 Subject: [PATCH] #2 Folder sharing fixup --- .../files/controller/FilesController.java | 40 ++++++++++++++++++- .../resources/templates/files/filesIndex.html | 8 ++-- .../resources/templates/files/gallery.html | 2 +- .../templates/files/includes/menu.html | 2 +- 4 files changed, 44 insertions(+), 8 deletions(-) diff --git a/files/src/main/java/de/nbscloud/files/controller/FilesController.java b/files/src/main/java/de/nbscloud/files/controller/FilesController.java index b32218a..92790e8 100644 --- a/files/src/main/java/de/nbscloud/files/controller/FilesController.java +++ b/files/src/main/java/de/nbscloud/files/controller/FilesController.java @@ -83,6 +83,7 @@ public class FilesController implements InitializingBean { model.addAttribute("sortOrder", order); model.addAttribute("apps", this.appRegistry.getAll()); model.addAttribute("restricted", this.sessionInfo.isRestrictedSession()); + model.addAttribute("prefix", ""); this.webContainerSharedConfig.addDefaults(model); return "files/filesIndex"; @@ -121,6 +122,7 @@ public class FilesController implements InitializingBean { model.addAttribute("apps", this.appRegistry.getAll()); model.addAttribute("filename", filename); model.addAttribute("restricted", this.sessionInfo.isRestrictedSession()); + model.addAttribute("prefix", ""); this.webContainerSharedConfig.addDefaults(model); return "files/rename"; @@ -148,6 +150,11 @@ public class FilesController implements InitializingBean { return "redirect:/files/browse/" + this.locationTracker.getRelativeLocation(); } + @GetMapping("/files/shares/files/download") + public ResponseEntity sharesDownloadFile(HttpServletResponse response, String filename) { + return downloadFile(response, filename); + } + @GetMapping("/files/download") public ResponseEntity downloadFile(HttpServletResponse response, String filename) { final Path targetPath = this.locationTracker.resolve(filename); @@ -226,6 +233,7 @@ public class FilesController implements InitializingBean { model.addAttribute("apps", this.appRegistry.getAll()); model.addAttribute("filename", filename); model.addAttribute("restricted", this.sessionInfo.isRestrictedSession()); + model.addAttribute("prefix", ""); this.webContainerSharedConfig.addDefaults(model); return "files/share"; @@ -271,6 +279,17 @@ public class FilesController implements InitializingBean { return "redirect:/files/browse/" + this.locationTracker.getRelativeLocation(); } + @GetMapping("/files/shares/files/browse/**") + public String sharesStart(Model model, HttpServletRequest httpServletRequest, String sortOrder) { + final String start = start(model, httpServletRequest, sortOrder); + + model.addAttribute("prefix", "/files/shares"); + + return start; + } + + // We need to copy all functions for shares because they should be available without auth and that is + // controlled by the URI via htaccess/htpasswd @GetMapping("files/shares") public Object shares(Model model, String shareUuid) { this.locationTracker.reset(); @@ -299,8 +318,9 @@ public class FilesController implements InitializingBean { if(this.fileSystemService.isDirectory(sharedFilePath)) { this.locationTracker.setBaseDirPath(share.getPath()); + this.locationTracker.resetCurrentLocation(); - return "redirect:/files/browse"; + return "redirect:/files/browse/"; } else { return doShares(shareUuid); @@ -332,8 +352,9 @@ public class FilesController implements InitializingBean { if(this.fileSystemService.isDirectory(sharedFilePath)) { this.locationTracker.setBaseDirPath(share.getPath()); + this.locationTracker.resetCurrentLocation(); - return "redirect:/files/browse"; + return "redirect:/files/browse/"; } else { return doShares(shareUuid); @@ -385,6 +406,11 @@ public class FilesController implements InitializingBean { } } + @GetMapping("/files/shares/files/preview") + public void sharesPreview(HttpServletResponse response, String filename) { + preview(response, filename); + } + @GetMapping("files/preview") public void preview(HttpServletResponse response, String filename) { try { @@ -398,6 +424,15 @@ public class FilesController implements InitializingBean { } } + @GetMapping("/files/shares/files/gallery") + public String sharesGallery(Model model) { + final String gallery = gallery(model); + + model.addAttribute("prefix", "/files/shares"); + + return gallery; + } + @GetMapping("files/gallery") public String gallery(Model model) { try { @@ -406,6 +441,7 @@ public class FilesController implements InitializingBean { model.addAttribute("files", files); model.addAttribute("apps", this.appRegistry.getAll()); model.addAttribute("restricted", this.sessionInfo.isRestrictedSession()); + model.addAttribute("prefix", ""); this.webContainerSharedConfig.addDefaults(model); return "files/gallery"; diff --git a/files/src/main/resources/templates/files/filesIndex.html b/files/src/main/resources/templates/files/filesIndex.html index c098858..421b041 100644 --- a/files/src/main/resources/templates/files/filesIndex.html +++ b/files/src/main/resources/templates/files/filesIndex.html @@ -49,9 +49,9 @@ d - - -
-
-
diff --git a/files/src/main/resources/templates/files/includes/menu.html b/files/src/main/resources/templates/files/includes/menu.html index 7181e33..96cb4d9 100644 --- a/files/src/main/resources/templates/files/includes/menu.html +++ b/files/src/main/resources/templates/files/includes/menu.html @@ -28,7 +28,7 @@
- +